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

feat: add extension gallery #238

Merged
merged 17 commits into from
Nov 22, 2023
Merged

Conversation

CompuIves
Copy link
Collaborator

@CompuIves CompuIves commented Nov 10, 2023

I think this is pretty ready for an early review now. This PR enables the extensions gallery service, and all the services it requires to function. It allows you to install extensions from the extension marketplace (https://open-vsx.org/) either in web only, or on the remote if a remote is connected.

To enable this, I made some changes:

  • Downgrade semver to v5.5.0, which is used within VSCode. This way we can stub their module.
  • Allow for passing a custom product configuration to the client & the server, this allows us to define a different extension marketplace (that is not from Microsoft)
  • Imported all extra required services, including their stubs

@CompuIves CompuIves force-pushed the feat/extension-gallery branch 4 times, most recently from 9d14bae to b3e0e4c Compare November 11, 2023 17:56
rollup/rollup.config.ts Outdated Show resolved Hide resolved
@CompuIves CompuIves force-pushed the feat/extension-gallery branch from 92a6adb to 01e1526 Compare November 16, 2023 22:17
@CompuIves CompuIves marked this pull request as ready for review November 16, 2023 22:20
@CompuIves CompuIves requested a review from CGNonofr November 16, 2023 22:25
@CompuIves CompuIves changed the title wip: add extension gallery feat: add extension gallery Nov 16, 2023
Copy link
Contributor

@CGNonofr CGNonofr left a comment

Choose a reason for hiding this comment

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

Impressive work, well done!

Is there a way for extensions to be kept after a reload?

There are networks errors, and not working images:
image
image
do you know why?

When trying to install a remote extension in the server, I get a FileOperationError: Unable to resolve nonexistent file '<project>/dist/extensions'

Also, could you please simplify the git history by removing commits that are reverted later?

.vscode/settings.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
rollup/rollup.server.config.ts Outdated Show resolved Hide resolved
src/missing-services.ts Outdated Show resolved Hide resolved
src/server/server-assets.ts Outdated Show resolved Hide resolved
src/service-override/extensionGallery.ts Outdated Show resolved Hide resolved
@CompuIves
Copy link
Collaborator Author

CompuIves commented Nov 17, 2023

do you know why?

Yes, removing res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin') makes it work, because currently we don't allow loading resources (like images) from other origins. I'm not sure if we want to remove it, though.

When trying to install a remote extension in the server, I get a FileOperationError: Unable to resolve nonexistent file '/dist/extensions'

Argh, I thought I had fixed it with this line, but maybe I got the directory wrong or we need more. The explanation is this: VSCode tries to look for system extensions (which are extensions preinstalled on the system, can only be disabled and not uninstalled) in a specific directory. If that directory does not exist, it will just error out and things will be broken. The directory it looks for is in the directory where the server.js got executed from (or so I thought). It could perhaps be that this directory resolution changed after the asset registration change.

Is there a way for extensions to be kept after a reload?

I think our storage service work might've fixed this! I'll rebase soon.

Also, could you please simplify the git history by removing commits that are reverted later?

Yep!

@CompuIves CompuIves force-pushed the feat/extension-gallery branch from 4a597c8 to 7ec0b62 Compare November 17, 2023 12:08
@CompuIves
Copy link
Collaborator Author

Also, could you please simplify the git history by removing commits that are reverted later?

Will do! I'll squash everything together and separate the demo changes in another commit.

@CGNonofr
Copy link
Contributor

Yes, removing res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin') makes it work, because currently we don't allow loading resources (like images) from other origins. I'm not sure if we want to remove it, though.

I'm not 100% familiar with those http headers, can you elaborate on what it does exactly and why removing it resolves the error ?

@CompuIves
Copy link
Collaborator Author

I'm not 100% familiar with those http headers, can you elaborate on what it does exactly and why removing it resolves the error ?

Actually... I think I know why it works in VSCode. The ExtensionResourceLoaderService has this code when resolving a resource:

		const requestInit: RequestInit = {};
		if (this.isExtensionGalleryResource(uri)) {
			requestInit.headers = await this.getExtensionGalleryRequestHeaders();
			requestInit.mode = 'cors'; /* set mode to cors so that above headers are always passed */
		}

And our SimpleExtensionResourceLoaderService doesn't have the cors adding yet. I'm adding that now.

@CGNonofr
Copy link
Contributor

I'm not 100% familiar with those http headers, can you elaborate on what it does exactly and why removing it resolves the error ?

Actually... I think I know why it works in VSCode. The ExtensionResourceLoaderService has this code when resolving a resource:

		const requestInit: RequestInit = {};
		if (this.isExtensionGalleryResource(uri)) {
			requestInit.headers = await this.getExtensionGalleryRequestHeaders();
			requestInit.mode = 'cors'; /* set mode to cors so that above headers are always passed */
		}

And our SimpleExtensionResourceLoaderService doesn't have the cors adding yet. I'm adding that now.

Well spotted!

I think now ExtensionResourceLoaderService without customization should be enough

@CompuIves
Copy link
Collaborator Author

I think now ExtensionResourceLoaderService without customization should be enough

I was initially thinking that, but the browser version is not exported. So I can do two things:

  1. Copy the code over (which I've done in the last commit)
  2. Add to the VSCode diff to export the service

Disadvantage of copying is that we won't keep up with VSCode changes. I can make it an export, what do you think?

@CGNonofr
Copy link
Contributor

I think now ExtensionResourceLoaderService without customization should be enough

I was initially thinking that, but the browser version is not exported. So I can do two things:

  1. Copy the code over (which I've done in the last commit)
  2. Add to the VSCode diff to export the service

Disadvantage of copying is that we won't keep up with VSCode changes. I can make it an export, what do you think?

That's what the patch is for, we already did it plenty of times already

@CompuIves
Copy link
Collaborator Author

CompuIves commented Nov 17, 2023

Okay! This is a pretty important commit, I could use your review on it.

I noticed that extensions would start disabled, when loading VSCode. I took a look at the extensionService, and they have some enable logic when the extension service boots. I copied that code, instead of using the service directly, because I believe our service has some custom logic for inline extensions. I tested this code both with the extension gallery override and without, and it still works! Now the extensions also get enabled properly (and they say how long it took to enable them!)

@CompuIves CompuIves force-pushed the feat/extension-gallery branch from 759a5d1 to 5f37155 Compare November 17, 2023 15:04
@CompuIves
Copy link
Collaborator Author

Okay, applied that change

@CompuIves CompuIves force-pushed the feat/extension-gallery branch 7 times, most recently from 1a6a10f to 0cd5a6c Compare November 17, 2023 15:21
@CompuIves
Copy link
Collaborator Author

Cleaned up the commits now as well

@CompuIves CompuIves force-pushed the feat/extension-gallery branch from 0cd5a6c to fd7fa79 Compare November 17, 2023 15:34
@CGNonofr
Copy link
Contributor

@CompuIves I've addressed myself all my concern, I'd like to know what you think about the last few commits

@CompuIves
Copy link
Collaborator Author

Wow, thanks a lot! I'll do a review now.

Copy link
Collaborator Author

@CompuIves CompuIves left a comment

Choose a reason for hiding this comment

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

Some small questions/notes. For the rest it looks good!

src/service-override/files.ts Outdated Show resolved Hide resolved
src/service-override/extensionGallery.ts Outdated Show resolved Hide resolved
demo/src/setup.ts Show resolved Hide resolved
src/server/server.ts Show resolved Hide resolved
@CGNonofr CGNonofr force-pushed the feat/extension-gallery branch from bc8a447 to 0e60c5f Compare November 22, 2023 10:01
@CompuIves
Copy link
Collaborator Author

Awesome!! Looking forward to this change 😄

@CGNonofr CGNonofr force-pushed the feat/extension-gallery branch from 0e60c5f to 50bb8c0 Compare November 22, 2023 10:10
@CGNonofr
Copy link
Contributor

wrongly rebased, no conflict anymore!

@CGNonofr CGNonofr self-requested a review November 22, 2023 10:11
@CGNonofr CGNonofr merged commit 86c089a into CodinGame:main Nov 22, 2023
1 check passed
@CompuIves
Copy link
Collaborator Author

Awesome to see this!!! Congrats on the release! 🎉

@CGNonofr
Copy link
Contributor

Awesome to see this!!! Congrats on the release! 🎉

There are still a few issues, and the demo failed to deploy, fix incoming!

@CGNonofr
Copy link
Contributor

Can you check #256 ? :)

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.

2 participants