@netless/appliance-plugin 1.1.18 → 1.1.19-beta.1
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 +318 -260
- package/cdn/cdn.js +1 -1
- package/cdn/fullWorker-3k30fq.js +439 -0
- package/cdn/subWorker-rWfN0e.js +439 -0
- package/dist/appliance-plugin.js +1 -1
- package/dist/appliance-plugin.mjs +7 -7
- package/dist/cdn.d.ts +2 -2
- package/dist/collector/index.d.ts +4 -4
- package/dist/collector/types.d.ts +2 -2
- package/dist/component/miniMap/index.d.ts +1 -1
- package/dist/component/miniMap/manager.d.ts +2 -2
- package/dist/component/miniMap/view.d.ts +1 -1
- package/dist/component/textEditor/index.d.ts +2 -2
- package/dist/component/textEditor/types.d.ts +2 -2
- package/dist/component/textEditor/view.d.ts +1 -1
- package/dist/core/index.d.ts +3 -3
- package/dist/core/mainEngine.d.ts +7 -3
- package/dist/core/mainThread/base.d.ts +4 -4
- package/dist/core/mainThread/index.d.ts +2 -2
- package/dist/core/mainThread/snapshotThread.d.ts +3 -3
- package/dist/core/mainThread/subLocalThread.d.ts +11 -6
- package/dist/core/mainThread/subServiceThread.d.ts +1 -1
- package/dist/core/mainThread/workerMainThread.d.ts +2 -2
- package/dist/core/msgEvent/copyNode/forMain.d.ts +2 -2
- package/dist/core/msgEvent/forMainThread.d.ts +4 -4
- package/dist/core/msgEvent/forWorker.d.ts +4 -4
- package/dist/core/msgEvent/index.d.ts +4 -4
- package/dist/core/tools/base.d.ts +3 -3
- package/dist/core/tools/index.d.ts +14 -14
- package/dist/core/tools/laserPen.d.ts +1 -1
- package/dist/core/tools/pencilEraser.d.ts +4 -34
- package/dist/core/tools/pencilEraserBitMap.d.ts +7 -30
- package/dist/core/tools/selector.d.ts +1 -1
- package/dist/core/types.d.ts +11 -9
- package/dist/core/utils/clipper.d.ts +1 -1
- package/dist/core/utils/getSvgPathFromPoints.d.ts +1 -1
- package/dist/core/utils/index.d.ts +4 -4
- package/dist/core/utils/primitives/Box2d.d.ts +4 -4
- package/dist/core/utils/proxy.d.ts +3 -4
- package/dist/core/worker/base.d.ts +5 -2
- package/dist/core/worker/fullWorkerLocal.d.ts +5 -11
- package/dist/cursors/index.d.ts +1 -1
- package/dist/fullWorker.js +142 -203
- package/dist/index-B4Ld7AM5.js +1 -0
- package/dist/index-BS5_t4VL.mjs +21267 -0
- package/dist/index-CG1H4AUQ.js +1 -0
- package/dist/{index-BmM-scQu.mjs → index-yLOzxVyY.mjs} +901 -658
- package/dist/plugin/baseViewContainerManager.d.ts +3 -3
- package/dist/plugin/const.d.ts +1 -0
- package/dist/plugin/multi/containerManager.d.ts +1 -1
- package/dist/plugin/types.d.ts +20 -11
- package/dist/style.css +1 -1
- package/dist/subWorker.js +142 -203
- package/dist/undo/index.d.ts +1 -1
- package/package.json +7 -1
- package/cdn/fullWorker-D_Qymn.js +0 -500
- package/cdn/subWorker-am2Vr9.js +0 -500
- package/dist/index-BRQCDzgF.mjs +0 -17608
- package/dist/index-C9F49Gge.js +0 -1
- package/dist/index-DUGXE2hv.js +0 -1
package/README.md
CHANGED
|
@@ -1,47 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
This plugin is based on the plugin mechanism of white-web-sdk, and realizes a set of whiteboard teaching AIDS drawing tools. At the same time, it is also based on @netless/window-manager, which can be used on multiple Windows.
|
|
6
|
-
|
|
7
|
-
## Introduction
|
|
8
|
-
|
|
1
|
+
# appliance-plugin
|
|
2
|
+
|
|
3
|
+
[中文文档](https://github.com/netless-io/fastboard/blob/main/docs/zh/appliance-plugin.md)
|
|
4
|
+
|
|
5
|
+
This plugin is based on the plugin mechanism of white-web-sdk, and realizes a set of whiteboard teaching AIDS drawing tools. At the same time, it is also based on @netless/window-manager, which can be used on multiple Windows.
|
|
6
|
+
|
|
7
|
+
## Introduction
|
|
8
|
+
|
|
9
9
|
appliance-plugin, Depend on [white-web-SDK](https://www.npmjs.com/package/white-web-sdk), [@netless/window-manager](https://www.npmjs.com/package/@netless/window-manager), And based on web API support for [offscreenCanvas](https://developer.mozilla.org/zh-CN/docs/Web/API/OffscreenCanvas).
|
|
10
10
|
|
|
11
|
-
## Principle
|
|
12
|
-
|
|
13
|
-
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
|
|
14
|
-
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.
|
|
15
|
-
|
|
16
|
-
## Plugin usage
|
|
17
|
-
|
|
18
|
-
### Install
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
npm install @netless/appliance-plugin
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Sign up for plugins
|
|
25
|
-
|
|
11
|
+
## Principle
|
|
12
|
+
|
|
13
|
+
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
|
|
14
|
+
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.
|
|
15
|
+
|
|
16
|
+
## Plugin usage
|
|
17
|
+
|
|
18
|
+
### Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @netless/appliance-plugin
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Sign up for plugins
|
|
25
|
+
|
|
26
26
|
Plug-ins can support two scenarios, their access plug-in names are different:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
|
|
28
|
+
- Multi-window 'ApplianceMultiPlugin'
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
import { ApplianceMultiPlugin } from "@netless/appliance-plugin";
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
- Single whiteboard 'ApplianceSinglePlugin'
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
import { ApplianceSinglePlugin } from "@netless/appliance-plugin";
|
|
38
|
+
```
|
|
39
|
+
|
|
36
40
|
> workerjs file cdn deployment
|
|
37
|
-
>
|
|
41
|
+
>
|
|
38
42
|
> We used two-worker concurrency to improve drawing efficiency, which improved it by more than 40% over single-thread efficiency. However, the common dependencies on the two worker files are repeated, so building directly into the package will greatly increase the package size. So we allow the workerjs file cdn deployment by simply deploying the file under @netless/appliance-plugin/cdn into the cdn and then configuring the c of the last two workerjs via the second parameter of getInstance in the plug-in, options.cdn The dn address is fine. This solves the problem of excessive package size
|
|
39
|
-
>
|
|
40
|
-
> - **The total package is about 300kB, and the two wokerjs are 600kB each** If you need to consider the size of the package you are building, select Configure cdn.
|
|
41
|
-
|
|
42
|
-
### Access mode reference
|
|
43
|
+
>
|
|
44
|
+
> - **The total package is about 300kB, and the two wokerjs are 600kB each** If you need to consider the size of the package you are building, select Configure cdn.
|
|
45
|
+
|
|
46
|
+
### Access mode reference
|
|
43
47
|
|
|
44
48
|
#### fastboard(interconnection with fastboard)
|
|
49
|
+
|
|
45
50
|
```js
|
|
46
51
|
// The method of importing worker.js is optional. If cdn is used, it does not need to be imported from dist. If dist is imported, it needs to be configured into options.cdn in the form of resource module and bolb inline. Such as '?raw', this requires packer support,vite default support '?raw',webpack needs to configure raw-loader or asset/source.
|
|
47
52
|
import fullWorkerString from '@netless/appliance-plugin/dist/fullWorker.js?raw';
|
|
@@ -107,12 +112,13 @@ const fastboard = await createFastboard({
|
|
|
107
112
|
```
|
|
108
113
|
|
|
109
114
|
#### Multi-window (Interconnecting with window-manager)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
import '@netless/
|
|
113
|
-
import
|
|
114
|
-
import {
|
|
115
|
-
import {
|
|
115
|
+
|
|
116
|
+
```js
|
|
117
|
+
import '@netless/window-manager/dist/style.css';
|
|
118
|
+
import '@netless/appliance-plugin/dist/style.css';
|
|
119
|
+
import { WhiteWebSdk } from "white-web-sdk";
|
|
120
|
+
import { WindowManager } from "@netless/window-manager";
|
|
121
|
+
import { ApplianceMultiPlugin } from '@netless/appliance-plugin';
|
|
116
122
|
// The method of importing worker.js is optional. If cdn is used, it does not need to be imported from dist. If dist is imported, it needs to be configured into options.cdn in the form of resource module and bolb inline. Such as '?raw', this requires packer support,vite default support '?raw',webpack needs to configure raw-loader or asset/source.
|
|
117
123
|
import fullWorkerString from '@netless/appliance-plugin/dist/fullWorker.js?raw';
|
|
118
124
|
import subWorkerString from '@netless/appliance-plugin/dist/subWorker.js?raw';
|
|
@@ -120,16 +126,16 @@ const fullWorkerBlob = new Blob([fullWorkerString], {type: 'text/javascript'});
|
|
|
120
126
|
const fullWorkerUrl = URL.createObjectURL(fullWorkerBlob);
|
|
121
127
|
const subWorkerBlob = new Blob([subWorkerString], {type: 'text/javascript'});
|
|
122
128
|
const subWorkerUrl = URL.createObjectURL(subWorkerBlob);
|
|
123
|
-
|
|
124
|
-
const whiteWebSdk = new WhiteWebSdk(...)
|
|
125
|
-
const room = await whiteWebSdk.joinRoom({
|
|
126
|
-
...
|
|
127
|
-
invisiblePlugins: [WindowManager, ApplianceMultiPlugin],
|
|
128
|
-
useMultiViews: true,
|
|
129
|
-
})
|
|
130
|
-
const manager = await WindowManager.mount({ room , container:elm, chessboard: true, cursor: true, supportAppliancePlugin: true});
|
|
131
|
-
if (manager) {
|
|
132
|
-
// await manager.switchMainViewToWriter();
|
|
129
|
+
|
|
130
|
+
const whiteWebSdk = new WhiteWebSdk(...)
|
|
131
|
+
const room = await whiteWebSdk.joinRoom({
|
|
132
|
+
...
|
|
133
|
+
invisiblePlugins: [WindowManager, ApplianceMultiPlugin],
|
|
134
|
+
useMultiViews: true,
|
|
135
|
+
})
|
|
136
|
+
const manager = await WindowManager.mount({ room , container:elm, chessboard: true, cursor: true, supportAppliancePlugin: true});
|
|
137
|
+
if (manager) {
|
|
138
|
+
// await manager.switchMainViewToWriter();
|
|
133
139
|
await ApplianceMultiPlugin.getInstance(manager,
|
|
134
140
|
{
|
|
135
141
|
options: {
|
|
@@ -139,15 +145,17 @@ await ApplianceMultiPlugin.getInstance(manager,
|
|
|
139
145
|
}
|
|
140
146
|
}
|
|
141
147
|
}
|
|
142
|
-
);
|
|
143
|
-
}
|
|
148
|
+
);
|
|
149
|
+
}
|
|
144
150
|
```
|
|
151
|
+
|
|
145
152
|
> **Note** the css file `import '@netless/appliance-plugin/dist/style.css'` needs to be imported into the project;
|
|
146
153
|
|
|
147
|
-
#### Single whiteboard (interconnection with white-web-sdk)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
import {
|
|
154
|
+
#### Single whiteboard (interconnection with white-web-sdk)
|
|
155
|
+
|
|
156
|
+
```js
|
|
157
|
+
import { WhiteWebSdk } from "white-web-sdk";
|
|
158
|
+
import { ApplianceSinglePlugin, ApplianceSigleWrapper } from '@netless/appliance-plugin';
|
|
151
159
|
// The method of importing worker.js is optional. If cdn is used, it does not need to be imported from dist. If dist is imported, it needs to be configured into options.cdn in the form of resource module and bolb inline. Such as '?raw', this requires packer support,vite default support '?raw',webpack needs to configure raw-loader or asset/source.
|
|
152
160
|
import fullWorkerString from '@netless/appliance-plugin/dist/fullWorker.js?raw';
|
|
153
161
|
import subWorkerString from '@netless/appliance-plugin/dist/subWorker.js?raw';
|
|
@@ -155,13 +163,13 @@ const fullWorkerBlob = new Blob([fullWorkerString], {type: 'text/javascript'});
|
|
|
155
163
|
const fullWorkerUrl = URL.createObjectURL(fullWorkerBlob);
|
|
156
164
|
const subWorkerBlob = new Blob([subWorkerString], {type: 'text/javascript'});
|
|
157
165
|
const subWorkerUrl = URL.createObjectURL(subWorkerBlob);
|
|
158
|
-
|
|
159
|
-
const whiteWebSdk = new WhiteWebSdk(...)
|
|
160
|
-
const room = await whiteWebSdk.joinRoom({
|
|
161
|
-
...
|
|
162
|
-
invisiblePlugins: [ApplianceSinglePlugin],
|
|
163
|
-
wrappedComponents: [ApplianceSigleWrapper]
|
|
164
|
-
})
|
|
166
|
+
|
|
167
|
+
const whiteWebSdk = new WhiteWebSdk(...)
|
|
168
|
+
const room = await whiteWebSdk.joinRoom({
|
|
169
|
+
...
|
|
170
|
+
invisiblePlugins: [ApplianceSinglePlugin],
|
|
171
|
+
wrappedComponents: [ApplianceSigleWrapper]
|
|
172
|
+
})
|
|
165
173
|
await ApplianceSinglePlugin.getInstance(room,
|
|
166
174
|
{
|
|
167
175
|
options: {
|
|
@@ -171,11 +179,13 @@ await ApplianceSinglePlugin.getInstance(room,
|
|
|
171
179
|
}
|
|
172
180
|
}
|
|
173
181
|
}
|
|
174
|
-
);
|
|
182
|
+
);
|
|
175
183
|
```
|
|
184
|
+
|
|
176
185
|
> **Note** the css file `import '@netless/appliance-plugin/dist/style.css'` needs to be imported into the project;
|
|
177
186
|
|
|
178
187
|
#### About ’?raw‘ webpack configuration
|
|
188
|
+
|
|
179
189
|
```js
|
|
180
190
|
module: {
|
|
181
191
|
rules: [
|
|
@@ -191,61 +201,67 @@ module: {
|
|
|
191
201
|
}
|
|
192
202
|
]
|
|
193
203
|
},
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
## Call introduction
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Call introduction
|
|
197
207
|
|
|
198
208
|
### api introduction
|
|
199
209
|
|
|
200
210
|
#### Optimize legacy interface
|
|
201
211
|
|
|
202
212
|
The plugin re-implements some of the interfaces of the same name on room or Windows Manager, but internally we have re-injected them back into the original object via injectMethodToObject. No changes are required for external users. As follows:
|
|
213
|
+
|
|
203
214
|
```js
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
215
|
+
// Internal hack
|
|
216
|
+
injectMethodToObject(windowmanager, "undo");
|
|
217
|
+
injectMethodToObject(windowmanager, "redo");
|
|
218
|
+
injectMethodToObject(windowmanager, "cleanCurrentScene");
|
|
219
|
+
injectMethodToObject(windowmanager, "insertImage");
|
|
220
|
+
injectMethodToObject(windowmanager, "completeImageUpload");
|
|
221
|
+
injectMethodToObject(windowmanager, "lockImage");
|
|
222
|
+
injectMethodToObject(room, "getImagesInformation");
|
|
223
|
+
injectMethodToObject(room, "callbacks");
|
|
224
|
+
injectMethodToObject(room, "screenshotToCanvasAsync");
|
|
225
|
+
injectMethodToObject(room, "getBoundingRectAsync");
|
|
226
|
+
injectMethodToObject(room, "scenePreviewAsync");
|
|
227
|
+
injectMethodToObject(windowmanager.mainView, "setMemberState");
|
|
228
|
+
// These we can see the call behavior through the front-end log, for example:
|
|
229
|
+
// [ApplianceMultiPlugin] setMemberState
|
|
230
|
+
// [ApplianceMultiPlugin] cleanCurrentScene
|
|
220
231
|
```
|
|
232
|
+
|
|
221
233
|
The following interfaces are involved:
|
|
222
234
|
|
|
223
|
-
1. Interface on room
|
|
224
|
-
|
|
225
|
-
- `
|
|
226
|
-
- `
|
|
227
|
-
- `
|
|
228
|
-
- `
|
|
229
|
-
- `
|
|
230
|
-
- `
|
|
231
|
-
- `
|
|
232
|
-
- `
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
- `
|
|
242
|
-
- `
|
|
243
|
-
- `
|
|
244
|
-
- `
|
|
245
|
-
- `
|
|
246
|
-
- `
|
|
247
|
-
|
|
248
|
-
|
|
235
|
+
1. Interface on room
|
|
236
|
+
|
|
237
|
+
- `setMemberState`
|
|
238
|
+
- `undo`
|
|
239
|
+
- `redo`
|
|
240
|
+
- `callbacks`
|
|
241
|
+
- `insertImage`
|
|
242
|
+
- `lockImage`
|
|
243
|
+
- `completeImageUpload`
|
|
244
|
+
- `getImagesInformation`
|
|
245
|
+
- `cleanCurrentScene`
|
|
246
|
+
|
|
247
|
+
2. windowmanager upper interface
|
|
248
|
+
|
|
249
|
+
- `cleanCurrentScene`
|
|
250
|
+
|
|
251
|
+
3. The mainview interface of windowmanager
|
|
252
|
+
|
|
253
|
+
- `setMemberState`
|
|
254
|
+
- `undo`
|
|
255
|
+
- `redo`
|
|
256
|
+
- `callbacks`
|
|
257
|
+
- `insertImage`
|
|
258
|
+
- `lockImage`
|
|
259
|
+
- `completeImageUpload`
|
|
260
|
+
- `getImagesInformation`
|
|
261
|
+
- `cleanCurrentScene`
|
|
262
|
+
|
|
263
|
+
4. Customize
|
|
264
|
+
|
|
249
265
|
- `getBoundingRectAsync` Replace the api `room.getBoundingRect`
|
|
250
266
|
- `screenshotToCanvasAsync` Replace the api `room.screenshotToCanvas`
|
|
251
267
|
- `scenePreviewAsync` Replace the api `room.scenePreview`
|
|
@@ -256,131 +272,169 @@ The following interfaces are involved:
|
|
|
256
272
|
- `disableEraseImage` Replace the api `room.disableEraseImage` **This method only suppert when currentApplianceName is `eraser`**
|
|
257
273
|
- `disableCameraTransform` Replace the api `room.disableCameraTransform`
|
|
258
274
|
|
|
259
|
-
5.Incompatible
|
|
275
|
+
5.Incompatible
|
|
276
|
+
|
|
260
277
|
- `exportScene` When the appliance-plugin is enabled, notes cannot be exported in room mode
|
|
261
278
|
- Server-side screenshot, after the appliance-plugin is turned on, notes cannot be obtained by calling server-side screenshot, but need to use `screenshotToCanvasAsync` to obtain the screenshot
|
|
262
279
|
|
|
263
280
|
#### New features
|
|
281
|
+
|
|
264
282
|
1. laserPen teaching aids (Version >=1.1.1)
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
283
|
+
```js
|
|
284
|
+
import { EStrokeType, ApplianceNames } from "@netless/appliance-plugin";
|
|
285
|
+
room.setMemberState({
|
|
286
|
+
currentApplianceName: ApplianceNames.laserPen,
|
|
287
|
+
strokeType: EStrokeType.Normal,
|
|
288
|
+
});
|
|
289
|
+
```
|
|
290
|
+

|
|
270
291
|
2. Extended Teaching AIDS (Version >=1.1.1)
|
|
271
|
-
```js
|
|
272
|
-
export enum EStrokeType {
|
|
273
|
-
/** Solid line */
|
|
274
|
-
Normal = 'Normal',
|
|
275
|
-
/** Line with pen edge */
|
|
276
|
-
Stroke = 'Stroke',
|
|
277
|
-
/** Dotted line */
|
|
278
|
-
Dotted = 'Dotted',
|
|
279
|
-
/** Long dotted line */
|
|
280
|
-
LongDotted = 'LongDotted'
|
|
281
|
-
};
|
|
282
|
-
export type ExtendMemberState = {
|
|
283
|
-
/** The teaching AIDS selected by the current user */
|
|
284
|
-
currentApplianceName: ApplianceNames;
|
|
285
|
-
/** Whether to open the pen tip */
|
|
286
|
-
strokeType? : EStrokeType;
|
|
287
|
-
/** Whether to delete the entire line segment */
|
|
288
|
-
isLine? : boolean;
|
|
289
|
-
/** Wireframe transparency */
|
|
290
|
-
strokeOpacity? : number;
|
|
291
|
-
/** Whether to turn on laser pointer */
|
|
292
|
-
useLaserPen? : boolean;
|
|
293
|
-
/** Laser pointer holding time, second */
|
|
294
|
-
duration? : number;
|
|
295
|
-
/** Fill style */
|
|
296
|
-
fillColor? : Color;
|
|
297
|
-
/** Fill transparency */
|
|
298
|
-
fillOpacity? : number;
|
|
299
|
-
/** The specific type of graph to draw when using shape */
|
|
300
|
-
shapeType? : ShapeType;
|
|
301
|
-
/** Number of polygon vertices */
|
|
302
|
-
vertices? :number;
|
|
303
|
-
/** Length of the inner vertex of the polygon */
|
|
304
|
-
innerVerticeStep? :number;
|
|
305
|
-
/** Ratio of the radius of the inner vertex of the polygon to the outer vertex */
|
|
306
|
-
innerRatio? : number;
|
|
307
|
-
/** Text transparency */
|
|
308
|
-
textOpacity? : number;
|
|
309
|
-
/** Text background color */
|
|
310
|
-
textBgColor? : Color;
|
|
311
|
-
/** Text background color transparency */
|
|
312
|
-
textBgOpacity? : number;
|
|
313
|
-
/** Location */
|
|
314
|
-
placement? : SpeechBalloonPlacement;
|
|
315
|
-
};
|
|
316
|
-
import { ExtendMemberState, ApplianceNames } from '@netless/appliance-plugin';
|
|
317
|
-
/** Set the state of teaching AIDS */
|
|
318
|
-
room.setMemberState({ ... } as ExtendMemberState);
|
|
319
|
-
manager.mainView.setMemberState({ ... } as ExtendMemberState);
|
|
320
|
-
appliance.setMemberState({ ... } as ExtendMemberState);
|
|
321
|
-
```
|
|
322
|
-
- Set stroke type:
|
|
323
|
-
```js
|
|
324
|
-
// Solid line
|
|
325
|
-
setMemberState({strokeType: EStrokeType.Normal });
|
|
326
|
-
// Line with pen edge
|
|
327
|
-
setMemberState({strokeType: EStrokeType.Stroke });
|
|
328
|
-
// Dotted line
|
|
329
|
-
setMemberState({strokeType: EStrokeType.Dotted });
|
|
330
|
-
// Long dotted line
|
|
331
|
-
setMemberState({strokeType: EStrokeType.LongDotted });
|
|
332
|
-
```
|
|
333
|
-

|
|
334
|
-
- Set stroke and shape border opacity (marker):
|
|
335
|
-
```js
|
|
336
|
-
setMemberState({strokeOpacity: 0.5 });
|
|
337
|
-
```
|
|
338
|
-

|
|
339
|
-
- Set text color, text opacity, text background color, text background opacity
|
|
340
|
-
```js
|
|
341
|
-
setMemberState({textOpacity: 0.5, textBgOpacity: 0.5, textBgColor:[0, 0, 0]});
|
|
342
|
-
```
|
|
343
|
-

|
|
344
|
-
- Set shape fill color and fill opacity
|
|
345
|
-
```js
|
|
346
|
-
setMemberState({fillOpacity: 0.5, fillColor:[0, 0, 0]});
|
|
347
|
-
```
|
|
348
|
-

|
|
349
|
-
- Custom regular polygon
|
|
350
|
-
```js
|
|
351
|
-
// regular pentagon
|
|
352
|
-
setMemberState({currentApplianceName: ApplianceNames.shape, shapeType: ShapeType.Polygon, vertices: 5});
|
|
353
|
-
```
|
|
354
|
-

|
|
355
|
-
- Custom star shape
|
|
356
|
-
```js
|
|
357
|
-
// fat hexagonal star
|
|
358
|
-
setMemberState({currentApplianceName: ApplianceNames.shape, shapeType: ShapeType.Star, vertices: 12, innerVerticeStep: 2, innerRatio: 0.8});
|
|
359
|
-
```
|
|
360
|
-

|
|
361
|
-
- Customize the placement of the speechballoon
|
|
362
|
-
```js
|
|
363
|
-
// The dialog box in the lower left corner
|
|
364
|
-
setMemberState({currentApplianceName: ApplianceNames.shape, shapeType: ShapeType.SpeechBalloon, placement: 'bottomLeft'});
|
|
365
|
-
```
|
|
366
|
-

|
|
367
292
|
|
|
293
|
+
```js
|
|
294
|
+
export enum EStrokeType {
|
|
295
|
+
/** Solid line */
|
|
296
|
+
Normal = 'Normal',
|
|
297
|
+
/** Line with pen edge */
|
|
298
|
+
Stroke = 'Stroke',
|
|
299
|
+
/** Dotted line */
|
|
300
|
+
Dotted = 'Dotted',
|
|
301
|
+
/** Long dotted line */
|
|
302
|
+
LongDotted = 'LongDotted'
|
|
303
|
+
};
|
|
304
|
+
export type ExtendMemberState = {
|
|
305
|
+
/** The teaching AIDS selected by the current user */
|
|
306
|
+
currentApplianceName: ApplianceNames;
|
|
307
|
+
/** Whether to open the pen tip */
|
|
308
|
+
strokeType? : EStrokeType;
|
|
309
|
+
/** Whether to delete the entire line segment */
|
|
310
|
+
isLine? : boolean;
|
|
311
|
+
/** Wireframe transparency */
|
|
312
|
+
strokeOpacity? : number;
|
|
313
|
+
/** Whether to turn on laser pointer */
|
|
314
|
+
useLaserPen? : boolean;
|
|
315
|
+
/** Laser pointer holding time, second */
|
|
316
|
+
duration? : number;
|
|
317
|
+
/** Fill style */
|
|
318
|
+
fillColor? : Color;
|
|
319
|
+
/** Fill transparency */
|
|
320
|
+
fillOpacity? : number;
|
|
321
|
+
/** The specific type of graph to draw when using shape */
|
|
322
|
+
shapeType? : ShapeType;
|
|
323
|
+
/** Number of polygon vertices */
|
|
324
|
+
vertices? :number;
|
|
325
|
+
/** Length of the inner vertex of the polygon */
|
|
326
|
+
innerVerticeStep? :number;
|
|
327
|
+
/** Ratio of the radius of the inner vertex of the polygon to the outer vertex */
|
|
328
|
+
innerRatio? : number;
|
|
329
|
+
/** Text transparency */
|
|
330
|
+
textOpacity? : number;
|
|
331
|
+
/** Text background color */
|
|
332
|
+
textBgColor? : Color;
|
|
333
|
+
/** Text background color transparency */
|
|
334
|
+
textBgOpacity? : number;
|
|
335
|
+
/** Location */
|
|
336
|
+
placement? : SpeechBalloonPlacement;
|
|
337
|
+
};
|
|
338
|
+
import { ExtendMemberState, ApplianceNames } from '@netless/appliance-plugin';
|
|
339
|
+
/** Set the state of teaching AIDS */
|
|
340
|
+
room.setMemberState({ ... } as ExtendMemberState);
|
|
341
|
+
manager.mainView.setMemberState({ ... } as ExtendMemberState);
|
|
342
|
+
appliance.setMemberState({ ... } as ExtendMemberState);
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
- Set stroke type:
|
|
346
|
+
|
|
347
|
+
```js
|
|
348
|
+
// Solid line
|
|
349
|
+
setMemberState({ strokeType: EStrokeType.Normal });
|
|
350
|
+
// Line with pen edge
|
|
351
|
+
setMemberState({ strokeType: EStrokeType.Stroke });
|
|
352
|
+
// Dotted line
|
|
353
|
+
setMemberState({ strokeType: EStrokeType.Dotted });
|
|
354
|
+
// Long dotted line
|
|
355
|
+
setMemberState({ strokeType: EStrokeType.LongDotted });
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+

|
|
359
|
+
- Set stroke and shape border opacity (marker):
|
|
360
|
+
|
|
361
|
+
```js
|
|
362
|
+
setMemberState({ strokeOpacity: 0.5 });
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+

|
|
366
|
+
- Set text color, text opacity, text background color, text background opacity
|
|
367
|
+
|
|
368
|
+
```js
|
|
369
|
+
setMemberState({
|
|
370
|
+
textOpacity: 0.5,
|
|
371
|
+
textBgOpacity: 0.5,
|
|
372
|
+
textBgColor: [0, 0, 0],
|
|
373
|
+
});
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+

|
|
377
|
+
- Set shape fill color and fill opacity
|
|
378
|
+
|
|
379
|
+
```js
|
|
380
|
+
setMemberState({ fillOpacity: 0.5, fillColor: [0, 0, 0] });
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+

|
|
384
|
+
- Custom regular polygon
|
|
385
|
+
|
|
386
|
+
```js
|
|
387
|
+
// regular pentagon
|
|
388
|
+
setMemberState({
|
|
389
|
+
currentApplianceName: ApplianceNames.shape,
|
|
390
|
+
shapeType: ShapeType.Polygon,
|
|
391
|
+
vertices: 5,
|
|
392
|
+
});
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+

|
|
396
|
+
- Custom star shape
|
|
397
|
+
|
|
398
|
+
```js
|
|
399
|
+
// fat hexagonal star
|
|
400
|
+
setMemberState({
|
|
401
|
+
currentApplianceName: ApplianceNames.shape,
|
|
402
|
+
shapeType: ShapeType.Star,
|
|
403
|
+
vertices: 12,
|
|
404
|
+
innerVerticeStep: 2,
|
|
405
|
+
innerRatio: 0.8,
|
|
406
|
+
});
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+

|
|
410
|
+
- Customize the placement of the speechballoon
|
|
411
|
+
|
|
412
|
+
```js
|
|
413
|
+
// The dialog box in the lower left corner
|
|
414
|
+
setMemberState({
|
|
415
|
+
currentApplianceName: ApplianceNames.shape,
|
|
416
|
+
shapeType: ShapeType.SpeechBalloon,
|
|
417
|
+
placement: "bottomLeft",
|
|
418
|
+
});
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+

|
|
368
422
|
|
|
369
423
|
3. Split screen display Elements (little whiteboard featrue), need to combine [`@netless/app-little-white-board`](https://github.com/netless-io/app-little-white-board) (Version >=1.1.3)
|
|
370
|
-
|
|
424
|
+

|
|
371
425
|
4. Minimap function (Version >=1.1.6)
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
426
|
+
```js
|
|
427
|
+
/** Create a minimap
|
|
428
|
+
* @param viewId ID of the whiteboard under windowManager. The ID of the main whiteboard is mainView, and the ID of other whiteboards is the appID of addApp() return
|
|
429
|
+
* @param div Small map DOM container
|
|
430
|
+
*/
|
|
431
|
+
createMiniMap(viewId: string, div: HTMLElement): Promise<void>;
|
|
432
|
+
/** Destroy minimap */
|
|
433
|
+
destroyMiniMap(viewId: string): Promise<void>;
|
|
434
|
+
```
|
|
435
|
+

|
|
382
436
|
5. Filter Elements (Version >=1.1.6)
|
|
383
|
-
|
|
437
|
+
`js
|
|
384
438
|
/** Filter Elements
|
|
385
439
|
* @param viewId ID of the whiteboard under windowManager. The ID of the main whiteboard is mainView, and the ID of other whiteboards is the appID of addApp() return
|
|
386
440
|
* @param filter filter condition
|
|
@@ -395,8 +449,8 @@ The following interfaces are involved:
|
|
|
395
449
|
* @param isSync Whether to synchronize data to other users. The default value is true, that is, the data will be synchronized to other users. Keep it the same as the filterRenderByUid setting
|
|
396
450
|
*/
|
|
397
451
|
cancelFilterRender(viewId: string, isSync?:boolean): void;
|
|
398
|
-
|
|
399
|
-
|
|
452
|
+
`
|
|
453
|
+

|
|
400
454
|
<!-- 6. Handwriting graphics automatic association function: 'autoDraw' (version >=1.1.7)
|
|
401
455
|
```js
|
|
402
456
|
export type AutoDrawOptions = {
|
|
@@ -417,35 +471,39 @@ The following interfaces are involved:
|
|
|
417
471
|
plugin.usePlugin(autoDrawPlugin);
|
|
418
472
|
```
|
|
419
473
|
 -->
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
```
|
|
474
|
+
|
|
475
|
+
### Configure parameters
|
|
476
|
+
|
|
477
|
+
`getInstance(wm: WindowManager, adaptor: ApplianceAdaptor)`
|
|
478
|
+
|
|
479
|
+
- wm: WindowManager\room\player. In multi-window mode, you pass WindowManager, and in single-window mode, you pass room or player(whiteboard playback mode).
|
|
480
|
+
- adaptor: configures the adapter.
|
|
481
|
+
- `options: AppliancePluginOptions`; The cdn addresses of both workers must be configured.
|
|
482
|
+
```js
|
|
483
|
+
export type AppliancePluginOptions = {
|
|
484
|
+
/** cdn Configuration item */
|
|
485
|
+
cdn: CdnOpt;
|
|
486
|
+
/** Synchronize data configuration items */
|
|
487
|
+
syncOpt? : SyncOpt;
|
|
488
|
+
/** Canvas configuration item */
|
|
489
|
+
canvasOpt? : CanvasOpt;
|
|
490
|
+
/** stroke width range */
|
|
491
|
+
strokeWidth?: {
|
|
492
|
+
min: number,
|
|
493
|
+
max: number,
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
```
|
|
497
|
+
- `cursorAdapter? : CursorAdapter`; This parameter is optional. In single whiteboard mode, customize the mouse style.
|
|
498
|
+
- `logger?: Logger`; This parameter is optional. Configure the log printer object. The default output is on the local console. If logs need to be uploaded to the specified server, you need to manually configure the configuration.
|
|
499
|
+
> If you need to upload the log to the whiteboard log server, configure the `room.logger` to this item。
|
|
500
|
+
|
|
501
|
+
### Front-end debugging introduction
|
|
502
|
+
|
|
503
|
+
During the interconnection process, if you want to understand and track the internal status of the plug-in, you can view the internal data through the following console commands.
|
|
504
|
+
|
|
505
|
+
```js
|
|
506
|
+
const applianPlugin = await ApplianceSinglePlugin.getInstance(...)
|
|
507
|
+
applianPlugin.CurrentManager // can see the package version number, internal state, etc
|
|
508
|
+
applianPlugin.CurrentManager.ConsoleWorkerInfo () // can check information to draw on the worker
|
|
509
|
+
```
|