Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support using a CDN for widgets #10076

Merged
merged 15 commits into from
May 20, 2022
Merged

Support using a CDN for widgets #10076

merged 15 commits into from
May 20, 2022

Conversation

rchiodo
Copy link
Contributor

@rchiodo rchiodo commented May 19, 2022

Fixes #9984

Most widgets will work after this change but not all. Some require js to load from the jupyter server and that requires some changes in VS code to accomplish #10060

@rchiodo rchiodo requested a review from a team as a code owner May 19, 2022 23:07
@@ -19,11 +19,11 @@ export class ScriptUriConverter implements ILocalResourceUriConverter {
return this.requestUriEmitter.event;
}
public get rootScriptFolder(): Uri {
return Uri.file(this._rootScriptFolder);
return this._rootScriptFolder;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file isn't node specific anymore, but doesn't actually work in the web because we can't write to the extensionUri location. It isn't used for web right now but once #10060 is implemented, it can be used to support that scenario.

That's why I left this being usable for web too.

@@ -165,7 +167,8 @@ export class VSCodeNotebookController implements Disposable, IVSCodeNotebookCont
viewType,
label,
this.handleExecution.bind(this),
this.getRendererScripts()
this.getRendererScripts(),
[this.scriptConverter.rootScriptFolder]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops. This is the change needed for @mjbvz's new API (which hasn't gone through yet)

I'll just comment this out with a note saying this is how we'd use it.

@@ -192,29 +192,9 @@ export type DownloadOptions = {
extension: 'tmp' | string;
};

export const IFileDownloader = Symbol('IFileDownloader');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IFileDownloader is not used. Leftovers from the python extension.

@@ -2183,8 +2183,6 @@
"redux": "^4.0.4",
"redux-logger": "^3.0.6",
"reflect-metadata": "^0.1.12",
"request": "^2.87.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request has been deprecated, switched to 'cross-fetch' instead.

@codecov-commenter
Copy link

codecov-commenter commented May 19, 2022

Codecov Report

Merging #10076 (5efd808) into main (7aa2b19) will decrease coverage by 0%.
The diff coverage is 80%.

❗ Current head 5efd808 differs from pull request most recent head 286f375. Consider uploading reports for the commit 286f375 to get more accurate results

@@          Coverage Diff           @@
##            main   #10076   +/-   ##
======================================
- Coverage     64%      64%   -1%     
======================================
  Files        216      214    -2     
  Lines      10060     9989   -71     
  Branches    1613     1605    -8     
======================================
- Hits        6509     6442   -67     
+ Misses      3028     3023    -5     
- Partials     523      524    +1     
Impacted Files Coverage Δ
src/platform/common/application/types.ts 100% <ø> (ø)
src/platform/common/platform/errors.ts 88% <ø> (ø)
src/platform/common/platform/types.node.ts 100% <ø> (ø)
src/platform/common/platform/types.ts 100% <ø> (ø)
src/platform/common/process/condaService.node.ts 71% <0%> (ø)
src/platform/common/types.ts 100% <ø> (ø)
src/platform/common/net/httpClient.ts 64% <64%> (ø)
src/platform/common/platform/fileSystem.ts 77% <80%> (+5%) ⬆️
src/platform/common/application/notebook.ts 91% <100%> (ø)
src/platform/common/platform/fileSystem.node.ts 85% <100%> (+5%) ⬆️
... and 8 more

return fetch.fetch(uri, this.requestOptions);
}

public async getJSON<T>(uri: string, strict: boolean = true): Promise<T> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to remove these. Not used anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the unit test for this class well because it's just a light wrapper around fetch. I don't think it needs a unit test

@injectable()
export class HttpClient implements IHttpClient {
public readonly requestOptions: RequestInit;
constructor(@inject(IServiceContainer) serviceContainer: IServiceContainer) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why inject the entire service container instead of the actual dependencies?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was doing that before, I didn't notice. I'll change it if there's another update.

@@ -0,0 +1,99 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is '.base' needed in the filename?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I just used it to distinguish that this is a base class for the .node and .web files. I've done this in other spots.

@@ -101,4 +109,64 @@ export class FileSystem implements IFileSystem {
const data = typeof text === 'string' ? Buffer.from(text) : text;
return this.vscfs.writeFile(uri, data);
}

async createTemporaryFile(options: { fileExtension?: string; prefix?: string }): Promise<TemporaryFileUri> {
// In non node situations, temporary files are created in the globalStorageUri location (extension specific)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be in node context as well since it's in a common file. Does globalStorageUri mean different things in those contexts, or will this only be called in web?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it works for both. It's intended to work for both (using it in the tests now). globalStorageUri is just a location on disk for desktop, and it's an in memory location for web.

I should change the comment though.

@rchiodo rchiodo merged commit c214534 into main May 20, 2022
@rchiodo rchiodo deleted the rchiodo/ipywidgets_web_2 branch May 20, 2022 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support ipywidgets in the web extension
4 participants