@univerjs/engine-render 0.1.6 → 0.1.8
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 +2 -2
- package/lib/es/index.js +18800 -9708
- package/lib/types/basics/const.d.ts +0 -1
- package/lib/types/basics/i-document-skeleton-cached.d.ts +2 -0
- package/lib/types/basics/index.d.ts +1 -1
- package/lib/types/basics/interfaces.d.ts +1 -8
- package/lib/types/basics/tools.d.ts +2 -6
- package/lib/types/components/docs/layout/block/paragraph/shaping.d.ts +1 -1
- package/lib/types/components/docs/layout/model/glyph.d.ts +3 -2
- package/lib/types/components/docs/layout/shaping-engine/__tests__/text-shaping.spec.d.ts +16 -0
- package/lib/types/{basics → components/docs/layout/shaping-engine}/font-cache.d.ts +22 -2
- package/lib/types/components/docs/layout/shaping-engine/font-library.d.ts +46 -0
- package/lib/types/components/docs/layout/shaping-engine/text-shaping.d.ts +21 -0
- package/lib/types/components/docs/layout/shaping-engine/utils.d.ts +9 -0
- package/lib/types/components/docs/layout/tools.d.ts +2 -6
- package/lib/types/components/sheets/sheet-skeleton.d.ts +12 -3
- package/lib/types/index.d.ts +3 -1
- package/lib/types/render-engine.d.ts +2 -2
- package/lib/types/{render-manager.service.d.ts → render-manager/render-manager.service.d.ts} +22 -23
- package/lib/types/render-manager/render-unit.d.ts +50 -0
- package/lib/types/viewport.d.ts +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +11 -10
- /package/lib/types/components/docs/layout/model/{__test__ → __tests__}/glyph.spec.d.ts +0 -0
|
@@ -156,7 +156,9 @@ export interface IDocumentSkeletonDrawing {
|
|
|
156
156
|
export interface IDocumentSkeletonFontStyle {
|
|
157
157
|
fontString: string;
|
|
158
158
|
fontSize: number;
|
|
159
|
+
originFontSize: number;
|
|
159
160
|
fontFamily: string;
|
|
161
|
+
fontCache: string;
|
|
160
162
|
}
|
|
161
163
|
export interface IDocumentSkeletonBoundingBox {
|
|
162
164
|
width: number;
|
|
@@ -17,7 +17,7 @@ export * from './cell-data';
|
|
|
17
17
|
export * from './const';
|
|
18
18
|
export * from './document-node-tools';
|
|
19
19
|
export * from './draw';
|
|
20
|
-
export * from '
|
|
20
|
+
export * from '../components/docs/layout/shaping-engine/font-cache';
|
|
21
21
|
export * from './i-document-skeleton-cached';
|
|
22
22
|
export * from './i-events';
|
|
23
23
|
export * from './interfaces';
|
|
@@ -38,13 +38,6 @@ export interface IFontLocale {
|
|
|
38
38
|
fontList: string[];
|
|
39
39
|
defaultFontSize: number;
|
|
40
40
|
}
|
|
41
|
-
export interface IMeasureTextCache {
|
|
42
|
-
fontBoundingBoxAscent: number;
|
|
43
|
-
fontBoundingBoxDescent: number;
|
|
44
|
-
actualBoundingBoxAscent: number;
|
|
45
|
-
actualBoundingBoxDescent: number;
|
|
46
|
-
width: number;
|
|
47
|
-
}
|
|
48
41
|
export interface IDocsConfig extends IReferenceSource, IDocumentLayout {
|
|
49
42
|
localeService: LocaleService;
|
|
50
43
|
documentTextStyle?: ITextStyle;
|
|
@@ -80,8 +73,8 @@ export interface IFontCreateConfig {
|
|
|
80
73
|
fontStyle: IDocumentSkeletonFontStyle;
|
|
81
74
|
textStyle: ITextStyle;
|
|
82
75
|
charSpace: number;
|
|
83
|
-
gridType?: GridType;
|
|
84
76
|
snapToGrid: BooleanNumber;
|
|
77
|
+
gridType?: GridType;
|
|
85
78
|
pageWidth?: number;
|
|
86
79
|
}
|
|
87
80
|
export interface INodeInfo {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IDocumentSkeletonFontStyle } from './i-document-skeleton-cached';
|
|
1
2
|
import { IBoundRectNoAngle } from './vector2';
|
|
2
3
|
import { IRange, IRangeWithCoord, IScale, ISelectionCell, ISelectionCellWithCoord, IStyleBase, LocaleService, Nullable } from '@univerjs/core';
|
|
3
4
|
|
|
@@ -44,12 +45,7 @@ export declare function precisionTo(num: number, accurate: number): number;
|
|
|
44
45
|
export declare function fixLineWidthByScale(num: number, scale: number): number;
|
|
45
46
|
export declare const UNIVER_GLOBAL_DEFAULT_FONT_SIZE = 11;
|
|
46
47
|
export declare const UNIVER_GLOBAL_DEFAULT_FONT_FAMILY = "Arial";
|
|
47
|
-
export declare function getFontStyleString(textStyle?: IStyleBase,
|
|
48
|
-
fontCache: string;
|
|
49
|
-
fontString: string;
|
|
50
|
-
fontSize: number;
|
|
51
|
-
fontFamily: string;
|
|
52
|
-
};
|
|
48
|
+
export declare function getFontStyleString(textStyle?: IStyleBase, _localeService?: LocaleService): IDocumentSkeletonFontStyle;
|
|
53
49
|
export declare function hasCJKText(text: string): boolean;
|
|
54
50
|
export declare function hasCJK(text: string): boolean;
|
|
55
51
|
export declare function hasCJKPunctuation(text: string): boolean;
|
|
@@ -8,4 +8,4 @@ export interface IShapedText {
|
|
|
8
8
|
text: string;
|
|
9
9
|
glyphs: IDocumentSkeletonGlyph[];
|
|
10
10
|
}
|
|
11
|
-
export declare function shaping(content: string, bodyModel: DocumentViewModel, paragraphNode: DataStreamTreeNode, sectionBreakConfig: ISectionBreakConfig, paragraphStyle: IParagraphStyle): IShapedText[];
|
|
11
|
+
export declare function shaping(content: string, bodyModel: DocumentViewModel, paragraphNode: DataStreamTreeNode, sectionBreakConfig: ISectionBreakConfig, paragraphStyle: IParagraphStyle, useOpenType?: boolean): IShapedText[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IOpenTypeGlyphInfo } from '../shaping-engine/text-shaping';
|
|
1
2
|
import { IFontCreateConfig } from '../../../../basics/interfaces';
|
|
2
3
|
import { IAdjustability, IDocumentSkeletonBullet, IDocumentSkeletonDivide, IDocumentSkeletonGlyph, GlyphType } from '../../../../basics/i-document-skeleton-cached';
|
|
3
4
|
|
|
@@ -5,9 +6,9 @@ export declare function isSpace(char: string): boolean;
|
|
|
5
6
|
export declare function isJustifiable(content: string): boolean;
|
|
6
7
|
export declare function baseAdjustability(content: string, width: number): IAdjustability;
|
|
7
8
|
export declare function createSkeletonWordGlyph(content: string, config: IFontCreateConfig, glyphWidth?: number): IDocumentSkeletonGlyph;
|
|
8
|
-
export declare function createSkeletonLetterGlyph(content: string, config: IFontCreateConfig, glyphWidth?: number): IDocumentSkeletonGlyph;
|
|
9
|
+
export declare function createSkeletonLetterGlyph(content: string, config: IFontCreateConfig, glyphWidth?: number, glyphInfo?: IOpenTypeGlyphInfo): IDocumentSkeletonGlyph;
|
|
9
10
|
export declare function createSkeletonTabGlyph(config: IFontCreateConfig, glyphWidth?: number): IDocumentSkeletonGlyph;
|
|
10
|
-
export declare function _createSkeletonWordOrLetter(glyphType: GlyphType, content: string, config: IFontCreateConfig, glyphWidth?: number): IDocumentSkeletonGlyph;
|
|
11
|
+
export declare function _createSkeletonWordOrLetter(glyphType: GlyphType, content: string, config: IFontCreateConfig, glyphWidth?: number, glyphInfo?: IOpenTypeGlyphInfo): IDocumentSkeletonGlyph;
|
|
11
12
|
export declare function createSkeletonBulletGlyph(glyph: IDocumentSkeletonGlyph, bulletSkeleton: IDocumentSkeletonBullet, charSpaceApply: number): IDocumentSkeletonGlyph;
|
|
12
13
|
export declare function setGlyphGroupLeft(glyphGroup: IDocumentSkeletonGlyph[], left?: number): void;
|
|
13
14
|
export declare function setGlyphLeft(glyph: IDocumentSkeletonGlyph, left?: number): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IDocumentSkeletonBoundingBox, IDocumentSkeletonFontStyle } from '
|
|
1
|
+
import { IOpenTypeGlyphInfo } from './text-shaping';
|
|
2
|
+
import { IDocumentSkeletonBoundingBox, IDocumentSkeletonFontStyle } from '../../../../basics/i-document-skeleton-cached';
|
|
3
3
|
import { Nullable } from '@univerjs/core';
|
|
4
4
|
|
|
5
|
+
export declare const DEFAULT_MEASURE_TEXT = "0";
|
|
6
|
+
export interface IMeasureTextCache {
|
|
7
|
+
fontBoundingBoxAscent: number;
|
|
8
|
+
fontBoundingBoxDescent: number;
|
|
9
|
+
actualBoundingBoxAscent: number;
|
|
10
|
+
actualBoundingBoxDescent: number;
|
|
11
|
+
width: number;
|
|
12
|
+
}
|
|
5
13
|
export declare class FontCache {
|
|
6
14
|
private static _getTextHeightCache;
|
|
7
15
|
private static _context;
|
|
@@ -23,6 +31,18 @@ export declare class FontCache {
|
|
|
23
31
|
height: number;
|
|
24
32
|
};
|
|
25
33
|
static getTextSize(content: string, fontStyle: IDocumentSkeletonFontStyle): IDocumentSkeletonBoundingBox;
|
|
34
|
+
static getBBoxFromGlyphInfo(glyphInfo: IOpenTypeGlyphInfo, fontStyle: IDocumentSkeletonFontStyle): {
|
|
35
|
+
width: number;
|
|
36
|
+
ba: number;
|
|
37
|
+
bd: number;
|
|
38
|
+
aba: number;
|
|
39
|
+
abd: number;
|
|
40
|
+
sp: number;
|
|
41
|
+
sbr: number;
|
|
42
|
+
spr: number;
|
|
43
|
+
sbo: number;
|
|
44
|
+
spo: number;
|
|
45
|
+
};
|
|
26
46
|
static getMeasureText(content: string, fontString: string): IMeasureTextCache;
|
|
27
47
|
private static _clearMeasureCache;
|
|
28
48
|
/**
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { IStyleBase, Nullable } from '@univerjs/core';
|
|
2
|
+
|
|
3
|
+
interface IFontData {
|
|
4
|
+
readonly family: string;
|
|
5
|
+
readonly fullName: string;
|
|
6
|
+
readonly postscriptName: string;
|
|
7
|
+
readonly style: string;
|
|
8
|
+
}
|
|
9
|
+
interface IFontWithBuffer {
|
|
10
|
+
readonly font: IFontData;
|
|
11
|
+
readonly buffer: ArrayBuffer;
|
|
12
|
+
}
|
|
13
|
+
declare enum FontStyle {
|
|
14
|
+
Normal = 0,
|
|
15
|
+
Italic = 1,
|
|
16
|
+
Oblique = 2
|
|
17
|
+
}
|
|
18
|
+
declare enum FontWeight {
|
|
19
|
+
THIN = 100,
|
|
20
|
+
EXTRALIGHT = 200,
|
|
21
|
+
LIGHT = 300,
|
|
22
|
+
REGULAR = 400,
|
|
23
|
+
MEDIUM = 500,
|
|
24
|
+
SEMIBOLD = 600,
|
|
25
|
+
BOLD = 700,
|
|
26
|
+
EXTRABOLD = 800,
|
|
27
|
+
BLACK = 900
|
|
28
|
+
}
|
|
29
|
+
interface IFontVariant {
|
|
30
|
+
style: FontStyle;
|
|
31
|
+
weight: FontWeight;
|
|
32
|
+
}
|
|
33
|
+
export interface IFontInfo {
|
|
34
|
+
family: string;
|
|
35
|
+
variant: IFontVariant;
|
|
36
|
+
}
|
|
37
|
+
declare class FontLibrary {
|
|
38
|
+
isReady: boolean;
|
|
39
|
+
private _fontBook;
|
|
40
|
+
constructor();
|
|
41
|
+
private _loadFontsToBook;
|
|
42
|
+
findBestMatchFontByStyle(style: IStyleBase): Nullable<IFontWithBuffer>;
|
|
43
|
+
getValidFontFamilies(families: string[]): string[];
|
|
44
|
+
}
|
|
45
|
+
export declare const fontLibrary: FontLibrary;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Nullable } from 'vitest';
|
|
2
|
+
import { default as Opentype } from 'opentype.js';
|
|
3
|
+
import { IDocumentBody } from '@univerjs/core';
|
|
4
|
+
|
|
5
|
+
interface IBoundingBox {
|
|
6
|
+
x1: number;
|
|
7
|
+
y1: number;
|
|
8
|
+
x2: number;
|
|
9
|
+
y2: number;
|
|
10
|
+
}
|
|
11
|
+
export interface IOpenTypeGlyphInfo {
|
|
12
|
+
char: string;
|
|
13
|
+
start: number;
|
|
14
|
+
end: number;
|
|
15
|
+
glyph: Nullable<Opentype.Glyph>;
|
|
16
|
+
font: Nullable<Opentype.Font>;
|
|
17
|
+
kerning: number;
|
|
18
|
+
boundingBox: Nullable<IBoundingBox>;
|
|
19
|
+
}
|
|
20
|
+
export declare function textShape(body: IDocumentBody): IOpenTypeGlyphInfo[];
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IDocumentBody, IStyleBase } from '@univerjs/core';
|
|
2
|
+
|
|
3
|
+
interface ITextChunk {
|
|
4
|
+
content: string;
|
|
5
|
+
style?: IStyleBase;
|
|
6
|
+
}
|
|
7
|
+
export declare function prepareParagraphBody(body: IDocumentBody, paragraphIndex: number): IDocumentBody;
|
|
8
|
+
export declare function prepareTextChunks(body: IDocumentBody): ITextChunk[];
|
|
9
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DocumentViewModel } from '../view-model/document-view-model';
|
|
2
2
|
import { DataStreamTreeNode } from '../view-model/data-stream-tree-node';
|
|
3
3
|
import { IParagraphConfig, ISectionBreakConfig } from '../../../basics/interfaces';
|
|
4
|
-
import { IDocumentSkeletonColumn, IDocumentSkeletonDivide, IDocumentSkeletonGlyph, IDocumentSkeletonLine, IDocumentSkeletonPage } from '../../../basics/i-document-skeleton-cached';
|
|
4
|
+
import { IDocumentSkeletonColumn, IDocumentSkeletonDivide, IDocumentSkeletonFontStyle, IDocumentSkeletonGlyph, IDocumentSkeletonLine, IDocumentSkeletonPage } from '../../../basics/i-document-skeleton-cached';
|
|
5
5
|
import { INumberUnit, IParagraphStyle, ITextStyle, ObjectPositionH, ObjectPositionV, BooleanNumber, GridType, SpacingRule } from '@univerjs/core';
|
|
6
6
|
|
|
7
7
|
export declare function getLastPage(pages: IDocumentSkeletonPage[]): IDocumentSkeletonPage;
|
|
@@ -54,11 +54,7 @@ export declare function getPositionHorizon(positionH: ObjectPositionH, column: I
|
|
|
54
54
|
export declare function getPositionVertical(positionV: ObjectPositionV, page: IDocumentSkeletonPage, lineTop: number, lineHeight: number, objectHeight: number, blockAnchorTop?: number, isPageBreak?: boolean): number | undefined;
|
|
55
55
|
export declare function getGlyphGroupWidth(divide: IDocumentSkeletonDivide): number;
|
|
56
56
|
interface IFontCreateConfig {
|
|
57
|
-
fontStyle:
|
|
58
|
-
fontString: string;
|
|
59
|
-
fontSize: number;
|
|
60
|
-
fontFamily: string;
|
|
61
|
-
};
|
|
57
|
+
fontStyle: IDocumentSkeletonFontStyle;
|
|
62
58
|
textStyle: ITextStyle;
|
|
63
59
|
charSpace: number;
|
|
64
60
|
gridType: GridType;
|
|
@@ -2,7 +2,7 @@ import { IStylesCache } from './interfaces';
|
|
|
2
2
|
import { Skeleton } from '../skeleton';
|
|
3
3
|
import { DocumentSkeleton } from '../docs/layout/doc-skeleton';
|
|
4
4
|
import { IBoundRectNoAngle, IViewportBound } from '../../basics/vector2';
|
|
5
|
-
import {
|
|
5
|
+
import { BooleanNumber, DocumentDataModel, HorizontalAlign, IContextService, LocaleService, ObjectMatrix, VerticalAlign, WrapStrategy, ICellData, IPaddingData, IRange, ISelectionCellWithCoord, ITextRotation, IWorksheetData, Nullable, Styles, Worksheet } from '@univerjs/core';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Obtain the height and width of a cell's text, taking into account scenarios with rotated text.
|
|
@@ -36,7 +36,11 @@ export interface IDocumentLayoutObject {
|
|
|
36
36
|
export declare const RENDER_RAW_FORMULA_KEY = "RENDER_RAW_FORMULA";
|
|
37
37
|
export declare class SpreadsheetSkeleton extends Skeleton {
|
|
38
38
|
private _worksheet;
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated avoid use `IWorksheetData` directly, use API provided by `Worksheet`, otherwise
|
|
41
|
+
* `ViewModel` will be not working.
|
|
42
|
+
*/
|
|
43
|
+
private _worksheetData;
|
|
40
44
|
private _cellData;
|
|
41
45
|
private _styles;
|
|
42
46
|
private readonly _contextService;
|
|
@@ -56,7 +60,12 @@ export declare class SpreadsheetSkeleton extends Skeleton {
|
|
|
56
60
|
private _marginTop;
|
|
57
61
|
private _marginLeft;
|
|
58
62
|
private _renderRawFormula;
|
|
59
|
-
constructor(_worksheet: Worksheet | undefined,
|
|
63
|
+
constructor(_worksheet: Worksheet | undefined,
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated avoid use `IWorksheetData` directly, use API provided by `Worksheet`, otherwise
|
|
66
|
+
* `ViewModel` will be not working.
|
|
67
|
+
*/
|
|
68
|
+
_worksheetData: IWorksheetData, _cellData: ObjectMatrix<Nullable<ICellData>>, _styles: Styles, _localeService: LocaleService, _contextService: IContextService);
|
|
60
69
|
get rowHeightAccumulation(): number[];
|
|
61
70
|
get rowTotalHeight(): number;
|
|
62
71
|
get columnWidthAccumulation(): number[];
|
package/lib/types/index.d.ts
CHANGED
|
@@ -23,7 +23,8 @@ export * from './engine';
|
|
|
23
23
|
export * from './group';
|
|
24
24
|
export * from './layer';
|
|
25
25
|
export { IRenderingEngine, UniverRenderEnginePlugin } from './render-engine';
|
|
26
|
-
export
|
|
26
|
+
export { type RenderComponentType, IRenderManagerService, RenderManagerService } from './render-manager/render-manager.service';
|
|
27
|
+
export { RenderUnit, type IRender, type IRenderControllerCtor, type IRenderController, type IRenderContext } from './render-manager/render-unit';
|
|
27
28
|
export * from './scene';
|
|
28
29
|
export * from './scene-viewer';
|
|
29
30
|
export * from './scroll-timer';
|
|
@@ -39,3 +40,4 @@ export { Documents } from './components/docs/document';
|
|
|
39
40
|
export type { IPageRenderConfig } from './components/docs/document';
|
|
40
41
|
export { DocumentSkeleton } from './components/docs/layout/doc-skeleton';
|
|
41
42
|
export { ThinEngine } from './thin-engine';
|
|
43
|
+
export { getCharSpaceApply, getNumberUnitValue } from './components/docs/layout/tools';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Engine } from './engine';
|
|
2
2
|
import { Injector } from '@wendellhu/redi';
|
|
3
|
-
import { Plugin
|
|
3
|
+
import { Plugin } from '@univerjs/core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The global rendering engine.
|
|
@@ -8,6 +8,6 @@ import { Plugin, PluginType } from '@univerjs/core';
|
|
|
8
8
|
export declare const IRenderingEngine: import('@wendellhu/redi').IdentifierDecorator<Engine>;
|
|
9
9
|
export declare class UniverRenderEnginePlugin extends Plugin {
|
|
10
10
|
readonly _injector: Injector;
|
|
11
|
-
static
|
|
11
|
+
static pluginName: string;
|
|
12
12
|
constructor(_config: undefined, _injector: Injector);
|
|
13
13
|
}
|
package/lib/types/{render-manager.service.d.ts → render-manager/render-manager.service.d.ts}
RENAMED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Engine } from '
|
|
3
|
-
import { Slide } from '
|
|
4
|
-
import { SheetComponent } from '
|
|
5
|
-
import { DocComponent } from '
|
|
6
|
-
import { BaseObject } from '
|
|
1
|
+
import { IRender, IRenderControllerCtor } from './render-unit';
|
|
2
|
+
import { Engine } from '../engine';
|
|
3
|
+
import { Slide } from '../components/slides/slide';
|
|
4
|
+
import { SheetComponent } from '../components/sheets/sheet-component';
|
|
5
|
+
import { DocComponent } from '../components/docs/doc-component';
|
|
6
|
+
import { BaseObject } from '../base-object';
|
|
7
7
|
import { Observable } from 'rxjs';
|
|
8
|
-
import {
|
|
8
|
+
import { IDisposable, Injector } from '@wendellhu/redi';
|
|
9
|
+
import { Nullable, UnitModel, UnitType, Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
9
10
|
|
|
10
|
-
export
|
|
11
|
+
export type RenderComponentType = SheetComponent | DocComponent | Slide | BaseObject;
|
|
12
|
+
export interface IRenderManagerService extends IDisposable {
|
|
11
13
|
currentRender$: Observable<Nullable<string>>;
|
|
12
14
|
createRender$: Observable<Nullable<string>>;
|
|
13
|
-
dispose(): void;
|
|
14
15
|
createRenderWithParent(unitId: string, parentUnitId: string): IRender;
|
|
15
16
|
createRender(unitId: string): IRender;
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
addRenderItem(unitId: string, item: IRender): void;
|
|
18
|
+
removeRender(unitId: string): void;
|
|
18
19
|
setCurrent(unitId: string): void;
|
|
19
20
|
getRenderById(unitId: string): Nullable<IRender>;
|
|
20
21
|
getRenderAll(): Map<string, IRender>;
|
|
@@ -23,17 +24,11 @@ export interface IRenderManagerService {
|
|
|
23
24
|
getCurrent(): Nullable<IRender>;
|
|
24
25
|
getFirst(): Nullable<IRender>;
|
|
25
26
|
has(unitId: string): boolean;
|
|
27
|
+
registerRenderControllers<T extends UnitModel>(type: UnitType, ctor: IRenderControllerCtor<T>): IDisposable;
|
|
26
28
|
}
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
engine: Engine;
|
|
31
|
-
scene: Scene;
|
|
32
|
-
mainComponent: Nullable<RenderComponentType>;
|
|
33
|
-
components: Map<string, RenderComponentType>;
|
|
34
|
-
isMainScene: boolean;
|
|
35
|
-
}
|
|
36
|
-
export declare class RenderManagerService implements IRenderManagerService {
|
|
29
|
+
export declare class RenderManagerService extends Disposable implements IRenderManagerService {
|
|
30
|
+
private readonly _injector;
|
|
31
|
+
private readonly _univerInstanceService;
|
|
37
32
|
private _defaultEngine;
|
|
38
33
|
private _currentUnitId;
|
|
39
34
|
private _renderMap;
|
|
@@ -42,14 +37,18 @@ export declare class RenderManagerService implements IRenderManagerService {
|
|
|
42
37
|
private readonly _createRender$;
|
|
43
38
|
readonly createRender$: Observable<Nullable<string>>;
|
|
44
39
|
get defaultEngine(): Engine;
|
|
40
|
+
private readonly _renderControllers;
|
|
41
|
+
constructor(_injector: Injector, _univerInstanceService: IUniverInstanceService);
|
|
45
42
|
dispose(): void;
|
|
43
|
+
registerRenderControllers(type: UnitType, ctor: IRenderControllerCtor): IDisposable;
|
|
44
|
+
private _getRenderControllersForType;
|
|
46
45
|
createRenderWithParent(unitId: string, parentUnitId: string): IRender;
|
|
47
46
|
createRenderWithEngine(unitId: string, engine: Engine): IRender;
|
|
48
47
|
create(unitId: Nullable<string>): void;
|
|
49
48
|
createRender(unitId: string): IRender;
|
|
50
49
|
private _createRender;
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
addRenderItem(unitId: string, item: IRender): void;
|
|
51
|
+
removeRender(unitId: string): void;
|
|
53
52
|
has(unitId: string): boolean;
|
|
54
53
|
setCurrent(unitId: string): void;
|
|
55
54
|
getCurrent(): IRender | undefined;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { RenderComponentType } from './render-manager.service';
|
|
2
|
+
import { Scene } from '../scene';
|
|
3
|
+
import { Engine } from '../engine';
|
|
4
|
+
import { IDisposable, Injector } from '@wendellhu/redi';
|
|
5
|
+
import { Nullable, UnitModel, UnitType, Disposable } from '@univerjs/core';
|
|
6
|
+
|
|
7
|
+
export interface IRender {
|
|
8
|
+
unitId: string;
|
|
9
|
+
engine: Engine;
|
|
10
|
+
scene: Scene;
|
|
11
|
+
mainComponent: Nullable<RenderComponentType>;
|
|
12
|
+
components: Map<string, RenderComponentType>;
|
|
13
|
+
isMainScene: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface IRenderControllerCtor<T extends UnitModel = UnitModel> {
|
|
16
|
+
new (unit: IRenderContext<T>, ...args: any[]): IRenderController;
|
|
17
|
+
}
|
|
18
|
+
export interface IRenderController extends IDisposable {
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* This object encapsulates methods or properties to render each element.
|
|
22
|
+
*/
|
|
23
|
+
export interface IRenderContext<T extends UnitModel = UnitModel> extends IRender {
|
|
24
|
+
unit: T;
|
|
25
|
+
type: UnitType;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* This class is responsible
|
|
29
|
+
*/
|
|
30
|
+
export declare class RenderUnit extends Disposable implements IRender {
|
|
31
|
+
readonly isRenderUnit: true;
|
|
32
|
+
get unitId(): string;
|
|
33
|
+
get type(): UnitType;
|
|
34
|
+
private readonly _injector;
|
|
35
|
+
private readonly _renderControllers;
|
|
36
|
+
private _renderContext;
|
|
37
|
+
set isMainScene(is: boolean);
|
|
38
|
+
get isMainScene(): boolean;
|
|
39
|
+
set engine(engine: Engine);
|
|
40
|
+
get engine(): Engine;
|
|
41
|
+
set mainComponent(component: Nullable<RenderComponentType>);
|
|
42
|
+
get mainComponent(): Nullable<RenderComponentType>;
|
|
43
|
+
set scene(scene: Scene);
|
|
44
|
+
get scene(): Scene;
|
|
45
|
+
get components(): Map<string, RenderComponentType>;
|
|
46
|
+
constructor(parentInjector: Injector, init: Pick<IRenderContext, 'engine' | 'scene' | 'isMainScene' | 'unit'>);
|
|
47
|
+
dispose(): void;
|
|
48
|
+
addRenderControllers(ctors: IRenderControllerCtor[]): void;
|
|
49
|
+
private _initControllers;
|
|
50
|
+
}
|
package/lib/types/viewport.d.ts
CHANGED
|
@@ -168,7 +168,7 @@ export declare class Viewport {
|
|
|
168
168
|
getAbsoluteVector(coord: Vector2): Vector2;
|
|
169
169
|
onMouseWheel(evt: IWheelEvent, state: EventState): void;
|
|
170
170
|
isHit(coord: Vector2): boolean | undefined;
|
|
171
|
-
pickScrollBar(coord: Vector2): import('./shape').Rect<import(
|
|
171
|
+
pickScrollBar(coord: Vector2): import('./shape').Rect<import('./shape').IRectProps> | null | undefined;
|
|
172
172
|
openClip(): void;
|
|
173
173
|
closeClip(): void;
|
|
174
174
|
dispose(): void;
|