@realsee/live 0.7.0 → 0.7.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.
- package/dist/index.cjs.js +3 -92
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +5 -1336
- package/dist/index.es.js +6165 -0
- package/dist/index.es.js.map +1 -0
- package/dist/live/controller.d.ts +118 -0
- package/dist/live/createLive.d.ts +8 -0
- package/dist/live/createLiveReact.d.ts +54 -0
- package/dist/live/live.d.ts +200 -0
- package/dist/rtc/BrowserRTC.d.ts +39 -0
- package/dist/rtc/BrowserRTC4Chime.d.ts +60 -0
- package/dist/rtc/CoreRTC.d.ts +23 -0
- package/dist/rtc/VRWebViewRTC.d.ts +97 -0
- package/dist/rtc/index.d.ts +5 -0
- package/dist/typings/chime/AttendeeResponse.d.ts +5 -0
- package/dist/typings/chime/MeetingResponse.d.ts +12 -0
- package/dist/typings/chime/MeetingSessionConfigurationOptions.d.ts +16 -0
- package/dist/typings/chime/index.d.ts +3 -0
- package/dist/typings/index.d.ts +4 -0
- package/dist/typings/live/EventType.d.ts +74 -0
- package/dist/typings/live/GetVoiceSign.d.ts +52 -0
- package/dist/typings/live/LiveConnectOptions.d.ts +24 -0
- package/dist/typings/live/LiveErrorType.d.ts +9 -0
- package/dist/typings/live/LiveMsg.d.ts +133 -0
- package/dist/typings/live/LiveOptions.d.ts +79 -0
- package/dist/typings/live/LiveState.d.ts +15 -0
- package/dist/typings/live/RoomInfo.d.ts +13 -0
- package/dist/typings/live/UserInfo.d.ts +103 -0
- package/dist/typings/live/UserVolume.d.ts +7 -0
- package/dist/typings/live/WebSocket.d.ts +82 -0
- package/dist/typings/live/index.d.ts +10 -0
- package/dist/typings/react/RTCActionReactCallback.d.ts +2 -0
- package/dist/typings/react/index.d.ts +1 -0
- package/dist/typings/rtc/VRWebViewRTCOptions.d.ts +6 -0
- package/dist/typings/rtc/eventType.d.ts +44 -0
- package/dist/typings/rtc/index.d.ts +5 -0
- package/dist/typings/rtc/joinedInfo.d.ts +38 -0
- package/dist/typings/rtc/protocol.d.ts +77 -0
- package/dist/typings/rtc/type.d.ts +12 -0
- package/dist/utils/RobustWebSocket.d.ts +160 -0
- package/dist/utils/appendUri.d.ts +1 -0
- package/dist/utils/clientDetector.d.ts +4 -0
- package/dist/utils/equal.d.ts +10 -0
- package/dist/utils/isServer.d.ts +5 -0
- package/dist/utils/logger.d.ts +19 -0
- package/dist/utils/subscribe.d.ts +75 -0
- package/dist/utils/uuid.d.ts +4 -0
- package/docs/classes/CoreRTC.md +7 -7
- package/docs/classes/Live.md +29 -56
- package/docs/globals.md +0 -6
- package/docs/interfaces/RTCProtocol.md +6 -6
- package/package.json +14 -22
- package/dist/index.d.cts +0 -1336
- package/dist/index.esm.js +0 -30
- package/docs/classes/Subscribe.md +0 -211
- package/docs/namespaces/SubscribeMixinType/README.md +0 -17
- package/docs/namespaces/SubscribeMixinType/interfaces/emit.md +0 -31
- package/docs/namespaces/SubscribeMixinType/interfaces/hasListener.md +0 -25
- package/docs/namespaces/SubscribeMixinType/interfaces/off.md +0 -31
- package/docs/namespaces/SubscribeMixinType/interfaces/on.md +0 -37
- package/docs/namespaces/SubscribeMixinType/interfaces/once.md +0 -35
- package/docs/type-aliases/EventMap.md +0 -17
package/dist/index.esm.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import Fe from 'trtc-js-sdk';
|
|
2
|
-
import { ConsoleLogger, LogLevel, DefaultDeviceController, MeetingSessionConfiguration, DefaultMeetingSession, DefaultModality, MeetingSessionStatusCode } from 'amazon-chime-sdk-js';
|
|
3
|
-
import Vi from '@realsee/jsbridge-x';
|
|
4
|
-
import { ObservableV2 } from 'lib0/observable';
|
|
5
|
-
import * as K from 'lib0/array';
|
|
6
|
-
import * as A from 'lib0/math';
|
|
7
|
-
import * as x from 'lib0/map';
|
|
8
|
-
import * as u from 'lib0/encoding';
|
|
9
|
-
import 'lib0/decoding';
|
|
10
|
-
import * as Ne from 'lib0/random';
|
|
11
|
-
import * as He from 'lib0/promise';
|
|
12
|
-
import 'lib0/buffer';
|
|
13
|
-
import * as S from 'lib0/error';
|
|
14
|
-
import * as v from 'lib0/binary';
|
|
15
|
-
import * as pt from 'lib0/function';
|
|
16
|
-
import { callAll } from 'lib0/function';
|
|
17
|
-
import * as ge from 'lib0/set';
|
|
18
|
-
import * as B from 'lib0/logging';
|
|
19
|
-
import 'lib0/time';
|
|
20
|
-
import 'lib0/string';
|
|
21
|
-
import * as ie from 'lib0/iterator';
|
|
22
|
-
import * as $ from 'lib0/object';
|
|
23
|
-
import * as Pt from 'lib0/environment';
|
|
24
|
-
import U, { createContext, useCallback } from 'react';
|
|
25
|
-
|
|
26
|
-
var ae=Symbol("$$REALSEE_LIVE_EVENT$$");function ke(i){return i[ae]||(i[ae]={}),i[ae]}function En(i){i[ae]?.length||delete i[ae];}var P=class{hasListener(e){let t=ke(this);return t&&t[e]&&t[e].length>0}on(e,t,n){let r=ke(this);return r[e]||(r[e]=[]),r[e].push([t,n||!1]),()=>this.off(e,t)}once(e,t){return this.on(e,t,!0)}off(e,t){let n=ke(this);if(!e){En(this);return}if(n[e]||(n[e]=[]),t===void 0){n[e].length=0;return}let r=n[e].findIndex(s=>s[0]===t);r!==-1&&n[e].splice(r,1);}emit(e,...t){let n=!1,s=ke(this)[e]||[];for(let o of s.slice()){let[c,a=!1]=o,l=c(...t);a&&this.off(e,c),l===!1&&(n=!0);}return n}};var J=class extends P{};var In=(n=>(n.RealseeBrowserRTC="RealseeBrowserRTC",n.RealseeVRWebViewRTC="RealseeVRWebViewRTC",n.RealseeBrowserChimeRTC="RealseeBrowserChimeRTC",n))(In||{}),Tn=(t=>(t.RealseeXTRTC="trtc",t.RealseeXChimeRTC="chime",t))(Tn||{});var Rn=()=>{let i=new Date,e=i.getFullYear(),t=(i.getMonth()+1).toString().padStart(2,"0"),n=i.getDate().toString().padStart(2,"0"),r=i.getHours().toString().padStart(2,"0"),s=i.getMinutes().toString().padStart(2,"0"),o=i.getSeconds().toString().padStart(2,"0"),c=i.getMilliseconds().toString().padStart(3,"0");return `[${e}-${t}-${n} ${r}:${s}:${o}.${c}]`};var le=(i,e=[])=>{let t=`Realsee Live ${Rn()} <${i}> `;switch(i){case"INFO":console.info(t,...e);break;case"ERROR":console.error(t,...e);break;case"WARN":console.warn(t,...e);break;case"DEBUG":console.debug(t,...e);break;default:console.log(t,...e);}},Dn={log:(...i)=>le("LOG",i),info:(...i)=>le("INFO",i),error:(...i)=>le("ERROR",i),warn:(...i)=>le("WARN",i),debug:(...i)=>le("DEBUG",i)},m=Dn;function H(){return ((1+Math.random())*65536|0).toString(16).substring(1)}function z(){return [H(),H(),"4"+H().substring(0,3),H(),H(),H()+H()+H()].join("-").toLowerCase()}var de=class extends J{type="RealseeBrowserRTC";joined=!1;micro=!1;voiceId="";_getVoiceSign=()=>{throw new Error("\u65B9\u6CD5 getVoiceSign \u672A\u5B9E\u73B0")};_autoPlayConfirm;checkRequirement=()=>Fe.checkSystemRequirements();$dom=document.createElement("div");_trtc={client:null,stream:null};constructor(e){super(),this._getVoiceSign=e.getVoiceSign,this._autoPlayConfirm=e.autoPlayConfirm,this._initParentDom();}_initParentDom(){this.$dom.id=`rs-rtc-${z()}`,this.$dom.style.display="none",document.body.appendChild(this.$dom);}join=async e=>{this.emit("joinWillStart");let t=await this._getVoiceSign({voiceId:e.voiceId,roomId:e.roomId,userId:e.userId});this._trtc.client=Fe.createClient({mode:"rtc",...t,enableAutoPlayDialog:typeof this._autoPlayConfirm!="function"}),this._trtc.client?.enableAudioVolumeEvaluation(),this._registerRtcEvent();let n=await new Promise(r=>{this._trtc.client?.join({roomId:Number(e.voiceId)}).then(()=>r(!0)).catch(()=>r(!1));});return this.joined=n,n?(this._trtc.stream=Fe.createStream({userId:t.userId,audio:!0,video:!1}),n=await new Promise(r=>{this._trtc.stream?.initialize().then(()=>r(!0)).catch(()=>r(!1));}),n=await new Promise(r=>{this._trtc.client?.publish(this._trtc.stream).then(()=>r(!0)).catch(()=>r(!1));}),this.joined=n,this.joined&&this.emit("joined"),n):!1};quit(){return new Promise(async e=>{this.joined=!1,this._trtc.stream&&(await this._trtc.client?.unpublish(this._trtc.stream),this._trtc.stream.stop(),this._trtc.stream.close(),this._trtc.stream=null),this._trtc.client?.leave().then(()=>this._trtc.client=null).then(()=>e(!0)).catch(()=>e(!1)),e(!0);})}detectMicro(){return new Promise(e=>{let t={audio:!0,video:!1};try{navigator.mediaDevices.getUserMedia(t).then(()=>e(!0)).catch(n=>{m.error(n.message),e(!1);});}catch(n){console.error(n),e(!1);}})}toggleMicro(e){return Promise.resolve((e?this._trtc?.stream?.unmuteAudio():this._trtc?.stream?.muteAudio())||!1)}shock(){throw new Error("Method not implemented.")}_registerRtcEvent(){this._trtc.client?.on("stream-added",this._handleStreamAdded),this._trtc.client?.on("stream-subscribed",this._handleStreamSubscribed),this._trtc.client?.on("audio-volume",e=>this.emit("userVolumes",e.result.map(({userId:t,audioVolume:n})=>({userId:t,audioVolume:n})))),this._trtc.client?.on("error",e=>this.emit("error",e));}_handleStreamAdded=e=>{let t=e.stream;console.log("\u8FDC\u7AEF\u6D41\u589E\u52A0: "+t.getId()),this._trtc.client?.subscribe(t);};_handleStreamSubscribed=e=>{let t=e.stream;console.log("\u8FDC\u7AEF\u6D41\u8BA2\u9605\u6210\u529F\uFF1A"+t.getId());let r=`rs-rtc-remote_stream-${t.getId()}`,s=document.createElement("div");s.id=r,this.$dom.appendChild(s),typeof this._autoPlayConfirm=="function"?(t.play(r).catch(o=>{}),t.on("error",o=>{if(o.getCode()===16451){let a=()=>t.resume();this._autoPlayConfirm({onConfirm:a});}})):t.play(r);}};var te=class extends J{type="RealseeBrowserChimeRTC";joined=!1;micro=!1;voiceId="";userId="";logger;deviceController;meetingSession;audioInput;audioOutput;deviceChangeObserver={};audioVideoObserver={};audioMixObserver;_getVoiceSign=()=>{throw new Error("\u65B9\u6CD5 getVoiceSign \u672A\u5B9E\u73B0")};_autoPlayConfirm;$dom=document.createElement("div");$audio=document.createElement("audio");constructor(e){super(),this._getVoiceSign=e.getVoiceSign,this._autoPlayConfirm=e.autoPlayConfirm,this._initDom(),this.logger=new ConsoleLogger("WebRTCLogger",e.logLevel||LogLevel.INFO),this.deviceController=new DefaultDeviceController(this.logger),this.initObservers();}_initDom=()=>{this.$audio.id=`rs-rtc-${z()}`,this.$dom.id=`rs-rtc-${z()}`,this.$dom.appendChild(this.$audio),document.body.appendChild(this.$dom);};initObservers=()=>{this.deviceChangeObserver={audioInputsChanged:e=>{this.logger.info(`audioInputsChanged ${typeof e}`),e?.forEach(t=>{this.logger.info(`Device ID: ${t.deviceId} Microphone: ${t.label}`);});},audioOutputsChanged:e=>{this.logger.info(`audioOutputsChanged ${typeof e}`),e?.forEach(t=>{this.logger.info(`Device ID: ${t.deviceId} Speaker: ${t.label}`);});},audioInputMuteStateChanged:(e,t)=>{this.logger.info(`Device ${e.toString()} ${t?"is muted in hardware":"is not muted"}`);}},this.audioVideoObserver={audioVideoDidStart:()=>{this.logger.info("Started");},audioVideoDidStop:e=>{this.logger.info(`Stopped with a session status code: ${e.statusCode()}`);},audioVideoDidStartConnecting:e=>{e&&this.logger.info("Attempting to reconnect");}},this.audioMixObserver={meetingAudioStreamBecameActive:e=>{if(this.$audio.paused){let t=()=>this.$audio.play().then(()=>{}).catch(n=>{if(m.error("\u64AD\u653E\u8FDC\u7AEF\u6D41\u5931\u8D25\uFF01",n),typeof this._autoPlayConfirm=="function"){let r=()=>t();this._autoPlayConfirm({onConfirm:r});}});t();}},meetingAudioStreamBecameInactive:e=>{}};};async join(e){return new Promise(async(t,n)=>{this.emit("joinWillStart");try{let{sdkAppId:r,userId:s,roomId:o,userSig:c}=await this._getVoiceSign({...e,roomId:e.roomId||0});this.userId=s;let{attendence:a,vendor_wrapper:l}=JSON.parse(decodeURIComponent(c)),d=new MeetingSessionConfiguration({Meeting:l},{Attendee:{ExternalUserId:a.external_user_id,AttendeeId:a.attendee_id,JoinToken:a.join_token}});this.meetingSession=new DefaultMeetingSession(d,this.logger,this.deviceController),this._registerRtcEvent(),this.meetingSession.audioVideo.addDeviceChangeObserver(this.deviceChangeObserver),this.meetingSession.audioVideo.addObserver(this.audioVideoObserver),this.meetingSession.audioVideo.bindAudioElement(this.$audio);let f={audioVideoDidStart:()=>{this.meetingSession?.audioVideo.realtimeMuteLocalAudio(),this.joined=!0,this.emit("joined"),t(!0);},audioVideoDidStop:()=>{this.joined=!1,t(!1);}};this.meetingSession.audioVideo.addObserver(f),this.audioMixObserver&&this.meetingSession.audioVideo.addAudioMixObserver(this.audioMixObserver),this.meetingSession.audioVideo.setDeviceLabelTrigger(async()=>await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}));try{let p=await this.meetingSession.audioVideo.listAudioInputDevices();m.info("audioInputDevices ===>",p);let g=p[0]?.deviceId||"default";await this.meetingSession.audioVideo.startAudioInput(g);}catch(p){m.error(`\u8BBE\u7F6E\u8BED\u97F3\u8F93\u5165\u8BBE\u5907\u5931\u8D25:${p.message}`);}try{let p=await this.meetingSession.audioVideo.listAudioOutputDevices();m.info("audioOutputDevices ===>",p);let g=p[0]?.deviceId||"default";await this.meetingSession.audioVideo.chooseAudioOutput(g);}catch(p){m.error(`\u8BBE\u7F6E\u8BED\u97F3\u8F93\u51FA\u8BBE\u5907\u5931\u8D25:${p.message}`);}this.meetingSession.audioVideo.start();}catch(r){this.emit("error",r),this.logger.error(r.message),t(!1);}})}_registerRtcEvent=()=>{let e=this.meetingSession?.configuration?.credentials?.attendeeId||"";if(e){let t=new Map,n=()=>{let r=[];return t.forEach((s,o)=>{r.push({userId:s.userId,volume:s.muted||s.signalStrength===0||!s.volume?0:s.volume});}),r};this.meetingSession?.audioVideo.realtimeSubscribeToAttendeeIdPresence((r,s,o)=>{if(!s){t.delete(r),this.emit("userVolumes",n());return}this.meetingSession?.audioVideo.realtimeSubscribeToVolumeIndicator(r,(c,a,l,d)=>{new DefaultModality(c).base()===c&&(t.set(c,{userId:o||c,volume:a,muted:l,signalStrength:d}),this.emit("userVolumes",n()));});}),this.meetingSession?.audioVideo.realtimeSubscribeToVolumeIndicator(e,(r,s,o,c)=>{new DefaultModality(r).base()===r&&c!==null&&c!==1&&this.emit("weakNetwork");}),this.meetingSession?.audioVideo.realtimeSubscribeToFatalError(r=>this.emit("error",r));}};quit(){return this.joined?new Promise((e,t)=>{this.joined=!1;let n={audioVideoDidStop:async r=>{let s=r.statusCode();this.meetingSession?.deviceController.destroy(),s===MeetingSessionStatusCode.Left?(this.logger.info("You left the session"),e(!0)):(this.logger.info(`Stopped with a session status code: ${s}`),e(!0));}};this.meetingSession?.audioVideo.addObserver(n),this.meetingSession?.audioVideo.stop();}):Promise.resolve(!0)}async detectMicro(){return new Promise(e=>{let t={audio:!0,video:!1};try{navigator.mediaDevices.getUserMedia(t).then(()=>e(!0)).catch(()=>e(!1));}catch(n){this.logger.error(n.message),e(!1);}})}async toggleMicro(e){e?this.meetingSession?.audioVideo.realtimeUnmuteLocalAudio():this.meetingSession?.audioVideo.realtimeMuteLocalAudio();let t=this.meetingSession?.audioVideo.realtimeIsLocalAudioMuted();return t!==void 0?e!==t:!1}shock(){throw new Error("Method not implemented.")}};var Mn=(s=>(s[s.Success=0]="Success",s[s.Failure=1]="Failure",s[s.ReJoin=2]="ReJoin",s[s.NoMicroPermission=3]="NoMicroPermission",s[s.Unknown=500]="Unknown",s))(Mn||{});var he=class extends J{type="RealseeVRWebViewRTC";joined=!1;micro=!1;voiceId="";_joinOptions=null;options;get jsBridge(){return this.options.jsBridge}constructor({jsBridge:e,getVoiceSign:t}){super(),this.options={jsBridge:e,getVoiceSign:t},this.jsBridge.webViewType!=="WxMiniProgramWebView"&&this.jsBridge.callAndListen("live/userVolumes",this.handleUserVolumes),this.jsBridge.callAndListen("live/weakNetwork",this.handleWeakNetwork),this.on("inner.rtc.fail",this.handleJoinResult);}handleUserVolumes=e=>{this.emit("userVolumes",e);};handleWeakNetwork=e=>{e&&this.emit("weakNetwork");};join=async e=>{this._joinOptions=e,this.emit("joinWillStart");let{sdkAppId:t,userId:n,userSig:r}=await this.getVoiceSignOrEmitError(e);return !t||!n||!r?!1:(this.type=e.type,this.jsBridge.webViewType==="WxMiniProgramWebView"?this.handleWxMiniProgramWebViewJoin({sdkAppId:t,userId:n,userSig:r,voiceId:e.voiceId}):this.handleAppWebViewJoin({sdkAppId:t,userId:n,userSig:r,voiceId:e.voiceId}))};reJoin=async()=>this._joinOptions?this.join({voiceId:this._joinOptions.voiceId,userId:this._joinOptions.userId,roomId:this._joinOptions.roomId,type:this._joinOptions.type}):(this.emitErrorAndSetJoinedFalse("\u91CD\u8FDE\u5931\u8D25\uFF1A\u672A\u627E\u5230\u52A0\u5165\u623F\u95F4\u53C2\u6570\u3002"),!1);getVoiceSignOrEmitError=async e=>{try{return await this.options.getVoiceSign(e)}catch{return this.emitErrorAndSetJoinedFalse("\u52A0\u5165\u623F\u95F4\u5931\u8D25\uFF1Artc \u7B7E\u540D\u8BF7\u6C42\u5F02\u5E38"),{}}};handleWxMiniProgramWebViewJoin=async e=>{let[t,n]=await this.joinRoomOrEmitError(e);return n?!1:this.handleJoinResult(t)};handleAppWebViewJoin=e=>new Promise(t=>{this.off("inner.rtc.success");let n=r=>{this.off("inner.rtc.fail",n),this.off("inner.rtc.success",n),t(this.handleJoinResult(r));};this.once("inner.rtc.fail",n),this.once("inner.rtc.success",n);try{let{sdkAppId:r,userId:s,userSig:o,voiceId:c}=e;this.jsBridge.callAndListen(`live/join?sdkAppID=${r}&userID=${s}&roomID=${c}&userSig=${o}`,a=>{a===!0?this.emit("inner.rtc.success",a):typeof a=="object"?a.code===0||a.code===2?this.emit("inner.rtc.success",a):this.emit("inner.rtc.fail",a):this.emit("inner.rtc.fail",a);});}catch(r){t(this.handleJoinResult({message:r.message,code:500}));}});joinRoomOrEmitError=async({sdkAppId:e,userId:t,voiceId:n,userSig:r})=>{try{return await this.jsBridge.callAndBackfeed(`live/join?sdkAppID=${e}&userID=${t}&roomID=${Number(n)}&userSig=${r}`)}catch(s){return this.emitErrorAndSetJoinedFalse("\u52A0\u5165\u623F\u95F4\u5931\u8D25\uFF1A"+s.message),[null,s]}};handleJoinResult=e=>{switch(!0){case e===!0:case(typeof e=="object"&&e.code===0):case(typeof e=="object"&&e.code===2):{this.emit("joined"),this.joined=!0;break}default:{this.joined=!1;let t=typeof e=="object"?e.message:"\u52A0\u5165\u623F\u95F4\u5931\u8D25\uFF1A\u672A\u77E5\u5F02\u5E38\u3002";this.emit("error",new Error(t,{cause:e}));}}return this.joined};emitErrorAndSetJoinedFalse=e=>{this.emit("error",new Error(e)),this.joined=!1;};quit=async()=>{let[e,t]=await this.jsBridge.callAndBackfeed("live/quit");return e===null&&this.emit("error",t||new Error("\u9000\u51FA\u623F\u95F4\u5931\u8D25\uFF1A\u672A\u77E5\u5F02\u5E38\u3002")),this.joined=!1,!!e};detectMicro=async()=>{let[e,t]=await this.jsBridge.detectMicro();return e===null?(this.emit("error",t||new Error("\u9EA6\u514B\u98CE\u76D1\u6D4B\u5F02\u5E38\uFF01")),!1):e};toggleMicro=async e=>{let[t,n]=await this.jsBridge.callAndBackfeed(`live/toggleMicro?flag=${e?1:0}`);return t===null?(this.emit("error",n||new Error("\u9EA6\u514B\u98CE\u76D1\u6D4B\u5F02\u5E38\uFF01")),!1):(this.micro=t,t)};shock=()=>{this.jsBridge.shock(1);}};var Kn=(a=>(a.SelfUserInfo="SELF_USER_INFO",a.RoomInfo="ROOM_INFO",a.RTCInfo="RTC_INFO",a.UserList="USER_LIST",a.BuiltinMsg="BUILTIN_MSG",a.CustomEvent="CUSTOM_EVENT",a.KeyframeSync="KEYFRAME_SYNC",a.UserKickOut="USER_KICK_OUT",a))(Kn||{}),Nn=(t=>(t.UserChange="user_change",t.RoomChange="room_change",t))(Nn||{}),Bn=(o=>(o.UserMicroStatus="change_micro_status",o.UserMicroStatusSync="sync_micro_status",o.UserPermission="change_permission",o.UserStatus="change_status",o.UserInfo="change_info",o.RoomClose="close",o))(Bn||{}),Pn=(t=>(t.OPEN="OPEN",t.CLOSE="CLOSE",t))(Pn||{});function hr(i){try{let e=JSON.parse(i),t={code:e.code,message:e.message,command:e.command,roomCode:e.room_code,appID:e.app_id,requestId:e.request_id,frontRequestId:e.front_request_id,triggerUserID:e.trigger_user_id,data:e.data||{}},n=Object.keys(t).filter(r=>t[r]===void 0);return n.length>0&&console.warn(`\u63A8\u9001\u6570\u636E\u683C\u5F0F\u5F02\u5E38\uFF1A${n.join(" ")} \u503C\u4E0D\u5B58\u5728\uFF01`),t}catch{return !1}}var jn=(r=>(r[r.NOTINITIALIZED=-1]="NOTINITIALIZED",r[r.CONNECTING=0]="CONNECTING",r[r.OPEN=1]="OPEN",r[r.CLOSED=3]="CLOSED",r))(jn||{});var Wn=(n=>(n[n.Normal=0]="Normal",n[n.Removed=1]="Removed",n[n.Replaced=2]="Replaced",n))(Wn||{}),$n=(o=>(o.WAIT_ENTER="WAIT_ENTER",o.ONLINE="ONLINE",o.LEAVE="LEAVE",o.KICK_OUT="KICK_OUT",o.BE_REPLACE="BE_REPLACE",o.EXCEPTION="EXCEPTION",o))($n||{});var Fn=(s=>(s[s.NOTINITIALIZED=-1]="NOTINITIALIZED",s[s.CONNECTING=0]="CONNECTING",s[s.OPEN=1]="OPEN",s[s.CLOSING=2]="CLOSING",s[s.CLOSED=3]="CLOSED",s))(Fn||{}),Jn=(c=>(c.Error="Error",c.Close="Close",c.MicroAuth="MicroAuth",c.DuplicateConnect="DuplicateConnect",c.IllegalURL="IllegalURL",c.Unknown="Unknown",c.IllegalArgs="IllegalArgs",c))(Jn||{}),Gn=(l=>(l.Err_1000="CLOSE_NORMAL",l.Err_1001="CLOSE_GOING_AWAY",l.Err_1002="CLOSE_PROTOCOL_ERROR",l.Err_1003="CLOSE_UNSUPPORTED",l.Err_1006="CLOSE_ABNORMAL",l.Err_1007="Unsupported Data",l.Err_1008="Policy Violation",l.Err_1009="CLOSE_TOO_LARGE",l.Err_unknown="unknown",l))(Gn||{});function kt(i){switch(i){case 1e3:return "CLOSE_NORMAL";case 1001:return "CLOSE_GOING_AWAY";case 1002:return "CLOSE_PROTOCOL_ERROR";case 1003:return "CLOSE_UNSUPPORTED";case 1006:return "CLOSE_ABNORMAL";case 1007:return "Unsupported Data";case 1008:return "Policy Violation";case 1009:return "CLOSE_TOO_LARGE";}return "unknown"}function vt(i,e={}){let t=new URL(i,"http://localhost"),n=new URLSearchParams(t.search);return Object.entries(e).forEach(([r,s])=>{n.append(r,String(s));}),i.split("?")[0]+"?"+n.toString()}var Ct=(()=>{let i=typeof process<"u"&&process.versions?.node!=null;return typeof window<"u"&&"Deno"in window||i||typeof window>"u"})();var ue=Ct?"":navigator.userAgent,Et=/android/i.test(ue),It=/iPhone|iPad\s+OS/i.test(ue),Tt=/MicroMessenger/i.test(ue)&&/miniProgram/i.test(ue),Rt=/realsee/i.test(ue);function ve(i){return Object.prototype.toString.call(i)==="[object Object]"}function Ce(i,e){return i===e?!0:i==null||e==null||typeof i!=typeof e?!1:Number.isNaN(i)&&Number.isNaN(e)}function qn(i,e){if(i===e)return !0;if(i==null||e==null)return !1;let t=Object.keys(i),n=Object.keys(e);return t.length!==n.length?!1:t.every(r=>Ce(i[r],e[r]))}function Hn(i,e){return i===e?!0:i==null||e==null||i.length!==e.length?!1:i.every((t,n)=>Ce(t,e[n]))}function zn(i,e){return Ce(i,e)?!0:ve(i)&&ve(e)?qn(i,e):Array.isArray(i)&&Array.isArray(e)?Hn(i,e):!1}function Je(i,e){return Ce(i,e)?!0:ve(i)&&ve(e)?Xn(i,e):Array.isArray(i)&&Array.isArray(e)?Yn(i,e):!1}function Yn(i,e){if(i.length!==e.length)return !1;for(let t=0,n=i.length;t<n;t++)if(!Je(i[t],e[t]))return !1;return !0}function Xn(i,e){if(i===e)return !0;if(i==null||e==null)return !1;let t=Object.keys(i),n=Object.keys(e);return t.length!==n.length?!1:t.every(r=>Je(i[r],e[r]))}function Dt(i,e,t={deep:!1}){return t.deep?Je(i,e):zn(i,e)}var Ee=class extends P{_realWebSocket;_url;_protocols;_readyState=-1;_options={timeout:1e4,shouldReconnect:(e,t)=>{if(!(e.code===1008||e.code===1011))return [0,1e3,2e3][t.attempts%3]},should1000Reconnect:!1,ignoreConnectivityEvents:!1,automaticOpen:!1};_connectTimeout;_attempts=0;_reconnects=-1;_reconnectWhenOnlineAgain=!1;_explicitlyClosed=!1;_pendingReconnect;_connectivityEventsAttached=!1;_heathCheckTimer;get attempts(){return this._attempts}constructor(e){super(),e&&this.setOptions(e),this._startHealthCheck();}setOptions(e){if(!e)return;this._url=e.url,this._protocols=e.protocols;let t=Object.assign(this._options,e.robustOptions||{});if(typeof t?.timeout!="number")throw new Error("timeout must be the number of milliseconds to timeout a connection attempt");if(typeof t?.shouldReconnect!="function")throw new Error("shouldReconnect must be a function that returns the number of milliseconds to wait for a reconnect attempt, or null or undefined to not reconnect.");this._options=t,this._options.automaticOpen&&this._createWebSocket();}_healthCheck=async()=>{if(this._realWebSocket){let e=this._realWebSocket.readyState;e!==this._readyState&&(this._readyState=e,this._readyState===2&&this.emit("closing"));}await new Promise(e=>setTimeout(e,2e3)),this._heathCheckTimer=requestAnimationFrame(this._healthCheck);};_clearConnectTimeoutIfNeed=()=>{this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=void 0);};_clearHeathCheckIfNeed=()=>{this._heathCheckTimer&&(cancelAnimationFrame(this._heathCheckTimer),this._heathCheckTimer=void 0);};_startHealthCheck=()=>{this._clearHeathCheckIfNeed(),this._heathCheckTimer=requestAnimationFrame(this._healthCheck);};_stopHealthCheck=()=>{this._clearHeathCheckIfNeed();};_clearPendingReconnectIfNeeded=()=>{this._pendingReconnect&&(clearTimeout(this._pendingReconnect),this._pendingReconnect=void 0);};_online=e=>{this._reconnectWhenOnlineAgain&&(this._clearPendingReconnectIfNeeded(),this._reconnect(e));};_offline=()=>{this._reconnectWhenOnlineAgain=!0,this._realWebSocket?.close(1e3,"offline");};_detachConnectivityEvents=()=>{this._connectivityEventsAttached&&(globalThis?.removeEventListener("online",this._online),globalThis?.removeEventListener("offline",this._offline),this._connectivityEventsAttached=!1);};_attachConnectivityEvents=()=>{this._connectivityEventsAttached||(globalThis?.addEventListener("online",this._online),globalThis?.addEventListener("offline",this._offline),this._connectivityEventsAttached=!0);};send=e=>{this._realWebSocket?.readyState===this._realWebSocket?.OPEN&&this._realWebSocket?.send(e);};close=(e,t)=>(typeof e!="number"&&(t=e,e=1e3),this._clearPendingReconnectIfNeeded(),this._reconnectWhenOnlineAgain=!1,this._explicitlyClosed=!0,this._detachConnectivityEvents(),this._realWebSocket?.close(e,t));open=e=>{e&&(this._url=e),this._realWebSocket?.readyState!==WebSocket.OPEN&&this._realWebSocket?.readyState!==WebSocket.CONNECTING&&(this._clearPendingReconnectIfNeeded(),this._reconnectWhenOnlineAgain=!1,this._explicitlyClosed=!1,this._createWebSocket());};_createWebSocket=()=>{let e=typeof this._url=="string"?this._url:this._url?.(this);if(!e)return;this._clearConnectTimeoutIfNeed(),this._clearPendingReconnectIfNeeded(),this._removeWebSocketEvent(),this._realWebSocket=new WebSocket(e,this._protocols||void 0),this._attempts++,this.emit("connecting",new CustomEvent("connecting",{detail:{attempts:this._attempts,reconnects:this._reconnects}}));let t=()=>{this._connectTimeout=void 0,this._detachConnectivityEvents(),this.emit("timeout",new CustomEvent("timeout",{detail:{attempts:this._attempts,reconnects:this._reconnects}}));};this._connectTimeout=setTimeout(t,this._options.timeout),this._dispatchWebSocketEvent(),this._options.ignoreConnectivityEvents||this._attachConnectivityEvents();};_removeWebSocketEvent=()=>{this._realWebSocket?.removeEventListener("open",this._webSocketOpenHandler),this._realWebSocket?.removeEventListener("close",this._webSocketCloseHandler),this._realWebSocket?.removeEventListener("error",this._webSocketErrorHandler),this._realWebSocket?.removeEventListener("message",this._webSocketMessageHandler);};_dispatchWebSocketEvent=()=>{this._realWebSocket?.addEventListener("open",this._webSocketOpenHandler),this._realWebSocket?.addEventListener("close",this._webSocketCloseHandler),this._realWebSocket?.addEventListener("error",this._webSocketErrorHandler),this._realWebSocket?.addEventListener("message",this._webSocketMessageHandler);};_webSocketOpenHandler=e=>{this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=void 0);let t=++this._reconnects,n=this._attempts;return this._attempts=0,this._reconnectWhenOnlineAgain=!1,this._startHealthCheck(),this.emit("open",Object.assign(e,{detail:{reconnects:t,attempts:n}}))};_webSocketCloseHandler=e=>(this._reconnect(e),this._stopHealthCheck(),this.emit("close",e));_webSocketErrorHandler=e=>this.emit("error",new CustomEvent("error",{detail:{error:e}}));_webSocketMessageHandler=e=>this.emit("message",e);_reconnect(e){if(!this._options.should1000Reconnect&&e.code===1e3||this._explicitlyClosed){this._attempts=0;return}if(this._connectivityEventsAttached&&globalThis?.navigator?.onLine===!1){this._reconnectWhenOnlineAgain=!0;return}let r=this._options.shouldReconnect?.(e,this);typeof r=="number"?(console.log(`Reconnecting in ${r}ms...`),this._pendingReconnect=setTimeout(this._createWebSocket,r)):console.log("No reconnection will be attempted.");}};var Ie=class extends P{_ws=new Ee({url:"",robustOptions:{should1000Reconnect:!0,ignoreConnectivityEvents:!0}});_state=-1;set state(e){let t=JSON.parse(JSON.stringify(this._state));this._state=e,this.emit("stateChange",this.state,t);}get state(){return this._state}constructor(){super(),this._addWebSocketEventListeners();}_addWebSocketEventListeners=()=>{this._ws.on("close",this._handleCloseEvent),this._ws.on("closing",this._handleClosingEvent),this._ws.on("connecting",this._handleConnectingEvent),this._ws.on("error",this._handleErrorEvent),this._ws.on("message",this._handleMessageEvent),this._ws.on("open",this._handleOpenEvent),this._ws.on("timeout",this._handleTimeoutEvent);};_removeWebSocketEventListeners=()=>{this._ws.off("close",this._handleCloseEvent),this._ws.off("closing",this._handleClosingEvent),this._ws.off("connecting",this._handleConnectingEvent),this._ws.off("error",this._handleErrorEvent),this._ws.off("message",this._handleMessageEvent),this._ws.off("open",this._handleOpenEvent),this._ws.off("timeout",this._handleTimeoutEvent);};_handleCloseEvent=e=>{m.info(`live room closed bacause of ${e.code}-${e.reason||kt(e.code)}`),this.state=3;};_handleClosingEvent=()=>{m.info("live room is closing, onLine:",globalThis?.navigator?.onLine),this.state=3;};_handleConnectingEvent=e=>{m.info("live room is connecting"),this.state=0,e.detail.reconnects>0&&this.emit("reconnecting",e.detail);};_handleErrorEvent=e=>{m.error("live room error",e),this.state=3;};_handleMessageEvent=e=>{let t=(()=>{try{return JSON.parse(e.data)}catch{return e.data}})();this.emit("message",t);};_handleOpenEvent=e=>{m.info("live room open",e.detail),this.state=1,e.detail.reconnects>0&&this.emit("reconnected",e.detail);};_handleTimeoutEvent=e=>{m.error("live room connect timeout!",e.detail),this.state=3;};dispose=async()=>(this._removeWebSocketEventListeners(),await this.close("live room close by controller disposed!"));open=e=>this._ws.open(e);close=(e,t)=>new Promise(n=>{this._ws.once("close",()=>n(!0)),this._ws.close(e,t);});sendMessage(e=""){if(e==null)throw new Error("live message is empty!");if(this.state!==1)throw new Error("live has not yet been initialized!");return this._ws.send(JSON.stringify(e))}readyClose(){this._ws&&(this._ws._explicitlyClosed=!0);}};var ze=class{constructor(e,t){this.clock=e,this.len=t;}},Ue=class{constructor(){this.clients=new Map;}},jt=(i,e,t)=>e.clients.forEach((n,r)=>{let s=i.doc.store.clients.get(r);for(let o=0;o<n.length;o++){let c=n[o];Ht(i,s,c.clock,c.len,t);}}),ii=(i,e)=>{let t=0,n=i.length-1;for(;t<=n;){let r=A.floor((t+n)/2),s=i[r],o=s.clock;if(o<=e){if(e<o+s.len)return r;t=r+1;}else n=r-1;}return null},Wt=(i,e)=>{let t=i.clients.get(e.client);return t!==void 0&&ii(t,e.clock)!==null},$t=i=>{i.clients.forEach(e=>{e.sort((r,s)=>r.clock-s.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],s=e[t];r.clock+r.len>=s.clock?r.len=A.max(r.len,s.clock+s.len-r.clock):(n<t&&(e[n]=s),n++);}e.length=n;});};var Ft=(i,e,t,n)=>{x.setIfUndefined(i.clients,e,()=>[]).push(new ze(t,n));};var si=(i,e)=>{u.writeVarUint(i.restEncoder,e.clients.size),K.from(e.clients.entries()).sort((t,n)=>n[0]-t[0]).forEach(([t,n])=>{i.resetDsCurVal(),u.writeVarUint(i.restEncoder,t);let r=n.length;u.writeVarUint(i.restEncoder,r);for(let s=0;s<r;s++){let o=n[s];i.writeDsClock(o.clock),i.writeDsLen(o.len);}});};var Jt=Ne.uint32,ee=class i extends ObservableV2{constructor({guid:e=Ne.uuidv4(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:s=null,autoLoad:o=!1,shouldLoad:c=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=Jt(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new it,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=o,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=He.create(l=>{this.on("load",()=>{this.isLoaded=!0,l(this);});});let a=()=>He.create(l=>{let d=f=>{(f===void 0||f===!0)&&(this.off("sync",d),l());};this.on("sync",d);});this.on("sync",l=>{l===!1&&this.isSynced&&(this.whenSynced=a()),this.isSynced=l===void 0||l===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this]);}),this.whenSynced=a();}load(){let e=this._item;e!==null&&!this.shouldLoad&&b(e.parent.doc,t=>{t.subdocsLoaded.add(this);},null,!0),this.shouldLoad=!0;}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(K.from(this.subdocs).map(e=>e.guid))}transact(e,t=null){return b(this,e,t)}get(e,t=I){let n=x.setIfUndefined(this.share,e,()=>{let s=new t;return s._integrate(this,null),s}),r=n.constructor;if(t!==I&&r!==t)if(r===I){let s=new t;s._map=n._map,n._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=s;}),s._start=n._start;for(let o=s._start;o!==null;o=o.right)o.parent=s;return s._length=n._length,this.share.set(e,s),s._integrate(this,null),s}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=""){return this.get(e,at)}getText(e=""){return this.get(e,ut)}getMap(e=""){return this.get(e,dt)}getXmlElement(e=""){return this.get(e,Ae)}getXmlFragment(e=""){return this.get(e,we)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON();}),e}destroy(){this.isDestroyed=!0,K.from(this.subdocs).forEach(t=>t.destroy());let e=this._item;if(e!==null){this._item=null;let t=e.content;t.doc=new i({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,b(e.parent.doc,n=>{let r=t.doc;e.deleted||n.subdocsAdded.add(r),n.subdocsRemoved.add(this);},null,!0);}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy();}};var Ye=class{constructor(){this.restEncoder=u.createEncoder();}toUint8Array(){return u.toUint8Array(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){u.writeVarUint(this.restEncoder,e);}writeDsLen(e){u.writeVarUint(this.restEncoder,e);}},Xe=class extends Ye{writeLeftID(e){u.writeVarUint(this.restEncoder,e.client),u.writeVarUint(this.restEncoder,e.clock);}writeRightID(e){u.writeVarUint(this.restEncoder,e.client),u.writeVarUint(this.restEncoder,e.clock);}writeClient(e){u.writeVarUint(this.restEncoder,e);}writeInfo(e){u.writeUint8(this.restEncoder,e);}writeString(e){u.writeVarString(this.restEncoder,e);}writeParentInfo(e){u.writeVarUint(this.restEncoder,e?1:0);}writeTypeRef(e){u.writeVarUint(this.restEncoder,e);}writeLen(e){u.writeVarUint(this.restEncoder,e);}writeAny(e){u.writeAny(this.restEncoder,e);}writeBuf(e){u.writeVarUint8Array(this.restEncoder,e);}writeJSON(e){u.writeVarString(this.restEncoder,JSON.stringify(e));}writeKey(e){u.writeVarString(this.restEncoder,e);}},Ze=class{constructor(){this.restEncoder=u.createEncoder(),this.dsCurrVal=0;}toUint8Array(){return u.toUint8Array(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0;}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,u.writeVarUint(this.restEncoder,t);}writeDsLen(e){e===0&&S.unexpectedCase(),u.writeVarUint(this.restEncoder,e-1),this.dsCurrVal+=e;}},Qe=class extends Ze{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new u.IntDiffOptRleEncoder,this.clientEncoder=new u.UintOptRleEncoder,this.leftClockEncoder=new u.IntDiffOptRleEncoder,this.rightClockEncoder=new u.IntDiffOptRleEncoder,this.infoEncoder=new u.RleEncoder(u.writeUint8),this.stringEncoder=new u.StringEncoder,this.parentInfoEncoder=new u.RleEncoder(u.writeUint8),this.typeRefEncoder=new u.UintOptRleEncoder,this.lenEncoder=new u.UintOptRleEncoder;}toUint8Array(){let e=u.createEncoder();return u.writeVarUint(e,0),u.writeVarUint8Array(e,this.keyClockEncoder.toUint8Array()),u.writeVarUint8Array(e,this.clientEncoder.toUint8Array()),u.writeVarUint8Array(e,this.leftClockEncoder.toUint8Array()),u.writeVarUint8Array(e,this.rightClockEncoder.toUint8Array()),u.writeVarUint8Array(e,u.toUint8Array(this.infoEncoder)),u.writeVarUint8Array(e,this.stringEncoder.toUint8Array()),u.writeVarUint8Array(e,u.toUint8Array(this.parentInfoEncoder)),u.writeVarUint8Array(e,this.typeRefEncoder.toUint8Array()),u.writeVarUint8Array(e,this.lenEncoder.toUint8Array()),u.writeUint8Array(e,u.toUint8Array(this.restEncoder)),u.toUint8Array(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock);}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock);}writeClient(e){this.clientEncoder.write(e);}writeInfo(e){this.infoEncoder.write(e);}writeString(e){this.stringEncoder.write(e);}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0);}writeTypeRef(e){this.typeRefEncoder.write(e);}writeLen(e){this.lenEncoder.write(e);}writeAny(e){u.writeAny(this.restEncoder,e);}writeBuf(e){u.writeVarUint8Array(this.restEncoder,e);}writeJSON(e){u.writeAny(this.restEncoder,e);}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t);}},oi=(i,e,t,n)=>{n=A.max(n,e[0].id.clock);let r=G(e,n);u.writeVarUint(i.restEncoder,e.length-r),i.writeClient(t),u.writeVarUint(i.restEncoder,n);let s=e[r];s.write(i,n-s.id.clock);for(let o=r+1;o<e.length;o++)e[o].write(i,0);},ci=(i,e,t)=>{let n=new Map;t.forEach((r,s)=>{M(e,s)>r&&n.set(s,r);}),mt(e).forEach((r,s)=>{t.has(s)||n.set(s,0);}),u.writeVarUint(i.restEncoder,n.size),K.from(n.entries()).sort((r,s)=>s[0]-r[0]).forEach(([r,s])=>{oi(i,e.clients.get(r),r,s);});};var ai=(i,e)=>ci(i,e.doc.store,e.beforeState);var et=class{constructor(){this.l=[];}},Ot=()=>new et,Ut=(i,e)=>i.l.push(e),Lt=(i,e)=>{let t=i.l,n=t.length;i.l=t.filter(r=>e!==r),n===i.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.");},Gt=(i,e,t)=>pt.callAll(i.l,[e,t]),re=class{constructor(e,t){this.client=e,this.clock=t;}},Te=(i,e)=>i===e||i!==null&&e!==null&&i.client===e.client&&i.clock===e.clock,k=(i,e)=>new re(i,e);var li=i=>{for(let[e,t]of i.doc.share.entries())if(t===i)return e;throw S.unexpectedCase()};var ne=(i,e)=>e===void 0?!i.deleted:e.sv.has(i.id.client)&&(e.sv.get(i.id.client)||0)>i.id.clock&&!Wt(e.ds,i.id),nt=(i,e)=>{let t=x.setIfUndefined(i.meta,nt,ge.create),n=i.doc.store;t.has(e)||(e.sv.forEach((r,s)=>{r<M(n,s)&&X(i,k(s,r));}),jt(i,e.ds,r=>{}),t.add(e));};var it=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null;}},mt=i=>{let e=new Map;return i.clients.forEach((t,n)=>{let r=t[t.length-1];e.set(n,r.id.clock+r.length);}),e},M=(i,e)=>{let t=i.clients.get(e);if(t===void 0)return 0;let n=t[t.length-1];return n.id.clock+n.length},qt=(i,e)=>{let t=i.clients.get(e.id.client);if(t===void 0)t=[],i.clients.set(e.id.client,t);else {let n=t[t.length-1];if(n.id.clock+n.length!==e.id.clock)throw S.unexpectedCase()}t.push(e);},G=(i,e)=>{let t=0,n=i.length-1,r=i[n],s=r.id.clock;if(s===e)return n;let o=A.floor(e/(s+r.length-1)*n);for(;t<=n;){if(r=i[o],s=r.id.clock,s<=e){if(e<s+r.length)return o;t=o+1;}else n=o-1;o=A.floor((t+n)/2);}throw S.unexpectedCase()},hi=(i,e)=>{let t=i.clients.get(e.client);return t[G(t,e.clock)]},Ge=hi,rt=(i,e,t)=>{let n=G(e,t),r=e[n];return r.id.clock<t&&r instanceof V?(e.splice(n+1,0,un(i,r,t-r.id.clock)),n+1):n},X=(i,e)=>{let t=i.doc.store.clients.get(e.client);return t[rt(i,t,e.clock)]},Vt=(i,e,t)=>{let n=e.clients.get(t.client),r=G(n,t.clock),s=n[r];return t.clock!==s.id.clock+s.length-1&&s.constructor!==W&&n.splice(r+1,0,un(i,s,t.clock-s.id.clock+1)),s},ui=(i,e,t)=>{let n=i.clients.get(e.id.client);n[G(n,e.id.clock)]=t;},Ht=(i,e,t,n,r)=>{if(n===0)return;let s=t+n,o=rt(i,e,t),c;do c=e[o++],s<c.id.clock+c.length&&rt(i,e,s),r(c);while(o<e.length&&e[o].id.clock<s)},st=class{constructor(e,t,n){this.doc=e,this.deleteSet=new Ue,this.beforeState=mt(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1;}},At=(i,e)=>e.deleteSet.clients.size===0&&!x.any(e.afterState,(t,n)=>e.beforeState.get(n)!==t)?!1:($t(e.deleteSet),ai(i,e),si(i,e.deleteSet),!0),xt=(i,e,t)=>{let n=e._item;(n===null||n.id.clock<(i.beforeState.get(n.id.client)||0)&&!n.deleted)&&x.setIfUndefined(i.changed,e,ge.create).add(t);},Oe=(i,e)=>{let t=i[e],n=i[e-1],r=e;for(;r>0;t=n,n=i[--r-1]){if(n.deleted===t.deleted&&n.constructor===t.constructor&&n.mergeWith(t)){t instanceof V&&t.parentSub!==null&&t.parent._map.get(t.parentSub)===t&&t.parent._map.set(t.parentSub,n);continue}break}let s=e-r;return s&&i.splice(e+1-s,s),s},fi=(i,e,t)=>{for(let[n,r]of i.clients.entries()){let s=e.clients.get(n);for(let o=r.length-1;o>=0;o--){let c=r[o],a=c.clock+c.len;for(let l=G(s,c.clock),d=s[l];l<s.length&&d.id.clock<a;d=s[++l]){let f=s[l];if(c.clock+c.len<=f.id.clock)break;f instanceof V&&f.deleted&&!f.keep&&t(f)&&f.gc(e,!1);}}}},gi=(i,e)=>{i.clients.forEach((t,n)=>{let r=e.clients.get(n);for(let s=t.length-1;s>=0;s--){let o=t[s],c=A.min(r.length-1,1+G(r,o.clock+o.len-1));for(let a=c,l=r[a];a>0&&l.id.clock>=o.clock;l=r[a])a-=1+Oe(r,a);}});};var zt=(i,e)=>{if(e<i.length){let t=i[e],n=t.doc,r=n.store,s=t.deleteSet,o=t._mergeStructs;try{$t(s),t.afterState=mt(t.doc.store),n.emit("beforeObserverCalls",[t,n]);let c=[];t.changed.forEach((a,l)=>c.push(()=>{(l._item===null||!l._item.deleted)&&l._callObserver(t,a);})),c.push(()=>{t.changedParentTypes.forEach((a,l)=>{l._dEH.l.length>0&&(l._item===null||!l._item.deleted)&&(a=a.filter(d=>d.target._item===null||!d.target._item.deleted),a.forEach(d=>{d.currentTarget=l,d._path=null;}),a.sort((d,f)=>d.path.length-f.path.length),Gt(l._dEH,a,t));});}),c.push(()=>n.emit("afterTransaction",[t,n])),callAll(c,[]),t._needFormattingCleanup&&vi(t);}finally{n.gc&&fi(s,r,n.gcFilter),gi(s,r),t.afterState.forEach((d,f)=>{let p=t.beforeState.get(f)||0;if(p!==d){let g=r.clients.get(f),w=A.max(G(g,p),1);for(let T=g.length-1;T>=w;)T-=1+Oe(g,T);}});for(let d=o.length-1;d>=0;d--){let{client:f,clock:p}=o[d].id,g=r.clients.get(f),w=G(g,p);w+1<g.length&&Oe(g,w+1)>1||w>0&&Oe(g,w);}if(!t.local&&t.afterState.get(n.clientID)!==t.beforeState.get(n.clientID)&&(B.print(B.ORANGE,B.BOLD,"[yjs] ",B.UNBOLD,B.RED,"Changed the client-id because another client seems to be using it."),n.clientID=Jt()),n.emit("afterTransactionCleanup",[t,n]),n._observers.has("update")){let d=new Xe;At(d,t)&&n.emit("update",[d.toUint8Array(),t.origin,n,t]);}if(n._observers.has("updateV2")){let d=new Qe;At(d,t)&&n.emit("updateV2",[d.toUint8Array(),t.origin,n,t]);}let{subdocsAdded:c,subdocsLoaded:a,subdocsRemoved:l}=t;(c.size>0||l.size>0||a.size>0)&&(c.forEach(d=>{d.clientID=n.clientID,d.collectionid==null&&(d.collectionid=n.collectionid),n.subdocs.add(d);}),l.forEach(d=>n.subdocs.delete(d)),n.emit("subdocs",[{loaded:a,added:c,removed:l},n,t]),l.forEach(d=>d.destroy())),i.length<=e+1?(n._transactionCleanups=[],n.emit("afterAllTransactions",[n,i])):zt(i,e+1);}}},b=(i,e,t=null,n=!0)=>{let r=i._transactionCleanups,s=!1,o=null;i._transaction===null&&(s=!0,i._transaction=new st(i,t,n),r.push(i._transaction),r.length===1&&i.emit("beforeAllTransactions",[i]),i.emit("beforeTransaction",[i._transaction,i]));try{o=e(i._transaction);}finally{if(s){let c=i._transaction===r[0];i._transaction=null,c&&zt(r,0);}}return o};var Mt="You must not compute changes after the event-handler fired.",se=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null;}get path(){return this._path||(this._path=pi(this.currentTarget,this.target))}deletes(e){return Wt(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw S.create(Mt);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(r=>{if(r!==null){let s=t._map.get(r),o,c;if(this.adds(s)){let a=s.left;for(;a!==null&&this.adds(a);)a=a.left;if(this.deletes(s))if(a!==null&&this.deletes(a))o="delete",c=K.last(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",c=K.last(a.content.getContent())):(o="add",c=void 0);}else if(this.deletes(s))o="delete",c=K.last(s.content.getContent());else return;e.set(r,{action:o,oldValue:c});}}),this._keys=e;}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw S.create(Mt);let t=this.target,n=ge.create(),r=ge.create(),s=[];if(e={added:n,deleted:r,delta:s,keys:this.keys},this.transaction.changed.get(t).has(null)){let c=null,a=()=>{c&&s.push(c);};for(let l=t._start;l!==null;l=l.right)l.deleted?this.deletes(l)&&!this.adds(l)&&((c===null||c.delete===void 0)&&(a(),c={delete:0}),c.delete+=l.length,r.add(l)):this.adds(l)?((c===null||c.insert===void 0)&&(a(),c={insert:[]}),c.insert=c.insert.concat(l.content.getContent()),n.add(l)):((c===null||c.retain===void 0)&&(a(),c={retain:0}),c.retain+=l.length);c!==null&&c.retain===void 0&&a();}this._changes=e;}return e}},pi=(i,e)=>{let t=[];for(;e._item!==null&&e!==i;){if(e._item.parentSub!==null)t.unshift(e._item.parentSub);else {let n=0,r=e._item.parent._start;for(;r!==e._item&&r!==null;)!r.deleted&&r.countable&&(n+=r.length),r=r.right;t.unshift(n);}e=e._item.parent;}return t},L=()=>{B.warn("Invalid access: Add Yjs type to a document before reading data.");},Yt=80,yt=0,ot=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=yt++;}},mi=i=>{i.timestamp=yt++;},Xt=(i,e,t)=>{i.p.marker=!1,i.p=e,e.marker=!0,i.index=t,i.timestamp=yt++;},yi=(i,e,t)=>{if(i.length>=Yt){let n=i.reduce((r,s)=>r.timestamp<s.timestamp?r:s);return Xt(n,e,t),n}else {let n=new ot(e,t);return i.push(n),n}},Be=(i,e)=>{if(i._start===null||e===0||i._searchMarker===null)return null;let t=i._searchMarker.length===0?null:i._searchMarker.reduce((s,o)=>A.abs(e-s.index)<A.abs(e-o.index)?s:o),n=i._start,r=0;for(t!==null&&(n=t.p,r=t.index,mi(t));n.right!==null&&r<e;){if(!n.deleted&&n.countable){if(e<r+n.length)break;r+=n.length;}n=n.right;}for(;n.left!==null&&r>e;)n=n.left,!n.deleted&&n.countable&&(r-=n.length);for(;n.left!==null&&n.left.id.client===n.id.client&&n.left.id.clock+n.left.length===n.id.clock;)n=n.left,!n.deleted&&n.countable&&(r-=n.length);return t!==null&&A.abs(t.index-r)<n.parent.length/Yt?(Xt(t,n,r),t):yi(i._searchMarker,n,r)},pe=(i,e,t)=>{for(let n=i.length-1;n>=0;n--){let r=i[n];if(t>0){let s=r.p;for(s.marker=!1;s&&(s.deleted||!s.countable);)s=s.left,s&&!s.deleted&&s.countable&&(r.index-=s.length);if(s===null||s.marker===!0){i.splice(n,1);continue}r.p=s,s.marker=!0;}(e<r.index||t>0&&e===r.index)&&(r.index=A.max(e,r.index+t));}};var Pe=(i,e,t)=>{let n=i,r=e.changedParentTypes;for(;x.setIfUndefined(r,i,()=>[]).push(t),i._item!==null;)i=i._item.parent;Gt(n._eH,t,e);},I=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Ot(),this._dEH=Ot(),this._searchMarker=null;}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t;}_copy(){throw S.methodUnimplemented()}clone(){throw S.methodUnimplemented()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0);}observe(e){Ut(this._eH,e);}observeDeep(e){Ut(this._dEH,e);}unobserve(e){Lt(this._eH,e);}unobserveDeep(e){Lt(this._dEH,e);}toJSON(){}},Zt=(i,e,t)=>{i.doc??L(),e<0&&(e=i._length+e),t<0&&(t=i._length+t);let n=t-e,r=[],s=i._start;for(;s!==null&&n>0;){if(s.countable&&!s.deleted){let o=s.content.getContent();if(o.length<=e)e-=o.length;else {for(let c=e;c<o.length&&n>0;c++)r.push(o[c]),n--;e=0;}}s=s.right;}return r},Qt=i=>{i.doc??L();let e=[],t=i._start;for(;t!==null;){if(t.countable&&!t.deleted){let n=t.content.getContent();for(let r=0;r<n.length;r++)e.push(n[r]);}t=t.right;}return e};var me=(i,e)=>{let t=0,n=i._start;for(i.doc??L();n!==null;){if(n.countable&&!n.deleted){let r=n.content.getContent();for(let s=0;s<r.length;s++)e(r[s],t++,i);}n=n.right;}},en=(i,e)=>{let t=[];return me(i,(n,r)=>{t.push(e(n,r,i));}),t},wi=i=>{let e=i._start,t=null,n=0;return {[Symbol.iterator](){return this},next:()=>{if(t===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return {done:!0,value:void 0};t=e.content.getContent(),n=0,e=e.right;}let r=t[n++];return t.length<=n&&(t=null),{done:!1,value:r}}}},tn=(i,e)=>{i.doc??L();let t=Be(i,e),n=i._start;for(t!==null&&(n=t.p,e-=t.index);n!==null;n=n.right)if(!n.deleted&&n.countable){if(e<n.length)return n.content.getContent()[e];e-=n.length;}},Le=(i,e,t,n)=>{let r=t,s=i.doc,o=s.clientID,c=s.store,a=t===null?e._start:t.right,l=[],d=()=>{l.length>0&&(r=new V(k(o,M(c,o)),r,r&&r.lastId,a,a&&a.id,e,null,new _e(l)),r.integrate(i,0),l=[]);};n.forEach(f=>{if(f===null)l.push(f);else switch(f.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(f);break;default:switch(d(),f.constructor){case Uint8Array:case ArrayBuffer:r=new V(k(o,M(c,o)),r,r&&r.lastId,a,a&&a.id,e,null,new Me(new Uint8Array(f))),r.integrate(i,0);break;case ee:r=new V(k(o,M(c,o)),r,r&&r.lastId,a,a&&a.id,e,null,new Ke(f)),r.integrate(i,0);break;default:if(f instanceof I)r=new V(k(o,M(c,o)),r,r&&r.lastId,a,a&&a.id,e,null,new Q(f)),r.integrate(i,0);else throw new Error("Unexpected content type in insert operation")}}}),d();},nn=()=>S.create("Length exceeded!"),rn=(i,e,t,n)=>{if(t>e._length)throw nn();if(t===0)return e._searchMarker&&pe(e._searchMarker,t,n.length),Le(i,e,null,n);let r=t,s=Be(e,t),o=e._start;for(s!==null&&(o=s.p,t-=s.index,t===0&&(o=o.prev,t+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(t<=o.length){t<o.length&&X(i,k(o.id.client,o.id.clock+t));break}t-=o.length;}return e._searchMarker&&pe(e._searchMarker,r,n.length),Le(i,e,o,n)},_i=(i,e,t)=>{let r=(e._searchMarker||[]).reduce((s,o)=>o.index>s.index?o:s,{index:0,p:e._start}).p;if(r)for(;r.right;)r=r.right;return Le(i,e,r,t)},sn=(i,e,t,n)=>{if(n===0)return;let r=t,s=n,o=Be(e,t),c=e._start;for(o!==null&&(c=o.p,t-=o.index);c!==null&&t>0;c=c.right)!c.deleted&&c.countable&&(t<c.length&&X(i,k(c.id.client,c.id.clock+t)),t-=c.length);for(;n>0&&c!==null;)c.deleted||(n<c.length&&X(i,k(c.id.client,c.id.clock+n)),c.delete(i),n-=c.length),c=c.right;if(n>0)throw nn();e._searchMarker&&pe(e._searchMarker,r,-s+n);},Ve=(i,e,t)=>{let n=e._map.get(t);n!==void 0&&n.delete(i);},wt=(i,e,t,n)=>{let r=e._map.get(t)||null,s=i.doc,o=s.clientID,c;if(n==null)c=new _e([n]);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:c=new _e([n]);break;case Uint8Array:c=new Me(n);break;case ee:c=new Ke(n);break;default:if(n instanceof I)c=new Q(n);else throw new Error("Unexpected content type")}new V(k(o,M(s.store,o)),r,r&&r.lastId,null,null,e,t,c).integrate(i,0);},_t=(i,e)=>{i.doc??L();let t=i._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},on=i=>{let e={};return i.doc??L(),i._map.forEach((t,n)=>{t.deleted||(e[n]=t.content.getContent()[t.length-1]);}),e},cn=(i,e)=>{i.doc??L();let t=i._map.get(e);return t!==void 0&&!t.deleted};var bi=(i,e)=>{let t={};return i._map.forEach((n,r)=>{let s=n;for(;s!==null&&(!e.sv.has(s.id.client)||s.id.clock>=(e.sv.get(s.id.client)||0));)s=s.left;s!==null&&ne(s,e)&&(t[r]=s.content.getContent()[s.length-1]);}),t},Re=i=>(i.doc??L(),ie.iteratorFilter(i._map.entries(),e=>!e[1].deleted)),ct=class extends se{},at=class i extends I{constructor(){super(),this._prelimContent=[],this._searchMarker=[];}static from(e){let t=new i;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null;}_copy(){return new i}clone(){let e=new i;return e.insert(0,this.toArray().map(t=>t instanceof I?t.clone():t)),e}get length(){return this.doc??L(),this._length}_callObserver(e,t){super._callObserver(e,t),Pe(this,e,new ct(this,e));}insert(e,t){this.doc!==null?b(this.doc,n=>{rn(n,this,e,t);}):this._prelimContent.splice(e,0,...t);}push(e){this.doc!==null?b(this.doc,t=>{_i(t,this,e);}):this._prelimContent.push(...e);}unshift(e){this.insert(0,e);}delete(e,t=1){this.doc!==null?b(this.doc,n=>{sn(n,this,e,t);}):this._prelimContent.splice(e,t);}get(e){return tn(this,e)}toArray(){return Qt(this)}slice(e=0,t=this.length){return Zt(this,e,t)}toJSON(){return this.map(e=>e instanceof I?e.toJSON():e)}map(e){return en(this,e)}forEach(e){me(this,e);}[Symbol.iterator](){return wi(this)}_write(e){e.writeTypeRef(Ti);}};var lt=class extends se{constructor(e,t,n){super(e,t),this.keysChanged=n;}},dt=class i extends I{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e);}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((n,r)=>{this.set(r,n);}),this._prelimContent=null;}_copy(){return new i}clone(){let e=new i;return this.forEach((t,n)=>{e.set(n,t instanceof I?t.clone():t);}),e}_callObserver(e,t){Pe(this,e,new lt(this,e,t));}toJSON(){this.doc??L();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof I?r.toJSON():r;}}),e}get size(){return [...Re(this)].length}keys(){return ie.iteratorMap(Re(this),e=>e[0])}values(){return ie.iteratorMap(Re(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return ie.iteratorMap(Re(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??L(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this);});}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?b(this.doc,t=>{Ve(t,this,e);}):this._prelimContent.delete(e);}set(e,t){return this.doc!==null?b(this.doc,n=>{wt(n,this,e,t);}):this._prelimContent.set(e,t),t}get(e){return _t(this,e)}has(e){return cn(this,e)}clear(){this.doc!==null?b(this.doc,e=>{this.forEach(function(t,n,r){Ve(e,r,n);});}):this._prelimContent.clear();}_write(e){e.writeTypeRef(Ri);}};var Y=(i,e)=>i===e||typeof i=="object"&&typeof e=="object"&&i&&e&&$.equalFlat(i,e),ye=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r;}forward(){switch(this.right===null&&S.unexpectedCase(),this.right.content.constructor){case D:this.right.deleted||ce(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right;}},Kt=(i,e,t)=>{for(;e.right!==null&&t>0;){switch(e.right.content.constructor){case D:e.right.deleted||ce(e.currentAttributes,e.right.content);break;default:e.right.deleted||(t<e.right.length&&X(i,k(e.right.id.client,e.right.id.clock+t)),e.index+=e.right.length,t-=e.right.length);break}e.left=e.right,e.right=e.right.right;}return e},De=(i,e,t,n)=>{let r=new Map,s=n?Be(e,t):null;if(s){let o=new ye(s.p.left,s.p,s.index,r);return Kt(i,o,t-s.index)}else {let o=new ye(null,e._start,0,r);return Kt(i,o,t)}},an=(i,e,t,n)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===D&&Y(n.get(t.right.content.key),t.right.content.value));)t.right.deleted||n.delete(t.right.content.key),t.forward();let r=i.doc,s=r.clientID;n.forEach((o,c)=>{let a=t.left,l=t.right,d=new V(k(s,M(r.store,s)),a,a&&a.lastId,l,l&&l.id,e,null,new D(c,o));d.integrate(i,0),t.right=d,t.forward();});},ce=(i,e)=>{let{key:t,value:n}=e;n===null?i.delete(t):i.set(t,n);},ln=(i,e)=>{for(;i.right!==null;){if(!(i.right.deleted||i.right.content.constructor===D&&Y(e[i.right.content.key]??null,i.right.content.value)))break;i.forward();}},dn=(i,e,t,n)=>{let r=i.doc,s=r.clientID,o=new Map;for(let c in n){let a=n[c],l=t.currentAttributes.get(c)??null;if(!Y(l,a)){o.set(c,l);let{left:d,right:f}=t;t.right=new V(k(s,M(r.store,s)),d,d&&d.lastId,f,f&&f.id,e,null,new D(c,a)),t.right.integrate(i,0),t.forward();}}return o},qe=(i,e,t,n,r)=>{t.currentAttributes.forEach((p,g)=>{r[g]===void 0&&(r[g]=null);});let s=i.doc,o=s.clientID;ln(t,r);let c=dn(i,e,t,r),a=n.constructor===String?new Z(n):n instanceof I?new Q(n):new oe(n),{left:l,right:d,index:f}=t;e._searchMarker&&pe(e._searchMarker,t.index,a.getLength()),d=new V(k(o,M(s.store,o)),l,l&&l.lastId,d,d&&d.id,e,null,a),d.integrate(i,0),t.right=d,t.index=f,t.forward(),an(i,e,t,c);},Nt=(i,e,t,n,r)=>{let s=i.doc,o=s.clientID;ln(t,r);let c=dn(i,e,t,r);e:for(;t.right!==null&&(n>0||c.size>0&&(t.right.deleted||t.right.content.constructor===D));){if(!t.right.deleted)switch(t.right.content.constructor){case D:{let{key:a,value:l}=t.right.content,d=r[a];if(d!==void 0){if(Y(d,l))c.delete(a);else {if(n===0)break e;c.set(a,l);}t.right.delete(i);}else t.currentAttributes.set(a,l);break}default:n<t.right.length&&X(i,k(t.right.id.client,t.right.id.clock+n)),n-=t.right.length;break}t.forward();}if(n>0){let a="";for(;n>0;n--)a+=`
|
|
27
|
-
`;t.right=new V(k(o,M(s.store,o)),t.left,t.left&&t.left.lastId,t.right,t.right&&t.right.id,e,null,new Z(a)),t.right.integrate(i,0),t.forward();}an(i,e,t,c);},hn=(i,e,t,n,r)=>{let s=e,o=x.create();for(;s&&(!s.countable||s.deleted);){if(!s.deleted&&s.content.constructor===D){let l=s.content;o.set(l.key,l);}s=s.right;}let c=0,a=!1;for(;e!==s;){if(t===e&&(a=!0),!e.deleted){let l=e.content;switch(l.constructor){case D:{let{key:d,value:f}=l,p=n.get(d)??null;(o.get(d)!==l||p===f)&&(e.delete(i),c++,!a&&(r.get(d)??null)===f&&p!==f&&(p===null?r.delete(d):r.set(d,p))),!a&&!e.deleted&&ce(r,l);break}}}e=e.right;}return c},Si=(i,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;let t=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===D){let n=e.content.key;t.has(n)?e.delete(i):t.add(n);}e=e.left;}},ki=i=>{let e=0;return b(i.doc,t=>{let n=i._start,r=i._start,s=x.create(),o=x.copy(s);for(;r;){if(r.deleted===!1)switch(r.content.constructor){case D:ce(o,r.content);break;default:e+=hn(t,n,r,s,o),s=x.copy(o),n=r;break}r=r.right;}}),e},vi=i=>{let e=new Set,t=i.doc;for(let[n,r]of i.afterState.entries()){let s=i.beforeState.get(n)||0;r!==s&&Ht(i,t.store.clients.get(n),s,r,o=>{!o.deleted&&o.content.constructor===D&&o.constructor!==W&&e.add(o.parent);});}b(t,n=>{jt(i,i.deleteSet,r=>{if(r instanceof W||!r.parent._hasFormatting||e.has(r.parent))return;let s=r.parent;r.content.constructor===D?e.add(s):Si(n,r);});for(let r of e)ki(r);});},Bt=(i,e,t)=>{let n=t,r=x.copy(e.currentAttributes),s=e.right;for(;t>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Q:case oe:case Z:t<e.right.length&&X(i,k(e.right.id.client,e.right.id.clock+t)),t-=e.right.length,e.right.delete(i);break}e.forward();}s&&hn(i,s,e.right,r,e.currentAttributes);let o=(e.left||e.right).parent;return o._searchMarker&&pe(o._searchMarker,e.index,-n+t),e},ht=class extends se{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(r=>{r===null?this.childListChanged=!0:this.keysChanged.add(r);});}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e;}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];b(e,n=>{let r=new Map,s=new Map,o=this.target._start,c=null,a={},l="",d=0,f=0,p=()=>{if(c!==null){let g=null;switch(c){case"delete":f>0&&(g={delete:f}),f=0;break;case"insert":(typeof l=="object"||l.length>0)&&(g={insert:l},r.size>0&&(g.attributes={},r.forEach((w,T)=>{w!==null&&(g.attributes[T]=w);}))),l="";break;case"retain":d>0&&(g={retain:d},$.isEmpty(a)||(g.attributes=$.assign({},a))),d=0;break}g&&t.push(g),c=null;}};for(;o!==null;){switch(o.content.constructor){case Q:case oe:this.adds(o)?this.deletes(o)||(p(),c="insert",l=o.content.getContent()[0],p()):this.deletes(o)?(c!=="delete"&&(p(),c="delete"),f+=1):o.deleted||(c!=="retain"&&(p(),c="retain"),d+=1);break;case Z:this.adds(o)?this.deletes(o)||(c!=="insert"&&(p(),c="insert"),l+=o.content.str):this.deletes(o)?(c!=="delete"&&(p(),c="delete"),f+=o.length):o.deleted||(c!=="retain"&&(p(),c="retain"),d+=o.length);break;case D:{let{key:g,value:w}=o.content;if(this.adds(o)){if(!this.deletes(o)){let T=r.get(g)??null;Y(T,w)?w!==null&&o.delete(n):(c==="retain"&&p(),Y(w,s.get(g)??null)?delete a[g]:a[g]=w);}}else if(this.deletes(o)){s.set(g,w);let T=r.get(g)??null;Y(T,w)||(c==="retain"&&p(),a[g]=T);}else if(!o.deleted){s.set(g,w);let T=a[g];T!==void 0&&(Y(T,w)?T!==null&&o.delete(n):(c==="retain"&&p(),w===null?delete a[g]:a[g]=w));}o.deleted||(c==="insert"&&p(),ce(r,o.content));break}}o=o.right;}for(p();t.length>0;){let g=t[t.length-1];if(g.retain!==void 0&&g.attributes===void 0)t.pop();else break}}),this._delta=t;}return this._delta}},ut=class i extends I{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1;}get length(){return this.doc??L(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(n=>n());}catch(n){console.error(n);}this._pending=null;}_copy(){return new i}clone(){let e=new i;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);let n=new ht(this,e,t);Pe(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0);}toString(){this.doc??L();let e="",t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Z&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc!==null?b(this.doc,n=>{let r=new ye(null,this._start,0,new Map);for(let s=0;s<e.length;s++){let o=e[s];if(o.insert!==void 0){let c=!t&&typeof o.insert=="string"&&s===e.length-1&&r.right===null&&o.insert.slice(-1)===`
|
|
28
|
-
`?o.insert.slice(0,-1):o.insert;(typeof c!="string"||c.length>0)&&qe(n,this,r,c,o.attributes||{});}else o.retain!==void 0?Nt(n,this,r,o.retain,o.attributes||{}):o.delete!==void 0&&Bt(n,r,o.delete);}}):this._pending.push(()=>this.applyDelta(e));}toDelta(e,t,n){this.doc??L();let r=[],s=new Map,o=this.doc,c="",a=this._start;function l(){if(c.length>0){let f={},p=!1;s.forEach((w,T)=>{p=!0,f[T]=w;});let g={insert:c};p&&(g.attributes=f),r.push(g),c="";}}let d=()=>{for(;a!==null;){if(ne(a,e)||t!==void 0&&ne(a,t))switch(a.content.constructor){case Z:{let f=s.get("ychange");e!==void 0&&!ne(a,e)?(f===void 0||f.user!==a.id.client||f.type!=="removed")&&(l(),s.set("ychange",n?n("removed",a.id):{type:"removed"})):t!==void 0&&!ne(a,t)?(f===void 0||f.user!==a.id.client||f.type!=="added")&&(l(),s.set("ychange",n?n("added",a.id):{type:"added"})):f!==void 0&&(l(),s.delete("ychange")),c+=a.content.str;break}case Q:case oe:{l();let f={insert:a.content.getContent()[0]};if(s.size>0){let p={};f.attributes=p,s.forEach((g,w)=>{p[w]=g;});}r.push(f);break}case D:ne(a,e)&&(l(),ce(s,a.content));break}a=a.right;}l();};return e||t?b(o,f=>{e&&nt(f,e),t&&nt(f,t),d();},"cleanup"):d(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r!==null?b(r,s=>{let o=De(s,this,e,!n);n||(n={},o.currentAttributes.forEach((c,a)=>{n[a]=c;})),qe(s,this,o,t,n);}):this._pending.push(()=>this.insert(e,t,n));}insertEmbed(e,t,n){let r=this.doc;r!==null?b(r,s=>{let o=De(s,this,e,!n);qe(s,this,o,t,n||{});}):this._pending.push(()=>this.insertEmbed(e,t,n||{}));}delete(e,t){if(t===0)return;let n=this.doc;n!==null?b(n,r=>{Bt(r,De(r,this,e,!0),t);}):this._pending.push(()=>this.delete(e,t));}format(e,t,n){if(t===0)return;let r=this.doc;r!==null?b(r,s=>{let o=De(s,this,e,!1);o.right!==null&&Nt(s,this,o,t,n);}):this._pending.push(()=>this.format(e,t,n));}removeAttribute(e){this.doc!==null?b(this.doc,t=>{Ve(t,this,e);}):this._pending.push(()=>this.removeAttribute(e));}setAttribute(e,t){this.doc!==null?b(this.doc,n=>{wt(n,this,e,t);}):this._pending.push(()=>this.setAttribute(e,t));}getAttribute(e){return _t(this,e)}getAttributes(){return on(this)}_write(e){e.writeTypeRef(Di);}};var fe=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??L();}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===Ae||t.constructor===we)&&t._start!==null)e=t._start;else for(;e!==null;)if(e.right!==null){e=e.right;break}else e.parent===this._root?e=null:e=e.parent._item;while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},we=class i extends I{constructor(){super(),this._prelimContent=[];}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null;}_copy(){return new i}clone(){let e=new i;return e.insert(0,this.toArray().map(t=>t instanceof I?t.clone():t)),e}get length(){return this.doc??L(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new fe(this,e)}querySelector(e){e=e.toUpperCase();let n=new fe(this,r=>r.nodeName&&r.nodeName.toUpperCase()===e).next();return n.done?null:n.value}querySelectorAll(e){return e=e.toUpperCase(),K.from(new fe(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){Pe(this,e,new ft(this,t,e));}toString(){return en(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),me(this,s=>{r.insertBefore(s.toDOM(e,t,n),null);}),r}insert(e,t){this.doc!==null?b(this.doc,n=>{rn(n,this,e,t);}):this._prelimContent.splice(e,0,...t);}insertAfter(e,t){if(this.doc!==null)b(this.doc,n=>{let r=e&&e instanceof I?e._item:e;Le(n,this,r,t);});else {let n=this._prelimContent,r=e===null?0:n.findIndex(s=>s===e)+1;if(r===0&&e!==null)throw S.create("Reference item not found");n.splice(r,0,...t);}}delete(e,t=1){this.doc!==null?b(this.doc,n=>{sn(n,this,e,t);}):this._prelimContent.splice(e,t);}toArray(){return Qt(this)}push(e){this.insert(this.length,e);}unshift(e){this.insert(0,e);}get(e){return tn(this,e)}slice(e=0,t=this.length){return Zt(this,e,t)}forEach(e){me(this,e);}_write(e){e.writeTypeRef(Ui);}};var Ae=class i extends we{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map;}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((n,r)=>{this.setAttribute(r,n);}),this._prelimAttrs=null;}_copy(){return new i(this.nodeName)}clone(){let e=new i(this.nodeName),t=this.getAttributes();return $.forEach(t,(n,r)=>{typeof n=="string"&&e.setAttribute(r,n);}),e.insert(0,this.toArray().map(n=>n instanceof I?n.clone():n)),e}toString(){let e=this.getAttributes(),t=[],n=[];for(let c in e)n.push(c);n.sort();let r=n.length;for(let c=0;c<r;c++){let a=n[c];t.push(a+'="'+e[a]+'"');}let s=this.nodeName.toLocaleLowerCase(),o=t.length>0?" "+t.join(" "):"";return `<${s}${o}>${super.toString()}</${s}>`}removeAttribute(e){this.doc!==null?b(this.doc,t=>{Ve(t,this,e);}):this._prelimAttrs.delete(e);}setAttribute(e,t){this.doc!==null?b(this.doc,n=>{wt(n,this,e,t);}):this._prelimAttrs.set(e,t);}getAttribute(e){return _t(this,e)}hasAttribute(e){return cn(this,e)}getAttributes(e){return e?bi(this,e):on(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),s=this.getAttributes();for(let o in s){let c=s[o];typeof c=="string"&&r.setAttribute(o,c);}return me(this,o=>{r.appendChild(o.toDOM(e,t,n));}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Oi),e.writeKey(this.nodeName);}};var ft=class extends se{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(r=>{r===null?this.childListChanged=!0:this.attributesChanged.add(r);});}};var xe=class{constructor(e,t){this.id=e,this.length=t;}get deleted(){throw S.methodUnimplemented()}mergeWith(e){return !1}write(e,t,n){throw S.methodUnimplemented()}integrate(e,t){throw S.methodUnimplemented()}},Ci=0,W=class extends xe{get deleted(){return !0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),qt(e.doc.store,this);}write(e,t){e.writeInfo(Ci),e.writeLen(this.length-t);}getMissing(e,t){return null}},Me=class i{constructor(e){this.content=e;}getLength(){return 1}getContent(){return [this.content]}isCountable(){return !0}copy(){return new i(this.content)}splice(e){throw S.methodUnimplemented()}mergeWith(e){return !1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content);}getRef(){return 3}};var gt=class i{constructor(e){this.len=e;}getLength(){return this.len}getContent(){return []}isCountable(){return !1}copy(){return new i(this.len)}splice(e){let t=new i(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){Ft(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted();}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t);}getRef(){return 1}};var Ei=(i,e)=>new ee({guid:i,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1}),Ke=class i{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta);}getLength(){return 1}getContent(){return [this.doc]}isCountable(){return !0}copy(){return new i(Ei(this.doc.guid,this.opts))}splice(e){throw S.methodUnimplemented()}mergeWith(e){return !1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc);}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc);}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts);}getRef(){return 9}};var oe=class i{constructor(e){this.embed=e;}getLength(){return 1}getContent(){return [this.embed]}isCountable(){return !0}copy(){return new i(this.embed)}splice(e){throw S.methodUnimplemented()}mergeWith(e){return !1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed);}getRef(){return 5}};var D=class i{constructor(e,t){this.key=e,this.value=t;}getLength(){return 1}getContent(){return []}isCountable(){return !1}copy(){return new i(this.key,this.value)}splice(e){throw S.methodUnimplemented()}mergeWith(e){return !1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0;}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value);}getRef(){return 6}};var Ii=Pt.getVariable("node_env")==="development",_e=class i{constructor(e){this.arr=e,Ii&&$.deepFreeze(e);}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return !0}copy(){return new i(this.arr)}splice(e){let t=new i(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let s=this.arr[r];e.writeAny(s);}}getRef(){return 8}};var Z=class i{constructor(e){this.str=e;}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return !0}copy(){return new i(this.str)}splice(e){let t=new i(this.str.slice(e));this.str=this.str.slice(0,e);let n=this.str.charCodeAt(e-1);return n>=55296&&n<=56319&&(this.str=this.str.slice(0,e-1)+"\uFFFD",t.str="\uFFFD"+t.str.slice(1)),t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t));}getRef(){return 4}};var Ti=0,Ri=1,Di=2,Oi=3,Ui=4;var Q=class i{constructor(e){this.type=e;}getLength(){return 1}getContent(){return [this.type]}isCountable(){return !0}copy(){return new i(this.type._copy())}splice(e){throw S.methodUnimplemented()}mergeWith(e){return !1}integrate(e,t){this.type._integrate(e.doc,t);}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(n=>{n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e);}),e.changed.delete(this.type);}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(n=>{for(;n!==null;)n.gc(e,!0),n=n.left;}),this.type._map=new Map;}write(e,t){this.type._write(e);}getRef(){return 7}};var un=(i,e,t)=>{let{client:n,clock:r}=e.id,s=new V(k(n,r+t),e,k(n,r+t-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(t));return e.deleted&&s.markDeleted(),e.keep&&(s.keep=!0),e.redone!==null&&(s.redone=k(e.redone.client,e.redone.clock+t)),e.right=s,s.right!==null&&(s.right.left=s),i._mergeStructs.push(s),s.parentSub!==null&&s.right===null&&s.parent._map.set(s.parentSub,s),e.length=t,s};var V=class i extends xe{constructor(e,t,n,r,s,o,c,a){super(e,a.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=s,this.parent=o,this.parentSub=c,this.redone=null,this.content=a,this.info=this.content.isCountable()?v.BIT2:0;}set marker(e){(this.info&v.BIT4)>0!==e&&(this.info^=v.BIT4);}get marker(){return (this.info&v.BIT4)>0}get keep(){return (this.info&v.BIT1)>0}set keep(e){this.keep!==e&&(this.info^=v.BIT1);}get countable(){return (this.info&v.BIT2)>0}get deleted(){return (this.info&v.BIT3)>0}set deleted(e){this.deleted!==e&&(this.info^=v.BIT3);}markDeleted(){this.info|=v.BIT3;}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=M(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=M(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===re&&this.id.client!==this.parent.client&&this.parent.clock>=M(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Vt(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=X(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===W||this.right&&this.right.constructor===W)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===i&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===i&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===re){let n=Ge(t,this.parent);n.constructor===W?this.parent=null:this.parent=n.content.type;}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Vt(e,e.doc.store,k(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let n=this.left,r;if(n!==null)r=n.right;else if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start;let s=new Set,o=new Set;for(;r!==null&&r!==this.right;){if(o.add(r),s.add(r),Te(this.origin,r.origin)){if(r.id.client<this.id.client)n=r,s.clear();else if(Te(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&o.has(Ge(e.doc.store,r.origin)))s.has(Ge(e.doc.store,r.origin))||(n=r,s.clear());else break;r=r.right;}this.left=n;}if(this.left!==null){let n=this.left.right;this.right=n,this.left.right=this;}else {let n;if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start,this.parent._start=this;this.right=n;}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),qt(e.doc.store,this),this.content.integrate(e,this),xt(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e);}else new W(this.id,this.length).integrate(e,0);}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:k(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Te(e.origin,this.lastId)&&this.right===e&&Te(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(n=>{n.p===e&&(n.p=this,!this.deleted&&this.countable&&(n.index-=this.length));}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return !1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),Ft(e.deleteSet,this.id.client,this.id.clock,this.length),xt(e,t,this.parentSub),this.content.delete(e);}}gc(e,t){if(!this.deleted)throw S.unexpectedCase();this.content.gc(e),t?ui(e,this,new W(this.id,this.length)):this.content=new gt(this.length);}write(e,t){let n=t>0?k(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&v.BITS5|(n===null?0:v.BIT8)|(r===null?0:v.BIT7)|(s===null?0:v.BIT6);if(e.writeInfo(o),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let c=this.parent;if(c._item!==void 0){let a=c._item;if(a===null){let l=li(c);e.writeParentInfo(!0),e.writeString(l);}else e.writeParentInfo(!1),e.writeLeftID(a.id);}else c.constructor===String?(e.writeParentInfo(!0),e.writeString(c)):c.constructor===re?(e.writeParentInfo(!1),e.writeLeftID(c)):S.unexpectedCase();s!==null&&e.writeString(s);}this.content.write(e,t);}};var fn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},gn="__ $YJS$ __";fn[gn]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");fn[gn]=!0;var be=i=>Promise.reject("unimplemented method GetVoiceSign"),bt=(i,e={},t=[])=>({command:i,front_request_id:z(),data:{...e,to_user_ids:Array.isArray(t)?t:[t]}}),pn=()=>{window?.__Realsee_Live__&&(window?.__Realsee_Live__?.dispose?.(),window.__Realsee_Live__=null);},je=class extends P{_options={};get options(){return Object.freeze(this._options||{})}get state(){return this._controller.state}get readyState(){return this._controller.state}get url(){return this.options.url}get $RTC(){return this._options.rtc}get jsBridge(){return this._options.jsBridge}keyframes=new P;_yDoc;_buildInData;constructor(e){super(),m.info("Initializing Live instance with options:",e),this._addLiveControllerEventListeners(),this._yDoc=new ee({guid:z()}),this._buildInData={keyframes:this._yDoc.getMap("keyframes")},this._initializeKeyframesObservers(),this._initializeOptions(e),this._autoConnect(),this._debugSetup();}get _buildInKeyframes(){return this._buildInData.keyframes}get snapshot(){return this._buildInData.keyframes.toJSON()}_initializeKeyframesObservers=()=>{this._buildInKeyframes.observe(this._handleKeyframesChange);};_handleKeyframesChange=e=>{let{transaction:t,target:n,changes:r}=e;if(n===this._buildInKeyframes)if(t.origin.triggerUserId===this.selfInfo?.id){let s=bt("KEYFRAME_SYNC",this.snapshot,void 0);try{this._controller.sendMessage(s);}catch(o){m.error("Failed to send keyframe sync message:",o);}}else r.keys.forEach((s,o)=>{let c=s.oldValue,a=this.getFramesByKey(o),l=t.origin.frontRequestId;this.keyframes.emit(o,a,c,l);}),r.keys.size!==0&&this.emit("keyframes",this.snapshot,t.origin.frontRequestId);};getFramesByKey=e=>this.snapshot[e];sendKeyframe=(e,t)=>this.state!==1?(m.warn("Attempted to send keyframe while connection is not open"),!1):(this._yDoc.transact(()=>{this._buildInKeyframes.set(e,t);},{triggerUserId:this.selfInfo?.id,frontRequestId:""}),!0);get selfInfo(){return this._buildInData.selfInfo}get userList(){return this._buildInData.userList||[]}get roomInfo(){return this._buildInData.roomInfo}_controller=new Ie;_initializeOptions(e){this._options=Object.assign({initialMicroStatus:"OPEN"},e),this._options.jsBridge=this._initializeJsBridge(e),this._options.getVoiceSign=e.getVoiceSign??be,this._options.autoPlayConfirm=e.autoPlayConfirm,this._options.rtc=this._initializeRTC(e);}_initializeJsBridge(e){if(e.jsBridge)return e.jsBridge;if(e.useBuiltInJsBridge)return new Vi}_initializeRTC(e){if(e.rtc)return e.rtc;if(e.rtcType)return this._createBuiltInRTC(e);if(e.useBuiltInRTC)return this._createDefaultRTC(e)}_createBuiltInRTC(e){if(!e.getVoiceSign){m.error("GetVoiceSign method must be passed when using built-in RTC instances");return}switch(e.rtcType){case"RealseeVRWebViewRTC":return this._createVRWebViewRTC();case"RealseeBrowserChimeRTC":return new te({getVoiceSign:this._options.getVoiceSign??be,logLevel:e.__debug__?0:1});case"RealseeBrowserRTC":return this._createBrowserRTC();default:m.error("unknown built-in RTC type");return}}_createVRWebViewRTC(){if(this._options.jsBridge)return new he({jsBridge:this._options.jsBridge,getVoiceSign:this._options.getVoiceSign??be});m.error("JsBridge instance must be passed when using built-in VRWebViewRTC instances");}_createBrowserRTC(){if(!this._options.autoPlayConfirm){m.error("autoPlayConfirm method must be passed when using built-in RealseeBrowserRTC instances");return}return new de({getVoiceSign:this._options.getVoiceSign??be,autoPlayConfirm:this._options.autoPlayConfirm})}_createDefaultRTC(e){if(!e.getVoiceSign){m.error("GetVoiceSign method must be passed when using built-in RTC instances");return}if(this._options.jsBridge){if(Rt&&(Et||It)||Tt)return this._createVRWebViewRTC();{let t=this._options.getVoiceSign??be;return e.builtInRTCType==="chime"?new te({getVoiceSign:t}):this._createBrowserRTC()}}else {m.error("jsBridge instance must be passed when using built-in RTC instances");return}}_autoConnect(){this._options.url&&this._options.getTicket&&this.connect();}_debugSetup(){this._options.__debug__&&Object.assign(window,{$liveController:this._controller,$live:this});}_addLiveControllerEventListeners=()=>{this._controller.on("stateChange",this._handleStateChange),this._controller.on("message",this._handleMessage);};_removeLiveControllerEventListeners=()=>{this._controller.off("stateChange",this._handleStateChange),this._controller.off("message",this._handleMessage);};_handleStateChange=(e,t)=>{m.info(`State changed from ${t} to ${e}`),this.emit("stateChange",e,t);};_handleMessage=async e=>{if(m.debug("Received message:",e),typeof e=="object"){let{command:t,data:n={},frontRequestId:r,code:s,message:o,triggerUserId:c}=e;if(s==="SUCCESS")switch(t){case"SELF_USER_INFO":{let a=n;Dt(this.selfInfo,a,{deep:!0})||(this._buildInData.selfInfo=a,this.emit("selfInfoUpdate",this._buildInData.selfInfo,r));break}case"ROOM_INFO":{let a=n;this._buildInData.roomInfo=Object.assign({},a);let l=a.last_frame||{};this._yDoc.transact(()=>{for(let d in l)this._buildInKeyframes.set(d,l[d]);},{triggerUserId:"readyKeyframeSync",frontRequestId:r}),this.emit("readyKeyframeSync",a.last_frame||{});break}case"RTC_INFO":{m.info("RTC info updated:",n);let{voice_id:a,type:l}=n;if(this._buildInData.rtcInfo={voiceId:a,type:l},this.$RTC?.joined)m.warn("\u5DF2\u52A0\u5165\u8BED\u97F3\u623F\u95F4\uFF0C\u65E0\u9700\u91CD\u590D\u52A0\u5165\uFF01");else if(await this.$RTC?.join({voiceId:a,userId:this.selfInfo?.id||"",roomId:this.roomInfo?.info.room_code,type:l})){let f=this._options.initialMicroStatus??"OPEN";await this.toggleMicro(f==="OPEN");}else m.error("\u52A0\u5165\u8BED\u97F3\u623F\u95F4\u5931\u8D25");break}case"USER_LIST":{let a=n;this._buildInData.userList=a,this.emit("userListUpdate",this.userList,r);break}case"CUSTOM_EVENT":{let a=n;this.emit("broadcast",a,r);break}case"KEYFRAME_SYNC":{let a=n;if(c===this.selfInfo?.id)return;this._yDoc.transact(()=>{for(let l in a)this._buildInKeyframes.set(l,a[l]);},{triggerUserId:c,frontRequestId:r});break}case"BUILTIN_MSG":{let a=n;this.emit("builtinEvent",a),a.event_type==="user_change"&&this.emit("userChange",a),a.event_type==="room_change"&&this.emit("roomChange",a),a.event_type==="user_change"&&a.action==="change_micro_status"&&await this.toggleMicro(a.data.status==="OPEN"),a.event_type==="room_change"&&a.action==="close"&&await this._exit();break}case"USER_KICK_OUT":{this.emit("kickOut");break}default:m.warn("Unknown command received:",t);}else m.error("Error in message:",o),this.emit("error",e);}};_clearLiveData=()=>{this._buildInKeyframes.clear(),this._buildInData={keyframes:this._yDoc.getMap("keyframes")};};connect=async(e={})=>{if(m.info("Attempting to connect with options:",e),this._options.url=e.url??this._options.url??"",this._options.getTicket=e.getTicket??this._options.getTicket,this._options.initialMicroStatus=e.rtcMicStatus??this._options.initialMicroStatus,!/^ws(s):\/\//.test(this._options.url)||typeof this._options.getTicket!="function")return new Error("Invalid connection parameters");if(this._options.rtc&&!await this._options.rtc.detectMicro())return new Error("Failed to obtain microphone authorization");let t=this.state;if(t===0||t===1)if(e.force)await this._controller.close("force close by connect").catch(console.warn);else return new Error("\u5DF2\u6709Live\u5B9E\u4F8B\u6B63\u5728\u8FDE\u63A5\u4E2D\uFF0C\u8BF7\u52FF\u91CD\u590D\u8FDE\u63A5\uFF01");this._clearLiveData();try{let n=await this._options.getTicket(),r=vt(this._options.url,{ticket:n,force:+!!e.force});return this._controller.open(r),m.info("Connection established successfully"),!0}catch(n){return m.error("Failed to connect:",n),new Error("Failed to connect")}};_exit=async()=>{this._clearLiveData();try{await this.$RTC?.quit();}catch(e){m.warn(e);}return this.state!==1?!0:await this._controller.close()};exit=async()=>this.close();close=async()=>{await this._controller.readyClose();try{await this.$RTC?.quit();}catch(e){m.warn(e);}await this.updateStatus("room_change","close",{});};dispose=async()=>(this._removeLiveControllerEventListeners(),this._clearLiveData(),await this._controller.dispose());async updateStatus(e,t,n,r){if(this.state!==1)return !1;let s=Object.assign({event_type:e,action:t},{data:n}),o=bt("BUILTIN_MSG",s,r);try{return this._controller.sendMessage(o),!0}catch(c){return m.error(c),!1}}setSelfInfo=async e=>await this.updateStatus("user_change","change_info",e);broadcast(e,t,n){return this.state!==1?!1:new Promise((r,s)=>{let o=bt("CUSTOM_EVENT",e,t),c=o.front_request_id,a=n?setTimeout(()=>{s(new Error("RESPONSE TIMEOUT")),this.off("broadcast",l);},n):void 0,l=(d,f)=>{f===c&&(a&&clearTimeout(a),this.off("broadcast",l),r(d));};this.on("broadcast",l);try{this._controller.sendMessage(o);}catch(d){s(d);}})}toggleMicro=async e=>{if(!this.selfInfo?.permission?.control_own_micro)return !1;let t=await this.$RTC?.toggleMicro(e);return t&&await this.updateStatus("user_change","change_micro_status",{status:e?"OPEN":"CLOSE"},[]),t};forbidMicro=async(e,t)=>typeof this._options.canForbidUserMicro=="function"&&!this._options.canForbidUserMicro(t)||!this.selfInfo?.permission?.control_other_micro?!1:await this.updateStatus("user_change","change_micro_status",{status:e},t);forbidSync=async(e,t)=>typeof this._options.canForbidUserSync=="function"&&!this._options.canForbidUserSync(t)||!this.selfInfo?.permission?.control_other_sync?!1:await this.updateStatus("user_change","change_permission",{sync_frame:e},t);kick=async e=>typeof this._options.canForbidUserKick=="function"&&!this._options.canForbidUserKick(e)||!this.selfInfo?.permission?.change_other_status?!1:await this.updateStatus("user_change","change_status",{status:"KICK_OUT"},e);getSnapshotForKey(e){return this.snapshot[e]}};var mn=i=>(pn(),new je(i));function Yr(i){let e=createContext(null),t=mn(i),n=t.jsBridge,r=h=>U.createElement(e.Provider,{value:t},h.children),s=()=>{let h=U.useContext(e);if(!h)throw new Error("LiveProvider never found.");return h},o=()=>t,c=()=>t.$RTC,a=()=>c(),l=()=>async h=>await t.connect(h);function d(h,_,R=[]){let y=s(),C=[y,name,...R],O=()=>y.keyframes.off(h,_);return U.useEffect(()=>(y.keyframes.on(h,_),O),C),O}function f(){let h=s(),_=useCallback(async E=>{await h.connect(E);},[h]),R=useCallback(E=>{h.toggleMicro(E);},[h]),y=useCallback(async(E,F,$e=0)=>{await h.broadcast(E,F,$e);},[h]),C=useCallback(async()=>{await h.exit();},[h]),O=useCallback(async E=>{await h.kick(E);},[h]),q=useCallback(async(E,F=[])=>{await h.forbidMicro(E,F);},[h]),Se=useCallback((E,F=[])=>{h.forbidSync(E,F);},[h]),We=useCallback(E=>h.getFramesByKey(E),[h]),Sn=useCallback((E,F)=>{h.sendKeyframe(E,F);},[h]),kn=useCallback(E=>{h.setSelfInfo(E);},[h]),vn=useCallback((E,F,$e,Cn)=>{h.updateStatus(E,F,$e,Cn);},[h]);return {connect:_,broadcast:y,exit:C,kick:O,toggleMicro:R,forbidMicro:q,forbidSync:Se,sendKeyframe:Sn,getFramesByKey:We,setSelfInfo:kn,updateStatus:vn}}function p(h){let _=s(),[R,y]=U.useState(_.getFramesByKey(h));U.useEffect(()=>{let O=We=>y(We),q=h,Se=O;return _.keyframes.on(q,Se),()=>_.keyframes.off(q,Se)},[_]);let C=U.useCallback(O=>_.sendKeyframe(h,O),[_]);return [R,C]}function g(h,_,R=[]){let y=s(),C=()=>y.off(h,_),O=[y,h,...R];return U.useEffect(()=>(y.on(h,_),C),O),C}function w(){let h=s(),[_,R]=U.useState(h.state);return U.useEffect(()=>{let y=C=>R(C);return h.on("stateChange",y),()=>h.off("stateChange",y)},[h]),_}function T(){let h=s();return {join:q=>h.$RTC.join(q),quit:()=>h.$RTC.quit(),shock:()=>h.$RTC.shock?.(),toggleMicro:q=>h.$RTC.toggleMicro(q),detectMicro:()=>h.$RTC.detectMicro()}}function yn(h,_,R=[]){let y=s(),C=()=>y.$RTC.off(h,_),O=[y,h,...R];return U.useEffect(()=>(y.$RTC.on(h,_),C),O),C}function wn(){let h=s(),[_,R]=U.useState(h.selfInfo||{}),y=O=>R(O);U.useEffect(()=>(h.on("selfInfoUpdate",y),()=>h.off("selfInfoUpdate",y)),[h]);let C=U.useCallback(async O=>await h.setSelfInfo(O),[h]);return [_,C]}function _n(){let h=s(),[_,R]=U.useState(h.snapshot);return U.useEffect(()=>{let y=C=>R(C);return h.on("keyframes",y),()=>h.off("keyframes",y)},[h]),_}function bn(){let h=s(),[_,R]=U.useState(h.userList),y=C=>R(C);return U.useEffect(()=>(h.on("userListUpdate",y),()=>h.off("userListUpdate",y)),[h]),_}return {live:t,jsBridge:n,LiveProvider:r,unsafe__useLiveInstance:o,unsafe__useRTCInstance:a,useConnect:l,useKeyframe:p,useKeyframeUpdateCallback:d,useLiveAction:f,useLiveEventCallback:g,useLiveState:w,useRTCAction:T,useRTCEventCallback:yn,useSelfInfo:wn,useKeyframesSnapshot:_n,useUserList:bn}}console.log(`%c${process.env.__REALSEE_LIVE_VERSION__}`,"background: #237804; color: white; padding: 2px 4px; border-radius: 4px;");
|
|
29
|
-
|
|
30
|
-
export { de as BrowserRTC, te as BrowserRTC4Chime, Tn as BuiltInRTCType, Bn as BuiltinActionType, Nn as BuiltinEventType, Kn as Command, J as CoreRTC, je as Live, jn as LiveState, $n as MemUserStatus, Pn as MicroStatus, Mn as RTCJoinedInfoCodeEnum, In as RTCType, P as Subscribe, Wn as UserStatus, he as VRWebViewRTC, Gn as WebSocketCloseError, Jn as WebSocketErrorType, Fn as WebSocketState, pn as _clearLiveInstanceIfNeed, mn as createLive, Yr as createLiveReact, hr as parseLiveMsg, kt as parseWSClsErr };
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
[**如视 Live SDK**](../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[如视 Live SDK](../globals.md) / Subscribe
|
|
6
|
-
|
|
7
|
-
# Class: Subscribe\<T\>
|
|
8
|
-
|
|
9
|
-
监听者模式
|
|
10
|
-
|
|
11
|
-
## Example
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
new Subscribe<{
|
|
15
|
-
"foo": [arg1: number, arg2: string],
|
|
16
|
-
"bar": [arg: boolean],
|
|
17
|
-
}>()
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Extended by
|
|
21
|
-
|
|
22
|
-
- [`CoreRTC`](CoreRTC.md)
|
|
23
|
-
- [`RTCProtocol`](../interfaces/RTCProtocol.md)
|
|
24
|
-
- [`Live`](Live.md)
|
|
25
|
-
|
|
26
|
-
## Type Parameters
|
|
27
|
-
|
|
28
|
-
• **T** *extends* [`EventMap`](../type-aliases/EventMap.md)
|
|
29
|
-
|
|
30
|
-
预设的监听回调类型
|
|
31
|
-
|
|
32
|
-
## Constructors
|
|
33
|
-
|
|
34
|
-
### new Subscribe()
|
|
35
|
-
|
|
36
|
-
> **new Subscribe**\<`T`\>(): [`Subscribe`](Subscribe.md)\<`T`\>
|
|
37
|
-
|
|
38
|
-
#### Returns
|
|
39
|
-
|
|
40
|
-
[`Subscribe`](Subscribe.md)\<`T`\>
|
|
41
|
-
|
|
42
|
-
## Methods
|
|
43
|
-
|
|
44
|
-
### emit()
|
|
45
|
-
|
|
46
|
-
> **emit**\<`K`\>(`name`, ...`data`): `boolean`
|
|
47
|
-
|
|
48
|
-
触发事件
|
|
49
|
-
|
|
50
|
-
#### Type Parameters
|
|
51
|
-
|
|
52
|
-
• **K** *extends* `string` \| `number` \| `symbol`
|
|
53
|
-
|
|
54
|
-
预设的监听事件名称
|
|
55
|
-
|
|
56
|
-
#### Parameters
|
|
57
|
-
|
|
58
|
-
• **name**: `K`
|
|
59
|
-
|
|
60
|
-
事件类型
|
|
61
|
-
|
|
62
|
-
• ...**data**: `Parameters`\<`T`\[`K`\]\>
|
|
63
|
-
|
|
64
|
-
触发事件的数据
|
|
65
|
-
|
|
66
|
-
#### Returns
|
|
67
|
-
|
|
68
|
-
`boolean`
|
|
69
|
-
|
|
70
|
-
canceled 是否被触发取消
|
|
71
|
-
|
|
72
|
-
#### Defined in
|
|
73
|
-
|
|
74
|
-
utils/subscribe.ts:113
|
|
75
|
-
|
|
76
|
-
***
|
|
77
|
-
|
|
78
|
-
### hasListener()
|
|
79
|
-
|
|
80
|
-
> **hasListener**(`name`): `boolean`
|
|
81
|
-
|
|
82
|
-
判断是否注册了事件
|
|
83
|
-
|
|
84
|
-
#### Parameters
|
|
85
|
-
|
|
86
|
-
• **name**: keyof `T`
|
|
87
|
-
|
|
88
|
-
事件类型
|
|
89
|
-
|
|
90
|
-
#### Returns
|
|
91
|
-
|
|
92
|
-
`boolean`
|
|
93
|
-
|
|
94
|
-
#### Defined in
|
|
95
|
-
|
|
96
|
-
utils/subscribe.ts:41
|
|
97
|
-
|
|
98
|
-
***
|
|
99
|
-
|
|
100
|
-
### off()
|
|
101
|
-
|
|
102
|
-
> **off**\<`K`\>(`name`?, `callback`?): `void`
|
|
103
|
-
|
|
104
|
-
解除事件
|
|
105
|
-
|
|
106
|
-
如果 name 不传的话解除对应所有事件
|
|
107
|
-
如果 name, callback 不传的话解除所有name的所有事件
|
|
108
|
-
|
|
109
|
-
#### Type Parameters
|
|
110
|
-
|
|
111
|
-
• **K** *extends* `string` \| `number` \| `symbol`
|
|
112
|
-
|
|
113
|
-
预设的监听事件名称
|
|
114
|
-
|
|
115
|
-
#### Parameters
|
|
116
|
-
|
|
117
|
-
• **name?**: `K`
|
|
118
|
-
|
|
119
|
-
事件类型
|
|
120
|
-
|
|
121
|
-
• **callback?**
|
|
122
|
-
|
|
123
|
-
事件回调函数
|
|
124
|
-
|
|
125
|
-
#### Returns
|
|
126
|
-
|
|
127
|
-
`void`
|
|
128
|
-
|
|
129
|
-
#### Defined in
|
|
130
|
-
|
|
131
|
-
utils/subscribe.ts:87
|
|
132
|
-
|
|
133
|
-
***
|
|
134
|
-
|
|
135
|
-
### on()
|
|
136
|
-
|
|
137
|
-
> **on**\<`K`\>(`name`, `callback`, `once`?): () => `void`
|
|
138
|
-
|
|
139
|
-
注册事件
|
|
140
|
-
|
|
141
|
-
#### Type Parameters
|
|
142
|
-
|
|
143
|
-
• **K** *extends* `string` \| `number` \| `symbol`
|
|
144
|
-
|
|
145
|
-
预设的监听事件名称
|
|
146
|
-
|
|
147
|
-
#### Parameters
|
|
148
|
-
|
|
149
|
-
• **name**: `K`
|
|
150
|
-
|
|
151
|
-
事件类型
|
|
152
|
-
|
|
153
|
-
• **callback**
|
|
154
|
-
|
|
155
|
-
事件回调函数
|
|
156
|
-
|
|
157
|
-
• **once?**: `boolean`
|
|
158
|
-
|
|
159
|
-
是否只执行一次
|
|
160
|
-
|
|
161
|
-
#### Returns
|
|
162
|
-
|
|
163
|
-
`Function`
|
|
164
|
-
|
|
165
|
-
解除事件
|
|
166
|
-
|
|
167
|
-
##### Returns
|
|
168
|
-
|
|
169
|
-
`void`
|
|
170
|
-
|
|
171
|
-
#### Defined in
|
|
172
|
-
|
|
173
|
-
utils/subscribe.ts:55
|
|
174
|
-
|
|
175
|
-
***
|
|
176
|
-
|
|
177
|
-
### once()
|
|
178
|
-
|
|
179
|
-
> **once**\<`K`\>(`name`, `callback`): () => `void`
|
|
180
|
-
|
|
181
|
-
注册事件(是否只执行一次)
|
|
182
|
-
|
|
183
|
-
#### Type Parameters
|
|
184
|
-
|
|
185
|
-
• **K** *extends* `string` \| `number` \| `symbol`
|
|
186
|
-
|
|
187
|
-
预设的监听事件名称
|
|
188
|
-
|
|
189
|
-
#### Parameters
|
|
190
|
-
|
|
191
|
-
• **name**: `K`
|
|
192
|
-
|
|
193
|
-
事件类型
|
|
194
|
-
|
|
195
|
-
• **callback**
|
|
196
|
-
|
|
197
|
-
事件回调函数
|
|
198
|
-
|
|
199
|
-
#### Returns
|
|
200
|
-
|
|
201
|
-
`Function`
|
|
202
|
-
|
|
203
|
-
解除事件
|
|
204
|
-
|
|
205
|
-
##### Returns
|
|
206
|
-
|
|
207
|
-
`void`
|
|
208
|
-
|
|
209
|
-
#### Defined in
|
|
210
|
-
|
|
211
|
-
utils/subscribe.ts:74
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
[**如视 Live SDK**](../../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[如视 Live SDK](../../globals.md) / SubscribeMixinType
|
|
6
|
-
|
|
7
|
-
# SubscribeMixinType
|
|
8
|
-
|
|
9
|
-
## Index
|
|
10
|
-
|
|
11
|
-
### Interfaces
|
|
12
|
-
|
|
13
|
-
- [emit](interfaces/emit.md)
|
|
14
|
-
- [hasListener](interfaces/hasListener.md)
|
|
15
|
-
- [off](interfaces/off.md)
|
|
16
|
-
- [on](interfaces/on.md)
|
|
17
|
-
- [once](interfaces/once.md)
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
[**如视 Live SDK**](../../../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[如视 Live SDK](../../../globals.md) / [SubscribeMixinType](../README.md) / emit
|
|
6
|
-
|
|
7
|
-
# Interface: emit()\<T\>
|
|
8
|
-
|
|
9
|
-
## Type Parameters
|
|
10
|
-
|
|
11
|
-
• **T** *extends* [`EventMap`](../../../type-aliases/EventMap.md)
|
|
12
|
-
|
|
13
|
-
> **emit**\<`K`\>(`name`, ...`data`): `boolean`
|
|
14
|
-
|
|
15
|
-
## Type Parameters
|
|
16
|
-
|
|
17
|
-
• **K** *extends* `string` \| `number` \| `symbol`
|
|
18
|
-
|
|
19
|
-
## Parameters
|
|
20
|
-
|
|
21
|
-
• **name**: `K`
|
|
22
|
-
|
|
23
|
-
• ...**data**: `Parameters`\<`T`\[`K`\]\>
|
|
24
|
-
|
|
25
|
-
## Returns
|
|
26
|
-
|
|
27
|
-
`boolean`
|
|
28
|
-
|
|
29
|
-
## Defined in
|
|
30
|
-
|
|
31
|
-
utils/subscribe.ts:141
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
[**如视 Live SDK**](../../../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[如视 Live SDK](../../../globals.md) / [SubscribeMixinType](../README.md) / hasListener
|
|
6
|
-
|
|
7
|
-
# Interface: hasListener()\<T\>
|
|
8
|
-
|
|
9
|
-
## Type Parameters
|
|
10
|
-
|
|
11
|
-
• **T** *extends* [`EventMap`](../../../type-aliases/EventMap.md)
|
|
12
|
-
|
|
13
|
-
> **hasListener**(`name`): `boolean`
|
|
14
|
-
|
|
15
|
-
## Parameters
|
|
16
|
-
|
|
17
|
-
• **name**: keyof `T`
|
|
18
|
-
|
|
19
|
-
## Returns
|
|
20
|
-
|
|
21
|
-
`boolean`
|
|
22
|
-
|
|
23
|
-
## Defined in
|
|
24
|
-
|
|
25
|
-
utils/subscribe.ts:129
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
[**如视 Live SDK**](../../../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[如视 Live SDK](../../../globals.md) / [SubscribeMixinType](../README.md) / off
|
|
6
|
-
|
|
7
|
-
# Interface: off()\<T\>
|
|
8
|
-
|
|
9
|
-
## Type Parameters
|
|
10
|
-
|
|
11
|
-
• **T** *extends* [`EventMap`](../../../type-aliases/EventMap.md)
|
|
12
|
-
|
|
13
|
-
> **off**\<`K`\>(`names`?, `callback`?): `void`
|
|
14
|
-
|
|
15
|
-
## Type Parameters
|
|
16
|
-
|
|
17
|
-
• **K** *extends* `string` \| `number` \| `symbol`
|
|
18
|
-
|
|
19
|
-
## Parameters
|
|
20
|
-
|
|
21
|
-
• **names?**: `K` \| `K`[]
|
|
22
|
-
|
|
23
|
-
• **callback?**
|
|
24
|
-
|
|
25
|
-
## Returns
|
|
26
|
-
|
|
27
|
-
`void`
|
|
28
|
-
|
|
29
|
-
## Defined in
|
|
30
|
-
|
|
31
|
-
utils/subscribe.ts:138
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
[**如视 Live SDK**](../../../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[如视 Live SDK](../../../globals.md) / [SubscribeMixinType](../README.md) / on
|
|
6
|
-
|
|
7
|
-
# Interface: on()\<T\>
|
|
8
|
-
|
|
9
|
-
## Type Parameters
|
|
10
|
-
|
|
11
|
-
• **T** *extends* [`EventMap`](../../../type-aliases/EventMap.md)
|
|
12
|
-
|
|
13
|
-
> **on**\<`K`\>(`name`, `callback`, `once`?): () => `void`
|
|
14
|
-
|
|
15
|
-
## Type Parameters
|
|
16
|
-
|
|
17
|
-
• **K** *extends* `string` \| `number` \| `symbol`
|
|
18
|
-
|
|
19
|
-
## Parameters
|
|
20
|
-
|
|
21
|
-
• **name**: `K`
|
|
22
|
-
|
|
23
|
-
• **callback**
|
|
24
|
-
|
|
25
|
-
• **once?**: `boolean`
|
|
26
|
-
|
|
27
|
-
## Returns
|
|
28
|
-
|
|
29
|
-
`Function`
|
|
30
|
-
|
|
31
|
-
### Returns
|
|
32
|
-
|
|
33
|
-
`void`
|
|
34
|
-
|
|
35
|
-
## Defined in
|
|
36
|
-
|
|
37
|
-
utils/subscribe.ts:132
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
[**如视 Live SDK**](../../../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[如视 Live SDK](../../../globals.md) / [SubscribeMixinType](../README.md) / once
|
|
6
|
-
|
|
7
|
-
# Interface: once()\<T\>
|
|
8
|
-
|
|
9
|
-
## Type Parameters
|
|
10
|
-
|
|
11
|
-
• **T** *extends* [`EventMap`](../../../type-aliases/EventMap.md)
|
|
12
|
-
|
|
13
|
-
> **once**\<`K`\>(`name`, `callback`): () => `void`
|
|
14
|
-
|
|
15
|
-
## Type Parameters
|
|
16
|
-
|
|
17
|
-
• **K** *extends* `string` \| `number` \| `symbol`
|
|
18
|
-
|
|
19
|
-
## Parameters
|
|
20
|
-
|
|
21
|
-
• **name**: `K`
|
|
22
|
-
|
|
23
|
-
• **callback**
|
|
24
|
-
|
|
25
|
-
## Returns
|
|
26
|
-
|
|
27
|
-
`Function`
|
|
28
|
-
|
|
29
|
-
### Returns
|
|
30
|
-
|
|
31
|
-
`void`
|
|
32
|
-
|
|
33
|
-
## Defined in
|
|
34
|
-
|
|
35
|
-
utils/subscribe.ts:135
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
[**如视 Live SDK**](../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[如视 Live SDK](../globals.md) / EventMap
|
|
6
|
-
|
|
7
|
-
# Type Alias: EventMap
|
|
8
|
-
|
|
9
|
-
> **EventMap**: `object`
|
|
10
|
-
|
|
11
|
-
## Index Signature
|
|
12
|
-
|
|
13
|
-
\[`name`: `string`\]: (...`args`) => `void` \| `boolean`
|
|
14
|
-
|
|
15
|
-
## Defined in
|
|
16
|
-
|
|
17
|
-
utils/subscribe.ts:3
|