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(facade): f-event & f-enum extend error (#4424)
zhangwbe77c479ebc9
diff --git a/packages/core/src/facade/f-enum.ts b/packages/core/src/facade/f-enum.tsindex 91e56e47b3..7c2f55f0ca 100644--- a/packages/core/src/facade/f-enum.ts+++ b/packages/core/src/facade/f-enum.ts@@ -21,9 +21,8 @@ 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 {+export class FEnum {static _instance: FEnum | null;static get() {if (this._instance) {@@ -35,6 +34,29 @@ export class FEnum extends FBase {return instance;}+ static extend(source: any): void {+ Object.getOwnPropertyNames(source.prototype).forEach((name) => {+ if (name !== 'constructor') {+ // @ts-ignore+ this.prototype[name] = source.prototype[name];+ }+ });++ Object.getOwnPropertyNames(source).forEach((name) => {+ if (name !== 'prototype' && name !== 'name' && name !== 'length') {+ // @ts-ignore+ this[name] = source[name];+ }+ });+ }++ constructor() {+ for (const key in FEnum.prototype) {+ // @ts-ignore+ this[key] = FEnum.prototype[key];+ }+ }+get UniverInstanceType() {return UniverInstanceType;}@@ -62,8 +84,4 @@ export class FEnum extends FBase {get DataValidationStatus() {return DataValidationStatus;}-- constructor() {- super();- }}diff --git a/packages/core/src/facade/f-event.ts b/packages/core/src/facade/f-event.tsindex 867c5be6ac..6228bd54e8 100644--- a/packages/core/src/facade/f-event.ts+++ b/packages/core/src/facade/f-event.ts@@ -18,7 +18,6 @@ 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;@@ -42,7 +41,7 @@ export interface IEventBase {export type IUnitCreateEvent = IEventBase & (ISheetCreateParam | IDocumentCreateParam);export type ILifeCycleChangedEvent = IEventBase & ILifeCycleChangedParam;-export class FEventName extends FBase {+export class FEventName {static _intance: FEventName | null;static get() {if (this._intance) {@@ -54,6 +53,29 @@ export class FEventName extends FBase {return instance;}+ static extend(source: any): void {+ Object.getOwnPropertyNames(source.prototype).forEach((name) => {+ if (name !== 'constructor') {+ // @ts-ignore+ this.prototype[name] = source.prototype[name];+ }+ });++ Object.getOwnPropertyNames(source).forEach((name) => {+ if (name !== 'prototype' && name !== 'name' && name !== 'length') {+ // @ts-ignore+ this[name] = source[name];+ }+ });+ }++ constructor() {+ for (const key in FEventName.prototype) {+ // @ts-ignore+ this[key] = FEventName.prototype[key];+ }+ }+get UnitCreated() {return 'UnitCreated' as const;}