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(facade): facade-namespace & global addEvent (#4346)
zhangw612c981b2fd4
diff --git a/packages/core/src/facade/f-base.ts b/packages/core/src/facade/f-base.tsindex b81ba0d10a..de9d26454a 100644--- a/packages/core/src/facade/f-base.ts+++ b/packages/core/src/facade/f-base.ts@@ -14,28 +14,51 @@* limitations under the License.*/+import type { Injector } from '@wendellhu/redi';+import { Disposable } from '../shared';+/*** `FBase` is a base class for all facade classes.* It provides a way to extend classes with static and instance methods.* The `_initialize` as a special method that will be called after the constructor. You should never call it directly.*/-export abstract class FBase {- private static _constructorQueue: Array<() => void> = [];+export abstract class FBase extends Disposable {+ static extend(source: any): void {+ Object.getOwnPropertyNames(source.prototype).forEach((name) => {+ if (name !== 'constructor') {+ // @ts-ignore+ this.prototype[name] = source.prototype[name];+ }+ });- constructor() {+ Object.getOwnPropertyNames(source).forEach((name) => {+ if (name !== 'prototype' && name !== 'name' && name !== 'length') {+ // @ts-ignore+ this[name] = source[name];+ }+ });+ }+}++export class FBaseInitialable extends Disposable {+ private static _constructorQueue: Array<(_injector: Injector) => void> = [];+ constructor(+ protected _injector: Injector+ ) {+ super();// eslint-disable-next-line ts/no-this-aliasconst self = this;- FBase._constructorQueue.forEach(function (fn) {- fn.apply(self);+ FBaseInitialable._constructorQueue.forEach(function (fn) {+ fn.apply(self, [_injector]);});}- _initialize() { }+ _initialize(injector: Injector) {}static extend(source: any): void {Object.getOwnPropertyNames(source.prototype).forEach((name) => {if (name === '_initialize') {- FBase._constructorQueue.push(source.prototype._initialize);+ FBaseInitialable._constructorQueue.push(source.prototype._initialize);} else if (name !== 'constructor') {// @ts-ignorethis.prototype[name] = source.prototype[name];@@ -50,4 +73,3 @@ export abstract class FBase {});}}-diff --git a/packages/core/src/facade/f-enum.ts b/packages/core/src/facade/f-enum.tsnew file mode 100644index 0000000000..fd3d1c07ed--- /dev/null+++ b/packages/core/src/facade/f-enum.ts@@ -0,0 +1,46 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import { UniverInstanceType } from '../common/unit';+import { LifecycleStages } from '../services/lifecycle/lifecycle';+import { DataValidationErrorStyle } from '../types/enum/data-validation-error-style';+import { DataValidationOperator } from '../types/enum/data-validation-operator';+import { DataValidationRenderMode } from '../types/enum/data-validation-render-mode';+import { DataValidationStatus } from '../types/enum/data-validation-status';+import { DataValidationType } from '../types/enum/data-validation-type';+import { FBase } from './f-base';++export class FEnum extends FBase {+ static _intance: FEnum | null;+ static get() {+ if (this._intance) {+ return this._intance;+ }++ const instance = new FEnum();+ this._intance = instance;+ return instance;+ }++ readonly UniverInstanceType = UniverInstanceType;+ readonly LifecycleStages = LifecycleStages;++ readonly DataValidationType = DataValidationType;+ readonly DataValidationErrorStyle = DataValidationErrorStyle;+ readonly DataValidationRenderMode = DataValidationRenderMode;+ readonly DataValidationOperator = DataValidationOperator;+ readonly DataValidationStatus = DataValidationStatus;+}diff --git a/packages/core/src/facade/f-event.ts b/packages/core/src/facade/f-event.tsnew file mode 100644index 0000000000..f3ef8893f2--- /dev/null+++ b/packages/core/src/facade/f-event.ts@@ -0,0 +1,64 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { UniverInstanceType } from '../common/unit';+import type { LifecycleStages } from '../services/lifecycle/lifecycle';+import type { IWorkbookData } from '../sheets/typedef';+import type { IDocumentData } from '../types/interfaces';+import { FBase } from './f-base';++export interface ISheetCreateParam {+ unitId: string;+ type: UniverInstanceType.UNIVER_SHEET;+ data: IWorkbookData;+}++export interface IDocumentCreateParam {+ unitId: string;+ type: UniverInstanceType.UNIVER_DOC;+ data: IDocumentData;+}++export interface ILifeCycleChangedParam {+ stage: LifecycleStages;+}+export interface IEventBase {+ cancel?: boolean;+}++export type IUnitCreateEvent = IEventBase & (ISheetCreateParam | IDocumentCreateParam);+export type ILifeCycleChangedEvent = IEventBase & ILifeCycleChangedParam;++export class FEventName extends FBase {+ static _intance: FEventName | null;+ static get() {+ if (this._intance) {+ return this._intance;+ }++ const instance = new FEventName();+ this._intance = instance;+ return instance;+ }++ UnitCreated = 'UnitCreated' as const;+ LifeCycleChanged = 'LifeCycleChanged' as const;+}++export interface IEventParamConfig {+ // UnitCreated: IUnitCreateEvent;+ LifeCycleChanged: ILifeCycleChangedEvent;+}diff --git a/packages/core/src/facade/f-univer.ts b/packages/core/src/facade/f-univer.tsindex b90df1d5f3..7f9b2a7510 100644--- a/packages/core/src/facade/f-univer.ts+++ b/packages/core/src/facade/f-univer.ts@@ -17,18 +17,23 @@import type { IDisposable } from '../common/di';import type { CommandListener, IExecutionOptions } from '../services/command/command.service';import type { LifecycleStages } from '../services/lifecycle/lifecycle';+import type { IEventParamConfig } from './f-event';import { Inject, Injector } from '../common/di';+import { Registry } from '../common/registry';import { ICommandService } from '../services/command/command.service';import { IUniverInstanceService } from '../services/instance/instance.service';import { LifecycleService } from '../services/lifecycle/lifecycle.service';import { RedoCommand, UndoCommand } from '../services/undoredo/undoredo.service';+import { toDisposable } from '../shared';import { Univer } from '../univer';-import { FBase } from './f-base';+import { FBaseInitialable } from './f-base';import { FBlob } from './f-blob';+import { FEnum } from './f-enum';+import { FEventName } from './f-event';import { FHooks } from './f-hooks';import { FUserManager } from './f-usermanager';-export class FUniver extends FBase {+export class FUniver extends FBaseInitialable {/*** Create an FUniver instance, if the injector is not provided, it will create a new Univer instance.*@@ -42,12 +47,33 @@ export class FUniver extends FBase {return injector.createInstance(FUniver);}+ private _eventRegistry: Map<string, Registry<(param: any) => void>> = new Map();++ private _ensureEventRegistry(event: string) {+ if (!this._eventRegistry.has(event)) {+ this._eventRegistry.set(event, new Registry());+ }++ return this._eventRegistry.get(event)!;+ }+constructor(- @Inject(Injector) protected readonly _injector: Injector,+ @Inject(Injector) protected override readonly _injector: Injector,@ICommandService protected readonly _commandService: ICommandService,- @IUniverInstanceService protected readonly _univerInstanceService: IUniverInstanceService+ @IUniverInstanceService protected readonly _univerInstanceService: IUniverInstanceService,+ @Inject(LifecycleService) protected readonly _lifecycleService: LifecycleService) {- super();+ super(_injector);++ this.disposeWithMe(+ this._lifecycleService.lifecycle$.subscribe((stage) => {+ this.fireEvent(this.Event.LifeCycleChanged, { stage });+ })+ );++ this._injector.onDispose(() => {+ this.dispose();+ });}/**@@ -90,7 +116,7 @@ export class FUniver extends FBase {/*** Register a callback that will be triggered before invoking a command.- *+ * @deprecated use `addEvent(univerAPI.event.BeforeCommandExecute, () => {})` instead.* @param {CommandListener} callback The callback.* @returns {IDisposable} The disposable instance.*/@@ -102,7 +128,7 @@ export class FUniver extends FBase {/*** Register a callback that will be triggered when a command is invoked.- *+ * @deprecated use `addEvent(univerAPI.event.CommandExecuted, () => {})` instead.* @param {CommandListener} callback The callback.* @returns {IDisposable} The disposable instance.*/@@ -144,7 +170,7 @@ export class FUniver extends FBase {/*** Get hooks.- *+ * @deprecated use `addEvent` instead.* @returns {FHooks} FHooks instance*/getHooks(): FHooks {@@ -164,7 +190,51 @@ export class FUniver extends FBase {return this._injector.createInstance(FBlob);}+ get Enum() {+ return FEnum.get();+ }++ get Event() {+ return FEventName.get();+ }++ /**+ * Add an event listener+ * @param event key of event+ * @param callback callback when event triggered+ * @returns {Disposable} The Disposable instance, for remove the listener+ * @example+ * ```ts+ * univerAPI.addEvent(univerAPI.event.UnitCreated, (params) => {+ * console.log('unit created', params);+ * });+ * ```+ */+ addEvent(event: keyof IEventParamConfig, callback: (params: IEventParamConfig[typeof event]) => void) {+ this._ensureEventRegistry(event).add(callback);+ return toDisposable(() => this._ensureEventRegistry(event).delete(callback));+ }++ /**+ * Fire an event, used in internal only.+ * @param event {string} key of event+ * @param params {any} parmas of event+ * @returns {boolean} should cancel+ * @example+ * ```ts+ * this.fireEvent(univerAPI.event.UnitCreated, params);+ * ```+ */+ protected fireEvent<T extends keyof IEventParamConfig>(event: T, params: IEventParamConfig[T]) {+ this._eventRegistry.get(event)?.getData().forEach((callback) => {+ callback(params);+ });++ return params.cancel;+ }+getUserManager(): FUserManager {return this._injector.createInstance(FUserManager);}}+diff --git a/packages/core/src/facade/f-util.ts b/packages/core/src/facade/f-util.tsnew file mode 100644index 0000000000..f025dde7cb--- /dev/null+++ b/packages/core/src/facade/f-util.ts@@ -0,0 +1,19 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export class FUtil {+ static Range = Range;+}diff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex 9d2897f2a9..4ce572c3d0 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -40,10 +40,12 @@ export { AsyncInterceptorManager, composeInterceptors, createAsyncInterceptorKeyexport type { Serializable } from './common/json';export { MemoryCursor } from './common/memory-cursor';export { mixinClass } from './common/mixin';-export { FBase } from './facade/f-base';+export { FBase, FBaseInitialable } from './facade/f-base';export { FUniver } from './facade/f-univer';export { FHooks } from './facade/f-hooks';export { FBlob, type IFBlobSource } from './facade/f-blob';+export { FEventName, type IEventBase, type IEventParamConfig } from './facade/f-event';+export { FEnum } from './facade/f-enum';export { isNumeric, isSafeNumeric } from './common/number';export { Registry, RegistryAsMap } from './common/registry';export { requestImmediateMacroTask } from './common/request-immediate-macro-task';diff --git a/packages/sheets-data-validation/src/facade/f-workbook.ts b/packages/sheets-data-validation/src/facade/f-workbook.tsindex a720a985ee..7bce5229da 100644--- a/packages/sheets-data-validation/src/facade/f-workbook.ts+++ b/packages/sheets-data-validation/src/facade/f-workbook.ts@@ -24,7 +24,6 @@ import type { IAddSheetDataValidationCommandParams,IValidStatusChange } from '@univerjs/sheets-data-validation';import { type DataValidationStatus, type IDisposable, type IExecutionOptions, type Nullable, type ObjectMatrix, toDisposable } from '@univerjs/core';-import { FWorkbook } from '@univerjs/sheets/facade';import { AddSheetDataValidationCommand,RemoveSheetAllDataValidationCommand,RemoveSheetDataValidationCommand,@@ -34,6 +33,7 @@ import { AddSheetDataValidationCommand,UpdateSheetDataValidationRangeCommand,UpdateSheetDataValidationSettingCommand,} from '@univerjs/sheets-data-validation';+import { FWorkbook } from '@univerjs/sheets/facade';import { filter } from 'rxjs';export interface IFWorkbookDataValidationMixin {diff --git a/packages/sheets/src/facade/f-event.ts b/packages/sheets/src/facade/f-event.tsnew file mode 100644index 0000000000..369cb3c476--- /dev/null+++ b/packages/sheets/src/facade/f-event.ts@@ -0,0 +1,54 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IEventBase, IWorksheetData } from '@univerjs/core';+import type { FWorkbook } from './f-workbook';+import type { FWorksheet } from './f-worksheet';+import { FEventName } from '@univerjs/core';++export interface IFSheetEventMixin {+ SheetCreated: 'SheetCreated';+ BeforeSheetCreate: 'BeforeSheetCreate';+}++export class FSheetEventName extends FEventName implements IFSheetEventMixin {+ override readonly SheetCreated = 'SheetCreated' as const;+ override readonly BeforeSheetCreate = 'BeforeSheetCreate' as const;+}++export interface IBeforeSheetCreateEventParams extends IEventBase {+ workbook: FWorkbook;+ index?: number;+ sheet?: IWorksheetData;+}++export interface ISheetCreatedEventParams extends IEventBase {+ workbook: FWorkbook;+ worksheet: FWorksheet;+}++export interface ISheetEventParamConfig {+ SheetCreated: ISheetCreatedEventParams;+ BeforeSheetCreate: IBeforeSheetCreateEventParams;+}++FEventName.extend(FSheetEventName);+declare module '@univerjs/core' {+ // eslint-disable-next-line ts/naming-convention+ interface FEventName extends IFSheetEventMixin { }+ interface IEventParamConfig extends ISheetEventParamConfig { }+}+diff --git a/packages/sheets/src/facade/f-range.ts b/packages/sheets/src/facade/f-range.tsindex 53fc6f26fb..bd8f6ffdc7 100644--- a/packages/sheets/src/facade/f-range.ts+++ b/packages/sheets/src/facade/f-range.ts@@ -17,7 +17,7 @@import type { CellValue, ICellData, IColorStyle, IObjectMatrixPrimitiveType, IRange, IStyleData, ITextDecoration, Nullable, Workbook, Worksheet } from '@univerjs/core';import type { ISetHorizontalTextAlignCommandParams, ISetStyleCommandParams, ISetTextWrapCommandParams, ISetVerticalTextAlignCommandParams, IStyleTypeValue, SplitDelimiterEnum } from '@univerjs/sheets';import type { FHorizontalAlignment, FVerticalAlignment } from './utils';-import { BooleanNumber, Dimension, FBase, ICommandService, Inject, Injector, Rectangle, WrapStrategy } from '@univerjs/core';+import { BooleanNumber, Dimension, FBaseInitialable, ICommandService, Inject, Injector, Rectangle, WrapStrategy } from '@univerjs/core';import { FormulaDataModel, serializeRange, serializeRangeWithSheet } from '@univerjs/engine-formula';import { addMergeCellsUtil, getAddMergeMutationRangeByType, RemoveWorksheetMergeCommand, SetHorizontalTextAlignCommand, SetRangeValuesCommand, SetStyleCommand, SetTextWrapCommand, SetVerticalTextAlignCommand, SplitTextToColumnsCommand } from '@univerjs/sheets';import { FWorkbook } from './f-workbook';@@ -27,16 +27,16 @@ export type FontLine = 'none' | 'underline' | 'line-through';export type FontStyle = 'normal' | 'italic';export type FontWeight = 'normal' | 'bold';-export class FRange extends FBase {+export class FRange extends FBaseInitialable {constructor(protected readonly _workbook: Workbook,protected readonly _worksheet: Worksheet,protected readonly _range: IRange,- @Inject(Injector) protected readonly _injector: Injector,+ @Inject(Injector) protected override readonly _injector: Injector,@ICommandService protected readonly _commandService: ICommandService,@Inject(FormulaDataModel) protected readonly _formulaDataModel: FormulaDataModel) {- super();+ super(_injector);}/**diff --git a/packages/sheets/src/facade/f-univer.ts b/packages/sheets/src/facade/f-univer.tsindex 483e3166f1..65b2ca032b 100644--- a/packages/sheets/src/facade/f-univer.ts+++ b/packages/sheets/src/facade/f-univer.ts@@ -14,8 +14,11 @@* limitations under the License.*/-import type { IDisposable, IWorkbookData, Workbook } from '@univerjs/core';-import { FUniver, IUniverInstanceService, toDisposable, UniverInstanceType } from '@univerjs/core';+import type { IDisposable, Injector, IWorkbookData, Workbook } from '@univerjs/core';+import type { IInsertSheetCommandParams } from '@univerjs/sheets';+import type { IBeforeSheetCreateEventParams, ISheetCreatedEventParams } from './f-event';+import { FUniver, ICommandService, IUniverInstanceService, toDisposable, UniverInstanceType } from '@univerjs/core';+import { InsertSheetCommand } from '@univerjs/sheets';import { FDefinedNameBuilder } from './f-defined-name';import { FPermission } from './f-permission';import { FWorkbook } from './f-workbook';@@ -61,6 +64,72 @@ export interface IFUniverSheetsMixin {}export class FUniverSheetsMixin extends FUniver implements IFUniverSheetsMixin {+ override _initialize(injector: Injector): void {+ const commandService = injector.get(ICommandService);+ this.disposeWithMe(+ commandService.beforeCommandExecuted((commandInfo) => {+ switch (commandInfo.id) {+ case InsertSheetCommand.id: {+ const params = (commandInfo.params) as IInsertSheetCommandParams;+ const { unitId, index, sheet } = params || {};+ const workbook = unitId ? this.getUniverSheet(unitId) : this.getActiveWorkbook?.();+ if (!workbook) {+ return;+ }+ const eventParams: IBeforeSheetCreateEventParams = {+ workbook,+ index,+ sheet,+ };+ this.fireEvent(+ this.Event.BeforeSheetCreate,+ eventParams+ );+ // cancel this command+ if (eventParams.cancel) {+ throw new Error('Sheet create canceled by facade api.');+ }+ break;+ }++ default:+ break;+ }+ })+ );++ this.disposeWithMe(+ commandService.onCommandExecuted((commandInfo) => {+ switch (commandInfo.id) {+ case InsertSheetCommand.id: {+ const params = commandInfo.params as IInsertSheetCommandParams;+ const { unitId } = params || {};+ const workbook = unitId ? this.getUniverSheet(unitId) : this.getActiveWorkbook?.();+ if (!workbook) {+ return;+ }+ const worksheet = workbook.getActiveSheet();+ if (!worksheet) {+ return;+ }+ const eventParams: ISheetCreatedEventParams = {+ workbook,+ worksheet,+ };+ this.fireEvent(+ this.Event.SheetCreated,+ eventParams+ );+ break;+ }++ default:+ break;+ }+ })+ );+ }+override createUniverSheet(data: Partial<IWorkbookData>): FWorkbook {const instanceService = this._injector.get(IUniverInstanceService);const workbook = instanceService.createUnit<IWorkbookData, Workbook>(UniverInstanceType.UNIVER_SHEET, data);diff --git a/packages/sheets/src/facade/f-workbook.ts b/packages/sheets/src/facade/f-workbook.tsindex 7b8cab31f0..0dd7dcf82b 100644--- a/packages/sheets/src/facade/f-workbook.ts+++ b/packages/sheets/src/facade/f-workbook.ts@@ -17,7 +17,7 @@import type { CommandListener, ICommandInfo, IDisposable, IRange, IWorkbookData, LocaleType, Workbook } from '@univerjs/core';import type { ISetDefinedNameMutationParam } from '@univerjs/engine-formula';import type { ISetSelectionsOperationParams, ISheetCommandSharedParams } from '@univerjs/sheets';-import { FBase, ICommandService, ILogService, Inject, Injector, IPermissionService, IResourceLoaderService, IUniverInstanceService, LocaleService, mergeWorksheetSnapshotWithDefault, RedoCommand, toDisposable, UndoCommand, UniverInstanceType } from '@univerjs/core';+import { FBaseInitialable, ICommandService, ILogService, Inject, Injector, IPermissionService, IResourceLoaderService, IUniverInstanceService, LocaleService, mergeWorksheetSnapshotWithDefault, RedoCommand, toDisposable, UndoCommand, UniverInstanceType } from '@univerjs/core';import { IDefinedNamesService } from '@univerjs/engine-formula';import { CopySheetCommand, getPrimaryForRange, InsertSheetCommand, RemoveSheetCommand, SCOPE_WORKBOOK_VALUE_DEFINED_NAME, SetDefinedNameCommand, SetSelectionsOperation, SetWorksheetActiveOperation, SetWorksheetOrderCommand, SheetsSelectionsService, WorkbookEditablePermission } from '@univerjs/sheets';import { FDefinedName, FDefinedNameBuilder } from './f-defined-name';@@ -25,12 +25,12 @@ import { FPermission } from './f-permission';import { FRange } from './f-range';import { FWorksheet } from './f-worksheet';-export class FWorkbook extends FBase {+export class FWorkbook extends FBaseInitialable {readonly id: string;constructor(protected readonly _workbook: Workbook,- @Inject(Injector) protected readonly _injector: Injector,+ @Inject(Injector) protected override readonly _injector: Injector,@Inject(IResourceLoaderService) protected readonly _resourceLoaderService: IResourceLoaderService,@Inject(SheetsSelectionsService) protected readonly _selectionManagerService: SheetsSelectionsService,@IUniverInstanceService protected readonly _univerInstanceService: IUniverInstanceService,@@ -40,7 +40,7 @@ export class FWorkbook extends FBase {@Inject(LocaleService) protected readonly _localeService: LocaleService,@IDefinedNamesService protected readonly _definedNamesService: IDefinedNamesService) {- super();+ super(_injector);this.id = this._workbook.getUnitId();}diff --git a/packages/sheets/src/facade/f-worksheet.ts b/packages/sheets/src/facade/f-worksheet.tsindex 78ccf13777..e29616a7b7 100644--- a/packages/sheets/src/facade/f-worksheet.ts+++ b/packages/sheets/src/facade/f-worksheet.ts@@ -18,7 +18,7 @@ import type { CustomData, ICellData, IColumnData, IDisposable, IFreeze, IObjectAimport type { ISetColDataCommandParams, ISetGridlinesColorCommandParams, ISetRangeValuesMutationParams, ISetRowDataCommandParams, IToggleGridlinesCommandParams } from '@univerjs/sheets';import type { FDefinedName } from './f-defined-name';import type { FWorkbook } from './f-workbook';-import { BooleanNumber, Direction, FBase, ICommandService, ILogService, Inject, Injector, ObjectMatrix, RANGE_TYPE } from '@univerjs/core';+import { BooleanNumber, Direction, FBaseInitialable, ICommandService, ILogService, Inject, Injector, ObjectMatrix, RANGE_TYPE } from '@univerjs/core';import { deserializeRangeWithSheet } from '@univerjs/engine-formula';import { CancelFrozenCommand, ClearSelectionAllCommand, ClearSelectionContentCommand, ClearSelectionFormatCommand, copyRangeStyles, InsertColByRangeCommand, InsertRowByRangeCommand, MoveColsCommand, MoveRowsCommand, RemoveColByRangeCommand, RemoveRowByRangeCommand, SetColDataCommand, SetColHiddenCommand, SetColWidthCommand, SetFrozenCommand, SetGridlinesColorCommand, SetRangeValuesMutation, SetRowDataCommand, SetRowHeightCommand, SetRowHiddenCommand, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetTabColorCommand, SetWorksheetDefaultStyleMutation, SetWorksheetHideCommand, SetWorksheetNameCommand, SetWorksheetRowIsAutoHeightCommand, SetWorksheetShowCommand, SheetsSelectionsService, ToggleGridlinesCommand } from '@univerjs/sheets';import { FDefinedNameBuilder } from './f-defined-name';@@ -34,17 +34,17 @@ interface IFacadeClearOptions {/*** Represents a worksheet facade api instance. Which provides a set of methods to interact with the worksheet.*/-export class FWorksheet extends FBase {+export class FWorksheet extends FBaseInitialable {constructor(protected readonly _fWorkbook: FWorkbook,protected readonly _workbook: Workbook,protected readonly _worksheet: Worksheet,- @Inject(Injector) protected readonly _injector: Injector,+ @Inject(Injector) protected override readonly _injector: Injector,@Inject(SheetsSelectionsService) protected readonly _selectionManagerService: SheetsSelectionsService,@Inject(ILogService) protected readonly _logService: ILogService,@ICommandService protected readonly _commandService: ICommandService) {- super();+ super(_injector);}/**diff --git a/packages/sheets/src/facade/index.ts b/packages/sheets/src/facade/index.tsindex 0574f54cee..a71f0d4834 100644--- a/packages/sheets/src/facade/index.ts+++ b/packages/sheets/src/facade/index.ts@@ -16,15 +16,16 @@import './f-univer';+export * from './f-event';export { FPermission } from './f-permission';export { FRange } from './f-range';export type { FontLine, FontStyle, FontWeight } from './f-range';export { FSelection } from './f-selection';+export { FSheetHooks } from './f-sheet-hooks';export { FWorkbook } from './f-workbook';-// eslint-disable-next-line perfectionist/sort-exports-export { FWorksheet } from './f-worksheet';// eslint-disable-next-line perfectionist/sort-exportsexport type * from './f-univer';+export { FWorksheet } from './f-worksheet';