@netless/appliance-plugin 1.1.31 → 1.1.33-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/READMA.zh-CN.md +9 -6
- package/README.md +293 -32
- package/cdn/cdn.js +1 -1
- package/cdn/{fullWorker-8cQCRH.js → fullWorker-D5ZxtP.js} +98 -98
- package/cdn/{subWorker-Bj1Oy7.js → subWorker-DJi31K.js} +98 -98
- package/dist/appliance-plugin.js +1 -1
- package/dist/appliance-plugin.mjs +13 -14
- package/dist/component/textEditor/types.d.ts +2 -2
- package/dist/core/enum.d.ts +1 -9
- package/dist/core/mainEngine.d.ts +7 -7
- package/dist/core/msgEvent/rotateNode/forMain.d.ts +2 -2
- package/dist/core/msgEvent/scaleNode/forMain.d.ts +2 -2
- package/dist/core/msgEvent/setColor/forMain.d.ts +2 -2
- package/dist/core/msgEvent/setPoint/forMain.d.ts +2 -2
- package/dist/core/msgEvent/translateNode/forMain.d.ts +2 -2
- package/dist/core/plugin.d.ts +2 -2
- package/dist/core/tools/arrow.d.ts +2 -2
- package/dist/core/tools/base.d.ts +2 -2
- package/dist/core/tools/ellipse.d.ts +2 -2
- package/dist/core/tools/pencil.d.ts +2 -2
- package/dist/core/tools/polygon.d.ts +2 -2
- package/dist/core/tools/rectangle.d.ts +2 -2
- package/dist/core/tools/speechBalloon.d.ts +2 -2
- package/dist/core/tools/star.d.ts +2 -2
- package/dist/core/tools/straight.d.ts +2 -2
- package/dist/core/tools/utils.d.ts +0 -3
- package/dist/core/types.d.ts +6 -6
- package/dist/core/worker/base.d.ts +2 -2
- package/dist/cursors/index.d.ts +3 -3
- package/dist/fullWorker.js +98 -98
- package/dist/{index-MwM-TUUF.mjs → index-C7U3tEJL.mjs} +80 -89
- package/dist/{index-DiHYEAGm.mjs → index-COnrz1Bl.mjs} +1029 -1031
- package/dist/index-CbCGd4f7.js +1 -0
- package/dist/{index-CpRTvTdJ.mjs → index-CxKr64Ya.mjs} +1 -1
- package/dist/index-ht-Ylmvp.js +1 -0
- package/dist/{index-XJ7wx0mr.js → index-u7Hv85FE.js} +1 -1
- package/dist/plugin/baseApplianceManager.d.ts +3 -3
- package/dist/plugin/types.d.ts +2 -3
- package/dist/subWorker.js +98 -98
- package/package.json +1 -1
- package/dist/index-D-zGeAx1.js +0 -1
- package/dist/index-OfIZzgAi.js +0 -1
package/READMA.zh-CN.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# appliance-plugin
|
|
2
2
|
|
|
3
|
-
[English Documentation](
|
|
3
|
+
[English Documentation](https://github.com/netless-io/fastboard/blob/main/docs/en/appliance-plugin.md)
|
|
4
4
|
|
|
5
5
|
该插件基于 white-web-sdk 的插件机制,实现了一套功能丰富的白板教具绘制工具。同时也基于 @netless/window-manager,实现了可在多窗口上使用。
|
|
6
6
|
|
|
@@ -309,9 +309,9 @@ injectMethodToObject(windowmanager.mainView,'setMemberState');
|
|
|
309
309
|
- `getElements` - 获取场景下的所有元素 (Version >=1.1.19)
|
|
310
310
|
- `stopDraw` - 停止Draw事件 (Version >=1.1.19)
|
|
311
311
|
- `setViewLocalScenePathChange` - 设置白板本地场景路径变化 (Version >=1.1.27)
|
|
312
|
-
- `insertMarkmap` - 插入markdow文本到白板 (Version >=1.1.
|
|
313
|
-
- `updateMarkmap` - 修改白板中的markdow文本 (Version >=1.1.
|
|
314
|
-
- `insertBackgroundImage` - 插入白板的背景图片 (Version >=1.1.
|
|
312
|
+
- `insertMarkmap` - 插入markdow文本到白板 (Version >=1.1.32) **该方法需要开启extras.useBackgroundThread**
|
|
313
|
+
- `updateMarkmap` - 修改白板中的markdow文本 (Version >=1.1.32) **该方法需要开启extras.useBackgroundThread**
|
|
314
|
+
- `insertBackgroundImage` - 插入白板的背景图片 (Version >=1.1.32) **该方法需要开启extras.useBackgroundThread**
|
|
315
315
|
|
|
316
316
|
5. 不兼容接口
|
|
317
317
|
- [`exportScene`](https://doc.shengwang.cn/api-ref/whiteboard/javascript/interfaces/room#exportScene) - appliance-plugin 开启后,笔记不能按 room 的方式导出
|
|
@@ -638,7 +638,7 @@ plugin.usePlugin(autoDrawPlugin);
|
|
|
638
638
|
```
|
|
639
639
|

|
|
640
640
|
|
|
641
|
-
##### 插入思维导图(需要markdown文本)
|
|
641
|
+
##### 插入思维导图(需要markdown文本) (Version >=1.1.32)
|
|
642
642
|
```ts
|
|
643
643
|
import { ApplianceMultiPlugin } from '@netless/appliance-plugin';
|
|
644
644
|
const plugin = await ApplianceMultiPlugin.getInstance(manager, {
|
|
@@ -684,7 +684,7 @@ plugin.updateMarkmap(viewId, markId, {
|
|
|
684
684
|
|
|
685
685
|
```
|
|
686
686
|

|
|
687
|
-
##### 插入背景图
|
|
687
|
+
##### 插入背景图 (Version >=1.1.32)
|
|
688
688
|
```ts
|
|
689
689
|
import { ApplianceMultiPlugin } from '@netless/appliance-plugin';
|
|
690
690
|
const plugin = await ApplianceMultiPlugin.getInstance(manager, {
|
|
@@ -939,3 +939,6 @@ MIT License
|
|
|
939
939
|
- [@netless/window-manager](https://www.npmjs.com/package/@netless/window-manager)
|
|
940
940
|
- [fastboard](https://github.com/netless-io/fastboard)
|
|
941
941
|
- [官方文档](https://doc.shengwang.cn/)
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
## [changelog](https://github.com/duty-os/appliance-plugin/blob/master/CHANGELOG.md)
|
package/README.md
CHANGED
|
@@ -6,13 +6,38 @@ This plugin is based on the plugin mechanism of white-web-sdk, and realizes a se
|
|
|
6
6
|
|
|
7
7
|
## Introduction
|
|
8
8
|
|
|
9
|
-
appliance-plugin
|
|
9
|
+
appliance-plugin is a high-performance whiteboard drawing plugin that depends on [white-web-sdk](https://www.npmjs.com/package/white-web-sdk) and [@netless/window-manager](https://www.npmjs.com/package/@netless/window-manager), and is based on Web API support for [OffscreenCanvas](https://developer.mozilla.org/zh-CN/docs/Web/API/OffscreenCanvas).
|
|
10
|
+
|
|
11
|
+
### Key Features
|
|
12
|
+
|
|
13
|
+
- 🎨 **Rich Drawing Tools**: Supports pencil, eraser, shape tools, text, images, and more
|
|
14
|
+
- ⚡ **High Performance Rendering**: Uses dual WebWorker + OffscreenCanvas mechanism, improving drawing efficiency by more than 40% compared to the main thread
|
|
15
|
+
- 🖼️ **Multi-window Support**: Supports multi-window scenarios, can be used independently on different windows
|
|
16
|
+
- 🎯 **Laser Pen Tool**: Supports laser pen functionality, suitable for presentation scenarios
|
|
17
|
+
- 📝 **Text Editing**: Supports text insertion, editing, and style settings
|
|
18
|
+
- 🗺️ **Minimap Function**: Provides minimap navigation for viewing overall content
|
|
19
|
+
- 🔄 **Undo/Redo**: Supports global undo/redo functionality
|
|
20
|
+
- 🎭 **Custom Styles**: Supports custom brush styles, text styles, etc.
|
|
21
|
+
- 🔌 **Plugin Extension**: Supports extending functionality through plugin mechanism (e.g., autoDraw handwriting graphics auto-association)
|
|
10
22
|
|
|
11
23
|
## Principle
|
|
12
24
|
|
|
13
|
-
1. The plugin is mainly based on
|
|
14
|
-
2. The plugin uses the dual WebWorker + OffscreenCanvas mechanism to process
|
|
15
|
-
|
|
25
|
+
1. **Rendering Engine**: The plugin is mainly based on SpriteJS's 2D functionality, supports WebGL2 rendering, and is backward compatible with downgrades to WebGL and Canvas2D.
|
|
26
|
+
2. **Multi-threaded Architecture**: The plugin uses the dual WebWorker + OffscreenCanvas mechanism to process drawing calculations and rendering logic in independent worker threads, not occupying the CPU tasks of the main thread.
|
|
27
|
+
- **Full Worker**: Thread responsible for drawing complete data
|
|
28
|
+
- **Sub Worker**: Thread responsible for drawing one frame of data
|
|
29
|
+
3. **Compatibility Handling**: For mobile terminals that do not support OffscreenCanvas, it will automatically downgrade to main thread processing.
|
|
30
|
+
|
|
31
|
+
### Supported Drawing Tools
|
|
32
|
+
|
|
33
|
+
The plugin supports the following drawing tools:
|
|
34
|
+
|
|
35
|
+
- **Basic Tools**: Pencil, eraser, partial eraser, bitmap eraser, selector tool, hand tool
|
|
36
|
+
- **Shape Tools**: Straight line, arrow, rectangle, circle, triangle, diamond, polygon, star, speech balloon
|
|
37
|
+
- **Text Tool**: Supports text input, editing, and style settings
|
|
38
|
+
- **Image Tool**: Supports image insertion and editing
|
|
39
|
+
- **Special Tools**: Laser pen, background SVG
|
|
40
|
+
- **Interactive Tools**: Click interactive tool (for plugin custom behavior)
|
|
16
41
|
|
|
17
42
|
## Plugin usage
|
|
18
43
|
|
|
@@ -233,43 +258,43 @@ injectMethodToObject(windowmanager.mainView,'setMemberState');
|
|
|
233
258
|
The following interfaces are involved:
|
|
234
259
|
|
|
235
260
|
1. Interfaces on room
|
|
236
|
-
- [`setMemberState`](https://
|
|
237
|
-
- [`undo`](https://
|
|
238
|
-
- [`redo`](https://
|
|
239
|
-
- [`callbacks`](https://
|
|
240
|
-
- [`insertImage`](https://
|
|
241
|
-
- [`lockImage`](https://
|
|
242
|
-
- [`completeImageUpload`](https://
|
|
261
|
+
- [`setMemberState`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#setmemberstate)
|
|
262
|
+
- [`undo`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#undo)
|
|
263
|
+
- [`redo`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#redo)
|
|
264
|
+
- [`callbacks`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#callbacks)
|
|
265
|
+
- [`insertImage`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#insertimage)
|
|
266
|
+
- [`lockImage`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#lockimage)
|
|
267
|
+
- [`completeImageUpload`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#completeimageupload)
|
|
243
268
|
- `getImagesInformation`
|
|
244
|
-
- [`cleanCurrentScene`](https://
|
|
269
|
+
- [`cleanCurrentScene`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#cleancurrentscene)
|
|
245
270
|
|
|
246
271
|
2. WindowManager interfaces
|
|
247
|
-
- [`cleanCurrentScene`](https://
|
|
248
|
-
- [`canUndoSteps`](https://
|
|
249
|
-
- [`canRedoSteps`](https://
|
|
272
|
+
- [`cleanCurrentScene`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#cleancurrentscene)
|
|
273
|
+
- [`canUndoSteps`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#canundosteps)
|
|
274
|
+
- [`canRedoSteps`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#canredosteps)
|
|
250
275
|
|
|
251
276
|
3. Interfaces on WindowManager's mainView
|
|
252
|
-
- [`setMemberState`](https://
|
|
253
|
-
- [`undo`](https://
|
|
254
|
-
- [`redo`](https://
|
|
255
|
-
- [`callbacks`](https://
|
|
256
|
-
- [`insertImage`](https://
|
|
257
|
-
- [`lockImage`](https://
|
|
258
|
-
- [`completeImageUpload`](https://
|
|
277
|
+
- [`setMemberState`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#setmemberstate)
|
|
278
|
+
- [`undo`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#undo)
|
|
279
|
+
- [`redo`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#redo)
|
|
280
|
+
- [`callbacks`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#callbacks)
|
|
281
|
+
- [`insertImage`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#insertimage)
|
|
282
|
+
- [`lockImage`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#lockimage)
|
|
283
|
+
- [`completeImageUpload`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#completeimageupload)
|
|
259
284
|
- `getImagesInformation`
|
|
260
|
-
- [`cleanCurrentScene`](https://
|
|
285
|
+
- [`cleanCurrentScene`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#cleancurrentscene)
|
|
261
286
|
|
|
262
287
|
4. Custom interfaces
|
|
263
288
|
- `getBoundingRectAsync` - Replace interface `room.getBoundingRect`
|
|
264
|
-
- `screenshotToCanvasAsync` - Replace interface [room.
|
|
265
|
-
- `scenePreviewAsync` - Replace interface [room.scenePreview](https://
|
|
266
|
-
- `fillSceneSnapshotAsync` - Replace interface [room.fillSceneSnapshot](https://
|
|
289
|
+
- `screenshotToCanvasAsync` - Replace interface [room.screenshotToCanvasAsync](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#screenshottocanvasasync)
|
|
290
|
+
- `scenePreviewAsync` - Replace interface [room.scenePreview](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#scenepreview)
|
|
291
|
+
- `fillSceneSnapshotAsync` - Replace interface [room.fillSceneSnapshot](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#fillscenesnapshot)
|
|
267
292
|
- `destroy` - Destroy the instance of appliance-plugin
|
|
268
293
|
- `addListener` - Add appliance-plugin internal event listener
|
|
269
294
|
- `removeListener` - Remove appliance-plugin internal event listener
|
|
270
|
-
- `disableDeviceInputs` - Replace interface [room.disableDeviceInputs](https://
|
|
271
|
-
- `disableEraseImage` - Replace interface [room.disableEraseImage](https://
|
|
272
|
-
- `disableCameraTransform` - Replace interface [room.disableCameraTransform](https://
|
|
295
|
+
- `disableDeviceInputs` - Replace interface [room.disableDeviceInputs](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#disabledeviceinputs)
|
|
296
|
+
- `disableEraseImage` - Replace interface [room.disableEraseImage](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#disableeraseimage) **This method only prohibits the eraser that erases the entire image from erasing images, partial eraser is invalid**
|
|
297
|
+
- `disableCameraTransform` - Replace interface [room.disableCameraTransform](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#disablecameratransform) (Version >=1.1.17)
|
|
273
298
|
- `insertText` - Insert text at the specified position (Version >=1.1.18)
|
|
274
299
|
- `updateText` - Edit the content of the specified text (Version >=1.1.18)
|
|
275
300
|
- `blurText` - Remove text focus (Version >=1.1.19)
|
|
@@ -277,10 +302,13 @@ The following interfaces are involved:
|
|
|
277
302
|
- `getElements` - Get all elements in the specified scene (Version >=1.1.19)
|
|
278
303
|
- `stopDraw` - Stop Draw event (Version >=1.1.19)
|
|
279
304
|
- `setViewLocalScenePathChange` - Set the local scene path change for the whiteboard view (Version >=1.1.27)
|
|
305
|
+
- `insertMarkmap` - Insert markdown text to whiteboard (Version >=1.1.32) **This method requires enabling extras.useBackgroundThread**
|
|
306
|
+
- `updateMarkmap` - Update markdown text in whiteboard (Version >=1.1.32) **This method requires enabling extras.useBackgroundThread**
|
|
307
|
+
- `insertBackgroundImage` - Insert whiteboard background image (Version >=1.1.32) **This method requires enabling extras.useBackgroundThread**
|
|
280
308
|
|
|
281
309
|
5. Incompatible interfaces
|
|
282
|
-
- [`exportScene`](https://
|
|
283
|
-
- [Server-side screenshot](https://
|
|
310
|
+
- [`exportScene`](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/interfaces/room.html#exportscene) - After appliance-plugin is enabled, notes cannot be exported in room mode
|
|
311
|
+
- [Server-side screenshot](https://docs.agora.io/en/interactive-whiteboard/reference/whiteboard-api/screenshots?platform=web#screenshot-a-scene-post) - After appliance-plugin is enabled, notes cannot be obtained by calling server-side screenshot, but need to use `screenshotToCanvasAsync` to obtain the screenshot
|
|
284
312
|
|
|
285
313
|
#### New Features
|
|
286
314
|
##### Laser Pen Tool (Version >=1.1.1)
|
|
@@ -291,7 +319,7 @@ room.setMemberState({currentApplianceName: ApplianceNames.laserPen, strokeType:
|
|
|
291
319
|

|
|
292
320
|
|
|
293
321
|
##### Extended Tools (Version >=1.1.1)
|
|
294
|
-
On the original [whiteboard tools](https://
|
|
322
|
+
On the original [whiteboard tools](https://api-ref.agora.io/en/interactive-whiteboard-sdk/web/2.x/globals.html#memberstate) type, some extended function attributes have been added, as follows:
|
|
295
323
|
|
|
296
324
|
```js
|
|
297
325
|
export enum EStrokeType {
|
|
@@ -574,6 +602,75 @@ html {
|
|
|
574
602
|
}
|
|
575
603
|
```
|
|
576
604
|
|
|
605
|
+
##### Insert Mind Map (requires markdown text) (Version >=1.1.32)
|
|
606
|
+
```ts
|
|
607
|
+
import { ApplianceMultiPlugin } from '@netless/appliance-plugin';
|
|
608
|
+
const plugin = await ApplianceMultiPlugin.getInstance(manager, {
|
|
609
|
+
options: {
|
|
610
|
+
cdn: {...}
|
|
611
|
+
extras: {
|
|
612
|
+
...,
|
|
613
|
+
useBackgroundThread: true,
|
|
614
|
+
}
|
|
615
|
+
},
|
|
616
|
+
});
|
|
617
|
+
const markId = await plugin.insertMarkmap(viewId, {
|
|
618
|
+
data: `# First Level Title
|
|
619
|
+
## Second Level Title 1
|
|
620
|
+
### Third Level Title 1
|
|
621
|
+
### Third Level Title 2
|
|
622
|
+
#### Fourth Level Title 1
|
|
623
|
+
#### Fourth Level Title 2
|
|
624
|
+
#### Fourth Level Title 3
|
|
625
|
+
## Second Level Title 2
|
|
626
|
+
### Third Level Title 1
|
|
627
|
+
### Third Level Title 2`,
|
|
628
|
+
uuid: 'unique identifier',
|
|
629
|
+
centerX: 0,
|
|
630
|
+
centerY: 0,
|
|
631
|
+
width: 200,
|
|
632
|
+
height: 200,
|
|
633
|
+
locked: false,
|
|
634
|
+
});
|
|
635
|
+
plugin.updateMarkmap(viewId, markId, {
|
|
636
|
+
data: `# First Level Title
|
|
637
|
+
## Second Level Title 1
|
|
638
|
+
## Second Level Title 2
|
|
639
|
+
### Third Level Title 1
|
|
640
|
+
### Third Level Title 2`,
|
|
641
|
+
uuid: 'unique identifier',
|
|
642
|
+
centerX: 0,
|
|
643
|
+
centerY: 0,
|
|
644
|
+
width: 200,
|
|
645
|
+
height: 200,
|
|
646
|
+
locked: false,
|
|
647
|
+
} )
|
|
648
|
+
|
|
649
|
+
```
|
|
650
|
+

|
|
651
|
+
##### Insert Background Image (Version >=1.1.32)
|
|
652
|
+
```ts
|
|
653
|
+
import { ApplianceMultiPlugin } from '@netless/appliance-plugin';
|
|
654
|
+
const plugin = await ApplianceMultiPlugin.getInstance(manager, {
|
|
655
|
+
options: {
|
|
656
|
+
cdn: {...}
|
|
657
|
+
extras: {
|
|
658
|
+
...,
|
|
659
|
+
useBackgroundThread: true,
|
|
660
|
+
}
|
|
661
|
+
},
|
|
662
|
+
});
|
|
663
|
+
plugin.insertBackgroundImage(viewId, {
|
|
664
|
+
src: 'https://example.com/background.png'
|
|
665
|
+
uuid: 'unique identifier',
|
|
666
|
+
centerX: 0,
|
|
667
|
+
centerY: 0,
|
|
668
|
+
width: 200,
|
|
669
|
+
height: 200,
|
|
670
|
+
locked: true,
|
|
671
|
+
})
|
|
672
|
+
```
|
|
673
|
+
|
|
577
674
|
##### Handwriting graphics automatic association function:`autoDraw`, need to combine [@netless/appliance-extend-auto-draw-plugin](https://www.npmjs.com/package/@netless/appliance-extend-auto-draw-plugin)
|
|
578
675
|
```js
|
|
579
676
|
export interface AutoDrawOptions {
|
|
@@ -654,6 +751,11 @@ plugin.usePlugin(autoDrawPlugin);
|
|
|
654
751
|
* mainThread: Use main thread, canvas drawing data.
|
|
655
752
|
*/
|
|
656
753
|
useWorker?: UseWorkerType;
|
|
754
|
+
/** Whether to use backgroundThread, default value is ``false``
|
|
755
|
+
* true: Use backgroundThread, can call ``insertMarkmap``, ``updateMarkmap``, ``insertBackgroundImage``
|
|
756
|
+
* false: Do not use backgroundThread
|
|
757
|
+
*/
|
|
758
|
+
useBackgroundThread?: boolean;
|
|
657
759
|
/** Synchronization data configuration item */
|
|
658
760
|
syncOpt?: SyncOpt;
|
|
659
761
|
/** Canvas configuration item */
|
|
@@ -690,3 +792,162 @@ const appliancePlugin = await ApplianceSinglePlugin.getInstance(...)
|
|
|
690
792
|
appliancePlugin.currentManager // Can view package version number, internal status, etc.
|
|
691
793
|
appliancePlugin.currentManager.consoleWorkerInfo() // Can view drawing information on worker
|
|
692
794
|
```
|
|
795
|
+
|
|
796
|
+
## Usage Examples
|
|
797
|
+
|
|
798
|
+
### Basic Usage Example
|
|
799
|
+
|
|
800
|
+
```js
|
|
801
|
+
import { ApplianceSinglePlugin } from '@netless/appliance-plugin';
|
|
802
|
+
import '@netless/appliance-plugin/dist/style.css';
|
|
803
|
+
|
|
804
|
+
// Method 1: Using CDN (recommended for production)
|
|
805
|
+
const plugin = await ApplianceSinglePlugin.getInstance(room, {
|
|
806
|
+
options: {
|
|
807
|
+
cdn: {
|
|
808
|
+
fullWorkerUrl: 'https://your-cdn.com/fullWorker.js',
|
|
809
|
+
subWorkerUrl: 'https://your-cdn.com/subWorker.js',
|
|
810
|
+
},
|
|
811
|
+
},
|
|
812
|
+
});
|
|
813
|
+
|
|
814
|
+
// Method 2: Using local worker files (suitable for development)
|
|
815
|
+
import fullWorkerString from '@netless/appliance-plugin/dist/fullWorker.js?raw';
|
|
816
|
+
import subWorkerString from '@netless/appliance-plugin/dist/subWorker.js?raw';
|
|
817
|
+
const fullWorkerBlob = new Blob([fullWorkerString], {type: 'text/javascript'});
|
|
818
|
+
const fullWorkerUrl = URL.createObjectURL(fullWorkerBlob);
|
|
819
|
+
const subWorkerBlob = new Blob([subWorkerString], {type: 'text/javascript'});
|
|
820
|
+
const subWorkerUrl = URL.createObjectURL(subWorkerBlob);
|
|
821
|
+
|
|
822
|
+
const plugin = await ApplianceSinglePlugin.getInstance(room, {
|
|
823
|
+
options: {
|
|
824
|
+
cdn: {
|
|
825
|
+
fullWorkerUrl,
|
|
826
|
+
subWorkerUrl,
|
|
827
|
+
},
|
|
828
|
+
},
|
|
829
|
+
});
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
### Switch Drawing Tools
|
|
833
|
+
|
|
834
|
+
```js
|
|
835
|
+
import { ApplianceNames, EStrokeType } from '@netless/appliance-plugin';
|
|
836
|
+
|
|
837
|
+
// Switch to pencil tool
|
|
838
|
+
room.setMemberState({ currentApplianceName: ApplianceNames.pencil });
|
|
839
|
+
|
|
840
|
+
// Switch to rectangle tool
|
|
841
|
+
room.setMemberState({ currentApplianceName: ApplianceNames.rectangle });
|
|
842
|
+
|
|
843
|
+
// Switch to laser pen tool
|
|
844
|
+
room.setMemberState({
|
|
845
|
+
currentApplianceName: ApplianceNames.laserPen,
|
|
846
|
+
strokeType: EStrokeType.Normal
|
|
847
|
+
});
|
|
848
|
+
|
|
849
|
+
// Switch to text tool
|
|
850
|
+
room.setMemberState({ currentApplianceName: ApplianceNames.text });
|
|
851
|
+
```
|
|
852
|
+
|
|
853
|
+
### Custom Style Example
|
|
854
|
+
|
|
855
|
+
```js
|
|
856
|
+
// Set brush style to dotted line
|
|
857
|
+
room.setMemberState({
|
|
858
|
+
strokeType: EStrokeType.Dotted,
|
|
859
|
+
strokeOpacity: 0.8
|
|
860
|
+
});
|
|
861
|
+
|
|
862
|
+
// Set shape fill
|
|
863
|
+
room.setMemberState({
|
|
864
|
+
fillColor: [255, 0, 0], // Red
|
|
865
|
+
fillOpacity: 0.5
|
|
866
|
+
});
|
|
867
|
+
|
|
868
|
+
// Set text style
|
|
869
|
+
room.setMemberState({
|
|
870
|
+
textOpacity: 0.9,
|
|
871
|
+
textBgColor: [255, 255, 0], // Yellow background
|
|
872
|
+
textBgOpacity: 0.3
|
|
873
|
+
});
|
|
874
|
+
```
|
|
875
|
+
|
|
876
|
+
### Text Editing Example
|
|
877
|
+
|
|
878
|
+
```js
|
|
879
|
+
// Insert text at specified position
|
|
880
|
+
const textId = plugin.insertText(100, 100, 'Hello World');
|
|
881
|
+
|
|
882
|
+
// Edit text content
|
|
883
|
+
plugin.updateText(textId, 'Updated Text');
|
|
884
|
+
|
|
885
|
+
// Remove text focus
|
|
886
|
+
plugin.blurText();
|
|
887
|
+
```
|
|
888
|
+
|
|
889
|
+
### Minimap Function Example
|
|
890
|
+
|
|
891
|
+
```js
|
|
892
|
+
// Create minimap
|
|
893
|
+
const minimapDiv = document.getElementById('minimap');
|
|
894
|
+
await plugin.createMiniMap('mainView', minimapDiv);
|
|
895
|
+
|
|
896
|
+
// Destroy minimap
|
|
897
|
+
await plugin.destroyMiniMap('mainView');
|
|
898
|
+
```
|
|
899
|
+
|
|
900
|
+
### Undo/Redo Example
|
|
901
|
+
|
|
902
|
+
```js
|
|
903
|
+
// Undo operation
|
|
904
|
+
const undoSteps = plugin.undo();
|
|
905
|
+
|
|
906
|
+
// Redo operation
|
|
907
|
+
const redoSteps = plugin.redo();
|
|
908
|
+
|
|
909
|
+
// Check if undo/redo is possible
|
|
910
|
+
const canUndo = plugin.canUndoSteps() > 0;
|
|
911
|
+
const canRedo = plugin.canRedoSteps() > 0;
|
|
912
|
+
```
|
|
913
|
+
|
|
914
|
+
## FAQ
|
|
915
|
+
|
|
916
|
+
### 1. How to choose the right integration method?
|
|
917
|
+
|
|
918
|
+
- **fastboard**: If you are using the fastboard framework, it is recommended to use fastboard's integration method, which has the simplest configuration
|
|
919
|
+
- **Multi-window scenario**: If you need multi-window functionality, use `ApplianceMultiPlugin`
|
|
920
|
+
- **Single whiteboard scenario**: If you only need single whiteboard functionality, use `ApplianceSinglePlugin`
|
|
921
|
+
|
|
922
|
+
### 2. Worker file deployment method selection?
|
|
923
|
+
|
|
924
|
+
- **CDN deployment** (recommended): Suitable for production environments, can reduce main package size (main package ~400kB, two workers ~800kB each)
|
|
925
|
+
- **Local packaging**: Suitable for development environments or scenarios where package size is not a concern
|
|
926
|
+
|
|
927
|
+
### 3. Performance optimization recommendations
|
|
928
|
+
|
|
929
|
+
- Use CDN deployment for worker files to reduce main package size
|
|
930
|
+
- Reasonably configure `bufferSize` to adjust canvas cache size according to device performance
|
|
931
|
+
- On mobile or low-performance devices, consider using `useSimple: true` simple mode
|
|
932
|
+
- If there are unnecessary features, you can avoid enabling `useBackgroundThread: true`
|
|
933
|
+
|
|
934
|
+
### 4. Compatibility notes
|
|
935
|
+
|
|
936
|
+
- Supports modern browsers (Chrome, Firefox, Safari, Edge)
|
|
937
|
+
- Mobile browser support depends on OffscreenCanvas support
|
|
938
|
+
- Devices that do not support OffscreenCanvas will automatically downgrade to main thread mode
|
|
939
|
+
|
|
940
|
+
## Version History
|
|
941
|
+
|
|
942
|
+
For detailed version update records, please refer to [CHANGELOG.md](./CHANGELOG.md)
|
|
943
|
+
|
|
944
|
+
## License
|
|
945
|
+
|
|
946
|
+
MIT License
|
|
947
|
+
|
|
948
|
+
## Related Links
|
|
949
|
+
|
|
950
|
+
- [white-web-sdk](https://www.npmjs.com/package/white-web-sdk)
|
|
951
|
+
- [@netless/window-manager](https://www.npmjs.com/package/@netless/window-manager)
|
|
952
|
+
- [fastboard](https://github.com/netless-io/fastboard)
|
|
953
|
+
- [Official Documentation](https://doc.shengwang.cn/)
|
package/cdn/cdn.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r="/fullWorker-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r="/fullWorker-D5ZxtP.js",e="/subWorker-DJi31K.js";exports.fullWorkerUrl=r;exports.subWorkerUrl=e;
|