@gdquest/gd-exercise-wrapper
Version:
React component that wraps an iframe that loads a GDExercise.
30 lines (26 loc) • 15.5 kB
JavaScript
(function(w,F){typeof exports=="object"&&typeof module<"u"?module.exports=F(require("react")):typeof define=="function"&&define.amd?define(["react"],F):(w=typeof globalThis<"u"?globalThis:w||self,w.GdExerciseWrapper=F(w.React))})(this,function(w){"use strict";var F=document.createElement("style");F.textContent=`.gdexercise-wrapper iframe{width:100%;height:100%;border:0;background-color:transparent}
`,document.head.appendChild(F);var H={exports:{}},L={};/**
* @license React
* react-jsx-dev-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ne;function Oe(){if(ne)return L;ne=1;var m=Symbol.for("react.fragment");return L.Fragment=m,L.jsxDEV=void 0,L}var U={};/**
* @license React
* react-jsx-dev-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ae;function Se(){return ae||(ae=1,process.env.NODE_ENV!=="production"&&function(){var m=w,y=Symbol.for("react.element"),g=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),b=Symbol.for("react.provider"),T=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),W=Symbol.for("react.offscreen"),N=Symbol.iterator,x="@@iterator";function j(e){if(e===null||typeof e!="object")return null;var r=N&&e[N]||e[x];return typeof r=="function"?r:null}var D=m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function h(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];Fe("error",e,t)}}function Fe(e,r,t){{var n=D.ReactDebugCurrentFrame,o=n.getStackAddendum();o!==""&&(r+="%s",t=t.concat([o]));var s=t.map(function(i){return String(i)});s.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,s)}}var Ae=!1,Ie=!1,We=!1,Ne=!1,Ve=!1,ie;ie=Symbol.for("react.module.reference");function Ye(e){return!!(typeof e=="string"||typeof e=="function"||e===d||e===c||Ve||e===P||e===p||e===u||Ne||e===W||Ae||Ie||We||typeof e=="object"&&e!==null&&(e.$$typeof===C||e.$$typeof===v||e.$$typeof===b||e.$$typeof===T||e.$$typeof===R||e.$$typeof===ie||e.getModuleId!==void 0))}function Le(e,r,t){var n=e.displayName;if(n)return n;var o=r.displayName||r.name||"";return o!==""?t+"("+o+")":t}function oe(e){return e.displayName||"Context"}function O(e){if(e==null)return null;if(typeof e.tag=="number"&&h("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case d:return"Fragment";case g:return"Portal";case c:return"Profiler";case P:return"StrictMode";case p:return"Suspense";case u:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case T:var r=e;return oe(r)+".Consumer";case b:var t=e;return oe(t._context)+".Provider";case R:return Le(e,e.render,"ForwardRef");case v:var n=e.displayName||null;return n!==null?n:O(e.type)||"Memo";case C:{var o=e,s=o._payload,i=o._init;try{return O(i(s))}catch{return null}}}return null}var k=Object.assign,V=0,se,ue,ce,fe,le,de,ve;function pe(){}pe.__reactDisabledLog=!0;function Ue(){{if(V===0){se=console.log,ue=console.info,ce=console.warn,fe=console.error,le=console.group,de=console.groupCollapsed,ve=console.groupEnd;var e={configurable:!0,enumerable:!0,value:pe,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}V++}}function Me(){{if(V--,V===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:k({},e,{value:se}),info:k({},e,{value:ue}),warn:k({},e,{value:ce}),error:k({},e,{value:fe}),group:k({},e,{value:le}),groupCollapsed:k({},e,{value:de}),groupEnd:k({},e,{value:ve})})}V<0&&h("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var K=D.ReactCurrentDispatcher,X;function $(e,r,t){{if(X===void 0)try{throw Error()}catch(o){var n=o.stack.trim().match(/\n( *(at )?)/);X=n&&n[1]||""}return`
`+X+e}}var q=!1,G;{var $e=typeof WeakMap=="function"?WeakMap:Map;G=new $e}function he(e,r){if(!e||q)return"";{var t=G.get(e);if(t!==void 0)return t}var n;q=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var s;s=K.current,K.current=null,Ue();try{if(r){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(S){n=S}Reflect.construct(e,[],i)}else{try{i.call()}catch(S){n=S}e.call(i.prototype)}}else{try{throw Error()}catch(S){n=S}e()}}catch(S){if(S&&n&&typeof S.stack=="string"){for(var a=S.stack.split(`
`),E=n.stack.split(`
`),f=a.length-1,l=E.length-1;f>=1&&l>=0&&a[f]!==E[l];)l--;for(;f>=1&&l>=0;f--,l--)if(a[f]!==E[l]){if(f!==1||l!==1)do if(f--,l--,l<0||a[f]!==E[l]){var _=`
`+a[f].replace(" at new "," at ");return e.displayName&&_.includes("<anonymous>")&&(_=_.replace("<anonymous>",e.displayName)),typeof e=="function"&&G.set(e,_),_}while(f>=1&&l>=0);break}}}finally{q=!1,K.current=s,Me(),Error.prepareStackTrace=o}var I=e?e.displayName||e.name:"",Ce=I?$(I):"";return typeof e=="function"&&G.set(e,Ce),Ce}function Ge(e,r,t){return he(e,!1)}function Be(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function B(e,r,t){if(e==null)return"";if(typeof e=="function")return he(e,Be(e));if(typeof e=="string")return $(e);switch(e){case p:return $("Suspense");case u:return $("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case R:return Ge(e.render);case v:return B(e.type,r,t);case C:{var n=e,o=n._payload,s=n._init;try{return B(s(o),r,t)}catch{}}}return""}var J=Object.prototype.hasOwnProperty,me={},ge=D.ReactDebugCurrentFrame;function z(e){if(e){var r=e._owner,t=B(e.type,e._source,r?r.type:null);ge.setExtraStackFrame(t)}else ge.setExtraStackFrame(null)}function Je(e,r,t,n,o){{var s=Function.call.bind(J);for(var i in e)if(s(e,i)){var a=void 0;try{if(typeof e[i]!="function"){var E=Error((n||"React class")+": "+t+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw E.name="Invariant Violation",E}a=e[i](r,i,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(f){a=f}a&&!(a instanceof Error)&&(z(o),h("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,i,typeof a),z(null)),a instanceof Error&&!(a.message in me)&&(me[a.message]=!0,z(o),h("Failed %s type: %s",t,a.message),z(null))}}}var ze=Array.isArray;function Z(e){return ze(e)}function He(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function Ke(e){try{return be(e),!1}catch{return!0}}function be(e){return""+e}function Ee(e){if(Ke(e))return h("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",He(e)),be(e)}var Y=D.ReactCurrentOwner,Xe={key:!0,ref:!0,__self:!0,__source:!0},ye,Re,Q;Q={};function qe(e){if(J.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function Ze(e){if(J.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function Qe(e,r){if(typeof e.ref=="string"&&Y.current&&r&&Y.current.stateNode!==r){var t=O(Y.current.type);Q[t]||(h('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',O(Y.current.type),e.ref),Q[t]=!0)}}function er(e,r){{var t=function(){ye||(ye=!0,h("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function rr(e,r){{var t=function(){Re||(Re=!0,h("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var tr=function(e,r,t,n,o,s,i){var a={$$typeof:y,type:e,key:r,ref:t,props:i,_owner:s};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function nr(e,r,t,n,o){{var s,i={},a=null,E=null;t!==void 0&&(Ee(t),a=""+t),Ze(r)&&(Ee(r.key),a=""+r.key),qe(r)&&(E=r.ref,Qe(r,o));for(s in r)J.call(r,s)&&!Xe.hasOwnProperty(s)&&(i[s]=r[s]);if(e&&e.defaultProps){var f=e.defaultProps;for(s in f)i[s]===void 0&&(i[s]=f[s])}if(a||E){var l=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&er(i,l),E&&rr(i,l)}return tr(e,a,E,o,n,Y.current,i)}}var ee=D.ReactCurrentOwner,_e=D.ReactDebugCurrentFrame;function A(e){if(e){var r=e._owner,t=B(e.type,e._source,r?r.type:null);_e.setExtraStackFrame(t)}else _e.setExtraStackFrame(null)}var re;re=!1;function te(e){return typeof e=="object"&&e!==null&&e.$$typeof===y}function we(){{if(ee.current){var e=O(ee.current.type);if(e)return`
Check the render method of \``+e+"`."}return""}}function ar(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return`
Check your code at `+r+":"+t+"."}return""}}var Te={};function ir(e){{var r=we();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
Check the top-level render call using <`+t+">.")}return r}}function xe(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=ir(r);if(Te[t])return;Te[t]=!0;var n="";e&&e._owner&&e._owner!==ee.current&&(n=" It was passed a child from "+O(e._owner.type)+"."),A(e),h('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),A(null)}}function Pe(e,r){{if(typeof e!="object")return;if(Z(e))for(var t=0;t<e.length;t++){var n=e[t];te(n)&&xe(n,r)}else if(te(e))e._store&&(e._store.validated=!0);else if(e){var o=j(e);if(typeof o=="function"&&o!==e.entries)for(var s=o.call(e),i;!(i=s.next()).done;)te(i.value)&&xe(i.value,r)}}}function or(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===R||r.$$typeof===v))t=r.propTypes;else return;if(t){var n=O(r);Je(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!re){re=!0;var o=O(r);h("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",o||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&h("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function sr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){A(e),h("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),A(null);break}}e.ref!==null&&(A(e),h("Invalid attribute `ref` supplied to `React.Fragment`."),A(null))}}function ur(e,r,t,n,o,s){{var i=Ye(e);if(!i){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var E=ar(o);E?a+=E:a+=we();var f;e===null?f="null":Z(e)?f="array":e!==void 0&&e.$$typeof===y?(f="<"+(O(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):f=typeof e,h("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",f,a)}var l=nr(e,r,t,o,s);if(l==null)return l;if(i){var _=r.children;if(_!==void 0)if(n)if(Z(_)){for(var I=0;I<_.length;I++)Pe(_[I],e);Object.freeze&&Object.freeze(_)}else h("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Pe(_,e)}return e===d?sr(l):or(l),l}}var cr=ur;U.Fragment=d,U.jsxDEV=cr}()),U}process.env.NODE_ENV==="production"?H.exports=Oe():H.exports=Se();var M=H.exports;globalThis&&globalThis.__awaiter,globalThis&&globalThis.__awaiter;function je(m,{threshold:y=0,root:g=null,rootMargin:d="0%",freezeOnceVisible:P=!1}){const[c,b]=w.useState(),T=(c==null?void 0:c.isIntersecting)&&P,R=([p])=>{b(p)};return w.useEffect(()=>{const p=m==null?void 0:m.current;if(!!!window.IntersectionObserver||T||!p)return;const v={threshold:y,root:g,rootMargin:d},C=new IntersectionObserver(R,v);return C.observe(p),()=>C.disconnect()},[m==null?void 0:m.current,JSON.stringify(y),g,d,T]),c}const fr="",De="/loader.html";function ke(m){const{loader:y=new URL(De,window.location.origin).href,dataPath:g,mainScene:d,openFiles:P=[],height:c,hideCode:b=!1,hideConsole:T=!1,hidePlayer:R=!1,hideTest:p=!1,snippet:u=""}=m,v=w.useRef(null),C=w.useRef(null),W=je(C,{}),N=(W==null?void 0:W.isIntersecting)===!0,x=new URL(y);x.searchParams.append("dataPath",g),x.searchParams.append("mainScene",d);for(const j of P){const D=()=>j.focus===!0?"focus":"nofocus";x.searchParams.append("open",[j.path,D(),j.override].filter(h=>h!=null).join(":"))}return b&&x.searchParams.append("hide","code"),T&&x.searchParams.append("hide","console"),R&&x.searchParams.append("hide","player"),p&&x.searchParams.append("hide","test"),u.length>0&&x.searchParams.append("snippet",u),w.useEffect(()=>{var j;v.current!=null&&((j=v.current.contentWindow)==null||j.postMessage({from:"gd-exercise",type:"low-processor-usage-mode",value:!N}))},[N,v.current]),M.jsxDEV(M.Fragment,{children:M.jsxDEV("div",{className:"gdexercise-wrapper",ref:C,children:M.jsxDEV("iframe",{allow:"fullscreen",src:x.href,style:{height:c},ref:v},void 0,!1,{fileName:"/home/adamscott/dev/builds/gd-web/packages/gd-exercise-wrapper/src/components/GdExerciseWrapper.tsx",lineNumber:97,columnNumber:9},this)},void 0,!1,{fileName:"/home/adamscott/dev/builds/gd-web/packages/gd-exercise-wrapper/src/components/GdExerciseWrapper.tsx",lineNumber:96,columnNumber:7},this)},void 0,!1,{fileName:"/home/adamscott/dev/builds/gd-web/packages/gd-exercise-wrapper/src/components/GdExerciseWrapper.tsx",lineNumber:95,columnNumber:5},this)}return ke});
//# sourceMappingURL=gdexercise-wrapper.umd.js.map