logisheets-engine 1.0.0
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.
- package/README.md +85 -0
- package/dist/assets/logisheets_wasm_server_bg.wasm +0 -0
- package/dist/assets/worker-DtAa7uxj.js +4205 -0
- package/dist/logisheets-engine.css +1 -0
- package/dist/logisheets-engine.es.js +14095 -0
- package/dist/logisheets-engine.umd.js +1 -0
- package/dist/types/lib/adapters/index.d.ts +5 -0
- package/dist/types/lib/adapters/react.d.ts +88 -0
- package/dist/types/lib/block/enum_set_manager.d.ts +118 -0
- package/dist/types/lib/block/field_manager.d.ts +236 -0
- package/dist/types/lib/block/index.d.ts +7 -0
- package/dist/types/lib/block/manager.d.ts +25 -0
- package/dist/types/lib/block/value_formula.d.ts +47 -0
- package/dist/types/lib/clients/index.d.ts +3 -0
- package/dist/types/lib/clients/offscreen.d.ts +23 -0
- package/dist/types/lib/clients/service.d.ts +48 -0
- package/dist/types/lib/clients/workbook.d.ts +184 -0
- package/dist/types/lib/components/contextMenuTypes.d.ts +39 -0
- package/dist/types/lib/components/index.d.ts +8 -0
- package/dist/types/lib/components/utils.d.ts +33 -0
- package/dist/types/lib/engine.d.ts +242 -0
- package/dist/types/lib/global.d.ts +36 -0
- package/dist/types/lib/index.d.ts +15 -0
- package/dist/types/lib/license/index.d.ts +26 -0
- package/dist/types/lib/worker/border_helper.d.ts +24 -0
- package/dist/types/lib/worker/index.d.ts +3 -0
- package/dist/types/lib/worker/license.d.ts +27 -0
- package/dist/types/lib/worker/offscreen.worker.d.ts +35 -0
- package/dist/types/lib/worker/painter.d.ts +23 -0
- package/dist/types/lib/worker/pool.d.ts +26 -0
- package/dist/types/lib/worker/render.d.ts +24 -0
- package/dist/types/lib/worker/standable.d.ts +119 -0
- package/dist/types/lib/worker/types.d.ts +122 -0
- package/dist/types/lib/worker/view_manager.d.ts +59 -0
- package/dist/types/lib/worker/workbook.worker.d.ts +163 -0
- package/dist/types/lib/worker/worker.d.ts +5 -0
- package/dist/types/types/index.d.ts +115 -0
- package/package.json +40 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Painter - handles canvas rendering operations.
|
|
3
|
+
*/
|
|
4
|
+
import type { CellView } from "./view_manager";
|
|
5
|
+
import type { AppropriateHeight } from "./types";
|
|
6
|
+
import { RenderCell } from "./render";
|
|
7
|
+
export declare class Painter {
|
|
8
|
+
private _canvas?;
|
|
9
|
+
private _ctx?;
|
|
10
|
+
private _showWatermark;
|
|
11
|
+
setCanvas(canvas: OffscreenCanvas): void;
|
|
12
|
+
setShowWatermark(show: boolean): void;
|
|
13
|
+
render(resp: CellView, anchorX: number, anchorY: number): void;
|
|
14
|
+
getAppropriateHeights(resp: CellView, anchorX: number, anchorY: number): AppropriateHeight[];
|
|
15
|
+
renderContent(resp: CellView, anchorX: number, anchorY: number): void;
|
|
16
|
+
renderCell(renderCell: RenderCell, anchorX: number, anchorY: number, render?: boolean): number;
|
|
17
|
+
renderMergeCells(resp: CellView, anchorX: number, anchorY: number): void;
|
|
18
|
+
renderGrid(data: CellView, anchorX: number, anchorY: number): void;
|
|
19
|
+
private _borderLine;
|
|
20
|
+
private _fill;
|
|
21
|
+
private _text;
|
|
22
|
+
private renderWatermark;
|
|
23
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object Pool for managing reusable objects.
|
|
3
|
+
* This improves performance by avoiding frequent object creation/destruction.
|
|
4
|
+
*/
|
|
5
|
+
import type { CellView } from "./view_manager";
|
|
6
|
+
import { RenderCell } from "./render";
|
|
7
|
+
import { Range, StandardCell, StandardStyle, StandardValue } from "./standable";
|
|
8
|
+
export declare class Pool {
|
|
9
|
+
getRenderCell(): RenderCell;
|
|
10
|
+
releaseRenderCell(c: RenderCell): void;
|
|
11
|
+
getRange(): Range;
|
|
12
|
+
releaseRange(r: Range): void;
|
|
13
|
+
getStandardValue(): StandardValue;
|
|
14
|
+
releaseStandardValue(v: StandardValue): void;
|
|
15
|
+
getStandardStyle(): StandardStyle;
|
|
16
|
+
releaseStandardStyle(s: StandardStyle): void;
|
|
17
|
+
getStandardCell(): StandardCell;
|
|
18
|
+
releaseStandardCell(c: StandardCell): void;
|
|
19
|
+
releaseCellView(v: CellView): void;
|
|
20
|
+
private _renderCells;
|
|
21
|
+
private _ranges;
|
|
22
|
+
private _standardCells;
|
|
23
|
+
private _standardValues;
|
|
24
|
+
private _standardStyles;
|
|
25
|
+
private _cellViews;
|
|
26
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RenderCell - represents a cell with position and coordinate information for rendering.
|
|
3
|
+
*/
|
|
4
|
+
import type { CellInfo } from "logisheets-web";
|
|
5
|
+
import { Range, StandardCell, StandardStyle, StandardValue } from "./standable";
|
|
6
|
+
export declare class RenderCell {
|
|
7
|
+
get width(): number;
|
|
8
|
+
get height(): number;
|
|
9
|
+
setCoordinate(coordinate: Range): this;
|
|
10
|
+
setPosition(position: Range): this;
|
|
11
|
+
setInfo(info: CellInfo, getStandardCell: () => StandardCell, getStandardValue: () => StandardValue, getStandardStyle: () => StandardStyle): this;
|
|
12
|
+
setStandardCell(info?: StandardCell): this;
|
|
13
|
+
setSkipRender(skip: boolean): this;
|
|
14
|
+
reset(): void;
|
|
15
|
+
hidden: boolean;
|
|
16
|
+
/** start/end row/col index */
|
|
17
|
+
coordinate: Range;
|
|
18
|
+
/** start/end row/col pixel distance (position in the whole sheet) */
|
|
19
|
+
position: Range;
|
|
20
|
+
info?: StandardCell;
|
|
21
|
+
skipRender: boolean;
|
|
22
|
+
cover(cell: RenderCell): boolean;
|
|
23
|
+
equals(cell: RenderCell): boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard data classes for the worker.
|
|
3
|
+
* These are simplified versions of the classes from the original codebase.
|
|
4
|
+
*/
|
|
5
|
+
import type { Value, Style, Font, RowInfo, ColInfo, Color, CtFontName, CtUnderlineProperty, Border, Fill, CtCellProtection, Alignment, MergeCell } from "logisheets-web";
|
|
6
|
+
export declare function ptToPx(pt: number): number;
|
|
7
|
+
export declare function pxToPt(px: number): number;
|
|
8
|
+
export declare function widthToPx(w: number): number;
|
|
9
|
+
export declare function pxToWidth(px: number): number;
|
|
10
|
+
export declare function shallowCopy(curr: any, target: any): void;
|
|
11
|
+
export declare class Range {
|
|
12
|
+
static fromMergeCell(mergeCell: MergeCell): Range;
|
|
13
|
+
get width(): number;
|
|
14
|
+
get height(): number;
|
|
15
|
+
get startRow(): number;
|
|
16
|
+
get startCol(): number;
|
|
17
|
+
get endRow(): number;
|
|
18
|
+
get endCol(): number;
|
|
19
|
+
setStartRow(startRow: number): this;
|
|
20
|
+
setStartCol(startCol: number): this;
|
|
21
|
+
setEndRow(endRow: number): this;
|
|
22
|
+
setEndCol(endCol: number): this;
|
|
23
|
+
reset(): void;
|
|
24
|
+
cover(range: Range): boolean;
|
|
25
|
+
equals(other: Range): boolean;
|
|
26
|
+
private _startRow;
|
|
27
|
+
private _startCol;
|
|
28
|
+
private _endRow;
|
|
29
|
+
private _endCol;
|
|
30
|
+
}
|
|
31
|
+
export declare class StandardColor {
|
|
32
|
+
static fromRgb(rgb: string): StandardColor;
|
|
33
|
+
static fromCtColor(color?: Color): StandardColor;
|
|
34
|
+
static from(r: number, g: number, b: number, a?: number): StandardColor;
|
|
35
|
+
css(): string;
|
|
36
|
+
rgb(): string;
|
|
37
|
+
setAlpha(alpha: number): void;
|
|
38
|
+
private _red?;
|
|
39
|
+
private _green?;
|
|
40
|
+
private _blue?;
|
|
41
|
+
private _alpha;
|
|
42
|
+
private _valid;
|
|
43
|
+
}
|
|
44
|
+
export type FontSizeUnit = "px" | "pt";
|
|
45
|
+
export declare class StandardFont implements Font {
|
|
46
|
+
static from(font: Font): StandardFont;
|
|
47
|
+
get size(): number;
|
|
48
|
+
name: CtFontName;
|
|
49
|
+
underline?: CtUnderlineProperty;
|
|
50
|
+
fontSizeUnit: FontSizeUnit;
|
|
51
|
+
lineHeight: string;
|
|
52
|
+
standardColor: StandardColor;
|
|
53
|
+
bold: boolean;
|
|
54
|
+
sz: number;
|
|
55
|
+
condense: boolean;
|
|
56
|
+
italic: boolean;
|
|
57
|
+
outline: boolean;
|
|
58
|
+
shadow: boolean;
|
|
59
|
+
strike: boolean;
|
|
60
|
+
extend: boolean;
|
|
61
|
+
toCssFont(): string;
|
|
62
|
+
}
|
|
63
|
+
export declare class StandardStyle implements Style {
|
|
64
|
+
protection: CtCellProtection;
|
|
65
|
+
border: Border;
|
|
66
|
+
font: Font;
|
|
67
|
+
fill: Fill;
|
|
68
|
+
alignment: Alignment;
|
|
69
|
+
formatter: string;
|
|
70
|
+
from(style: Style): this;
|
|
71
|
+
getFont(): StandardFont;
|
|
72
|
+
}
|
|
73
|
+
export declare class StandardValue {
|
|
74
|
+
cellValueOneof?: {
|
|
75
|
+
$case: "str";
|
|
76
|
+
str: string;
|
|
77
|
+
} | {
|
|
78
|
+
$case: "number";
|
|
79
|
+
number: number;
|
|
80
|
+
} | {
|
|
81
|
+
$case: "bool";
|
|
82
|
+
bool: boolean;
|
|
83
|
+
} | {
|
|
84
|
+
$case: "error";
|
|
85
|
+
error: string;
|
|
86
|
+
};
|
|
87
|
+
get value(): string | number | boolean;
|
|
88
|
+
get valueStr(): string;
|
|
89
|
+
from(value: Value): this;
|
|
90
|
+
}
|
|
91
|
+
export declare class StandardCell {
|
|
92
|
+
style?: StandardStyle;
|
|
93
|
+
value?: StandardValue;
|
|
94
|
+
formula: string;
|
|
95
|
+
diyCellId?: number;
|
|
96
|
+
blockId?: number;
|
|
97
|
+
setStyle(style?: StandardStyle): void;
|
|
98
|
+
getFormattedText(): string;
|
|
99
|
+
getText(): string;
|
|
100
|
+
getNumber(): number | undefined;
|
|
101
|
+
}
|
|
102
|
+
export declare class StandardRowInfo implements RowInfo {
|
|
103
|
+
readonly idx: number;
|
|
104
|
+
constructor(idx: number);
|
|
105
|
+
height: number;
|
|
106
|
+
hidden: boolean;
|
|
107
|
+
get pt(): number;
|
|
108
|
+
get px(): number;
|
|
109
|
+
static from(rowInfo: RowInfo): StandardRowInfo;
|
|
110
|
+
}
|
|
111
|
+
export declare class StandardColInfo implements ColInfo {
|
|
112
|
+
readonly idx: number;
|
|
113
|
+
constructor(idx: number);
|
|
114
|
+
hidden: boolean;
|
|
115
|
+
width: number;
|
|
116
|
+
get px(): number;
|
|
117
|
+
get pt(): number;
|
|
118
|
+
static from(colInfo: ColInfo): StandardColInfo;
|
|
119
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker types and constants used for communication between main thread and workers.
|
|
3
|
+
*/
|
|
4
|
+
import type { BlockInfo, CellInfo, CellPosition, DisplayWindowWithStartPoint, ErrorMessage, SheetDimension, SheetInfo, ReproducibleCell, Value, FormulaDisplayInfo } from "logisheets-web";
|
|
5
|
+
import type { Grid, AppropriateHeight } from "$types/index";
|
|
6
|
+
export type { AppropriateHeight } from "$types/index";
|
|
7
|
+
export declare const enum WorkerUpdate {
|
|
8
|
+
Cell = 0,
|
|
9
|
+
Sheet = 1,
|
|
10
|
+
CellAndSheet = 2,
|
|
11
|
+
Ready = 3,
|
|
12
|
+
CellValueChanged = 4,
|
|
13
|
+
CellRemoved = 5,
|
|
14
|
+
HeaderUpdated = 6
|
|
15
|
+
}
|
|
16
|
+
export declare enum MethodName {
|
|
17
|
+
GetSheetDimension = "getSheetDimension",
|
|
18
|
+
GetAllSheetInfo = "getAllSheetInfo",
|
|
19
|
+
GetDisplayWindow = "getDisplayWindow",
|
|
20
|
+
GetBlockDisplayWindow = "getBlockDisplayWindow",
|
|
21
|
+
GetCell = "getCell",
|
|
22
|
+
GetCells = "getCells",
|
|
23
|
+
GetCellsExceptWindow = "getCellsExceptWindow",
|
|
24
|
+
GetBlockInfo = "getBlockInfo",
|
|
25
|
+
GetCellPosition = "getCellPosition",
|
|
26
|
+
Undo = "undo",
|
|
27
|
+
Redo = "redo",
|
|
28
|
+
HandleTransaction = "handleTransaction",
|
|
29
|
+
HandleTransactionWithoutEvents = "handleTransactionWithoutEvents",
|
|
30
|
+
LoadWorkbook = "loadWorkbook",
|
|
31
|
+
IsReady = "isReady",
|
|
32
|
+
GetMergedCells = "getMergedCells",
|
|
33
|
+
CalcCondition = "calcCondition",
|
|
34
|
+
GetCellIdByBlockRef = "getCellIdByBlockRef",
|
|
35
|
+
GetTempStatusChanges = "getTempStatusChanges",
|
|
36
|
+
CheckFormula = "checkFormula",
|
|
37
|
+
Save = "save",
|
|
38
|
+
CleanupTempStatus = "cleanupTempStatus",
|
|
39
|
+
ToggleStatus = "toggleStatus",
|
|
40
|
+
CommitTempStatus = "commitTempStatus",
|
|
41
|
+
BatchGetCellInfoById = "batchGetCellInfoById",
|
|
42
|
+
BatchGetCellCoordinateWithSheetById = "batchGetCellCoordinateWithSheetById",
|
|
43
|
+
GetSheetNameByIdx = "getSheetNameByIdx",
|
|
44
|
+
LookupAppendixUpward = "lookupAppendixUpward",
|
|
45
|
+
GetBlockRowId = "getBlockRowId",
|
|
46
|
+
GetBlockColId = "getBlockColId",
|
|
47
|
+
GetSheetIdx = "getSheetIdx",
|
|
48
|
+
GetSheetId = "getSheetId",
|
|
49
|
+
GetBlockValues = "getBlockValues",
|
|
50
|
+
GetAvailableBlockId = "getAvailableBlockId",
|
|
51
|
+
GetDiyCellIdWithBlockId = "getDiyCellIdWithBlockId",
|
|
52
|
+
GetReproducibleCell = "getReproducibleCell",
|
|
53
|
+
GetReproducibleCells = "getReproducibleCells",
|
|
54
|
+
GetCellValue = "getCellValue",
|
|
55
|
+
GetShadowCellId = "getShadowCellId",
|
|
56
|
+
GetShadowCellIds = "getShadowCellIds",
|
|
57
|
+
GetShadowInfoById = "getShadowInfoById",
|
|
58
|
+
GetCellId = "getCellId",
|
|
59
|
+
GetDisplayUnitsOfFormula = "getDisplayUnitsOfFormula",
|
|
60
|
+
GetNextVisibleCell = "getNextVisibleCell",
|
|
61
|
+
GetAllBlockFields = "getAllBlockFields",
|
|
62
|
+
GetAppData = "getAppData",
|
|
63
|
+
GetFullyCoveredBlocks = "getFullyCoveredBlocks"
|
|
64
|
+
}
|
|
65
|
+
export declare enum OffscreenRenderName {
|
|
66
|
+
Render = "render",
|
|
67
|
+
Resize = "resize",
|
|
68
|
+
Init = "init",
|
|
69
|
+
GetAppropriateHeights = "getAppropriateHeights",
|
|
70
|
+
SetLicense = "setLicense",
|
|
71
|
+
ClearLicense = "clearLicense"
|
|
72
|
+
}
|
|
73
|
+
export type Result<T> = T | ErrorMessage;
|
|
74
|
+
export interface IWorkbookWorker {
|
|
75
|
+
isReady(): Result<boolean>;
|
|
76
|
+
getAllSheetInfo(): Result<readonly SheetInfo[]>;
|
|
77
|
+
getDisplayWindow(params: any): Result<DisplayWindowWithStartPoint>;
|
|
78
|
+
getCell(params: any): Result<CellInfo>;
|
|
79
|
+
getCells(params: any): Result<readonly CellInfo[]>;
|
|
80
|
+
getReproducibleCell(params: any): Result<ReproducibleCell>;
|
|
81
|
+
getReproducibleCells(params: any): Result<readonly ReproducibleCell[]>;
|
|
82
|
+
getValue(params: any): Result<Value>;
|
|
83
|
+
getBlockInfo(params: any): Result<BlockInfo>;
|
|
84
|
+
getCellPosition(params: any): Result<CellPosition>;
|
|
85
|
+
getSheetDimension(sheetIdx: number): Result<SheetDimension>;
|
|
86
|
+
undo(): Result<void>;
|
|
87
|
+
redo(): Result<void>;
|
|
88
|
+
handleTransaction(params: any): Result<void>;
|
|
89
|
+
loadWorkbook(params: any): Result<void>;
|
|
90
|
+
getSheetIdx(params: any): Result<number>;
|
|
91
|
+
getBlockValues(params: any): Result<readonly string[]>;
|
|
92
|
+
getAvailableBlockId(params: any): Result<number>;
|
|
93
|
+
getSheetId(params: any): Result<number>;
|
|
94
|
+
getDisplayUnitsOfFormula(f: string): Result<FormulaDisplayInfo>;
|
|
95
|
+
getWorkbook(): any;
|
|
96
|
+
}
|
|
97
|
+
export interface IOffscreenWorker {
|
|
98
|
+
render(sheetId: number, anchorX: number, anchorY: number): Result<Grid>;
|
|
99
|
+
resize(width: number, height: number, dpr: number): Result<Grid>;
|
|
100
|
+
init(canvas: OffscreenCanvas, dpr: number): void;
|
|
101
|
+
getAppropriateHeights(sheetId: number, anchorX: number, anchorY: number): Result<AppropriateHeight[]>;
|
|
102
|
+
}
|
|
103
|
+
export interface WorkerRequest {
|
|
104
|
+
id: number;
|
|
105
|
+
m: string;
|
|
106
|
+
args?: any;
|
|
107
|
+
}
|
|
108
|
+
export interface WorkerResponse {
|
|
109
|
+
id: number;
|
|
110
|
+
result?: any;
|
|
111
|
+
error?: any;
|
|
112
|
+
}
|
|
113
|
+
export interface OffscreenRequest {
|
|
114
|
+
rid: number;
|
|
115
|
+
m: string;
|
|
116
|
+
args?: any;
|
|
117
|
+
}
|
|
118
|
+
export interface OffscreenResponse {
|
|
119
|
+
rid: number;
|
|
120
|
+
result?: any;
|
|
121
|
+
error?: any;
|
|
122
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ViewManager - responsible for efficiently generating CellViewData for rendering.
|
|
3
|
+
*/
|
|
4
|
+
import type { BlockDisplayInfo, Comment } from "logisheets-web";
|
|
5
|
+
import type { IWorkbookWorker, Result } from "./types";
|
|
6
|
+
import type { Pool } from "./pool";
|
|
7
|
+
import { RenderCell } from "./render";
|
|
8
|
+
export declare class CellView {
|
|
9
|
+
readonly data: CellViewData[];
|
|
10
|
+
constructor(data: CellViewData[]);
|
|
11
|
+
get fromRow(): number;
|
|
12
|
+
get toRow(): number;
|
|
13
|
+
get fromCol(): number;
|
|
14
|
+
get toCol(): number;
|
|
15
|
+
get rows(): readonly RenderCell[];
|
|
16
|
+
get cols(): readonly RenderCell[];
|
|
17
|
+
get cells(): readonly RenderCell[];
|
|
18
|
+
get mergeCells(): readonly RenderCell[];
|
|
19
|
+
get blocks(): readonly BlockDisplayInfo[];
|
|
20
|
+
}
|
|
21
|
+
export declare class CellViewData {
|
|
22
|
+
rows: readonly RenderCell[];
|
|
23
|
+
cols: readonly RenderCell[];
|
|
24
|
+
cells: readonly RenderCell[];
|
|
25
|
+
mergeCells: readonly RenderCell[];
|
|
26
|
+
comments: readonly Comment[];
|
|
27
|
+
blocks: readonly BlockDisplayInfo[];
|
|
28
|
+
fromRow: number;
|
|
29
|
+
toRow: number;
|
|
30
|
+
fromCol: number;
|
|
31
|
+
toCol: number;
|
|
32
|
+
constructor(rows: readonly RenderCell[], cols: readonly RenderCell[], cells: readonly RenderCell[], mergeCells: readonly RenderCell[], comments: readonly Comment[], blocks: readonly BlockDisplayInfo[]);
|
|
33
|
+
}
|
|
34
|
+
export interface CellViewRequest {
|
|
35
|
+
readonly startX: number;
|
|
36
|
+
readonly startY: number;
|
|
37
|
+
readonly height: number;
|
|
38
|
+
readonly width: number;
|
|
39
|
+
}
|
|
40
|
+
export interface CellViewResponse {
|
|
41
|
+
readonly type: CellViewRespType;
|
|
42
|
+
readonly data: CellView;
|
|
43
|
+
readonly request: CellViewRequest;
|
|
44
|
+
readonly anchorX: number;
|
|
45
|
+
readonly anchorY: number;
|
|
46
|
+
}
|
|
47
|
+
export declare enum CellViewRespType {
|
|
48
|
+
Existed = 0,
|
|
49
|
+
Incremental = 1,
|
|
50
|
+
New = 2
|
|
51
|
+
}
|
|
52
|
+
export declare class ViewManager {
|
|
53
|
+
private _workbook;
|
|
54
|
+
private _sheetIdx;
|
|
55
|
+
private _pool;
|
|
56
|
+
constructor(_workbook: IWorkbookWorker, _sheetIdx: number, _pool: Pool);
|
|
57
|
+
dataChunks: CellViewData[];
|
|
58
|
+
getViewResponse(startX: number, startY: number, height: number, width: number): Result<CellViewResponse>;
|
|
59
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workbook worker service - handles all workbook-related operations in a Web Worker.
|
|
3
|
+
*/
|
|
4
|
+
import { Workbook } from "logisheets-web";
|
|
5
|
+
import type { BlockInfo, CellInfo, CellPosition, DisplayWindowWithStartPoint, MergeCell, SheetDimension, SheetInfo, CellCoordinate, FormulaDisplayInfo, ActionEffect, Value, ReproducibleCell, AppendixWithCell, SheetCellId, ShadowCellInfo, BlockField, AppData, CellCoordinateWithSheet, TempStatusDiff } from "logisheets-web";
|
|
6
|
+
import type { Result, IWorkbookWorker } from "./types";
|
|
7
|
+
export declare class WorkbookWorkerService implements IWorkbookWorker {
|
|
8
|
+
private _ctx;
|
|
9
|
+
constructor(_ctx: Worker);
|
|
10
|
+
private _workbookImpl;
|
|
11
|
+
init(): Promise<void>;
|
|
12
|
+
get workbook(): Workbook;
|
|
13
|
+
getWorkbook(): Workbook;
|
|
14
|
+
isReady(): Result<boolean>;
|
|
15
|
+
loadWorkbook(params: {
|
|
16
|
+
content: Uint8Array;
|
|
17
|
+
name: string;
|
|
18
|
+
}): Result<void>;
|
|
19
|
+
save(params: any): Result<any>;
|
|
20
|
+
getAllSheetInfo(): Result<readonly SheetInfo[]>;
|
|
21
|
+
getSheetDimension(sheetIdx: number): Result<SheetDimension>;
|
|
22
|
+
getSheetIdx(params: {
|
|
23
|
+
sheetId: number;
|
|
24
|
+
}): Result<number>;
|
|
25
|
+
getSheetId(params: {
|
|
26
|
+
sheetIdx: number;
|
|
27
|
+
}): Result<number>;
|
|
28
|
+
getSheetNameByIdx(idx: number): Result<string>;
|
|
29
|
+
private getSheet;
|
|
30
|
+
getCell(params: {
|
|
31
|
+
sheetIdx: number;
|
|
32
|
+
row: number;
|
|
33
|
+
col: number;
|
|
34
|
+
}): Result<CellInfo>;
|
|
35
|
+
getCells(params: {
|
|
36
|
+
sheetIdx: number;
|
|
37
|
+
startRow: number;
|
|
38
|
+
startCol: number;
|
|
39
|
+
endRow: number;
|
|
40
|
+
endCol: number;
|
|
41
|
+
}): Result<readonly CellInfo[]>;
|
|
42
|
+
getCellPosition(params: {
|
|
43
|
+
sheetIdx: number;
|
|
44
|
+
row: number;
|
|
45
|
+
col: number;
|
|
46
|
+
}): Result<CellPosition>;
|
|
47
|
+
getCellId(params: any): Result<SheetCellId>;
|
|
48
|
+
getValue(params: {
|
|
49
|
+
sheetId: number;
|
|
50
|
+
row: number;
|
|
51
|
+
col: number;
|
|
52
|
+
}): Result<Value>;
|
|
53
|
+
getReproducibleCell(params: {
|
|
54
|
+
sheetIdx: number;
|
|
55
|
+
row: number;
|
|
56
|
+
col: number;
|
|
57
|
+
}): Result<ReproducibleCell>;
|
|
58
|
+
getReproducibleCells(params: {
|
|
59
|
+
sheetIdx: number;
|
|
60
|
+
coordinates: any;
|
|
61
|
+
}): Result<readonly ReproducibleCell[]>;
|
|
62
|
+
batchGetCellInfoById(params: {
|
|
63
|
+
ids: readonly SheetCellId[];
|
|
64
|
+
}): Result<readonly CellInfo[]>;
|
|
65
|
+
batchGetCellCoordinateWithSheetById(ids: readonly SheetCellId[]): Result<readonly CellCoordinateWithSheet[]>;
|
|
66
|
+
getNextVisibleCell(args: {
|
|
67
|
+
sheetIdx: number;
|
|
68
|
+
rowIdx: number;
|
|
69
|
+
colIdx: number;
|
|
70
|
+
direction: "up" | "down" | "left" | "right";
|
|
71
|
+
}): Result<CellCoordinate>;
|
|
72
|
+
getDisplayWindow(params: {
|
|
73
|
+
sheetIdx: number;
|
|
74
|
+
startX: number;
|
|
75
|
+
startY: number;
|
|
76
|
+
height: number;
|
|
77
|
+
width: number;
|
|
78
|
+
}): Result<DisplayWindowWithStartPoint>;
|
|
79
|
+
getMergedCells(params: {
|
|
80
|
+
sheetIdx: number;
|
|
81
|
+
startRow: number;
|
|
82
|
+
startCol: number;
|
|
83
|
+
endRow: number;
|
|
84
|
+
endCol: number;
|
|
85
|
+
}): Result<readonly MergeCell[]>;
|
|
86
|
+
getBlockInfo(params: {
|
|
87
|
+
sheetId: number;
|
|
88
|
+
blockId: number;
|
|
89
|
+
}): Result<BlockInfo>;
|
|
90
|
+
getBlockValues(params: {
|
|
91
|
+
sheetId: number;
|
|
92
|
+
blockId: number;
|
|
93
|
+
rowIds: any;
|
|
94
|
+
colIds: any;
|
|
95
|
+
}): Result<readonly string[]>;
|
|
96
|
+
getAvailableBlockId(params: {
|
|
97
|
+
sheetIdx: number;
|
|
98
|
+
}): Result<number>;
|
|
99
|
+
getDiyCellIdWithBlockId(params: {
|
|
100
|
+
sheetId: number;
|
|
101
|
+
blockId: number;
|
|
102
|
+
row: number;
|
|
103
|
+
col: number;
|
|
104
|
+
}): Result<number>;
|
|
105
|
+
lookupAppendixUpward(params: {
|
|
106
|
+
sheetId: number;
|
|
107
|
+
blockId: number;
|
|
108
|
+
row: number;
|
|
109
|
+
col: number;
|
|
110
|
+
craftId: string;
|
|
111
|
+
tag: number;
|
|
112
|
+
}): Result<AppendixWithCell>;
|
|
113
|
+
getAllBlockFields(): Result<readonly BlockField[]>;
|
|
114
|
+
getFullyCoveredBlocks(params: {
|
|
115
|
+
sheetIdx: number;
|
|
116
|
+
rowIdx: number;
|
|
117
|
+
colIdx: number;
|
|
118
|
+
rowCnt: number;
|
|
119
|
+
colCnt: number;
|
|
120
|
+
}): Result<readonly BlockInfo[]>;
|
|
121
|
+
getShadowCellId(params: {
|
|
122
|
+
sheetIdx: number;
|
|
123
|
+
rowIdx: number;
|
|
124
|
+
colIdx: number;
|
|
125
|
+
}): Result<number>;
|
|
126
|
+
getShadowCellIds(params: any): Result<readonly number[]>;
|
|
127
|
+
getShadowInfoById(params: {
|
|
128
|
+
shadowId: number;
|
|
129
|
+
}): Result<ShadowCellInfo>;
|
|
130
|
+
handleTransaction(params: {
|
|
131
|
+
transaction: any;
|
|
132
|
+
temp: boolean;
|
|
133
|
+
}): Result<void>;
|
|
134
|
+
handleTransactionWithoutEvents(params: {
|
|
135
|
+
transaction: any;
|
|
136
|
+
temp: boolean;
|
|
137
|
+
}): Result<ActionEffect>;
|
|
138
|
+
undo(): Result<void>;
|
|
139
|
+
redo(): Result<void>;
|
|
140
|
+
commitTempStatus(): Result<void>;
|
|
141
|
+
cleanupTempStatus(): Result<void>;
|
|
142
|
+
toggleStatus(useTemp: boolean): Result<void>;
|
|
143
|
+
getDisplayUnitsOfFormula(f: string): Result<FormulaDisplayInfo>;
|
|
144
|
+
calcCondition(params: {
|
|
145
|
+
sheetIdx: number;
|
|
146
|
+
condition: any;
|
|
147
|
+
}): Result<boolean>;
|
|
148
|
+
getCellIdByBlockRef(params: {
|
|
149
|
+
refName: string;
|
|
150
|
+
key: string;
|
|
151
|
+
field: string;
|
|
152
|
+
}): Result<SheetCellId>;
|
|
153
|
+
getTempStatusChanges(): Result<TempStatusDiff>;
|
|
154
|
+
checkFormula(params: {
|
|
155
|
+
formula: string;
|
|
156
|
+
}): boolean;
|
|
157
|
+
getAppData(): Result<readonly AppData[]>;
|
|
158
|
+
handleRequest(request: {
|
|
159
|
+
m: string;
|
|
160
|
+
args: any;
|
|
161
|
+
id: number;
|
|
162
|
+
}): Promise<void>;
|
|
163
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for the LogiSheets engine.
|
|
3
|
+
* This file contains all the interfaces that the engine interacts with externally.
|
|
4
|
+
*/
|
|
5
|
+
import type { BlockDisplayInfo, CellInfo, MergeCell, SelectedData, SheetInfo, CellLayout } from "logisheets-web";
|
|
6
|
+
export interface Row {
|
|
7
|
+
height: number;
|
|
8
|
+
idx: number;
|
|
9
|
+
}
|
|
10
|
+
export interface Column {
|
|
11
|
+
width: number;
|
|
12
|
+
idx: number;
|
|
13
|
+
}
|
|
14
|
+
export interface Grid {
|
|
15
|
+
anchorX: number;
|
|
16
|
+
anchorY: number;
|
|
17
|
+
/**
|
|
18
|
+
* Pixels by which the first visible row/column is scrolled past the canvas
|
|
19
|
+
* top/left. `anchorY - firstVisibleRow.position.startRow`. Overlay helpers
|
|
20
|
+
* subtract these so positions stay in canvas-pixel space.
|
|
21
|
+
*/
|
|
22
|
+
subOffsetX: number;
|
|
23
|
+
subOffsetY: number;
|
|
24
|
+
rows: readonly Row[];
|
|
25
|
+
columns: readonly Column[];
|
|
26
|
+
mergeCells?: readonly MergeCell[];
|
|
27
|
+
blockInfos?: readonly BlockDisplayInfo[];
|
|
28
|
+
preRowHeight?: number;
|
|
29
|
+
preColWidth?: number;
|
|
30
|
+
nextRowHeight?: number;
|
|
31
|
+
nextColWidth?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface AppropriateHeight {
|
|
34
|
+
height: number;
|
|
35
|
+
row: number;
|
|
36
|
+
col: number;
|
|
37
|
+
}
|
|
38
|
+
export interface SelectorStyle {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
width: number;
|
|
42
|
+
height: number;
|
|
43
|
+
borderTopWidth: number;
|
|
44
|
+
borderBottomWidth: number;
|
|
45
|
+
borderLeftWidth: number;
|
|
46
|
+
borderRightWidth: number;
|
|
47
|
+
}
|
|
48
|
+
export declare class Range {
|
|
49
|
+
static fromMergeCell(mergeCell: MergeCell): Range;
|
|
50
|
+
get width(): number;
|
|
51
|
+
get height(): number;
|
|
52
|
+
get startRow(): number;
|
|
53
|
+
get startCol(): number;
|
|
54
|
+
get endRow(): number;
|
|
55
|
+
get endCol(): number;
|
|
56
|
+
setStartRow(startRow: number): this;
|
|
57
|
+
setStartCol(startCol: number): this;
|
|
58
|
+
setEndRow(endRow: number): this;
|
|
59
|
+
setEndCol(endCol: number): this;
|
|
60
|
+
setStartEndRow(row: number): this;
|
|
61
|
+
setStartEndCol(col: number): this;
|
|
62
|
+
reset(): void;
|
|
63
|
+
cover(range: Range): boolean;
|
|
64
|
+
equals(other: Range): boolean;
|
|
65
|
+
private _startRow;
|
|
66
|
+
private _startCol;
|
|
67
|
+
private _endRow;
|
|
68
|
+
private _endCol;
|
|
69
|
+
}
|
|
70
|
+
export type CellType = "Cell" | "LeftTop" | "FixedLeftHeader" | "FixedTopHeader" | "unknown";
|
|
71
|
+
export declare class Cell {
|
|
72
|
+
type: CellType;
|
|
73
|
+
constructor(type: CellType);
|
|
74
|
+
get width(): number;
|
|
75
|
+
get height(): number;
|
|
76
|
+
setCoordinate(coordinate: Range): this;
|
|
77
|
+
setPosition(position: Range): this;
|
|
78
|
+
equals(cell: Cell): boolean;
|
|
79
|
+
coordinate: Range;
|
|
80
|
+
position: Range;
|
|
81
|
+
info?: CellInfo;
|
|
82
|
+
}
|
|
83
|
+
export interface CanvasProps {
|
|
84
|
+
selectedData: SelectedData;
|
|
85
|
+
onSelectedDataChange: (e: SelectedData) => void;
|
|
86
|
+
activeSheet: number;
|
|
87
|
+
onActiveSheetChange: (s: number) => void;
|
|
88
|
+
onSelectedDataContentChanged: (e: object) => void;
|
|
89
|
+
grid: Grid | null;
|
|
90
|
+
onGridChange: (grid: Grid | null) => void;
|
|
91
|
+
cellLayouts: CellLayout[];
|
|
92
|
+
}
|
|
93
|
+
export interface EngineEvents {
|
|
94
|
+
onSheetChange: (sheets: readonly SheetInfo[]) => void;
|
|
95
|
+
onCellUpdate: () => void;
|
|
96
|
+
onError: (error: Error) => void;
|
|
97
|
+
}
|
|
98
|
+
export interface EngineConfig {
|
|
99
|
+
/** Width of the left header panel in pixels */
|
|
100
|
+
leftTopWidth: number;
|
|
101
|
+
/** Height of the top header panel in pixels */
|
|
102
|
+
leftTopHeight: number;
|
|
103
|
+
/** Show horizontal grid lines */
|
|
104
|
+
showHorizontalGridLines: boolean;
|
|
105
|
+
/** Show vertical grid lines */
|
|
106
|
+
showVerticalGridLines: boolean;
|
|
107
|
+
/** Default cell width in pt */
|
|
108
|
+
defaultCellWidth: number;
|
|
109
|
+
/** Default cell height in pt */
|
|
110
|
+
defaultCellHeight: number;
|
|
111
|
+
/** Scrollbar size in pixels */
|
|
112
|
+
scrollbarSize: number;
|
|
113
|
+
}
|
|
114
|
+
export declare const DEFAULT_ENGINE_CONFIG: EngineConfig;
|
|
115
|
+
export type { SelectedData, SelectedCellRange, SelectedLines, SheetInfo, CellInfo, CellRef, FormulaDisplayInfo, MergeCell, BlockDisplayInfo, CellLayout, Transaction, Payload, } from "logisheets-web";
|