-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Expose important pieces of vs folder on API #5283
Comments
Good idea for common things like |
Looking through the list of addons, these would benefit from exposing event/emitter stuff on the API:
|
@Tyriar Did some further digging around Event/Emitter and Disposable:
Given the list of addons using
|
@jerch if you don't extend the typical thing is to use DisposableStore as a property instead. That's less convenient sometimes but if it'll save a bunch we can use that approach exclusively in addons instead of extends? Example: Did you want to take a stab at a PR for this or want me to, since I introduced the problem? 😉 |
Oh ic, yeah that might be the easier pattern then. Although I found a pattern with runtime /////////////////
// before
// in AddonXY.ts
import { Disposable } from 'vs/base/common/lifecycle';
export class AddonXY extends Disposable { ... }
/////////////////
// with runtime extends
// in core terminal (quickly hacked into core)
private helperCls = class extends Disposable {}
public disposableCtor(): {new(): Disposable} {
return this.helperCls;
}
// in AddonXY.ts
import type { Disposable } from 'vs/base/common/lifecycle';
export function AddonXY(terminal: Terminal, ...) {
const DisposableBase = (terminal as any)._core.disposableCtor() as {new(): Disposable};
const AddonXY = class extends DisposableBase { ... };
return new AddonXY(...);
} It works basically the same as before, but now needs a terminal arg at the fake ctor already to derive the Disposable impl from there. Its not nicely abstracted yet, the
Up to you. I can try to formalize that idea, though I am not 100% sure yet, if this works properly in all circumstances. At the moment this is a full drop-in replacement with only the Edit: To get |
Runtime extends looks pretty confusing to me. The composition approach isn't quite as convenient but it's super clear how it works. We could also have a special // shared/
export class AddonDisposable {
constructor(storeCtor: DisposableStoreCtor) {
// init protected readonly _store
}
dispose() {
this._store.dispose();
}
} // addon
export class WebglAddon extends AddonDisposable {
constructor() {
super(xterm.DisposableStore);
}
} That way only the class in shared/ will be pulled into the addon bundle |
Yepp, +1 to composition. It also needs less awkward APi additions. |
Coming from #5251 (comment)
Currently using Event, Disposable etc. from the
vs/*
path in addons adds ~50kB on addons. We should investigate, if and how we can save some binary size on addons by exposing crucial parts on the API, so the impls dont have to be copied over for every single addon.The text was updated successfully, but these errors were encountered: