Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat(core): export injector directly from Univer (#371)

Wenzhao Hu2f5e61258b20
diff --git a/packages/core/src/Basics/Univer.ts b/packages/core/src/Basics/Univer.ts
index a52fff83b1..10572f104d 100644
--- a/packages/core/src/Basics/Univer.ts
+++ b/packages/core/src/Basics/Univer.ts
@@ -37,15 +37,16 @@ export class Univer {
private readonly _rootInjector: Injector;
private readonly _univerPluginStore = new PluginStore();
-
private readonly _univerPluginRegistry = new PluginRegistry();
private _univerSheet: UniverSheet | null = null;
-
private _univerDoc: UniverDoc | null = null;
-
private _univerSlide: UniverSlide | null = null;
+ private get _currentUniverService(): IUniverInstanceService {
+ return this._rootInjector.get(IUniverInstanceService);
+ }
+
constructor(univerData: Partial<IUniverData> = {}) {
this._rootInjector = this._initDependencies();
@@ -55,19 +56,16 @@ export class Univer {
locale && this._rootInjector.get(LocaleService).setLocale(locale);
}
- dispose(): void {
- // left empty for purpose
- // TODO@wzhudev: dispose all the businesses
+ __getInjector(): Injector {
+ return this._rootInjector;
}
- private get _currentUniverService(): IUniverInstanceService {
- return this._rootInjector.get(IUniverInstanceService);
+ dispose(): void {
+ this._rootInjector.dispose();
}
/** Register a plugin into univer. */
registerPlugin<T extends Plugin>(plugin: PluginCtor<T>, configs?: any): void {
- // TODO: type of `configs` could be optimized here using typescript infer
-
if (plugin.type === PluginType.Univer) {
this._registerUniverPlugin(plugin, configs);
} else if (plugin.type === PluginType.Sheet) {