Skip to content

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.

feat: enable running get filter values in worker

Wenzhao Hudf35f3e9c469
diff --git a/examples/src/sheets/lazy.ts b/examples/src/sheets/lazy.ts
index a58835af8c..41dc02ab98 100644
--- a/examples/src/sheets/lazy.ts
+++ b/examples/src/sheets/lazy.ts
@@ -33,7 +33,7 @@ export default function getLazyPlugins(): Array<[PluginCtor<Plugin>] | [PluginCt
// },
// },
// ],
- [UniverSheetsFilterUIPlugin],
+ [UniverSheetsFilterUIPlugin, { useRemoteFilterValuesGenerator: true }],
[UniverSheetsFindReplacePlugin],
];
}
diff --git a/examples/src/sheets/main.ts b/examples/src/sheets/main.ts
index 5af8ae88f4..6216360cb7 100644
--- a/examples/src/sheets/main.ts
+++ b/examples/src/sheets/main.ts
@@ -40,9 +40,9 @@ import { UniverSheetsZenEditorPlugin } from '@univerjs/sheets-zen-editor';
import { UniverSheetsSortUIPlugin } from '@univerjs/sheets-sort-ui';
import { UniverSheetsDrawingUIPlugin } from '@univerjs/sheets-drawing-ui';
import { UniverDocsHyperLinkPlugin } from '@univerjs/docs-hyper-link';
-
import { enUS, ruRU, viVN, zhCN, zhTW } from '../locales';
import { DEFAULT_WORKBOOK_DATA_DEMO } from '../data/sheets/demo/default-workbook-data-demo';
+
/* eslint-disable-next-line node/prefer-global/process */
const IS_E2E: boolean = !!process.env.IS_E2E;
diff --git a/examples/src/sheets/worker.ts b/examples/src/sheets/worker.ts
index bc72b2cdfc..1795528ffa 100644
--- a/examples/src/sheets/worker.ts
+++ b/examples/src/sheets/worker.ts
@@ -18,18 +18,28 @@ import { LocaleType, LogLevel, Univer } from '@univerjs/core';
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';
import { UniverRPCWorkerThreadPlugin } from '@univerjs/rpc';
import { UniverSheetsPlugin } from '@univerjs/sheets';
+import { UniverSheetsFilterUIWorkerPlugin } from '@univerjs/sheets-filter-ui';
import { UniverRemoteSheetsFormulaPlugin } from '@univerjs/sheets-formula';
+import { enUS, ruRU, viVN, zhCN, zhTW } from '../locales';
// Univer web worker is also a univer application.
const univer = new Univer({
locale: LocaleType.ZH_CN,
logLevel: LogLevel.VERBOSE,
+ locales: {
+ [LocaleType.ZH_CN]: zhCN,
+ [LocaleType.EN_US]: enUS,
+ [LocaleType.RU_RU]: ruRU,
+ [LocaleType.ZH_TW]: zhTW,
+ [LocaleType.VI_VN]: viVN,
+ },
});
univer.registerPlugin(UniverSheetsPlugin, { onlyRegisterFormulaRelatedMutations: true });
univer.registerPlugin(UniverFormulaEnginePlugin);
univer.registerPlugin(UniverRPCWorkerThreadPlugin);
univer.registerPlugin(UniverRemoteSheetsFormulaPlugin);
+univer.registerPlugin(UniverSheetsFilterUIWorkerPlugin);
declare let self: WorkerGlobalScope & typeof globalThis & { univer: Univer };
self.univer = univer;
diff --git a/packages/rpc/src/plugin.ts b/packages/rpc/src/plugin.ts
index 7131c3dcd8..6b8535a70e 100644
--- a/packages/rpc/src/plugin.ts
+++ b/packages/rpc/src/plugin.ts
@@ -71,8 +71,6 @@ export class UniverRPCMainThreadPlugin extends Plugin {
}
}
-export interface IUniverRPCWorkerThreadPluginConfig {}
-
/**
* This plugin is used to register the RPC services on the worker thread.
*/
@@ -80,7 +78,7 @@ export class UniverRPCWorkerThreadPlugin extends Plugin {
static override pluginName = 'UNIVER_RPC_WORKER_THREAD_PLUGIN';
constructor(
- private readonly _config: IUniverRPCWorkerThreadPluginConfig,
+ private readonly _config: unknown,
@Inject(Injector) protected readonly _injector: Injector
) {
super();
diff --git a/packages/sheets-filter-ui/package.json b/packages/sheets-filter-ui/package.json
index 0a0d5cd3eb..b61ed89f4c 100644
--- a/packages/sheets-filter-ui/package.json
+++ b/packages/sheets-filter-ui/package.json
@@ -66,6 +66,7 @@
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/engine-render": "workspace:*",
+ "@univerjs/rpc": "workspace:*",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-filter": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
@@ -83,6 +84,7 @@
"@univerjs/design": "workspace:*",
"@univerjs/drawing": "workspace:*",
"@univerjs/engine-render": "workspace:*",
+ "@univerjs/rpc": "workspace:*",
"@univerjs/shared": "workspace:*",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-filter": "workspace:*",
diff --git a/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts b/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts
index 163c8c8a80..71aeeb181c 100644
--- a/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts
+++ b/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts
@@ -21,7 +21,7 @@ import { SetSheetsFilterRangeMutation, UniverSheetsFilterPlugin } from '@univerj
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { RefRangeService, SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';
import type { IEditorBridgeServiceVisibleParam } from '@univerjs/sheets-ui';
-import { CloseFilterPanelOperation, FILTER_PANEL_OPENED_KEY, OpenFilterPanelOperation } from '../sheets-filter.operation';
+import { CloseFilterPanelOperation, FILTER_PANEL_OPENED_KEY, OpenFilterPanelCommand } from '../sheets-filter.operation';
import { SheetsFilterPanelService } from '../../../services/sheets-filter-panel.service';
const SetCellEditVisibleOperation: IOperation<IEditorBridgeServiceVisibleParam> = {
@@ -92,7 +92,7 @@ function createFilterOperationTestBed() {
const commandService = get(ICommandService);
[
- OpenFilterPanelOperation,
+ OpenFilterPanelCommand,
CloseFilterPanelOperation,
SetCellEditVisibleOperation,
].forEach((command) => commandService.registerCommand(command));
@@ -124,7 +124,7 @@ describe('test sheets filter ui operations', () => {
describe('test "OpenFilerPanelOperation"', () => {
it('should return false when the filter model is not found', () => {
const spy = vi.spyOn(sheetsFilterPanelService, 'setupCol');
- expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
@@ -139,7 +139,7 @@ describe('test sheets filter ui operations', () => {
subUnitId: 'sheet1',
range: { startRow: 0, startColumn: 0, endRow: 5, endColumn: 5 },
} as ISetSheetsFilterRangeMutationParams)).toBeTruthy();
- expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
diff --git a/packages/sheets-filter-ui/src/commands/operations/sheets-filter.operation.ts b/packages/sheets-filter-ui/src/commands/operations/sheets-filter.operation.ts
index 62146fa924..22bfc0856e 100644
--- a/packages/sheets-filter-ui/src/commands/operations/sheets-filter.operation.ts
+++ b/packages/sheets-filter-ui/src/commands/operations/sheets-filter.operation.ts
@@ -14,17 +14,17 @@
* limitations under the License.
*/
-import { CommandType, ICommandService, IContextService, type IOperation } from '@univerjs/core';
+import type { ICommand, IOperation } from '@univerjs/core';
+import { CommandType, ICommandService, IContextService, Quantity } from '@univerjs/core';
import { SheetsFilterService } from '@univerjs/sheets-filter';
import { ILayoutService } from '@univerjs/ui';
-import { Quantity } from '@univerjs/core';
import { SetCellEditVisibleOperation } from '@univerjs/sheets-ui';
import type { FilterBy } from '../../services/sheets-filter-panel.service';
import { SheetsFilterPanelService } from '../../services/sheets-filter-panel.service';
export const FILTER_PANEL_OPENED_KEY = 'FILTER_PANEL_OPENED';
-export interface IOpenFilterPanelOperationParams {
+export interface IOpenFilterPanelCommandParams {
unitId: string;
subUnitId: string;
@@ -34,10 +34,10 @@ export interface IOpenFilterPanelOperationParams {
/**
* The operation to open the filter panel and prepare for changing the filter conditions on a given column.
*/
-export const OpenFilterPanelOperation: IOperation<IOpenFilterPanelOperationParams> = {
- id: 'sheet.operation.open-filter-panel',
- type: CommandType.OPERATION,
- handler: (accessor, params) => {
+export const OpenFilterPanelCommand: ICommand<IOpenFilterPanelCommandParams> = {
+ id: 'sheet.commadn.open-filter-panel',
+ type: CommandType.COMMAND,
+ handler: async (accessor, params: IOpenFilterPanelCommandParams) => {
const contextService = accessor.get(IContextService);
const sheetsFilterService = accessor.get(SheetsFilterService);
const sheetsFilterPanelService = accessor.get(SheetsFilterPanelService);
@@ -50,7 +50,7 @@ export const OpenFilterPanelOperation: IOperation<IOpenFilterPanelOperationParam
const filterModel = sheetsFilterService.getFilterModel(unitId, subUnitId);
if (!filterModel) return false;
- const result = sheetsFilterPanelService.setupCol(filterModel, col);
+ const result = await sheetsFilterPanelService.setupCol(filterModel, col);
if (!result) return false;
if (!contextService.getContextValue(FILTER_PANEL_OPENED_KEY)) {
diff --git a/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts b/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts
index 4d77b8b389..bf7ea1c824 100644
--- a/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts
+++ b/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts
@@ -22,7 +22,7 @@ import { RemoveSheetsFilterMutation, SetSheetsFilterCriteriaMutation, SetSheetsF
import { IMenuService, IPlatformService, IShortcutService, MenuService, PlatformService, ShortcutService } from '@univerjs/ui';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { ClearSheetsFilterCriteriaCommand, ReCalcSheetsFilterCommand, SmartToggleSheetsFilterCommand } from '../../commands/commands/sheets-filter.command';
-import { CloseFilterPanelOperation, OpenFilterPanelOperation } from '../../commands/operations/sheets-filter.operation';
+import { CloseFilterPanelOperation, OpenFilterPanelCommand } from '../../commands/operations/sheets-filter.operation';
import { ClearFilterCriteriaMenuItemFactory, ReCalcFilterMenuItemFactory, SmartToggleFilterMenuItemFactory } from '../sheets-filter.menu';
const TEST_WORKBOOK_DATA_DEMO: IWorkbookData = {
@@ -82,7 +82,7 @@ function createSheetsFilterMenuTestBed() {
SmartToggleSheetsFilterCommand,
ClearSheetsFilterCriteriaCommand,
ReCalcSheetsFilterCommand,
- OpenFilterPanelOperation,
+ OpenFilterPanelCommand,
CloseFilterPanelOperation,
].forEach((command) => commandService.registerCommand(command));
}
diff --git a/packages/sheets-filter-ui/src/controllers/sheets-filter-permission.controller.ts b/packages/sheets-filter-ui/src/controllers/sheets-filter-permission.controller.ts
index 0b9f074c08..310684edd0 100644
--- a/packages/sheets-filter-ui/src/controllers/sheets-filter-permission.controller.ts
+++ b/packages/sheets-filter-ui/src/controllers/sheets-filter-permission.controller.ts
@@ -23,7 +23,7 @@ import { SheetPermissionInterceptorBaseController } from '@univerjs/sheets-ui';
import { SheetsFilterService } from '@univerjs/sheets-filter';
import { RangeProtectionPermissionViewPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetFilterPermission } from '@univerjs/sheets';
import { SmartToggleSheetsFilterCommand } from '../commands/commands/sheets-filter.command';
-import { type IOpenFilterPanelOperationParams, OpenFilterPanelOperation } from '../commands/operations/sheets-filter.operation';
+import { type IOpenFilterPanelCommandParams, OpenFilterPanelCommand } from '../commands/operations/sheets-filter.operation';
export interface IUniverSheetsFilterUIConfig {
menu: MenuConfig;
@@ -63,8 +63,8 @@ export class SheetsFilterPermissionController extends Disposable {
this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t('permission.dialog.filterErr'));
}
}
- if (command.id === OpenFilterPanelOperation.id) {
- const params = command.params as IOpenFilterPanelOperationParams;
+ if (command.id === OpenFilterPanelCommand.id) {
+ const params = command.params as IOpenFilterPanelCommandParams;
const { unitId, subUnitId } = params;
const filterRange = this._sheetsFilterService.getFilterModel(unitId, subUnitId)?.getRange();
const colRange = Tools.deepClone(filterRange);
diff --git a/packages/sheets-filter-ui/src/controllers/sheets-filter-ui.controller.ts b/packages/sheets-filter-ui/src/controllers/sheets-filter-ui.controller.ts
index ffe2ba5967..ea15a86c48 100644
--- a/packages/sheets-filter-ui/src/controllers/sheets-filter-ui.controller.ts
+++ b/packages/sheets-filter-ui/src/controllers/sheets-filter-ui.controller.ts
@@ -28,7 +28,7 @@ import { SheetsFilterService } from '@univerjs/sheets-filter';
import { MessageType } from '@univerjs/design';
import { ClearSheetsFilterCriteriaCommand, ReCalcSheetsFilterCommand, SetSheetsFilterCriteriaCommand, SmartToggleSheetsFilterCommand } from '../commands/commands/sheets-filter.command';
import { FilterPanel } from '../views/components/SheetsFilterPanel';
-import { ChangeFilterByOperation, CloseFilterPanelOperation, FILTER_PANEL_OPENED_KEY, OpenFilterPanelOperation } from '../commands/operations/sheets-filter.operation';
+import { ChangeFilterByOperation, CloseFilterPanelOperation, FILTER_PANEL_OPENED_KEY, OpenFilterPanelCommand } from '../commands/operations/sheets-filter.operation';
import { SheetsFilterPanelService } from '../services/sheets-filter-panel.service';
import { SmartToggleFilterShortcut } from './sheets-filter.shortcut';
import { ClearFilterCriteriaMenuItemFactory, ReCalcFilterMenuItemFactory, SmartToggleFilterMenuItemFactory } from './sheets-filter.menu';
@@ -36,6 +36,8 @@ import { SheetsFilterMobileUIController } from './sheets-filter-mobile-ui.contro
export interface IUniverSheetsFilterUIConfig {
menu: MenuConfig;
+
+ useRemoteFilterValuesGenerator?: boolean;
}
export const DefaultSheetFilterUiConfig = {};
@@ -91,7 +93,7 @@ export class SheetsFilterUIController extends SheetsFilterMobileUIController {
ClearSheetsFilterCriteriaCommand,
ReCalcSheetsFilterCommand,
ChangeFilterByOperation,
- OpenFilterPanelOperation,
+ OpenFilterPanelCommand,
CloseFilterPanelOperation,
].forEach((c) => {
this.disposeWithMe(this._commandService.registerCommand(c));
diff --git a/packages/sheets-filter-ui/src/index.ts b/packages/sheets-filter-ui/src/index.ts
index 8b048d522f..2af4893bfe 100644
--- a/packages/sheets-filter-ui/src/index.ts
+++ b/packages/sheets-filter-ui/src/index.ts
@@ -16,6 +16,7 @@
export { UniverSheetsFilterUIPlugin } from './plugin';
export { UniverSheetsFilterMobileUIPlugin } from './mobile-plugin';
+export { UniverSheetsFilterUIWorkerPlugin } from './worker/plugin';
// #region - all commands
@@ -26,10 +27,10 @@ export {
ReCalcSheetsFilterCommand,
} from './commands/commands/sheets-filter.command';
export {
- OpenFilterPanelOperation,
+ OpenFilterPanelCommand,
CloseFilterPanelOperation,
ChangeFilterByOperation,
- type IOpenFilterPanelOperationParams,
+ type IOpenFilterPanelCommandParams,
} from './commands/operations/sheets-filter.operation';
// #endregion
diff --git a/packages/sheets-filter-ui/src/plugin.ts b/packages/sheets-filter-ui/src/plugin.ts
index e9b16585dc..1d78a7196b 100644
--- a/packages/sheets-filter-ui/src/plugin.ts
+++ b/packages/sheets-filter-ui/src/plugin.ts
@@ -14,14 +14,15 @@
* limitations under the License.
*/
-import { DependentOn, Inject, Injector, LocaleService, Plugin, Tools, UniverInstanceType } from '@univerjs/core';
+import { DependentOn, Inject, Injector, Optional, Plugin, Tools, UniverInstanceType } from '@univerjs/core';
import type { Dependency } from '@univerjs/core';
import { UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
-
+import { IRPCChannelService, toModule } from '@univerjs/rpc';
import type { IUniverSheetsFilterUIConfig } from './controllers/sheets-filter-ui.controller';
import { DefaultSheetFilterUiConfig, SheetsFilterUIController } from './controllers/sheets-filter-ui.controller';
import { SheetsFilterPanelService } from './services/sheets-filter-panel.service';
import { SheetsFilterPermissionController } from './controllers/sheets-filter-permission.controller';
+import { ISheetsGenerateFilterValuesService, SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME } from './worker/generate-filter-values.service';
const NAME = 'SHEET_FILTER_UI_PLUGIN';
@@ -33,7 +34,7 @@ export class UniverSheetsFilterUIPlugin extends Plugin {
constructor(
private readonly _config: Partial<IUniverSheetsFilterUIConfig> = {},
@Inject(Injector) protected readonly _injector: Injector,
- @Inject(LocaleService) private readonly _localeService: LocaleService
+ @Optional(IRPCChannelService) private readonly _rpcChannelService?: IRPCChannelService
) {
super();
@@ -51,5 +52,15 @@ export class UniverSheetsFilterUIPlugin extends Plugin {
},
],
] as Dependency[]).forEach((d) => this._injector.add(d));
+
+ if (this._config.useRemoteFilterValuesGenerator && this._rpcChannelService) {
+ this._injector.add([
+ ISheetsGenerateFilterValuesService, {
+ useFactory: () => toModule<ISheetsGenerateFilterValuesService>(
+ this._rpcChannelService!.requestChannel(SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME)
+ ),
+ },
+ ]);
+ }
}
}
diff --git a/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts b/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts
index ccd588b07b..f7fc0cb462 100644
--- a/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts
+++ b/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts
@@ -21,8 +21,8 @@ import { afterEach, beforeEach, describe, expect, it, vitest } from 'vitest';
import { CustomFilterOperator, SheetsFilterService, UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
import type { IEditorBridgeServiceVisibleParam } from '@univerjs/sheets-ui';
import { ByConditionsModel, ByValuesModel, FilterBy, SheetsFilterPanelService } from '../sheets-filter-panel.service';
-import type { IOpenFilterPanelOperationParams } from '../../commands/operations/sheets-filter.operation';
-import { CloseFilterPanelOperation, OpenFilterPanelOperation } from '../../commands/operations/sheets-filter.operation';
+import type { IOpenFilterPanelCommandParams } from '../../commands/operations/sheets-filter.operation';
+import { CloseFilterPanelOperation, OpenFilterPanelCommand } from '../../commands/operations/sheets-filter.operation';
import { E_ITEMS, ITEMS, WithCustomFilterModelFactory, WithMergedCellFilterFactory, WithMultiEmptyCellsModelFactory, WithTwoFilterColumnsFactory, WithValuesAndEmptyFilterModelFactory, WithValuesFilterModelFactory } from '../../__testing__/data';
import type { IFilterConditionFormParams } from '../../models/conditions';
import { FilterConditionItems } from '../../models/conditions';
@@ -74,7 +74,7 @@ function createSheetsFilterPanelServiceTestBed(workbookData: IWorkbookData) {
const commandService = get(ICommandService);
[
- OpenFilterPanelOperation,
+ OpenFilterPanelCommand,
CloseFilterPanelOperation,
SetSheetsFilterCriteriaCommand,
SetCellEditVisibleOperation,
@@ -110,11 +110,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should initialize by conditional model when the filter column is by custom filters', () => {
prepare(WithCustomFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelOperationParams)).toBe(true);
+ } as IOpenFilterPanelCommandParams)).toBe(true);
expect(sheetsFilterPanelService.filterBy).toBe(FilterBy.CONDITIONS);
const filterByModel = sheetsFilterPanelService.filterByModel as ByConditionsModel;
@@ -128,11 +128,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should update the filter condition item when the primary operator changes', () => {
prepare(WithCustomFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelOperationParams)).toBe(true);
+ } as IOpenFilterPanelCommandParams)).toBe(true);
const filterByModel = sheetsFilterPanelService.filterByModel as ByConditionsModel;
@@ -157,11 +157,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should update primary operator when the secondary operator changes (in some conditions)', () => {
prepare(WithCustomFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelOperationParams)).toBe(true);
+ } as IOpenFilterPanelCommandParams)).toBe(true);
const filterByModel = sheetsFilterPanelService.filterByModel as ByConditionsModel;
@@ -186,11 +186,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should execute command when "apply" is called', async () => {
prepare(WithCustomFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelOperationParams)).toBe(true);
+ } as IOpenFilterPanelCommandParams)).toBe(true);
const filterByModel = sheetsFilterPanelService.filterByModel as ByConditionsModel;
filterByModel.onConditionFormChange({ val1: '5' });
@@ -205,11 +205,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should initialize by filters when the filter column holds "filters"', () => {
prepare(WithValuesFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelOperationParams)).toBeTruthy();
+ } as IOpenFilterPanelCommandParams)).toBeTruthy();
expect(sheetsFilterPanelService.filterBy).toBe(FilterBy.VALUES);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
@@ -220,11 +220,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should initialize with blank content', () => {
prepare(WithValuesAndEmptyFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelOperationParams)).toBeTruthy();
+ } as IOpenFilterPanelCommandParams)).toBeTruthy();
expect(sheetsFilterPanelService.filterBy).toBe(FilterBy.VALUES);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
@@ -241,11 +241,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should count empty cells', () => {
prepare(WithMultiEmptyCellsModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelOperationParams)).toBeTruthy();
+ } as IOpenFilterPanelCommandParams)).toBeTruthy();
expect(sheetsFilterPanelService.filterBy).toBe(FilterBy.VALUES);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
@@ -263,11 +263,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should filter out the items from the panel if its row is already filtered out by other column', () => {
prepare(WithTwoFilterColumnsFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 1,
- } as IOpenFilterPanelOperationParams)).toBeTruthy();
+ } as IOpenFilterPanelCommandParams)).toBeTruthy();
expect(sheetsFilterPanelService.filterBy).toBe(FilterBy.VALUES);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
@@ -308,11 +308,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('merged cell should use value of the top left corner', () => {
prepare(WithMergedCellFilterFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 1,
- } as IOpenFilterPanelOperationParams)).toBeTruthy();
+ } as IOpenFilterPanelCommandParams)).toBeTruthy();
expect(sheetsFilterPanelService.filterBy).toBe(FilterBy.VALUES);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
@@ -346,11 +346,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should update the filter items when toggle checked status', () => {
prepare(WithValuesFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelOperationParams)).toBe(true);
+ } as IOpenFilterPanelCommandParams)).toBe(true);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
filterByModel.onFilterCheckToggled(ITEMS[0], true);
@@ -371,11 +371,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should execute command when "apply" is called', async () => {
prepare(WithValuesFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelOperationParams)).toBe(true);
+ } as IOpenFilterPanelCommandParams)).toBe(true);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
filterByModel.onFilterCheckToggled(ITEMS[0], true);
@@ -402,11 +402,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should update the filter items when searching', () => {
prepare(WithValuesFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelOperationParams)).toBe(true);
+ } as IOpenFilterPanelCommandParams)).toBe(true);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
@@ -418,11 +418,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should toggle all applied to searched results', () => {
prepare(WithValuesFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelOperationParams)).toBe(true);
+ } as IOpenFilterPanelCommandParams)).toBe(true);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
@@ -436,11 +436,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should filter only applied to searched results', () => {
prepare(WithValuesFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelOperationParams)).toBe(true);
+ } as IOpenFilterPanelCommandParams)).toBe(true);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
diff --git a/packages/sheets-filter-ui/src/services/sheets-filter-panel.service.ts b/packages/sheets-filter-ui/src/services/sheets-filter-panel.service.ts
index 34c1351732..9e72be5b11 100644
--- a/packages/sheets-filter-ui/src/services/sheets-filter-panel.service.ts
+++ b/packages/sheets-filter-ui/src/services/sheets-filter-panel.service.ts
@@ -15,7 +15,7 @@
*/
import type { IDisposable, IRange, Nullable } from '@univerjs/core';
-import { createIdentifier, Disposable, extractPureTextFromCell, ICommandService, Inject, Injector, IUniverInstanceService, LocaleService } from '@univerjs/core';
+import { createIdentifier, Disposable, ICommandService, Inject, Injector, IUniverInstanceService, LocaleService, Quantity } from '@univerjs/core';
import { SheetsFilterService } from '@univerjs/sheets-filter';
import type { FilterColumn, FilterModel, IFilterColumn } from '@univerjs/sheets-filter';
import type { Observable } from 'rxjs';
@@ -26,6 +26,7 @@ import type { FilterOperator, IFilterConditionFormParams, IFilterConditionItem }
import { FilterConditionItems } from '../models/conditions';
import { type ISetSheetsFilterCriteriaCommandParams, SetSheetsFilterCriteriaCommand } from '../commands/commands/sheets-filter.command';
import { statisticFilterByValueItems } from '../models/utils';
+import { getFilterByValueItems, ISheetsGenerateFilterValuesService } from '../worker/generate-filter-values.service';
export enum FilterBy {
VALUES,
@@ -112,7 +113,7 @@ export class SheetsFilterPanelService extends Disposable {
this._hasCriteria$.complete();
}
- setupCol(filterModel: FilterModel, col: number): boolean {
+ async setupCol(filterModel: FilterModel, col: number): Promise<boolean> {
this.terminate();
this._filterModel = filterModel;
@@ -196,13 +197,13 @@ export class SheetsFilterPanelService extends Disposable {
});
}
- private _setupByValues(filterModel: FilterModel, col: number): boolean {
+ private async _setupByValues(filterModel: FilterModel, col: number): Promise<boolean> {
this._disposePreviousModel();
const range = filterModel.getRange();
if (range.startRow === range.endRow) return false;
- const model = ByValuesModel.fromFilterColumn(
+ const model = await ByValuesModel.fromFilterColumn(
this._injector,
filterModel,
col
@@ -391,9 +392,10 @@ export class ByValuesModel extends Disposable implements IFilterByModel {
*
* @returns the model to control the panel's state
*/
- static fromFilterColumn(injector: Injector, filterModel: FilterModel, col: number): ByValuesModel {
+ static async fromFilterColumn(injector: Injector, filterModel: FilterModel, col: number): Promise<ByValuesModel> {
const univerInstanceService = injector.get(IUniverInstanceService);
const localeService = injector.get(LocaleService);
+ const generateFilterValuesService = injector.get(ISheetsGenerateFilterValuesService, Quantity.OPTIONAL);
const { unitId, subUnitId } = filterModel;
const workbook = univerInstanceService.getUniverSheetInstance(unitId);
@@ -405,67 +407,33 @@ export class ByValuesModel extends Disposable implements IFilterByModel {
const range = filterModel.getRange();
const column = col;
const filters = filterModel.getFilterColumn(col)?.getColumnData().filters;
- const blankChecked = !!(filters && filters.blank);
-
- // the first row is filter header and should be added to options
- const iterateRange: IRange = { ...range, startRow: range.startRow + 1, startColumn: column, endColumn: column };
- const items: IFilterByValueItem[] = [];
- const itemsByKey: Record<string, IFilterByValueItem> = {};
const alreadyChecked = new Set(filters?.filters);
+ const blankChecked = !!(filters && filters.blank);
const filteredOutRowsByOtherColumns = filterModel.getFilteredOutRowsExceptCol(col);
+ const iterateRange: IRange = { ...range, startRow: range.startRow + 1, startColumn: column, endColumn: column };
- let index = 0;
- let emptyCount = 0;
- for (const cell of worksheet.iterateByColumn(iterateRange, false, false)) { // iterate and do not skip empty cells
- const { row, rowSpan = 1 } = cell;
-
- let rowIndex = 0;
- while (rowIndex < rowSpan) {
- const targetRow = row + rowIndex;
-
- if (filteredOutRowsByOtherColumns.has(targetRow)) {
- rowIndex++;
- continue;
- }
-
- const value = cell?.value ? extractPureTextFromCell(cell.value) : '';
- if (!value) {
- emptyCount += 1;
- rowIndex += rowSpan;
- continue;
- }
-
- if (!itemsByKey[value]) {
- const item: IFilterByValueItem = {
- value,
- checked: alreadyChecked.size ? alreadyChecked.has(value) : !blankChecked,
- count: 1,
- index,
- isEmpty: false,
- };
-
- itemsByKey[value] = item;
- items.push(item);
- } else {
- itemsByKey[value].count++;
- }
- rowIndex++;
- }
-
- index++;
- }
-
- const initialBlankChecked = filters ? blankChecked : true;
- if (emptyCount > 0) {
- const item: IFilterByValueItem = {
- value: localeService.t('sheets-filter.panel.empty'),
- checked: initialBlankChecked,
- count: emptyCount,
- index,
- isEmpty: true,
- };
-
- items.push(item);
+ let items: IFilterByValueItem[];
+ if (generateFilterValuesService) {
+ items = await generateFilterValuesService.getFilterValues({
+ unitId,
+ subUnitId,
+ filteredOutRowsByOtherColumns: Array.from(filteredOutRowsByOtherColumns),
+ filters: !!filters,
+ blankChecked,
+ iterateRange,
+ alreadyChecked: Array.from(alreadyChecked),
+ });
+ } else {
+ // the first row is filter header and should be added to options
+ items = getFilterByValueItems(
+ !!filters,
+ blankChecked,
+ localeService,
+ iterateRange,
+ worksheet,
+ alreadyChecked,
+ filteredOutRowsByOtherColumns
+ );
}
return injector.createInstance(ByValuesModel, filterModel, col, items);
diff --git a/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.stories.tsx b/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.stories.tsx
index c5a4efba2a..363770d351 100644
--- a/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.stories.tsx
+++ b/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.stories.tsx
@@ -24,8 +24,8 @@ import { IMenuService, IShortcutService, MenuService, ShortcutService } from '@u
import { SetCellEditVisibleOperation } from '@univerjs/sheets-ui';
import { SheetsFilterPanelService } from '../../services/sheets-filter-panel.service';
import { ClearSheetsFilterCriteriaCommand, ReCalcSheetsFilterCommand, SetSheetsFilterCriteriaCommand, SmartToggleSheetsFilterCommand } from '../../commands/commands/sheets-filter.command';
-import type { IOpenFilterPanelOperationParams } from '../../commands/operations/sheets-filter.operation';
-import { ChangeFilterByOperation, CloseFilterPanelOperation, OpenFilterPanelOperation } from '../../commands/operations/sheets-filter.operation';
+import type { IOpenFilterPanelCommandParams } from '../../commands/operations/sheets-filter.operation';
+import { ChangeFilterByOperation, CloseFilterPanelOperation, OpenFilterPanelCommand } from '../../commands/operations/sheets-filter.operation';
import enUS from '../../locale/en-US';
import zhCN from '../../locale/zh-CN';
import ruRU from '../../locale/ru-RU';
@@ -76,16 +76,16 @@ function createFilterStorybookBed(workbookData: IWorkbookData, locale: LocaleTyp
SetSheetsFilterCriteriaCommand,
ClearSheetsFilterCriteriaCommand,
ReCalcSheetsFilterCommand,
- OpenFilterPanelOperation,
+ OpenFilterPanelCommand,
CloseFilterPanelOperation,
ChangeFilterByOperation,
].forEach((command) => commandService.registerCommand(command));
- commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
+ commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelOperationParams);
+ } as IOpenFilterPanelCommandParams);
}
}
diff --git a/packages/sheets-filter-ui/src/views/widgets/filter-button.shape.ts b/packages/sheets-filter-ui/src/views/widgets/filter-button.shape.ts
index 7c2fb5a4bd..9e0afd3ea3 100644
--- a/packages/sheets-filter-ui/src/views/widgets/filter-button.shape.ts
+++ b/packages/sheets-filter-ui/src/views/widgets/filter-button.shape.ts
@@ -17,7 +17,7 @@
import { ICommandService, IContextService, Inject, ThemeService } from '@univerjs/core';
import { type IMouseEvent, type IPointerEvent, type IShapeProps, Shape, type UniverRenderingContext2D } from '@univerjs/engine-render';
-import { FILTER_PANEL_OPENED_KEY, type IOpenFilterPanelOperationParams, OpenFilterPanelOperation } from '../../commands/operations/sheets-filter.operation';
+import { FILTER_PANEL_OPENED_KEY, type IOpenFilterPanelCommandParams, OpenFilterPanelCommand } from '../../commands/operations/sheets-filter.operation';
import { FilterButton } from './drawings';
export const FILTER_ICON_SIZE = 16;
@@ -112,16 +112,16 @@ export class SheetsFilterButtonShape extends Shape<ISheetsFilterButtonShapeProps
const { col, unitId, subUnitId } = this._filterParams!;
const opened = this._contextService.getContextValue(FILTER_PANEL_OPENED_KEY);
- if (opened || !this._commandService.hasCommand(OpenFilterPanelOperation.id)) {
+ if (opened || !this._commandService.hasCommand(OpenFilterPanelCommand.id)) {
return;
}
setTimeout(() => {
- this._commandService.executeCommand(OpenFilterPanelOperation.id, {
+ this._commandService.executeCommand(OpenFilterPanelCommand.id, {
unitId,
subUnitId,
col,
- } as IOpenFilterPanelOperationParams);
+ } as IOpenFilterPanelCommandParams);
}, 200);
}
diff --git a/packages/sheets-filter-ui/src/worker/generate-filter-values.service.ts b/packages/sheets-filter-ui/src/worker/generate-filter-values.service.ts
new file mode 100644
index 0000000000..2f8cd02f0f
--- /dev/null
+++ b/packages/sheets-filter-ui/src/worker/generate-filter-values.service.ts
@@ -0,0 +1,139 @@
+/**
+ * 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 { IRange, Workbook, Worksheet } from '@univerjs/core';
+import { createIdentifier, Disposable, extractPureTextFromCell, ILogService, Inject, IUniverInstanceService, LocaleService } from '@univerjs/core';
+import type { IFilterByValueItem } from '../services/sheets-filter-panel.service';
+
+export interface ISheetsGenerateFilterValuesService {
+ getFilterValues(params: {
+ unitId: string;
+ subUnitId: string;
+ filteredOutRowsByOtherColumns: number[];
+ filters: boolean;
+ blankChecked: boolean;
+ iterateRange: IRange;
+ alreadyChecked: string[];
+ }): Promise<IFilterByValueItem[]>;
+}
+export const SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME = 'sheets-filter.generate-filter-values.service';
+export const ISheetsGenerateFilterValuesService = createIdentifier<ISheetsGenerateFilterValuesService>(SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME);
+
+export class SheetsGenerateFilterValuesService extends Disposable {
+ constructor(
+ @Inject(LocaleService) private readonly _localeService: LocaleService,
+ @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,
+ @ILogService private readonly _logService: ILogService
+ ) {
+ super();
+ }
+
+ async getFilterValues(params: {
+ unitId: string;
+ subUnitId: string;
+ filteredOutRowsByOtherColumns: number[];
+ filters: boolean;
+ blankChecked: boolean;
+ iterateRange: IRange;
+ alreadyChecked: string[];
+ }) {
+ const { unitId, subUnitId, filteredOutRowsByOtherColumns, filters, blankChecked, iterateRange, alreadyChecked } = params;
+ const worksheet = this._univerInstanceService.getUnit<Workbook>(unitId)?.getSheetBySheetId(subUnitId);
+
+ if (!worksheet) return [];
+
+ this._logService.debug('[SheetsGenerateFilterValuesService]', 'getFilterValues for', { unitId, subUnitId });
+
+ return getFilterByValueItems(
+ filters,
+ blankChecked,
+ this._localeService,
+ iterateRange,
+ worksheet,
+ new Set(alreadyChecked.map(String)),
+ new Set(filteredOutRowsByOtherColumns)
+ );
+ }
+}
+
+export function getFilterByValueItems(
+ filters: boolean,
+ blankChecked: boolean,
+ localeService: LocaleService,
+ iterateRange: IRange,
+ worksheet: Worksheet,
+ alreadyChecked: Set<string>,
+ filteredOutRowsByOtherColumns: Set<number>
+): IFilterByValueItem[] {
+ const items: IFilterByValueItem[] = [];
+ const itemsByKey: Record<string, IFilterByValueItem> = {};
+
+ let index = 0;
+ let emptyCount = 0;
+ for (const cell of worksheet.iterateByColumn(iterateRange, false, false)) { // iterate and do not skip empty cells
+ const { row, rowSpan = 1 } = cell;
+
+ let rowIndex = 0;
+ while (rowIndex < rowSpan) {
+ const targetRow = row + rowIndex;
+
+ if (filteredOutRowsByOtherColumns.has(targetRow)) {
+ rowIndex++;
+ continue;
+ }
+
+ const value = cell?.value ? extractPureTextFromCell(cell.value) : '';
+ if (!value) {
+ emptyCount += 1;
+ rowIndex += rowSpan;
+ continue;
+ }
+
+ if (!itemsByKey[value]) {
+ const item: IFilterByValueItem = {
+ value,
+ checked: alreadyChecked.size ? alreadyChecked.has(value) : !blankChecked,
+ count: 1,
+ index,
+ isEmpty: false,
+ };
+
+ itemsByKey[value] = item;
+ items.push(item);
+ } else {
+ itemsByKey[value].count++;
+ }
+ rowIndex++;
+ }
+
+ index++;
+ }
+
+ const initialBlankChecked = filters ? blankChecked : true;
+ if (emptyCount > 0) {
+ const item: IFilterByValueItem = {
+ value: localeService.t('sheets-filter.panel.empty'),
+ checked: initialBlankChecked,
+ count: emptyCount,
+ index,
+ isEmpty: true,
+ };
+
+ items.push(item);
+ }
+
+ return items;
+}
diff --git a/packages/sheets-filter-ui/src/worker/plugin.ts b/packages/sheets-filter-ui/src/worker/plugin.ts
new file mode 100644
index 0000000000..f72502adb1
--- /dev/null
+++ b/packages/sheets-filter-ui/src/worker/plugin.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 type { Dependency } from '@univerjs/core';
+import { Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
+import { fromModule, IRPCChannelService } from '@univerjs/rpc';
+import { ISheetsGenerateFilterValuesService, SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME, SheetsGenerateFilterValuesService } from './generate-filter-values.service';
+
+export class UniverSheetsFilterUIWorkerPlugin extends Plugin {
+ static override type = UniverInstanceType.UNIVER_SHEET;
+ static override pluginName: string = 'SHEET_FILTER_UI_WORKER_PLUGIN';
+
+ constructor(
+ private readonly _config: unknown,
+ @Inject(Injector) protected readonly _injector: Injector,
+ @IRPCChannelService private readonly _rpcChannelService: IRPCChannelService
+ ) {
+ super();
+ }
+
+ override onStarting(_injector?: Injector): void {
+ ([
+ [ISheetsGenerateFilterValuesService, { useClass: SheetsGenerateFilterValuesService }],
+ ] as Dependency[]).forEach((d) => this._injector.add(d));
+ }
+
+ override onReady(): void {
+ this._rpcChannelService.registerChannel(
+ SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME,
+ fromModule(this._injector.get(ISheetsGenerateFilterValuesService))
+ );
+ }
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 66cca6e951..290c088300 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -10,7 +10,7 @@ importers:
devDependencies:
'@antfu/eslint-config':
specifier: 2.21.3
'@commitlint/cli':
specifier: ^19.3.0
version: 19.3.0(@types/[email protected])([email protected])
@@ -133,7 +133,7 @@ importers:
'@storybook/addon-interactions':
specifier: 8.2.7
'@storybook/addon-links':
specifier: 8.2.7
@@ -1793,6 +1793,9 @@ importers:
'@univerjs/engine-render':
specifier: workspace:*
version: link:../engine-render
+ '@univerjs/rpc':
+ specifier: workspace:*
+ version: link:../rpc
'@univerjs/shared':
specifier: workspace:*
version: link:../../common/shared
@@ -10834,7 +10837,7 @@ snapshots:
dependencies:
'@babel/runtime': 7.24.7
dependencies:
'@antfu/install-pkg': 0.3.3
'@clack/prompts': 0.7.0
@@ -10859,7 +10862,7 @@ snapshots:
eslint-plugin-toml: 0.11.1([email protected])
eslint-plugin-unicorn: 54.0.0([email protected])
eslint-plugin-unused-imports: 3.2.0(@typescript-eslint/[email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected]))([email protected])
eslint-plugin-vue: 9.27.0([email protected])
eslint-plugin-yml: 1.14.0([email protected])
eslint-processor-vue-blocks: 0.1.2(@vue/[email protected])([email protected])
@@ -12800,11 +12803,11 @@ snapshots:
'@storybook/global': 5.0.0
storybook: 8.2.7(@babel/[email protected](@babel/[email protected]))
dependencies:
'@storybook/global': 5.0.0
'@storybook/instrumenter': 8.2.7([email protected](@babel/[email protected](@babel/[email protected])))
polished: 4.3.1
storybook: 8.2.7(@babel/[email protected](@babel/[email protected]))
ts-dedent: 2.2.0
@@ -13238,12 +13241,12 @@ snapshots:
optionalDependencies:
typescript: 5.5.4
dependencies:
'@storybook/csf': 0.1.11
'@storybook/instrumenter': 8.2.7([email protected](@babel/[email protected](@babel/[email protected])))
'@testing-library/dom': 10.1.0
'@testing-library/user-event': 14.5.2(@testing-library/[email protected])
'@vitest/expect': 1.6.0
'@vitest/spy': 1.6.0
@@ -13384,7 +13387,7 @@ snapshots:
lz-string: 1.5.0
pretty-format: 27.5.1
dependencies:
'@adobe/css-tools': 4.4.0
'@babel/runtime': 7.24.7
@@ -15833,7 +15836,7 @@ snapshots:
optionalDependencies:
'@typescript-eslint/eslint-plugin': 7.15.0(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])
dependencies:
'@typescript-eslint/utils': 7.15.0([email protected])([email protected])
eslint: 8.57.0