Skip to content

Commit

Permalink
Extract plugin handling in a PluginRegistry class independent of th…
Browse files Browse the repository at this point in the history
…e `Application` (#703)

* Refactor the plugin registry out of the application

* Start test for PluginRegistry

* Add new tests

* Add test for `PluginRegistry.application`

* Minor tweaks

* Update API and lint

* Switch from allowed/blocked list to validate function for plugins

* Update API and lint

* Move PluginRegistry in coreutils

* Update packages/coreutils/src/plugins.ts

Co-authored-by: Nicolas Brichet <[email protected]>

* Update api

---------

Co-authored-by: Frédéric Collonval <[email protected]>
Co-authored-by: Nicolas Brichet <[email protected]>
  • Loading branch information
3 people authored May 25, 2024
1 parent f26c85a commit 63a0e8d
Show file tree
Hide file tree
Showing 11 changed files with 1,757 additions and 604 deletions.
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

0 comments on commit 63a0e8d

Please sign in to comment.