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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix: fix univer plugin not started
Wenzhao Hu5f5b0a76d9a4
diff --git a/packages/core/src/services/plugin/plugin.service.ts b/packages/core/src/services/plugin/plugin.service.tsindex bedb63264b..3ef5fd4c1f 100644--- a/packages/core/src/services/plugin/plugin.service.ts+++ b/packages/core/src/services/plugin/plugin.service.ts@@ -37,7 +37,7 @@ export class PluginService implements IDisposable {}dispose(): void {- this._clearFlushLazyPluginsTimer();+ this._clearFlushTimer();for (const holder of this._pluginHoldersForTypes.values()) {holder.dispose();@@ -93,27 +93,31 @@ export class PluginService implements IDisposable {}}- private _initLazyPluginsTimer?: number;+ private _flushTimer?: number;private _scheduleInitPlugin() {- if (this._initLazyPluginsTimer === undefined) {- this._initLazyPluginsTimer = setTimeout(+ if (this._flushTimer === undefined) {+ this._flushTimer = setTimeout(() => {- this._flushLazyPlugins();- this._clearFlushLazyPluginsTimer();+ if (!this._pluginHolderForUniver.started) {+ this._pluginHolderForUniver.start();+ }++ this._flushPlugins();+ this._clearFlushTimer();},INIT_LAZY_PLUGINS_TIMEOUT) as unknown as number;}}- private _clearFlushLazyPluginsTimer() {- if (this._initLazyPluginsTimer) {- clearTimeout(this._initLazyPluginsTimer);- this._initLazyPluginsTimer = undefined;+ private _clearFlushTimer() {+ if (this._flushTimer) {+ clearTimeout(this._flushTimer);+ this._flushTimer = undefined;}}- private _flushLazyPlugins() {+ private _flushPlugins() {this._pluginHolderForUniver.flush();for (const [_, holder] of this._pluginHoldersForTypes) {if (holder.started) {diff --git a/packages/core/src/univer.ts b/packages/core/src/univer.tsindex af96a85576..4b1bcc8136 100644--- a/packages/core/src/univer.ts+++ b/packages/core/src/univer.ts@@ -119,7 +119,7 @@ export class Univer {const univerInstanceService = injector.get(IUniverInstanceService) as UniverInstanceService;univerInstanceService.__setCreateHandler((type: UnitType, data, ctor) => {- this._tryProgressToStart();+ this._pluginService.start();if (!this._startedTypes.has(type)) {this._pluginService.startPluginForType(type);@@ -140,10 +140,6 @@ export class Univer {);}- private _tryProgressToStart(): void {- this._pluginService.start();- }-private _tryProgressToReady(): void {const lifecycleService = this._injector.get(LifecycleService);if (lifecycleService.stage < LifecycleStages.Ready) {