@netless/appliance-plugin 1.0.7 → 1.0.9

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.
Files changed (44) hide show
  1. package/cdn/cdn.js +1 -1
  2. package/cdn/fullWorker-C9GaK9.js +439 -0
  3. package/cdn/subWorker-BqoFdX.js +439 -0
  4. package/dist/appliance-plugin.js +1 -1
  5. package/dist/appliance-plugin.mjs +1 -1
  6. package/dist/core/enum.d.ts +20 -16
  7. package/dist/core/mainEngine.d.ts +1 -0
  8. package/dist/core/mainThread/base.d.ts +6 -0
  9. package/dist/core/mainThread/snapshotThread.d.ts +7 -1
  10. package/dist/core/mainThread/subLocalThread.d.ts +7 -4
  11. package/dist/core/mainThread/subServiceThread.d.ts +1 -0
  12. package/dist/core/mainThread/subTopThread.d.ts +2 -2
  13. package/dist/core/mainThread/workerMainThread.d.ts +1 -1
  14. package/dist/core/msgEvent/baseForMainThread.d.ts +3 -3
  15. package/dist/core/msgEvent/baseForWorker.d.ts +3 -3
  16. package/dist/core/msgEvent/forMainThread.d.ts +2 -4
  17. package/dist/core/msgEvent/forWorker.d.ts +2 -4
  18. package/dist/core/tools/base.d.ts +12 -0
  19. package/dist/core/tools/image.d.ts +6 -3
  20. package/dist/core/tools/pencilEraser.d.ts +0 -2
  21. package/dist/core/tools/pencilEraserBitMap.d.ts +83 -0
  22. package/dist/core/tools/selector.d.ts +2 -5
  23. package/dist/core/tools/utils.d.ts +6 -5
  24. package/dist/core/types.d.ts +3 -2
  25. package/dist/core/utils/image.d.ts +5 -0
  26. package/dist/core/utils/math.d.ts +3 -0
  27. package/dist/core/worker/base.d.ts +11 -2
  28. package/dist/core/worker/fullWorkerLocal.d.ts +4 -2
  29. package/dist/core/worker/subWorkerTopLayer.d.ts +2 -2
  30. package/dist/core/worker/workerManager.d.ts +1 -0
  31. package/dist/fullWorker.js +153 -152
  32. package/dist/index-A33g679O.js +1 -0
  33. package/dist/{index-C7xQ-iwn.mjs → index-BJIMFi3a.mjs} +708 -547
  34. package/dist/{index-DWP99OFK.mjs → index-C3iivLNQ.mjs} +5747 -5267
  35. package/dist/index-D8qYooNV.js +1 -0
  36. package/dist/plugin/baseApplianceManager.d.ts +5 -4
  37. package/dist/plugin/const.d.ts +3 -0
  38. package/dist/plugin/types.d.ts +28 -1
  39. package/dist/subWorker.js +153 -152
  40. package/package.json +2 -2
  41. package/cdn/fullWorker-CF7R0e.js +0 -438
  42. package/cdn/subWorker-BbF9q2.js +0 -438
  43. package/dist/index-2kLI3OsH.js +0 -1
  44. package/dist/index-OwNIkbKl.js +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-OwNIkbKl.js");exports.ActiveContainerType=e.ActiveContainerType;exports.ApplianceMultiPlugin=e.ApplianceMultiPlugin;exports.ApplianceNames=e.ApplianceNames;exports.ApplianceSigleWrapper=e.ApplianceSigleWrapper;exports.ApplianceSinglePlugin=e.ApplianceSinglePlugin;exports.ECanvasContextType=e.ECanvasContextType;exports.ECanvasShowType=e.ECanvasShowType;exports.EDataType=e.EDataType;exports.EMatrixrRelationType=e.EMatrixrRelationType;exports.EPostMessageType=e.EPostMessageType;exports.EScaleType=e.EScaleType;exports.EStrokeType=e.EStrokeType;exports.EToolsKey=e.EToolsKey;exports.ElayerType=e.ElayerType;exports.EmitEventType=e.EmitEventType;exports.EventMessageType=e.EventMessageType;exports.EvevtWorkState=e.EvevtWorkState;exports.EvevtWorkType=e.EvevtWorkType;exports.InternalMsgEmitterType=e.InternalMsgEmitterType;exports.ShapeType=e.ShapeType;exports.fullWorkerUrl=e.fullWorker;exports.subWorkerUrl=e.subWorker;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-A33g679O.js");exports.ActiveContainerType=e.ActiveContainerType;exports.ApplianceMultiPlugin=e.ApplianceMultiPlugin;exports.ApplianceNames=e.ApplianceNames;exports.ApplianceSigleWrapper=e.ApplianceSigleWrapper;exports.ApplianceSinglePlugin=e.ApplianceSinglePlugin;exports.ECanvasContextType=e.ECanvasContextType;exports.ECanvasShowType=e.ECanvasShowType;exports.EDataType=e.EDataType;exports.EMatrixrRelationType=e.EMatrixrRelationType;exports.EPostMessageType=e.EPostMessageType;exports.EScaleType=e.EScaleType;exports.EStrokeType=e.EStrokeType;exports.EToolsKey=e.EToolsKey;exports.ElayerType=e.ElayerType;exports.EmitEventType=e.EmitEventType;exports.EventMessageType=e.EventMessageType;exports.EvevtWorkState=e.EvevtWorkState;exports.EvevtWorkType=e.EvevtWorkType;exports.InternalMsgEmitterType=e.InternalMsgEmitterType;exports.ShapeType=e.ShapeType;exports.fullWorkerUrl=e.fullWorker;exports.subWorkerUrl=e.subWorker;
@@ -1,4 +1,4 @@
1
- import { H as s, A as p, B as t, z as r, y as l, J as n, K as y, h as E, r as i, k as T, O as o, F as v, E as g, N as S, p as c, L as k, a as A, P as u, I as M, G as W, w as m, x } from "./index-DWP99OFK.mjs";
1
+ import { H as s, A as p, B as t, z as r, y as l, J as n, K as y, h as E, r as i, k as T, O as o, F as v, E as g, N as S, p as c, L as k, a as A, P as u, I as M, G as W, w as m, x } from "./index-C3iivLNQ.mjs";
2
2
  export {
3
3
  s as ActiveContainerType,
4
4
  p as ApplianceMultiPlugin,
@@ -5,36 +5,38 @@ export declare enum EToolsKey {
5
5
  Eraser = 2,
6
6
  /** 局部橡皮擦 */
7
7
  PencilEraser = 3,
8
+ /** 局部位图橡皮擦 */
9
+ BitMapEraser = 4,
8
10
  /** 选择工具 */
9
- Selector = 4,
11
+ Selector = 5,
10
12
  /** 点击互动工具 */
11
- Clicker = 5,
13
+ Clicker = 6,
12
14
  /** 箭头工具 */
13
- Arrow = 6,
15
+ Arrow = 7,
14
16
  /** 抓手工具 */
15
- Hand = 7,
17
+ Hand = 8,
16
18
  /** 激光铅笔绘制工具 */
17
- LaserPen = 8,
19
+ LaserPen = 9,
18
20
  /** 文字工具 */
19
- Text = 9,
21
+ Text = 10,
20
22
  /** 直线工具 */
21
- Straight = 10,
23
+ Straight = 11,
22
24
  /** 矩形工具 */
23
- Rectangle = 11,
25
+ Rectangle = 12,
24
26
  /** 圆形工具 */
25
- Ellipse = 12,
27
+ Ellipse = 13,
26
28
  /** 星形工具 */
27
- Star = 13,
29
+ Star = 14,
28
30
  /** 三角形工具 */
29
- Triangle = 14,
31
+ Triangle = 15,
30
32
  /** 菱形工具 */
31
- Rhombus = 15,
33
+ Rhombus = 16,
32
34
  /** 多边形工具 */
33
- Polygon = 16,
35
+ Polygon = 17,
34
36
  /** 聊天泡泡框 */
35
- SpeechBalloon = 17,
37
+ SpeechBalloon = 18,
36
38
  /** 图片 */
37
- Image = 18
39
+ Image = 19
38
40
  }
39
41
  export declare enum EDataType {
40
42
  /** 本地数据 */
@@ -101,7 +103,9 @@ export declare enum EPostMessageType {
101
103
  /** 优先激活worker */
102
104
  PriorityWorker = 21,
103
105
  /** 优先激活worker */
104
- PriorityMainThreadWorker = 22
106
+ PriorityMainThreadWorker = 22,
107
+ /** 获取图片位图 */
108
+ GetImageBitMap = 23
105
109
  }
106
110
  export declare enum ECanvasContextType {
107
111
  Webgl2 = "webgl2",
@@ -143,6 +143,7 @@ export declare class MasterControlForWorker extends MasterController {
143
143
  private get isCanSentCursor();
144
144
  private get isCanStartEventConsum();
145
145
  init(): Promise<void>;
146
+ private useMainThread;
146
147
  on(): Promise<void>;
147
148
  clearReRenders(num?: number): void;
148
149
  get isBusy(): boolean;
@@ -63,9 +63,15 @@ export declare class MainThreadEngineImpl implements MainThreadEngine {
63
63
  private mainThreadPostId?;
64
64
  private combinePostMsg;
65
65
  private methodBuilder;
66
+ private cacheImages;
67
+ private imageResolveMap;
66
68
  constructor(viewId: string, opt: IMainThreadInitOption);
69
+ getCachedImages(imageSrc: string): ImageBitmap | undefined;
70
+ clearCacheImages(): void;
71
+ clearImageResolveMap(): void;
67
72
  post(msg: Omit<IBatchMainMessage, 'render'>): void;
68
73
  on(msg: IWorkerMessage): Promise<void>;
74
+ loadImageBitMap(msg: Pick<IWorkerMessage, 'toolsType' | 'opt' | 'workId'>): Promise<ImageBitmap | undefined>;
69
75
  private removeNode;
70
76
  consumeFull(type: EDataType, data: IWorkerMessage): Promise<void>;
71
77
  setCameraOpt(cameraOpt: ICameraOpt): void;
@@ -14,12 +14,18 @@ export declare class SnapshotThreadImpl {
14
14
  private mainThreadPostId?;
15
15
  private combinePostMsg;
16
16
  workShapes: Map<string, BaseShapeTool>;
17
+ private cacheImages;
18
+ private imageResolveMap;
17
19
  constructor(viewId: string, opt: IMainThreadInitOption);
20
+ getCachedImages(imageSrc: string): ImageBitmap | undefined;
21
+ clearCacheImages(): void;
22
+ clearImageResolveMap(): void;
18
23
  post(msg: Omit<IBatchMainMessage, 'render'>): void;
19
24
  on(msg: IWorkerMessage): Promise<void>;
25
+ loadImageBitMap(msg: Pick<IWorkerMessage, 'toolsType' | 'opt' | 'workId'>): Promise<ImageBitmap | undefined>;
20
26
  createWorkShapeNode(opt: IActiveToolsDataType & {
21
27
  workId: string;
22
- }): import("../tools").PencilShape | import("../tools").LaserPenShape | import("../tools").EraserShape | import("../tools").StarShape | TextShape | import("../tools").SelectorShape | ImageShape | import("../tools").ArrowShape | import("../tools/straight").StraightShape | import("../tools").EllipseShape | import("../tools").PolygonShape | import("../tools").RectangleShape | import("../tools").SpeechBalloonShape | import("../tools/pencilEraser").PencilEraserShape | undefined;
28
+ }): import("../tools").PencilShape | import("../tools").LaserPenShape | import("../tools").EraserShape | import("../tools").StarShape | TextShape | import("../tools").SelectorShape | ImageShape | import("../tools").ArrowShape | import("../tools/straight").StraightShape | import("../tools").EllipseShape | import("../tools").PolygonShape | import("../tools").RectangleShape | import("../tools").SpeechBalloonShape | import("../tools/pencilEraserBitMap").BitMapEraserShape | import("../tools/pencilEraser").PencilEraserShape | undefined;
23
29
  setFullWork(data: Pick<IWorkerMessage, 'workId' | 'opt' | 'toolsType'>): BaseShapeTool | undefined;
24
30
  runFullWork(data: IWorkerMessage): Promise<IRectType | undefined>;
25
31
  private getSnapshot;
@@ -3,9 +3,9 @@ import type { BaseShapeTool, BaseShapeOptions, SelectorShape, ImageShape, ShapeT
3
3
  import { MainThreadEngineImpl, ISubThreadInitOption } from "./base";
4
4
  import { VNodeManager } from "../vNodeManager";
5
5
  import { EToolsKey } from "../enum";
6
- import { Scene } from "spritejs";
7
6
  import { SubServiceThread } from "./subServiceThread";
8
7
  import { TextShape } from "../tools/text";
8
+ import { BitMapEraserShape } from "../tools/pencilEraserBitMap";
9
9
  export interface SubLocalThread {
10
10
  readonly vNodes: VNodeManager;
11
11
  readonly thread: MainThreadEngineImpl;
@@ -30,7 +30,7 @@ export interface SubLocalThread {
30
30
  getWorkShape(workId: string): BaseShapeTool | undefined;
31
31
  getWorkShapes(): Map<string, BaseShapeTool>;
32
32
  setFullWork(data: Pick<IWorkerMessage, 'workId' | 'opt' | 'toolsType'>): ShapeToolsClass | undefined;
33
- consumeFull(data: IWorkerMessage, scene?: Scene): Promise<void>;
33
+ consumeFull(data: IWorkerMessage): Promise<void>;
34
34
  removeWork(data: IWorkerMessage): void;
35
35
  removeSelector(data: IWorkerMessage): Promise<void>;
36
36
  updateFullSelectWork(data: IWorkerMessage): void;
@@ -65,6 +65,7 @@ export declare class SubLocalThreadImpl implements SubLocalThread {
65
65
  private drawCount;
66
66
  private drawWorkActiveId?;
67
67
  constructor(opt: ISubThreadInitOption);
68
+ loadImageBitMap(msg: Pick<IWorkerMessage, 'toolsType' | 'opt' | 'workId'>): Promise<ImageBitmap | undefined>;
68
69
  createLocalWork(data: IWorkerMessage): void;
69
70
  workShapesDone(scenePath: string, serviceWork: SubServiceThread): void;
70
71
  updateSelector(params: IUpdateSelectorPropsType & {
@@ -90,7 +91,7 @@ export declare class SubLocalThreadImpl implements SubLocalThread {
90
91
  removeWork(data: IWorkerMessage): void;
91
92
  removeNode(key: string): void;
92
93
  setFullWork(data: Pick<IWorkerMessage, 'workId' | 'opt' | 'toolsType'>): BaseShapeTool | undefined;
93
- consumeFull(data: IWorkerMessage, scene?: Scene): Promise<void>;
94
+ consumeFull(data: IWorkerMessage): Promise<void>;
94
95
  colloctEffectSelectWork(data: IWorkerMessage): Promise<IWorkerMessage | undefined>;
95
96
  private runEffectSelectWork;
96
97
  hasSelector(): boolean;
@@ -98,6 +99,8 @@ export declare class SubLocalThreadImpl implements SubLocalThread {
98
99
  reRenderSelector(willSyncService?: boolean): Promise<void> | undefined;
99
100
  blurSelector(data?: IWorkerMessage): Promise<void>;
100
101
  clearWorkShapeNodeCache(workId: string): void;
102
+ private drawBitMapEraser;
103
+ private drawBitMapEraserFull;
101
104
  private drawPencilEraser;
102
105
  private drawEraser;
103
106
  private updateBatchEraserCombineNode;
@@ -111,5 +114,5 @@ export declare class SubLocalThreadImpl implements SubLocalThread {
111
114
  setWorkOptions(workId: string, opt: BaseShapeOptions): void;
112
115
  createWorkShapeNode(opt: IActiveToolsDataType & {
113
116
  workId: string;
114
- }): PencilShape | import("../tools").LaserPenShape | import("../tools").EraserShape | import("../tools").StarShape | TextShape | SelectorShape | ImageShape | import("../tools").ArrowShape | import("../tools/straight").StraightShape | import("../tools").EllipseShape | import("../tools").PolygonShape | import("../tools").RectangleShape | import("../tools").SpeechBalloonShape | import("../tools/pencilEraser").PencilEraserShape | undefined;
117
+ }): PencilShape | import("../tools").LaserPenShape | import("../tools").EraserShape | import("../tools").StarShape | TextShape | SelectorShape | ImageShape | import("../tools").ArrowShape | import("../tools/straight").StraightShape | import("../tools").EllipseShape | import("../tools").PolygonShape | import("../tools").RectangleShape | import("../tools").SpeechBalloonShape | BitMapEraserShape | import("../tools/pencilEraser").PencilEraserShape | undefined;
115
118
  }
@@ -22,6 +22,7 @@ export declare class SubServiceThreadImpl implements SubServiceThread {
22
22
  private animationId?;
23
23
  private syncUnitTime;
24
24
  constructor(opt: ISubThreadInitOption);
25
+ loadImageBitMap(msg: Pick<IWorkerMessage, 'toolsType' | 'opt' | 'workId'>): Promise<ImageBitmap | undefined>;
25
26
  destroy(): void;
26
27
  clearAll(): void;
27
28
  private runEffect;
@@ -33,7 +33,7 @@ export declare class SubTopThreadImpl implements SubTopThread {
33
33
  constructor(opt: ISubThreadInitOption);
34
34
  createLocalWork(data: IWorkerMessage): void;
35
35
  getLocalWorkShape(workId: string): ILocalWorkItem | undefined;
36
- createLocalWorkShape(workId: string, opt?: BaseShapeOptions): import("../tools").PencilShape | import("../tools").LaserPenShape | import("../tools").EraserShape | import("../tools").StarShape | import("../tools/text").TextShape | import("../tools").SelectorShape | import("../tools").ImageShape | import("../tools").ArrowShape | import("../tools/straight").StraightShape | import("../tools").EllipseShape | import("../tools").PolygonShape | import("../tools").RectangleShape | import("../tools").SpeechBalloonShape | import("../tools/pencilEraser").PencilEraserShape | undefined;
36
+ createLocalWorkShape(workId: string, opt?: BaseShapeOptions): import("../tools").PencilShape | import("../tools").LaserPenShape | import("../tools").EraserShape | import("../tools").StarShape | import("../tools/text").TextShape | import("../tools").SelectorShape | import("../tools").ImageShape | import("../tools").ArrowShape | import("../tools/straight").StraightShape | import("../tools").EllipseShape | import("../tools").PolygonShape | import("../tools").RectangleShape | import("../tools").SpeechBalloonShape | import("../tools/pencilEraserBitMap").BitMapEraserShape | import("../tools/pencilEraser").PencilEraserShape | undefined;
37
37
  canUseTopLayer(toolsType: EToolsKey): toolsType is EToolsKey.LaserPen;
38
38
  destroy(): void;
39
39
  clearAll(): void;
@@ -42,7 +42,7 @@ export declare class SubTopThreadImpl implements SubTopThread {
42
42
  getToolsOpt(): IActiveToolsDataType | undefined;
43
43
  createWorkShapeNode(opt: IActiveToolsDataType & {
44
44
  workId: string;
45
- }): import("../tools").PencilShape | import("../tools").LaserPenShape | import("../tools").EraserShape | import("../tools").StarShape | import("../tools/text").TextShape | import("../tools").SelectorShape | import("../tools").ImageShape | import("../tools").ArrowShape | import("../tools/straight").StraightShape | import("../tools").EllipseShape | import("../tools").PolygonShape | import("../tools").RectangleShape | import("../tools").SpeechBalloonShape | import("../tools/pencilEraser").PencilEraserShape | undefined;
45
+ }): import("../tools").PencilShape | import("../tools").LaserPenShape | import("../tools").EraserShape | import("../tools").StarShape | import("../tools/text").TextShape | import("../tools").SelectorShape | import("../tools").ImageShape | import("../tools").ArrowShape | import("../tools/straight").StraightShape | import("../tools").EllipseShape | import("../tools").PolygonShape | import("../tools").RectangleShape | import("../tools").SpeechBalloonShape | import("../tools/pencilEraserBitMap").BitMapEraserShape | import("../tools/pencilEraser").PencilEraserShape | undefined;
46
46
  private setNodeKey;
47
47
  private activeServiceWorkShape;
48
48
  private computNextAnimationIndex;
@@ -92,7 +92,7 @@ export declare class SubMainThreadWorkerImpl implements SubMainThreadWorker {
92
92
  setToolsOpt(opt: IActiveToolsDataType): void;
93
93
  createWorkShapeNode(opt: IActiveToolsDataType & {
94
94
  workId: string;
95
- }): import("../tools").PencilShape | import("../tools").LaserPenShape | import("../tools").EraserShape | import("../tools").StarShape | import("../tools/text").TextShape | import("../tools").SelectorShape | import("../tools").ImageShape | import("../tools").ArrowShape | import("../tools/straight").StraightShape | import("../tools").EllipseShape | import("../tools").PolygonShape | import("../tools").RectangleShape | import("../tools").SpeechBalloonShape | import("../tools/pencilEraser").PencilEraserShape | undefined;
95
+ }): import("../tools").PencilShape | import("../tools").LaserPenShape | import("../tools").EraserShape | import("../tools").StarShape | import("../tools/text").TextShape | import("../tools").SelectorShape | import("../tools").ImageShape | import("../tools").ArrowShape | import("../tools/straight").StraightShape | import("../tools").EllipseShape | import("../tools").PolygonShape | import("../tools").RectangleShape | import("../tools").SpeechBalloonShape | import("../tools/pencilEraserBitMap").BitMapEraserShape | import("../tools/pencilEraser").PencilEraserShape | undefined;
96
96
  clearWorkShapeNodeCache(workId: string): void;
97
97
  getWorkShape(workId: string): BaseShapeTool | undefined;
98
98
  }
@@ -1,13 +1,13 @@
1
- import type { Scene } from "spritejs";
2
1
  import { EmitEventType } from "../../plugin/types";
3
2
  import { IWorkerMessage } from "../types";
4
3
  import { SubLocalThread } from "../mainThread/subLocalThread";
5
4
  import { SubServiceThread } from "../mainThread/subServiceThread";
5
+ import { MainThreadEngineImpl } from "../mainThread/base";
6
6
  export declare abstract class BaseMsgMethodForMainThread {
7
7
  abstract readonly emitEventType: EmitEventType;
8
8
  localWork?: SubLocalThread;
9
9
  serviceWork?: SubServiceThread;
10
- scene: Scene | undefined;
11
- registerMainThread(localWork: SubLocalThread, serviceWork?: SubServiceThread, scene?: Scene): this;
10
+ threadEngine: MainThreadEngineImpl | undefined;
11
+ registerMainThread(threadEngine: MainThreadEngineImpl): this;
12
12
  abstract consume(data: IWorkerMessage): Promise<boolean | undefined>;
13
13
  }
@@ -1,13 +1,13 @@
1
- import type { Scene } from "spritejs";
2
1
  import { EmitEventType } from "../../plugin/types";
3
2
  import { IWorkerMessage } from "../types";
4
3
  import { LocalWorkForFullWorker } from "../worker/fullWorkerLocal";
5
4
  import { ServiceWorkForFullWorker } from "../worker/fullWorkerService";
5
+ import type { WorkThreadEngineForFullWorker } from "../worker/workerManager";
6
6
  export declare abstract class BaseMsgMethodForWorker {
7
7
  abstract readonly emitEventType: EmitEventType;
8
8
  localWork: LocalWorkForFullWorker | undefined;
9
9
  serviceWork: ServiceWorkForFullWorker | undefined;
10
- scene: Scene | undefined;
11
- registerForWorker(localWork: LocalWorkForFullWorker, serviceWork?: ServiceWorkForFullWorker, scene?: Scene): this;
10
+ threadEngine: WorkThreadEngineForFullWorker | undefined;
11
+ registerForWorker(threadEngine: WorkThreadEngineForFullWorker): this;
12
12
  abstract consume(data: IWorkerMessage): boolean | undefined;
13
13
  }
@@ -1,14 +1,12 @@
1
1
  import { EmitEventType } from '../../plugin/types';
2
2
  import { BaseMsgMethodForMainThread } from './baseForMainThread';
3
3
  import { IWorkerMessage } from '../types';
4
- import type { Scene } from 'spritejs';
5
- import type { SubLocalThread } from '../mainThread/subLocalThread';
6
- import type { SubServiceThread } from '../mainThread/subServiceThread';
4
+ import { MainThreadEngineImpl } from '../mainThread/base';
7
5
  export type MsgMethodForMainThread<T extends BaseMsgMethodForMainThread> = T;
8
6
  export declare class MethodBuilderWorker {
9
7
  builders: Map<EmitEventType, MsgMethodForMainThread<BaseMsgMethodForMainThread> | undefined>;
10
8
  constructor(emitTypes: EmitEventType[]);
11
9
  build(type: EmitEventType): MsgMethodForMainThread<BaseMsgMethodForMainThread> | undefined;
12
- registerForMainThread(localWork: SubLocalThread, serviceWork?: SubServiceThread, scene?: Scene): this;
10
+ registerForMainThread(threadEngine: MainThreadEngineImpl): this;
13
11
  consumeForMainThread(data: IWorkerMessage): Promise<boolean>;
14
12
  }
@@ -1,14 +1,12 @@
1
1
  import { EmitEventType } from '../../plugin/types';
2
2
  import { BaseMsgMethodForWorker } from './baseForWorker';
3
3
  import { IWorkerMessage } from '../types';
4
- import { LocalWorkForFullWorker } from '../worker/fullWorkerLocal';
5
- import { ServiceWorkForFullWorker } from '../worker/fullWorkerService';
6
- import type { Scene } from 'spritejs';
4
+ import type { WorkThreadEngineForFullWorker } from '../worker/workerManager';
7
5
  export type MsgMethodForWorker<T extends BaseMsgMethodForWorker> = T;
8
6
  export declare class MethodBuilderWorker {
9
7
  builders: Map<EmitEventType, MsgMethodForWorker<BaseMsgMethodForWorker> | undefined>;
10
8
  constructor(emitTypes: EmitEventType[]);
11
9
  build(type: EmitEventType): MsgMethodForWorker<BaseMsgMethodForWorker> | undefined;
12
- registerForWorker(localWork: LocalWorkForFullWorker, serviceWork?: ServiceWorkForFullWorker, scene?: Scene): this;
10
+ registerForWorker(threadEngine: WorkThreadEngineForFullWorker): this;
13
11
  consumeForWorker(data: IWorkerMessage): boolean;
14
12
  }
@@ -5,6 +5,7 @@ import { Group } from "spritejs";
5
5
  import { VNodeManager } from "../vNodeManager";
6
6
  import { ShapeNodes, ShapeOptions } from "./utils";
7
7
  import { TextOptions } from "../../component/textEditor/types";
8
+ import { SerializerEraserLines } from "./pencilEraserBitMap";
8
9
  export interface BaseShapeOptions {
9
10
  isOpacity?: boolean;
10
11
  fontColor?: string;
@@ -20,6 +21,7 @@ export interface BaseShapeOptions {
20
21
  thickness?: number;
21
22
  textOpt?: TextOptions;
22
23
  translate?: [number, number];
24
+ eraserlines?: SerializerEraserLines;
23
25
  }
24
26
  export interface BaseShapeToolProps {
25
27
  workId: string;
@@ -83,6 +85,16 @@ export declare abstract class BaseShapeTool {
83
85
  setWorkOptions(workOptions: BaseShapeOptions): void;
84
86
  /** 更新服务端同步配置,返回绘制结果 */
85
87
  updataOptService(opt?: IUpdateNodeOpt): IRectType | undefined;
88
+ drawEraserlines(props: {
89
+ group: Group;
90
+ eraserlines: SerializerEraserLines;
91
+ pos: [number, number];
92
+ layer: Group;
93
+ isClear?: boolean;
94
+ }): void;
95
+ protected computEraserPoints(points: number[], thickness: number): Point2d[];
96
+ private computDot;
97
+ private computLine;
86
98
  replace(layer: Group, replaceId: string, newNode?: ShapeNodes): void;
87
99
  static updateNodeOpt(param: {
88
100
  node: ShapeNodes;
@@ -1,10 +1,14 @@
1
- import { Scene } from "spritejs";
2
1
  import { IRectType, IUpdateNodeOpt, BaseNodeMapItem } from "../types";
3
2
  import { EPostMessageType, EScaleType, EToolsKey } from "../enum";
4
3
  import { Point2d } from "../utils/primitives/Point2d";
5
4
  import { BaseShapeOptions, BaseShapeTool, BaseShapeToolProps } from "./base";
6
5
  import { VNodeManager } from "../vNodeManager";
7
6
  import { ShapeNodes } from "./utils";
7
+ import type { LocalWorkForFullWorker } from "../worker/fullWorkerLocal";
8
+ import type { SubLocalThreadImpl } from "../mainThread/subLocalThread";
9
+ import type { SnapshotThreadImpl } from "../mainThread/snapshotThread";
10
+ import type { SubServiceThreadImpl } from "../mainThread/subServiceThread";
11
+ import type { WorkThreadEngineForFullWorker, WorkThreadEngineForSubWorker } from "../worker/workerManager";
8
12
  export interface ImageOptions extends BaseShapeOptions {
9
13
  /** 图片的唯一识别符 */
10
14
  uuid: string;
@@ -43,9 +47,8 @@ export declare class ImageShape extends BaseShapeTool {
43
47
  consumeService(): IRectType | undefined;
44
48
  consumeServiceAsync(props: {
45
49
  isFullWork: boolean;
46
- scene: Scene;
50
+ worker: LocalWorkForFullWorker | WorkThreadEngineForFullWorker | WorkThreadEngineForSubWorker | SubLocalThreadImpl | SnapshotThreadImpl | SubServiceThreadImpl;
47
51
  replaceId?: string;
48
- isMainThread?: boolean;
49
52
  }): Promise<IRectType | undefined>;
50
53
  clearTmpPoints(): void;
51
54
  static getScaleType(opt: ImageOptions): EScaleType.all | EScaleType.proportional;
@@ -18,9 +18,7 @@ export declare class PencilEraserShape extends BaseShapeTool {
18
18
  eraserRect: IRectType | undefined;
19
19
  eraserPolyline?: [number, number, number, number];
20
20
  constructor(props: BaseShapeToolProps, serviceWork?: ServiceThreadSubWork);
21
- combineConsume(): undefined;
22
21
  consumeService(): IRectType | undefined;
23
- setWorkOptions(setWorkOptions: PencilEraserOptions): void;
24
22
  private createEraserRect;
25
23
  private computRectCenterPoints;
26
24
  private isNear;
@@ -0,0 +1,83 @@
1
+ import { BaseShapeOptions, BaseShapeTool, BaseShapeToolProps } from "./base";
2
+ import { EDataType, EPostMessageType, EScaleType, EToolsKey } from "../enum";
3
+ import { IWorkerMessage, IRectType, BaseNodeMapItem } from "../types";
4
+ import { Point2d } from "../utils/primitives/Point2d";
5
+ import type { LocalWorkForFullWorker } from "../worker/fullWorkerLocal";
6
+ import type { SubLocalThreadImpl } from "../mainThread/subLocalThread";
7
+ export type SerializerEraserLines = Array<SerializerEraserItem>;
8
+ export interface SerializerEraserItem {
9
+ op: number[][];
10
+ thickness: number;
11
+ }
12
+ export interface BitMapEraserOptions extends BaseShapeOptions {
13
+ thickness: number;
14
+ }
15
+ export declare class BitMapEraserShape extends BaseShapeTool {
16
+ readonly canRotate: boolean;
17
+ readonly scaleType: EScaleType;
18
+ readonly toolsType: EToolsKey;
19
+ private static readonly eraserSizes;
20
+ protected tmpPoints: Array<Point2d>;
21
+ protected workOptions: BitMapEraserOptions;
22
+ worldPosition: [number, number];
23
+ worldScaling: [number, number];
24
+ eraserRect: IRectType | undefined;
25
+ eraserPolyline?: [number, number, number, number];
26
+ syncUnitTime: number;
27
+ private syncIndex;
28
+ private syncTimestamp;
29
+ constructor(props: BaseShapeToolProps);
30
+ consumeService(params: {
31
+ op: number[];
32
+ isFullWork?: boolean;
33
+ }): IRectType | undefined;
34
+ private updateTempPoints;
35
+ private getChangeNodes;
36
+ reRenderEffectNodes(props: {
37
+ willUpdateNodes: Map<string, BaseNodeMapItem>;
38
+ worker: LocalWorkForFullWorker | SubLocalThreadImpl;
39
+ }): Promise<IRectType | undefined>;
40
+ consume(props: {
41
+ data: IWorkerMessage;
42
+ }): {
43
+ workId: string;
44
+ toolsType: EToolsKey;
45
+ opt: import("./utils").ShapeOptions;
46
+ type: EPostMessageType;
47
+ } | {
48
+ type: EPostMessageType;
49
+ dataType: EDataType;
50
+ rect: IRectType | undefined;
51
+ op: number[] | undefined;
52
+ index: number | undefined;
53
+ updateNodeOpt: {
54
+ useAnimation: boolean;
55
+ };
56
+ workId: string;
57
+ toolsType: EToolsKey;
58
+ opt: import("./utils").ShapeOptions;
59
+ };
60
+ private draw;
61
+ consumeAll(): {
62
+ workId: string;
63
+ toolsType: EToolsKey;
64
+ opt: import("./utils").ShapeOptions;
65
+ type: EPostMessageType;
66
+ } | {
67
+ rect: IRectType | undefined;
68
+ workId: string;
69
+ toolsType: EToolsKey;
70
+ opt: import("./utils").ShapeOptions;
71
+ type: EPostMessageType;
72
+ } | {
73
+ type: EPostMessageType;
74
+ dataType: EDataType;
75
+ rect: IRectType | undefined;
76
+ ops: string;
77
+ willUpdateNodes: Map<string, BaseNodeMapItem>;
78
+ workId: string;
79
+ toolsType: EToolsKey;
80
+ opt: import("./utils").ShapeOptions;
81
+ };
82
+ clearTmpPoints(): void;
83
+ }
@@ -1,4 +1,3 @@
1
- import { Scene } from "spritejs";
2
1
  import { BaseShapeOptions, BaseShapeTool, BaseShapeToolProps } from "./base";
3
2
  import { EDataType, EPostMessageType, EScaleType, EToolsKey } from "../enum";
4
3
  import { IWorkerMessage, IMainMessage, IRectType, IUpdateNodeOpt, IServiceWorkItem } from "../types";
@@ -7,7 +6,7 @@ import type { VNodeManager } from "../vNodeManager";
7
6
  import { TextOptions } from "../../component/textEditor/types";
8
7
  import { LocalWorkForFullWorker } from "../worker/fullWorkerLocal";
9
8
  import { ShapeOptType } from "../../displayer/types";
10
- import type { SubLocalThread } from "../mainThread/subLocalThread";
9
+ import type { SubLocalThreadImpl } from "../mainThread/subLocalThread";
11
10
  import { EStrokeType } from "../../plugin";
12
11
  export interface SelectorOptions extends BaseShapeOptions {
13
12
  }
@@ -112,10 +111,8 @@ export declare class SelectorShape extends BaseShapeTool {
112
111
  vNodes: VNodeManager;
113
112
  selectIds?: string[];
114
113
  willSerializeData?: boolean;
115
- worker?: LocalWorkForFullWorker | SubLocalThread;
114
+ worker?: LocalWorkForFullWorker | SubLocalThreadImpl;
116
115
  offset?: [number, number];
117
- scene?: Scene;
118
- isMainThread?: boolean;
119
116
  }): Promise<IMainMessage | undefined>;
120
117
  blurSelector(): {
121
118
  type: EPostMessageType;
@@ -20,9 +20,10 @@ import type { ServiceWorkForFullWorker } from "../worker/fullWorkerService";
20
20
  import type { SubServiceThread } from "../mainThread/subServiceThread";
21
21
  import { BaseShapeTool } from "./base";
22
22
  import { PencilEraserOptions, PencilEraserShape } from "./pencilEraser";
23
- export type ShapeTools = typeof PencilShape | typeof LaserPenShape | typeof PencilEraserShape | typeof EraserShape | typeof StarShape | typeof SelectorShape | typeof ArrowShape | typeof EllipseShape | typeof RectangleShape | typeof StarShape | typeof PolygonShape | typeof TextShape | typeof SpeechBalloonShape | typeof ImageShape;
24
- export type ShapeToolsClass = BaseShapeTool | PencilShape | LaserPenShape | PencilEraserShape | EraserShape | StarShape | SelectorShape | ArrowShape | EllipseShape | RectangleShape | StarShape | PolygonShape | TextShape | SpeechBalloonShape | ImageShape;
25
- export type ShapeOptions = PencilOptions | LaserPenOptions | PencilEraserOptions | EraserOptions | StarOptions | SelectorOptions | ArrowOptions | EllipseOptions | RectangleOptions | StarOptions | PolygonOptions | StraightOptions | TextOptions | SpeechBalloonOptions | ImageOptions;
23
+ import { BitMapEraserOptions, BitMapEraserShape } from "./pencilEraserBitMap";
24
+ export type ShapeTools = typeof PencilShape | typeof LaserPenShape | typeof PencilEraserShape | typeof BitMapEraserShape | typeof EraserShape | typeof StarShape | typeof SelectorShape | typeof ArrowShape | typeof EllipseShape | typeof RectangleShape | typeof StarShape | typeof PolygonShape | typeof TextShape | typeof SpeechBalloonShape | typeof ImageShape;
25
+ export type ShapeToolsClass = BaseShapeTool | PencilShape | LaserPenShape | PencilEraserShape | BitMapEraserShape | EraserShape | StarShape | SelectorShape | ArrowShape | EllipseShape | RectangleShape | StarShape | PolygonShape | TextShape | SpeechBalloonShape | ImageShape;
26
+ export type ShapeOptions = PencilOptions | LaserPenOptions | PencilEraserOptions | BitMapEraserOptions | EraserOptions | StarOptions | SelectorOptions | ArrowOptions | EllipseOptions | RectangleOptions | StarOptions | PolygonOptions | StraightOptions | TextOptions | SpeechBalloonOptions | ImageOptions;
26
27
  export type ShapeNodes = Group | Path | Polyline | Rect | Ellipse | Sprite | Label;
27
28
  export type ServiceThreadSubWork = SubServiceThread | ServiceWorkForFullWorker;
28
29
  export interface CombineConsumeResult {
@@ -33,7 +34,7 @@ export interface CombineConsumeResult {
33
34
  export interface ShapeStateInfo {
34
35
  willClear: boolean;
35
36
  }
36
- export declare function getShapeTools(toolsType: EToolsKey): typeof PencilShape | typeof LaserPenShape | typeof EraserShape | typeof StarShape | typeof TextShape | typeof ArrowShape | typeof StraightShape | typeof EllipseShape | typeof PolygonShape | typeof RectangleShape | typeof SpeechBalloonShape | typeof PencilEraserShape | typeof SelectorShape | typeof ImageShape | undefined;
37
+ export declare function getShapeTools(toolsType: EToolsKey): typeof PencilShape | typeof LaserPenShape | typeof EraserShape | typeof StarShape | typeof TextShape | typeof ArrowShape | typeof StraightShape | typeof EllipseShape | typeof PolygonShape | typeof RectangleShape | typeof SpeechBalloonShape | typeof BitMapEraserShape | typeof PencilEraserShape | typeof SelectorShape | typeof ImageShape | undefined;
37
38
  export declare function getShapeInstance(param: {
38
39
  workId: string;
39
40
  toolsType: EToolsKey;
@@ -41,5 +42,5 @@ export declare function getShapeInstance(param: {
41
42
  vNodes?: VNodeManager;
42
43
  fullLayer: Group;
43
44
  drawLayer?: Group;
44
- }, serviceWork?: ServiceThreadSubWork): PencilShape | LaserPenShape | EraserShape | StarShape | TextShape | SelectorShape | ImageShape | ArrowShape | StraightShape | EllipseShape | PolygonShape | RectangleShape | SpeechBalloonShape | PencilEraserShape | undefined;
45
+ }, serviceWork?: ServiceThreadSubWork): PencilShape | LaserPenShape | EraserShape | StarShape | TextShape | SelectorShape | ImageShape | ArrowShape | StraightShape | EllipseShape | PolygonShape | RectangleShape | SpeechBalloonShape | BitMapEraserShape | PencilEraserShape | undefined;
45
46
  export declare function findShapeBody(nodes: ShapeNodes[]): ShapeNodes[];
@@ -1,4 +1,3 @@
1
- import type { Scene } from 'spritejs';
2
1
  import { BaseCollectorReducerAction, INormalPushMsg, ISerializableStorageData } from '../collector/types';
3
2
  import { ETextEditorType, FontStyleType, FontWeightType, TextOptions } from '../component/textEditor/types';
4
3
  import { EmitEventType } from '../plugin/types';
@@ -176,6 +175,7 @@ export interface IMainMessage extends INormalPushMsg {
176
175
  shapeOpt?: ShapeOptType;
177
176
  toolsTypes?: EToolsKey[];
178
177
  isLockSentEventCursor?: boolean;
178
+ nextTasks?: IMainMessage[];
179
179
  [key: string]: any;
180
180
  }
181
181
  export interface IMainMessageRenderData {
@@ -222,7 +222,6 @@ export interface IUpdateSelectorPropsType {
222
222
  emitEventType?: EmitEventType;
223
223
  isSync?: boolean;
224
224
  textUpdateForWoker?: boolean;
225
- scene?: Scene;
226
225
  }
227
226
  export interface IUpdateSelectorCallbackPropsType {
228
227
  res?: IMainMessage;
@@ -261,6 +260,7 @@ export type IServiceWorkItem = {
261
260
  oldRect?: IRectType;
262
261
  totalRect?: IRectType;
263
262
  isDiff?: boolean;
263
+ imageBitmap?: ImageBitmap;
264
264
  };
265
265
  export type ILocalWorkItem = {
266
266
  toolsType: EToolsKey;
@@ -284,6 +284,7 @@ export type BaseNodeMapItem = {
284
284
  /** 是否被框选中,框选中的元素不能被其它人操作 */
285
285
  isSelected: boolean;
286
286
  isHid?: boolean;
287
+ eraserlines?: Map<string, Pick<BaseNodeMapItem, 'op' | 'opt'>>;
287
288
  };
288
289
  export type Size = {
289
290
  /**
@@ -0,0 +1,5 @@
1
+ export declare const loadImageToBitMap: (param: {
2
+ src: string;
3
+ isgl?: boolean;
4
+ isCache?: boolean;
5
+ }, imageCache?: Map<string, ImageBitmap>) => Promise<ImageBitmap | undefined>;
@@ -15,6 +15,7 @@ export declare function interRect(rect: IRectType, offset: number): {
15
15
  w: number;
16
16
  h: number;
17
17
  };
18
+ export declare function rectToBoundingPoints(rect: IRectType): number[];
18
19
  export declare function computRect(rect1?: IRectType, rect2?: IRectType): IRectType | undefined;
19
20
  export declare function computRectangle(rect1?: Rectangle, rect2?: Rectangle): Rectangle | undefined;
20
21
  export declare function getRectFromPoints(points: (Point2d | Vec2d)[], offset?: number): {
@@ -59,7 +60,9 @@ export declare function getRectScaleWPoint(rect: IRectType, scale: [number, numb
59
60
  export declare function getScalePoints(points: Vec2d[], scale: [number, number], originPos: Vec2d): Vec2d[];
60
61
  export declare function getRotatePoints(points: Vec2d[], originPos: Vec2d, angle: number): Vec2d[];
61
62
  export declare function rotatePoints(points: number[], originPos: [number, number], angle: number): void;
63
+ export declare function rotateLitePoints(points: number[], originPos: [number, number], angle: number): void;
62
64
  export declare function scalePoints(points: number[], originPos: [number, number], scale: [number, number], transition?: [number, number]): void;
65
+ export declare function scaleLitePoints(points: number[], originPos: [number, number], scale: [number, number], transition?: [number, number]): void;
63
66
  export declare function getNodeRect(key: string, layer?: Group, safeBorderPadding?: number): IRectType | undefined;
64
67
  export declare function isIntersectForPoint(point: [number, number], rect: IRectType): boolean;
65
68
  export declare const getLineSegIntersection: (p1: [number, number], p2: [number, number], p3: [number, number], p4: [number, number]) => [number, number] | null;
@@ -44,11 +44,20 @@ export declare abstract class WorkThreadEngineBase {
44
44
  };
45
45
  protected hasPriorityDraw: boolean;
46
46
  protected delayPostDoneResolve?: (bol: boolean) => void;
47
+ protected cacheImages: Map<string, ImageBitmap>;
48
+ protected imageResolveMap: Map<string, {
49
+ timer?: number;
50
+ resolve?: (workId: string) => void;
51
+ }>;
47
52
  constructor(viewId: string, opt: IWorkerInitOption, workerType: EWorkThreadType);
53
+ getCachedImages(imageSrc: string): ImageBitmap | undefined;
54
+ clearCacheImages(): void;
55
+ clearImageResolveMap(): void;
48
56
  setHasPriorityDraw(bol: boolean): void;
49
57
  getPriorityDraw(): boolean;
50
58
  setIsSafari(isSafari: boolean): void;
51
59
  on(msg: IWorkerMessage): Promise<void>;
60
+ loadImageBitMap(msg: Pick<IWorkerMessage, 'toolsType' | 'opt' | 'workId'>): Promise<ImageBitmap | undefined>;
52
61
  protected createLocalWork(data: IWorkerMessage): void;
53
62
  protected updateScene(offscreenCanvasOpt: IOffscreenCanvasOptionType): void;
54
63
  protected updateLayer(layerOpt: ILayerOptionType): void;
@@ -63,7 +72,7 @@ export declare abstract class WorkThreadEngineBase {
63
72
  private runBatchPostData;
64
73
  protected combinePostData(): IBatchMainMessage;
65
74
  protected safariFixRect(rect: IRectType, dpr: number): IRectType | undefined;
66
- protected getSceneRect(): IRectType;
75
+ getSceneRect(): IRectType;
67
76
  abstract combinePost(): Promise<void>;
68
77
  protected abstract getLayer(workLayer: ECanvasShowType): Group | undefined;
69
78
  abstract setCameraOpt(cameraOpt: ICameraOpt): void;
@@ -90,7 +99,7 @@ export declare abstract class LocalWork {
90
99
  setWorkOptions(workId: string, opt: BaseShapeOptions): void;
91
100
  createWorkShapeNode(opt: IActiveToolsDataType & {
92
101
  workId: string;
93
- }): import("../tools").PencilShape | import("../tools").LaserPenShape | import("../tools").EraserShape | import("../tools").StarShape | import("../tools/text").TextShape | import("../tools").SelectorShape | import("../tools").ImageShape | import("../tools").ArrowShape | import("../tools/straight").StraightShape | import("../tools").EllipseShape | import("../tools").PolygonShape | import("../tools").RectangleShape | import("../tools").SpeechBalloonShape | import("../tools/pencilEraser").PencilEraserShape | undefined;
102
+ }): import("../tools").PencilShape | import("../tools").LaserPenShape | import("../tools").EraserShape | import("../tools").StarShape | import("../tools/text").TextShape | import("../tools").SelectorShape | import("../tools/image").ImageShape | import("../tools").ArrowShape | import("../tools/straight").StraightShape | import("../tools").EllipseShape | import("../tools").PolygonShape | import("../tools").RectangleShape | import("../tools").SpeechBalloonShape | import("../tools/pencilEraserBitMap").BitMapEraserShape | import("../tools/pencilEraser").PencilEraserShape | undefined;
94
103
  setToolsOpt(opt: IActiveToolsDataType): void;
95
104
  getToolsOpt(): IActiveToolsDataType | undefined;
96
105
  clearWorkShapeNodeCache(workId: string): void;