@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.
Files changed (128) hide show
  1. package/README.md +138 -0
  2. package/cdn/appliance-plugin.js +1 -0
  3. package/cdn/appliance-plugin.mjs +8639 -0
  4. package/cdn/style.css +1 -0
  5. package/dist/appliance-plugin.js +1 -0
  6. package/dist/appliance-plugin.mjs +8639 -0
  7. package/dist/collector/base.d.ts +20 -0
  8. package/dist/collector/collector.d.ts +53 -0
  9. package/dist/collector/const.d.ts +3 -0
  10. package/dist/collector/enum.d.ts +13 -0
  11. package/dist/collector/eventCollector.d.ts +29 -0
  12. package/dist/collector/index.d.ts +4 -0
  13. package/dist/collector/types.d.ts +70 -0
  14. package/dist/collector/utils/color.d.ts +31 -0
  15. package/dist/collector/utils/index.d.ts +5 -0
  16. package/dist/component/textEditor/index.d.ts +2 -0
  17. package/dist/component/textEditor/manager.d.ts +120 -0
  18. package/dist/component/textEditor/types.d.ts +50 -0
  19. package/dist/component/textEditor/utils.d.ts +3 -0
  20. package/dist/component/textEditor/view.d.ts +68 -0
  21. package/dist/core/const.d.ts +1 -0
  22. package/dist/core/enum.d.ts +135 -0
  23. package/dist/core/index.d.ts +3 -0
  24. package/dist/core/mainEngine.d.ts +163 -0
  25. package/dist/core/msgEvent/activeZIndex/forMain.d.ts +12 -0
  26. package/dist/core/msgEvent/activeZIndex/forWorker.d.ts +8 -0
  27. package/dist/core/msgEvent/base.d.ts +18 -0
  28. package/dist/core/msgEvent/baseForWorker.d.ts +13 -0
  29. package/dist/core/msgEvent/copyNode/forMain.d.ts +47 -0
  30. package/dist/core/msgEvent/copyNode/forWorker.d.ts +8 -0
  31. package/dist/core/msgEvent/deleteNode/forMain.d.ts +11 -0
  32. package/dist/core/msgEvent/deleteNode/forWorker.d.ts +13 -0
  33. package/dist/core/msgEvent/forWorker.d.ts +14 -0
  34. package/dist/core/msgEvent/index.d.ts +15 -0
  35. package/dist/core/msgEvent/rotateNode/forMain.d.ts +16 -0
  36. package/dist/core/msgEvent/rotateNode/forWorker.d.ts +9 -0
  37. package/dist/core/msgEvent/scaleNode/forMain.d.ts +20 -0
  38. package/dist/core/msgEvent/scaleNode/forWorker.d.ts +9 -0
  39. package/dist/core/msgEvent/setColor/forMain.d.ts +18 -0
  40. package/dist/core/msgEvent/setColor/forWorker.d.ts +9 -0
  41. package/dist/core/msgEvent/setFont/forMain.d.ts +18 -0
  42. package/dist/core/msgEvent/setFont/forWorker.d.ts +9 -0
  43. package/dist/core/msgEvent/setLock/forMain.d.ts +12 -0
  44. package/dist/core/msgEvent/setLock/forWorker.d.ts +9 -0
  45. package/dist/core/msgEvent/setPoint/forMain.d.ts +15 -0
  46. package/dist/core/msgEvent/setPoint/forWorker.d.ts +9 -0
  47. package/dist/core/msgEvent/setShape/forMain.d.ts +18 -0
  48. package/dist/core/msgEvent/setShape/forWorker.d.ts +9 -0
  49. package/dist/core/msgEvent/setZIndex/forMain.d.ts +22 -0
  50. package/dist/core/msgEvent/setZIndex/forWorker.d.ts +9 -0
  51. package/dist/core/msgEvent/translateNode/forMain.d.ts +20 -0
  52. package/dist/core/msgEvent/translateNode/forWorker.d.ts +9 -0
  53. package/dist/core/tools/arrow.d.ts +46 -0
  54. package/dist/core/tools/base.d.ts +82 -0
  55. package/dist/core/tools/ellipse.d.ts +44 -0
  56. package/dist/core/tools/eraser.d.ts +41 -0
  57. package/dist/core/tools/image.d.ts +53 -0
  58. package/dist/core/tools/index.d.ts +13 -0
  59. package/dist/core/tools/laserPen.d.ts +42 -0
  60. package/dist/core/tools/pencil.d.ts +66 -0
  61. package/dist/core/tools/polygon.d.ts +45 -0
  62. package/dist/core/tools/rectangle.d.ts +46 -0
  63. package/dist/core/tools/selector.d.ts +83 -0
  64. package/dist/core/tools/speechBalloon.d.ts +49 -0
  65. package/dist/core/tools/star.d.ts +47 -0
  66. package/dist/core/tools/straight.d.ts +46 -0
  67. package/dist/core/tools/text.d.ts +42 -0
  68. package/dist/core/tools/utils.d.ts +39 -0
  69. package/dist/core/types.d.ts +295 -0
  70. package/dist/core/utils/bezier.d.ts +43 -0
  71. package/dist/core/utils/getSvgPathFromPoints.d.ts +10 -0
  72. package/dist/core/utils/index.d.ts +364 -0
  73. package/dist/core/utils/math.d.ts +57 -0
  74. package/dist/core/utils/primitives/Box2d.d.ts +100 -0
  75. package/dist/core/utils/primitives/Point2d.d.ts +71 -0
  76. package/dist/core/utils/primitives/Vec2d.d.ts +146 -0
  77. package/dist/core/utils/primitives/easings.d.ts +24 -0
  78. package/dist/core/utils/proxy.d.ts +21 -0
  79. package/dist/core/utils/spriteNode.d.ts +4 -0
  80. package/dist/core/worker/base.d.ts +103 -0
  81. package/dist/core/worker/fullWorker.d.ts +1 -0
  82. package/dist/core/worker/fullWorkerLocal.d.ts +46 -0
  83. package/dist/core/worker/fullWorkerService.d.ts +41 -0
  84. package/dist/core/worker/subWorker.d.ts +1 -0
  85. package/dist/core/worker/subWorkerLocal.d.ts +20 -0
  86. package/dist/core/worker/vNodeManager.d.ts +32 -0
  87. package/dist/core/worker/workerManager.d.ts +71 -0
  88. package/dist/cursors/index.d.ts +73 -0
  89. package/dist/displayer/const.d.ts +11 -0
  90. package/dist/displayer/cursor/index.d.ts +15 -0
  91. package/dist/displayer/floatBar/index.d.ts +10 -0
  92. package/dist/displayer/floatBtns/colors.d.ts +6 -0
  93. package/dist/displayer/floatBtns/del.d.ts +6 -0
  94. package/dist/displayer/floatBtns/duplicate.d.ts +5 -0
  95. package/dist/displayer/floatBtns/fontSize.d.ts +4 -0
  96. package/dist/displayer/floatBtns/fontStyle.d.ts +4 -0
  97. package/dist/displayer/floatBtns/index.d.ts +11 -0
  98. package/dist/displayer/floatBtns/layer.d.ts +3 -0
  99. package/dist/displayer/floatBtns/lock.d.ts +7 -0
  100. package/dist/displayer/floatBtns/shapeOpt.d.ts +3 -0
  101. package/dist/displayer/highlightBox/index.d.ts +5 -0
  102. package/dist/displayer/icons/index.d.ts +4 -0
  103. package/dist/displayer/resizable/index.d.ts +16 -0
  104. package/dist/displayer/rotate/index.d.ts +4 -0
  105. package/dist/displayer/types.d.ts +51 -0
  106. package/dist/hotkey/index.d.ts +51 -0
  107. package/dist/index.d.ts +1 -0
  108. package/dist/members/index.d.ts +15 -0
  109. package/dist/plugin/applianceMultiPlugin.d.ts +24 -0
  110. package/dist/plugin/applianceSinglePlugin.d.ts +28 -0
  111. package/dist/plugin/baseApplianceManager.d.ts +82 -0
  112. package/dist/plugin/baseViewContainerManager.d.ts +174 -0
  113. package/dist/plugin/displayerView.d.ts +55 -0
  114. package/dist/plugin/external.d.ts +2 -0
  115. package/dist/plugin/index.d.ts +6 -0
  116. package/dist/plugin/multi/applianceMultiManager.d.ts +14 -0
  117. package/dist/plugin/multi/containerManager.d.ts +24 -0
  118. package/dist/plugin/multi/displayer/appViewDisplayerManager.d.ts +24 -0
  119. package/dist/plugin/multi/displayer/mainViewDisplayerManager.d.ts +25 -0
  120. package/dist/plugin/single/applianceDisplayer.d.ts +16 -0
  121. package/dist/plugin/single/applianceSingleManager.d.ts +13 -0
  122. package/dist/plugin/single/containerManager.d.ts +11 -0
  123. package/dist/plugin/single/displayer/mainViewDisplayerManager.d.ts +25 -0
  124. package/dist/plugin/types.d.ts +310 -0
  125. package/dist/plugin/utils.d.ts +6 -0
  126. package/dist/style.css +1 -0
  127. package/dist/undo/index.d.ts +70 -0
  128. 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.