@netless/appliance-plugin 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +138 -0
- package/cdn/appliance-plugin.js +1 -0
- package/cdn/appliance-plugin.mjs +8639 -0
- package/cdn/style.css +1 -0
- package/dist/appliance-plugin.js +1 -0
- package/dist/appliance-plugin.mjs +8639 -0
- package/dist/collector/base.d.ts +20 -0
- package/dist/collector/collector.d.ts +53 -0
- package/dist/collector/const.d.ts +3 -0
- package/dist/collector/enum.d.ts +13 -0
- package/dist/collector/eventCollector.d.ts +29 -0
- package/dist/collector/index.d.ts +4 -0
- package/dist/collector/types.d.ts +70 -0
- package/dist/collector/utils/color.d.ts +31 -0
- package/dist/collector/utils/index.d.ts +5 -0
- package/dist/component/textEditor/index.d.ts +2 -0
- package/dist/component/textEditor/manager.d.ts +120 -0
- package/dist/component/textEditor/types.d.ts +50 -0
- package/dist/component/textEditor/utils.d.ts +3 -0
- package/dist/component/textEditor/view.d.ts +68 -0
- package/dist/core/const.d.ts +1 -0
- package/dist/core/enum.d.ts +135 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/mainEngine.d.ts +163 -0
- package/dist/core/msgEvent/activeZIndex/forMain.d.ts +12 -0
- package/dist/core/msgEvent/activeZIndex/forWorker.d.ts +8 -0
- package/dist/core/msgEvent/base.d.ts +18 -0
- package/dist/core/msgEvent/baseForWorker.d.ts +13 -0
- package/dist/core/msgEvent/copyNode/forMain.d.ts +47 -0
- package/dist/core/msgEvent/copyNode/forWorker.d.ts +8 -0
- package/dist/core/msgEvent/deleteNode/forMain.d.ts +11 -0
- package/dist/core/msgEvent/deleteNode/forWorker.d.ts +13 -0
- package/dist/core/msgEvent/forWorker.d.ts +14 -0
- package/dist/core/msgEvent/index.d.ts +15 -0
- package/dist/core/msgEvent/rotateNode/forMain.d.ts +16 -0
- package/dist/core/msgEvent/rotateNode/forWorker.d.ts +9 -0
- package/dist/core/msgEvent/scaleNode/forMain.d.ts +20 -0
- package/dist/core/msgEvent/scaleNode/forWorker.d.ts +9 -0
- package/dist/core/msgEvent/setColor/forMain.d.ts +18 -0
- package/dist/core/msgEvent/setColor/forWorker.d.ts +9 -0
- package/dist/core/msgEvent/setFont/forMain.d.ts +18 -0
- package/dist/core/msgEvent/setFont/forWorker.d.ts +9 -0
- package/dist/core/msgEvent/setLock/forMain.d.ts +12 -0
- package/dist/core/msgEvent/setLock/forWorker.d.ts +9 -0
- package/dist/core/msgEvent/setPoint/forMain.d.ts +15 -0
- package/dist/core/msgEvent/setPoint/forWorker.d.ts +9 -0
- package/dist/core/msgEvent/setShape/forMain.d.ts +18 -0
- package/dist/core/msgEvent/setShape/forWorker.d.ts +9 -0
- package/dist/core/msgEvent/setZIndex/forMain.d.ts +22 -0
- package/dist/core/msgEvent/setZIndex/forWorker.d.ts +9 -0
- package/dist/core/msgEvent/translateNode/forMain.d.ts +20 -0
- package/dist/core/msgEvent/translateNode/forWorker.d.ts +9 -0
- package/dist/core/tools/arrow.d.ts +46 -0
- package/dist/core/tools/base.d.ts +82 -0
- package/dist/core/tools/ellipse.d.ts +44 -0
- package/dist/core/tools/eraser.d.ts +41 -0
- package/dist/core/tools/image.d.ts +53 -0
- package/dist/core/tools/index.d.ts +13 -0
- package/dist/core/tools/laserPen.d.ts +42 -0
- package/dist/core/tools/pencil.d.ts +66 -0
- package/dist/core/tools/polygon.d.ts +45 -0
- package/dist/core/tools/rectangle.d.ts +46 -0
- package/dist/core/tools/selector.d.ts +83 -0
- package/dist/core/tools/speechBalloon.d.ts +49 -0
- package/dist/core/tools/star.d.ts +47 -0
- package/dist/core/tools/straight.d.ts +46 -0
- package/dist/core/tools/text.d.ts +42 -0
- package/dist/core/tools/utils.d.ts +39 -0
- package/dist/core/types.d.ts +295 -0
- package/dist/core/utils/bezier.d.ts +43 -0
- package/dist/core/utils/getSvgPathFromPoints.d.ts +10 -0
- package/dist/core/utils/index.d.ts +364 -0
- package/dist/core/utils/math.d.ts +57 -0
- package/dist/core/utils/primitives/Box2d.d.ts +100 -0
- package/dist/core/utils/primitives/Point2d.d.ts +71 -0
- package/dist/core/utils/primitives/Vec2d.d.ts +146 -0
- package/dist/core/utils/primitives/easings.d.ts +24 -0
- package/dist/core/utils/proxy.d.ts +21 -0
- package/dist/core/utils/spriteNode.d.ts +4 -0
- package/dist/core/worker/base.d.ts +103 -0
- package/dist/core/worker/fullWorker.d.ts +1 -0
- package/dist/core/worker/fullWorkerLocal.d.ts +46 -0
- package/dist/core/worker/fullWorkerService.d.ts +41 -0
- package/dist/core/worker/subWorker.d.ts +1 -0
- package/dist/core/worker/subWorkerLocal.d.ts +20 -0
- package/dist/core/worker/vNodeManager.d.ts +32 -0
- package/dist/core/worker/workerManager.d.ts +71 -0
- package/dist/cursors/index.d.ts +73 -0
- package/dist/displayer/const.d.ts +11 -0
- package/dist/displayer/cursor/index.d.ts +15 -0
- package/dist/displayer/floatBar/index.d.ts +10 -0
- package/dist/displayer/floatBtns/colors.d.ts +6 -0
- package/dist/displayer/floatBtns/del.d.ts +6 -0
- package/dist/displayer/floatBtns/duplicate.d.ts +5 -0
- package/dist/displayer/floatBtns/fontSize.d.ts +4 -0
- package/dist/displayer/floatBtns/fontStyle.d.ts +4 -0
- package/dist/displayer/floatBtns/index.d.ts +11 -0
- package/dist/displayer/floatBtns/layer.d.ts +3 -0
- package/dist/displayer/floatBtns/lock.d.ts +7 -0
- package/dist/displayer/floatBtns/shapeOpt.d.ts +3 -0
- package/dist/displayer/highlightBox/index.d.ts +5 -0
- package/dist/displayer/icons/index.d.ts +4 -0
- package/dist/displayer/resizable/index.d.ts +16 -0
- package/dist/displayer/rotate/index.d.ts +4 -0
- package/dist/displayer/types.d.ts +51 -0
- package/dist/hotkey/index.d.ts +51 -0
- package/dist/index.d.ts +1 -0
- package/dist/members/index.d.ts +15 -0
- package/dist/plugin/applianceMultiPlugin.d.ts +24 -0
- package/dist/plugin/applianceSinglePlugin.d.ts +28 -0
- package/dist/plugin/baseApplianceManager.d.ts +82 -0
- package/dist/plugin/baseViewContainerManager.d.ts +174 -0
- package/dist/plugin/displayerView.d.ts +55 -0
- package/dist/plugin/external.d.ts +2 -0
- package/dist/plugin/index.d.ts +6 -0
- package/dist/plugin/multi/applianceMultiManager.d.ts +14 -0
- package/dist/plugin/multi/containerManager.d.ts +24 -0
- package/dist/plugin/multi/displayer/appViewDisplayerManager.d.ts +24 -0
- package/dist/plugin/multi/displayer/mainViewDisplayerManager.d.ts +25 -0
- package/dist/plugin/single/applianceDisplayer.d.ts +16 -0
- package/dist/plugin/single/applianceSingleManager.d.ts +13 -0
- package/dist/plugin/single/containerManager.d.ts +11 -0
- package/dist/plugin/single/displayer/mainViewDisplayerManager.d.ts +25 -0
- package/dist/plugin/types.d.ts +310 -0
- package/dist/plugin/utils.d.ts +6 -0
- package/dist/style.css +1 -0
- package/dist/undo/index.d.ts +70 -0
- package/package.json +59 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TextOptions } from "../../component/textEditor";
|
|
3
|
+
export declare const FloatBtns: React.MemoExoticComponent<(props: {
|
|
4
|
+
position?: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
};
|
|
8
|
+
textOpt?: TextOptions;
|
|
9
|
+
workIds?: string[];
|
|
10
|
+
noLayer?: boolean;
|
|
11
|
+
}) => React.JSX.Element>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare const HighlightBox: () => React.JSX.Element;
|
|
3
|
+
export declare const HighlightTwoBox: () => React.JSX.Element;
|
|
4
|
+
export declare const HighlightFourBox: () => React.JSX.Element;
|
|
5
|
+
export declare const LockedBox: () => React.JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare const ResizableBox: (props: {
|
|
3
|
+
className: string;
|
|
4
|
+
}) => React.JSX.Element;
|
|
5
|
+
export declare const ResizableTwoBtn: (props: {
|
|
6
|
+
id: string;
|
|
7
|
+
pos: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
};
|
|
11
|
+
pointMap: Map<string, [number, number][]>;
|
|
12
|
+
type: 'start' | 'end';
|
|
13
|
+
}) => React.JSX.Element;
|
|
14
|
+
export declare const ResizableTwoBox: (props: {
|
|
15
|
+
className: string;
|
|
16
|
+
}) => React.JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TextOptions } from "../component/textEditor";
|
|
3
|
+
import { EScaleType, EToolsKey } from "../core";
|
|
4
|
+
import { SpeechBalloonPlacement } from "../plugin/types";
|
|
5
|
+
export type Color = [number, number, number];
|
|
6
|
+
export type ShowFloatBarMsgValue = {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
w: number;
|
|
10
|
+
h: number;
|
|
11
|
+
padding?: number;
|
|
12
|
+
selectorColor?: string;
|
|
13
|
+
translate?: [number, number];
|
|
14
|
+
selectIds?: string[];
|
|
15
|
+
canvasWidth?: number;
|
|
16
|
+
canvasHeight?: number;
|
|
17
|
+
strokeColor?: string;
|
|
18
|
+
fillColor?: string;
|
|
19
|
+
thickness?: number;
|
|
20
|
+
lineDash?: number[];
|
|
21
|
+
canTextEdit?: boolean;
|
|
22
|
+
textOpt?: TextOptions;
|
|
23
|
+
scaleType?: EScaleType;
|
|
24
|
+
canRotate?: boolean;
|
|
25
|
+
canLock?: boolean;
|
|
26
|
+
isLocked?: boolean;
|
|
27
|
+
points?: [number, number][];
|
|
28
|
+
shapeOpt?: ShapeOptType;
|
|
29
|
+
toolsTypes?: Array<EToolsKey>;
|
|
30
|
+
};
|
|
31
|
+
export type SubButProps = {
|
|
32
|
+
open: boolean;
|
|
33
|
+
floatBarRef?: React.RefObject<HTMLDivElement>;
|
|
34
|
+
style?: React.CSSProperties;
|
|
35
|
+
setOpen: (bol: boolean) => void;
|
|
36
|
+
};
|
|
37
|
+
export type TextButProps = SubButProps & {
|
|
38
|
+
textOpt?: TextOptions;
|
|
39
|
+
workIds?: string[];
|
|
40
|
+
};
|
|
41
|
+
export type ShapeOptType = {
|
|
42
|
+
placement?: SpeechBalloonPlacement;
|
|
43
|
+
vertices?: number;
|
|
44
|
+
innerVerticeStep?: number;
|
|
45
|
+
innerRatio?: number;
|
|
46
|
+
};
|
|
47
|
+
export type ShapeOptButProps = SubButProps & {
|
|
48
|
+
toolsTypes?: Array<EToolsKey>;
|
|
49
|
+
shapeOpt?: ShapeOptType;
|
|
50
|
+
workIds?: string[];
|
|
51
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { HotKeys, BaseSubWorkModuleProps } from "../plugin/types";
|
|
2
|
+
import { BaseApplianceManager } from "../plugin/baseApplianceManager";
|
|
3
|
+
import type EventEmitter2 from "eventemitter2";
|
|
4
|
+
import { Collector } from "../collector";
|
|
5
|
+
import { MasterControlForWorker } from "../core/mainEngine";
|
|
6
|
+
export type HotKeyChecker = (event: HotKeyEvent, kind: KeyboardKind) => boolean;
|
|
7
|
+
export type HotKeyEvent = {
|
|
8
|
+
readonly nativeEvent?: KeyboardEvent;
|
|
9
|
+
readonly kind: "KeyDown" | "KeyUp";
|
|
10
|
+
readonly key: string;
|
|
11
|
+
readonly altKey: boolean;
|
|
12
|
+
readonly ctrlKey: boolean;
|
|
13
|
+
readonly shiftKey: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare enum KeyboardKind {
|
|
16
|
+
Mac = "mac",
|
|
17
|
+
Windows = "windows"
|
|
18
|
+
}
|
|
19
|
+
export type HotKeyCheckerNode = {
|
|
20
|
+
readonly kind: keyof HotKeys;
|
|
21
|
+
readonly checker: HotKeyChecker;
|
|
22
|
+
};
|
|
23
|
+
export interface HotkeyManager {
|
|
24
|
+
readonly internalMsgEmitter: EventEmitter2;
|
|
25
|
+
readonly control: BaseApplianceManager;
|
|
26
|
+
readonly roomHotkeyCheckers: HotKeyCheckerNode[];
|
|
27
|
+
onActiveHotkey(hotKey: keyof HotKeys): void;
|
|
28
|
+
onSelfActiveHotkey(hotKey: keyof HotKeys): void;
|
|
29
|
+
colloctHotkey(e: KeyboardEvent): void;
|
|
30
|
+
}
|
|
31
|
+
export declare class HotkeyManagerImpl implements HotkeyManager {
|
|
32
|
+
internalMsgEmitter: EventEmitter2;
|
|
33
|
+
control: BaseApplianceManager;
|
|
34
|
+
roomHotkeyCheckers: HotKeyCheckerNode[];
|
|
35
|
+
private tmpCopyStore;
|
|
36
|
+
private tmpCopyCoordInfo?;
|
|
37
|
+
constructor(props: BaseSubWorkModuleProps);
|
|
38
|
+
get isUseSelf(): boolean;
|
|
39
|
+
get isSelector(): boolean;
|
|
40
|
+
get collector(): Collector | undefined;
|
|
41
|
+
get mainEngine(): MasterControlForWorker | undefined;
|
|
42
|
+
get keyboardKind(): KeyboardKind;
|
|
43
|
+
private getEventKey;
|
|
44
|
+
onActiveHotkey(hotKey: keyof HotKeys): void;
|
|
45
|
+
colloctHotkey(e: KeyboardEvent): void;
|
|
46
|
+
onSelfActiveHotkey(hotKey: keyof HotKeys): void;
|
|
47
|
+
private checkHotkey;
|
|
48
|
+
private copySelectorToTemp;
|
|
49
|
+
private pasteTempToFocusView;
|
|
50
|
+
private setMemberState;
|
|
51
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./plugin";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RoomMember } from "../plugin/types";
|
|
2
|
+
export type MemberDiff = {
|
|
3
|
+
online: string[];
|
|
4
|
+
offline: string[];
|
|
5
|
+
};
|
|
6
|
+
export declare class RoomMemberManager {
|
|
7
|
+
private roomMembers;
|
|
8
|
+
private onChangeHooks;
|
|
9
|
+
setRoomMembers(roomMembers: readonly RoomMember[]): void;
|
|
10
|
+
private executChangeUidHook;
|
|
11
|
+
getRoomMember(uid: string): RoomMember | undefined;
|
|
12
|
+
isOnLine(uid: string): boolean;
|
|
13
|
+
onUidChangeHook(callBack: (diff: MemberDiff) => void): void;
|
|
14
|
+
destroy(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { InvisiblePlugin } from "./external";
|
|
2
|
+
import { Room, Displayer, AppliancePluginAttributes, AppliancePluginOptions, AppliancePluginInstance, Logger, ApplianceAdaptor } from "./types";
|
|
3
|
+
import type { WindowManager } from "./multi/applianceMultiManager";
|
|
4
|
+
import { ApplianceMultiManager } from "./multi/applianceMultiManager";
|
|
5
|
+
/**
|
|
6
|
+
* 多窗口教具
|
|
7
|
+
*/
|
|
8
|
+
export declare class ApplianceMultiPlugin extends InvisiblePlugin<AppliancePluginAttributes, any> {
|
|
9
|
+
static readonly kind: string;
|
|
10
|
+
static currentManager?: ApplianceMultiManager;
|
|
11
|
+
static logger: Logger;
|
|
12
|
+
static options: AppliancePluginOptions;
|
|
13
|
+
static getInstance(remake: WindowManager, adaptor?: ApplianceAdaptor): Promise<AppliancePluginInstance>;
|
|
14
|
+
static onCreate(plugin: InvisiblePlugin<AppliancePluginAttributes, any>): void;
|
|
15
|
+
static createApplianceMultiPlugin(d: Room, kind: string): Promise<ApplianceMultiPlugin>;
|
|
16
|
+
static createCurrentManager: (remake: WindowManager, options: AppliancePluginOptions, plugin: ApplianceMultiPlugin) => void;
|
|
17
|
+
private get isReplay();
|
|
18
|
+
private get callbackName();
|
|
19
|
+
init(displayer: Displayer): void;
|
|
20
|
+
private onPhaseChanged;
|
|
21
|
+
private updateRoomWritable;
|
|
22
|
+
private roomStateChangeListener;
|
|
23
|
+
destroy(): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { InvisiblePlugin } from "./external";
|
|
2
|
+
import { CursorAdapter, Room, AppliancePluginAttributes, AppliancePluginOptions, AppliancePluginInstance, Logger, ApplianceAdaptor, Displayer } from "./types";
|
|
3
|
+
import { ApplianceSingleManager } from "./single/applianceSingleManager";
|
|
4
|
+
/**
|
|
5
|
+
* 单白板教具
|
|
6
|
+
*/
|
|
7
|
+
export declare class ApplianceSinglePlugin extends InvisiblePlugin<AppliancePluginAttributes, any> {
|
|
8
|
+
static readonly kind: string;
|
|
9
|
+
static cursorAdapter?: CursorAdapter;
|
|
10
|
+
static currentManager?: ApplianceSingleManager;
|
|
11
|
+
static logger: Logger;
|
|
12
|
+
static options: AppliancePluginOptions;
|
|
13
|
+
static getInstance(remake: Displayer, adaptor?: ApplianceAdaptor): Promise<AppliancePluginInstance>;
|
|
14
|
+
static onCreate(plugin: InvisiblePlugin<AppliancePluginAttributes, any>): void;
|
|
15
|
+
static createAppliancePlugin(d: Room, kind: string): Promise<ApplianceSinglePlugin>;
|
|
16
|
+
static createCurrentManager: (displayer: Displayer, options: AppliancePluginOptions, plugin?: ApplianceSinglePlugin) => void;
|
|
17
|
+
/**
|
|
18
|
+
* 房间实例化时,将当前实例对displayer外部API的添加内部处理逻辑;
|
|
19
|
+
* @param displayer
|
|
20
|
+
*/
|
|
21
|
+
static effectInstance(): void;
|
|
22
|
+
private get isReplay();
|
|
23
|
+
private get callbackName();
|
|
24
|
+
init(displayer: Displayer): void;
|
|
25
|
+
private updateRoomWritable;
|
|
26
|
+
private roomStateChangeListener;
|
|
27
|
+
destroy(): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import EventEmitter2 from "eventemitter2";
|
|
3
|
+
import { MemberState, AppliancePluginLike, AppliancePluginOptions } from "./types";
|
|
4
|
+
import { Collector } from "../collector";
|
|
5
|
+
import { RoomMemberManager } from "../members";
|
|
6
|
+
import { TextEditorManager } from "../component/textEditor";
|
|
7
|
+
import type { Camera, Displayer, DisplayerCallbacks, Player, Rectangle, Room, RoomMember } from "./types";
|
|
8
|
+
import { CursorManager } from "../cursors";
|
|
9
|
+
import { ViewContainerManager } from "./baseViewContainerManager";
|
|
10
|
+
import { MasterControlForWorker } from "../core/mainEngine";
|
|
11
|
+
import { EToolsKey } from "../core/enum";
|
|
12
|
+
import { BaseShapeOptions } from "../core/tools/base";
|
|
13
|
+
import { ICameraOpt } from "../core/types";
|
|
14
|
+
import { HotkeyManager } from "../hotkey";
|
|
15
|
+
export interface BaseApplianceManagerProps {
|
|
16
|
+
displayer: Displayer<DisplayerCallbacks>;
|
|
17
|
+
plugin?: AppliancePluginLike;
|
|
18
|
+
options?: AppliancePluginOptions;
|
|
19
|
+
}
|
|
20
|
+
/** 插件管理器 */
|
|
21
|
+
export declare abstract class BaseApplianceManager {
|
|
22
|
+
static InternalMsgEmitter: EventEmitter2;
|
|
23
|
+
plugin?: AppliancePluginLike;
|
|
24
|
+
room?: Room;
|
|
25
|
+
play?: Player;
|
|
26
|
+
collector?: Collector;
|
|
27
|
+
hasSwitchToSelectorEffect?: boolean;
|
|
28
|
+
snapshootStateMap?: Map<string, unknown>;
|
|
29
|
+
effectResolve?: (value: boolean) => void;
|
|
30
|
+
readonly hotkeyManager: HotkeyManager;
|
|
31
|
+
readonly pluginOptions?: AppliancePluginOptions;
|
|
32
|
+
readonly roomMember: RoomMemberManager;
|
|
33
|
+
readonly cursor: CursorManager;
|
|
34
|
+
readonly textEditorManager: TextEditorManager;
|
|
35
|
+
readonly worker: MasterControlForWorker;
|
|
36
|
+
abstract readonly viewContainerManager: ViewContainerManager;
|
|
37
|
+
constructor(params: BaseApplianceManagerProps);
|
|
38
|
+
bindPlugin(plugin: AppliancePluginLike): void;
|
|
39
|
+
/** 激活 plugin */
|
|
40
|
+
abstract activePlugin(): void;
|
|
41
|
+
/** 初始化 */
|
|
42
|
+
abstract init(): void;
|
|
43
|
+
/** 激活worker */
|
|
44
|
+
abstract activeWorker(): void;
|
|
45
|
+
/** 销毁 */
|
|
46
|
+
destroy(): void;
|
|
47
|
+
/** 清空当前获焦路径下的所有内容 */
|
|
48
|
+
cleanCurrentScene(): void;
|
|
49
|
+
/** 监听读写状态变更 */
|
|
50
|
+
onWritableChange(isWritable: boolean): void;
|
|
51
|
+
/** 监听路径变化 */
|
|
52
|
+
onSceneChange: (scenePath: string, viewId: string) => Promise<void>;
|
|
53
|
+
/** 监听房间成员变化 */
|
|
54
|
+
onRoomMembersChange: (roomMembers: readonly RoomMember[]) => void;
|
|
55
|
+
/** 监听房间教具变更 */
|
|
56
|
+
onMemberChange: import("lodash").DebouncedFunc<(memberState: MemberState) => void>;
|
|
57
|
+
/** 获取当前工具key */
|
|
58
|
+
protected getToolsKey(memberState: MemberState): EToolsKey.Pencil | EToolsKey.Eraser | EToolsKey.Selector | EToolsKey.Clicker | EToolsKey.Arrow | EToolsKey.LaserPen | EToolsKey.Text | EToolsKey.Straight | EToolsKey.Rectangle | EToolsKey.Ellipse | EToolsKey.Star | EToolsKey.Polygon | EToolsKey.SpeechBalloon;
|
|
59
|
+
/** 获取当前工具默认配置 */
|
|
60
|
+
protected getToolsOpt(toolsKey: EToolsKey, memberState: MemberState): {
|
|
61
|
+
toolsType: EToolsKey;
|
|
62
|
+
toolsOpt: BaseShapeOptions;
|
|
63
|
+
};
|
|
64
|
+
/** 激活当前view容器*/
|
|
65
|
+
protected effectViewContainer(toolsKey: EToolsKey): void;
|
|
66
|
+
internalSceneChange: (viewId: string, scenePath: string) => void;
|
|
67
|
+
internalCameraChange: (viewId: string, cameraOpt: ICameraOpt) => void;
|
|
68
|
+
/** 异步获取指定路径下绘制内容的区域大小 */
|
|
69
|
+
getBoundingRect(scenePath: string): Promise<Rectangle | undefined>;
|
|
70
|
+
/** 异步获取指定路径下的的快照并绘制到指定的画布上 */
|
|
71
|
+
screenshotToCanvas(context: CanvasRenderingContext2D, scenePath: string, width?: number, height?: number, camera?: Camera, originX?: number, originY?: number): Promise<void>;
|
|
72
|
+
/** 异步获取指定路径下的缩略图 */
|
|
73
|
+
scenePreview(scenePath: string, img: HTMLImageElement): Promise<void>;
|
|
74
|
+
setOriginMemberState(): void;
|
|
75
|
+
/** 切换到选择工具 */
|
|
76
|
+
switchToSelector(): void;
|
|
77
|
+
/** 开始执行副作用 */
|
|
78
|
+
runEffectWork(callback?: () => void): Promise<void>;
|
|
79
|
+
setSnapshootData(): void;
|
|
80
|
+
getSnapshootData(key: string): unknown;
|
|
81
|
+
clearSnapshootData(): void;
|
|
82
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/// <reference types="lodash" />
|
|
3
|
+
import type EventEmitter2 from "eventemitter2";
|
|
4
|
+
import { ICameraOpt, ILayerOptionType, IMainMessageRenderData, IOffscreenCanvasOptionType } from "../core/types";
|
|
5
|
+
import { BaseSubWorkModuleProps, ApplianceManagerLike } from "./types";
|
|
6
|
+
import type { CameraState, View } from "./types";
|
|
7
|
+
import { ShowFloatBarMsgValue } from "../displayer/types";
|
|
8
|
+
import { UndoRedoMethod } from "../undo";
|
|
9
|
+
import { BaseViewDisplayer } from "./displayerView";
|
|
10
|
+
export interface ViewInfo {
|
|
11
|
+
id: string;
|
|
12
|
+
focusScenePath: string;
|
|
13
|
+
displayer: MainViewDisplayerManager | AppViewDisplayerManager;
|
|
14
|
+
container?: HTMLDivElement;
|
|
15
|
+
cameraOpt?: ICameraOpt;
|
|
16
|
+
viewData?: View;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
19
|
+
/** view容器管理器抽象 */
|
|
20
|
+
export declare abstract class ViewContainerManager {
|
|
21
|
+
static defaultCameraOpt: Pick<ICameraOpt, 'centerX' | 'centerY' | 'scale'>;
|
|
22
|
+
static defaultScreenCanvasOpt: Pick<IOffscreenCanvasOptionType, 'autoRender' | 'contextType'>;
|
|
23
|
+
static defaultLayerOpt: Pick<ILayerOptionType, 'offscreen' | 'handleEvent' | 'depth'>;
|
|
24
|
+
internalMsgEmitter: EventEmitter2;
|
|
25
|
+
control: ApplianceManagerLike;
|
|
26
|
+
abstract focuedViewId?: string;
|
|
27
|
+
abstract focuedView?: ViewInfo;
|
|
28
|
+
mainView?: ViewInfo;
|
|
29
|
+
appViews: Map<string, ViewInfo>;
|
|
30
|
+
constructor(props: BaseSubWorkModuleProps);
|
|
31
|
+
undoTickerStart(id: number, viewId: string): void;
|
|
32
|
+
undoTickerEnd(id: number, viewId: string, isSync?: boolean): void;
|
|
33
|
+
addExcludeIds(ids: string[], viewId: string): void;
|
|
34
|
+
undo(): number;
|
|
35
|
+
redo(): number;
|
|
36
|
+
protected validator(target: ViewInfo, key: string, value: any): void;
|
|
37
|
+
abstract mountView(viewIde: string): void;
|
|
38
|
+
destroyAppView(viewId: string, justLocal?: boolean): void;
|
|
39
|
+
createMianView(originMainView: ViewInfo): void;
|
|
40
|
+
createAppView(originAppView: ViewInfo): void;
|
|
41
|
+
isAppView(viewId: string): boolean;
|
|
42
|
+
getView(viewId: string): ViewInfo | undefined;
|
|
43
|
+
getCurScenePath(viewId: string): string | undefined;
|
|
44
|
+
getAllViews(): (ViewInfo | undefined)[];
|
|
45
|
+
setViewScenePath(viewId: string, scenePath: string): void;
|
|
46
|
+
setViewData(viewId: string, viewData: View): void;
|
|
47
|
+
setFocuedViewId(viewId: string): void;
|
|
48
|
+
setViewFocusScenePath(viewId: string, scenePath: string): void;
|
|
49
|
+
/** 销毁 */
|
|
50
|
+
destroy(): void;
|
|
51
|
+
setFocuedViewCameraOpt(cameraState: CameraState): void;
|
|
52
|
+
/** view中心点坐标转换成页面原始坐标 */
|
|
53
|
+
transformToOriginPoint(p: [number, number], viewId: string): [number, number];
|
|
54
|
+
/** 页面坐标转换成view中心点坐标 */
|
|
55
|
+
transformToScenePoint(p: [number, number], viewId: string): [number, number];
|
|
56
|
+
/** 绘制view */
|
|
57
|
+
render(renderData: IMainMessageRenderData[]): void;
|
|
58
|
+
/** 是否绘制浮动选框 */
|
|
59
|
+
showFloatBar(viewId: string, isShow: boolean, opt?: Partial<ShowFloatBarMsgValue>): void;
|
|
60
|
+
/** 激活浮动选框 */
|
|
61
|
+
activeFloatBar(viewId: string): void;
|
|
62
|
+
/** 销毁浮动选框 */
|
|
63
|
+
unActiveFloatBar(viewId: string): void;
|
|
64
|
+
/** 激活刷新文字编辑器 */
|
|
65
|
+
setActiveTextEditor(viewId: string, activeTextId?: string): void;
|
|
66
|
+
}
|
|
67
|
+
/** appView容器管理器抽象 */
|
|
68
|
+
export declare abstract class AppViewDisplayerManager {
|
|
69
|
+
viewId: string;
|
|
70
|
+
abstract dpr: number;
|
|
71
|
+
abstract width: number;
|
|
72
|
+
abstract height: number;
|
|
73
|
+
readonly control: ApplianceManagerLike;
|
|
74
|
+
readonly internalMsgEmitter: EventEmitter2;
|
|
75
|
+
readonly commiter: UndoRedoMethod;
|
|
76
|
+
abstract vDom?: BaseViewDisplayer;
|
|
77
|
+
abstract eventTragetElement?: HTMLDivElement;
|
|
78
|
+
abstract canvasServiceFloatRef: React.RefObject<HTMLCanvasElement>;
|
|
79
|
+
abstract canvasFloatRef: React.RefObject<HTMLCanvasElement>;
|
|
80
|
+
abstract canvasBgRef: React.RefObject<HTMLCanvasElement>;
|
|
81
|
+
abstract floatBarRef: React.RefObject<HTMLDivElement>;
|
|
82
|
+
abstract floatBarCanvasRef: React.RefObject<HTMLCanvasElement>;
|
|
83
|
+
abstract containerOffset: {
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
};
|
|
87
|
+
private cachePoint?;
|
|
88
|
+
private cacheCursorPoint?;
|
|
89
|
+
private active;
|
|
90
|
+
constructor(viewId: string, control: ApplianceManagerLike, internalMsgEmitter: EventEmitter2);
|
|
91
|
+
abstract setCanvassStyle(): void;
|
|
92
|
+
bindToolsClass(): void;
|
|
93
|
+
mountView(): void;
|
|
94
|
+
reflashContainerOffset(): void;
|
|
95
|
+
updateSize(): void;
|
|
96
|
+
setViewId(viewId: string): void;
|
|
97
|
+
destroy(): void;
|
|
98
|
+
getPoint(e: any): [number, number] | undefined;
|
|
99
|
+
setActive(bol: boolean): void;
|
|
100
|
+
stopEventHandler(): Promise<void>;
|
|
101
|
+
private getTranslate;
|
|
102
|
+
protected getContainerOffset(eventTraget: HTMLDivElement, offset: {
|
|
103
|
+
x: number;
|
|
104
|
+
y: number;
|
|
105
|
+
}): {
|
|
106
|
+
x: any;
|
|
107
|
+
y: any;
|
|
108
|
+
};
|
|
109
|
+
protected mousedown: (e: MouseEvent) => void;
|
|
110
|
+
protected mousemove: (e: MouseEvent) => void;
|
|
111
|
+
protected mouseup: (e: MouseEvent) => void;
|
|
112
|
+
protected touchstart: (e: TouchEvent) => void;
|
|
113
|
+
protected touchmove: (e: TouchEvent) => void;
|
|
114
|
+
protected touchend: (e: TouchEvent) => void;
|
|
115
|
+
cursorMouseMove: import("lodash").DebouncedFunc<(e: MouseEvent) => void>;
|
|
116
|
+
protected cursorMouseLeave: import("lodash").DebouncedFunc<() => void>;
|
|
117
|
+
protected keydown: (e: KeyboardEvent) => void;
|
|
118
|
+
protected bindDisplayerEvent(div: HTMLDivElement): void;
|
|
119
|
+
protected removeDisplayerEvent(div: HTMLDivElement): void;
|
|
120
|
+
}
|
|
121
|
+
/** 主容器管理器抽象 */
|
|
122
|
+
export declare abstract class MainViewDisplayerManager {
|
|
123
|
+
static readonly viewId: string;
|
|
124
|
+
readonly viewId: string;
|
|
125
|
+
readonly control: ApplianceManagerLike;
|
|
126
|
+
readonly internalMsgEmitter: EventEmitter2;
|
|
127
|
+
readonly commiter: UndoRedoMethod;
|
|
128
|
+
abstract dpr: number;
|
|
129
|
+
abstract width: number;
|
|
130
|
+
abstract height: number;
|
|
131
|
+
abstract vDom?: BaseViewDisplayer;
|
|
132
|
+
abstract eventTragetElement?: HTMLDivElement;
|
|
133
|
+
abstract canvasServiceFloatRef: React.RefObject<HTMLCanvasElement>;
|
|
134
|
+
abstract canvasFloatRef: React.RefObject<HTMLCanvasElement>;
|
|
135
|
+
abstract canvasBgRef: React.RefObject<HTMLCanvasElement>;
|
|
136
|
+
abstract floatBarRef: React.RefObject<HTMLDivElement>;
|
|
137
|
+
abstract floatBarCanvasRef: React.RefObject<HTMLCanvasElement>;
|
|
138
|
+
abstract containerOffset: {
|
|
139
|
+
x: number;
|
|
140
|
+
y: number;
|
|
141
|
+
};
|
|
142
|
+
private cachePoint?;
|
|
143
|
+
private cacheCursorPoint?;
|
|
144
|
+
private active;
|
|
145
|
+
constructor(control: ApplianceManagerLike, internalMsgEmitter: EventEmitter2);
|
|
146
|
+
abstract setCanvassStyle(): void;
|
|
147
|
+
bindToolsClass(): void;
|
|
148
|
+
mountView(): void;
|
|
149
|
+
updateSize(): void;
|
|
150
|
+
reflashContainerOffset(): void;
|
|
151
|
+
destroy(): void;
|
|
152
|
+
getPoint(e: any): [number, number] | undefined;
|
|
153
|
+
setActive(bol: boolean): void;
|
|
154
|
+
stopEventHandler(): Promise<void>;
|
|
155
|
+
private getTranslate;
|
|
156
|
+
protected getContainerOffset(eventTraget: HTMLDivElement, offset: {
|
|
157
|
+
x: number;
|
|
158
|
+
y: number;
|
|
159
|
+
}): {
|
|
160
|
+
x: any;
|
|
161
|
+
y: any;
|
|
162
|
+
};
|
|
163
|
+
protected mousedown: (e: MouseEvent) => void;
|
|
164
|
+
protected mousemove: (e: MouseEvent) => void;
|
|
165
|
+
protected mouseup: (e: MouseEvent) => void;
|
|
166
|
+
protected touchstart: (e: TouchEvent) => void;
|
|
167
|
+
protected touchmove: (e: TouchEvent) => void;
|
|
168
|
+
protected touchend: (e: TouchEvent) => void;
|
|
169
|
+
cursorMouseMove: import("lodash").DebouncedFunc<(e: MouseEvent) => void>;
|
|
170
|
+
protected cursorMouseLeave: import("lodash").DebouncedFunc<() => void>;
|
|
171
|
+
protected keydown: (e: KeyboardEvent) => void;
|
|
172
|
+
protected bindDisplayerEvent(div: HTMLDivElement): void;
|
|
173
|
+
protected removeDisplayerEvent(div: HTMLDivElement): void;
|
|
174
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { EmitEventType, ApplianceViewManagerLike } from "./types";
|
|
3
|
+
import { TextEditorInfo } from "../component/textEditor";
|
|
4
|
+
import { ShowFloatBarMsgValue } from "../displayer/types";
|
|
5
|
+
export interface BaseDisplayerProps {
|
|
6
|
+
viewId: string;
|
|
7
|
+
maranger: ApplianceViewManagerLike;
|
|
8
|
+
refs: {
|
|
9
|
+
canvasServiceFloatRef: React.RefObject<HTMLCanvasElement>;
|
|
10
|
+
canvasFloatRef: React.RefObject<HTMLCanvasElement>;
|
|
11
|
+
canvasBgRef: React.RefObject<HTMLCanvasElement>;
|
|
12
|
+
floatBarRef: React.RefObject<HTMLDivElement>;
|
|
13
|
+
floatBarCanvasRef: React.RefObject<HTMLCanvasElement>;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface BaseDisplayerState {
|
|
17
|
+
showFloatBar: boolean;
|
|
18
|
+
zIndex: number;
|
|
19
|
+
floatBarData?: ShowFloatBarMsgValue;
|
|
20
|
+
dpr: number;
|
|
21
|
+
position?: {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
};
|
|
25
|
+
operationType: EmitEventType;
|
|
26
|
+
angle: number;
|
|
27
|
+
scale: [number, number];
|
|
28
|
+
editors?: Map<string, TextEditorInfo>;
|
|
29
|
+
activeTextId?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare const DisplayerContext: React.Context<Pick<BaseDisplayerState, "scale" | "zIndex" | "dpr" | "position" | "angle" | "floatBarData" | "operationType"> & {
|
|
32
|
+
maranger?: ApplianceViewManagerLike | undefined;
|
|
33
|
+
floatBarColors: [number, number, number][];
|
|
34
|
+
setPosition: (point: {
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
}) => void;
|
|
38
|
+
setAngle: (angle: number) => void;
|
|
39
|
+
setOperationType: (type: EmitEventType) => void;
|
|
40
|
+
setFloatBarData: (data: Partial<ShowFloatBarMsgValue>) => void;
|
|
41
|
+
}>;
|
|
42
|
+
export declare class BaseViewDisplayer extends React.Component<BaseDisplayerProps, BaseDisplayerState> {
|
|
43
|
+
constructor(props: BaseDisplayerProps);
|
|
44
|
+
private get editors();
|
|
45
|
+
componentDidMount(): void;
|
|
46
|
+
componentWillUnmount(): void;
|
|
47
|
+
showFloatBar(show: boolean, value?: Partial<ShowFloatBarMsgValue>): void;
|
|
48
|
+
setActiveTextEditor(activeTextId?: string): void;
|
|
49
|
+
setFloatZIndex(zIndex: number): void;
|
|
50
|
+
setFloatBarData(data: Partial<ShowFloatBarMsgValue>): void;
|
|
51
|
+
private setPosition;
|
|
52
|
+
private setAngle;
|
|
53
|
+
private setOperationType;
|
|
54
|
+
render(): ReactNode;
|
|
55
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ApplianceAdaptor, AppliancePluginOptions, ApplianceNames, MemberState } from "./types";
|
|
2
|
+
export type { ApplianceAdaptor, AppliancePluginOptions, ApplianceNames, MemberState };
|
|
3
|
+
export { ECanvasContextType } from "../core/enum";
|
|
4
|
+
export { ApplianceMultiPlugin } from "./applianceMultiPlugin";
|
|
5
|
+
export { ApplianceSinglePlugin } from "./applianceSinglePlugin";
|
|
6
|
+
export { ApplianceSigleWrapper } from "../plugin/single/applianceDisplayer";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AnimationMode, WindowManager } from "@netless/window-manager";
|
|
2
|
+
import { BaseApplianceManager, BaseApplianceManagerProps } from "../baseApplianceManager";
|
|
3
|
+
import { ViewContainerMultiManager } from "./containerManager";
|
|
4
|
+
export type { AnimationMode, WindowManager };
|
|
5
|
+
export declare class ApplianceMultiManager extends BaseApplianceManager {
|
|
6
|
+
windowManager?: WindowManager;
|
|
7
|
+
viewContainerManager: ViewContainerMultiManager;
|
|
8
|
+
constructor(params: BaseApplianceManagerProps);
|
|
9
|
+
init(): void;
|
|
10
|
+
destroy(): void;
|
|
11
|
+
activePlugin(): void;
|
|
12
|
+
activeWorker(): void;
|
|
13
|
+
setWindowManager(windowManager: WindowManager): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ViewContainerManager, ViewInfo } from "../baseViewContainerManager";
|
|
2
|
+
import type { View } from "../types";
|
|
3
|
+
import { BaseSubWorkModuleProps } from "../types";
|
|
4
|
+
import { ApplianceMultiManager } from "./applianceMultiManager";
|
|
5
|
+
import type { WindowManager } from './applianceMultiManager';
|
|
6
|
+
export declare class ViewContainerMultiManager extends ViewContainerManager {
|
|
7
|
+
focuedViewId?: string;
|
|
8
|
+
focuedView?: ViewInfo;
|
|
9
|
+
control: ApplianceMultiManager;
|
|
10
|
+
/** 针对windowmanager的focusedChange先于onAppViewMounted*/
|
|
11
|
+
tmpFocusedViewId?: string;
|
|
12
|
+
private checkScaleTimer?;
|
|
13
|
+
constructor(props: BaseSubWorkModuleProps);
|
|
14
|
+
mountView(viewId: string): void;
|
|
15
|
+
listenerWindowManager(windowManager: WindowManager): void;
|
|
16
|
+
private onMainViewRelease;
|
|
17
|
+
onMainViewMounted: (bindMainView: View) => void;
|
|
18
|
+
private onMainViewSizeUpdated;
|
|
19
|
+
private onMainViewCameraUpdated;
|
|
20
|
+
onAppViewMounted: (payload: any) => void;
|
|
21
|
+
private onAppViewSizeUpdated;
|
|
22
|
+
private onAppViewCameraUpdated;
|
|
23
|
+
private onActiveHotkeyChange;
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BaseViewDisplayer } from "../../displayerView";
|
|
3
|
+
import { AppViewDisplayerManager } from "../../baseViewContainerManager";
|
|
4
|
+
import { EventEmitter2 } from "eventemitter2";
|
|
5
|
+
import { ApplianceMultiManager } from "../applianceMultiManager";
|
|
6
|
+
export declare class AppViewDisplayerManagerImpl extends AppViewDisplayerManager {
|
|
7
|
+
dpr: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
vDom?: BaseViewDisplayer;
|
|
11
|
+
eventTragetElement?: HTMLDivElement;
|
|
12
|
+
canvasServiceFloatRef: React.RefObject<HTMLCanvasElement>;
|
|
13
|
+
canvasFloatRef: React.RefObject<HTMLCanvasElement>;
|
|
14
|
+
canvasBgRef: React.RefObject<HTMLCanvasElement>;
|
|
15
|
+
floatBarRef: React.RefObject<HTMLDivElement>;
|
|
16
|
+
floatBarCanvasRef: React.RefObject<HTMLCanvasElement>;
|
|
17
|
+
containerOffset: {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
};
|
|
21
|
+
constructor(viewId: string, control: ApplianceMultiManager, internalMsgEmitter: EventEmitter2);
|
|
22
|
+
setCanvassStyle(): void;
|
|
23
|
+
createAppViewDisplayer(viewId: string, appViewContainer: HTMLDivElement): AppViewDisplayerManager;
|
|
24
|
+
}
|