@netless/appliance-plugin 1.1.36-beta.1 → 1.1.36-beta.2

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 (35) hide show
  1. package/READMA.zh-CN.md +11 -48
  2. package/README.md +11 -49
  3. package/dist/appliance-plugin.js +1 -1
  4. package/dist/appliance-plugin.mjs +1 -1
  5. package/dist/assets/{fullWorker-B_mvkoeW.js → fullWorker-D9xRgd20.js} +7 -7
  6. package/dist/assets/{subWorker-CRdsidWT.js → subWorker-DDz22vt8.js} +7 -7
  7. package/dist/{bridge-enxPG6qf.js → bridge-BKHuhuVK.js} +1 -1
  8. package/dist/bridge-g7eU9k12.mjs +67 -0
  9. package/dist/bridge.js +1 -1
  10. package/dist/bridge.mjs +1 -1
  11. package/dist/component/textEditor/manager.d.ts +0 -1
  12. package/dist/fullWorker.js +2 -2
  13. package/dist/index-B7w-GcID.js +1 -0
  14. package/dist/{index-D4z0hSjm.js → index-BLzjGoXh.js} +1 -1
  15. package/dist/{index-CcS9cKSp.js → index-BjEjHeEF.js} +1 -1
  16. package/dist/{index-BrJL-fin.mjs → index-C019qtsS.mjs} +14 -21
  17. package/dist/{index-DbI0V6BY.mjs → index-CfKLCV2y.mjs} +4858 -4987
  18. package/dist/{index-K9QVPOhV.mjs → index-L2uoKaSf.mjs} +14 -21
  19. package/dist/index-L470yte_.js +1 -0
  20. package/dist/{index-2On9v0Ff.mjs → index-LBCXcuGb.mjs} +4841 -4970
  21. package/dist/{index-CIjmeY9J.js → index-PebKJQE3.js} +1 -1
  22. package/dist/{index-Bm90lQii.js → index-Yc4OIUoM.js} +1 -1
  23. package/dist/{index-BZql6xgR.mjs → index-bMvJ4igq.mjs} +1 -1
  24. package/dist/{index-D8SnD90W.mjs → index-hePUiGEB.mjs} +1 -1
  25. package/dist/plugin/selectorApi.d.ts +7 -1
  26. package/dist/plugin/types.d.ts +8 -3
  27. package/dist/subWorker.js +2 -2
  28. package/dist/undo/index.d.ts +0 -1
  29. package/package.json +2 -4
  30. package/cdn/cdn.js +0 -1
  31. package/cdn/fullWorker-uAwmRi.js +0 -486
  32. package/cdn/subWorker-BVNpAC.js +0 -486
  33. package/dist/bridge-DYkH1J6p.mjs +0 -67
  34. package/dist/index-BSD0B_eV.js +0 -1
  35. package/dist/index-W9Jz9E04.js +0 -1
package/READMA.zh-CN.md CHANGED
@@ -63,34 +63,13 @@ import { ApplianceMultiPlugin } from '@netless/appliance-plugin';
63
63
  import { ApplianceSinglePlugin } from '@netless/appliance-plugin';
64
64
  ```
65
65
 
66
- > **worker.js 文件与 CDN / 静态资源**
67
- >
68
- > 我们采用双 worker 并发来提高绘制效率,比主线程效率提高 40% 以上。两个 worker 文件的公共依赖重复,直接打进包体会显著增加体积,因此推荐通过 `options.cdn` 指定 worker 地址,有两种常见方式:
69
- >
70
- > 1. **CDN 方式**:将 `@netless/appliance-plugin/cdn` 下的 `fullWorker.js`、`subWorker.js` 部署到 CDN,在插件的 `getInstance` 的第二个参数 `options.cdn` 中传入这两个文件的 CDN 地址(`fullWorkerUrl`、`subWorkerUrl`)。
71
- > ***注意***:CDN 配置的 URL 必须同源,否则 worker 线程会无法加载。
72
- >
73
- > 2. **静态资源方式**:将 `fullWorker.js`、`subWorker.js` 放到项目的静态目录(如 Vite 的 `public/`),不参与打包。在代码中基于 `import.meta.env.BASE_URL`(或等效的 publicPath)拼出完整 URL,传入 `options.cdn`。同源请求、不占打包体积,也无需 Blob 内联,内存占用更小。
74
- >
75
- > 若需控制包体积,请使用上述任一方式配置 `options.cdn`。
76
-
77
66
  ### 接入方式参考
78
67
 
79
- #### 引入worker.js
68
+ #### 准备 worker URL
80
69
  ```js
81
- // 引入 worker 方式三选一:
82
- // 方式一:静态资源(推荐)- 将 fullWorker.js、subWorker.js 放到 public 等静态目录,同源请求、不占打包体积
83
- const workerBase = (import.meta.env.BASE_URL || '/').replace(/\/?$/, '/');
84
- const fullWorkerUrl = workerBase + 'fullWorker.js';
85
- const subWorkerUrl = workerBase + 'subWorker.js';
86
-
87
- // 方式二:CDN - 将 @netless/appliance-plugin/cdn 下文件部署到 CDN 后,此处写 CDN 地址、不占打包体积 注意: 域名一定要同源
88
- const fullWorkerUrl = 'https://your-cdn.com/fullWorker.js';
89
- const subWorkerUrl = 'https://your-cdn.com/subWorker.js';
90
-
91
- // 方式三:从 dist 以 ?raw 内联为 Blob(需打包器支持 ?raw,如 Vite / webpack raw-loader)这种方式会占用一定内存.
92
70
  import fullWorkerString from '@netless/appliance-plugin/dist/fullWorker.js?raw';
93
71
  import subWorkerString from '@netless/appliance-plugin/dist/subWorker.js?raw';
72
+
94
73
  const fullWorkerUrl = URL.createObjectURL(new Blob([fullWorkerString], { type: 'text/javascript' }));
95
74
  const subWorkerUrl = URL.createObjectURL(new Blob([subWorkerString], { type: 'text/javascript' }));
96
75
  ```
@@ -103,7 +82,7 @@ const subWorkerUrl = URL.createObjectURL(new Blob([subWorkerString], { type: 'te
103
82
  // 分包引用
104
83
  import { useFastboard, Fastboard } from "@netless/fastboard-react";
105
84
 
106
- // 引入 worker 方式三选一:
85
+ // 按上文方式准备 worker URL:
107
86
  const fullWorkerUrl = ...;
108
87
  const subWorkerUrl = ...;
109
88
 
@@ -134,7 +113,7 @@ const app = useFastboard(() => ({
134
113
  // 分包引用
135
114
  import { createFastboard, createUI } from "@netless/fastboard";
136
115
 
137
- // 引入 worker 方式三选一:
116
+ // 按上文方式准备 worker URL:
138
117
  const fullWorkerUrl = ...;
139
118
  const subWorkerUrl = ...;
140
119
 
@@ -173,7 +152,7 @@ import { WhiteWebSdk } from "white-web-sdk";
173
152
  import { WindowManager } from "@netless/window-manager";
174
153
  import { ApplianceMultiPlugin } from '@netless/appliance-plugin';
175
154
 
176
- // 引入 worker 方式三选一:
155
+ // 按上文方式准备 worker URL:
177
156
  const fullWorkerUrl = ...;
178
157
  const subWorkerUrl = ...;
179
158
 
@@ -211,7 +190,7 @@ import '@netless/appliance-plugin/dist/style.css';
211
190
  import { WhiteWebSdk } from "white-web-sdk";
212
191
  import { ApplianceSinglePlugin, ApplianceSigleWrapper } from '@netless/appliance-plugin';
213
192
 
214
- // 引入 worker 方式三选一:
193
+ // 按上文方式准备 worker URL:
215
194
  const fullWorkerUrl = ...;
216
195
  const subWorkerUrl = ...;
217
196
 
@@ -796,10 +775,10 @@ plugin.insertBackgroundImage(viewId, {
796
775
  `getInstance(wm: WindowManager | Room | Player, adaptor: ApplianceAdaptor)`
797
776
  - `wm`: `WindowManager | Room | Player`。多窗口模式下传入的是 `WindowManager`,单窗口模式下传入的是 `Room` 或者 `Player`(白板回放模式)。
798
777
  - `adaptor`: 配置适配器。
799
- - `options: AppliancePluginOptions` - 必须配置,其中 `cdn` 为必填项。
778
+ - `options: AppliancePluginOptions` - 必须配置,其中 `cdn` 用于传入 worker URL。
800
779
  ```js
801
780
  export type AppliancePluginOptions = {
802
- /** cdn配置项 */
781
+ /** worker URL 配置项 */
803
782
  cdn: CdnOpt;
804
783
  /** 额外配置项 */
805
784
  extras?: ExtrasOptions;
@@ -874,19 +853,9 @@ appliancePlugin.currentManager.consoleWorkerInfo() // 可以查看到 worker
874
853
  import { ApplianceSinglePlugin } from '@netless/appliance-plugin';
875
854
  import '@netless/appliance-plugin/dist/style.css';
876
855
 
877
- // 方式1: 使用 CDN(推荐生产环境)
878
- const plugin = await ApplianceSinglePlugin.getInstance(room, {
879
- options: {
880
- cdn: {
881
- fullWorkerUrl: 'https://your-cdn.com/fullWorker.js',
882
- subWorkerUrl: 'https://your-cdn.com/subWorker.js',
883
- },
884
- },
885
- });
886
-
887
- // 方式2: 使用本地 worker 文件(适合开发环境)
888
856
  import fullWorkerString from '@netless/appliance-plugin/dist/fullWorker.js?raw';
889
857
  import subWorkerString from '@netless/appliance-plugin/dist/subWorker.js?raw';
858
+
890
859
  const fullWorkerBlob = new Blob([fullWorkerString], {type: 'text/javascript'});
891
860
  const fullWorkerUrl = URL.createObjectURL(fullWorkerBlob);
892
861
  const subWorkerBlob = new Blob([subWorkerString], {type: 'text/javascript'});
@@ -992,19 +961,13 @@ const canRedo = plugin.canRedoSteps() > 0;
992
961
  - **多窗口场景**:如果需要多窗口功能,使用 `ApplianceMultiPlugin`
993
962
  - **单白板场景**:如果只需要单白板功能,使用 `ApplianceSinglePlugin`
994
963
 
995
- ### 2. Worker 文件部署方式选择?
996
-
997
- - **CDN 部署**(推荐):适合生产环境,可以减少主包体积(主包约 400kB,两个 worker 各约 800kB)
998
- - **本地打包**:适合开发环境或对包体积不敏感的场景
999
-
1000
- ### 3. 性能优化建议
964
+ ### 2. 性能优化建议
1001
965
 
1002
- - 使用 CDN 部署 worker 文件,减少主包体积
1003
966
  - 合理配置 `bufferSize`,根据设备性能调整画布缓存大小
1004
967
  - 在移动端或低性能设备上,可以考虑使用 `useSimple: true` 简单模式
1005
968
  - 如有非必要的功能, 可以不用开启 `useBackgroundThread: true`
1006
969
 
1007
- ### 4. 兼容性说明
970
+ ### 3. 兼容性说明
1008
971
 
1009
972
  - 支持现代浏览器(Chrome、Firefox、Safari、Edge)
1010
973
  - 移动端浏览器支持情况取决于 OffscreenCanvas 支持情况
package/README.md CHANGED
@@ -63,35 +63,13 @@ import { ApplianceMultiPlugin } from '@netless/appliance-plugin';
63
63
  import { ApplianceSinglePlugin } from '@netless/appliance-plugin';
64
64
  ```
65
65
 
66
- > **worker.js files: CDN & static assets**
67
- >
68
- > We use dual workers for higher drawing efficiency (40%+ over the main thread). The two worker files share duplicated dependencies, so bundling them would significantly increase package size. We recommend providing worker URLs via `options.cdn`. Two common approaches:
69
- >
70
- > 1. **CDN**: Deploy `fullWorker.js` and `subWorker.js` from `@netless/appliance-plugin/cdn` to your CDN, then pass their URLs as `fullWorkerUrl` and `subWorkerUrl` in the plugin’s `getInstance` second argument `options.cdn`.
71
- > ***Note***: CDN URLs must be same-origin with your app, or the workers will fail to load.
72
- >
73
- > 2. **Static assets**: Put `fullWorker.js` and `subWorker.js` in your project’s static directory (e.g. Vite’s `public/`), so they are not bundled. In code, build full URLs from `import.meta.env.BASE_URL` (or your publicPath) and pass them to `options.cdn`. Same-origin, no bundle bloat, no Blob inline, lower memory use.
74
- >
75
- > To keep bundle size down, configure `options.cdn` using one of the above.
76
-
77
66
  ### Access Mode Reference
78
67
 
79
- #### Introducing worker.js
68
+ #### Preparing worker URLs
80
69
  ```js
81
- // Choose one of three ways to provide worker URLs:
82
-
83
- // Option 1: Static assets (recommended) — put fullWorker.js & subWorker.js in public (or similar); same-origin, no bundle cost
84
- const workerBase = (import.meta.env.BASE_URL || '/').replace(/\/?$/, '/');
85
- const fullWorkerUrl = workerBase + 'fullWorker.js';
86
- const subWorkerUrl = workerBase + 'subWorker.js';
87
-
88
- // Option 2: CDN — after deploying files from @netless/appliance-plugin/cdn to your CDN, set URLs here. Note: must be same-origin
89
- const fullWorkerUrl = 'https://your-cdn.com/fullWorker.js';
90
- const subWorkerUrl = 'https://your-cdn.com/subWorker.js';
91
-
92
- // Option 3: Inline via ?raw as Blob (requires ?raw support, e.g. Vite or webpack raw-loader). Uses more memory.
93
70
  import fullWorkerString from '@netless/appliance-plugin/dist/fullWorker.js?raw';
94
71
  import subWorkerString from '@netless/appliance-plugin/dist/subWorker.js?raw';
72
+
95
73
  const fullWorkerUrl = URL.createObjectURL(new Blob([fullWorkerString], { type: 'text/javascript' }));
96
74
  const subWorkerUrl = URL.createObjectURL(new Blob([subWorkerString], { type: 'text/javascript' }));
97
75
  ```
@@ -104,7 +82,7 @@ const subWorkerUrl = URL.createObjectURL(new Blob([subWorkerString], { type: 'te
104
82
  // Subpackage reference
105
83
  import { useFastboard, Fastboard } from "@netless/fastboard-react";
106
84
 
107
- // Use one of the three worker options from "Introducing worker.js" above:
85
+ // Prepare worker URLs as shown above:
108
86
  const fullWorkerUrl = ...;
109
87
  const subWorkerUrl = ...;
110
88
 
@@ -135,7 +113,7 @@ const app = useFastboard(() => ({
135
113
  // Subpackage reference
136
114
  import { createFastboard, createUI } from "@netless/fastboard";
137
115
 
138
- // Use one of the three worker options from "Introducing worker.js" above:
116
+ // Prepare worker URLs as shown above:
139
117
  const fullWorkerUrl = ...;
140
118
  const subWorkerUrl = ...;
141
119
 
@@ -174,7 +152,7 @@ import { WhiteWebSdk } from "white-web-sdk";
174
152
  import { WindowManager } from "@netless/window-manager";
175
153
  import { ApplianceMultiPlugin } from '@netless/appliance-plugin';
176
154
 
177
- // Use one of the three worker options from "Introducing worker.js" above:
155
+ // Prepare worker URLs as shown above:
178
156
  const fullWorkerUrl = ...;
179
157
  const subWorkerUrl = ...;
180
158
 
@@ -211,7 +189,7 @@ import '@netless/appliance-plugin/dist/style.css';
211
189
 
212
190
  import { WhiteWebSdk } from "white-web-sdk";
213
191
  import { ApplianceSinglePlugin, ApplianceSigleWrapper } from '@netless/appliance-plugin';
214
- // Use one of the three worker options from "Introducing worker.js" above:
192
+ // Prepare worker URLs as shown above:
215
193
  const fullWorkerUrl = ...;
216
194
  const subWorkerUrl = ...;
217
195
 
@@ -780,10 +758,10 @@ plugin.usePlugin(autoDrawPlugin);
780
758
  `getInstance(wm: WindowManager | Room | Player, adaptor: ApplianceAdaptor)`
781
759
  - `wm`: `WindowManager | Room | Player`. In multi-window mode, pass `WindowManager`, in single-window mode, pass `Room` or `Player` (whiteboard playback mode).
782
760
  - `adaptor`: Configuration adapter.
783
- - `options: AppliancePluginOptions` - Must be configured, where `cdn` is required.
761
+ - `options: AppliancePluginOptions` - Must be configured, where `cdn` contains worker URLs.
784
762
  ```js
785
763
  export type AppliancePluginOptions = {
786
- /** CDN configuration item */
764
+ /** Worker URL configuration item */
787
765
  cdn: CdnOpt;
788
766
  /** Additional configuration items */
789
767
  extras?: ExtrasOptions;
@@ -856,19 +834,9 @@ appliancePlugin.currentManager.consoleWorkerInfo() // Can view drawing informat
856
834
  import { ApplianceSinglePlugin } from '@netless/appliance-plugin';
857
835
  import '@netless/appliance-plugin/dist/style.css';
858
836
 
859
- // Method 1: Using CDN (recommended for production)
860
- const plugin = await ApplianceSinglePlugin.getInstance(room, {
861
- options: {
862
- cdn: {
863
- fullWorkerUrl: 'https://your-cdn.com/fullWorker.js',
864
- subWorkerUrl: 'https://your-cdn.com/subWorker.js',
865
- },
866
- },
867
- });
868
-
869
- // Method 2: Using local worker files (suitable for development)
870
837
  import fullWorkerString from '@netless/appliance-plugin/dist/fullWorker.js?raw';
871
838
  import subWorkerString from '@netless/appliance-plugin/dist/subWorker.js?raw';
839
+
872
840
  const fullWorkerBlob = new Blob([fullWorkerString], {type: 'text/javascript'});
873
841
  const fullWorkerUrl = URL.createObjectURL(fullWorkerBlob);
874
842
  const subWorkerBlob = new Blob([subWorkerString], {type: 'text/javascript'});
@@ -974,19 +942,13 @@ const canRedo = plugin.canRedoSteps() > 0;
974
942
  - **Multi-window scenario**: If you need multi-window functionality, use `ApplianceMultiPlugin`
975
943
  - **Single whiteboard scenario**: If you only need single whiteboard functionality, use `ApplianceSinglePlugin`
976
944
 
977
- ### 2. Worker file deployment method selection?
978
-
979
- - **CDN deployment** (recommended): Suitable for production environments, can reduce main package size (main package ~400kB, two workers ~800kB each)
980
- - **Local packaging**: Suitable for development environments or scenarios where package size is not a concern
981
-
982
- ### 3. Performance optimization recommendations
945
+ ### 2. Performance optimization recommendations
983
946
 
984
- - Use CDN deployment for worker files to reduce main package size
985
947
  - Reasonably configure `bufferSize` to adjust canvas cache size according to device performance
986
948
  - On mobile or low-performance devices, consider using `useSimple: true` simple mode
987
949
  - If there are unnecessary features, you can avoid enabling `useBackgroundThread: true`
988
950
 
989
- ### 4. Compatibility notes
951
+ ### 3. Compatibility notes
990
952
 
991
953
  - Supports modern browsers (Chrome, Firefox, Safari, Edge)
992
954
  - Mobile browser support depends on OffscreenCanvas support
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-W9Jz9E04.js");exports.ActiveContainerType=e.ActiveContainerType;exports.ApplianceMultiPlugin=e.ApplianceMultiPlugin;exports.ApplianceNames=e.ApplianceNames;exports.ApplianceSigleWrapper=e.ApplianceSigleWrapper;exports.ApplianceSinglePlugin=e.ApplianceSinglePlugin;exports.Cursor_Hover_Id=e.Cursor_Hover_Id;exports.ECanvasShowType=e.ECanvasShowType;exports.EDataType=e.EDataType;exports.EForceStopReason=e.EForceStopReason;exports.EImageType=e.EImageType;exports.EMatrixrRelationType=e.EMatrixrRelationType;exports.EOperationType=e.EOperationType;exports.EPostMessageType=e.EPostMessageType;exports.ERenderFilterType=e.ERenderFilterType;exports.ESVGType=e.ESVGType;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.EventWorkState=e.EventWorkState;exports.EvevtWorkState=e.EventWorkState;exports.InternalMsgEmitterType=e.InternalMsgEmitterType;exports.Main_View_Id=e.Main_View_Id;exports.Plugin=e.Plugin;exports.ShapeType=e.ShapeType;exports.Task_Time_Interval=e.Task_Time_Interval;exports.fullWorkerUrl=e.fullWorker;exports.subWorkerUrl=e.subWorker;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-B7w-GcID.js");exports.ActiveContainerType=e.ActiveContainerType;exports.ApplianceMultiPlugin=e.ApplianceMultiPlugin;exports.ApplianceNames=e.ApplianceNames;exports.ApplianceSigleWrapper=e.ApplianceSigleWrapper;exports.ApplianceSinglePlugin=e.ApplianceSinglePlugin;exports.Cursor_Hover_Id=e.Cursor_Hover_Id;exports.ECanvasShowType=e.ECanvasShowType;exports.EDataType=e.EDataType;exports.EForceStopReason=e.EForceStopReason;exports.EImageType=e.EImageType;exports.EMatrixrRelationType=e.EMatrixrRelationType;exports.EOperationType=e.EOperationType;exports.EPostMessageType=e.EPostMessageType;exports.ERenderFilterType=e.ERenderFilterType;exports.ESVGType=e.ESVGType;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.EventWorkState=e.EventWorkState;exports.EvevtWorkState=e.EventWorkState;exports.InternalMsgEmitterType=e.InternalMsgEmitterType;exports.Main_View_Id=e.Main_View_Id;exports.Plugin=e.Plugin;exports.ShapeType=e.ShapeType;exports.Task_Time_Interval=e.Task_Time_Interval;exports.fullWorkerUrl=e.fullWorker;exports.subWorkerUrl=e.subWorker;
@@ -1,4 +1,4 @@
1
- import { a7 as s, a8 as p, a9 as r, aa as t, ab as i, a4 as l, Z as n, b as E, ac as o, t as T, j as y, ad as v, a as g, ae as S, d as c, u, w as k, c as m, af as M, E as _, ag as d, v as A, v as I, ah as W, Y as P, ai as b, aj as f, a6 as h, ak as w, al as C } from "./index-DbI0V6BY.mjs";
1
+ import { a7 as s, a8 as p, a9 as r, aa as t, ab as i, a4 as l, Z as n, b as E, ac as o, t as T, j as y, ad as v, a as g, ae as S, d as c, u, w as k, c as m, af as M, E as _, ag as d, v as A, v as I, ah as W, Y as P, ai as b, aj as f, a6 as h, ak as w, al as C } from "./index-CfKLCV2y.mjs";
2
2
  export {
3
3
  s as ActiveContainerType,
4
4
  p as ApplianceMultiPlugin,