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

Extract plugin handling in a PluginRegistry class independent of the Application #703

Merged
merged 11 commits into from
May 25, 2024
691 changes: 102 additions & 589 deletions packages/application/src/index.ts

Large diffs are not rendered by default.

31 changes: 30 additions & 1 deletion packages/application/tests/src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { expect } from 'chai';
import { Application } from '@lumino/application';
import { ContextMenu, Widget } from '@lumino/widgets';
import { CommandRegistry } from '@lumino/commands';
import { Token } from '@lumino/coreutils';
import { PluginRegistry, Token } from '@lumino/coreutils';

describe('@lumino/application', () => {
describe('Application', () => {
Expand All @@ -28,6 +28,35 @@ describe('@lumino/application', () => {
expect(app.contextMenu).to.be.instanceOf(ContextMenu);
expect(app.shell).to.equal(shell);
});

it('should accept an external plugin registry', async () => {
const shell = new Widget();
const pluginRegistry = new PluginRegistry();
const id1 = 'plugin1';
pluginRegistry.registerPlugin({
id: id1,
activate: () => {
// no-op
}
});
const id2 = 'plugin2';
pluginRegistry.registerPlugin({
id: id2,
activate: () => {
// no-op
}
});

const app = new Application({
shell,
pluginRegistry
});

await pluginRegistry.activatePlugin(id2);

expect(app.hasPlugin(id1)).to.be.true;
expect(app.isPluginActivated(id2)).to.be.true;
});
});

describe('#getPluginDescription', () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/coreutils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"test:webkit-headless": "cd tests && karma start --browsers=WebkitHeadless",
"watch": "tsc --build --watch"
},
"dependencies": {
"@lumino/algorithm": "^2.0.1"
},
"devDependencies": {
"@lumino/buildutils": "^2.0.1",
"@microsoft/api-extractor": "^7.36.0",
Expand Down
1 change: 1 addition & 0 deletions packages/coreutils/src/index.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
|----------------------------------------------------------------------------*/
export * from './json';
export * from './mime';
export * from './plugins';
export * from './promise';
export * from './token';
Loading
Loading