@netless/app-geogebra
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -7,3 +7,3 @@ import type { GGBApplet, GGBAppletParameters } from "../types"; | ||
} | ||
export default function getGGBApplet(): Promise<typeof GGBApplet>; | ||
export default function getGGBApplet(codebase?: string): Promise<typeof GGBApplet>; | ||
export declare const defaultParameters: GGBAppletParameters; |
@@ -11,4 +11,8 @@ import type { NetlessApp } from "@netless/window-manager"; | ||
* https://www.geogebra.org/license | ||
* | ||
* KNOWN ISSUE: The GeoGebra sync is based on sending & receiving data about | ||
* partial info of the full picture, this can cause errors because of the order | ||
* of executing them. | ||
*/ | ||
declare const GeoGebra: NetlessApp<Attributes>; | ||
export default GeoGebra; |
@@ -1,3 +0,3 @@ | ||
"use strict";var T=Object.defineProperty,I=Object.defineProperties;var A=Object.getOwnPropertyDescriptors;var C=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var k=(i,a,e)=>a in i?T(i,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[a]=e,S=(i,a)=>{for(var e in a||(a={}))j.call(a,e)&&k(i,e,a[e]);if(C)for(var e of C(a))V.call(a,e)&&k(i,e,a[e]);return i},M=(i,a)=>I(i,A(a));Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";class N{constructor(){this.disposers=new Map,this.disposerIDGenCount=-1}add(a,e=this.genDisposerID()){return this.flush(e),this.disposers.set(e,a()),e}addEventListener(a,e,s,t,n=this.genDisposerID()){return this.add(()=>(a.addEventListener(e,s,t),()=>a.removeEventListener(e,s,t)),n),n}setTimeout(a,e,s=this.genDisposerID()){return this.add(()=>{const t=window.setTimeout(()=>{this.remove(s),a()},e);return()=>window.clearTimeout(t)},s)}setInterval(a,e,s=this.genDisposerID()){return this.add(()=>{const t=window.setInterval(a,e);return()=>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=>{try{a()}catch(e){console.error(e)}}),this.disposers.clear()}genDisposerID(){const{MAX_SAFE_INTEGER:a=9007199254740991}=Number;return this.disposerIDGenCount=(this.disposerIDGenCount+1)%a,`disposer-${this.disposerIDGenCount}`}}function D(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 D(a)&&Object.keys(a).forEach(s=>{Object.prototype.hasOwnProperty.call(e,s)||i.updateAttributes([s],a[s])}),e}let v;function x(){if(window.GGBApplet)return Promise.resolve(window.GGBApplet);if(v)return v;{const i=document.createElement("script");return v=new Promise((a,e)=>{i.onload=()=>a(window.GGBApplet),i.onerror=()=>{v=void 0,e()}}),i.src="https://www.geogebra.org/apps/deployggb.js",document.head.appendChild(i),v}}const B={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"},L=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?void 0: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?void 0: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 l of r.archive)l.fileName.includes(s)&&this.sendEvent("addImage",JSON.stringify(l))}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,l=-n/s;return this.viewState={scale:o,x:r,y:l},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 l,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 d=1,c;do c=`${o}_${d}`,d++;while(t.api.exists(c));this.unregisterListeners(),t.api.renameObject(o,c),this.registerListeners();const h=t.api.getAlgorithmXML(c)||t.api.getXML(c);this.sendEvent("conflictResolution",h,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 d=this.conflictedObjects.indexOf(o);d!==-1&&this.conflictedObjects.splice(d,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 d=JSON.parse(r);t.api.addImage(d.fileName,d.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 d=(t.api.getEmbeddedCalculators(!0)||{})[o];d&&d.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 d=((p=(l=this.context).getColor)==null?void 0:p.call(l,e.clientId))||"#80808080";t.api.addMultiuserSelection(String(e.nickName),d,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:d,x:c,y:h}=JSON.parse(r),g=t._flushViewState();t.startSyncViewState(),t.api.evalCommand(`Pan(${c-g.x},${h-g.y})`),t.api.evalCommand(`ZoomIn(${d/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 L(M(S({},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)>L.Threshold/10||Math.abs(e-i.x)>L.Threshold||Math.abs(s-i.y)>L.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 G=L;G.Threshold=20;var R=`.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 _(i,a){const e=new ResizeObserver(()=>a(i));return e.observe(i),()=>e.disconnect()}function P(i,a,e){const s=i.getDisplayer(),t=i.getRoom();let n=[];const o=d=>{d.authorId!==s.observerId&&n.forEach(c=>c(d.payload))},r="sync--"+i.appId;return s.addMagixEventListener(r,o),{service:{addListener(d){n.push(d)},postMessage(d){t==null||t.dispatchMagixEvent(r,d)},load(){return a[e]},save(d){i.updateAttributes([e],d)}},disposer:()=>{n=[],s.removeMagixEventListener(r)}}}const F={kind:"GeoGebra",async setup(i){var w;const a=i.getDisplayer(),e=a.observerId,s=(w=a.state.roomMembers.find(u=>u.memberId===e))==null?void 0:w.payload,t=(s==null?void 0:s.uid)||"",n=(s==null?void 0:s.nickName)||t,o=X(i,{uid:"",ggbBase64:""}),r=i.getBox();r.mountStyles(R);const l=document.createElement("div");l.classList.add("netless-app-geogebra","loading"),t!==o.uid&&o.uid&&l.classList.add("netless-app-geogebra","readonly"),r.mountContent(l);const p=new N,d=S({},B);o.ggbBase64&&(d.ggbBase64=o.ggbBase64),d.id="ggb_"+i.appId;let c;const h=P(i,o,"ggbBase64");function g(){const{width:u,height:m}=l.getBoundingClientRect();c==null||c.setWidth(u),c==null||c.setHeight(m)}d.appletOnLoad=u=>{console.log(`[GeoGebra]: loaded ${JSON.stringify(d.id)}`),c=u,g(),l.classList.remove("loading");const m=i.getDisplayer(),E=new G(S({clientId:m.observerId,nickName:n,api:u,isDecider:b=>m.state.roomMembers.map(f=>f.memberId).every(f=>b<=f),getColor:b=>{const y=m.memberState(b).strokeColor;return"#"+y.map(f=>f.toString(16).padStart(2,"0")).join("")+"80"}},h.service));E.registerListeners(),h.service.addListener(b=>{E.dispatch(b),c==null||c.setUndoPoint()})},p.add(()=>_(l,g)),i.emitter.on("destroy",()=>{console.log("[GeoGebra]: destroy"),p.flushAll(),h.disposer(),c==null||c.remove()});const O=await x();new O(d).inject(l)}};exports.default=F; | ||
"use strict";var j=Object.defineProperty,V=Object.defineProperties;var N=Object.getOwnPropertyDescriptors;var G=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable;var O=(i,a,e)=>a in i?j(i,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[a]=e,S=(i,a)=>{for(var e in a||(a={}))D.call(a,e)&&O(i,e,a[e]);if(G)for(var e of G(a))X.call(a,e)&&O(i,e,a[e]);return i},T=(i,a)=>V(i,N(a));Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";class x{constructor(){this.disposers=new Map,this.disposerIDGenCount=-1}add(a,e=this.genDisposerID()){return this.flush(e),this.disposers.set(e,a()),e}addEventListener(a,e,s,t,n=this.genDisposerID()){return this.add(()=>(a.addEventListener(e,s,t),()=>a.removeEventListener(e,s,t)),n),n}setTimeout(a,e,s=this.genDisposerID()){return this.add(()=>{const t=window.setTimeout(()=>{this.remove(s),a()},e);return()=>window.clearTimeout(t)},s)}setInterval(a,e,s=this.genDisposerID()){return this.add(()=>{const t=window.setInterval(a,e);return()=>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=>{try{a()}catch(e){console.error(e)}}),this.disposers.clear()}genDisposerID(){const{MAX_SAFE_INTEGER:a=9007199254740991}=Number;return this.disposerIDGenCount=(this.disposerIDGenCount+1)%a,`disposer-${this.disposerIDGenCount}`}}function B(i){return i!=null&&typeof i=="object"&&!Array.isArray(i)}function R(i,a){let e=i.getAttributes();if(e||(i.setAttributes(a),e=i.getAttributes()),!e)throw new Error("[NetlessAppMonaco] No attributes");return B(a)&&Object.keys(a).forEach(s=>{Object.prototype.hasOwnProperty.call(e,s)||i.updateAttributes([s],a[s])}),e}let v;function _(i){if(window.GGBApplet)return Promise.resolve(window.GGBApplet);if(v)return v;{const a=document.createElement("script");if(v=new Promise((e,s)=>{a.onload=()=>e(window.GGBApplet),a.onerror=()=>{v=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),v}}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"},L=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?void 0: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?void 0: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 d=1,c;do c=`${o}_${d}`,d++;while(t.api.exists(c));this.unregisterListeners(),t.api.renameObject(o,c),this.registerListeners();const l=t.api.getAlgorithmXML(c)||t.api.getXML(c);this.sendEvent("conflictResolution",l,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 d=this.conflictedObjects.indexOf(o);d!==-1&&this.conflictedObjects.splice(d,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 d=JSON.parse(r);t.api.addImage(d.fileName,d.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 d=(t.api.getEmbeddedCalculators(!0)||{})[o];d&&d.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 d=((p=(h=this.context).getColor)==null?void 0:p.call(h,e.clientId))||"#80808080";t.api.addMultiuserSelection(String(e.nickName),d,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:d,x:c,y:l}=JSON.parse(r),g=t._flushViewState();t.startSyncViewState(),t.api.evalCommand(`Pan(${c-g.x},${l-g.y})`),t.api.evalCommand(`ZoomIn(${d/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 L(T(S({},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)>L.Threshold/10||Math.abs(e-i.x)>L.Threshold||Math.abs(s-i.y)>L.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 I=L;I.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(i,a){const e=new ResizeObserver(()=>a(i));return e.observe(i),()=>e.disconnect()}function $(i,a,e){const s=i.getDisplayer(),t=i.getRoom();let n=[];const o=d=>{d.authorId!==s.observerId&&n.forEach(c=>c(d.payload))},r="sync--"+i.appId;return s.addMagixEventListener(r,o),{service:{addListener(d){n.push(d)},postMessage(d){t==null||t.dispatchMagixEvent(r,d)},load(){return a[e]},save(d){i.updateAttributes([e],d)}},disposer:()=>{n=[],s.removeMagixEventListener(r)}}}const U={kind:"GeoGebra",async setup(i){var y,C;const a=i.getDisplayer(),e=a.observerId,s=(y=a.state.roomMembers.find(u=>u.memberId===e))==null?void 0:y.payload,t=(s==null?void 0:s.uid)||"",n=(s==null?void 0:s.nickName)||t,o=(C=i.getAppOptions())==null?void 0:C.HTML5Codebase,r=R(i,{uid:"",ggbBase64:""}),h=i.getBox();h.mountStyles(F);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 d=new x,c=S({},P);r.ggbBase64&&(c.ggbBase64=r.ggbBase64),c.id="ggb_"+i.appId;let l;const g=$(i,r,"ggbBase64");function w(){const{width:u,height:m}=p.getBoundingClientRect();l==null||l.setWidth(u),l==null||l.setHeight(m)}c.appletOnLoad=u=>{console.log(`[GeoGebra]: loaded ${JSON.stringify(c.id)}`),l=u,w(),p.classList.remove("loading");const m=i.getDisplayer(),k=new I(S({clientId:m.observerId,nickName:n,api:u,isDecider:b=>m.state.roomMembers.map(f=>f.memberId).every(f=>b<=f),getColor:b=>{const M=m.memberState(b).strokeColor;return"#"+M.map(f=>f.toString(16).padStart(2,"0")).join("")+"80"}},g.service));k.registerListeners(),g.service.addListener(b=>{k.dispatch(b),l==null||l.setUndoPoint()})},d.add(()=>J(p,w)),i.emitter.on("destroy",()=>{console.log("[GeoGebra]: destroy"),d.flushAll(),g.disposer(),l==null||l.remove()});const A=await _(o),E=new A(c);o&&E.setHTML5Codebase(o),E.inject(p)}};exports.default=U; | ||
//# sourceMappingURL=main.cjs.js.map |
@@ -93,3 +93,3 @@ var __defProp = Object.defineProperty; | ||
let getGGBAppletPromise; | ||
function getGGBApplet() { | ||
function getGGBApplet(codebase) { | ||
if (window.GGBApplet) { | ||
@@ -108,3 +108,8 @@ return Promise.resolve(window.GGBApplet); | ||
}); | ||
script.src = "https://www.geogebra.org/apps/deployggb.js"; | ||
if (codebase) { | ||
const index = codebase.lastIndexOf("GeoGebra") + 8; | ||
script.src = codebase.slice(0, index) + "/deployggb.js"; | ||
} else { | ||
script.src = "https://www.geogebra.org/apps/deployggb.js"; | ||
} | ||
document.head.appendChild(script); | ||
@@ -596,3 +601,3 @@ return getGGBAppletPromise; | ||
async setup(context) { | ||
var _a; | ||
var _a, _b; | ||
const displayer = context.getDisplayer(); | ||
@@ -603,2 +608,3 @@ const memberId = displayer.observerId; | ||
const nickName = (userPayload == null ? void 0 : userPayload.nickName) || uid; | ||
const codebase = (_b = context.getAppOptions()) == null ? void 0 : _b.HTML5Codebase; | ||
const attrs = ensureAttributes(context, { | ||
@@ -661,4 +667,7 @@ uid: "", | ||
}); | ||
const GGBApplet = await getGGBApplet(); | ||
const GGBApplet = await getGGBApplet(codebase); | ||
const applet = new GGBApplet(params); | ||
if (codebase) { | ||
applet.setHTML5Codebase(codebase); | ||
} | ||
applet.inject(content); | ||
@@ -665,0 +674,0 @@ } |
@@ -1,3 +0,3 @@ | ||
(()=>{var x=Object.defineProperty,_=Object.defineProperties;var P=Object.getOwnPropertyDescriptors;var O=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable;var T=(h,p,g)=>p in h?x(h,p,{enumerable:!0,configurable:!0,writable:!0,value:g}):h[p]=g,y=(h,p)=>{for(var g in p||(p={}))F.call(p,g)&&T(h,g,p[g]);if(O)for(var g of O(p))J.call(p,g)&&T(h,g,p[g]);return h},I=(h,p)=>_(h,P(p));var W=function(h){"use strict";class p{constructor(){this.disposers=new Map,this.disposerIDGenCount=-1}add(r,t=this.genDisposerID()){return this.flush(t),this.disposers.set(t,r()),t}addEventListener(r,t,s,e,i=this.genDisposerID()){return this.add(()=>(r.addEventListener(t,s,e),()=>r.removeEventListener(t,s,e)),i),i}setTimeout(r,t,s=this.genDisposerID()){return this.add(()=>{const e=window.setTimeout(()=>{this.remove(s),r()},t);return()=>window.clearTimeout(e)},s)}setInterval(r,t,s=this.genDisposerID()){return this.add(()=>{const e=window.setInterval(r,t);return()=>window.clearInterval(e)},s)}remove(r){const t=this.disposers.get(r);return this.disposers.delete(r),t}flush(r){const t=this.remove(r);if(t)try{t()}catch(s){console.error(s)}}flushAll(){this.disposers.forEach(r=>{try{r()}catch(t){console.error(t)}}),this.disposers.clear()}genDisposerID(){const{MAX_SAFE_INTEGER:r=9007199254740991}=Number;return this.disposerIDGenCount=(this.disposerIDGenCount+1)%r,`disposer-${this.disposerIDGenCount}`}}function g(n){return n!=null&&typeof n=="object"&&!Array.isArray(n)}function A(n,r){let t=n.getAttributes();if(t||(n.setAttributes(r),t=n.getAttributes()),!t)throw new Error("[NetlessAppMonaco] No attributes");return g(r)&&Object.keys(r).forEach(s=>{Object.prototype.hasOwnProperty.call(t,s)||n.updateAttributes([s],r[s])}),t}let v;function j(){if(window.GGBApplet)return Promise.resolve(window.GGBApplet);if(v)return v;{const n=document.createElement("script");return v=new Promise((r,t)=>{n.onload=()=>r(window.GGBApplet),n.onerror=()=>{v=void 0,t()}}),n.src="https://www.geogebra.org/apps/deployggb.js",document.head.appendChild(n),v}}const V={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"},L=class{constructor(n){var r;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?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=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 a=this.api.getFileJSON();for(const l of a.archive)l.fileName.includes(s)&&this.sendEvent("addImage",JSON.stringify(l))}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,a=-e/t,l=-i/s;return this.viewState={scale:o,x:a,y:l},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 l,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,a=t.content;if(console.debug("[GeoGebra] receive:",i,o,a),i==="addObject")if(e.api.exists(o))if(this.context.isDecider)if(this.context.isDecider(this.clientId)){let d=1,c;do c=`${o}_${d}`,d++;while(e.api.exists(c));this.unregisterListeners(),e.api.renameObject(o,c),this.registerListeners();const u=e.api.getAlgorithmXML(c)||e.api.getXML(c);this.sendEvent("conflictResolution",u,o)}else this.conflictedObjects.push(o);else e.evalXML(a),e.api.previewRefresh();else e.evalXML(a),e.api.previewRefresh();else if(i==="conflictResolution"){const d=this.conflictedObjects.indexOf(o);d!==-1&&this.conflictedObjects.splice(d,1),e.evalXML(a),e.api.previewRefresh()}else if(i==="evalXML")e.evalXML(a),e.api.previewRefresh();else if(i==="setXML")e.setXML(a);else if(i==="evalCommand")e.evalCommand(a),e.api.previewRefresh();else if(i==="deleteObject")e.unregisterListeners(),e===this&&delete this.embeds[a],e.api.deleteObject(a),e.registerListeners();else if(i==="setEditorState")e.unregisterListeners(),e.api.setEditorState(a,o),e.registerListeners();else if(i==="addImage"){const d=JSON.parse(a);e.api.addImage(d.fileName,d.fileContent)}else if(["addSlide","removeSlide","moveSlide","clearSlide"].includes(i))e.api.handleSlideAction(i,a);else if(i==="selectSlide")e.unregisterListeners(),e.api.selectSlide(a),e.registerListeners();else if(i==="renameObject")e.unregisterListeners(),e.api.renameObject(a,o),e.registerListeners();else if(i==="pasteSlide")e.api.handleSlideAction(i,a,o);else if(i==="evalGMContent"){const d=(e.api.getEmbeddedCalculators(!0)||{})[o];d&&d.loadFromJSON(a)}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(a){const d=((m=(l=this.context).getColor)==null?void 0:m.call(l,t.clientId))||"#80808080";e.api.addMultiuserSelection(String(t.nickName),d,a,!!o)}}else if(i==="deselect")e.api.removeMultiuserSelections(String(t.nickName));else if(i==="orderingChange")e.api.updateOrdering(a);else if(i==="groupObjects")e.api.groupObjects(a);else if(i==="ungroupObjects")e.api.ungroupObjects(a);else if(i==="addToGroup")e.api.addToGroup(a,o);else if(i==="embeddedContentChanged")e.api.setEmbedContent(o,a);else if(i==="addGeoToTV")e.api.addGeoToTV(a);else if(i==="setValuesOfTV")e.api.setValuesOfTV(a);else if(i==="removeGeoFromTV")e.api.removeGeoFromTV(a);else if(i==="showPointsTV")e.api.showPointsTV(a,o);else if(i==="lockTextElement")e.api.lockTextElement(a);else if(i==="unlockTextElement")e.api.unlockTextElement(a);else if(i==="viewChanged2D")if(e.viewState.scale===0)e.api.evalCommand("Pan(0,0)"),e.startSyncViewState();else{const{scale:d,x:c,y:u}=JSON.parse(a),b=e._flushViewState();e.startSyncViewState(),e.api.evalCommand(`Pan(${c-b.x},${u-b.y})`),e.api.evalCommand(`ZoomIn(${d/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,t){const s={type:n,content:r,clientId:this.clientId,nickName:this.nickName};return this.context.embedLabel&&(s.embedLabel=this.context.embedLabel),t&&(s.label=t),s}sendEvent(n,r,t){console.log("[GeoGebra] send:",n,t,r),this.context.postMessage(this.createEvent(n,r,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 r=this.api.getEmbeddedCalculators();if(!r)return;const t=r[n];if(t&&"registerClientListener"in t){const s=new L(I(y({},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,r,t,s){return Math.abs(r-n.scale)>L.Threshold/10||Math.abs(t-n.x)>L.Threshold||Math.abs(s-n.y)>L.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=L;C.Threshold=20;var N=`.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 D(n,r){const t=new ResizeObserver(()=>r(n));return t.observe(n),()=>t.disconnect()}function X(n,r,t){const s=n.getDisplayer(),e=n.getRoom();let i=[];const o=d=>{d.authorId!==s.observerId&&i.forEach(c=>c(d.payload))},a="sync--"+n.appId;return s.addMagixEventListener(a,o),{service:{addListener(d){i.push(d)},postMessage(d){e==null||e.dispatchMagixEvent(a,d)},load(){return r[t]},save(d){n.updateAttributes([t],d)}},disposer:()=>{i=[],s.removeMagixEventListener(a)}}}const B={kind:"GeoGebra",async setup(n){var k;const r=n.getDisplayer(),t=r.observerId,s=(k=r.state.roomMembers.find(f=>f.memberId===t))==null?void 0:k.payload,e=(s==null?void 0:s.uid)||"",i=(s==null?void 0:s.nickName)||e,o=A(n,{uid:"",ggbBase64:""}),a=n.getBox();a.mountStyles(N);const l=document.createElement("div");l.classList.add("netless-app-geogebra","loading"),e!==o.uid&&o.uid&&l.classList.add("netless-app-geogebra","readonly"),a.mountContent(l);const m=new p,d=y({},V);o.ggbBase64&&(d.ggbBase64=o.ggbBase64),d.id="ggb_"+n.appId;let c;const u=X(n,o,"ggbBase64");function b(){const{width:f,height:S}=l.getBoundingClientRect();c==null||c.setWidth(f),c==null||c.setHeight(S)}d.appletOnLoad=f=>{console.log(`[GeoGebra]: loaded ${JSON.stringify(d.id)}`),c=f,b(),l.classList.remove("loading");const S=n.getDisplayer(),M=new C(y({clientId:S.observerId,nickName:i,api:f,isDecider:w=>S.state.roomMembers.map(E=>E.memberId).every(E=>w<=E),getColor:w=>{const G=S.memberState(w).strokeColor;return"#"+G.map(E=>E.toString(16).padStart(2,"0")).join("")+"80"}},u.service));M.registerListeners(),u.service.addListener(w=>{M.dispatch(w),c==null||c.setUndoPoint()})},m.add(()=>D(l,b)),n.emitter.on("destroy",()=>{console.log("[GeoGebra]: destroy"),m.flushAll(),u.disposer(),c==null||c.remove()});const R=await j();new R(d).inject(l)}};return h.default=B,Object.defineProperty(h,"__esModule",{value:!0}),h[Symbol.toStringTag]="Module",h}({});})(); | ||
(()=>{var F=Object.defineProperty,J=Object.defineProperties;var $=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable;var j=(h,p,g)=>p in h?F(h,p,{enumerable:!0,configurable:!0,writable:!0,value:g}):h[p]=g,y=(h,p)=>{for(var g in p||(p={}))U.call(p,g)&&j(h,g,p[g]);if(A)for(var g of A(p))W.call(p,g)&&j(h,g,p[g]);return h},V=(h,p)=>J(h,$(p));var z=function(h){"use strict";class p{constructor(){this.disposers=new Map,this.disposerIDGenCount=-1}add(r,e=this.genDisposerID()){return this.flush(e),this.disposers.set(e,r()),e}addEventListener(r,e,s,t,i=this.genDisposerID()){return this.add(()=>(r.addEventListener(e,s,t),()=>r.removeEventListener(e,s,t)),i),i}setTimeout(r,e,s=this.genDisposerID()){return this.add(()=>{const t=window.setTimeout(()=>{this.remove(s),r()},e);return()=>window.clearTimeout(t)},s)}setInterval(r,e,s=this.genDisposerID()){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()}genDisposerID(){const{MAX_SAFE_INTEGER:r=9007199254740991}=Number;return this.disposerIDGenCount=(this.disposerIDGenCount+1)%r,`disposer-${this.disposerIDGenCount}`}}function g(n){return n!=null&&typeof n=="object"&&!Array.isArray(n)}function N(n,r){let e=n.getAttributes();if(e||(n.setAttributes(r),e=n.getAttributes()),!e)throw new Error("[NetlessAppMonaco] No attributes");return g(r)&&Object.keys(r).forEach(s=>{Object.prototype.hasOwnProperty.call(e,s)||n.updateAttributes([s],r[s])}),e}let v;function D(n){if(window.GGBApplet)return Promise.resolve(window.GGBApplet);if(v)return v;{const r=document.createElement("script");if(v=new Promise((e,s)=>{r.onload=()=>e(window.GGBApplet),r.onerror=()=>{v=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),v}}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"},L=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 d=1,c;do c=`${o}_${d}`,d++;while(t.api.exists(c));this.unregisterListeners(),t.api.renameObject(o,c),this.registerListeners();const l=t.api.getAlgorithmXML(c)||t.api.getXML(c);this.sendEvent("conflictResolution",l,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 d=this.conflictedObjects.indexOf(o);d!==-1&&this.conflictedObjects.splice(d,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 d=JSON.parse(a);t.api.addImage(d.fileName,d.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 d=(t.api.getEmbeddedCalculators(!0)||{})[o];d&&d.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 d=((m=(u=this.context).getColor)==null?void 0:m.call(u,e.clientId))||"#80808080";t.api.addMultiuserSelection(String(e.nickName),d,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:d,x:c,y:l}=JSON.parse(a),b=t._flushViewState();t.startSyncViewState(),t.api.evalCommand(`Pan(${c-b.x},${l-b.y})`),t.api.evalCommand(`ZoomIn(${d/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 L(V(y({},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)>L.Threshold/10||Math.abs(e-n.x)>L.Threshold||Math.abs(s-n.y)>L.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=L;C.Threshold=20;var x=`.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 B(n,r){const e=new ResizeObserver(()=>r(n));return e.observe(n),()=>e.disconnect()}function R(n,r,e){const s=n.getDisplayer(),t=n.getRoom();let i=[];const o=d=>{d.authorId!==s.observerId&&i.forEach(c=>c(d.payload))},a="sync--"+n.appId;return s.addMagixEventListener(a,o),{service:{addListener(d){i.push(d)},postMessage(d){t==null||t.dispatchMagixEvent(a,d)},load(){return r[e]},save(d){n.updateAttributes([e],d)}},disposer:()=>{i=[],s.removeMagixEventListener(a)}}}const _={kind:"GeoGebra",async setup(n){var G,O;const r=n.getDisplayer(),e=r.observerId,s=(G=r.state.roomMembers.find(f=>f.memberId===e))==null?void 0:G.payload,t=(s==null?void 0:s.uid)||"",i=(s==null?void 0:s.nickName)||t,o=(O=n.getAppOptions())==null?void 0:O.HTML5Codebase,a=N(n,{uid:"",ggbBase64:""}),u=n.getBox();u.mountStyles(x);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 d=new p,c=y({},X);a.ggbBase64&&(c.ggbBase64=a.ggbBase64),c.id="ggb_"+n.appId;let l;const b=R(n,a,"ggbBase64");function k(){const{width:f,height:S}=m.getBoundingClientRect();l==null||l.setWidth(f),l==null||l.setHeight(S)}c.appletOnLoad=f=>{console.log(`[GeoGebra]: loaded ${JSON.stringify(c.id)}`),l=f,k(),m.classList.remove("loading");const S=n.getDisplayer(),T=new C(y({clientId:S.observerId,nickName:i,api:f,isDecider:w=>S.state.roomMembers.map(E=>E.memberId).every(E=>w<=E),getColor:w=>{const I=S.memberState(w).strokeColor;return"#"+I.map(E=>E.toString(16).padStart(2,"0")).join("")+"80"}},b.service));T.registerListeners(),b.service.addListener(w=>{T.dispatch(w),l==null||l.setUndoPoint()})},d.add(()=>B(m,k)),n.emitter.on("destroy",()=>{console.log("[GeoGebra]: destroy"),d.flushAll(),b.disposer(),l==null||l.remove()});const P=await D(o),M=new P(c);o&&M.setHTML5Codebase(o),M.inject(m)}};return h.default=_,Object.defineProperty(h,"__esModule",{value:!0}),h[Symbol.toStringTag]="Module",h}({});})(); | ||
//# sourceMappingURL=main.iife.js.map |
{ | ||
"name": "@netless/app-geogebra", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"main": "dist/main.cjs.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/main.es.js", |
@@ -11,3 +11,3 @@ import type { GGBApplet, GGBAppletParameters } from "../types"; | ||
export default function getGGBApplet(): Promise<typeof GGBApplet> { | ||
export default function getGGBApplet(codebase?: string): Promise<typeof GGBApplet> { | ||
if (window.GGBApplet) { | ||
@@ -26,3 +26,8 @@ return Promise.resolve(window.GGBApplet); | ||
}); | ||
script.src = "https://www.geogebra.org/apps/deployggb.js"; | ||
if (codebase) { | ||
const index = codebase.lastIndexOf("GeoGebra") + 8; /* "GeoGebra".length */ | ||
script.src = codebase.slice(0, index) + "/deployggb.js"; | ||
} else { | ||
script.src = "https://www.geogebra.org/apps/deployggb.js"; | ||
} | ||
document.head.appendChild(script); | ||
@@ -29,0 +34,0 @@ return getGGBAppletPromise; |
@@ -34,2 +34,6 @@ import { ensureAttributes } from "@netless/app-shared"; | ||
* https://www.geogebra.org/license | ||
* | ||
* KNOWN ISSUE: The GeoGebra sync is based on sending & receiving data about | ||
* partial info of the full picture, this can cause errors because of the order | ||
* of executing them. | ||
*/ | ||
@@ -43,6 +47,8 @@ const GeoGebra: NetlessApp<Attributes> = { | ||
member => member.memberId === memberId | ||
)?.payload; | ||
)?.payload as UserPayload; | ||
const uid = userPayload?.uid || ""; | ||
const nickName = userPayload?.nickName || uid; | ||
const codebase = context.getAppOptions()?.HTML5Codebase; | ||
const attrs = ensureAttributes(context, { | ||
@@ -126,4 +132,7 @@ uid: "", | ||
const GGBApplet = await getGGBApplet(); | ||
const GGBApplet = await getGGBApplet(codebase); | ||
const applet = new GGBApplet(params); | ||
if (codebase) { | ||
applet.setHTML5Codebase(codebase); | ||
} | ||
applet.inject(content); | ||
@@ -130,0 +139,0 @@ }, |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
251773
2780