@@ -6,6 +6,13 @@ import { ApplianceNames, DeviceType, WhiteWebSdk } from "white-web-sdk";
66
77import { QueryVersion , store , type RoomInfo } from "./common" ;
88import { clearQueryString , createRoom , persistStore } from "./common" ;
9+ import {
10+ ApplianceMultiPlugin ,
11+ AppliancePluginOptions ,
12+ UseWorkerType ,
13+ } from "@netless/appliance-plugin" ;
14+ import fullWorkerString from "@netless/appliance-plugin/dist/fullWorker.js?raw" ;
15+ import subWorkerString from "@netless/appliance-plugin/dist/subWorker.js?raw" ;
916
1017export const sdk = new WhiteWebSdk ( {
1118 appIdentifier : import . meta. env . VITE_APPID ,
@@ -68,7 +75,7 @@ export async function joinRoom(info: RoomInfo): Promise<Room> {
6875 const room = await sdk . joinRoom ( {
6976 ...info ,
7077 uid,
71- invisiblePlugins : [ WindowManager ] ,
78+ invisiblePlugins : [ WindowManager as any , ApplianceMultiPlugin ] ,
7279 useMultiViews : true ,
7380 disableNewPencil : false ,
7481 disableMagixEventDispatchLimit : true ,
@@ -114,22 +121,78 @@ export async function reset({
114121 }
115122}
116123
117- export function init ( container : HTMLElement ) {
118- WindowManager . mount ( {
124+ export async function init ( container : HTMLElement ) {
125+ const manager = await WindowManager . mount ( {
119126 room,
120127 container,
121128 chessboard : false ,
122129 cursor : true ,
123130 debug : true ,
124131 prefersColorScheme : "auto" ,
125- } ) . then ( async manager => {
126- window . manager = manager ;
127- await manager . switchMainViewToWriter ( ) ;
128- const tool = store . getItem ( "currentApplianceName" ) as ApplianceNames ;
129- if ( tool ) {
130- manager . mainView . setMemberState ( { currentApplianceName : tool } ) ;
131- }
132+ supportAppliancePlugin : true ,
133+ } )
134+ const fullWorkerBlob = new Blob ( [ fullWorkerString ] , {
135+ type : "text/javascript" ,
136+ } ) ;
137+ const fullWorkerUrl = URL . createObjectURL ( fullWorkerBlob ) ;
138+ const subWorkerBlob = new Blob ( [ subWorkerString ] , {
139+ type : "text/javascript" ,
140+ } ) ;
141+ const subWorkerUrl = URL . createObjectURL ( subWorkerBlob ) ;
142+ const pluginOptions : AppliancePluginOptions = {
143+ cdn : {
144+ fullWorkerUrl,
145+ subWorkerUrl,
146+ } ,
147+ extras : {
148+ useSimple : true ,
149+ // useWorker,
150+ // canvasOpt: {
151+ // contextType: "2d",
152+ // },
153+ cursor : {
154+ enable : false ,
155+ expirationTime : 500 ,
156+ moveDelayTime : 300 ,
157+ } ,
158+ syncOpt : {
159+ interval : 100 ,
160+ smoothSync : false ,
161+ } ,
162+ bezier : {
163+ enable : false ,
164+ maxDrawCount : 180 ,
165+ } ,
166+ textEditor : {
167+ showFloatBar : false ,
168+ canSelectorSwitch : false ,
169+ rightBoundBreak : true ,
170+ // extendFontFaces: [{fontFamily: "Pacifico", src: "https://fonts.gstatic.com/s/pacifico/v17/FwZY7-Qmy14u9lezJ-6H6MmBp0u-.woff2"}]
171+ extendFontFaces : [
172+ {
173+ fontFamily : "Noto Sans SC" ,
174+ src : "https://fonts.gstatic.com/s/opensans/v44/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTS-mu0SC55I.woff2" ,
175+ } ,
176+ ] ,
177+ loadFontFacesTimeout : 20000 ,
178+ } ,
179+ longDottedStroke : {
180+ lineCap : "round" ,
181+ segment : 2 ,
182+ gap : 3 ,
183+ } ,
184+ } ,
185+ } ;
186+ const plugin = await ApplianceMultiPlugin . getInstance ( manager as any , {
187+ options : pluginOptions ,
132188 } ) ;
189+ ( window as any ) . appliancePlugin = plugin ;
190+ window . manager = manager ;
191+ await manager . switchMainViewToWriter ( ) ;
192+ const tool = store . getItem ( "currentApplianceName" ) as ApplianceNames ;
193+ if ( tool ) {
194+ manager . mainView . setMemberState ( { currentApplianceName : tool } ) ;
195+ }
133196}
134197
135198export const tools = Object . values ( ApplianceNames ) ;
0 commit comments