mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
1654a2681f
Summary: This moves all client code to core, and makes minimal fix-ups to get grist and grist-core to compile correctly. The client works in core, but I'm leaving clean-up around the build and bundles to follow-up. Test Plan: existing tests pass; server-dev bundle looks sane Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2627
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import {PluginInstance} from 'app/common/PluginInstance';
|
|
import {InternalImportSourceAPI} from 'app/plugin/InternalImportSourceAPI';
|
|
import {ImportSource} from 'app/plugin/PluginManifest';
|
|
import {checkers} from 'app/plugin/TypeCheckers';
|
|
|
|
/**
|
|
* Encapsulate together an import source contribution with its plugin instance and a callable stub
|
|
* for the ImportSourceAPI. Exposes as well a `fromArray` static method to get all the import
|
|
* sources from an array of plugins instances.
|
|
*/
|
|
export class ImportSourceElement {
|
|
|
|
/**
|
|
* Get all import sources from an array of plugin instances.
|
|
*/
|
|
public static fromArray(pluginInstances: PluginInstance[]): ImportSourceElement[] {
|
|
const importSources: ImportSourceElement[] = [];
|
|
for (const plugin of pluginInstances) {
|
|
const definitions = plugin.definition.manifest.contributions.importSources;
|
|
if (definitions) {
|
|
for (const importSource of definitions) {
|
|
importSources.push(new ImportSourceElement(plugin, importSource));
|
|
}
|
|
}
|
|
}
|
|
return importSources;
|
|
}
|
|
|
|
public importSourceStub: InternalImportSourceAPI;
|
|
|
|
private constructor(public plugin: PluginInstance, public importSource: ImportSource) {
|
|
this.importSourceStub = plugin.getStub<InternalImportSourceAPI>(importSource.importSource,
|
|
checkers.InternalImportSourceAPI);
|
|
}
|
|
}
|