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
feat(network): network plugin support overrides (#3870)
Wenzhao Hucbabe12a1a44
diff --git a/packages/network/src/plugin.ts b/packages/network/src/plugin.tsindex 650c642ce9..102bf3daf9 100644--- a/packages/network/src/plugin.ts+++ b/packages/network/src/plugin.ts@@ -14,11 +14,22 @@* limitations under the License.*/-import { Inject, Injector, Plugin, registerDependencies } from '@univerjs/core';+import type { DependencyOverride } from '@univerjs/core';+import { Inject, Injector, mergeOverrideWithDependencies, Plugin, registerDependencies } from '@univerjs/core';import { HTTPService } from './services/http/http.service';import { IHTTPImplementation } from './services/http/implementations/implementation';import { XHRHTTPImplementation } from './services/http/implementations/xhr';+export interface IUniverNetworkPluginConfig {+ /**+ * Build in dependencies that can be overridden:+ *+ * - {@link HTTPService}+ * - {@link IHTTPImplementation}+ */+ override?: DependencyOverride;+}+/*** This plugin add network services to the Univer instance.*/@@ -26,15 +37,16 @@ export class UniverNetworkPlugin extends Plugin {static override pluginName = 'UNIVER_NETWORK_PLUGIN';constructor(+ private readonly _config: Partial<IUniverNetworkPluginConfig> | undefined = undefined,@Inject(Injector) protected readonly _injector: Injector) {super();}override onStarting(): void {- registerDependencies(this._injector, [+ registerDependencies(this._injector, mergeOverrideWithDependencies([[HTTPService],[IHTTPImplementation, { useClass: XHRHTTPImplementation }],- ]);+ ], this._config?.override));}}