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.4 to 0.0.5

dist/main.js

4

dist/main.iife.js

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

var W=Object.defineProperty,H=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var Z=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable;var N=(p,c,g)=>c in p?W(p,c,{enumerable:!0,configurable:!0,writable:!0,value:g}):p[c]=g,C=(p,c)=>{for(var g in c||(c={}))Z.call(c,g)&&N(p,g,c[g]);if(V)for(var g of V(c))K.call(c,g)&&N(p,g,c[g]);return p},X=(p,c)=>H(p,z(c));var NetlessAppGeoGebra=function(p){"use strict";const c="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",g=c.length,k=Array(20),v=()=>{for(let n=0;n<20;n++)k[n]=c.charAt(Math.random()*g);return k.join("")};class x{constructor(){this.disposers=new Map}add(r,e=v()){return this.flush(e),this.disposers.set(e,r()),e}addDisposer(r,e=v()){return this.flush(e),this.disposers.set(e,r),e}addEventListener(r,e,s,t,i=v()){return this.add(()=>(r.addEventListener(e,s,t),()=>r.removeEventListener(e,s,t)),i),i}setTimeout(r,e,s=v()){return this.add(()=>{const t=window.setTimeout(()=>{this.remove(s),r()},e);return()=>window.clearTimeout(t)},s)}setInterval(r,e,s=v()){return this.add(()=>{const t=window.setInterval(r,e);return()=>window.clearInterval(t)},s)}remove(r){const e=this.disposers.get(r);return this.disposers.delete(r),e}flush(r){const e=this.remove(r);if(e)try{e()}catch(s){console.error(s)}}flushAll(){this.disposers.forEach(r=>{try{r()}catch(e){console.error(e)}}),this.disposers.clear()}}function B(n){return n!=null&&typeof n=="object"&&!Array.isArray(n)}function R(n,r){let e=n.getAttributes();if(e||(n.setAttributes(r),e=n.getAttributes()),!e)throw new Error("[NetlessAppMonaco] No attributes");return B(r)&&Object.keys(r).forEach(s=>{Object.prototype.hasOwnProperty.call(e,s)||n.updateAttributes([s],r[s])}),e}let L;function D(n){if(window.GGBApplet)return Promise.resolve(window.GGBApplet);if(L)return L;{const r=document.createElement("script");if(L=new Promise((e,s)=>{r.onload=()=>e(window.GGBApplet),r.onerror=()=>{L=void 0,s()}}),n){const e=n.lastIndexOf("GeoGebra")+8;r.src=n.slice(0,e)+"/deployggb.js"}else r.src="https://www.geogebra.org/apps/deployggb.js";return document.head.appendChild(r),L}}const _={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 r;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?void 0:i.controller)&&this.sendEvent("evalGMContent",i.toJSON(),s);const o=this.api.getCommandString(s,!1);if(o){this.sendEvent("evalCommand",`${s} := ${o}`,s);const a=this.api.getObjectsOfItsGroup(s);(a==null?void 0:a.length)&&this.sendEvent("addToGroup",s,a)}if(!o||this.api.isMoveable(s)){const a=this.api.getXML(s);this.sendEvent("evalXML",a,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 a=this.api.getFileJSON();for(const u of a.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,a=-t/e,u=-i/s;return this.viewState={scale:o,x:a,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,a=e.content;if(console.debug("[GeoGebra] receive:",i,o,a),i==="addObject")if(t.api.exists(o))if(this.context.isDecider)if(this.context.isDecider(this.clientId)){let l=1,h;do h=`${o}_${l}`,l++;while(t.api.exists(h));this.unregisterListeners(),t.api.renameObject(o,h),this.registerListeners();const d=t.api.getAlgorithmXML(h)||t.api.getXML(h);this.sendEvent("conflictResolution",d,o)}else this.conflictedObjects.push(o);else t.evalXML(a),t.api.previewRefresh();else t.evalXML(a),t.api.previewRefresh();else if(i==="conflictResolution"){const l=this.conflictedObjects.indexOf(o);l!==-1&&this.conflictedObjects.splice(l,1),t.evalXML(a),t.api.previewRefresh()}else if(i==="evalXML")t.evalXML(a),t.api.previewRefresh();else if(i==="setXML")t.setXML(a);else if(i==="evalCommand")t.evalCommand(a),t.api.previewRefresh();else if(i==="deleteObject")t.unregisterListeners(),t===this&&delete this.embeds[a],t.api.deleteObject(a),t.registerListeners();else if(i==="setEditorState")t.unregisterListeners(),t.api.setEditorState(a,o),t.registerListeners();else if(i==="addImage"){const l=JSON.parse(a);t.api.addImage(l.fileName,l.fileContent)}else if(["addSlide","removeSlide","moveSlide","clearSlide"].includes(i))t.api.handleSlideAction(i,a);else if(i==="selectSlide")t.unregisterListeners(),t.api.selectSlide(a),t.registerListeners();else if(i==="renameObject")t.unregisterListeners(),t.api.renameObject(a,o),t.registerListeners();else if(i==="pasteSlide")t.api.handleSlideAction(i,a,o);else if(i==="evalGMContent"){const l=(t.api.getEmbeddedCalculators(!0)||{})[o];l&&l.loadFromJSON(a)}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(a){const l=((m=(u=this.context).getColor)==null?void 0:m.call(u,e.clientId))||"#80808080";t.api.addMultiuserSelection(String(e.nickName),l,a,!!o)}}else if(i==="deselect")t.api.removeMultiuserSelections(String(e.nickName));else if(i==="orderingChange")t.api.updateOrdering(a);else if(i==="groupObjects")t.api.groupObjects(a);else if(i==="ungroupObjects")t.api.ungroupObjects(a);else if(i==="addToGroup")t.api.addToGroup(a,o);else if(i==="embeddedContentChanged")t.api.setEmbedContent(o,a);else if(i==="addGeoToTV")t.api.addGeoToTV(a);else if(i==="setValuesOfTV")t.api.setValuesOfTV(a);else if(i==="removeGeoFromTV")t.api.removeGeoFromTV(a);else if(i==="showPointsTV")t.api.showPointsTV(a,o);else if(i==="lockTextElement")t.api.lockTextElement(a);else if(i==="unlockTextElement")t.api.unlockTextElement(a);else if(i==="viewChanged2D")if(t.viewState.scale===0)t.api.evalCommand("Pan(0,0)"),t.startSyncViewState();else{const{scale:l,x:h,y:d}=JSON.parse(a),b=t._flushViewState();t.startSyncViewState(),t.api.evalCommand(`Pan(${h-b.x},${d-b.y})`),t.api.evalCommand(`ZoomIn(${l/b.scale})`)}else console.debug("[GeoGebra] unknown event",i,a,o)},this.api=n.api,this.clientId=n.clientId,this.nickName=n.nickName,this.delay=(r=n.delay)!=null?r:200,this.context=n,setTimeout(()=>{this.api.evalCommand("Pan(0,0)")},this.delay)}createEvent(n,r,e){const s={type:n,content:r,clientId:this.clientId,nickName:this.nickName};return this.context.embedLabel&&(s.embedLabel=this.context.embedLabel),e&&(s.label=e),s}sendEvent(n,r,e){console.log("[GeoGebra] send:",n,e,r),this.context.postMessage(this.createEvent(n,r,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 r=this.api.getEmbeddedCalculators();if(!r)return;const e=r[n];if(e&&"registerClientListener"in e){const s=new S(X(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,r,e,s){return Math.abs(r-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 M=S;M.Threshold=20;var P=`.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 F(n,r){const e=new ResizeObserver(()=>r(n));return e.observe(n),()=>e.disconnect()}function J(n,r,e){const s=n.getDisplayer(),t=n.getRoom();let i=[];const o=l=>{l.authorId!==s.observerId&&i.forEach(h=>h(l.payload))},a="sync--"+n.appId;return s.addMagixEventListener(a,o),{service:{addListener(l){i.push(l)},postMessage(l){t==null||t.dispatchMagixEvent(a,l)},load(){return r[e]},save(l){n.updateAttributes([e],l)}},disposer:()=>{i=[],s.removeMagixEventListener(a)}}}const U={kind:"GeoGebra",async setup(n){var A,G;const r=n.getDisplayer(),e=r.observerId,s=(A=r.state.roomMembers.find(f=>f.memberId===e))==null?void 0:A.payload,t=(s==null?void 0:s.uid)||"",i=(s==null?void 0:s.nickName)||t,o=(G=n.getAppOptions())==null?void 0:G.HTML5Codebase,a=R(n,{uid:"",ggbBase64:""}),u=n.getBox();u.mountStyles(P);const m=document.createElement("div");m.classList.add("netless-app-geogebra","loading"),t!==a.uid&&a.uid&&m.classList.add("netless-app-geogebra","readonly"),u.mountContent(m);const l=new x,h=C({},_);a.ggbBase64&&(h.ggbBase64=a.ggbBase64),h.id="ggb_"+n.appId;let d;const b=J(n,a,"ggbBase64");function O(){const{width:f,height:w}=m.getBoundingClientRect();d==null||d.setWidth(f),d==null||d.setHeight(w)}h.appletOnLoad=f=>{console.log(`[GeoGebra]: loaded ${JSON.stringify(h.id)}`),d=f,O(),m.classList.remove("loading");const w=n.getDisplayer(),j=new M(C({clientId:w.observerId,nickName:i,api:f,isDecider:y=>w.state.roomMembers.map(E=>E.memberId).every(E=>y<=E),getColor:y=>{const I=w.memberState(y).strokeColor;return"#"+I.map(E=>E.toString(16).padStart(2,"0")).join("")+"80"}},b.service));j.registerListeners(),b.service.addListener(y=>{j.dispatch(y),d==null||d.setUndoPoint()})},l.add(()=>F(m,O)),n.emitter.on("destroy",()=>{console.log("[GeoGebra]: destroy"),l.flushAll(),b.disposer(),d==null||d.remove()});const $=await D(o),T=new $(h);o&&T.setHTML5Codebase(o),T.inject(m)}};return p.default=U,Object.defineProperty(p,"__esModule",{value:!0}),p[Symbol.toStringTag]="Module",p}({});
const NetlessAppGeoGebra=function(S){"use strict";const w="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",I=w.length,y=Array(20),j=()=>{for(let i=0;i<20;i++)y[i]=w.charAt(Math.random()*I);return y.join("")};function E(i){try{return i()}catch(a){console.error(a)}}class V{constructor(){this.disposers=new Map}addDisposer(a,e=this.genUID()){return this.flush(e),this.disposers.set(e,Array.isArray(a)?()=>a.forEach(E):a),e}add(a,e=this.genUID()){const s=a();return s?this.addDisposer(s,e):e}addEventListener(a,e,s,t,n=this.genUID()){return a.addEventListener(e,s,t),this.addDisposer(()=>a.removeEventListener(e,s,t),n),n}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(E),this.disposers.clear()}genUID(){let a;do a=j();while(this.disposers.has(a));return a}}function N(i){return i!=null&&typeof i=="object"&&!Array.isArray(i)}function X(i,a){let e=i.getAttributes();if(e||(i.setAttributes(a),e=i.getAttributes()),!e)throw new Error("[NetlessAppMonaco] No attributes");return N(a)&&Object.keys(a).forEach(s=>{Object.prototype.hasOwnProperty.call(e,s)||i.updateAttributes([s],a[s])}),e}let m;function D(i){if(window.GGBApplet)return Promise.resolve(window.GGBApplet);if(m)return m;{const a=document.createElement("script");if(m=new Promise((e,s)=>{a.onload=()=>e(window.GGBApplet),a.onerror=()=>{m=void 0,s()}}),i){const e=i.lastIndexOf("GeoGebra")+8;a.src=i.slice(0,e)+"/deployggb.js"}else a.src="https://www.geogebra.org/apps/deployggb.js";return document.head.appendChild(a),m}}const x={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"},b=class{constructor(i){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),n=t==null?void 0:t[s];n!=null&&n.controller&&this.sendEvent("evalGMContent",n.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:n}=JSON.parse(this.api.getViewProperties(0)),o=1/e,r=-t/e,h=-n/s;return this.viewState={scale:o,x:r,y:h},this.viewSyncCallback=0,this.viewState},this.clientListener=e=>{let s,t;const n=e.type;switch(n){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(n);break;case"removeSlide":case"moveSlide":case"selectSlide":case"clearSlide":case"orderingChange":t=e[2],this.sendEvent(n,t);break;case"pasteSlide":({cardIdx:t,ggbFile:s}=e),this.sendEvent(n,t,s);break;case"startAnimation":s=e[1],this.currentAnimations.push(s),this.sendEvent(n,s,s);break;case"stopAnimation":s=e[1],this.currentAnimations.splice(this.currentAnimations.indexOf(s),1),this.sendEvent(n,s,s);break;case"groupObjects":case"ungroupObjects":t=e.targets,this.sendEvent(n,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(n,t);break;case"setValuesOfTV":t=e[2],this.sendEvent(n,t);break;case"showPointsTV":({column:t,show:s}=e),this.sendEvent(n,t,s);break;case"lockTextElement":case"unlockTextElement":t=e[1],this.sendEvent(n,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,n=e.type,o=e.label,r=e.content;if(console.debug("[GeoGebra] receive:",n,o,r),n==="addObject")if(t.api.exists(o))if(this.context.isDecider)if(this.context.isDecider(this.clientId)){let l=1,c;do c=`${o}_${l}`,l++;while(t.api.exists(c));this.unregisterListeners(),t.api.renameObject(o,c),this.registerListeners();const d=t.api.getAlgorithmXML(c)||t.api.getXML(c);this.sendEvent("conflictResolution",d,o)}else this.conflictedObjects.push(o);else t.evalXML(r),t.api.previewRefresh();else t.evalXML(r),t.api.previewRefresh();else if(n==="conflictResolution"){const l=this.conflictedObjects.indexOf(o);l!==-1&&this.conflictedObjects.splice(l,1),t.evalXML(r),t.api.previewRefresh()}else if(n==="evalXML")t.evalXML(r),t.api.previewRefresh();else if(n==="setXML")t.setXML(r);else if(n==="evalCommand")t.evalCommand(r),t.api.previewRefresh();else if(n==="deleteObject")t.unregisterListeners(),t===this&&delete this.embeds[r],t.api.deleteObject(r),t.registerListeners();else if(n==="setEditorState")t.unregisterListeners(),t.api.setEditorState(r,o),t.registerListeners();else if(n==="addImage"){const l=JSON.parse(r);t.api.addImage(l.fileName,l.fileContent)}else if(["addSlide","removeSlide","moveSlide","clearSlide"].includes(n))t.api.handleSlideAction(n,r);else if(n==="selectSlide")t.unregisterListeners(),t.api.selectSlide(r),t.registerListeners();else if(n==="renameObject")t.unregisterListeners(),t.api.renameObject(r,o),t.registerListeners();else if(n==="pasteSlide")t.api.handleSlideAction(n,r,o);else if(n==="evalGMContent"){const l=(t.api.getEmbeddedCalculators(!0)||{})[o];l&&l.loadFromJSON(r)}else if(n==="startAnimation")t.api.setAnimating(o,!0),t.api.startAnimation();else if(n==="stopAnimation")t.api.setAnimating(o,!1);else if(n==="select"){if(r){const l=((p=(h=this.context).getColor)==null?void 0:p.call(h,e.clientId))||"#80808080";t.api.addMultiuserSelection(String(e.nickName),l,r,!!o)}}else if(n==="deselect")t.api.removeMultiuserSelections(String(e.nickName));else if(n==="orderingChange")t.api.updateOrdering(r);else if(n==="groupObjects")t.api.groupObjects(r);else if(n==="ungroupObjects")t.api.ungroupObjects(r);else if(n==="addToGroup")t.api.addToGroup(r,o);else if(n==="embeddedContentChanged")t.api.setEmbedContent(o,r);else if(n==="addGeoToTV")t.api.addGeoToTV(r);else if(n==="setValuesOfTV")t.api.setValuesOfTV(r);else if(n==="removeGeoFromTV")t.api.removeGeoFromTV(r);else if(n==="showPointsTV")t.api.showPointsTV(r,o);else if(n==="lockTextElement")t.api.lockTextElement(r);else if(n==="unlockTextElement")t.api.unlockTextElement(r);else if(n==="viewChanged2D")if(t.viewState.scale===0)t.api.evalCommand("Pan(0,0)"),t.startSyncViewState();else{const{scale:l,x:c,y:d}=JSON.parse(r),g=t._flushViewState();t.startSyncViewState(),t.api.evalCommand(`Pan(${c-g.x},${d-g.y})`),t.api.evalCommand(`ZoomIn(${l/g.scale})`)}else console.debug("[GeoGebra] unknown event",n,r,o)},this.api=i.api,this.clientId=i.clientId,this.nickName=i.nickName,this.delay=(a=i.delay)!=null?a:200,this.context=i,setTimeout(()=>{this.api.evalCommand("Pan(0,0)")},this.delay)}createEvent(i,a,e){const s={type:i,content:a,clientId:this.clientId,nickName:this.nickName};return this.context.embedLabel&&(s.embedLabel=this.context.embedLabel),e&&(s.label=e),s}sendEvent(i,a,e){console.log("[GeoGebra] send:",i,e,a),this.context.postMessage(this.createEvent(i,a,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 a=this.api.getEmbeddedCalculators();if(!a)return;const e=a[i];if(e&&"registerClientListener"in e){const s=new b({...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,a,e,s){return Math.abs(a-i.scale)>b.Threshold/10||Math.abs(e-i.x)>b.Threshold||Math.abs(s-i.y)>b.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 C=b;C.Threshold=20;const B=`.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 R(i,a){const e=new ResizeObserver(()=>a(i));return e.observe(i),()=>e.disconnect()}function U(i,a,e){const s=i.displayer,t=i.room;let n=[];const o=l=>{l.authorId!==s.observerId&&n.forEach(c=>c(l.payload))},r="sync--"+i.appId;return s.addMagixEventListener(r,o),{service:{addListener(l){n.push(l)},postMessage(l){t==null||t.dispatchMagixEvent(r,l)},load(){return a[e]},save(l){i.updateAttributes([e],l)}},disposer:()=>{n=[],s.removeMagixEventListener(r)}}}const _={kind:"GeoGebra",config:{enableShadowDOM:!1},async setup(i){var O,A;const a=i.displayer,e=a.observerId,s=(O=a.state.roomMembers.find(u=>u.memberId===e))==null?void 0:O.payload,t=(s==null?void 0:s.uid)||"",n=(s==null?void 0:s.nickName)||t,o=(A=i.getAppOptions())==null?void 0:A.HTML5Codebase,r=X(i,{uid:"",ggbBase64:""}),h=i.box;h.mountStyles(B);const p=document.createElement("div");p.classList.add("netless-app-geogebra","loading"),t!==r.uid&&r.uid&&p.classList.add("netless-app-geogebra","readonly"),h.mountContent(p);const l=new V,c={...x};c.language=navigator.language.startsWith("zh")?"zh":"en",r.ggbBase64&&(c.ggbBase64=r.ggbBase64),c.id="ggb_"+i.appId;let d;const g=U(i,r,"ggbBase64");function k(){const{width:u,height:f}=p.getBoundingClientRect();d==null||d.setWidth(u),d==null||d.setHeight(f)}c.appletOnLoad=u=>{console.log(`[GeoGebra]: loaded ${JSON.stringify(c.id)}`),d=u,k(),p.classList.remove("loading");const f=i.displayer,T=new C({clientId:f.observerId,nickName:n,api:u,isDecider:v=>f.state.roomMembers.map(L=>L.memberId).every(L=>v<=L),getColor:v=>{const G=f.memberState(v).strokeColor;return"#"+G.map(L=>L.toString(16).padStart(2,"0")).join("")+"80"},...g.service});T.registerListeners(),g.service.addListener(v=>{T.dispatch(v),d==null||d.setUndoPoint()})},l.add(()=>R(p,k)),i.emitter.on("destroy",()=>{console.log("[GeoGebra]: destroy"),l.flushAll(),g.disposer(),d==null||d.remove()});const P=await D(o),M=new P(c);o&&M.setHTML5Codebase(o),M.inject(p)}};return S.default=_,Object.defineProperties(S,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),S}({});
//# sourceMappingURL=main.iife.js.map
{
"name": "@netless/app-geogebra",
"version": "0.0.4",
"main": "dist/main.cjs.js",
"module": "dist/main.es.js",
"version": "0.0.5",
"main": "dist/main.js",
"module": "dist/main.mjs",
"unpkg": "dist/main.iife.js",

@@ -15,3 +15,3 @@ "jsdelivr": "dist/main.iife.js",

"@netless/app-shared": "0.1.2",
"side-effect-manager": "^0.1.5"
"side-effect-manager": "^1.1.1"
},

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

@@ -41,4 +41,7 @@ import { ensureAttributes } from "@netless/app-shared";

kind: "GeoGebra",
config: {
enableShadowDOM: false,
},
async setup(context) {
const displayer = context.getDisplayer();
const displayer = context.displayer;
const memberId = displayer.observerId;

@@ -58,3 +61,3 @@ const userPayload: UserPayload | undefined = displayer.state.roomMembers.find(

const box = context.getBox();
const box = context.box;
box.mountStyles(styles);

@@ -72,2 +75,3 @@

const params: GGBAppletParameters = { ...defaultParameters };
params.language = navigator.language.startsWith("zh") ? "zh" : "en";
if (attrs.ggbBase64) {

@@ -95,3 +99,3 @@ params.ggbBase64 = attrs.ggbBase64;

const displayer = context.getDisplayer();
const displayer = context.displayer;
const liveApp = new LiveApp({

@@ -98,0 +102,0 @@ clientId: displayer.observerId,

@@ -23,4 +23,4 @@ import type { Event } from "white-web-sdk";

} {
const displayer = context.getDisplayer();
const room = context.getRoom();
const displayer = context.displayer;
const room = context.room;

@@ -27,0 +27,0 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any

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