@univerjs/engine-render 1.4.0 → 1.5.1
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 +17 -5
- package/lib/cjs/{worker-dzyTVvQi.js → doc-skeleton-xHfOLvcR.js} +105 -263
- package/lib/cjs/index.js +3070 -1374
- package/lib/cjs/worker.js +239 -4
- package/lib/{es/worker-BlCdBXpV.js → doc-skeleton-h5WFPD-i.js} +88 -258
- package/lib/{worker-BlCdBXpV.js → es/doc-skeleton-h5WFPD-i.js} +88 -258
- package/lib/es/index.js +2198 -502
- package/lib/es/worker.js +236 -1
- package/lib/index.js +2198 -502
- package/lib/types/base-object.d.ts +5 -0
- package/lib/types/basics/draw.d.ts +1 -1
- package/lib/types/basics/interfaces.d.ts +1 -0
- package/lib/types/components/component.d.ts +1 -0
- package/lib/types/components/docs/document-layout-presentation.d.ts +1 -0
- package/lib/types/components/docs/layout/shaping-engine/font-cache.d.ts +2 -0
- package/lib/types/components/docs/layout/tools.d.ts +2 -0
- package/lib/types/components/docs/view-model/document-view-model.d.ts +2 -1
- package/lib/types/components/extension.d.ts +5 -1
- package/lib/types/components/sheets/extensions/background.d.ts +1 -0
- package/lib/types/components/sheets/extensions/border-row-cache.d.ts +27 -0
- package/lib/types/components/sheets/extensions/border.d.ts +9 -1
- package/lib/types/components/sheets/extensions/column-header-layout.d.ts +1 -0
- package/lib/types/components/sheets/extensions/custom.d.ts +1 -0
- package/lib/types/components/sheets/extensions/font.d.ts +6 -0
- package/lib/types/components/sheets/extensions/marker.d.ts +1 -0
- package/lib/types/components/sheets/extensions/render-primitive-cache.d.ts +37 -0
- package/lib/types/components/sheets/extensions/row-header-layout.d.ts +1 -0
- package/lib/types/components/sheets/interfaces.d.ts +1 -0
- package/lib/types/components/sheets/sheet-cell-document-view-model.d.ts +2 -0
- package/lib/types/components/sheets/sheet-component.d.ts +3 -0
- package/lib/types/components/sheets/sheet.render-skeleton.d.ts +9 -0
- package/lib/types/components/sheets/spreadsheet.d.ts +25 -3
- package/lib/types/context.d.ts +3 -0
- package/lib/types/index.d.ts +0 -3
- package/lib/types/layer.d.ts +8 -1
- package/lib/types/scene.d.ts +13 -1
- package/lib/types/scene.transformer.d.ts +21 -1
- package/lib/types/shape/control.d.ts +1 -0
- package/lib/types/shape/scroll-bar.d.ts +2 -2
- package/lib/types/shape/text.d.ts +6 -1
- package/lib/types/transformer-rotation.d.ts +42 -0
- package/lib/types/viewport.d.ts +3 -2
- package/lib/umd/index.js +5 -5
- package/lib/worker.js +236 -1
- package/package.json +6 -6
|
@@ -146,7 +146,12 @@ export declare abstract class BaseObject extends Disposable {
|
|
|
146
146
|
get transformerConfig(): ITransformerConfig;
|
|
147
147
|
set transformerConfig(config: ITransformerConfig);
|
|
148
148
|
get maxZIndex(): number;
|
|
149
|
+
/** Opt in only when pixels depend on invalidated render state, not animation or external callbacks. */
|
|
150
|
+
viewportCacheReusable: boolean;
|
|
151
|
+
canReuseViewportCache(): boolean;
|
|
152
|
+
onViewportCacheReuse(_viewportInfo: IViewportInfo): void;
|
|
149
153
|
makeDirty(state?: boolean): this | undefined;
|
|
154
|
+
isForceDirty(): boolean;
|
|
150
155
|
makeForceDirty(state?: boolean): void;
|
|
151
156
|
makeDirtyNoDebounce(state?: boolean): this;
|
|
152
157
|
isDirty(): boolean;
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { IPosition } from '@univerjs/core';
|
|
17
|
+
import { BorderStyleTypes } from '@univerjs/core';
|
|
17
18
|
import type { UniverRenderingContext } from '../context';
|
|
18
19
|
import type { IDocumentSkeletonLine } from './i-document-skeleton-cached';
|
|
19
|
-
import { BorderStyleTypes } from '@univerjs/core';
|
|
20
20
|
import { BORDER_TYPE, ORIENTATION_TYPE } from './const';
|
|
21
21
|
import { Vector2 } from './vector2';
|
|
22
22
|
export interface IContext2D extends CanvasRenderingContext2D {
|
|
@@ -127,6 +127,7 @@ export interface IParagraphConfig {
|
|
|
127
127
|
pDrawingAnchor?: Map<number, IDocumentSkeletonDrawingAnchor>;
|
|
128
128
|
}
|
|
129
129
|
export interface IFontCreateConfig {
|
|
130
|
+
stackedText?: boolean;
|
|
130
131
|
fontStyle: IDocumentSkeletonFontStyle;
|
|
131
132
|
textStyle: IDocumentLayoutTextStyle;
|
|
132
133
|
charSpace: number;
|
|
@@ -20,6 +20,7 @@ import type { ComponentExtension } from './extension';
|
|
|
20
20
|
import { BaseObject } from '../base-object';
|
|
21
21
|
export declare class RenderComponent<T, U, V> extends BaseObject {
|
|
22
22
|
private _extensions;
|
|
23
|
+
canReuseViewportCache(): boolean;
|
|
23
24
|
get extensions(): Map<string, ComponentExtension<T, U, V>>;
|
|
24
25
|
register(...extensions: Array<ComponentExtension<T, U, V>>): IDisposable;
|
|
25
26
|
getExtensionsByOrder(): ComponentExtension<T, U, V>[];
|
|
@@ -41,6 +41,7 @@ export interface IDocumentLayoutTextStyle extends ITextStyle {
|
|
|
41
41
|
ol?: IDocumentLayoutTextDecoration;
|
|
42
42
|
}
|
|
43
43
|
export interface IDocumentLayoutRenderConfig extends IDocumentRenderConfig {
|
|
44
|
+
stackedText?: boolean;
|
|
44
45
|
topAlignExactLineSpacing?: BooleanNumber;
|
|
45
46
|
useTextInkForHitTesting?: BooleanNumber;
|
|
46
47
|
preservePunctuationSpacing?: BooleanNumber;
|
|
@@ -31,6 +31,8 @@ export declare class FontCache {
|
|
|
31
31
|
private static _context;
|
|
32
32
|
private static _fontDataMap;
|
|
33
33
|
private static _globalFontMeasureCache;
|
|
34
|
+
private static _metricsRevision;
|
|
35
|
+
static get metricsRevision(): number;
|
|
34
36
|
static get globalFontMeasureCache(): Map<string, Map<string, IMeasureTextCache>>;
|
|
35
37
|
static invalidateMetrics(matches: (fontStyle: string) => boolean): boolean;
|
|
36
38
|
static setFontMeasureCache(fontStyle: string, content: string, tm: IMeasureTextCache): void;
|
|
@@ -164,6 +164,7 @@ export declare function getPositionHorizon(positionH: IObjectPositionH, column:
|
|
|
164
164
|
export declare function getPositionVertical(positionV: IObjectPositionV, page: IDocumentSkeletonPage, lineTop: number, lineHeight: number, objectHeight: number, blockAnchorTop?: number, isPageBreak?: boolean): number | undefined;
|
|
165
165
|
export declare function getGlyphGroupWidth(divide: IDocumentSkeletonDivide, excludeTrailingSpaces?: boolean): number;
|
|
166
166
|
interface IFontCreateConfig {
|
|
167
|
+
stackedText?: boolean;
|
|
167
168
|
documentCompatibilityPolicy?: IDocumentCompatibilityPolicy;
|
|
168
169
|
fontStyle: IDocumentSkeletonFontStyle;
|
|
169
170
|
textStyle: IDocumentLayoutTextStyle;
|
|
@@ -176,6 +177,7 @@ interface IFontCreateConfig {
|
|
|
176
177
|
export declare function clearFontCreateConfigCache(): void;
|
|
177
178
|
export declare function getFontConfigFromLastGlyph(glyph: IDocumentSkeletonGlyph, sectionBreakConfig: ISectionBreakConfig, paragraphStyle: IDocumentLayoutParagraphStyle): {
|
|
178
179
|
documentCompatibilityPolicy: IDocumentCompatibilityPolicy;
|
|
180
|
+
stackedText: boolean | undefined;
|
|
179
181
|
fontStyle: IDocumentSkeletonFontStyle;
|
|
180
182
|
textStyle: IDocumentLayoutTextStyle;
|
|
181
183
|
balanceSingleByteDoubleByteWidth: BooleanNumber | undefined;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { DocumentDataModel, ICustomBlock, ICustomDecorationForInterceptor, ICustomRangeForInterceptor, ICustomTable, IDisposable, IParagraphStyle, ITable, JSONXActions, Nullable } from '@univerjs/core';
|
|
17
17
|
import { BooleanNumber } from '@univerjs/core';
|
|
18
|
-
import type { IDocumentLayoutBody, IDocumentLayoutColumnGroup, IDocumentLayoutCustomColumnGroup, IDocumentLayoutParagraph, IDocumentLayoutSectionBreak, IDocumentLayoutSnapshot, IDocumentLayoutTextRun } from '../document-layout-presentation';
|
|
18
|
+
import type { IDocumentLayoutBody, IDocumentLayoutColumnGroup, IDocumentLayoutCustomColumnGroup, IDocumentLayoutParagraph, IDocumentLayoutRenderConfig, IDocumentLayoutSectionBreak, IDocumentLayoutSnapshot, IDocumentLayoutTextRun } from '../document-layout-presentation';
|
|
19
19
|
import type { IHeadingSection } from './heading-sections';
|
|
20
20
|
import { DataStreamTreeNode } from './data-stream-tree-node';
|
|
21
21
|
interface ITableNodeCache {
|
|
@@ -92,6 +92,7 @@ export declare class DocumentViewModel implements IDisposable {
|
|
|
92
92
|
getBody(): IDocumentLayoutBody | undefined;
|
|
93
93
|
getSnapshot(): IDocumentLayoutSnapshot;
|
|
94
94
|
getParagraphWordWrap(paragraphStyle: IParagraphStyle): BooleanNumber | undefined;
|
|
95
|
+
getLayoutRenderConfig(config: IDocumentLayoutRenderConfig): IDocumentLayoutRenderConfig;
|
|
95
96
|
createLineBreaker(content: string, paragraphStyle: IParagraphStyle, start: number): import("../layout/line-breaker/line-breaker").LineBreaker;
|
|
96
97
|
getDataModel(): DocumentDataModel;
|
|
97
98
|
getSelfOrHeaderFooterViewModel(segmentId?: string): DocumentViewModel;
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { IRange, IScale, Nullable } from '@univerjs/core';
|
|
17
|
+
import { Registry } from '@univerjs/core';
|
|
17
18
|
import type { BaseObject } from '../base-object';
|
|
18
19
|
import type { IBoundRectNoAngle, Vector2 } from '../basics/vector2';
|
|
19
20
|
import type { UniverRenderingContext } from '../context';
|
|
20
21
|
import type { IDocumentLayoutRenderConfig } from './docs/document-layout-presentation';
|
|
21
|
-
import { Registry } from '@univerjs/core';
|
|
22
22
|
export interface IExtensionConfig {
|
|
23
23
|
originTranslate?: Vector2;
|
|
24
24
|
spanStartPoint?: Vector2;
|
|
@@ -34,9 +34,12 @@ export interface IDrawInfo {
|
|
|
34
34
|
fontRenderRanges?: IRange[];
|
|
35
35
|
hasMergeData?: boolean;
|
|
36
36
|
viewBound?: IBoundRectNoAngle;
|
|
37
|
+
/** Physical-pixel damage clip, before any extension-specific clipping. */
|
|
38
|
+
textClipBound?: IBoundRectNoAngle;
|
|
37
39
|
}
|
|
38
40
|
export declare class ComponentExtension<T, U, V> {
|
|
39
41
|
uKey: string;
|
|
42
|
+
viewportCacheReusable: boolean;
|
|
40
43
|
type: U;
|
|
41
44
|
protected Z_INDEX: number;
|
|
42
45
|
parent: Nullable<BaseObject>;
|
|
@@ -44,6 +47,7 @@ export declare class ComponentExtension<T, U, V> {
|
|
|
44
47
|
translateY: number;
|
|
45
48
|
extensionOffset: IExtensionConfig;
|
|
46
49
|
get zIndex(): number;
|
|
50
|
+
canReuseViewportCache(): boolean;
|
|
47
51
|
draw(_ctx: UniverRenderingContext, _parentScale: IScale, _skeleton: T, _diff?: V, _more?: IDrawInfo): void;
|
|
48
52
|
clearCache(): void;
|
|
49
53
|
protected _getScale(parentScale: IScale): number;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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 { IRange } from '@univerjs/core';
|
|
17
|
+
import { Disposable } from '@univerjs/core';
|
|
18
|
+
import type { SpreadsheetSkeleton } from '../sheet.render-skeleton';
|
|
19
|
+
import { UniverRenderingContext } from '../../../context';
|
|
20
|
+
/** Reuse native edge blits, preserving their order and individual alpha/clip composition. */
|
|
21
|
+
export declare class BorderRowCache extends Disposable {
|
|
22
|
+
private readonly _rows;
|
|
23
|
+
private _commands;
|
|
24
|
+
draw(ctx: UniverRenderingContext, skeleton: SpreadsheetSkeleton, row: number, range: IRange, resolveColor: (color: string) => string, paint: (target: UniverRenderingContext) => void): boolean;
|
|
25
|
+
clear(): void;
|
|
26
|
+
dispose(): void;
|
|
27
|
+
}
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { IRange, IScale, ObjectMatrix } from '@univerjs/core';
|
|
17
|
+
import { BorderStyleTypes } from '@univerjs/core';
|
|
17
18
|
import type { UniverRenderingContext } from '../../../context';
|
|
18
19
|
import type { IDrawInfo } from '../../extension';
|
|
19
20
|
import type { IBorderCache } from '../interfaces';
|
|
20
21
|
import type { SpreadsheetSkeleton } from '../sheet.render-skeleton';
|
|
21
|
-
import { BorderStyleTypes } from '@univerjs/core';
|
|
22
22
|
import { SheetExtension } from './sheet-extension';
|
|
23
23
|
interface IRenderBorderContext {
|
|
24
24
|
ctx: UniverRenderingContext;
|
|
@@ -27,12 +27,20 @@ interface IRenderBorderContext {
|
|
|
27
27
|
spreadsheetSkeleton: SpreadsheetSkeleton;
|
|
28
28
|
diffRanges: IRange[];
|
|
29
29
|
viewRanges: IRange[];
|
|
30
|
+
lineStyle?: BorderStyleTypes;
|
|
31
|
+
lineWidth?: number;
|
|
32
|
+
lineColor?: string;
|
|
30
33
|
}
|
|
31
34
|
export declare class Border extends SheetExtension {
|
|
35
|
+
readonly viewportCacheReusable: boolean;
|
|
32
36
|
uKey: string;
|
|
33
37
|
Z_INDEX: number;
|
|
34
38
|
preStyle: BorderStyleTypes;
|
|
35
39
|
preColor: string;
|
|
40
|
+
private readonly _strokeCache;
|
|
41
|
+
private readonly _rowCache;
|
|
42
|
+
clearCache(): void;
|
|
43
|
+
dispose(): void;
|
|
36
44
|
draw(ctx: UniverRenderingContext, _parentScale: IScale, spreadsheetSkeleton: SpreadsheetSkeleton, diffRanges: IRange[], { viewRanges }: IDrawInfo): void;
|
|
37
45
|
renderBorderByCell(renderBorderContext: IRenderBorderContext, row: number, col: number, borderCacheItem: IBorderCache): true | undefined;
|
|
38
46
|
private _getOverflowExclusion;
|
|
@@ -26,6 +26,7 @@ export interface IColumnsHeaderCfgParam {
|
|
|
26
26
|
* Column Header Bar, include a lot of columns header
|
|
27
27
|
*/
|
|
28
28
|
export declare class ColumnHeaderLayout extends SheetExtension {
|
|
29
|
+
readonly viewportCacheReusable: boolean;
|
|
29
30
|
uKey: string;
|
|
30
31
|
Z_INDEX: number;
|
|
31
32
|
columnsCfg: Record<number, IAColumnCfg>;
|
|
@@ -18,6 +18,7 @@ import type { UniverRenderingContext } from '../../../context';
|
|
|
18
18
|
import type { SpreadsheetSkeleton } from '../sheet.render-skeleton';
|
|
19
19
|
import { SheetExtension } from './sheet-extension';
|
|
20
20
|
export declare class Custom extends SheetExtension {
|
|
21
|
+
viewportCacheReusable: boolean;
|
|
21
22
|
protected Z_INDEX: number;
|
|
22
23
|
uKey: string;
|
|
23
24
|
draw(ctx: UniverRenderingContext, _parentScale: IScale, skeleton: SpreadsheetSkeleton, diffRanges: IRange[] | undefined): void;
|
|
@@ -52,11 +52,16 @@ interface IRenderFontContext {
|
|
|
52
52
|
cellInfo: ICellWithCoord;
|
|
53
53
|
}
|
|
54
54
|
export declare class Font extends SheetExtension {
|
|
55
|
+
readonly viewportCacheReusable: boolean;
|
|
55
56
|
uKey: string;
|
|
56
57
|
Z_INDEX: number;
|
|
57
58
|
private _imageFallback;
|
|
59
|
+
private readonly _primitiveCache;
|
|
60
|
+
clearCache(): void;
|
|
61
|
+
dispose(): void;
|
|
58
62
|
constructor();
|
|
59
63
|
getDocuments(): any;
|
|
64
|
+
getNativeTextClipRepairRanges(skeleton: SpreadsheetSkeleton): IRange[];
|
|
60
65
|
/**
|
|
61
66
|
* Safely draw fallback image, checking if it's fully loaded first.
|
|
62
67
|
* If not loaded, draw a simple gray rectangle as placeholder.
|
|
@@ -64,6 +69,7 @@ export declare class Font extends SheetExtension {
|
|
|
64
69
|
private _drawFallbackImage;
|
|
65
70
|
draw(ctx: UniverRenderingContext, parentScale: IScale, spreadsheetSkeleton: SpreadsheetSkeleton, diffRanges: IRange[], moreBoundsInfo: IDrawInfo): void;
|
|
66
71
|
_renderFontEachCell(renderFontCtx: IRenderFontContext, row: number, col: number, fontMatrix: ObjectMatrix<IFontCacheItem>, cacheValue?: IFontCacheItem): boolean;
|
|
72
|
+
private _canRenderPlainTextWithoutClip;
|
|
67
73
|
private _renderPlainTextWithoutClip;
|
|
68
74
|
private _renderImages;
|
|
69
75
|
/**
|
|
@@ -18,6 +18,7 @@ import type { UniverRenderingContext } from '../../../context';
|
|
|
18
18
|
import type { SpreadsheetSkeleton } from '../sheet.render-skeleton';
|
|
19
19
|
import { SheetExtension } from './sheet-extension';
|
|
20
20
|
export declare class Marker extends SheetExtension {
|
|
21
|
+
readonly viewportCacheReusable: boolean;
|
|
21
22
|
protected Z_INDEX: number;
|
|
22
23
|
uKey: string;
|
|
23
24
|
draw(ctx: UniverRenderingContext, parentScale: IScale, skeleton: SpreadsheetSkeleton, diffRanges: IRange[]): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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 { Disposable } from '@univerjs/core';
|
|
17
|
+
import type { IBoundRectNoAngle } from '../../../basics/vector2';
|
|
18
|
+
import type { UniverRenderingContext } from '../../../context';
|
|
19
|
+
/** Rasterize at a stable local origin, retaining the native physical resolution and antialiasing. */
|
|
20
|
+
export declare class RenderPrimitiveCache extends Disposable {
|
|
21
|
+
private readonly _maxEntries;
|
|
22
|
+
private readonly _bitmaps;
|
|
23
|
+
private _contexts;
|
|
24
|
+
private _pixels;
|
|
25
|
+
private _fontRevision;
|
|
26
|
+
private _fonts?;
|
|
27
|
+
private _textClipBound?;
|
|
28
|
+
private _textClipRepairCanvas?;
|
|
29
|
+
constructor(_maxEntries?: number);
|
|
30
|
+
draw(ctx: UniverRenderingContext, draw: () => void, textClipBound?: IBoundRectNoAngle): void;
|
|
31
|
+
clear(): void;
|
|
32
|
+
dispose(): void;
|
|
33
|
+
private _getContext;
|
|
34
|
+
private _stroke;
|
|
35
|
+
private _fillText;
|
|
36
|
+
private _trim;
|
|
37
|
+
}
|
|
@@ -23,6 +23,7 @@ export interface IRowsHeaderCfgParam {
|
|
|
23
23
|
rowsCfg?: Record<number, IARowCfg>;
|
|
24
24
|
}
|
|
25
25
|
export declare class RowHeaderLayout extends SheetExtension {
|
|
26
|
+
readonly viewportCacheReusable: boolean;
|
|
26
27
|
uKey: string;
|
|
27
28
|
Z_INDEX: number;
|
|
28
29
|
rowsCfg: Record<number, IARowCfg>;
|
|
@@ -14,9 +14,11 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { DocumentDataModel, ITable } from '@univerjs/core';
|
|
17
|
+
import type { IDocumentLayoutRenderConfig } from '../docs/document-layout-presentation';
|
|
17
18
|
import { LineBreaker } from '../docs/layout/line-breaker/line-breaker';
|
|
18
19
|
import { DocumentViewModel } from '../docs/view-model/document-view-model';
|
|
19
20
|
export declare class SheetCellDocumentViewModel extends DocumentViewModel {
|
|
21
|
+
getLayoutRenderConfig(config: IDocumentLayoutRenderConfig): IDocumentLayoutRenderConfig;
|
|
20
22
|
getParagraphWordWrap(): undefined;
|
|
21
23
|
createLineBreaker(content: string): LineBreaker;
|
|
22
24
|
protected _createChildViewModel(model: DocumentDataModel, tableSource?: Record<string, ITable>): SheetCellDocumentViewModel;
|
|
@@ -22,6 +22,9 @@ import { RenderComponent } from '../component';
|
|
|
22
22
|
export declare abstract class SheetComponent extends RenderComponent<SpreadsheetSkeleton, SHEET_EXTENSION_TYPE, IRange[]> {
|
|
23
23
|
private _skeleton?;
|
|
24
24
|
constructor(oKey: string, _skeleton?: SpreadsheetSkeleton | undefined);
|
|
25
|
+
protected _viewportCacheFontRevision: number;
|
|
26
|
+
canReuseViewportCache(): boolean;
|
|
27
|
+
onViewportCacheReuse(viewportInfo: IViewportInfo): void;
|
|
25
28
|
getSkeleton(): SpreadsheetSkeleton | undefined;
|
|
26
29
|
updateSkeleton(spreadsheetSkeleton: SpreadsheetSkeleton): void;
|
|
27
30
|
render(mainCtx: UniverRenderingContext, bounds?: IViewportInfo): this | undefined;
|
|
@@ -77,11 +77,16 @@ export declare class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
77
77
|
private _visibleRangeMap;
|
|
78
78
|
private _overflowCache;
|
|
79
79
|
private _incrementalFontRenderRanges;
|
|
80
|
+
private _preparedStyleRanges;
|
|
81
|
+
private _preparedMergeStyleRanges;
|
|
80
82
|
private _stylesCache;
|
|
81
83
|
private _clearTaskId;
|
|
82
84
|
/** A matrix to store if a (row, column) position has render cache. */
|
|
83
85
|
private _handleBgMatrix;
|
|
84
86
|
private _handleBorderMatrix;
|
|
87
|
+
private _emptyFontCache;
|
|
88
|
+
private readonly _nativeTextClipCache;
|
|
89
|
+
private readonly _plainTextVerticalOverflowByRow;
|
|
85
90
|
private _showGridlines;
|
|
86
91
|
private _gridlinesColor;
|
|
87
92
|
private _defaultGridlinesColor;
|
|
@@ -104,11 +109,15 @@ export declare class SpreadsheetSkeleton extends SheetSkeleton {
|
|
|
104
109
|
get stylesCache(): IStylesCache;
|
|
105
110
|
get overflowCache(): ObjectMatrix<IRange>;
|
|
106
111
|
get incrementalFontRenderRanges(): IRange[];
|
|
112
|
+
get nativeTextClipCache(): ObjectMatrix<boolean>;
|
|
113
|
+
/** Bound source-row checks by the current cache, without scanning retained font entries. */
|
|
114
|
+
getPlainTextVerticalOverflow(bound?: IBoundRectNoAngle): number;
|
|
107
115
|
get showGridlines(): BooleanNumber;
|
|
108
116
|
get gridlinesColor(): string | undefined;
|
|
109
117
|
get defaultGridlinesColor(): string;
|
|
110
118
|
dispose(): void;
|
|
111
119
|
setOverflowCache(value: ObjectMatrix<IRange>): void;
|
|
120
|
+
private _refreshPlainTextVerticalOverflow;
|
|
112
121
|
getFont(rowIndex: number, columnIndex: number): Nullable<IFontCacheItem>;
|
|
113
122
|
/**
|
|
114
123
|
* Get range in visible area (range in view bounds) and set into this._rowColumnSegment.
|
|
@@ -25,9 +25,18 @@ import type { SpreadsheetSkeleton } from './sheet.render-skeleton';
|
|
|
25
25
|
import { Canvas } from '../../canvas';
|
|
26
26
|
import { Documents } from '../docs/document';
|
|
27
27
|
import { SheetComponent } from './sheet-component';
|
|
28
|
+
interface IRepaintBound {
|
|
29
|
+
bound: IBoundRectNoAngle;
|
|
30
|
+
repairsMerge: boolean;
|
|
31
|
+
repairsNativeText?: boolean;
|
|
32
|
+
}
|
|
28
33
|
export declare class Spreadsheet extends SheetComponent {
|
|
29
34
|
private _allowCache;
|
|
35
|
+
viewportCacheReusable: boolean;
|
|
36
|
+
onViewportCacheReuse(viewportInfo: IViewportInfo): void;
|
|
30
37
|
private _scrollBufferCanvases;
|
|
38
|
+
private _scrollCacheStates;
|
|
39
|
+
private readonly _gridlineCache;
|
|
31
40
|
private _backgroundExtension;
|
|
32
41
|
private _borderExtension;
|
|
33
42
|
private _fontExtension;
|
|
@@ -49,7 +58,8 @@ export declare class Spreadsheet extends SheetComponent {
|
|
|
49
58
|
* @param ctx
|
|
50
59
|
* @param viewportInfo
|
|
51
60
|
*/
|
|
52
|
-
draw(ctx: UniverRenderingContext2D, viewportInfo: IViewportInfo, isMergeRepair?: boolean): void;
|
|
61
|
+
draw(ctx: UniverRenderingContext2D, viewportInfo: IViewportInfo, isMergeRepair?: boolean, textClipBound?: IBoundRectNoAngle): void;
|
|
62
|
+
private _getBorderRenderRanges;
|
|
53
63
|
addRenderFrameTimeMetricToScene(timeKey: string, val: number, scene: Scene): void;
|
|
54
64
|
addRenderTagToScene(renderKey: string, val: any, scene?: Scene): void;
|
|
55
65
|
/**
|
|
@@ -77,10 +87,19 @@ export declare class Spreadsheet extends SheetComponent {
|
|
|
77
87
|
*/
|
|
78
88
|
makeDirty(state?: boolean): this;
|
|
79
89
|
setDirtyArea(dirtyBounds: IBoundRectNoAngle[]): void;
|
|
80
|
-
renderByViewports(mainCtx: UniverRenderingContext2D,
|
|
90
|
+
renderByViewports(mainCtx: UniverRenderingContext2D, inputViewportInfo: IViewportInfo, spreadsheetSkeleton: SpreadsheetSkeleton): void;
|
|
81
91
|
private _getMergeRepairBounds;
|
|
82
92
|
private _getRepaintBounds;
|
|
83
|
-
|
|
93
|
+
private _addNativeTextClipRepairBounds;
|
|
94
|
+
private _requiresNativeFrozenEdgeRepaint;
|
|
95
|
+
private _requiresGapStripeRepaint;
|
|
96
|
+
private _requiresNativeGridlineRepaint;
|
|
97
|
+
private _requiresHorizontalResampling;
|
|
98
|
+
private _hasFractionalViewportPixels;
|
|
99
|
+
private _getScrollCacheState;
|
|
100
|
+
private _getReusableScrollCacheState;
|
|
101
|
+
private _canPaintHorizontalScrollIncrementally;
|
|
102
|
+
paintNewAreaForScrolling(viewportInfo: IViewportInfo, param: IPaintForScrolling, mergeRepairBounds?: IBoundRectNoAngle[], repaintBounds?: IRepaintBound[]): Canvas;
|
|
84
103
|
private _copyCacheForScrolling;
|
|
85
104
|
private _getScrollBufferCanvas;
|
|
86
105
|
/**
|
|
@@ -88,6 +107,7 @@ export declare class Spreadsheet extends SheetComponent {
|
|
|
88
107
|
*/
|
|
89
108
|
refreshCacheCanvas(viewportInfo: IViewportInfo, param: IPaintForRefresh): void;
|
|
90
109
|
render(mainCtx: UniverRenderingContext2D, viewportInfo: IViewportInfo): this | undefined;
|
|
110
|
+
private _canReuseStyleCache;
|
|
91
111
|
/**
|
|
92
112
|
* applyCache from cache canvas
|
|
93
113
|
* @param cacheCanvas Source Image
|
|
@@ -115,6 +135,7 @@ export declare class Spreadsheet extends SheetComponent {
|
|
|
115
135
|
* Clear the guide lines within a range in the table, to make room for merged cells and overflow.
|
|
116
136
|
*/
|
|
117
137
|
private _clearRectangle;
|
|
138
|
+
private _repairGridlineStroke;
|
|
118
139
|
/**
|
|
119
140
|
* Draw gap areas for row and column gaps.
|
|
120
141
|
* Clears gridlines in gap regions and fills with gap style.
|
|
@@ -127,3 +148,4 @@ export declare class Spreadsheet extends SheetComponent {
|
|
|
127
148
|
testShowRuler(cacheCtx: UniverRenderingContext2D, viewportInfo: IViewportInfo): void;
|
|
128
149
|
testGetRandomLightColor(): string;
|
|
129
150
|
}
|
|
151
|
+
export {};
|
package/lib/types/context.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export interface IUniverRenderingContextOptions {
|
|
|
21
21
|
export declare class UniverRenderingContext2D implements CanvasRenderingContext2D {
|
|
22
22
|
__mode: string;
|
|
23
23
|
private _transformCache;
|
|
24
|
+
private _cacheScale;
|
|
24
25
|
private _bitmapMutationId;
|
|
25
26
|
private _bitmapMutationTrackingDepth;
|
|
26
27
|
readonly canvas: HTMLCanvasElement;
|
|
@@ -104,6 +105,8 @@ export declare class UniverRenderingContext2D implements CanvasRenderingContext2
|
|
|
104
105
|
scaleX: number;
|
|
105
106
|
scaleY: number;
|
|
106
107
|
};
|
|
108
|
+
/** Reuse scale queries during drawing; transform methods still invalidate the cached matrix. */
|
|
109
|
+
withCachedScale(draw: () => void): void;
|
|
107
110
|
getContextAttributes(): CanvasRenderingContext2DSettings;
|
|
108
111
|
isPointInStroke(x: number, y: number): boolean;
|
|
109
112
|
isPointInStroke(path: Path2D, x: number, y: number): boolean;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -94,7 +94,4 @@ export * from './scroll-timer';
|
|
|
94
94
|
export { CanvasColorService, DumbCanvasColorService, ICanvasColorService } from './services/canvas-color.service';
|
|
95
95
|
export * from './shape';
|
|
96
96
|
export * from './viewport';
|
|
97
|
-
export {
|
|
98
|
-
/** @deprecated Import from '@univerjs/engine-render/worker' instead. This root export will be removed in the next release. */
|
|
99
|
-
DocumentLayoutSession, } from './worker';
|
|
100
97
|
export type { IDocumentLayoutSessionStartOptions, IDocumentLayoutStepResult } from './worker-layout';
|
package/lib/types/layer.d.ts
CHANGED
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { Disposable } from '@univerjs/core';
|
|
16
17
|
import type { IBoundRectNoAngle, IViewportInfo } from './basics/vector2';
|
|
17
18
|
import type { UniverRenderingContext } from './context';
|
|
18
19
|
import type { Scene } from './scene';
|
|
19
|
-
import { Disposable } from '@univerjs/core';
|
|
20
20
|
import { BaseObject } from './base-object';
|
|
21
21
|
export interface IScrollRenderInfo {
|
|
22
22
|
bounds: IBoundRectNoAngle;
|
|
@@ -27,6 +27,10 @@ export interface ILayerRenderOptions {
|
|
|
27
27
|
dirtyBounds?: IBoundRectNoAngle[];
|
|
28
28
|
preserveCache?: boolean;
|
|
29
29
|
viewportInfos?: Map<string, IViewportInfo>;
|
|
30
|
+
retainedViewportCache?: {
|
|
31
|
+
bottom: number;
|
|
32
|
+
viewportKeys: ReadonlySet<string>;
|
|
33
|
+
};
|
|
30
34
|
}
|
|
31
35
|
export declare function scrollAndClearCanvas(ctx: UniverRenderingContext, pixelRatio: number, scrollRenderInfos: IScrollRenderInfo[], dirtyBounds: IBoundRectNoAngle[]): void;
|
|
32
36
|
export declare class Layer extends Disposable {
|
|
@@ -36,6 +40,7 @@ export declare class Layer extends Disposable {
|
|
|
36
40
|
private _objects;
|
|
37
41
|
private _cacheCanvas;
|
|
38
42
|
private _cacheValid;
|
|
43
|
+
private _retainedCacheValid;
|
|
39
44
|
protected _dirty: boolean;
|
|
40
45
|
private _debounceDirtyFunc;
|
|
41
46
|
constructor(_scene: Scene, objects?: BaseObject[], _zIndex?: number, _allowCache?: boolean);
|
|
@@ -70,6 +75,8 @@ export declare class Layer extends Disposable {
|
|
|
70
75
|
addObjects(objects: BaseObject[]): Layer;
|
|
71
76
|
removeObjects(objects: BaseObject[] | string[]): void;
|
|
72
77
|
makeDirty(state?: boolean): this;
|
|
78
|
+
canReuseViewportCache(): boolean;
|
|
79
|
+
makeDirtyForViewportScroll(): void;
|
|
73
80
|
makeDirtyWithDebounce(state?: boolean): void;
|
|
74
81
|
isDirty(): boolean;
|
|
75
82
|
render(parentCtx?: UniverRenderingContext, isMaxLayer?: boolean, options?: ILayerRenderOptions): this;
|
package/lib/types/scene.d.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { Nullable } from '@univerjs/core';
|
|
17
|
+
import { Disposable, EventSubject } from '@univerjs/core';
|
|
17
18
|
import type { BaseObject } from './base-object';
|
|
18
19
|
import type { IDragEvent, IMouseEvent, IPointerEvent, IWheelEvent } from './basics/i-events';
|
|
19
20
|
import type { ISceneTransformState, ITransformChangeState } from './basics/interfaces';
|
|
@@ -24,7 +25,6 @@ import type { UniverRenderingContext } from './context';
|
|
|
24
25
|
import type { Engine } from './engine';
|
|
25
26
|
import type { SceneViewer } from './scene-viewer';
|
|
26
27
|
import type { Viewport } from './viewport';
|
|
27
|
-
import { Disposable, EventSubject } from '@univerjs/core';
|
|
28
28
|
import { CURSOR_TYPE, RENDER_CLASS_TYPE } from './basics/const';
|
|
29
29
|
import { DeviceType } from './basics/i-events';
|
|
30
30
|
import { Transform } from './basics/transform';
|
|
@@ -57,6 +57,10 @@ export declare class Scene extends Disposable {
|
|
|
57
57
|
private _layers;
|
|
58
58
|
private _viewports;
|
|
59
59
|
private _preserveEngineOnRender;
|
|
60
|
+
private _viewportCacheReuseKey;
|
|
61
|
+
private _viewportCacheReuseBlocked;
|
|
62
|
+
private _viewportCacheReusePending;
|
|
63
|
+
private _renderedViewportCacheKey;
|
|
60
64
|
private _hasPostRenderCanvasMutation;
|
|
61
65
|
private _scrollbarDragViewport;
|
|
62
66
|
private _isScrollbarSeeking;
|
|
@@ -86,6 +90,9 @@ export declare class Scene extends Disposable {
|
|
|
86
90
|
onDblclick$: EventSubject<IMouseEvent | IPointerEvent>;
|
|
87
91
|
onTripleClick$: EventSubject<IMouseEvent | IPointerEvent>;
|
|
88
92
|
onMouseWheel$: EventSubject<IWheelEvent>;
|
|
93
|
+
private readonly _prepareRender$;
|
|
94
|
+
/** Layout updates before scroll-cache decisions; paint on the canvas in beforeRender$ instead. */
|
|
95
|
+
readonly prepareRender$: import("rxjs").Observable<void>;
|
|
89
96
|
private _beforeRender$;
|
|
90
97
|
readonly beforeRender$: import("rxjs").Observable<Nullable<Canvas>>;
|
|
91
98
|
private _afterRender$;
|
|
@@ -131,6 +138,11 @@ export declare class Scene extends Disposable {
|
|
|
131
138
|
detachControl(): this;
|
|
132
139
|
makeDirty(state?: boolean): this;
|
|
133
140
|
makeDirtyForScrolling(): this;
|
|
141
|
+
setViewportCacheReuseKey(key: Nullable<string>): void;
|
|
142
|
+
invalidateViewportCacheReuse(): void;
|
|
143
|
+
isViewportCacheReusePending(): boolean;
|
|
144
|
+
makeDirtyForViewportScroll(viewport: Viewport): void;
|
|
145
|
+
private _getViewportCacheGeometry;
|
|
134
146
|
beginScrollbarDrag(viewport: Viewport): void;
|
|
135
147
|
updateScrollbarDrag(viewport: Viewport): void;
|
|
136
148
|
endScrollbarDrag(viewport: Viewport): void;
|
|
@@ -14,11 +14,13 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { Nullable } from '@univerjs/core';
|
|
17
|
+
import { Disposable } from '@univerjs/core';
|
|
17
18
|
import type { BaseObject } from './base-object';
|
|
18
19
|
import type { IMouseEvent, IPointerEvent } from './basics/i-events';
|
|
19
20
|
import type { ITransformerConfig } from './basics/transformer-config';
|
|
20
21
|
import type { Scene } from './scene';
|
|
21
|
-
import {
|
|
22
|
+
import { DeviceType } from './basics/i-events';
|
|
23
|
+
import { Vector2 } from './basics/vector2';
|
|
22
24
|
import { Group } from './group';
|
|
23
25
|
declare enum MoveObserverType {
|
|
24
26
|
MOVE_START = 0,
|
|
@@ -124,12 +126,16 @@ export declare class Transformer extends Disposable implements ITransformerConfi
|
|
|
124
126
|
private _cancelFocusSubscription;
|
|
125
127
|
private _transformerControlMap;
|
|
126
128
|
private _selectedObjectMap;
|
|
129
|
+
private readonly _rotationControls;
|
|
130
|
+
private readonly _rotationSides;
|
|
127
131
|
private _subscriptionObjectMap;
|
|
128
132
|
private _copperControl;
|
|
129
133
|
private _copperSelectedObject;
|
|
130
134
|
private _moveBufferSkip;
|
|
131
135
|
private _debounceClearFunc;
|
|
132
136
|
constructor(_scene: Scene, config?: ITransformerConfig);
|
|
137
|
+
/** Hit-test the actual displayed handles using canvas coordinates, including viewport edge avoidance. */
|
|
138
|
+
isPointOnControl(objectKey: string, coord: Vector2, deviceType?: DeviceType): boolean;
|
|
133
139
|
updateZeroPoint(left: number, top: number): void;
|
|
134
140
|
changeNotification(): this;
|
|
135
141
|
getSelectedObjectMap(): Map<string, BaseObject>;
|
|
@@ -148,10 +154,16 @@ export declare class Transformer extends Disposable implements ITransformerConfi
|
|
|
148
154
|
setSelectedControl(applyObject: BaseObject): void;
|
|
149
155
|
private _getConfig;
|
|
150
156
|
attachTo(applyObject: BaseObject): BaseObject;
|
|
157
|
+
private _selectOnPointerUp;
|
|
151
158
|
detachFrom(applyObject: BaseObject): BaseObject;
|
|
152
159
|
dispose(): void;
|
|
153
160
|
private _initialProps;
|
|
154
161
|
private _checkMoveBoundary;
|
|
162
|
+
/**
|
|
163
|
+
* Filters selected objects by the requested capability in their effective transformer config.
|
|
164
|
+
* Objects without that capability stay selected but do not participate in the move or resize gesture.
|
|
165
|
+
*/
|
|
166
|
+
private _getTransformObjects;
|
|
155
167
|
private _moving;
|
|
156
168
|
private _moveBufferBlocker;
|
|
157
169
|
private _anchorMoving;
|
|
@@ -200,6 +212,14 @@ export declare class Transformer extends Disposable implements ITransformerConfi
|
|
|
200
212
|
clearControlByIds(ids: string[]): void;
|
|
201
213
|
private _clearControlMap;
|
|
202
214
|
private _createControl;
|
|
215
|
+
private _createResizeControls;
|
|
216
|
+
private _createRotationControls;
|
|
217
|
+
private _updateRotationControls;
|
|
218
|
+
private _getRotationViewport;
|
|
219
|
+
private _getRotationObstacles;
|
|
220
|
+
private _updateRotationControl;
|
|
221
|
+
private _hideRotationControls;
|
|
222
|
+
private _positionRotationControls;
|
|
203
223
|
private _getTopScene;
|
|
204
224
|
activeAnObject(applyObject: BaseObject): void;
|
|
205
225
|
private _updateActiveObjectList;
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { Vector2 } from '../basics/vector2';
|
|
17
17
|
import { Rect } from './rect';
|
|
18
|
+
export declare const CONTROL_TOUCH_HIT_RADIUS = 22;
|
|
18
19
|
/** A precise mouse handle with a zoom-independent touch target. */
|
|
19
20
|
export declare class Control extends Rect {
|
|
20
21
|
getTouchHitDistance(coord: Vector2): number;
|