Skip to content

Commit

Permalink
it works, but I need to clean things up
Browse files Browse the repository at this point in the history
  • Loading branch information
sadasant committed May 26, 2022
1 parent 7b15848 commit 52e5687
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/platform/common/net/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ import * as fetch from 'cross-fetch';

@injectable()
export class HttpClient implements IHttpClient {
public readonly requestOptions: RequestInit;
public readonly requestOptions: RequestInit = {};
constructor(@inject(IWorkspaceService) workspaceService: IWorkspaceService) {
this.requestOptions = { headers: { proxy: workspaceService.getConfiguration('http').get('proxy', '') } };
const proxy = workspaceService.getConfiguration('http').get('proxy', '');
if (proxy) {
this.requestOptions = { headers: { proxy: workspaceService.getConfiguration('http').get('proxy', '') } };
}
}

public async downloadFile(uri: string): Promise<Response> {
Expand Down
2 changes: 2 additions & 0 deletions src/platform/common/platform/fileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export class FileSystem implements IFileSystem {
}

async getFiles(dir: vscode.Uri): Promise<vscode.Uri[]> {
console.log('getFiles', { dir });
const files = await this.vscfs.readDirectory(dir);
console.log({ files });
return files.filter((f) => f[1] === vscode.FileType.File).map((f) => vscode.Uri.file(f[0]));
}

Expand Down
5 changes: 2 additions & 3 deletions src/webviews/extension-side/variablesView/variableView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { Telemetry } from '../../webview-side/common/constants';
import { DataViewerChecker } from '../dataviewer/dataViewerChecker';
import { IJupyterVariableDataProviderFactory, IDataViewerFactory, IDataViewer } from '../dataviewer/types';
import { WebviewViewHost } from '../webviewViewHost';
import { joinPath } from '../../../platform/vscode-path/resources';

// This is the client side host for the native notebook variable view webview
// It handles passing messages to and from the react view as well as the connection
Expand All @@ -59,14 +58,14 @@ export class VariableView extends WebviewViewHost<IVariableViewPanelMapping> imp
private readonly commandManager: ICommandManager,
private readonly documentManager: IDocumentManager
) {
const variableViewDir = joinPath(context.extensionUri, 'out', 'webviews', 'webview-side', 'viewers');
const variableViewDir = Uri.joinPath(context.extensionUri, 'out', 'webviews', 'webview-side', 'viewers');
super(
configuration,
workspaceService,
(c, d) => new VariableViewMessageListener(c, d),
provider,
variableViewDir,
[joinPath(variableViewDir, 'variableView.js')]
[Uri.joinPath(variableViewDir, 'variableView.js')]
);

// Sign up if the active variable view notebook is changed, restarted or updated
Expand Down
15 changes: 14 additions & 1 deletion src/webviews/extension-side/webviews/webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,24 @@ export abstract class Webview implements IWebview {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
protected async generateLocalReactHtml() {
console.log('AAAAAA');
if (!this.webviewHost?.webview) {
throw new Error('WebView not initialized, too early to get a Uri');
}
console.log('BBBBBB');

const uriBase = this.webviewHost?.webview.asWebviewUri(this.options.cwd).toString();
console.log({ uriBase });
const uris = this.options.scripts.map((script) => this.webviewHost!.webview!.asWebviewUri(script));
const testFiles = await this.fs.getFiles(this.options.rootPath);
console.log({ uris });
let testFiles: Uri[] = [];
try {
testFiles = await this.fs.getFiles(this.options.rootPath);
} catch (e) {
console.log(e);
}

console.log({ testFiles });

// This method must be called so VSC is aware of files that can be pulled.
// Allow js and js.map files to be loaded by webpack in the webview.
Expand All @@ -103,6 +114,7 @@ export abstract class Webview implements IWebview {
)
)
.toString();
console.log({ rootPath, fontAwesomePath });

// Change to `true` to force on Test middleware for our react code
const forceTestMiddleware = 'false';
Expand Down Expand Up @@ -148,6 +160,7 @@ export abstract class Webview implements IWebview {
try {
if (this.webviewHost?.webview) {
const localFilesExist = await Promise.all(this.options.scripts.map((s) => this.fs.exists(s)));
console.log({ scripts: this.options.scripts, localFilesExist });
if (localFilesExist.every((exists) => exists === true)) {
// Call our special function that sticks this script inside of an html page
// and translates all of the paths to vscode-resource URIs
Expand Down

0 comments on commit 52e5687

Please sign in to comment.