@@ -10,104 +10,9 @@ import { editorChangeHandler, fileSaveListener, moveNeuroCursorHere, toggleSaveA
1010import { emergencyDenyRequests , acceptRceRequest , denyRceRequest , revealRceNotification } from '../rce' ;
1111import type { GitExtension } from '../types/git' ;
1212import { getGitExtension } from '../git' ;
13-
14- // Shared docs management
15- let docsOptions : Record < string , string > ;
16- let docsItems : string [ ] ;
17-
18- export function registerDocsLink ( name : string , link : string ) {
19- docsOptions [ name ] = link ;
20- docsItems = Object . keys ( docsOptions ) ;
21- }
22-
23- function initializeDocsOptions ( ) {
24- docsOptions = {
25- 'NeuroPilot' : CONFIG . docsURL ,
26- 'NeuroPilot (Local Dev Default)' : 'http://127.0.0.1:4321/neuropilot' ,
27- } ;
28- docsItems = Object . keys ( docsOptions ) ;
29- }
13+ import { registerDocsCommands , registerDocsLink } from './docs' ;
3014
3115// Shared commands
32- export function registerDocsCommands ( ) {
33- const showDocsCommand = vscode . commands . registerCommand ( 'neuropilot.showDocsHomepage' , async ( ) => {
34- const quickPick = vscode . window . createQuickPick ( ) ;
35- quickPick . items = docsItems . map ( key => ( { label : key } ) ) ;
36- quickPick . placeholder = 'Select a documentation base URL' ;
37-
38- quickPick . onDidAccept ( async ( ) => {
39- const selectedOption = quickPick . selectedItems [ 0 ] ?. label ;
40- if ( ! selectedOption ) {
41- vscode . window . showErrorMessage ( 'No documentation option selected.' ) ;
42- quickPick . hide ( ) ;
43- return ;
44- }
45-
46- const baseUrl = docsOptions [ selectedOption ] ;
47- logOutput ( 'DEBUG' , `Opening ${ selectedOption } 's docs at URL ${ baseUrl } ` ) ;
48-
49- const panel = vscode . window . createWebviewPanel (
50- 'docsWebView' ,
51- `${ selectedOption } Docs (WebView)` ,
52- vscode . ViewColumn . Active ,
53- { enableScripts : true } ,
54- ) ;
55- panel . webview . html = openDocsPage ( baseUrl ) ;
56- quickPick . hide ( ) ;
57- } ) ;
58-
59- quickPick . show ( ) ;
60- } ) ;
61-
62- const openSpecificDocsCommand = vscode . commands . registerCommand ( 'neuropilot.openSpecificDocsPage' , async ( args ?: { subpage ?: string } ) => {
63- const quickPick = vscode . window . createQuickPick ( ) ;
64- quickPick . items = docsItems . map ( key => ( { label : key } ) ) ;
65- quickPick . placeholder = 'Select a documentation base URL' ;
66-
67- quickPick . onDidAccept ( async ( ) => {
68- const selectedOption = quickPick . selectedItems [ 0 ] ?. label ;
69- if ( ! selectedOption ) {
70- vscode . window . showErrorMessage ( 'No documentation option selected.' ) ;
71- quickPick . hide ( ) ;
72- return ;
73- }
74-
75- const baseUrl = docsOptions [ selectedOption ] ;
76-
77- let subpage : string | undefined ;
78- if ( args && typeof args . subpage === 'string' ) {
79- subpage = args . subpage ;
80- } else {
81- subpage = await vscode . window . showInputBox ( {
82- prompt : 'Enter the docs subpath (e.g., /guide, /api, etc.)' ,
83- placeHolder : '/' ,
84- } ) ;
85- }
86-
87- if ( ! subpage ) {
88- vscode . window . showErrorMessage ( 'No subpage specified.' ) ;
89- quickPick . hide ( ) ;
90- return ;
91- }
92-
93- logOutput ( 'DEBUG' , `Opening ${ selectedOption } 's docs at URL ${ baseUrl } ${ subpage } ` ) ;
94-
95- const panel = vscode . window . createWebviewPanel (
96- 'docsWebView' ,
97- `${ selectedOption } Docs (WebView)` ,
98- vscode . ViewColumn . Active ,
99- { enableScripts : true } ,
100- ) ;
101- panel . webview . html = openDocsPage ( baseUrl , subpage ) ;
102- quickPick . hide ( ) ;
103- } ) ;
104-
105- quickPick . show ( ) ;
106- } ) ;
107-
108- return [ showDocsCommand , openSpecificDocsCommand ] ;
109- }
110-
11116export function registerCommonCommands ( ) {
11217 return [
11318 vscode . commands . registerCommand ( 'neuropilot.reconnect' , reconnect ) ,
@@ -172,8 +77,6 @@ export function setupCommonEventHandlers() {
17277}
17378
17479export function initializeCommonState ( context : vscode . ExtensionContext ) {
175- initializeDocsOptions ( ) ;
176-
17780 NEURO . context = context ;
17881 NEURO . url = CONFIG . websocketUrl ;
17982 NEURO . gameName = CONFIG . gameName ;
@@ -307,47 +210,6 @@ function switchCurrentNeuroAPIUser() {
307210 quickPick . show ( ) ;
308211}
309212
310- function openDocsPage ( docsSite : string , subpage = '/' ) : string {
311- let constructedDocsPage : string = docsSite ;
312- if ( subpage . startsWith ( '/' ) ) {
313- constructedDocsPage += subpage ;
314- } else {
315- constructedDocsPage += '/' + subpage ;
316- }
317-
318- logOutput ( 'DEBUG' , `Constructed docs page is ${ constructedDocsPage } ` ) ;
319-
320- const docsOrigin = new URL ( docsSite ) . origin ;
321-
322- const htmlpage =
323- '<!DOCTYPE html>' +
324- '<html lang="en">' +
325- '<head>' +
326- ' <meta charset="UTF-8">' +
327- ` <meta http-equiv="Content-Security-Policy" content="default-src 'none'; frame-src ${ docsOrigin } ; script-src 'none'; style-src 'unsafe-inline';">` +
328- ' <meta name="viewport" content="width=device-width, initial-scale=1.0">' +
329- ' <title>NeuroPilot Docs WebView</title>' +
330- ' <style>' +
331- ' html, body, iframe {' +
332- ' width: 100%;' +
333- ' height: 100%;' +
334- ' margin: 0;' +
335- ' padding: 0;' +
336- ' overflow: hidden;' +
337- ' }' +
338- ' iframe {' +
339- ' display: block;' +
340- ' }' +
341- ' </style>' +
342- '</head>' +
343- '<body>' +
344- ` <iframe src="${ constructedDocsPage } " frameborder="0"></iframe>` +
345- '</body>' +
346- '</html>' ;
347-
348- return htmlpage ;
349- }
350-
351213export function obtainExtensionState ( ) : void {
352214 const copilotChat = vscode . extensions . getExtension ( 'github.copilot-chat' ) ?. isActive ;
353215 EXTENSIONS . copilotChat = copilotChat === true ;
0 commit comments