@univerjs/core 0.1.0-beta.0 → 0.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/lib/cjs/index.js +5 -5
  2. package/lib/es/index.js +1394 -1240
  3. package/lib/types/docs/data-model/document-data-model.d.ts +2 -0
  4. package/lib/types/index.d.ts +3 -1
  5. package/lib/types/services/command/command.service.d.ts +12 -4
  6. package/lib/types/services/config/config.service.d.ts +2 -2
  7. package/lib/types/services/context/context.service.d.ts +1 -1
  8. package/lib/types/services/floating-object/floating-object-manager.service.d.ts +1 -1
  9. package/lib/types/services/{auth/auth.service.d.ts → lifecycle/__tests__/lifecycle.service.spec.d.ts} +1 -2
  10. package/lib/types/services/lifecycle/lifecycle.service.d.ts +19 -1
  11. package/lib/types/services/log/log.service.d.ts +5 -1
  12. package/lib/types/shared/lifecycle.d.ts +1 -1
  13. package/lib/types/shared/object-matrix.d.ts +2 -2
  14. package/lib/types/{types/const/doc-action-names.d.ts → sheets/__tests__/r1c1-reference.spec.d.ts} +1 -6
  15. package/lib/types/sheets/__tests__/reference.spec.d.ts +16 -0
  16. package/lib/types/sheets/__tests__/workbook.spec.d.ts +16 -0
  17. package/lib/types/sheets/r1c1-reference.d.ts +17 -0
  18. package/lib/types/sheets/reference.d.ts +11 -7
  19. package/lib/types/sheets/workbook.d.ts +18 -0
  20. package/lib/types/types/const/index.d.ts +0 -1
  21. package/lib/types/types/interfaces/__tests__/i-cell-data.spec.d.ts +16 -0
  22. package/lib/types/types/interfaces/i-cell-data.d.ts +1 -0
  23. package/lib/types/types/interfaces/i-style-data.d.ts +1 -0
  24. package/lib/types/types/interfaces/i-workbook-data.d.ts +12 -3
  25. package/lib/umd/index.js +5 -5
  26. package/package.json +8 -8
  27. package/lib/types/types/const/action-names.d.ts +0 -65
  28. /package/lib/types/services/command/{command.service.spec.d.ts → __tests__/command.service.spec.d.ts} +0 -0
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import type { Nullable } from '../../shared';
16
17
  import type { IDocumentBody, IDocumentData, IDocumentRenderConfig } from '../../types/interfaces/i-document-data';
17
18
  import { type IPaddingData } from '../../types/interfaces/i-style-data';
18
19
  import { type DocMutationParams } from './mutation-types';
@@ -62,6 +63,7 @@ export declare class DocumentDataModel extends DocumentDataModelSimple {
62
63
  getSelfOrHeaderFooterModel(segmentId?: string): DocumentDataModel;
63
64
  getUnitId(): string;
64
65
  apply(mutations: DocMutationParams[]): DocMutationParams[];
66
+ sliceBody(startOffset: number, endOffset: number): Nullable<IDocumentBody>;
65
67
  private _updateApply;
66
68
  private _deleteApply;
67
69
  private _insertApply;
@@ -43,11 +43,13 @@ export { IResourceManagerService, ISnapshotPersistenceService } from './services
43
43
  export { type IStyleSheet, ThemeService } from './services/theme/theme.service';
44
44
  export { type IUndoRedoCommandInfos, type IUndoRedoItem, IUndoRedoService, type IUndoRedoStatus, LocalUndoRedoService, RedoCommand, UndoCommand, } from './services/undoredo/undoredo.service';
45
45
  export * from './shared';
46
+ export { deserializeRangeForR1C1 } from './sheets/r1c1-reference';
46
47
  export type { IComposeInterceptors, IInterceptor, InterceptorHandler } from './common/interceptor';
47
48
  export { composeInterceptors, createInterceptorKey, InterceptorManager } from './common/interceptor';
49
+ export { normalizeTextRuns } from './docs/data-model/apply-utils/common';
48
50
  export type { PluginCtor } from './plugin/plugin';
49
51
  export { Range } from './sheets/range';
50
- export { deserializeRangeWithSheet, getAbsoluteRefTypeWithSingleString, getAbsoluteRefTypeWitString, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet, } from './sheets/reference';
52
+ export { deserializeRangeWithSheet, getAbsoluteRefTypeWithSingleString, getAbsoluteRefTypeWitString, type IAbsoluteRefTypeForRange, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet, UNIT_NAME_REGEX, } from './sheets/reference';
51
53
  export { Styles } from './sheets/styles';
52
54
  export { SheetViewModel } from './sheets/view-model';
53
55
  export { getWorksheetUID, Workbook } from './sheets/workbook';
@@ -104,7 +104,7 @@ export interface IExecutionOptions {
104
104
  export type CommandListener = (commandInfo: Readonly<ICommandInfo>, options?: IExecutionOptions) => void;
105
105
  export interface ICommandService {
106
106
  registerCommand(command: ICommand): IDisposable;
107
- registerAsMultipleCommand(command: ICommand): IDisposable;
107
+ registerMultipleCommand(command: ICommand): IDisposable;
108
108
  executeCommand<P extends object = object, R = boolean>(id: string, params?: P, options?: IExecutionOptions): Promise<R>;
109
109
  syncExecuteCommand<P extends object = object, R = boolean>(id: string, params?: P, options?: IExecutionOptions): R;
110
110
  /**
@@ -118,18 +118,26 @@ export interface ICommandService {
118
118
  beforeCommandExecuted(listener: CommandListener): IDisposable;
119
119
  }
120
120
  export declare const ICommandService: import("@wendellhu/redi").IdentifierDecorator<ICommandService>;
121
+ /**
122
+ * The registry of commands.
123
+ */
124
+ export declare class CommandRegistry {
125
+ private readonly _commands;
126
+ registerCommand(command: ICommand): IDisposable;
127
+ getCommand(id: string): [ICommand] | null;
128
+ }
121
129
  export declare class CommandService implements ICommandService {
122
130
  private readonly _injector;
123
- private readonly _log;
131
+ private readonly _logService;
124
132
  private readonly _commandRegistry;
125
133
  private readonly _beforeCommandExecutionListeners;
126
134
  private readonly _commandExecutedListeners;
127
135
  private _multiCommandDisposables;
128
136
  private _commandExecutingLevel;
129
137
  private _commandExecutionStack;
130
- constructor(_injector: Injector, _log: ILogService);
138
+ constructor(_injector: Injector, _logService: ILogService);
131
139
  registerCommand(command: ICommand): IDisposable;
132
- registerAsMultipleCommand(command: ICommand): IDisposable;
140
+ registerMultipleCommand(command: ICommand): IDisposable;
133
141
  beforeCommandExecuted(listener: CommandListener): IDisposable;
134
142
  onCommandExecuted(listener: (commandInfo: ICommandInfo) => void): IDisposable;
135
143
  executeCommand<P extends object = object, R = boolean>(id: string, params?: P, options?: IExecutionOptions): Promise<R>;
@@ -21,12 +21,12 @@ export declare const IConfigService: import("@wendellhu/redi").IdentifierDecorat
21
21
  export interface IConfigService {
22
22
  getConfig<T>(id: string, defaultValue: T): T;
23
23
  getConfig<T>(id: string): Nullable<T>;
24
- setConfig(id: string, value: any): void;
24
+ setConfig(id: string, value: unknown): void;
25
25
  deleteConfig(id: string): void;
26
26
  }
27
27
  export declare class ConfigService implements IConfigService {
28
28
  private readonly _config;
29
29
  getConfig<T>(id: string): Nullable<T>;
30
- setConfig(id: string, value: any): void;
30
+ setConfig(id: string, value: unknown): void;
31
31
  deleteConfig(id: string): void;
32
32
  }
@@ -16,7 +16,7 @@
16
16
  import type { Observable } from 'rxjs';
17
17
  import { Disposable } from '../../shared/lifecycle';
18
18
  export interface IContextService {
19
- contextChanged$: Observable<void>;
19
+ readonly contextChanged$: Observable<void>;
20
20
  getContextValue(key: string): boolean;
21
21
  setContextValue(key: string, value: boolean): void;
22
22
  }
@@ -20,7 +20,7 @@ import type { ITransformState } from './floating-object-interfaces';
20
20
  export declare const DEFAULT_DOCUMENT_SUB_COMPONENT_ID = "__default_document_sub_component_id20231101__";
21
21
  export interface IFloatingObjectManagerSearchParam {
22
22
  unitId: string;
23
- subComponentId: string;
23
+ subUnitId: string;
24
24
  }
25
25
  export interface IFloatingObjectManagerSearchItemParam extends IFloatingObjectManagerSearchParam {
26
26
  floatingObjectId: string;
@@ -13,5 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export interface IAuthService {
17
- }
16
+ export {};
@@ -18,15 +18,33 @@ import { Observable } from 'rxjs';
18
18
  import { Disposable } from '../../shared/lifecycle';
19
19
  import { ILogService } from '../log/log.service';
20
20
  import { LifecycleStages } from './lifecycle';
21
+ /**
22
+ * This service controls the lifecycle of a Univer instance. Other modules can
23
+ * inject this service to read the current lifecycle stage or subscribe to
24
+ * lifecycle changes.
25
+ */
21
26
  export declare class LifecycleService extends Disposable {
22
27
  private readonly _logService;
23
28
  private _lifecycle$;
24
- lifecycle$: Observable<LifecycleStages>;
29
+ readonly lifecycle$: Observable<LifecycleStages>;
25
30
  constructor(_logService: ILogService);
26
31
  get stage(): LifecycleStages;
27
32
  set stage(stage: LifecycleStages);
33
+ dispose(): void;
34
+ /**
35
+ * Subscribe to lifecycle changes and all previous stages and the current
36
+ * stage will be emitted immediately.
37
+ * @returns
38
+ */
28
39
  subscribeWithPrevious(): Observable<LifecycleStages>;
40
+ private _reportProgress;
29
41
  }
42
+ /**
43
+ * This service is used to initialize modules on a certain lifecycle stage.
44
+ * Refer to `runOnLifecycle` and `OnLifecycle` for more details.
45
+ *
46
+ * @internal
47
+ */
30
48
  export declare class LifecycleInitializerService extends Disposable {
31
49
  private _lifecycleService;
32
50
  private readonly _injector;
@@ -18,10 +18,12 @@ export declare enum LogLevel {
18
18
  SILENT = 0,
19
19
  ERROR = 1,
20
20
  WARN = 2,
21
- VERBOSE = 3
21
+ INFO = 3,
22
+ VERBOSE = 4
22
23
  }
23
24
  type ArgsType = any[];
24
25
  export interface ILogService {
26
+ debug(...args: ArgsType): void;
25
27
  log(...args: ArgsType): void;
26
28
  warn(...args: ArgsType): void;
27
29
  error(...args: ArgsType): void;
@@ -30,9 +32,11 @@ export interface ILogService {
30
32
  export declare const ILogService: import("@wendellhu/redi").IdentifierDecorator<ILogService>;
31
33
  export declare class DesktopLogService extends Disposable implements ILogService {
32
34
  private _logLevel;
35
+ debug(...args: ArgsType): void;
33
36
  log(...args: ArgsType): void;
34
37
  warn(...args: ArgsType): void;
35
38
  error(...args: ArgsType): void;
36
39
  setLogLevel(logLevel: LogLevel): void;
40
+ private _log;
37
41
  }
38
42
  export {};
@@ -33,7 +33,7 @@ export declare class DisposableCollection implements IDisposable {
33
33
  export declare class Disposable implements IDisposable {
34
34
  protected _disposed: boolean;
35
35
  private readonly _collection;
36
- protected disposeWithMe(disposable: IDisposable): IDisposable;
36
+ protected disposeWithMe(disposable: IDisposable | SubscriptionLike): IDisposable;
37
37
  dispose(): void;
38
38
  }
39
39
  export declare class RxDisposable extends Disposable implements IDisposable {
@@ -27,8 +27,8 @@ export interface IObjectArrayPrimitiveType<T> {
27
27
  export declare function getArrayLength<T>(o: IObjectArrayPrimitiveType<T> | IObjectMatrixPrimitiveType<T>): number;
28
28
  export declare function insertMatrixArray<T>(index: number, value: T, o: IObjectArrayPrimitiveType<T> | IObjectMatrixPrimitiveType<T>): void;
29
29
  export declare function spliceArray<T>(start: number, count: number, o: IObjectArrayPrimitiveType<T>): void;
30
- export declare function concatMatrixArray<T>(source: IObjectArrayPrimitiveType<T> | IObjectMatrixPrimitiveType<T>, target: IObjectArrayPrimitiveType<T> | IObjectMatrixPrimitiveType<T>): IObjectArrayPrimitiveType<T> | IObjectMatrixPrimitiveType<T>;
31
- export declare function sliceMatrixArray<T>(start: number, end: number, matrixArray: IObjectArrayPrimitiveType<T> | IObjectMatrixPrimitiveType<T>): IObjectArrayPrimitiveType<T> | IObjectMatrixPrimitiveType<T>;
30
+ export declare function concatMatrixArray<T>(source: IObjectArrayPrimitiveType<T>, target: IObjectArrayPrimitiveType<T>): IObjectArrayPrimitiveType<T>;
31
+ export declare function sliceMatrixArray<T>(start: number, end: number, matrixArray: IObjectArrayPrimitiveType<T>): IObjectArrayPrimitiveType<T>;
32
32
  export declare function moveMatrixArray<T>(fromIndex: number, count: number, toIndex: number, o: IObjectArrayPrimitiveType<T> | IObjectMatrixPrimitiveType<T>): void;
33
33
  /**
34
34
  * A two-dimensional array represented by a two-level deep object and provides an array-like API
@@ -13,9 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare enum DOC_ACTION_NAMES {
17
- INSERT_ACTION_NAME = "InsertAction",
18
- DELETE_ACTION_NAME = "DeleteAction",
19
- RETAIN_ACTION_NAME = "RetainAction",
20
- UPDATE_DOCUMENT_ACTION_NAME = "UpdateDocumentAction"
21
- }
16
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { IGridRangeName } from './reference';
17
+ export declare function deserializeRangeForR1C1(refString: string, currentRow?: number, currentColumn?: number): IGridRangeName;
@@ -15,11 +15,16 @@
15
15
  */
16
16
  import type { IRange } from '../types/interfaces/i-range';
17
17
  import { AbsoluteRefType } from '../types/interfaces/i-range';
18
+ export declare const UNIT_NAME_REGEX = "'?\\[((?![\\/?:\"<>|*\\\\]).)*?\\]";
18
19
  export interface IGridRangeName {
19
20
  unitId: string;
20
21
  sheetName: string;
21
22
  range: IRange;
22
23
  }
24
+ export interface IAbsoluteRefTypeForRange {
25
+ startAbsoluteRefType: AbsoluteRefType;
26
+ endAbsoluteRefType?: AbsoluteRefType;
27
+ }
23
28
  /**
24
29
  *
25
30
  * @param singleRefString for example A1 or B10, not A1:B10
@@ -29,13 +34,7 @@ export declare function getAbsoluteRefTypeWithSingleString(singleRefString: stri
29
34
  *
30
35
  * @param refString for example A1:B10
31
36
  */
32
- export declare function getAbsoluteRefTypeWitString(refString: string): {
33
- startAbsoluteRefType: AbsoluteRefType;
34
- endAbsoluteRefType: AbsoluteRefType;
35
- } | {
36
- startAbsoluteRefType: AbsoluteRefType;
37
- endAbsoluteRefType?: undefined;
38
- };
37
+ export declare function getAbsoluteRefTypeWitString(refString: string): IAbsoluteRefTypeForRange;
39
38
  /**
40
39
  * Serialize an `IRange` into a string.
41
40
  * @param range The `IRange` to be serialized
@@ -57,4 +56,9 @@ export declare function serializeRangeWithSheet(sheetName: string, range: IRange
57
56
  */
58
57
  export declare function serializeRangeWithSpreadsheet(unit: string, sheetName: string, range: IRange): string;
59
58
  export declare function serializeRangeToRefString(gridRangeName: IGridRangeName): string;
59
+ export declare function handleRefStringInfo(refString: string): {
60
+ refBody: string;
61
+ sheetName: string;
62
+ unitId: string;
63
+ };
60
64
  export declare function deserializeRangeWithSheet(refString: string): IGridRangeName;
@@ -48,11 +48,13 @@ export declare class Workbook extends Disposable {
48
48
  private _snapshot;
49
49
  private _unitId;
50
50
  private _count;
51
+ get name(): string;
51
52
  constructor(workbookData: Partial<IWorkbookData> | undefined, _log: ILogService);
52
53
  dispose(): void;
53
54
  save(): IWorkbookData;
54
55
  static isIRangeType(range: IRangeType | IRangeType[]): Boolean;
55
56
  getSnapshot(): IWorkbookData;
57
+ getName(): string;
56
58
  getUnitId(): string;
57
59
  getRev(): number;
58
60
  incrementRev(): void;
@@ -126,8 +128,24 @@ export declare class Workbook extends Disposable {
126
128
  */
127
129
  transformRangeType(range: IRangeType | IRangeType[]): IGridRange;
128
130
  load(config: IWorkbookData): void;
131
+ /**
132
+ * Check if sheet name is unique
133
+ * @param name sheet name
134
+ * @returns True if sheet name is unique
135
+ */
129
136
  checkSheetName(name: string): boolean;
137
+ /**
138
+ * Check whether the sheet name is unique and generate a new unique sheet name
139
+ * @param name sheet name
140
+ * @returns Unique sheet name
141
+ */
130
142
  uniqueSheetName(name?: string): string;
143
+ /**
144
+ * Automatically generate new sheet name
145
+ * @param name sheet name
146
+ * @returns New sheet name
147
+ */
148
+ generateNewSheetName(name: string): string;
131
149
  /**
132
150
  * Get the range array based on the range string and sheet id
133
151
  *
@@ -13,7 +13,6 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export * from './action-names';
17
16
  export * from './const';
18
17
  export * from './extension-names';
19
18
  export * from './theme-color-map';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export {};
@@ -47,3 +47,4 @@ export interface ICellDataForSheetInterceptor extends ICellData {
47
47
  export declare function isICellData(value: any): value is ICellData;
48
48
  export declare function getCellValueType(cell: ICellData): CellValueType | null | undefined;
49
49
  export declare function isNullCell(cell: Nullable<ICellData>): boolean;
50
+ export declare function isCellV(cell: Nullable<ICellData | ICellV>): boolean;
@@ -22,6 +22,7 @@ import type { ThemeColorType } from '../enum/theme-color-type';
22
22
  */
23
23
  export interface ITextDecoration {
24
24
  s: BooleanNumber;
25
+ c?: BooleanNumber;
25
26
  cl?: IColorStyle;
26
27
  t?: TextDecoration;
27
28
  }
@@ -22,12 +22,21 @@ import type { IWorksheetData } from './i-worksheet-data';
22
22
  * Properties of a workbook's configuration
23
23
  */
24
24
  export interface IWorkbookData extends IExtraModelData {
25
- /** unit id */
25
+ /**
26
+ * unit id
27
+ */
26
28
  id: string;
27
- /** Revision of this document. Would be used in collaborated editing. Starts from one. */
29
+ /**
30
+ * Revision of this spreadsheet. Would be used in collaborated editing. Starts from one.
31
+ */
28
32
  rev?: number;
33
+ /**
34
+ * Name of the spreadsheet.
35
+ */
29
36
  name: string;
30
- /** Version of Univer model definition. */
37
+ /**
38
+ * Version of Univer model definition.
39
+ */
31
40
  appVersion: string;
32
41
  locale: LocaleType;
33
42
  /** Style reference. */