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

Access to electron API and VSCode methods. #2

Closed
seivan opened this issue Oct 15, 2019 · 5 comments
Closed

Access to electron API and VSCode methods. #2

seivan opened this issue Oct 15, 2019 · 5 comments

Comments

@seivan
Copy link

seivan commented Oct 15, 2019

Sorry to use your issue tracker for questions, but I'm trying to implement swipe to navigate and I was wondering if monkey patching would give me access to the Electron BrowserWindow and the ability to access IWorkbenchEditorConfiguration and other VSCode code that isn't listed as pub (TypeScript accessors).

I kinda rely heavily on microsoft/vscode#82528 and unfortunately it got yanked - I am not exactly sure why, but I am guessing it stemmed from confusion on what it was supposed to do and the team doesn't want to rely on further Electron API usage.

@seivan
Copy link
Author

seivan commented Oct 15, 2019

I actually managed to get a PoC working, but only using monkey-patch directly. It didn't seem to load my extensions, but will load my files using the config.

    utils.override(app.CodeApplication, "openFirstWindow", function (appOriginal) {
        utils.override(win.CodeWindow, "onConfigurationUpdated", function (windowOriginal) {

            let window = this;
            window._win.removeAllListeners('swipe');

            window._win.addListener("swipe", function (_event, cmd) {

                if (cmd == "left") {
                    window.sendWhenReady('vscode:runAction', { id: 'workbench.action.navigateBack' });
                }
                else if (cmd == "right") {
                    window.sendWhenReady('vscode:runAction', { id: 'workbench.action.navigateForward' });
                }
            });
            return windowOriginal();
        });
        return appOriginal();

    });

@knopp
Copy link
Collaborator

knopp commented Oct 15, 2019

Well, you can look at https://github.com/iocave/customize-ui to see extension built on top of monkey-patch. It is bit more involved, as the extension needs to copy the injected javascript files in global storage. That is because extension path changes with each extension update, however the module folders registered with monkey-patch must remain the same.

@seivan
Copy link
Author

seivan commented Oct 15, 2019

Right, I think the issue stemmed from using two extensions that dependent on monkey patch.
Meaning once I had customize-ui and my own at the same time, it seems to have picked only one for loading in the browser-entrypoint.

Most certain I am doing something wrong here, or it's related to how loading dev-extensions work in Vscode. Anyhow, I've managed to at least load my own files using monkey-patch directly and setting the path in the config and you know what... it works great!

Gotta figure out a nice way of loading config from the user and do proper logging.

@knopp
Copy link
Collaborator

knopp commented Oct 15, 2019

Well, I haven't really tried monkey-patch with multiple extensions, but in theory there shouldn't be difference between multiple extension and single extension with multiple contributed modules.

@seivan
Copy link
Author

seivan commented Oct 17, 2019

@knopp I'm closing this in favour of #3 since my questions been answered - and yeah it works great!

@seivan seivan closed this as completed Oct 17, 2019
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