@univerjs/engine-render 0.2.10 → 0.2.12
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/lib/cjs/index.js +3 -3
- package/lib/es/index.js +489 -322
- package/lib/types/basics/interfaces.d.ts +7 -0
- package/lib/types/basics/performance-monitor.d.ts +56 -27
- package/lib/types/basics/tools.d.ts +4 -3
- package/lib/types/components/docs/layout/line-breaker/break.d.ts +2 -1
- package/lib/types/components/docs/layout/line-breaker/enhancers/hyphen-enhancer.d.ts +1 -2
- package/lib/types/components/docs/layout/line-breaker/enhancers/link-enhancer.d.ts +15 -0
- package/lib/types/components/docs/layout/line-breaker/enhancers/utils.d.ts +18 -0
- package/lib/types/components/docs/view-model/document-view-model.d.ts +1 -1
- package/lib/types/components/sheets/extensions/background.d.ts +1 -1
- package/lib/types/components/sheets/extensions/border.d.ts +1 -1
- package/lib/types/components/sheets/extensions/custom.d.ts +1 -1
- package/lib/types/components/sheets/extensions/row-header-layout.d.ts +1 -1
- package/lib/types/components/sheets/extensions/sheet-extension.d.ts +4 -0
- package/lib/types/components/sheets/spreadsheet.d.ts +15 -7
- package/lib/types/controllers/config.schema.d.ts +20 -0
- package/lib/types/engine.d.ts +31 -10
- package/lib/types/render-engine.d.ts +5 -2
- package/lib/types/scene.d.ts +9 -3
- package/lib/types/scene.input-manager.d.ts +8 -2
- package/lib/types/scroll-timer.d.ts +4 -1
- package/lib/types/thin-scene.d.ts +8 -3
- package/lib/umd/index.js +3 -3
- package/package.json +4 -4
|
@@ -100,3 +100,10 @@ export interface INodeSearch {
|
|
|
100
100
|
export interface INodePosition extends INodeSearch {
|
|
101
101
|
isBack: boolean;
|
|
102
102
|
}
|
|
103
|
+
export interface IAfterRender$Info {
|
|
104
|
+
frameTimeMetric: Record<string, number | number[]>;
|
|
105
|
+
tags: {
|
|
106
|
+
scrolling: boolean;
|
|
107
|
+
} & Record<string, any>;
|
|
108
|
+
}
|
|
109
|
+
export type ITimeMetric = [string, number];
|
|
@@ -1,32 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { Disposable } from '@univerjs/core';
|
|
2
|
+
export declare const DEFAULT_FRAME_SAMPLE_SIZE = 60;
|
|
3
|
+
export declare const DEFAULT_FRAME_LIST_SIZE: number;
|
|
4
|
+
export interface IBasicFrameInfo {
|
|
5
|
+
FPS: number;
|
|
6
|
+
frameTime: number;
|
|
7
|
+
elapsedTime: number;
|
|
8
|
+
}
|
|
9
|
+
export interface IExtendFrameInfo extends IBasicFrameInfo {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
scrolling: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface ISummaryFrameInfo {
|
|
14
|
+
FPS: ISummaryMetric;
|
|
15
|
+
frameTime: ISummaryMetric;
|
|
16
|
+
[key: string]: ISummaryMetric;
|
|
17
|
+
}
|
|
18
|
+
export interface ISummaryMetric {
|
|
19
|
+
avg: number;
|
|
20
|
+
min: number;
|
|
21
|
+
max: number;
|
|
22
|
+
}
|
|
16
23
|
/**
|
|
17
24
|
* Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
|
|
18
25
|
*/
|
|
19
|
-
export declare class PerformanceMonitor {
|
|
26
|
+
export declare class PerformanceMonitor extends Disposable {
|
|
20
27
|
private _enabled;
|
|
21
28
|
private _rollingFrameTime;
|
|
22
29
|
private _lastFrameTimeMs;
|
|
23
30
|
/**
|
|
24
|
-
*
|
|
25
|
-
|
|
31
|
+
* Counting frame in a second.
|
|
32
|
+
*/
|
|
33
|
+
private _frameCountInLastSecond;
|
|
34
|
+
/**
|
|
35
|
+
* The millisecond value of the last second. For counting frame in a second.
|
|
36
|
+
*/
|
|
37
|
+
private _lastSecondTimeMs;
|
|
38
|
+
/**
|
|
39
|
+
* The FPS values recorded in the past 1 second.
|
|
40
|
+
*/
|
|
41
|
+
private _recFPSValueLastSecond;
|
|
42
|
+
/**
|
|
43
|
+
* @param {number} frameSampleSize The number of samples required to saturate the sliding window
|
|
26
44
|
*/
|
|
27
45
|
constructor(frameSampleSize?: number);
|
|
46
|
+
dispose(): void;
|
|
28
47
|
/**
|
|
29
|
-
* Returns the average frame time in milliseconds
|
|
48
|
+
* Returns the average frame time in milliseconds of the sliding window (or the subset of frames sampled so far)
|
|
30
49
|
*/
|
|
31
50
|
get averageFrameTime(): number;
|
|
32
51
|
/**
|
|
@@ -34,7 +53,7 @@ export declare class PerformanceMonitor {
|
|
|
34
53
|
*/
|
|
35
54
|
get averageFrameTimeVariance(): number;
|
|
36
55
|
/**
|
|
37
|
-
* Returns the frame time of the
|
|
56
|
+
* Returns the frame time of the last recent frame.
|
|
38
57
|
*/
|
|
39
58
|
get instantaneousFrameTime(): number;
|
|
40
59
|
/**
|
|
@@ -54,11 +73,13 @@ export declare class PerformanceMonitor {
|
|
|
54
73
|
*/
|
|
55
74
|
get isEnabled(): boolean;
|
|
56
75
|
/**
|
|
57
|
-
* Samples current frame
|
|
58
|
-
*
|
|
76
|
+
* Samples current frame, set averageFPS instantaneousFrameTime
|
|
77
|
+
* this method is called each frame by engine renderLoop --> endFrame.
|
|
78
|
+
* @param timestamp A timestamp in milliseconds of the current frame to compare with other frames
|
|
59
79
|
*/
|
|
60
|
-
sampleFrame(
|
|
61
|
-
|
|
80
|
+
sampleFrame(timestamp?: number): void;
|
|
81
|
+
endFrame(timestamp: number): void;
|
|
82
|
+
now(): number;
|
|
62
83
|
/**
|
|
63
84
|
* Enables contributions to the sliding window sample set
|
|
64
85
|
*/
|
|
@@ -82,12 +103,16 @@ export declare class RollingAverage {
|
|
|
82
103
|
/**
|
|
83
104
|
* Current average
|
|
84
105
|
*/
|
|
85
|
-
|
|
106
|
+
averageFrameTime: number;
|
|
86
107
|
/**
|
|
87
108
|
* Current variance
|
|
88
109
|
*/
|
|
89
110
|
variance: number;
|
|
90
111
|
protected _samples: number[];
|
|
112
|
+
/**
|
|
113
|
+
* for isStaturated
|
|
114
|
+
* max value of _sampleCount is length of _samples
|
|
115
|
+
*/
|
|
91
116
|
protected _sampleCount: number;
|
|
92
117
|
protected _pos: number;
|
|
93
118
|
protected _m2: number;
|
|
@@ -96,11 +121,15 @@ export declare class RollingAverage {
|
|
|
96
121
|
* @param length The number of samples required to saturate the sliding window
|
|
97
122
|
*/
|
|
98
123
|
constructor(length: number);
|
|
124
|
+
/**
|
|
125
|
+
* Calc average frameTime and variance.
|
|
126
|
+
*/
|
|
127
|
+
calcAverageFrameTime(): void;
|
|
99
128
|
/**
|
|
100
129
|
* Adds a sample to the sample set
|
|
101
|
-
* @param
|
|
130
|
+
* @param frameTime The sample value
|
|
102
131
|
*/
|
|
103
|
-
|
|
132
|
+
addFrameTime(frameTime: number): void;
|
|
104
133
|
/**
|
|
105
134
|
* Returns previously added values or null if outside of history or outside the sliding window domain
|
|
106
135
|
* @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
|
|
@@ -128,10 +128,11 @@ export declare function inCurrentAndAboveViewRanges(ranges: IRange[], rowIndex:
|
|
|
128
128
|
*/
|
|
129
129
|
export declare function inRowViewRanges(ranges: IRange[], rowIndex: number): boolean;
|
|
130
130
|
/**
|
|
131
|
-
*
|
|
132
|
-
* @param ranges
|
|
131
|
+
* If there is an intersection in ranges to the mainRanges, extend it to the first set of ranges.
|
|
132
|
+
* @param {IRange[]} mainRanges target ranges
|
|
133
|
+
* @param {IRange[]} ranges
|
|
133
134
|
*/
|
|
134
|
-
export declare function
|
|
135
|
+
export declare function expandRangeIfIntersects(mainRanges: IRange[], ranges: IRange[]): IRange[];
|
|
135
136
|
export declare function clampRanges(range: IRange): {
|
|
136
137
|
startRow: number;
|
|
137
138
|
startColumn: number;
|
|
@@ -3,7 +3,6 @@ import { Break } from '../break';
|
|
|
3
3
|
import { IBreakPoints, LineBreaker } from '../line-breaker';
|
|
4
4
|
import { Hyphen } from '../../hyphenation/hyphen';
|
|
5
5
|
import { Lang } from '../../hyphenation/lang';
|
|
6
|
-
export declare function isLetter(char: string): boolean;
|
|
7
6
|
export declare class LineBreakerHyphenEnhancer implements IBreakPoints {
|
|
8
7
|
private _lineBreaker;
|
|
9
8
|
private _hyphen;
|
|
@@ -15,7 +14,7 @@ export declare class LineBreakerHyphenEnhancer implements IBreakPoints {
|
|
|
15
14
|
private _word;
|
|
16
15
|
private _hyphenIndex;
|
|
17
16
|
private _hyphenSlice;
|
|
18
|
-
|
|
17
|
+
content: string;
|
|
19
18
|
constructor(_lineBreaker: LineBreaker, _hyphen: Hyphen, _lang: Lang, _doNotHyphenateCaps?: boolean);
|
|
20
19
|
nextBreakPoint(): Nullable<Break>;
|
|
21
20
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Nullable } from '@univerjs/core';
|
|
2
|
+
import { IBreakPoints, LineBreaker } from '../line-breaker';
|
|
3
|
+
import { Break } from '../break';
|
|
4
|
+
export declare class LineBreakerLinkEnhancer implements IBreakPoints {
|
|
5
|
+
private _lineBreaker;
|
|
6
|
+
private _curBreak;
|
|
7
|
+
private _nextBreak;
|
|
8
|
+
private _isInLink;
|
|
9
|
+
private _link;
|
|
10
|
+
private _index;
|
|
11
|
+
private _linkSlice;
|
|
12
|
+
content: string;
|
|
13
|
+
constructor(_lineBreaker: LineBreaker);
|
|
14
|
+
nextBreakPoint(): Nullable<Break>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 declare function isLetter(char: string): boolean;
|
|
17
|
+
export declare function getWord(str: string): string;
|
|
18
|
+
export declare function getSlicePosition(lastPos: number, hyphenSlice: string[], index: number): number;
|
|
@@ -55,7 +55,7 @@ export declare class DocumentViewModel implements IDisposable {
|
|
|
55
55
|
getCustomBlock(index: number): import('@univerjs/core').ICustomBlock | undefined;
|
|
56
56
|
getCustomBlockWithoutSetCurrentIndex(index: number): import('@univerjs/core').ICustomBlock | undefined;
|
|
57
57
|
getTable(index: number): import('@univerjs/core').ITable | undefined;
|
|
58
|
-
getCustomRangeRaw(index: number): import('@univerjs/core').ICustomRange | undefined;
|
|
58
|
+
getCustomRangeRaw(index: number): import('@univerjs/core').ICustomRange<Record<string, any>> | undefined;
|
|
59
59
|
getCustomRange(index: number): Nullable<ICustomRangeForInterceptor>;
|
|
60
60
|
getCustomDecorationRaw(index: number): import('@univerjs/core').ICustomDecoration | undefined;
|
|
61
61
|
getCustomDecoration(index: number): Nullable<ICustomDecorationForInterceptor>;
|
|
@@ -8,5 +8,5 @@ export declare class Background extends SheetExtension {
|
|
|
8
8
|
Z_INDEX: number;
|
|
9
9
|
PRINTING_Z_INDEX: number;
|
|
10
10
|
get zIndex(): number;
|
|
11
|
-
draw(ctx: UniverRenderingContext,
|
|
11
|
+
draw(ctx: UniverRenderingContext, _parentScale: IScale, spreadsheetSkeleton: SpreadsheetSkeleton, diffRanges: IRange[], { viewRanges, checkOutOfViewBound }: IDrawInfo): void;
|
|
12
12
|
}
|
|
@@ -5,6 +5,6 @@ import { SheetExtension } from './sheet-extension';
|
|
|
5
5
|
export declare class Border extends SheetExtension {
|
|
6
6
|
uKey: string;
|
|
7
7
|
Z_INDEX: number;
|
|
8
|
-
draw(ctx: UniverRenderingContext,
|
|
8
|
+
draw(ctx: UniverRenderingContext, _parentScale: IScale, spreadsheetSkeleton: SpreadsheetSkeleton, diffRanges: IRange[]): void;
|
|
9
9
|
private _getOverflowExclusion;
|
|
10
10
|
}
|
|
@@ -5,5 +5,5 @@ import { SheetExtension } from './sheet-extension';
|
|
|
5
5
|
export declare class Custom extends SheetExtension {
|
|
6
6
|
protected Z_INDEX: number;
|
|
7
7
|
uKey: string;
|
|
8
|
-
draw(ctx: UniverRenderingContext,
|
|
8
|
+
draw(ctx: UniverRenderingContext, _parentScale: IScale, skeleton: SpreadsheetSkeleton, diffRanges: IRange[] | undefined): void;
|
|
9
9
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IScale } from '@univerjs/core';
|
|
2
2
|
import { UniverRenderingContext } from '../../../context';
|
|
3
3
|
import { SpreadsheetSkeleton } from '../sheet-skeleton';
|
|
4
|
-
import { IARowCfg, IARowCfgObj, IColumnStyleCfg, IRowStyleCfg } from '../interfaces
|
|
4
|
+
import { IARowCfg, IARowCfgObj, IColumnStyleCfg, IRowStyleCfg } from '../interfaces';
|
|
5
5
|
import { SheetExtension } from './sheet-extension';
|
|
6
6
|
export interface IRowsHeaderCfgParam {
|
|
7
7
|
headerStyle?: Partial<IRowStyleCfg>;
|
|
@@ -4,6 +4,10 @@ import { SpreadsheetSkeleton } from '../sheet-skeleton';
|
|
|
4
4
|
export declare enum SHEET_EXTENSION_TYPE {
|
|
5
5
|
GRID = 0
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* for distinguish doc & slides extensions, now only used when metric performance.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SHEET_EXTENSION_PREFIX = "sheet-ext-";
|
|
7
11
|
export declare class SheetExtension extends ComponentExtension<SpreadsheetSkeleton, SHEET_EXTENSION_TYPE, IRange[]> {
|
|
8
12
|
type: SHEET_EXTENSION_TYPE;
|
|
9
13
|
/**
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { IRange } from '@univerjs/core';
|
|
2
2
|
import { IBoundRectNoAngle, IViewportInfo, Vector2 } from '../../basics/vector2';
|
|
3
3
|
import { Canvas } from '../../canvas';
|
|
4
|
-
import {
|
|
4
|
+
import { UniverRenderingContext2D } from '../../context';
|
|
5
|
+
import { Scene } from '../../scene';
|
|
5
6
|
import { Documents } from '../docs/document';
|
|
6
7
|
import { Background } from './extensions/background';
|
|
7
8
|
import { Border } from './extensions/border';
|
|
@@ -35,7 +36,14 @@ export declare class Spreadsheet extends SheetComponent {
|
|
|
35
36
|
* @param ctx
|
|
36
37
|
* @param viewportInfo
|
|
37
38
|
*/
|
|
38
|
-
draw(ctx:
|
|
39
|
+
draw(ctx: UniverRenderingContext2D, viewportInfo: IViewportInfo): void;
|
|
40
|
+
addRenderFrameTimeMetricToScene(timeKey: string, val: number, scene: Scene): void;
|
|
41
|
+
addRenderTagToScene(renderKey: string, val: any, scene?: Scene): void;
|
|
42
|
+
/**
|
|
43
|
+
* override for return type as Scene.
|
|
44
|
+
* @returns Scene
|
|
45
|
+
*/
|
|
46
|
+
getScene(): Scene;
|
|
39
47
|
isHit(coord: Vector2): boolean;
|
|
40
48
|
getNoMergeCellPositionByIndex(rowIndex: number, columnIndex: number): {
|
|
41
49
|
startY: number;
|
|
@@ -61,13 +69,13 @@ export declare class Spreadsheet extends SheetComponent {
|
|
|
61
69
|
*/
|
|
62
70
|
makeDirty(state?: boolean): this;
|
|
63
71
|
setDirtyArea(dirtyBounds: IBoundRectNoAngle[]): void;
|
|
64
|
-
renderByViewport(mainCtx:
|
|
72
|
+
renderByViewport(mainCtx: UniverRenderingContext2D, viewportInfo: IViewportInfo, spreadsheetSkeleton: SpreadsheetSkeleton): void;
|
|
65
73
|
paintNewAreaForScrolling(viewportInfo: IViewportInfo, param: IPaintForScrolling): void;
|
|
66
74
|
/**
|
|
67
75
|
* Redraw the entire viewport.
|
|
68
76
|
*/
|
|
69
77
|
refreshCacheCanvas(viewportInfo: IViewportInfo, param: IPaintForRefresh): void;
|
|
70
|
-
render(mainCtx:
|
|
78
|
+
render(mainCtx: UniverRenderingContext2D, viewportInfo: IViewportInfo): this | undefined;
|
|
71
79
|
/**
|
|
72
80
|
* applyCache from cache canvas
|
|
73
81
|
* @param cacheCanvas Source Image
|
|
@@ -81,8 +89,8 @@ export declare class Spreadsheet extends SheetComponent {
|
|
|
81
89
|
* @param dw
|
|
82
90
|
* @param dh
|
|
83
91
|
*/
|
|
84
|
-
protected _applyCache(cacheCanvas: Canvas, ctx:
|
|
85
|
-
protected _draw(ctx:
|
|
92
|
+
protected _applyCache(cacheCanvas: Canvas, ctx: UniverRenderingContext2D, sx?: number, sy?: number, sw?: number, sh?: number, dx?: number, dy?: number, dw?: number, dh?: number): void;
|
|
93
|
+
protected _draw(ctx: UniverRenderingContext2D, bounds?: IViewportInfo): void;
|
|
86
94
|
private _getAncestorSize;
|
|
87
95
|
private _getAncestorParent;
|
|
88
96
|
private _initialDefaultExtension;
|
|
@@ -98,6 +106,6 @@ export declare class Spreadsheet extends SheetComponent {
|
|
|
98
106
|
private _clearBackground;
|
|
99
107
|
sheetContentViewport(): SHEET_VIEWPORT_KEY[];
|
|
100
108
|
sheetHeaderViewport(): SHEET_VIEWPORT_KEY[];
|
|
101
|
-
testShowRuler(cacheCtx:
|
|
109
|
+
testShowRuler(cacheCtx: UniverRenderingContext2D, viewportInfo: IViewportInfo): void;
|
|
102
110
|
testGetRandomLightColor(): string;
|
|
103
111
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 declare const PLUGIN_CONFIG_KEY = "engine-render.config";
|
|
17
|
+
export declare const configSymbol: unique symbol;
|
|
18
|
+
export interface IUniverEngineRenderConfig {
|
|
19
|
+
}
|
|
20
|
+
export declare const defaultPluginConfig: IUniverEngineRenderConfig;
|
package/lib/types/engine.d.ts
CHANGED
|
@@ -1,22 +1,33 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
1
|
+
import { Observable, Subject } from 'rxjs';
|
|
2
2
|
import { CURSOR_TYPE } from './basics/const';
|
|
3
|
+
import { ITimeMetric } from './basics/interfaces';
|
|
4
|
+
import { IBasicFrameInfo } from './basics/performance-monitor';
|
|
3
5
|
import { Canvas, CanvasRenderMode } from './canvas';
|
|
4
6
|
import { Scene } from './scene';
|
|
5
7
|
import { ThinEngine } from './thin-engine';
|
|
6
8
|
export declare class Engine extends ThinEngine<Scene> {
|
|
7
9
|
renderEvenInBackground: boolean;
|
|
8
10
|
private readonly _beginFrame$;
|
|
9
|
-
readonly beginFrame$: Observable<
|
|
11
|
+
readonly beginFrame$: Observable<number>;
|
|
10
12
|
private readonly _endFrame$;
|
|
11
|
-
readonly endFrame$: Observable<
|
|
13
|
+
readonly endFrame$: Observable<IBasicFrameInfo>;
|
|
14
|
+
readonly renderFrameTimeMetric$: Subject<ITimeMetric>;
|
|
15
|
+
readonly renderFrameTags$: Subject<[string, any]>;
|
|
16
|
+
/**
|
|
17
|
+
* time when render start, for elapsedTime
|
|
18
|
+
*/
|
|
19
|
+
private _renderStartTime;
|
|
12
20
|
private _rect$;
|
|
13
21
|
get clientRect$(): Observable<void>;
|
|
14
22
|
private _container;
|
|
15
23
|
private _canvas;
|
|
16
24
|
private _renderingQueueLaunched;
|
|
17
|
-
private
|
|
25
|
+
private _renderFrameTasks;
|
|
18
26
|
private _renderFunction;
|
|
19
27
|
private _requestNewFrameHandler;
|
|
28
|
+
/**
|
|
29
|
+
* frameCount
|
|
30
|
+
*/
|
|
20
31
|
private _frameId;
|
|
21
32
|
private _usingSafari;
|
|
22
33
|
private _resizeObserver;
|
|
@@ -44,6 +55,8 @@ export declare class Engine extends ThinEngine<Scene> {
|
|
|
44
55
|
private _previousWidth;
|
|
45
56
|
private _previousHeight;
|
|
46
57
|
constructor(elemWidth?: number, elemHeight?: number, pixelRatio?: number, mode?: CanvasRenderMode);
|
|
58
|
+
_init(): void;
|
|
59
|
+
get elapsedTime(): number;
|
|
47
60
|
get width(): number;
|
|
48
61
|
get height(): number;
|
|
49
62
|
get requestNewFrameHandler(): number;
|
|
@@ -70,8 +83,10 @@ export declare class Engine extends ThinEngine<Scene> {
|
|
|
70
83
|
*/
|
|
71
84
|
resizeBySize(width: number, height: number): void;
|
|
72
85
|
dispose(): void;
|
|
86
|
+
addFunction2RenderLoop(renderFunction: () => void): void;
|
|
87
|
+
startRenderLoop(): void;
|
|
73
88
|
/**
|
|
74
|
-
* Register and execute a render loop. The engine
|
|
89
|
+
* Register and execute a render loop. The engine could manage more than one render function
|
|
75
90
|
* @param renderFunction defines the function to continuously execute
|
|
76
91
|
*/
|
|
77
92
|
runRenderLoop(renderFunction: () => void): void;
|
|
@@ -83,11 +98,11 @@ export declare class Engine extends ThinEngine<Scene> {
|
|
|
83
98
|
/**
|
|
84
99
|
* Begin a new frame
|
|
85
100
|
*/
|
|
86
|
-
|
|
101
|
+
_beginFrame(_timestamp: number): void;
|
|
87
102
|
/**
|
|
88
103
|
* End the current frame
|
|
89
104
|
*/
|
|
90
|
-
|
|
105
|
+
_endFrame(timestamp: number): void;
|
|
91
106
|
/**
|
|
92
107
|
* Gets the current framerate
|
|
93
108
|
* @returns a number representing the framerate
|
|
@@ -98,11 +113,17 @@ export declare class Engine extends ThinEngine<Scene> {
|
|
|
98
113
|
* @returns a number representing the delta time in ms
|
|
99
114
|
*/
|
|
100
115
|
getDeltaTime(): number;
|
|
101
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Exec all function in _renderFrameTasks
|
|
118
|
+
*/
|
|
119
|
+
private _renderFrame;
|
|
102
120
|
private _cancelFrame;
|
|
103
121
|
private _getHostWindow;
|
|
104
|
-
|
|
105
|
-
|
|
122
|
+
/**
|
|
123
|
+
* call itself by raf
|
|
124
|
+
* Exec all function in _renderFrameTasks in _renderFrame()
|
|
125
|
+
*/
|
|
126
|
+
private _renderFunctionCore;
|
|
106
127
|
private _handleKeyboardAction;
|
|
107
128
|
private _handlePointerAction;
|
|
108
129
|
private _handleDragAction;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { Injector, Plugin } from '@univerjs/core';
|
|
1
|
+
import { IConfigService, Injector, Plugin } from '@univerjs/core';
|
|
2
2
|
import { Engine } from './engine';
|
|
3
|
+
import { IUniverEngineRenderConfig } from './controllers/config.schema';
|
|
3
4
|
/**
|
|
4
5
|
* The global rendering engine.
|
|
5
6
|
*/
|
|
6
7
|
export declare const IRenderingEngine: import('@univerjs/core').IdentifierDecorator<Engine>;
|
|
7
8
|
export declare class UniverRenderEnginePlugin extends Plugin {
|
|
9
|
+
private readonly _config;
|
|
8
10
|
readonly _injector: Injector;
|
|
11
|
+
private readonly _configService;
|
|
9
12
|
static pluginName: string;
|
|
10
|
-
constructor(_config:
|
|
13
|
+
constructor(_config: Partial<IUniverEngineRenderConfig>, _injector: Injector, _configService: IConfigService);
|
|
11
14
|
}
|
package/lib/types/scene.d.ts
CHANGED
|
@@ -3,15 +3,15 @@ import { BaseObject } from './base-object';
|
|
|
3
3
|
import { CURSOR_TYPE } from './basics/const';
|
|
4
4
|
import { IDragEvent, IKeyboardEvent, IMouseEvent, IPointerEvent, IWheelEvent } from './basics/i-events';
|
|
5
5
|
import { ISceneTransformState } from './basics/interfaces';
|
|
6
|
+
import { ITransformerConfig } from './basics/transformer-config';
|
|
6
7
|
import { Vector2 } from './basics/vector2';
|
|
7
8
|
import { UniverRenderingContext } from './context';
|
|
8
9
|
import { Layer } from './layer';
|
|
9
|
-
import { Transformer } from './scene.transformer';
|
|
10
10
|
import { SceneViewer } from './scene-viewer';
|
|
11
|
+
import { Transformer } from './scene.transformer';
|
|
11
12
|
import { ThinEngine } from './thin-engine';
|
|
12
13
|
import { ThinScene } from './thin-scene';
|
|
13
14
|
import { Viewport } from './viewport';
|
|
14
|
-
import { ITransformerConfig } from './basics/transformer-config';
|
|
15
15
|
import { Engine } from './engine';
|
|
16
16
|
export declare class Scene extends ThinScene {
|
|
17
17
|
private _parent;
|
|
@@ -68,6 +68,7 @@ export declare class Scene extends ThinScene {
|
|
|
68
68
|
getEngine(): Nullable<Engine>;
|
|
69
69
|
getLayers(): Layer[];
|
|
70
70
|
getLayer(zIndex?: number): Layer;
|
|
71
|
+
findLayerByZIndex(zIndex?: number): Nullable<Layer>;
|
|
71
72
|
getLayerMaxZIndex(): number;
|
|
72
73
|
addLayer(...argument: Layer[]): void;
|
|
73
74
|
/**
|
|
@@ -173,7 +174,12 @@ export declare class Scene extends ThinScene {
|
|
|
173
174
|
scaleY: number;
|
|
174
175
|
};
|
|
175
176
|
dispose(): void;
|
|
176
|
-
|
|
177
|
+
/**
|
|
178
|
+
* Get the object under the pointer, if scene.event is disabled, the object is null.
|
|
179
|
+
* @param {Vector2} coord
|
|
180
|
+
* @return {Nullable<BaseObject | Scene | ThinScene>} object under the pointer
|
|
181
|
+
*/
|
|
182
|
+
pick(coord: Vector2): Nullable<BaseObject | Scene | ThinScene>;
|
|
177
183
|
triggerKeyDown(evt: IKeyboardEvent): void;
|
|
178
184
|
triggerKeyUp(evt: IKeyboardEvent): void;
|
|
179
185
|
triggerPointerUp(evt: IPointerEvent | IMouseEvent): boolean;
|
|
@@ -11,6 +11,7 @@ export declare class InputManager extends Disposable {
|
|
|
11
11
|
static TripleClickDelay: number;
|
|
12
12
|
/** If you need to check double click without raising a single click at first click, enable this flag */
|
|
13
13
|
static ExclusiveDoubleClickMode: boolean;
|
|
14
|
+
private _scene;
|
|
14
15
|
/** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
|
|
15
16
|
private _alreadyAttached;
|
|
16
17
|
private _onInput$;
|
|
@@ -28,7 +29,6 @@ export declare class InputManager extends Disposable {
|
|
|
28
29
|
private _onDragLeave;
|
|
29
30
|
private _onDragOver;
|
|
30
31
|
private _onDrop;
|
|
31
|
-
private _scene;
|
|
32
32
|
private _currentMouseEnterPicked;
|
|
33
33
|
private _startingPosition;
|
|
34
34
|
private _delayedTimeout;
|
|
@@ -48,7 +48,13 @@ export declare class InputManager extends Disposable {
|
|
|
48
48
|
* Detaches all event handlers
|
|
49
49
|
*/
|
|
50
50
|
detachControl(): void;
|
|
51
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Just call this._scene?.pick, nothing special.
|
|
53
|
+
* @param offsetX
|
|
54
|
+
* @param offsetY
|
|
55
|
+
* @returns
|
|
56
|
+
*/
|
|
57
|
+
private _getObjectAtPos;
|
|
52
58
|
private _checkDirectSceneEventTrigger;
|
|
53
59
|
/**
|
|
54
60
|
* @hidden
|
|
@@ -19,6 +19,9 @@ export declare class ScrollTimer {
|
|
|
19
19
|
private _moveY;
|
|
20
20
|
private _scrollX;
|
|
21
21
|
private _scrollY;
|
|
22
|
+
/**
|
|
23
|
+
* Custmize scroll function.
|
|
24
|
+
*/
|
|
22
25
|
private _scrollFunction;
|
|
23
26
|
constructor(_scene: Scene, _scrollTimerType?: ScrollTimerType, _padding?: IPaddingData | undefined);
|
|
24
27
|
static create(scene: any, scrollTimerType?: ScrollTimerType, padding?: IPaddingData): ScrollTimer;
|
|
@@ -27,7 +30,7 @@ export declare class ScrollTimer {
|
|
|
27
30
|
setActiveViewport(viewport: Viewport): void;
|
|
28
31
|
getActiveViewport(): any;
|
|
29
32
|
startScroll(offsetX: number, offsetY: number, targetViewport?: any): void;
|
|
30
|
-
private
|
|
33
|
+
private _autoScroll;
|
|
31
34
|
scrolling(offsetX: number, offsetY: number, scrollFunction: (x?: number, y?: number) => void): void;
|
|
32
35
|
stopScroll(): void;
|
|
33
36
|
dispose(): void;
|
|
@@ -43,14 +43,19 @@ export declare abstract class ThinScene extends Disposable {
|
|
|
43
43
|
get scaleX(): number;
|
|
44
44
|
get scaleY(): number;
|
|
45
45
|
get sceneKey(): string;
|
|
46
|
-
get
|
|
46
|
+
get objectsEvented(): boolean;
|
|
47
47
|
set transform(trans: Transform);
|
|
48
48
|
set width(num: number);
|
|
49
49
|
set height(num: number);
|
|
50
50
|
set scaleX(scaleX: number);
|
|
51
51
|
set scaleY(scaleY: number);
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
enableObjectsEvent(): void;
|
|
53
|
+
/**
|
|
54
|
+
* If scene.event is disabled, scene.pick(curosrPos) return null.
|
|
55
|
+
* Then only scene itself can response to pointer event, all objects under the scene would not.
|
|
56
|
+
* see sceneInputManager@_onPointerMove
|
|
57
|
+
*/
|
|
58
|
+
disableObjectsEvent(): void;
|
|
54
59
|
triggerKeyDown(evt: IKeyboardEvent): void;
|
|
55
60
|
triggerKeyUp(evt: IKeyboardEvent): void;
|
|
56
61
|
abstract triggerPointerUp(evt: IPointerEvent | IMouseEvent): void;
|