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.

refactor: make univer type default plugin type to reduce declarations

Wenzhao Hu63b1e835b93b
diff --git a/examples/src/plugins/debugger/debugger-plugin.ts b/examples/src/plugins/debugger/debugger-plugin.ts
index d8f3a04545..bc66df47c4 100644
--- a/examples/src/plugins/debugger/debugger-plugin.ts
+++ b/examples/src/plugins/debugger/debugger-plugin.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { Plugin, UniverInstanceType } from '@univerjs/core';
+import { Plugin } from '@univerjs/core';
import type { Dependency } from '@wendellhu/redi';
import { Inject, Injector } from '@wendellhu/redi';
@@ -26,7 +26,6 @@ export interface IDebuggerPluginConfig { }
export class DebuggerPlugin extends Plugin {
static override pluginName = 'debugger';
- static override type = UniverInstanceType.UNIVER;
private _debuggerController!: DebuggerController;
diff --git a/packages/core/src/services/plugin/plugin.ts b/packages/core/src/services/plugin/plugin.ts
index 7d67a43f44..ade2df45ad 100644
--- a/packages/core/src/services/plugin/plugin.ts
+++ b/packages/core/src/services/plugin/plugin.ts
@@ -24,8 +24,9 @@ export type PluginCtor<T extends Plugin> = Ctor<T> & { type: UniverInstanceType;
* Plug-in base class, all plug-ins must inherit from this base class. Provide basic methods.
*/
export abstract class Plugin extends Disposable {
- static pluginName: string = '';
- static type: UniverInstanceType = UniverInstanceType.UNRECOGNIZED;
+ static pluginName: string;
+
+ static type: UniverInstanceType = UniverInstanceType.UNIVER;
protected abstract _injector: Injector;
diff --git a/packages/data-validation/src/plugin.ts b/packages/data-validation/src/plugin.ts
index ff105c6a74..79da876db8 100644
--- a/packages/data-validation/src/plugin.ts
+++ b/packages/data-validation/src/plugin.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { ICommandService, Plugin, UniverInstanceType } from '@univerjs/core';
+import { ICommandService, Plugin } from '@univerjs/core';
import type { Dependency } from '@wendellhu/redi';
import { Inject, Injector } from '@wendellhu/redi';
import { DataValidatorRegistryService } from './services/data-validator-registry.service';
@@ -28,7 +28,6 @@ const PLUGIN_NAME = 'data-validation';
export class UniverDataValidationPlugin extends Plugin {
static override pluginName = PLUGIN_NAME;
- static override type = UniverInstanceType.UNIVER;
constructor(
_config: unknown,
diff --git a/packages/docs/src/commands/commands/__tests__/create-command-test-bed.ts b/packages/docs/src/commands/commands/__tests__/create-command-test-bed.ts
index 48901b5acd..64d851e8f8 100644
--- a/packages/docs/src/commands/commands/__tests__/create-command-test-bed.ts
+++ b/packages/docs/src/commands/commands/__tests__/create-command-test-bed.ts
@@ -22,7 +22,6 @@ import {
LogLevel,
Plugin,
Univer,
- UniverInstanceType,
} from '@univerjs/core';
import type { Dependency } from '@wendellhu/redi';
import { Inject, Injector } from '@wendellhu/redi';
@@ -98,7 +97,6 @@ export function createCommandTestBed(workbookConfig?: IDocumentData, dependencie
*/
class TestPlugin extends Plugin {
static override pluginName = 'test-plugin';
- static override type = UniverInstanceType.UNIVER;
constructor(_config: undefined, @Inject(Injector) override readonly _injector: Injector) {
super();
diff --git a/packages/engine-formula/src/plugin.ts b/packages/engine-formula/src/plugin.ts
index 217f3dbf30..d84844a819 100644
--- a/packages/engine-formula/src/plugin.ts
+++ b/packages/engine-formula/src/plugin.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { Plugin, UniverInstanceType } from '@univerjs/core';
+import { Plugin } from '@univerjs/core';
import type { Ctor, Dependency } from '@wendellhu/redi';
import { Inject, Injector } from '@wendellhu/redi';
@@ -66,7 +66,6 @@ interface IUniverFormulaEngine {
}
export class UniverFormulaEnginePlugin extends Plugin {
- static override type = UniverInstanceType.UNIVER;
static override pluginName = PLUGIN_NAME;
constructor(
diff --git a/packages/engine-render/src/render-engine.ts b/packages/engine-render/src/render-engine.ts
index 9c70d130d9..9bedccbc95 100644
--- a/packages/engine-render/src/render-engine.ts
+++ b/packages/engine-render/src/render-engine.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { Plugin, UniverInstanceType } from '@univerjs/core';
+import { Plugin } from '@univerjs/core';
import { createIdentifier, Inject, Injector } from '@wendellhu/redi';
import { Engine } from './engine';
@@ -29,7 +29,6 @@ const PLUGIN_NAME = 'render-engine';
export class UniverRenderEnginePlugin extends Plugin {
static override pluginName = PLUGIN_NAME;
- static override type = UniverInstanceType.UNIVER;
constructor(
_config: undefined,
diff --git a/packages/facade/src/apis/docs/__tests__/create-test-bed.ts b/packages/facade/src/apis/docs/__tests__/create-test-bed.ts
index b587d7f57c..dbed0de461 100644
--- a/packages/facade/src/apis/docs/__tests__/create-test-bed.ts
+++ b/packages/facade/src/apis/docs/__tests__/create-test-bed.ts
@@ -22,7 +22,6 @@ import {
LogLevel,
Plugin,
Univer,
- UniverInstanceType,
} from '@univerjs/core';
import {
enUS,
@@ -68,7 +67,6 @@ export function createTestBed(documentConfig?: IDocumentData, dependencies?: Dep
class TestPlugin extends Plugin {
static override pluginName = 'test-plugin';
- static override type = UniverInstanceType.UNIVER;
constructor(
_config: undefined,
diff --git a/packages/find-replace/src/plugin.ts b/packages/find-replace/src/plugin.ts
index 63d9544ce7..82d26d8016 100644
--- a/packages/find-replace/src/plugin.ts
+++ b/packages/find-replace/src/plugin.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { LocaleService, Plugin, UniverInstanceType } from '@univerjs/core';
+import { LocaleService, Plugin } from '@univerjs/core';
import { type Dependency, Inject, type Injector } from '@wendellhu/redi';
import { FindReplaceController } from './controllers/find-replace.controller';
@@ -25,7 +25,6 @@ const PLUGIN_NAME = 'FIND_REPLACE';
export class UniverFindReplacePlugin extends Plugin {
static override pluginName = PLUGIN_NAME;
- static override type = UniverInstanceType.UNIVER;
constructor(
protected readonly _injector: Injector,
diff --git a/packages/image/src/plugin.ts b/packages/image/src/plugin.ts
index 94d83fbdc2..fe8c57dcf2 100644
--- a/packages/image/src/plugin.ts
+++ b/packages/image/src/plugin.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { DEFAULT_DOCUMENT_SUB_COMPONENT_ID, Plugin, UniverInstanceType } from '@univerjs/core';
+import { DEFAULT_DOCUMENT_SUB_COMPONENT_ID, Plugin } from '@univerjs/core';
import type { Dependency, Injector } from '@wendellhu/redi';
import { ImageLoadController } from './controllers/image.load.controller';
@@ -27,8 +27,6 @@ const PLUGIN_NAME = 'IMAGE_PLUGIN';
export class UniverImagePlugin extends Plugin {
static override pluginName = PLUGIN_NAME;
- static override type = UniverInstanceType.UNIVER;
-
constructor(
_config: undefined,
protected _injector: Injector
diff --git a/packages/rpc/src/plugin.ts b/packages/rpc/src/plugin.ts
index 2d8eae72c3..c9987c18a8 100644
--- a/packages/rpc/src/plugin.ts
+++ b/packages/rpc/src/plugin.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { Plugin, UniverInstanceType } from '@univerjs/core';
+import { Plugin } from '@univerjs/core';
import type { Dependency } from '@wendellhu/redi';
import { Inject, Injector } from '@wendellhu/redi';
@@ -42,7 +42,6 @@ export interface IUniverRPCMainThreadConfig {
*/
export class UniverRPCMainThreadPlugin extends Plugin {
static override pluginName = 'UNIVER_RPC_MAIN_THREAD_PLUGIN';
- static override type = UniverInstanceType.UNIVER;
constructor(
private readonly _config: IUniverRPCMainThreadConfig,
@@ -80,7 +79,6 @@ export interface IUniverRPCWorkerThreadPluginConfig {}
*/
export class UniverRPCWorkerThreadPlugin extends Plugin {
static override pluginName = 'UNIVER_RPC_WORKER_THREAD_PLUGIN';
- static override type = UniverInstanceType.UNIVER;
constructor(
private readonly _config: IUniverRPCWorkerThreadPluginConfig,
diff --git a/packages/ui/src/ui-plugin.ts b/packages/ui/src/ui-plugin.ts
index 73b901d864..c07407e8b7 100644
--- a/packages/ui/src/ui-plugin.ts
+++ b/packages/ui/src/ui-plugin.ts
@@ -15,7 +15,7 @@
*/
import type { IContextService } from '@univerjs/core';
-import { IConfigService, ILocalStorageService, LocaleService, Plugin, UniverInstanceType } from '@univerjs/core';
+import { IConfigService, ILocalStorageService, LocaleService, Plugin } from '@univerjs/core';
import type { Dependency } from '@wendellhu/redi';
import { Inject, Injector } from '@wendellhu/redi';
@@ -70,7 +70,6 @@ export const DISABLE_AUTO_FOCUS_KEY = 'DISABLE_AUTO_FOCUS';
*/
export class UniverUIPlugin extends Plugin {
static override pluginName = PLUGIN_NAME;
- static override type = UniverInstanceType.UNIVER;
constructor(
private _config: Partial<IUniverUIConfig> = {},
diff --git a/packages/uniscript/src/plugin.ts b/packages/uniscript/src/plugin.ts
index 5d2ec5622d..6353bfb89e 100644
--- a/packages/uniscript/src/plugin.ts
+++ b/packages/uniscript/src/plugin.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { LocaleService, Plugin, UniverInstanceType } from '@univerjs/core';
+import { LocaleService, Plugin } from '@univerjs/core';
import type { Dependency } from '@wendellhu/redi';
import { Inject, Injector } from '@wendellhu/redi';
@@ -31,7 +31,6 @@ export interface IUniscriptConfig extends IScriptEditorServiceConfig {}
export class UniverUniscriptPlugin extends Plugin {
static override pluginName = PLUGIN_NAME;
- static override type = UniverInstanceType.UNIVER;
constructor(
private readonly _config: IUniscriptConfig,