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

Extensions icons are not loading in demo #549

Open
alienself opened this issue Jan 8, 2025 · 8 comments
Open

Extensions icons are not loading in demo #549

alienself opened this issue Jan 8, 2025 · 8 comments

Comments

@alienself
Copy link

Hi there,

I built the project locally, it works pretty great but the extensions icons are not loading, why is that? Any way to fix it?

Screenshot 2025-01-08 at 1 52 55 PM
@CGNonofr
Copy link
Contributor

CGNonofr commented Jan 8, 2025

Any error in the console maybe?

@alienself
Copy link
Author

alienself commented Jan 8, 2025

Thanks for the quick reply, does it work on your side? Yes it looks like the requests are being blocked, I was able to make it work by removing the cross origin headers used for SharedArrayBuffer, but this means language-features will no longer work right? Is there a way around this? how is vscode.dev able to have language features working + able to load cross origin content?

{
	// For the *-language-features extensions which use SharedArrayBuffer
	name: "configure-response-headers",
	apply: "serve",
	configureServer: (server) => {
		server.middlewares.use((_req, res, next) => {
			res.setHeader("Cross-Origin-Embedder-Policy", "credentialless");
			res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
			res.setHeader("Cross-Origin-Resource-Policy", "cross-origin");
			next();
		});
	}
},

Additionally do you know if there is something similar to "retainContextWhenHidden" for custom editors? I would like to create a tab that is retained in memory even when it not visible similar to the expected behavior in a vscode extension:

	const customEditorProvider = new CustomEditorProvider(context);
	context.subscriptions.push(
		vscode.window.registerCustomEditorProvider(
			'custom.customEditor',
			customEditorProvider, {
				webviewOptions: {
					// retain the webview’s context (keep it in memory) even when switching tabs 
					retainContextWhenHidden: true
				},
				supportsMultipleEditorsPerDocument: false
			})
	);

but when playing around with the custom panel code you have in the demo, the iframe is always reloaded when changing tabs:

	class CustomEditorPane extends SimpleEditorPane {
	static readonly ID = "workbench.editors.customEditor";

	constructor(group: IEditorGroup) {
		super(CustomEditorPane.ID, group);
	}

	initialize(): HTMLElement {
		const container = document.createElement("div");
		container.style.display = "flex";
		container.style.alignItems = "center";
		container.style.justifyContent = "center";
		container.innerHTML =
			"This is a custom editor pane<br />You can render anything you want here";
		return container;
	}

	async renderInput(input: EditorInput): Promise<monaco.IDisposable> {
		if (input.resource != null) {
			this.container.innerHTML = "Opened file: " + input.resource.path+ `<iframe src="https://github.com/"></iframe>`;
		} else {
			this.container.innerHTML =
				"This is a custom editor pane<br />You can render anything you want here";
		}

		return {
			dispose() {}
		};
	}
}```

@alienself
Copy link
Author

alienself commented Jan 9, 2025

After more research, Codesanbox is using this project and is able to run the typescript language server without SharedArrayBuffer, how is that possible? Do you think that they modified the typescript language server directly?
I see that vscode's typescript language server does have the following check:

if (isWebAndHasSharedArrayBuffers()) {
args.push('--enableProjectWideIntelliSenseOnWeb');
}

They also have the same issue that the tabs of custom editors are constantly being reloaded and not kept in memory, I wonder if there is a workaround for this.

@CGNonofr
Copy link
Contributor

CGNonofr commented Jan 9, 2025

does it work on your side?

I've just tried, no issue on my side 🤔
image

Additionally do you know if there is something similar to "retainContextWhenHidden" for custom editors?

I don't think so, it seems specific to webviews

After more research, Codesanbox is using this project and is able to run the typescript language server without SharedArrayBuffer, how is that possible?

I've just tried, and it doesn't seem that the project-wide intellisense is working 🤔

@alienself
Copy link
Author

alienself commented Jan 9, 2025

no issue on my side

wow! how? :D I am following exactly the steps in your readme and open localhost.
All the icons request are in a failed state but it seems that another request is made after that which is able to retrieve the icons however nothing is shown in the editor. I am using the latest version of Chrome on mac.

Screenshot 2025-01-09 at 8 52 35 AM

I don't think so, it seems specific to webviews

oh I see, it makes sense, thanks!

I've just tried, and it doesn't seem that the project-wide intellisense is working 🤔

Really? It seems to work fine on my side even tho they are not cross origin isolated.
On codesandbox if I create a typescript file containing an exported class, and attempt to import it in another file I do get suggested that class and its methods with the autocompletion and everything + ctrl click to go to definition.

@CGNonofr
Copy link
Contributor

CGNonofr commented Jan 9, 2025

Are you able to load https://open-vsx.org/vscode/asset/haberdashPI/vscode-select-by-indent/0.3.3/Microsoft.VisualStudio.Services.Icons.Default?targetPlatform=universal in your browser ?

I don't think so, it seems specific to webviews

oh I see, it makes sense, thanks!

But you can probably implement it yourself, by rendering in a detached element, and just attaching it when the tab is displayed?

Really? It seems to work fine on my side even tho they are not cross origin isolated.

Are you using the "devbox"? (i.e. your env is running in a codesandbox server) In that case, the extension is running on the server and cross origin isolated has no impact

@alienself
Copy link
Author

Are you able to load https://open-vsx.org/vscode/asset/haberdashPI/vscode-select-by-indent/0.3.3/Microsoft.VisualStudio.Services.Icons.Default?targetPlatform=universal in your browser ?

Yes absolutely, i can see the icon.

But you can probably implement it yourself, by rendering in a detached element, and just attaching it when the tab is displayed?

That's a great idea, thank you very much for the suggestion.

Are you using the "devbox"? (i.e. your env is running in a codesandbox server) In that case, the extension is running on the server and cross origin isolated has no impact

No I am just using a simple typescript sandbox runtime (no devbox/vm involved).

@CGNonofr
Copy link
Contributor

CGNonofr commented Jan 10, 2025

Yes absolutely, i can see the icon.

I'm not sure what is the issue then. I've just noticed it's not working at all in the published version of the demo though, like it was blocked by open-vsx 🤔

No I am just using a simple typescript sandbox runtime (no devbox/vm involved).

are you sure project wide intellisense is working then? it doesn't seem to be able to get types from other files
image

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

No branches or pull requests

2 participants