@idraw/core 0.3.0-beta.6 → 0.3.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/dist/esm/index.d.ts +5 -5
- package/dist/esm/lib/engine.d.ts +47 -0
- package/dist/esm/lib/helper.d.ts +30 -0
- package/dist/esm/lib/mapper.d.ts +26 -0
- package/dist/index.global.js +1128 -2215
- package/dist/index.global.min.js +1 -1
- package/package.json +6 -6
package/dist/esm/index.d.ts
CHANGED
|
@@ -20,8 +20,8 @@ export default class Core {
|
|
|
20
20
|
$draw(opts?: {
|
|
21
21
|
resourceChangeUUIDs?: string[];
|
|
22
22
|
}): void;
|
|
23
|
-
getElement(uuid: string):
|
|
24
|
-
getElementByIndex(index: number):
|
|
23
|
+
getElement(uuid: string): DataElement<keyof DataElemDesc> | null;
|
|
24
|
+
getElementByIndex(index: number): DataElement<keyof DataElemDesc> | null;
|
|
25
25
|
selectElementByIndex(index: number): void;
|
|
26
26
|
selectElement(uuid: string): void;
|
|
27
27
|
cancelElementByIndex(index: number): void;
|
|
@@ -33,7 +33,7 @@ export default class Core {
|
|
|
33
33
|
deleteElement(uuid: string): void;
|
|
34
34
|
insertElementBefore(elem: DataElementBase<keyof DataElemDesc>, beforeUUID: string): any;
|
|
35
35
|
insertElementBeforeIndex(elem: DataElementBase<keyof DataElemDesc>, index: number): any;
|
|
36
|
-
getSelectedElements(): DataElement<
|
|
36
|
+
getSelectedElements(): DataElement<keyof DataElemDesc>[];
|
|
37
37
|
insertElementAfter(elem: DataElementBase<keyof DataElemDesc>, beforeUUID: string): any;
|
|
38
38
|
insertElementAfterIndex(elem: DataElementBase<keyof DataElemDesc>, index: number): any;
|
|
39
39
|
resetSize(opts: BoardSizeOptions): void;
|
|
@@ -49,8 +49,8 @@ export default class Core {
|
|
|
49
49
|
on<T extends keyof TypeCoreEventArgMap>(key: T, callback: (p: TypeCoreEventArgMap[T]) => void): void;
|
|
50
50
|
off<T extends keyof TypeCoreEventArgMap>(key: T, callback: (p: TypeCoreEventArgMap[T]) => void): void;
|
|
51
51
|
getEngine(): Engine;
|
|
52
|
-
pointScreenToContext(p: Point):
|
|
53
|
-
pointContextToScreen(p: Point):
|
|
52
|
+
pointScreenToContext(p: Point): Point;
|
|
53
|
+
pointContextToScreen(p: Point): Point;
|
|
54
54
|
$getBoardContext(): IDrawContext;
|
|
55
55
|
$getDisplayContext2D(): CanvasRenderingContext2D;
|
|
56
56
|
$getOriginContext2D(): CanvasRenderingContext2D;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Point, InterfaceHelperPlugin, IDrawConfigStrict, IDrawData, HelperConfig } from '@idraw/types';
|
|
2
|
+
import Board from '@idraw/board';
|
|
3
|
+
import { TempData } from './engine-temp';
|
|
4
|
+
import { Helper } from './helper';
|
|
5
|
+
import { Element } from './element';
|
|
6
|
+
import { CoreEvent } from './core-event';
|
|
7
|
+
type Options = {
|
|
8
|
+
coreEvent: CoreEvent;
|
|
9
|
+
board: Board;
|
|
10
|
+
element: Element;
|
|
11
|
+
config: IDrawConfigStrict;
|
|
12
|
+
drawFeekback: () => void;
|
|
13
|
+
getDataFeekback: () => IDrawData;
|
|
14
|
+
selectElementByIndex: (index: number, opts?: {
|
|
15
|
+
useMode?: boolean;
|
|
16
|
+
}) => void;
|
|
17
|
+
emitChangeScreen: () => void;
|
|
18
|
+
emitChangeData: () => void;
|
|
19
|
+
};
|
|
20
|
+
export declare class Engine {
|
|
21
|
+
private _plugins;
|
|
22
|
+
private _opts;
|
|
23
|
+
private _mapper;
|
|
24
|
+
temp: TempData;
|
|
25
|
+
helper: Helper;
|
|
26
|
+
constructor(opts: Options);
|
|
27
|
+
addPlugin(plugin: InterfaceHelperPlugin): void;
|
|
28
|
+
getHelperConfig(): HelperConfig;
|
|
29
|
+
updateHelperConfig(opts: {
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
devicePixelRatio: number;
|
|
33
|
+
}): void;
|
|
34
|
+
init(): void;
|
|
35
|
+
private _initEvent;
|
|
36
|
+
private _handleDoubleClick;
|
|
37
|
+
_handlePoint(point: Point): void;
|
|
38
|
+
private _handleClick;
|
|
39
|
+
private _handleMoveStart;
|
|
40
|
+
private _handleMove;
|
|
41
|
+
private _dragElements;
|
|
42
|
+
private _transfromElement;
|
|
43
|
+
private _handleMoveEnd;
|
|
44
|
+
private _handleHover;
|
|
45
|
+
private _handleLeave;
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IDrawData, HelperConfig, HelperUpdateOpts, HelperWrapperControllerDirection, Point, IDrawConfigStrict } from '@idraw/types';
|
|
2
|
+
import Board from '@idraw/board';
|
|
3
|
+
export declare class Helper {
|
|
4
|
+
private _helperConfig;
|
|
5
|
+
private _coreConfig;
|
|
6
|
+
private _ctx;
|
|
7
|
+
private _board;
|
|
8
|
+
private _areaStart;
|
|
9
|
+
private _areaEnd;
|
|
10
|
+
constructor(board: Board, config: IDrawConfigStrict);
|
|
11
|
+
updateConfig(data: IDrawData, opts: HelperUpdateOpts): void;
|
|
12
|
+
getConfig(): HelperConfig;
|
|
13
|
+
getElementIndexByUUID(uuid: string): number | null;
|
|
14
|
+
isPointInElementWrapperController(p: Point, data?: IDrawData): {
|
|
15
|
+
uuid: string | null | undefined;
|
|
16
|
+
selectedControllerDirection: HelperWrapperControllerDirection | null;
|
|
17
|
+
hoverControllerDirection: HelperWrapperControllerDirection | null;
|
|
18
|
+
directIndex: number | null;
|
|
19
|
+
};
|
|
20
|
+
isPointInElementList(p: Point, data: IDrawData): boolean;
|
|
21
|
+
startSelectArea(p: Point): void;
|
|
22
|
+
changeSelectArea(p: Point): void;
|
|
23
|
+
clearSelectedArea(): void;
|
|
24
|
+
calcSelectedElements(data: IDrawData): string[];
|
|
25
|
+
private _calcSelectedArea;
|
|
26
|
+
private _updateElementIndex;
|
|
27
|
+
private _updateSelectedElementWrapper;
|
|
28
|
+
private _updateSelectedElementListWrapper;
|
|
29
|
+
private _createSelectedElementWrapper;
|
|
30
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IDrawData, Point, PointCursor } from '@idraw/types';
|
|
2
|
+
import Board from '@idraw/board';
|
|
3
|
+
import { Helper } from './helper';
|
|
4
|
+
import { Element } from './element';
|
|
5
|
+
declare const _board: unique symbol;
|
|
6
|
+
declare const _helper: unique symbol;
|
|
7
|
+
declare const _element: unique symbol;
|
|
8
|
+
declare const _opts: unique symbol;
|
|
9
|
+
type Options = {
|
|
10
|
+
board: Board;
|
|
11
|
+
element: Element;
|
|
12
|
+
helper: Helper;
|
|
13
|
+
};
|
|
14
|
+
export declare class Mapper {
|
|
15
|
+
private [_opts];
|
|
16
|
+
private [_board];
|
|
17
|
+
private [_helper];
|
|
18
|
+
private [_element];
|
|
19
|
+
constructor(opts: Options);
|
|
20
|
+
isEffectivePoint(p: Point): boolean;
|
|
21
|
+
judgePointCursor(p: Point, data: IDrawData): {
|
|
22
|
+
cursor: PointCursor;
|
|
23
|
+
elementUUID: string | null;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export {};
|