Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

@netless/app-geogebra

Package Overview
Dependencies
0
Maintainers
12
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.8 to 0.0.9

2

dist/main.cjs.js

@@ -1,3 +0,3 @@

"use strict";var D=Object.defineProperty,x=Object.defineProperties;var B=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var T=(i,n,e)=>n in i?D(i,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[n]=e,w=(i,n)=>{for(var e in n||(n={}))R.call(n,e)&&T(i,e,n[e]);if(A)for(var e of A(n))U.call(n,e)&&T(i,e,n[e]);return i},G=(i,n)=>x(i,B(n));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const N="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",_=N.length,I=Array(20),P=()=>{for(let i=0;i<20;i++)I[i]=N.charAt(Math.random()*_);return I.join("")};function j(i){try{return i()}catch(n){console.error(n)}}class F{constructor(){this.disposers=new Map}addDisposer(n,e=this.genUID()){return this.flush(e),this.disposers.set(e,Array.isArray(n)?()=>n.forEach(j):n),e}add(n,e=this.genUID()){return this.addDisposer(n(),e)}addEventListener(n,e,s,t,a=this.genUID()){return n.addEventListener(e,s,t),this.addDisposer(()=>n.removeEventListener(e,s,t),a),a}setTimeout(n,e,s=this.genUID()){const t=window.setTimeout(()=>{this.remove(s),n()},e);return this.addDisposer(()=>window.clearTimeout(t),s)}setInterval(n,e,s=this.genUID()){const t=window.setInterval(n,e);return this.addDisposer(()=>window.clearInterval(t),s)}remove(n){const e=this.disposers.get(n);return this.disposers.delete(n),e}flush(n){const e=this.remove(n);if(e)try{e()}catch(s){console.error(s)}}flushAll(){this.disposers.forEach(j),this.disposers.clear()}genUID(){let n;do n=P();while(this.disposers.has(n));return n}}function J(i){return i!=null&&typeof i=="object"&&!Array.isArray(i)}function W(i,n){let e=i.getAttributes();if(e||(i.setAttributes(n),e=i.getAttributes()),!e)throw new Error("[NetlessAppMonaco] No attributes");return J(n)&&Object.keys(n).forEach(s=>{Object.prototype.hasOwnProperty.call(e,s)||i.updateAttributes([s],n[s])}),e}let L;function $({deployggb:i="https://www.geogebra.org/apps/latest/deployggb.js"}={}){if(window.GGBApplet)return Promise.resolve(window.GGBApplet);if(L)return L;{const n=document.createElement("script");return L=new Promise((e,s)=>{n.onload=()=>e(window.GGBApplet),n.onerror=()=>{L=void 0,s()}}),n.src=i,document.head.appendChild(n),L}}const z={appName:"classic",showMenuBar:!0,showAlgebraInput:!0,showToolBar:!0,customToolBar:"0 39 73 62 | 1 501 67 , 5 19 , 72 75 76 | 2 15 45 , 18 65 , 7 37 | 4 3 8 9 , 13 44 , 58 , 47 | 16 51 64 , 70 | 10 34 53 11 , 24 20 22 , 21 23 | 55 56 57 , 12 | 36 46 , 38 49 50 , 71 14 68 | 30 29 54 32 31 33 | 25 17 26 60 52 61 | 40 41 42 , 27 28 35 , 6",showToolBarHelp:!1,showResetIcon:!1,enableFileFeatures:!1,enableLabelDrags:!1,enableShiftDragZoom:!0,enableRightClick:!0,errorDialogsActive:!1,allowStyleBar:!1,preventFocus:!1,useBrowserForJS:!0,language:"en",borderColor:"transparent"},S=class{constructor(i){var n;this.currentAnimations=[],this.embeds={},this.storageCallback=0,this.initAllEmbeds=()=>{for(const e of this.api.getAllObjectNames("embed"))this.initEmbed(e)},this.objectsInWaiting=[],this.updateCallback=0,this.dispatchUpdates=()=>{this.updateCallback||(this.updateCallback=setTimeout(this._dispatchUpdates,this.delay))},this._dispatchUpdates=()=>{const{objectsInWaiting:e}=this;this.objectsInWaiting=[];for(const s of e){const t=this.api.getEmbeddedCalculators(!0),a=t==null?void 0:t[s];a!=null&&a.controller&&this.sendEvent("evalGMContent",a.toJSON(),s);const o=this.api.getCommandString(s,!1);if(o){this.sendEvent("evalCommand",`${s} := ${o}`,s);const r=this.api.getObjectsOfItsGroup(s);r!=null&&r.length&&this.sendEvent("addToGroup",s,r)}if(!o||this.api.isMoveable(s)){const r=this.api.getXML(s);this.sendEvent("evalXML",r,s)}this.sendEvent("select",s,!0)}this.updateCallback=0},this.updateListener=e=>{(this.api.hasUnlabeledPredecessors(e)||this.api.isMoveable(e))&&!this.currentAnimations.includes(e)&&(this.objectsInWaiting.includes(e)||(this.objectsInWaiting.push(e),this.dispatchUpdates()))},this.addListener=e=>{const s=this.api.getImageFileName(e);if(s){const r=this.api.getFileJSON();for(const h of r.archive)h.fileName.includes(s)&&this.sendEvent("addImage",JSON.stringify(h))}const t=this.api.getXML(e),o=this.api.getCommandString(e)&&this.api.getAlgorithmXML(e);this.sendEvent("addObject",o||t,e),this.sendEvent("deselect"),this.sendEvent("select",e,!0),setTimeout(()=>this.initEmbed(e),500)},this.removeListener=e=>{this.sendEvent("deleteObject",e),delete this.embeds[e]},this.renameListener=(e,s)=>{this.sendEvent("renameObject",e,s)},this.isSyncingViewState=0,this.stopSyncViewState=()=>{this.isSyncingViewState=0},this._flushViewState=()=>{const{invXscale:e,invYscale:s,xMin:t,yMin:a}=JSON.parse(this.api.getViewProperties(0)),o=1/e,r=-t/e,h=-a/s;return this.viewState={scale:o,x:r,y:h},this.viewSyncCallback=0,this.viewState},this.clientListener=e=>{let s,t;const a=e.type;switch(a){case"updateStyle":s=e.target,t=this.api.getXML(s),this.sendEvent("evalXML",t);break;case"editorStart":this.lastEditingLabel=e.target;break;case"editorKeyTyped":t=this.api.getEditorState(),this.sendEvent("setEditorState",t,this.lastEditingLabel);break;case"editorStop":this.lastEditingLabel=void 0,this.sendEvent("setEditorState",JSON.stringify({content:""}));break;case"deselect":this.sendEvent("deselect",e.target);break;case"select":this.sendEvent("select",e.target);break;case"embeddedContentChanged":s=e[1],t=e[2],this.sendEvent("embeddedContentChanged",t,s);break;case"undo":case"redo":case"addPolygonComplete":t=this.api.getXML(),this.sendEvent("setXML",t);break;case"addSlide":this.sendEvent(a);break;case"removeSlide":case"moveSlide":case"selectSlide":case"clearSlide":case"orderingChange":t=e[2],this.sendEvent(a,t);break;case"pasteSlide":({cardIdx:t,ggbFile:s}=e),this.sendEvent(a,t,s);break;case"startAnimation":s=e[1],this.currentAnimations.push(s),this.sendEvent(a,s,s);break;case"stopAnimation":s=e[1],this.currentAnimations.splice(this.currentAnimations.indexOf(s),1),this.sendEvent(a,s,s);break;case"groupObjects":case"ungroupObjects":t=e.targets,this.sendEvent(a,t);break;case"pasteElmsComplete":t=e.targets.map(o=>this.api.getXML(o)).join(""),this.sendEvent("evalXML",t);break;case"addGeoToTV":case"removeGeoFromTV":t=e[1],this.sendEvent(a,t);break;case"setValuesOfTV":t=e[2],this.sendEvent(a,t);break;case"showPointsTV":({column:t,show:s}=e),this.sendEvent(a,t,s);break;case"lockTextElement":case"unlockTextElement":t=e[1],this.sendEvent(a,t);break;case"viewChanged2D":this.viewSyncCallback||(this.isSyncingViewState||this.viewState.scale===0?this.viewSyncCallback=setTimeout(this._flushViewState,this.delay):this.viewSyncCallback=setTimeout(this._sendViewSyncEvent,this.delay));break;case"mouseDown":case"deleteGeos":case"dragEnd":break;default:console.debug("[GeoGebra] unhandled event ",e.type,e)}},this.viewSyncCallback=0,this.viewState={scale:0,x:0,y:0},this._sendViewSyncEvent=()=>{this._flushViewState(),this.sendEvent("viewChanged2D",JSON.stringify(this.viewState)),this.viewSyncCallback=0},this._delayedRegisterListeners=()=>{this.registerListeners(),this.viewSyncCallback=0},this.conflictedObjects=[],this.dispatch=e=>{var h,p;if(this.conflictedObjects.includes(e.label)&&e.type!=="conflictResolution")return;const t=e.embedLabel?this.embeds[e.embedLabel]:this,a=e.type,o=e.label,r=e.content;if(console.debug("[GeoGebra] receive:",a,o,r),a==="addObject")if(t.api.exists(o))if(this.context.isDecider)if(this.context.isDecider(this.clientId)){let c=1,l;do l=`${o}_${c}`,c++;while(t.api.exists(l));this.unregisterListeners(),t.api.renameObject(o,l),this.registerListeners();const u=t.api.getAlgorithmXML(l)||t.api.getXML(l);this.sendEvent("conflictResolution",u,o)}else this.conflictedObjects.push(o);else t.evalXML(r),t.api.previewRefresh();else t.evalXML(r),t.api.previewRefresh();else if(a==="conflictResolution"){const c=this.conflictedObjects.indexOf(o);c!==-1&&this.conflictedObjects.splice(c,1),t.evalXML(r),t.api.previewRefresh()}else if(a==="evalXML")t.evalXML(r),t.api.previewRefresh();else if(a==="setXML")t.setXML(r);else if(a==="evalCommand")t.evalCommand(r),t.api.previewRefresh();else if(a==="deleteObject")t.unregisterListeners(),t===this&&delete this.embeds[r],t.api.deleteObject(r),t.registerListeners();else if(a==="setEditorState")t.unregisterListeners(),t.api.setEditorState(r,o),t.registerListeners();else if(a==="addImage"){const c=JSON.parse(r);t.api.addImage(c.fileName,c.fileContent)}else if(["addSlide","removeSlide","moveSlide","clearSlide"].includes(a))t.api.handleSlideAction(a,r);else if(a==="selectSlide")t.unregisterListeners(),t.api.selectSlide(r),t.registerListeners();else if(a==="renameObject")t.unregisterListeners(),t.api.renameObject(r,o),t.registerListeners();else if(a==="pasteSlide")t.api.handleSlideAction(a,r,o);else if(a==="evalGMContent"){const c=(t.api.getEmbeddedCalculators(!0)||{})[o];c&&c.loadFromJSON(r)}else if(a==="startAnimation")t.api.setAnimating(o,!0),t.api.startAnimation();else if(a==="stopAnimation")t.api.setAnimating(o,!1);else if(a==="select"){if(r){const c=((p=(h=this.context).getColor)==null?void 0:p.call(h,e.clientId))||"#80808080";try{t.api.addMultiuserSelection(String(e.nickName),c,r,!!o)}catch(l){console.error(l)}}}else if(a==="deselect")t.api.removeMultiuserSelections(String(e.nickName));else if(a==="orderingChange")t.api.updateOrdering(r);else if(a==="groupObjects")t.api.groupObjects(r);else if(a==="ungroupObjects")t.api.ungroupObjects(r);else if(a==="addToGroup")t.api.addToGroup(r,o);else if(a==="embeddedContentChanged")t.api.setEmbedContent(o,r);else if(a==="addGeoToTV")t.api.addGeoToTV(r);else if(a==="setValuesOfTV")t.api.setValuesOfTV(r);else if(a==="removeGeoFromTV")t.api.removeGeoFromTV(r);else if(a==="showPointsTV")t.api.showPointsTV(r,o);else if(a==="lockTextElement")t.api.lockTextElement(r);else if(a==="unlockTextElement")t.api.unlockTextElement(r);else if(a==="viewChanged2D")if(t.viewState.scale===0)t.api.evalCommand("Pan(0,0)"),t.startSyncViewState();else{const{scale:c,x:l,y:u}=JSON.parse(r),g=t._flushViewState();t.startSyncViewState(),t.api.evalCommand(`Pan(${l-g.x},${u-g.y})`),t.api.evalCommand(`ZoomIn(${c/g.scale})`)}else console.debug("[GeoGebra] unknown event",a,r,o)},this.api=i.api,this.clientId=i.clientId,this.nickName=i.nickName,this.delay=(n=i.delay)!=null?n:200,this.context=i,setTimeout(()=>{this.api.evalCommand("Pan(0,0)")},this.delay)}createEvent(i,n,e){const s={type:i,content:n,clientId:this.clientId,nickName:this.nickName};return this.context.embedLabel&&(s.embedLabel=this.context.embedLabel),e&&(s.label=e),s}sendEvent(i,n,e){console.log("[GeoGebra] send:",i,e,n),this.context.postMessage(this.createEvent(i,n,e)),this.storageCallback||(this.storageCallback=setTimeout(()=>{this.context.save(this.api.getBase64()),this.storageCallback=0},this.delay))}evalCommand(i){this.unregisterListeners(),this.api.evalCommand(i),this.registerListeners()}evalXML(i){this.unregisterListeners(),this.api.evalXML(i),this.api.updateConstruction(),this.registerListeners(),setTimeout(this.initAllEmbeds,500)}setXML(i){this.unregisterListeners(),this.api.setXML(i),this.api.updateConstruction(),this.registerListeners()}initEmbed(i){if(this.embeds[i])return;const n=this.api.getEmbeddedCalculators();if(!n)return;const e=n[i];if(e&&"registerClientListener"in e){const s=new S(G(w({},this.context),{clientId:this.clientId,nickName:this.nickName,api:e,embedLabel:i}));s.registerListeners(),this.embeds[i]=s}}startSyncViewState(){clearTimeout(this.isSyncingViewState),this.isSyncingViewState=setTimeout(this.stopSyncViewState,1e3)}shouldSyncView(i,n,e,s){return Math.abs(n-i.scale)>S.Threshold/10||Math.abs(e-i.x)>S.Threshold||Math.abs(s-i.y)>S.Threshold}registerListeners(){this.api.registerUpdateListener(this.updateListener),this.api.registerRemoveListener(this.removeListener),this.api.registerAddListener(this.addListener),this.api.registerClientListener(this.clientListener),this.api.registerRenameListener(this.renameListener)}unregisterListeners(){this.api.unregisterUpdateListener(this.updateListener),this.api.unregisterRemoveListener(this.removeListener),this.api.unregisterAddListener(this.addListener),this.api.unregisterClientListener(this.clientListener),this.api.unregisterRenameListener(this.renameListener)}};let V=S;V.Threshold=20;var H=(()=>`.netless-app-geogebra{width:100%!important;height:100%!important;overflow:hidden}.netless-app-geogebra.loading{background-color:#fff}.netless-app-geogebra.readonly{user-select:none;pointer-events:none}
"use strict";var D=Object.defineProperty,x=Object.defineProperties;var B=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var T=(i,n,e)=>n in i?D(i,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[n]=e,w=(i,n)=>{for(var e in n||(n={}))R.call(n,e)&&T(i,e,n[e]);if(A)for(var e of A(n))U.call(n,e)&&T(i,e,n[e]);return i},I=(i,n)=>x(i,B(n));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const N="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",_=N.length,G=Array(20),P=()=>{for(let i=0;i<20;i++)G[i]=N.charAt(Math.random()*_);return G.join("")};function j(i){try{return i()}catch(n){console.error(n)}}class F{constructor(){this.disposers=new Map}addDisposer(n,e=this.genUID()){return this.flush(e),this.disposers.set(e,Array.isArray(n)?()=>n.forEach(j):n),e}add(n,e=this.genUID()){return this.addDisposer(n(),e)}addEventListener(n,e,s,t,a=this.genUID()){return n.addEventListener(e,s,t),this.addDisposer(()=>n.removeEventListener(e,s,t),a),a}setTimeout(n,e,s=this.genUID()){const t=window.setTimeout(()=>{this.remove(s),n()},e);return this.addDisposer(()=>window.clearTimeout(t),s)}setInterval(n,e,s=this.genUID()){const t=window.setInterval(n,e);return this.addDisposer(()=>window.clearInterval(t),s)}remove(n){const e=this.disposers.get(n);return this.disposers.delete(n),e}flush(n){const e=this.remove(n);if(e)try{e()}catch(s){console.error(s)}}flushAll(){this.disposers.forEach(j),this.disposers.clear()}genUID(){let n;do n=P();while(this.disposers.has(n));return n}}function J(i){return i!=null&&typeof i=="object"&&!Array.isArray(i)}function W(i,n){let e=i.getAttributes();if(e||(i.setAttributes(n),e=i.getAttributes()),!e)throw new Error("[NetlessAppMonaco] No attributes");return J(n)&&Object.keys(n).forEach(s=>{Object.prototype.hasOwnProperty.call(e,s)||i.updateAttributes([s],n[s])}),e}let L;function $({deployggb:i="https://www.geogebra.org/apps/latest/deployggb.js"}={}){if(window.GGBApplet)return Promise.resolve(window.GGBApplet);if(L)return L;{const n=document.createElement("script");return L=new Promise((e,s)=>{n.onload=()=>e(window.GGBApplet),n.onerror=()=>{L=void 0,s()}}),n.src=i,document.head.appendChild(n),L}}const z={appName:"classic",showMenuBar:!0,showAlgebraInput:!0,showToolBar:!0,customToolBar:"0 39 73 62 | 1 501 67 , 5 19 , 72 75 76 | 2 15 45 , 18 65 , 7 37 | 4 3 8 9 , 13 44 , 58 , 47 | 16 51 64 , 70 | 10 34 53 11 , 24 20 22 , 21 23 | 55 56 57 , 12 | 36 46 , 38 49 50 , 71 14 68 | 30 29 54 32 31 33 | 25 17 26 60 52 61 | 40 41 42 , 27 28 35 , 6",showToolBarHelp:!1,showResetIcon:!1,enableFileFeatures:!1,enableLabelDrags:!1,enableShiftDragZoom:!0,enableRightClick:!0,errorDialogsActive:!1,allowStyleBar:!1,preventFocus:!1,useBrowserForJS:!0,language:"en",borderColor:"transparent"},S=class{constructor(i){var n;this.currentAnimations=[],this.embeds={},this.storageCallback=0,this.initAllEmbeds=()=>{for(const e of this.api.getAllObjectNames("embed"))this.initEmbed(e)},this.objectsInWaiting=[],this.updateCallback=0,this.dispatchUpdates=()=>{this.updateCallback||(this.updateCallback=setTimeout(this._dispatchUpdates,this.delay))},this._dispatchUpdates=()=>{const{objectsInWaiting:e}=this;this.objectsInWaiting=[];for(const s of e){const t=this.api.getEmbeddedCalculators(!0),a=t==null?void 0:t[s];a!=null&&a.controller&&this.sendEvent("evalGMContent",a.toJSON(),s);const o=this.api.getCommandString(s,!1);if(o){this.sendEvent("evalCommand",`${s} := ${o}`,s);const r=this.api.getObjectsOfItsGroup(s);r!=null&&r.length&&this.sendEvent("addToGroup",s,r)}if(!o||this.api.isMoveable(s)){const r=this.api.getXML(s);this.sendEvent("evalXML",r,s)}this.sendEvent("select",s,!0)}this.updateCallback=0},this.updateListener=e=>{(this.api.hasUnlabeledPredecessors(e)||this.api.isMoveable(e))&&!this.currentAnimations.includes(e)&&(this.objectsInWaiting.includes(e)||(this.objectsInWaiting.push(e),this.dispatchUpdates()))},this.addListener=e=>{const s=this.api.getImageFileName(e);if(s){const r=this.api.getFileJSON();for(const h of r.archive)h.fileName.includes(s)&&this.sendEvent("addImage",JSON.stringify(h))}const t=this.api.getXML(e),o=this.api.getCommandString(e)&&this.api.getAlgorithmXML(e);this.sendEvent("addObject",o||t,e),this.sendEvent("deselect"),this.sendEvent("select",e,!0),setTimeout(()=>this.initEmbed(e),500)},this.removeListener=e=>{this.sendEvent("deleteObject",e),delete this.embeds[e]},this.renameListener=(e,s)=>{this.sendEvent("renameObject",e,s)},this.isSyncingViewState=0,this.stopSyncViewState=()=>{this.isSyncingViewState=0},this._flushViewState=()=>{const{invXscale:e,invYscale:s,xMin:t,yMin:a}=JSON.parse(this.api.getViewProperties(0)),o=1/e,r=-t/e,h=-a/s;return this.viewState={scale:o,x:r,y:h},this.viewSyncCallback=0,this.viewState},this.clientListener=e=>{let s,t;const a=e.type;switch(a){case"updateStyle":s=e.target,t=this.api.getXML(s),this.sendEvent("evalXML",t);break;case"editorStart":this.lastEditingLabel=e.target;break;case"editorKeyTyped":t=this.api.getEditorState(),this.sendEvent("setEditorState",t,this.lastEditingLabel);break;case"editorStop":this.lastEditingLabel=void 0,this.sendEvent("setEditorState",JSON.stringify({content:""}));break;case"deselect":this.sendEvent("deselect",e.target);break;case"select":this.sendEvent("select",e.target);break;case"embeddedContentChanged":s=e[1],t=e[2],this.sendEvent("embeddedContentChanged",t,s);break;case"undo":case"redo":case"addPolygonComplete":t=this.api.getXML(),this.sendEvent("setXML",t);break;case"addSlide":this.sendEvent(a);break;case"removeSlide":case"moveSlide":case"selectSlide":case"clearSlide":case"orderingChange":t=e[2],this.sendEvent(a,t);break;case"pasteSlide":({cardIdx:t,ggbFile:s}=e),this.sendEvent(a,t,s);break;case"startAnimation":s=e[1],this.currentAnimations.push(s),this.sendEvent(a,s,s);break;case"stopAnimation":s=e[1],this.currentAnimations.splice(this.currentAnimations.indexOf(s),1),this.sendEvent(a,s,s);break;case"groupObjects":case"ungroupObjects":t=e.targets,this.sendEvent(a,t);break;case"pasteElmsComplete":t=e.targets.map(o=>this.api.getXML(o)).join(""),this.sendEvent("evalXML",t);break;case"addGeoToTV":case"removeGeoFromTV":t=e[1],this.sendEvent(a,t);break;case"setValuesOfTV":t=e[2],this.sendEvent(a,t);break;case"showPointsTV":({column:t,show:s}=e),this.sendEvent(a,t,s);break;case"lockTextElement":case"unlockTextElement":t=e[1],this.sendEvent(a,t);break;case"viewChanged2D":this.viewSyncCallback||(this.isSyncingViewState||this.viewState.scale===0?this.viewSyncCallback=setTimeout(this._flushViewState,this.delay):this.viewSyncCallback=setTimeout(this._sendViewSyncEvent,this.delay));break;case"mouseDown":case"deleteGeos":case"dragEnd":break;default:console.debug("[GeoGebra] unhandled event ",e.type,e)}},this.viewSyncCallback=0,this.viewState={scale:0,x:0,y:0},this._sendViewSyncEvent=()=>{this._flushViewState(),this.sendEvent("viewChanged2D",JSON.stringify(this.viewState)),this.viewSyncCallback=0},this._delayedRegisterListeners=()=>{this.registerListeners(),this.viewSyncCallback=0},this.conflictedObjects=[],this.dispatch=e=>{var h,p;if(this.conflictedObjects.includes(e.label)&&e.type!=="conflictResolution")return;const t=e.embedLabel?this.embeds[e.embedLabel]:this,a=e.type,o=e.label,r=e.content;if(console.debug("[GeoGebra] receive:",a,o,r),a==="addObject")if(t.api.exists(o))if(this.context.isDecider)if(this.context.isDecider(this.clientId)){let c=1,l;do l=`${o}_${c}`,c++;while(t.api.exists(l));this.unregisterListeners(),t.api.renameObject(o,l),this.registerListeners();const u=t.api.getAlgorithmXML(l)||t.api.getXML(l);this.sendEvent("conflictResolution",u,o)}else this.conflictedObjects.push(o);else t.evalXML(r),t.api.previewRefresh();else t.evalXML(r),t.api.previewRefresh();else if(a==="conflictResolution"){const c=this.conflictedObjects.indexOf(o);c!==-1&&this.conflictedObjects.splice(c,1),t.evalXML(r),t.api.previewRefresh()}else if(a==="evalXML")t.evalXML(r),t.api.previewRefresh();else if(a==="setXML")t.setXML(r);else if(a==="evalCommand")t.evalCommand(r),t.api.previewRefresh();else if(a==="deleteObject")t.unregisterListeners(),t===this&&delete this.embeds[r],t.api.deleteObject(r),t.registerListeners();else if(a==="setEditorState")t.unregisterListeners(),t.api.setEditorState(r,o),t.registerListeners();else if(a==="addImage"){const c=JSON.parse(r);t.api.addImage(c.fileName,c.fileContent)}else if(["addSlide","removeSlide","moveSlide","clearSlide"].includes(a))t.api.handleSlideAction(a,r);else if(a==="selectSlide")t.unregisterListeners(),t.api.selectSlide(r),t.registerListeners();else if(a==="renameObject")t.unregisterListeners(),t.api.renameObject(r,o),t.registerListeners();else if(a==="pasteSlide")t.api.handleSlideAction(a,r,o);else if(a==="evalGMContent"){const c=(t.api.getEmbeddedCalculators(!0)||{})[o];c&&c.loadFromJSON(r)}else if(a==="startAnimation")t.api.setAnimating(o,!0),t.api.startAnimation();else if(a==="stopAnimation")t.api.setAnimating(o,!1);else if(a==="select"){if(r){const c=((p=(h=this.context).getColor)==null?void 0:p.call(h,e.clientId))||"#80808080";try{t.api.addMultiuserSelection(String(e.clientId),String(e.nickName),c,r,!!o)}catch(l){console.error(l)}}}else if(a==="deselect")t.api.removeMultiuserSelections(String(e.nickName));else if(a==="orderingChange")t.api.updateOrdering(r);else if(a==="groupObjects")t.api.groupObjects(r);else if(a==="ungroupObjects")t.api.ungroupObjects(r);else if(a==="addToGroup")t.api.addToGroup(r,o);else if(a==="embeddedContentChanged")t.api.setEmbedContent(o,r);else if(a==="addGeoToTV")t.api.addGeoToTV(r);else if(a==="setValuesOfTV")t.api.setValuesOfTV(r);else if(a==="removeGeoFromTV")t.api.removeGeoFromTV(r);else if(a==="showPointsTV")t.api.showPointsTV(r,o);else if(a==="lockTextElement")t.api.lockTextElement(r);else if(a==="unlockTextElement")t.api.unlockTextElement(r);else if(a==="viewChanged2D")if(t.viewState.scale===0)t.api.evalCommand("Pan(0,0)"),t.startSyncViewState();else{const{scale:c,x:l,y:u}=JSON.parse(r),g=t._flushViewState();t.startSyncViewState(),t.api.evalCommand(`Pan(${l-g.x},${u-g.y})`),t.api.evalCommand(`ZoomIn(${c/g.scale})`)}else console.debug("[GeoGebra] unknown event",a,r,o)},this.api=i.api,this.clientId=i.clientId,this.nickName=i.nickName,this.delay=(n=i.delay)!=null?n:200,this.context=i,setTimeout(()=>{this.api.evalCommand("Pan(0,0)")},this.delay)}createEvent(i,n,e){const s={type:i,content:n,clientId:this.clientId,nickName:this.nickName};return this.context.embedLabel&&(s.embedLabel=this.context.embedLabel),e&&(s.label=e),s}sendEvent(i,n,e){console.log("[GeoGebra] send:",i,e,n),this.context.postMessage(this.createEvent(i,n,e)),this.storageCallback||(this.storageCallback=setTimeout(()=>{this.context.save(this.api.getBase64()),this.storageCallback=0},this.delay))}evalCommand(i){this.unregisterListeners(),this.api.evalCommand(i),this.registerListeners()}evalXML(i){this.unregisterListeners(),this.api.evalXML(i),this.api.updateConstruction(),this.registerListeners(),setTimeout(this.initAllEmbeds,500)}setXML(i){this.unregisterListeners(),this.api.setXML(i),this.api.updateConstruction(),this.registerListeners()}initEmbed(i){if(this.embeds[i])return;const n=this.api.getEmbeddedCalculators();if(!n)return;const e=n[i];if(e&&"registerClientListener"in e){const s=new S(I(w({},this.context),{clientId:this.clientId,nickName:this.nickName,api:e,embedLabel:i}));s.registerListeners(),this.embeds[i]=s}}startSyncViewState(){clearTimeout(this.isSyncingViewState),this.isSyncingViewState=setTimeout(this.stopSyncViewState,1e3)}shouldSyncView(i,n,e,s){return Math.abs(n-i.scale)>S.Threshold/10||Math.abs(e-i.x)>S.Threshold||Math.abs(s-i.y)>S.Threshold}registerListeners(){this.api.registerUpdateListener(this.updateListener),this.api.registerRemoveListener(this.removeListener),this.api.registerAddListener(this.addListener),this.api.registerClientListener(this.clientListener),this.api.registerRenameListener(this.renameListener)}unregisterListeners(){this.api.unregisterUpdateListener(this.updateListener),this.api.unregisterRemoveListener(this.removeListener),this.api.unregisterAddListener(this.addListener),this.api.unregisterClientListener(this.clientListener),this.api.unregisterRenameListener(this.renameListener)}};let V=S;V.Threshold=20;var H=(()=>`.netless-app-geogebra{width:100%!important;height:100%!important;overflow:hidden}.netless-app-geogebra.loading{background-color:#fff}.netless-app-geogebra.readonly{user-select:none;pointer-events:none}
`)();function Z(i,n){const e=new ResizeObserver(()=>n(i));return e.observe(i),()=>e.disconnect()}function K(i,n,e){const s=i.getDisplayer(),t=i.getRoom();let a=[];const o=c=>{c.authorId!==s.observerId&&a.forEach(l=>l(c.payload))},r="sync--"+i.appId;return s.addMagixEventListener(r,o),{service:{addListener(c){a.push(c)},postMessage(c){t==null||t.dispatchMagixEvent(r,c)},load(){return n[e]},save(c){i.updateAttributes([e],c)}},disposer:()=>{a=[],s.removeMagixEventListener(r)}}}const Y=new Set(["classic","graphing","geometry","3d","suite","evaluator","scientific"]),q={kind:"GeoGebra",async setup(i){var k;const n=i.getDisplayer(),e=n.observerId,s=(k=n.state.roomMembers.find(m=>m.memberId===e))==null?void 0:k.payload,t=(s==null?void 0:s.uid)||"",a=(s==null?void 0:s.nickName)||t,o=i.getAppOptions()||{},r=o.deployggb,h=o.HTML5Codebase,p=W(i,{uid:"",ggbBase64:"",appName:"classic"}),c=i.getBox();c.mountStyles(H);const l=document.createElement("div");l.classList.add("netless-app-geogebra","loading"),t!==p.uid&&p.uid&&l.classList.add("netless-app-geogebra","readonly"),c.mountContent(l);const u=new F,g=w({},z);Y.has(p.appName)&&(g.appName=p.appName),g.language=navigator.language.startsWith("zh")?"zh":"en",p.ggbBase64&&(g.ggbBase64=p.ggbBase64),g.id="ggb_"+i.appId;let d;const y=K(i,p,"ggbBase64");function E(){const{width:m,height:b}=l.getBoundingClientRect();d==null||d.setWidth(m),d==null||d.setHeight(b)}g.appletOnLoad=m=>{console.log(`[GeoGebra]: loaded ${JSON.stringify(g.id)}`),d=m,E(),l.classList.remove("loading");const b=i.getDisplayer(),M=new V(w({clientId:b.observerId,nickName:a,api:m,isDecider:f=>b.state.roomMembers.map(v=>v.memberId).every(v=>f<=v),getColor:f=>{const O=b.memberState(f).strokeColor;return"#"+O.map(v=>v.toString(16).padStart(2,"0")).join("")+"80"}},y.service));M.registerListeners(),y.service.addListener(f=>{M.dispatch(f),d==null||d.setUndoPoint()})},u.add(()=>Z(l,E)),i.emitter.on("destroy",()=>{console.log("[GeoGebra]: destroy"),u.flushAll(),y.disposer(),d==null||d.remove()});const X=await $({deployggb:r}),C=new X(g);h&&C.setHTML5Codebase(h),C.inject(l)}};exports.default=q;
//# sourceMappingURL=main.cjs.js.map

@@ -437,3 +437,3 @@ var __defProp = Object.defineProperty;

try {
target.api.addMultiuserSelection(String(last.nickName), color, content, !!label);
target.api.addMultiuserSelection(String(last.clientId), String(last.nickName), color, content, !!label);
} catch (error) {

@@ -440,0 +440,0 @@ console.error(error);

@@ -1,3 +0,3 @@

var NetlessAppGeoGebra=function(h){"use strict";var Z=Object.defineProperty,K=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var q=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable;var X=(h,d,g)=>d in h?Z(h,d,{enumerable:!0,configurable:!0,writable:!0,value:g}):h[d]=g,C=(h,d)=>{for(var g in d||(d={}))q.call(d,g)&&X(h,g,d[g]);if(V)for(var g of V(d))Q.call(d,g)&&X(h,g,d[g]);return h},D=(h,d)=>K(h,Y(d));const d="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",g=d.length,M=Array(20),B=()=>{for(let n=0;n<20;n++)M[n]=d.charAt(Math.random()*g);return M.join("")};function A(n){try{return n()}catch(a){console.error(a)}}class x{constructor(){this.disposers=new Map}addDisposer(a,t=this.genUID()){return this.flush(t),this.disposers.set(t,Array.isArray(a)?()=>a.forEach(A):a),t}add(a,t=this.genUID()){return this.addDisposer(a(),t)}addEventListener(a,t,s,e,i=this.genUID()){return a.addEventListener(t,s,e),this.addDisposer(()=>a.removeEventListener(t,s,e),i),i}setTimeout(a,t,s=this.genUID()){const e=window.setTimeout(()=>{this.remove(s),a()},t);return this.addDisposer(()=>window.clearTimeout(e),s)}setInterval(a,t,s=this.genUID()){const e=window.setInterval(a,t);return this.addDisposer(()=>window.clearInterval(e),s)}remove(a){const t=this.disposers.get(a);return this.disposers.delete(a),t}flush(a){const t=this.remove(a);if(t)try{t()}catch(s){console.error(s)}}flushAll(){this.disposers.forEach(A),this.disposers.clear()}genUID(){let a;do a=B();while(this.disposers.has(a));return a}}function R(n){return n!=null&&typeof n=="object"&&!Array.isArray(n)}function U(n,a){let t=n.getAttributes();if(t||(n.setAttributes(a),t=n.getAttributes()),!t)throw new Error("[NetlessAppMonaco] No attributes");return R(a)&&Object.keys(a).forEach(s=>{Object.prototype.hasOwnProperty.call(t,s)||n.updateAttributes([s],a[s])}),t}let L;function _({deployggb:n="https://www.geogebra.org/apps/latest/deployggb.js"}={}){if(window.GGBApplet)return Promise.resolve(window.GGBApplet);if(L)return L;{const a=document.createElement("script");return L=new Promise((t,s)=>{a.onload=()=>t(window.GGBApplet),a.onerror=()=>{L=void 0,s()}}),a.src=n,document.head.appendChild(a),L}}const P={appName:"classic",showMenuBar:!0,showAlgebraInput:!0,showToolBar:!0,customToolBar:"0 39 73 62 | 1 501 67 , 5 19 , 72 75 76 | 2 15 45 , 18 65 , 7 37 | 4 3 8 9 , 13 44 , 58 , 47 | 16 51 64 , 70 | 10 34 53 11 , 24 20 22 , 21 23 | 55 56 57 , 12 | 36 46 , 38 49 50 , 71 14 68 | 30 29 54 32 31 33 | 25 17 26 60 52 61 | 40 41 42 , 27 28 35 , 6",showToolBarHelp:!1,showResetIcon:!1,enableFileFeatures:!1,enableLabelDrags:!1,enableShiftDragZoom:!0,enableRightClick:!0,errorDialogsActive:!1,allowStyleBar:!1,preventFocus:!1,useBrowserForJS:!0,language:"en",borderColor:"transparent"},S=class{constructor(n){var a;this.currentAnimations=[],this.embeds={},this.storageCallback=0,this.initAllEmbeds=()=>{for(const t of this.api.getAllObjectNames("embed"))this.initEmbed(t)},this.objectsInWaiting=[],this.updateCallback=0,this.dispatchUpdates=()=>{this.updateCallback||(this.updateCallback=setTimeout(this._dispatchUpdates,this.delay))},this._dispatchUpdates=()=>{const{objectsInWaiting:t}=this;this.objectsInWaiting=[];for(const s of t){const e=this.api.getEmbeddedCalculators(!0),i=e==null?void 0:e[s];i!=null&&i.controller&&this.sendEvent("evalGMContent",i.toJSON(),s);const o=this.api.getCommandString(s,!1);if(o){this.sendEvent("evalCommand",`${s} := ${o}`,s);const r=this.api.getObjectsOfItsGroup(s);r!=null&&r.length&&this.sendEvent("addToGroup",s,r)}if(!o||this.api.isMoveable(s)){const r=this.api.getXML(s);this.sendEvent("evalXML",r,s)}this.sendEvent("select",s,!0)}this.updateCallback=0},this.updateListener=t=>{(this.api.hasUnlabeledPredecessors(t)||this.api.isMoveable(t))&&!this.currentAnimations.includes(t)&&(this.objectsInWaiting.includes(t)||(this.objectsInWaiting.push(t),this.dispatchUpdates()))},this.addListener=t=>{const s=this.api.getImageFileName(t);if(s){const r=this.api.getFileJSON();for(const u of r.archive)u.fileName.includes(s)&&this.sendEvent("addImage",JSON.stringify(u))}const e=this.api.getXML(t),o=this.api.getCommandString(t)&&this.api.getAlgorithmXML(t);this.sendEvent("addObject",o||e,t),this.sendEvent("deselect"),this.sendEvent("select",t,!0),setTimeout(()=>this.initEmbed(t),500)},this.removeListener=t=>{this.sendEvent("deleteObject",t),delete this.embeds[t]},this.renameListener=(t,s)=>{this.sendEvent("renameObject",t,s)},this.isSyncingViewState=0,this.stopSyncViewState=()=>{this.isSyncingViewState=0},this._flushViewState=()=>{const{invXscale:t,invYscale:s,xMin:e,yMin:i}=JSON.parse(this.api.getViewProperties(0)),o=1/t,r=-e/t,u=-i/s;return this.viewState={scale:o,x:r,y:u},this.viewSyncCallback=0,this.viewState},this.clientListener=t=>{let s,e;const i=t.type;switch(i){case"updateStyle":s=t.target,e=this.api.getXML(s),this.sendEvent("evalXML",e);break;case"editorStart":this.lastEditingLabel=t.target;break;case"editorKeyTyped":e=this.api.getEditorState(),this.sendEvent("setEditorState",e,this.lastEditingLabel);break;case"editorStop":this.lastEditingLabel=void 0,this.sendEvent("setEditorState",JSON.stringify({content:""}));break;case"deselect":this.sendEvent("deselect",t.target);break;case"select":this.sendEvent("select",t.target);break;case"embeddedContentChanged":s=t[1],e=t[2],this.sendEvent("embeddedContentChanged",e,s);break;case"undo":case"redo":case"addPolygonComplete":e=this.api.getXML(),this.sendEvent("setXML",e);break;case"addSlide":this.sendEvent(i);break;case"removeSlide":case"moveSlide":case"selectSlide":case"clearSlide":case"orderingChange":e=t[2],this.sendEvent(i,e);break;case"pasteSlide":({cardIdx:e,ggbFile:s}=t),this.sendEvent(i,e,s);break;case"startAnimation":s=t[1],this.currentAnimations.push(s),this.sendEvent(i,s,s);break;case"stopAnimation":s=t[1],this.currentAnimations.splice(this.currentAnimations.indexOf(s),1),this.sendEvent(i,s,s);break;case"groupObjects":case"ungroupObjects":e=t.targets,this.sendEvent(i,e);break;case"pasteElmsComplete":e=t.targets.map(o=>this.api.getXML(o)).join(""),this.sendEvent("evalXML",e);break;case"addGeoToTV":case"removeGeoFromTV":e=t[1],this.sendEvent(i,e);break;case"setValuesOfTV":e=t[2],this.sendEvent(i,e);break;case"showPointsTV":({column:e,show:s}=t),this.sendEvent(i,e,s);break;case"lockTextElement":case"unlockTextElement":e=t[1],this.sendEvent(i,e);break;case"viewChanged2D":this.viewSyncCallback||(this.isSyncingViewState||this.viewState.scale===0?this.viewSyncCallback=setTimeout(this._flushViewState,this.delay):this.viewSyncCallback=setTimeout(this._sendViewSyncEvent,this.delay));break;case"mouseDown":case"deleteGeos":case"dragEnd":break;default:console.debug("[GeoGebra] unhandled event ",t.type,t)}},this.viewSyncCallback=0,this.viewState={scale:0,x:0,y:0},this._sendViewSyncEvent=()=>{this._flushViewState(),this.sendEvent("viewChanged2D",JSON.stringify(this.viewState)),this.viewSyncCallback=0},this._delayedRegisterListeners=()=>{this.registerListeners(),this.viewSyncCallback=0},this.conflictedObjects=[],this.dispatch=t=>{var u,m;if(this.conflictedObjects.includes(t.label)&&t.type!=="conflictResolution")return;const e=t.embedLabel?this.embeds[t.embedLabel]:this,i=t.type,o=t.label,r=t.content;if(console.debug("[GeoGebra] receive:",i,o,r),i==="addObject")if(e.api.exists(o))if(this.context.isDecider)if(this.context.isDecider(this.clientId)){let c=1,l;do l=`${o}_${c}`,c++;while(e.api.exists(l));this.unregisterListeners(),e.api.renameObject(o,l),this.registerListeners();const f=e.api.getAlgorithmXML(l)||e.api.getXML(l);this.sendEvent("conflictResolution",f,o)}else this.conflictedObjects.push(o);else e.evalXML(r),e.api.previewRefresh();else e.evalXML(r),e.api.previewRefresh();else if(i==="conflictResolution"){const c=this.conflictedObjects.indexOf(o);c!==-1&&this.conflictedObjects.splice(c,1),e.evalXML(r),e.api.previewRefresh()}else if(i==="evalXML")e.evalXML(r),e.api.previewRefresh();else if(i==="setXML")e.setXML(r);else if(i==="evalCommand")e.evalCommand(r),e.api.previewRefresh();else if(i==="deleteObject")e.unregisterListeners(),e===this&&delete this.embeds[r],e.api.deleteObject(r),e.registerListeners();else if(i==="setEditorState")e.unregisterListeners(),e.api.setEditorState(r,o),e.registerListeners();else if(i==="addImage"){const c=JSON.parse(r);e.api.addImage(c.fileName,c.fileContent)}else if(["addSlide","removeSlide","moveSlide","clearSlide"].includes(i))e.api.handleSlideAction(i,r);else if(i==="selectSlide")e.unregisterListeners(),e.api.selectSlide(r),e.registerListeners();else if(i==="renameObject")e.unregisterListeners(),e.api.renameObject(r,o),e.registerListeners();else if(i==="pasteSlide")e.api.handleSlideAction(i,r,o);else if(i==="evalGMContent"){const c=(e.api.getEmbeddedCalculators(!0)||{})[o];c&&c.loadFromJSON(r)}else if(i==="startAnimation")e.api.setAnimating(o,!0),e.api.startAnimation();else if(i==="stopAnimation")e.api.setAnimating(o,!1);else if(i==="select"){if(r){const c=((m=(u=this.context).getColor)==null?void 0:m.call(u,t.clientId))||"#80808080";try{e.api.addMultiuserSelection(String(t.nickName),c,r,!!o)}catch(l){console.error(l)}}}else if(i==="deselect")e.api.removeMultiuserSelections(String(t.nickName));else if(i==="orderingChange")e.api.updateOrdering(r);else if(i==="groupObjects")e.api.groupObjects(r);else if(i==="ungroupObjects")e.api.ungroupObjects(r);else if(i==="addToGroup")e.api.addToGroup(r,o);else if(i==="embeddedContentChanged")e.api.setEmbedContent(o,r);else if(i==="addGeoToTV")e.api.addGeoToTV(r);else if(i==="setValuesOfTV")e.api.setValuesOfTV(r);else if(i==="removeGeoFromTV")e.api.removeGeoFromTV(r);else if(i==="showPointsTV")e.api.showPointsTV(r,o);else if(i==="lockTextElement")e.api.lockTextElement(r);else if(i==="unlockTextElement")e.api.unlockTextElement(r);else if(i==="viewChanged2D")if(e.viewState.scale===0)e.api.evalCommand("Pan(0,0)"),e.startSyncViewState();else{const{scale:c,x:l,y:f}=JSON.parse(r),b=e._flushViewState();e.startSyncViewState(),e.api.evalCommand(`Pan(${l-b.x},${f-b.y})`),e.api.evalCommand(`ZoomIn(${c/b.scale})`)}else console.debug("[GeoGebra] unknown event",i,r,o)},this.api=n.api,this.clientId=n.clientId,this.nickName=n.nickName,this.delay=(a=n.delay)!=null?a:200,this.context=n,setTimeout(()=>{this.api.evalCommand("Pan(0,0)")},this.delay)}createEvent(n,a,t){const s={type:n,content:a,clientId:this.clientId,nickName:this.nickName};return this.context.embedLabel&&(s.embedLabel=this.context.embedLabel),t&&(s.label=t),s}sendEvent(n,a,t){console.log("[GeoGebra] send:",n,t,a),this.context.postMessage(this.createEvent(n,a,t)),this.storageCallback||(this.storageCallback=setTimeout(()=>{this.context.save(this.api.getBase64()),this.storageCallback=0},this.delay))}evalCommand(n){this.unregisterListeners(),this.api.evalCommand(n),this.registerListeners()}evalXML(n){this.unregisterListeners(),this.api.evalXML(n),this.api.updateConstruction(),this.registerListeners(),setTimeout(this.initAllEmbeds,500)}setXML(n){this.unregisterListeners(),this.api.setXML(n),this.api.updateConstruction(),this.registerListeners()}initEmbed(n){if(this.embeds[n])return;const a=this.api.getEmbeddedCalculators();if(!a)return;const t=a[n];if(t&&"registerClientListener"in t){const s=new S(D(C({},this.context),{clientId:this.clientId,nickName:this.nickName,api:t,embedLabel:n}));s.registerListeners(),this.embeds[n]=s}}startSyncViewState(){clearTimeout(this.isSyncingViewState),this.isSyncingViewState=setTimeout(this.stopSyncViewState,1e3)}shouldSyncView(n,a,t,s){return Math.abs(a-n.scale)>S.Threshold/10||Math.abs(t-n.x)>S.Threshold||Math.abs(s-n.y)>S.Threshold}registerListeners(){this.api.registerUpdateListener(this.updateListener),this.api.registerRemoveListener(this.removeListener),this.api.registerAddListener(this.addListener),this.api.registerClientListener(this.clientListener),this.api.registerRenameListener(this.renameListener)}unregisterListeners(){this.api.unregisterUpdateListener(this.updateListener),this.api.unregisterRemoveListener(this.removeListener),this.api.unregisterAddListener(this.addListener),this.api.unregisterClientListener(this.clientListener),this.api.unregisterRenameListener(this.renameListener)}};let O=S;O.Threshold=20;var F=(()=>`.netless-app-geogebra{width:100%!important;height:100%!important;overflow:hidden}.netless-app-geogebra.loading{background-color:#fff}.netless-app-geogebra.readonly{user-select:none;pointer-events:none}
`)();function J(n,a){const t=new ResizeObserver(()=>a(n));return t.observe(n),()=>t.disconnect()}function W(n,a,t){const s=n.getDisplayer(),e=n.getRoom();let i=[];const o=c=>{c.authorId!==s.observerId&&i.forEach(l=>l(c.payload))},r="sync--"+n.appId;return s.addMagixEventListener(r,o),{service:{addListener(c){i.push(c)},postMessage(c){e==null||e.dispatchMagixEvent(r,c)},load(){return a[t]},save(c){n.updateAttributes([t],c)}},disposer:()=>{i=[],s.removeMagixEventListener(r)}}}const $=new Set(["classic","graphing","geometry","3d","suite","evaluator","scientific"]),z={kind:"GeoGebra",async setup(n){var I;const a=n.getDisplayer(),t=a.observerId,s=(I=a.state.roomMembers.find(v=>v.memberId===t))==null?void 0:I.payload,e=(s==null?void 0:s.uid)||"",i=(s==null?void 0:s.nickName)||e,o=n.getAppOptions()||{},r=o.deployggb,u=o.HTML5Codebase,m=U(n,{uid:"",ggbBase64:"",appName:"classic"}),c=n.getBox();c.mountStyles(F);const l=document.createElement("div");l.classList.add("netless-app-geogebra","loading"),e!==m.uid&&m.uid&&l.classList.add("netless-app-geogebra","readonly"),c.mountContent(l);const f=new x,b=C({},P);$.has(m.appName)&&(b.appName=m.appName),b.language=navigator.language.startsWith("zh")?"zh":"en",m.ggbBase64&&(b.ggbBase64=m.ggbBase64),b.id="ggb_"+n.appId;let p;const k=W(n,m,"ggbBase64");function T(){const{width:v,height:w}=l.getBoundingClientRect();p==null||p.setWidth(v),p==null||p.setHeight(w)}b.appletOnLoad=v=>{console.log(`[GeoGebra]: loaded ${JSON.stringify(b.id)}`),p=v,T(),l.classList.remove("loading");const w=n.getDisplayer(),j=new O(C({clientId:w.observerId,nickName:i,api:v,isDecider:y=>w.state.roomMembers.map(E=>E.memberId).every(E=>y<=E),getColor:y=>{const N=w.memberState(y).strokeColor;return"#"+N.map(E=>E.toString(16).padStart(2,"0")).join("")+"80"}},k.service));j.registerListeners(),k.service.addListener(y=>{j.dispatch(y),p==null||p.setUndoPoint()})},f.add(()=>J(l,T)),n.emitter.on("destroy",()=>{console.log("[GeoGebra]: destroy"),f.flushAll(),k.disposer(),p==null||p.remove()});const H=await _({deployggb:r}),G=new H(b);u&&G.setHTML5Codebase(u),G.inject(l)}};return h.default=z,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),h}({});
var NetlessAppGeoGebra=function(h){"use strict";var Z=Object.defineProperty,K=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var q=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable;var X=(h,d,g)=>d in h?Z(h,d,{enumerable:!0,configurable:!0,writable:!0,value:g}):h[d]=g,C=(h,d)=>{for(var g in d||(d={}))q.call(d,g)&&X(h,g,d[g]);if(V)for(var g of V(d))Q.call(d,g)&&X(h,g,d[g]);return h},D=(h,d)=>K(h,Y(d));const d="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",g=d.length,M=Array(20),B=()=>{for(let n=0;n<20;n++)M[n]=d.charAt(Math.random()*g);return M.join("")};function A(n){try{return n()}catch(a){console.error(a)}}class x{constructor(){this.disposers=new Map}addDisposer(a,e=this.genUID()){return this.flush(e),this.disposers.set(e,Array.isArray(a)?()=>a.forEach(A):a),e}add(a,e=this.genUID()){return this.addDisposer(a(),e)}addEventListener(a,e,s,t,i=this.genUID()){return a.addEventListener(e,s,t),this.addDisposer(()=>a.removeEventListener(e,s,t),i),i}setTimeout(a,e,s=this.genUID()){const t=window.setTimeout(()=>{this.remove(s),a()},e);return this.addDisposer(()=>window.clearTimeout(t),s)}setInterval(a,e,s=this.genUID()){const t=window.setInterval(a,e);return this.addDisposer(()=>window.clearInterval(t),s)}remove(a){const e=this.disposers.get(a);return this.disposers.delete(a),e}flush(a){const e=this.remove(a);if(e)try{e()}catch(s){console.error(s)}}flushAll(){this.disposers.forEach(A),this.disposers.clear()}genUID(){let a;do a=B();while(this.disposers.has(a));return a}}function R(n){return n!=null&&typeof n=="object"&&!Array.isArray(n)}function U(n,a){let e=n.getAttributes();if(e||(n.setAttributes(a),e=n.getAttributes()),!e)throw new Error("[NetlessAppMonaco] No attributes");return R(a)&&Object.keys(a).forEach(s=>{Object.prototype.hasOwnProperty.call(e,s)||n.updateAttributes([s],a[s])}),e}let L;function _({deployggb:n="https://www.geogebra.org/apps/latest/deployggb.js"}={}){if(window.GGBApplet)return Promise.resolve(window.GGBApplet);if(L)return L;{const a=document.createElement("script");return L=new Promise((e,s)=>{a.onload=()=>e(window.GGBApplet),a.onerror=()=>{L=void 0,s()}}),a.src=n,document.head.appendChild(a),L}}const P={appName:"classic",showMenuBar:!0,showAlgebraInput:!0,showToolBar:!0,customToolBar:"0 39 73 62 | 1 501 67 , 5 19 , 72 75 76 | 2 15 45 , 18 65 , 7 37 | 4 3 8 9 , 13 44 , 58 , 47 | 16 51 64 , 70 | 10 34 53 11 , 24 20 22 , 21 23 | 55 56 57 , 12 | 36 46 , 38 49 50 , 71 14 68 | 30 29 54 32 31 33 | 25 17 26 60 52 61 | 40 41 42 , 27 28 35 , 6",showToolBarHelp:!1,showResetIcon:!1,enableFileFeatures:!1,enableLabelDrags:!1,enableShiftDragZoom:!0,enableRightClick:!0,errorDialogsActive:!1,allowStyleBar:!1,preventFocus:!1,useBrowserForJS:!0,language:"en",borderColor:"transparent"},S=class{constructor(n){var a;this.currentAnimations=[],this.embeds={},this.storageCallback=0,this.initAllEmbeds=()=>{for(const e of this.api.getAllObjectNames("embed"))this.initEmbed(e)},this.objectsInWaiting=[],this.updateCallback=0,this.dispatchUpdates=()=>{this.updateCallback||(this.updateCallback=setTimeout(this._dispatchUpdates,this.delay))},this._dispatchUpdates=()=>{const{objectsInWaiting:e}=this;this.objectsInWaiting=[];for(const s of e){const t=this.api.getEmbeddedCalculators(!0),i=t==null?void 0:t[s];i!=null&&i.controller&&this.sendEvent("evalGMContent",i.toJSON(),s);const o=this.api.getCommandString(s,!1);if(o){this.sendEvent("evalCommand",`${s} := ${o}`,s);const r=this.api.getObjectsOfItsGroup(s);r!=null&&r.length&&this.sendEvent("addToGroup",s,r)}if(!o||this.api.isMoveable(s)){const r=this.api.getXML(s);this.sendEvent("evalXML",r,s)}this.sendEvent("select",s,!0)}this.updateCallback=0},this.updateListener=e=>{(this.api.hasUnlabeledPredecessors(e)||this.api.isMoveable(e))&&!this.currentAnimations.includes(e)&&(this.objectsInWaiting.includes(e)||(this.objectsInWaiting.push(e),this.dispatchUpdates()))},this.addListener=e=>{const s=this.api.getImageFileName(e);if(s){const r=this.api.getFileJSON();for(const u of r.archive)u.fileName.includes(s)&&this.sendEvent("addImage",JSON.stringify(u))}const t=this.api.getXML(e),o=this.api.getCommandString(e)&&this.api.getAlgorithmXML(e);this.sendEvent("addObject",o||t,e),this.sendEvent("deselect"),this.sendEvent("select",e,!0),setTimeout(()=>this.initEmbed(e),500)},this.removeListener=e=>{this.sendEvent("deleteObject",e),delete this.embeds[e]},this.renameListener=(e,s)=>{this.sendEvent("renameObject",e,s)},this.isSyncingViewState=0,this.stopSyncViewState=()=>{this.isSyncingViewState=0},this._flushViewState=()=>{const{invXscale:e,invYscale:s,xMin:t,yMin:i}=JSON.parse(this.api.getViewProperties(0)),o=1/e,r=-t/e,u=-i/s;return this.viewState={scale:o,x:r,y:u},this.viewSyncCallback=0,this.viewState},this.clientListener=e=>{let s,t;const i=e.type;switch(i){case"updateStyle":s=e.target,t=this.api.getXML(s),this.sendEvent("evalXML",t);break;case"editorStart":this.lastEditingLabel=e.target;break;case"editorKeyTyped":t=this.api.getEditorState(),this.sendEvent("setEditorState",t,this.lastEditingLabel);break;case"editorStop":this.lastEditingLabel=void 0,this.sendEvent("setEditorState",JSON.stringify({content:""}));break;case"deselect":this.sendEvent("deselect",e.target);break;case"select":this.sendEvent("select",e.target);break;case"embeddedContentChanged":s=e[1],t=e[2],this.sendEvent("embeddedContentChanged",t,s);break;case"undo":case"redo":case"addPolygonComplete":t=this.api.getXML(),this.sendEvent("setXML",t);break;case"addSlide":this.sendEvent(i);break;case"removeSlide":case"moveSlide":case"selectSlide":case"clearSlide":case"orderingChange":t=e[2],this.sendEvent(i,t);break;case"pasteSlide":({cardIdx:t,ggbFile:s}=e),this.sendEvent(i,t,s);break;case"startAnimation":s=e[1],this.currentAnimations.push(s),this.sendEvent(i,s,s);break;case"stopAnimation":s=e[1],this.currentAnimations.splice(this.currentAnimations.indexOf(s),1),this.sendEvent(i,s,s);break;case"groupObjects":case"ungroupObjects":t=e.targets,this.sendEvent(i,t);break;case"pasteElmsComplete":t=e.targets.map(o=>this.api.getXML(o)).join(""),this.sendEvent("evalXML",t);break;case"addGeoToTV":case"removeGeoFromTV":t=e[1],this.sendEvent(i,t);break;case"setValuesOfTV":t=e[2],this.sendEvent(i,t);break;case"showPointsTV":({column:t,show:s}=e),this.sendEvent(i,t,s);break;case"lockTextElement":case"unlockTextElement":t=e[1],this.sendEvent(i,t);break;case"viewChanged2D":this.viewSyncCallback||(this.isSyncingViewState||this.viewState.scale===0?this.viewSyncCallback=setTimeout(this._flushViewState,this.delay):this.viewSyncCallback=setTimeout(this._sendViewSyncEvent,this.delay));break;case"mouseDown":case"deleteGeos":case"dragEnd":break;default:console.debug("[GeoGebra] unhandled event ",e.type,e)}},this.viewSyncCallback=0,this.viewState={scale:0,x:0,y:0},this._sendViewSyncEvent=()=>{this._flushViewState(),this.sendEvent("viewChanged2D",JSON.stringify(this.viewState)),this.viewSyncCallback=0},this._delayedRegisterListeners=()=>{this.registerListeners(),this.viewSyncCallback=0},this.conflictedObjects=[],this.dispatch=e=>{var u,m;if(this.conflictedObjects.includes(e.label)&&e.type!=="conflictResolution")return;const t=e.embedLabel?this.embeds[e.embedLabel]:this,i=e.type,o=e.label,r=e.content;if(console.debug("[GeoGebra] receive:",i,o,r),i==="addObject")if(t.api.exists(o))if(this.context.isDecider)if(this.context.isDecider(this.clientId)){let c=1,l;do l=`${o}_${c}`,c++;while(t.api.exists(l));this.unregisterListeners(),t.api.renameObject(o,l),this.registerListeners();const f=t.api.getAlgorithmXML(l)||t.api.getXML(l);this.sendEvent("conflictResolution",f,o)}else this.conflictedObjects.push(o);else t.evalXML(r),t.api.previewRefresh();else t.evalXML(r),t.api.previewRefresh();else if(i==="conflictResolution"){const c=this.conflictedObjects.indexOf(o);c!==-1&&this.conflictedObjects.splice(c,1),t.evalXML(r),t.api.previewRefresh()}else if(i==="evalXML")t.evalXML(r),t.api.previewRefresh();else if(i==="setXML")t.setXML(r);else if(i==="evalCommand")t.evalCommand(r),t.api.previewRefresh();else if(i==="deleteObject")t.unregisterListeners(),t===this&&delete this.embeds[r],t.api.deleteObject(r),t.registerListeners();else if(i==="setEditorState")t.unregisterListeners(),t.api.setEditorState(r,o),t.registerListeners();else if(i==="addImage"){const c=JSON.parse(r);t.api.addImage(c.fileName,c.fileContent)}else if(["addSlide","removeSlide","moveSlide","clearSlide"].includes(i))t.api.handleSlideAction(i,r);else if(i==="selectSlide")t.unregisterListeners(),t.api.selectSlide(r),t.registerListeners();else if(i==="renameObject")t.unregisterListeners(),t.api.renameObject(r,o),t.registerListeners();else if(i==="pasteSlide")t.api.handleSlideAction(i,r,o);else if(i==="evalGMContent"){const c=(t.api.getEmbeddedCalculators(!0)||{})[o];c&&c.loadFromJSON(r)}else if(i==="startAnimation")t.api.setAnimating(o,!0),t.api.startAnimation();else if(i==="stopAnimation")t.api.setAnimating(o,!1);else if(i==="select"){if(r){const c=((m=(u=this.context).getColor)==null?void 0:m.call(u,e.clientId))||"#80808080";try{t.api.addMultiuserSelection(String(e.clientId),String(e.nickName),c,r,!!o)}catch(l){console.error(l)}}}else if(i==="deselect")t.api.removeMultiuserSelections(String(e.nickName));else if(i==="orderingChange")t.api.updateOrdering(r);else if(i==="groupObjects")t.api.groupObjects(r);else if(i==="ungroupObjects")t.api.ungroupObjects(r);else if(i==="addToGroup")t.api.addToGroup(r,o);else if(i==="embeddedContentChanged")t.api.setEmbedContent(o,r);else if(i==="addGeoToTV")t.api.addGeoToTV(r);else if(i==="setValuesOfTV")t.api.setValuesOfTV(r);else if(i==="removeGeoFromTV")t.api.removeGeoFromTV(r);else if(i==="showPointsTV")t.api.showPointsTV(r,o);else if(i==="lockTextElement")t.api.lockTextElement(r);else if(i==="unlockTextElement")t.api.unlockTextElement(r);else if(i==="viewChanged2D")if(t.viewState.scale===0)t.api.evalCommand("Pan(0,0)"),t.startSyncViewState();else{const{scale:c,x:l,y:f}=JSON.parse(r),b=t._flushViewState();t.startSyncViewState(),t.api.evalCommand(`Pan(${l-b.x},${f-b.y})`),t.api.evalCommand(`ZoomIn(${c/b.scale})`)}else console.debug("[GeoGebra] unknown event",i,r,o)},this.api=n.api,this.clientId=n.clientId,this.nickName=n.nickName,this.delay=(a=n.delay)!=null?a:200,this.context=n,setTimeout(()=>{this.api.evalCommand("Pan(0,0)")},this.delay)}createEvent(n,a,e){const s={type:n,content:a,clientId:this.clientId,nickName:this.nickName};return this.context.embedLabel&&(s.embedLabel=this.context.embedLabel),e&&(s.label=e),s}sendEvent(n,a,e){console.log("[GeoGebra] send:",n,e,a),this.context.postMessage(this.createEvent(n,a,e)),this.storageCallback||(this.storageCallback=setTimeout(()=>{this.context.save(this.api.getBase64()),this.storageCallback=0},this.delay))}evalCommand(n){this.unregisterListeners(),this.api.evalCommand(n),this.registerListeners()}evalXML(n){this.unregisterListeners(),this.api.evalXML(n),this.api.updateConstruction(),this.registerListeners(),setTimeout(this.initAllEmbeds,500)}setXML(n){this.unregisterListeners(),this.api.setXML(n),this.api.updateConstruction(),this.registerListeners()}initEmbed(n){if(this.embeds[n])return;const a=this.api.getEmbeddedCalculators();if(!a)return;const e=a[n];if(e&&"registerClientListener"in e){const s=new S(D(C({},this.context),{clientId:this.clientId,nickName:this.nickName,api:e,embedLabel:n}));s.registerListeners(),this.embeds[n]=s}}startSyncViewState(){clearTimeout(this.isSyncingViewState),this.isSyncingViewState=setTimeout(this.stopSyncViewState,1e3)}shouldSyncView(n,a,e,s){return Math.abs(a-n.scale)>S.Threshold/10||Math.abs(e-n.x)>S.Threshold||Math.abs(s-n.y)>S.Threshold}registerListeners(){this.api.registerUpdateListener(this.updateListener),this.api.registerRemoveListener(this.removeListener),this.api.registerAddListener(this.addListener),this.api.registerClientListener(this.clientListener),this.api.registerRenameListener(this.renameListener)}unregisterListeners(){this.api.unregisterUpdateListener(this.updateListener),this.api.unregisterRemoveListener(this.removeListener),this.api.unregisterAddListener(this.addListener),this.api.unregisterClientListener(this.clientListener),this.api.unregisterRenameListener(this.renameListener)}};let O=S;O.Threshold=20;var F=(()=>`.netless-app-geogebra{width:100%!important;height:100%!important;overflow:hidden}.netless-app-geogebra.loading{background-color:#fff}.netless-app-geogebra.readonly{user-select:none;pointer-events:none}
`)();function J(n,a){const e=new ResizeObserver(()=>a(n));return e.observe(n),()=>e.disconnect()}function W(n,a,e){const s=n.getDisplayer(),t=n.getRoom();let i=[];const o=c=>{c.authorId!==s.observerId&&i.forEach(l=>l(c.payload))},r="sync--"+n.appId;return s.addMagixEventListener(r,o),{service:{addListener(c){i.push(c)},postMessage(c){t==null||t.dispatchMagixEvent(r,c)},load(){return a[e]},save(c){n.updateAttributes([e],c)}},disposer:()=>{i=[],s.removeMagixEventListener(r)}}}const $=new Set(["classic","graphing","geometry","3d","suite","evaluator","scientific"]),z={kind:"GeoGebra",async setup(n){var I;const a=n.getDisplayer(),e=a.observerId,s=(I=a.state.roomMembers.find(v=>v.memberId===e))==null?void 0:I.payload,t=(s==null?void 0:s.uid)||"",i=(s==null?void 0:s.nickName)||t,o=n.getAppOptions()||{},r=o.deployggb,u=o.HTML5Codebase,m=U(n,{uid:"",ggbBase64:"",appName:"classic"}),c=n.getBox();c.mountStyles(F);const l=document.createElement("div");l.classList.add("netless-app-geogebra","loading"),t!==m.uid&&m.uid&&l.classList.add("netless-app-geogebra","readonly"),c.mountContent(l);const f=new x,b=C({},P);$.has(m.appName)&&(b.appName=m.appName),b.language=navigator.language.startsWith("zh")?"zh":"en",m.ggbBase64&&(b.ggbBase64=m.ggbBase64),b.id="ggb_"+n.appId;let p;const k=W(n,m,"ggbBase64");function T(){const{width:v,height:w}=l.getBoundingClientRect();p==null||p.setWidth(v),p==null||p.setHeight(w)}b.appletOnLoad=v=>{console.log(`[GeoGebra]: loaded ${JSON.stringify(b.id)}`),p=v,T(),l.classList.remove("loading");const w=n.getDisplayer(),j=new O(C({clientId:w.observerId,nickName:i,api:v,isDecider:y=>w.state.roomMembers.map(E=>E.memberId).every(E=>y<=E),getColor:y=>{const N=w.memberState(y).strokeColor;return"#"+N.map(E=>E.toString(16).padStart(2,"0")).join("")+"80"}},k.service));j.registerListeners(),k.service.addListener(y=>{j.dispatch(y),p==null||p.setUndoPoint()})},f.add(()=>J(l,T)),n.emitter.on("destroy",()=>{console.log("[GeoGebra]: destroy"),f.flushAll(),k.disposer(),p==null||p.remove()});const H=await _({deployggb:r}),G=new H(b);u&&G.setHTML5Codebase(u),G.inject(l)}};return h.default=z,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),h}({});
//# sourceMappingURL=main.iife.js.map

@@ -162,4 +162,4 @@ /**

showTooltip(tooltip: boolean): void;
addMultiuserSelection(user: string, color: string, label: string, newGeo: boolean): void;
removeMultiuserSelections(user: string): void;
addMultiuserSelection(userId: string, userName: string, color: string, label: string, newGeo: boolean): void;
removeMultiuserSelections(userId: string): void;
getExerciseFraction(): number;

@@ -166,0 +166,0 @@ isExercise(): boolean;

{
"name": "@netless/app-geogebra",
"version": "0.0.8",
"version": "0.0.9",
"main": "dist/main.cjs.js",

@@ -14,4 +14,4 @@ "module": "dist/main.es.js",

"devDependencies": {
"@netless/app-shared": "0.1.2",
"side-effect-manager": "^1.1.0"
"side-effect-manager": "^1.1.0",
"@netless/app-shared": "0.1.2"
},

@@ -18,0 +18,0 @@ "scripts": {

@@ -551,3 +551,9 @@ import type { AppletObject, ClientEvent } from "../types";

try {
target.api.addMultiuserSelection(String(last.nickName), color, content, !!label);
target.api.addMultiuserSelection(
String(last.clientId),
String(last.nickName),
color,
content,
!!label
);
} catch (error) {

@@ -554,0 +560,0 @@ console.error(error);

@@ -152,4 +152,10 @@ /**

showTooltip(tooltip: boolean): void;
addMultiuserSelection(user: string, color: string, label: string, newGeo: boolean): void;
removeMultiuserSelections(user: string): void;
addMultiuserSelection(
userId: string,
userName: string,
color: string,
label: string,
newGeo: boolean
): void;
removeMultiuserSelections(userId: string): void;
getExerciseFraction(): number;

@@ -156,0 +162,0 @@ isExercise(): boolean;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc