diff --git a/examples-node/src/cases/basic.ts b/examples-node/src/cases/basic.ts index d4d0d60f7be..05953b44168 100644 --- a/examples-node/src/cases/basic.ts +++ b/examples-node/src/cases/basic.ts @@ -18,7 +18,7 @@ import process from 'node:process'; import { awaitTime, FUniver } from '@univerjs/core'; import { createUniverOnNode } from '../sdk'; -import '@univerjs/sheets/facade'; +import '../sdk/facade'; // From now on, Univer is a full-stack SDK. diff --git a/examples-node/src/sdk/facade.ts b/examples-node/src/sdk/facade.ts new file mode 100644 index 00000000000..5ba94c3f48b --- /dev/null +++ b/examples-node/src/sdk/facade.ts @@ -0,0 +1,24 @@ +/** + * 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. + */ + +// Facade API here are part of packages/facade/src/apis/everything.ts +// However some plugins are implemented incorrectly, so they are not included here. + +import '@univerjs/sheets/facade'; +import '@univerjs/sheets-data-validation/facade'; +import '@univerjs/engine-formula/facade'; +import '@univerjs/sheets-filter/facade'; +import '@univerjs/sheets-formula/facade'; diff --git a/packages-experimental/action-recorder/package.json b/packages-experimental/action-recorder/package.json index ec38ac96dd6..77252f0613f 100644 --- a/packages-experimental/action-recorder/package.json +++ b/packages-experimental/action-recorder/package.json @@ -67,7 +67,7 @@ "@univerjs/design": "workspace:*", "@univerjs/icons": "^0.1.79", "@univerjs/sheets": "workspace:*", - "@univerjs/sheets-filter-ui": "workspace:*", + "@univerjs/sheets-filter": "workspace:*", "@univerjs/sheets-ui": "workspace:*", "@univerjs/ui": "workspace:*", "clsx": "^2.1.1" diff --git a/packages-experimental/action-recorder/src/controllers/action-recorder.controller.tsx b/packages-experimental/action-recorder/src/controllers/action-recorder.controller.tsx index f79cb30b699..d20ec2176e8 100644 --- a/packages-experimental/action-recorder/src/controllers/action-recorder.controller.tsx +++ b/packages-experimental/action-recorder/src/controllers/action-recorder.controller.tsx @@ -20,6 +20,7 @@ import { AddWorksheetMergeAllCommand, AddWorksheetMergeCommand, AddWorksheetMergeHorizontalCommand, AddWorksheetMergeVerticalCommand, + CancelFrozenCommand, CopySheetCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, @@ -31,7 +32,6 @@ import { AddWorksheetMergeAllCommand, InsertRowBeforeCommand, InsertSheetCommand, RemoveSheetCommand, - SetFrozenCancelCommand, SetFrozenCommand, SetHorizontalTextAlignCommand, SetOverlineCommand, @@ -47,7 +47,7 @@ import { AddWorksheetMergeAllCommand, SetWorksheetActivateCommand, SetWorksheetActiveOperation, } from '@univerjs/sheets'; -import { RemoveSheetFilterCommand, SetSheetFilterRangeCommand, SetSheetsFilterCriteriaCommand } from '@univerjs/sheets-filter-ui'; +import { RemoveSheetFilterCommand, SetSheetFilterRangeCommand, SetSheetsFilterCriteriaCommand } from '@univerjs/sheets-filter'; import { SetRangeBoldCommand, SetRangeFontFamilyCommand, SetRangeFontSizeCommand, @@ -142,8 +142,8 @@ export class ActionRecorderController extends Disposable { // SetBoldCommand, // SetFontFamilyCommand, // SetFontSizeCommand, - SetFrozenCancelCommand, SetFrozenCommand, + CancelFrozenCommand, SetHorizontalTextAlignCommand, // SetItalicCommand, SetOverlineCommand, diff --git a/packages/core/src/facade/f-base.ts b/packages/core/src/facade/f-base.ts new file mode 100644 index 00000000000..1d66c498b18 --- /dev/null +++ b/packages/core/src/facade/f-base.ts @@ -0,0 +1,53 @@ +/** + * 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. + */ + +/** + * `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> = []; + + constructor() { + FBase._constructorQueue.forEach((fn) => { + fn(); + }); + } + + _initialize() { } + + static extend(source: any): void { + Object.getOwnPropertyNames(source.prototype).forEach((name) => { + if (name === '_initialize') { + FBase._constructorQueue.push( + source.prototype._initialize.bind(this) + ); + } else 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]; + } + }); + } +} + diff --git a/packages/core/src/facade/f-hooks.ts b/packages/core/src/facade/f-hooks.ts index b4c8db1c400..b71e05a37b4 100644 --- a/packages/core/src/facade/f-hooks.ts +++ b/packages/core/src/facade/f-hooks.ts @@ -23,7 +23,7 @@ import { LifecycleStages } from '../services/lifecycle/lifecycle'; import { LifecycleService } from '../services/lifecycle/lifecycle.service'; import { IUndoRedoService, RedoCommand, UndoCommand } from '../services/undoredo/undoredo.service'; import { toDisposable } from '../shared/lifecycle'; -import { FBase } from './f-univer'; +import { FBase } from './f-base'; export class FHooks extends FBase { constructor( diff --git a/packages/core/src/facade/f-univer.ts b/packages/core/src/facade/f-univer.ts index 72ee01c6a66..662c38c6a5a 100644 --- a/packages/core/src/facade/f-univer.ts +++ b/packages/core/src/facade/f-univer.ts @@ -23,45 +23,9 @@ import { IUniverInstanceService } from '../services/instance/instance.service'; import { LifecycleService } from '../services/lifecycle/lifecycle.service'; import { RedoCommand, UndoCommand } from '../services/undoredo/undoredo.service'; import { Univer } from '../univer'; +import { FBase } from './f-base'; import { FHooks } from './f-hooks'; -/** - * `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> = []; - - constructor() { - FBase._constructorQueue.forEach((fn) => { - fn(); - }); - } - - _initialize() { } - - static extend(source: any): void { - Object.getOwnPropertyNames(source.prototype).forEach((name) => { - if (name === '_initialize') { - FBase._constructorQueue.push( - source.prototype._initialize.bind(this) - ); - } else 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]; - } - }); - } -} - export class FUniver extends FBase { /** * Create an FUniver instance, if the injector is not provided, it will create a new Univer instance. diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 88f7b7300b9..8b2ffcd97f8 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -39,7 +39,8 @@ export { composeInterceptors, createInterceptorKey, InterceptorEffectEnum, Inter export type { Serializable } from './common/json'; export { MemoryCursor } from './common/memory-cursor'; export { mixinClass } from './common/mixin'; -export { FBase, FUniver } from './facade/f-univer'; +export { FBase } from './facade/f-base'; +export { FUniver } from './facade/f-univer'; export { FHooks } from './facade/f-hooks'; export { isNumeric, isSafeNumeric } from './common/number'; export { Registry, RegistryAsMap } from './common/registry'; diff --git a/packages/facade/src/apis/everything.ts b/packages/facade/src/apis/everything.ts index 971375de921..f2d13069f35 100644 --- a/packages/facade/src/apis/everything.ts +++ b/packages/facade/src/apis/everything.ts @@ -22,8 +22,9 @@ import '@univerjs/sheets-data-validation/facade'; import '@univerjs/engine-formula/facade'; import '@univerjs/sheets-filter/facade'; import '@univerjs/sheets-formula/facade'; -import '@univerjs/sheets-numfmt/facade'; // TODO: extract -import '@univerjs/sheets-hyper-link-ui/facade'; // TODO: extract +import '@univerjs/sheets-numfmt/facade'; // TODO@Gggpound: extract +import '@univerjs/sheets-hyper-link-ui/facade'; // TODO@weird94: extract +import '@univerjs/sheets-thread-comment/facade'; // TODO@weird94: extract export { FHooks, FUniver } from '@univerjs/core'; export { FFormula } from '@univerjs/engine-formula/facade'; diff --git a/packages/sheets-find-replace/src/controllers/__tests__/utils.spec.ts b/packages/sheets-find-replace/src/controllers/__tests__/utils.spec.ts index c6b49ee324f..a4ffc69a943 100644 --- a/packages/sheets-find-replace/src/controllers/__tests__/utils.spec.ts +++ b/packages/sheets-find-replace/src/controllers/__tests__/utils.spec.ts @@ -14,12 +14,13 @@ * limitations under the License. */ -import { afterEach, beforeEach, describe, expect, it } from 'vitest'; - import type { Dependency, IWorkbookData, Worksheet } from '@univerjs/core'; -import { ILogService, IUniverInstanceService, LocaleType, LogLevel, Univer } from '@univerjs/core'; + import type { IFindQuery } from '@univerjs/find-replace'; +import { ILogService, IUniverInstanceService, LocaleType, LogLevel, Univer } from '@univerjs/core'; import { FindBy, FindDirection, FindScope } from '@univerjs/find-replace'; +import { afterEach, beforeEach, describe, expect, it } from 'vitest'; +import { hitCell } from '../sheet-find-replace.controller'; import { isBeforePositionWithColumnPriority, isBeforePositionWithRowPriority, @@ -27,7 +28,6 @@ import { isBehindPositionWithRowPriority, isSamePosition, } from '../utils'; -import { hitCell } from '../sheet-find-replace.controller'; describe('Test sheet find replace utils', () => { it('Should "isSamePosition" work as expected', () => { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6a57f606f33..4b06bf558c5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,7 +10,7 @@ importers: devDependencies: '@antfu/eslint-config': specifier: 3.7.3 - version: 3.7.3(@eslint-react/eslint-plugin@1.14.3(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3))(@typescript-eslint/utils@8.8.1(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3))(@vue/compiler-sfc@3.5.9)(eslint-plugin-format@0.1.2(eslint@9.12.0(jiti@1.21.6)))(eslint-plugin-react-hooks@5.1.0-rc-107a2f8c3e-20240617(eslint@9.12.0(jiti@1.21.6)))(eslint-plugin-react-refresh@0.4.12(eslint@9.12.0(jiti@1.21.6)))(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3)(vitest@2.1.2(@types/node@22.7.5)(happy-dom@15.0.0)(jsdom@24.1.1)(less@4.2.0)(sass@1.77.5)(terser@5.31.6)) + version: 3.7.3(@eslint-react/eslint-plugin@1.14.3(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3))(@typescript-eslint/utils@8.8.1(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3))(@vue/compiler-sfc@3.5.9)(eslint-plugin-format@0.1.2(eslint@9.12.0(jiti@1.21.6)))(eslint-plugin-react-hooks@5.1.0-rc-107a2f8c3e-20240617(eslint@9.12.0(jiti@1.21.6)))(eslint-plugin-react-refresh@0.4.12(eslint@9.12.0(jiti@1.21.6)))(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3)(vitest@2.1.2(@types/node@22.7.5)(less@4.2.0)(sass@1.77.5)(terser@5.31.6)) '@commitlint/cli': specifier: ^19.5.0 version: 19.5.0(@types/node@22.7.5)(typescript@5.6.3) @@ -576,9 +576,9 @@ importers: '@univerjs/sheets': specifier: workspace:* version: link:../../packages/sheets - '@univerjs/sheets-filter-ui': + '@univerjs/sheets-filter': specifier: workspace:* - version: link:../../packages/sheets-filter-ui + version: link:../../packages/sheets-filter '@univerjs/sheets-ui': specifier: workspace:* version: link:../../packages/sheets-ui @@ -10788,7 +10788,7 @@ snapshots: dependencies: '@babel/runtime': 7.25.0 - '@antfu/eslint-config@3.7.3(@eslint-react/eslint-plugin@1.14.3(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3))(@typescript-eslint/utils@8.8.1(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3))(@vue/compiler-sfc@3.5.9)(eslint-plugin-format@0.1.2(eslint@9.12.0(jiti@1.21.6)))(eslint-plugin-react-hooks@5.1.0-rc-107a2f8c3e-20240617(eslint@9.12.0(jiti@1.21.6)))(eslint-plugin-react-refresh@0.4.12(eslint@9.12.0(jiti@1.21.6)))(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3)(vitest@2.1.2(@types/node@22.7.5)(happy-dom@15.0.0)(jsdom@24.1.1)(less@4.2.0)(sass@1.77.5)(terser@5.31.6))': + '@antfu/eslint-config@3.7.3(@eslint-react/eslint-plugin@1.14.3(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3))(@typescript-eslint/utils@8.8.1(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3))(@vue/compiler-sfc@3.5.9)(eslint-plugin-format@0.1.2(eslint@9.12.0(jiti@1.21.6)))(eslint-plugin-react-hooks@5.1.0-rc-107a2f8c3e-20240617(eslint@9.12.0(jiti@1.21.6)))(eslint-plugin-react-refresh@0.4.12(eslint@9.12.0(jiti@1.21.6)))(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3)(vitest@2.1.2(@types/node@22.7.5)(less@4.2.0)(sass@1.77.5)(terser@5.31.6))': dependencies: '@antfu/install-pkg': 0.4.1 '@clack/prompts': 0.7.0 @@ -10797,7 +10797,7 @@ snapshots: '@stylistic/eslint-plugin': 2.8.0(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3) '@typescript-eslint/eslint-plugin': 8.7.0(@typescript-eslint/parser@8.8.1(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3))(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3) '@typescript-eslint/parser': 8.8.1(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3) - '@vitest/eslint-plugin': 1.1.4(@typescript-eslint/utils@8.8.1(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3))(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3)(vitest@2.1.2(@types/node@22.7.5)(happy-dom@15.0.0)(jsdom@24.1.1)(less@4.2.0)(sass@1.77.5)(terser@5.31.6)) + '@vitest/eslint-plugin': 1.1.4(@typescript-eslint/utils@8.8.1(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3))(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3)(vitest@2.1.2(@types/node@22.7.5)(less@4.2.0)(sass@1.77.5)(terser@5.31.6)) eslint: 9.12.0(jiti@1.21.6) eslint-config-flat-gitignore: 0.3.0(eslint@9.12.0(jiti@1.21.6)) eslint-flat-config-utils: 0.4.0 @@ -12867,7 +12867,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@vitest/eslint-plugin@1.1.4(@typescript-eslint/utils@8.8.1(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3))(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3)(vitest@2.1.2(@types/node@22.7.5)(happy-dom@15.0.0)(jsdom@24.1.1)(less@4.2.0)(sass@1.77.5)(terser@5.31.6))': + '@vitest/eslint-plugin@1.1.4(@typescript-eslint/utils@8.8.1(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3))(eslint@9.12.0(jiti@1.21.6))(typescript@5.6.3)(vitest@2.1.2(@types/node@22.7.5)(less@4.2.0)(sass@1.77.5)(terser@5.31.6))': dependencies: eslint: 9.12.0(jiti@1.21.6) optionalDependencies: