@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
package/README.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# appliance-plugin
|
|
2
|
+
|
|
3
|
+
[中文文档](https://github.com/hqer927/appliance-plugin/blob/master/READMA.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
The plug-in is attached to the plug-in mechanism of white-web-sdk to achieve a set of whiteboard teaching AIDS, state synchronization, playback, scene switching and other functions still rely on white-web-sdk or window-manager.
|
|
6
|
+
|
|
7
|
+
## Introduction
|
|
8
|
+
|
|
9
|
+
A whiteboard pencil drawing plugin based on SpriteJS as a rendering engine.
|
|
10
|
+
|
|
11
|
+
The following two demos are implemented in the example folder for reference only.
|
|
12
|
+
| scenario | demo path | depends on |
|
|
13
|
+
| :-- | :----: | :-- |
|
|
14
|
+
| multi-window | example/src/multi.ts | @netless/window-manager, white-web-sdk |
|
|
15
|
+
| white-board | example/src/single.ts | white-web-sdk |
|
|
16
|
+
<!-- | fastboard | todo | todo | -->
|
|
17
|
+
|
|
18
|
+
## Principle
|
|
19
|
+
|
|
20
|
+
1. The plugin is mainly based on the 2D functionality of SpriteJS, supports webgl2 rendering, and is backward compatible with downgrades to webgl and canvas2d
|
|
21
|
+
2. The plugin uses the dual webWorker+offscreenCanvas mechanism to process the drawing calculation + rendering logic in a separate worker thread. Does not occupy cpu tasks of the main thread.
|
|
22
|
+
|
|
23
|
+
## Plugin usage
|
|
24
|
+
|
|
25
|
+
### Install
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @netless/appliance-plugin
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Sign up for plugins
|
|
32
|
+
|
|
33
|
+
Plug-ins can support two scenarios, their access plug-in names are different:
|
|
34
|
+
- Multi-window 'ApplianceMultiPlugin'
|
|
35
|
+
```js
|
|
36
|
+
// All bundled
|
|
37
|
+
import { ApplianceMultiPlugin } from '@netless/appliance-plugin';
|
|
38
|
+
// cdn
|
|
39
|
+
// import { ApplianceMultiPlugin } from '@netless/appliance-plugin/cdn';
|
|
40
|
+
```
|
|
41
|
+
- Single whiteboard 'ApplianceSinglePlugin'
|
|
42
|
+
```js
|
|
43
|
+
// All bundled
|
|
44
|
+
import { ApplianceSinglePlugin } from '@netless/appliance-plugin';
|
|
45
|
+
// cdn
|
|
46
|
+
// import { ApplianceSinglePlugin } from '@netless/appliance-plugin/cdn';
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
> About cdn version description
|
|
50
|
+
>
|
|
51
|
+
> Since worker is logic independent of main thread js, public packages in worker, such as spritejs, etc. These are all repeated into workerjs, so we have introduced the cdn version to include these public packages in the cdn
|
|
52
|
+
>
|
|
53
|
+
> - **cdn package is about 700kb, full package is about 2100kb.** If you need to consider the size of the package to be built, please choose reasonably.
|
|
54
|
+
> - The cdn version reduces the size of the package, but there are network problems, please fully consider it
|
|
55
|
+
|
|
56
|
+
### Access mode reference
|
|
57
|
+
|
|
58
|
+
#### Multi-window mode (Interconnecting with window-manager)
|
|
59
|
+
```js
|
|
60
|
+
import '@netless/window-manager/dist/style.css';
|
|
61
|
+
import '@netless/appliance-plugin/dist/style.css';
|
|
62
|
+
import { WhiteWebSdk } from "white-web-sdk";
|
|
63
|
+
import { WindowManager } from "@netless/window-manager";
|
|
64
|
+
// All bundled
|
|
65
|
+
import { ApplianceMultiPlugin } from '@netless/appliance-plugin';
|
|
66
|
+
// cdn
|
|
67
|
+
// import { ApplianceMultiPlugin } from '@netless/appliance-plugin/cdn';
|
|
68
|
+
|
|
69
|
+
const whiteWebSdk = new WhiteWebSdk(...)
|
|
70
|
+
const room = await whiteWebSdk.joinRoom({
|
|
71
|
+
...
|
|
72
|
+
invisiblePlugins: [WindowManager, ApplianceMultiPlugin],
|
|
73
|
+
useMultiViews: true,
|
|
74
|
+
})
|
|
75
|
+
const manager = await WindowManager.mount({ room , container:elm, chessboard: true, cursor: true, supportTeachingAidsPlugin: true});
|
|
76
|
+
if (manager) {
|
|
77
|
+
await manager.switchMainViewToWriter();
|
|
78
|
+
await ApplianceMultiPlugin.getInstance(manager);
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
#### Single whiteboard (interconnection with white-web-sdk)
|
|
82
|
+
```js
|
|
83
|
+
import { WhiteWebSdk } from "white-web-sdk";
|
|
84
|
+
// All bundled
|
|
85
|
+
import { ApplianceSinglePlugin, ApplianceSigleWrapper } from '@netless/appliance-plugin';
|
|
86
|
+
// cdn
|
|
87
|
+
// import { ApplianceMultiPlugin } from '@netless/appliance-plugin/cdn';
|
|
88
|
+
|
|
89
|
+
const whiteWebSdk = new WhiteWebSdk(...)
|
|
90
|
+
const room = await whiteWebSdk.joinRoom({
|
|
91
|
+
...
|
|
92
|
+
invisiblePlugins: [ApplianceSinglePlugin],
|
|
93
|
+
wrappedComponents: [ApplianceSigleWrapper]
|
|
94
|
+
})
|
|
95
|
+
await ApplianceSinglePlugin.getInstance(room);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Call introduction
|
|
99
|
+
The plug-in re-implements some interfaces of the same name on room or window or manager. If you do not use the interface on the plug-in, you will not get the desired effect. But we can use injectMethodToObject to re-inject it back into the original object to get the plugin's intended effect. As follows:
|
|
100
|
+
1. Interface on room
|
|
101
|
+
- `setMemberState`
|
|
102
|
+
- `undo`
|
|
103
|
+
- `redo`
|
|
104
|
+
- `callbacks`
|
|
105
|
+
- `insertImage`
|
|
106
|
+
- `lockImage`
|
|
107
|
+
- `completeImageUpload`
|
|
108
|
+
- `getImagesInformation`
|
|
109
|
+
- `cleanCurrentScene`
|
|
110
|
+
|
|
111
|
+
2. windowmanager upper interface
|
|
112
|
+
- `cleanCurrentScene`
|
|
113
|
+
|
|
114
|
+
3. The mainview interface of windowmanager
|
|
115
|
+
- `setMemberState`
|
|
116
|
+
- `undo`
|
|
117
|
+
- `redo`
|
|
118
|
+
- `callbacks`
|
|
119
|
+
- `insertImage`
|
|
120
|
+
- `lockImage`
|
|
121
|
+
- `completeImageUpload`
|
|
122
|
+
- `getImagesInformation`
|
|
123
|
+
- `cleanCurrentScene`
|
|
124
|
+
|
|
125
|
+
4. Customize
|
|
126
|
+
- `getBoundingRectAsync`
|
|
127
|
+
- `screenshotToCanvasAsync`
|
|
128
|
+
- `scenePreviewAsync`
|
|
129
|
+
- `destroy`
|
|
130
|
+
- `injectMethodToObject`
|
|
131
|
+
|
|
132
|
+
**The injectMethodToObject interface can rebind the plugin's reimplemented method to the desired object.** For example:
|
|
133
|
+
|
|
134
|
+
```js
|
|
135
|
+
// The purpose is to bind the plugin's undo operation to room. Keep outside calls to undo logic from room.
|
|
136
|
+
plugin.injectMethodToObject(room,'undo');
|
|
137
|
+
```
|
|
138
|
+
So, the interface of the same name on room,window-manager, or Window-Manager.mainView can be injected into the original object using injectMethodToObject.
|