From 6dcbb7876f248e909e48be9d8542b97c8115bf2f Mon Sep 17 00:00:00 2001 From: greggman Date: Fri, 5 Jul 2024 03:01:32 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20=20@=20625a2?= =?UTF-8?q?c1add6cdbb59a9cb0b0f76cea66e3ec5ee0=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- asset-manifest.json | 8 ++++---- index.html | 2 +- jsgist-runner.js | 19 +++++++++++++++++++ ...nifest.2b128e4fb818833787fd20757bbd369f.js | 8 ++++---- service-worker.js | 2 +- static/js/main.2d70f3f4.chunk.js | 2 ++ static/js/main.2d70f3f4.chunk.js.map | 1 + static/js/main.6a1bf393.chunk.js | 2 -- static/js/main.6a1bf393.chunk.js.map | 1 - 9 files changed, 32 insertions(+), 13 deletions(-) rename precache-manifest.34f32a518005c0a720b623d8ecd2677c.js => precache-manifest.2b128e4fb818833787fd20757bbd369f.js (85%) create mode 100644 static/js/main.2d70f3f4.chunk.js create mode 100644 static/js/main.2d70f3f4.chunk.js.map delete mode 100644 static/js/main.6a1bf393.chunk.js delete mode 100644 static/js/main.6a1bf393.chunk.js.map diff --git a/asset-manifest.json b/asset-manifest.json index 3fa0d11..250b596 100644 --- a/asset-manifest.json +++ b/asset-manifest.json @@ -1,15 +1,15 @@ { "files": { "main.css": "/static/css/main.3b498017.chunk.css", - "main.js": "/static/js/main.6a1bf393.chunk.js", - "main.js.map": "/static/js/main.6a1bf393.chunk.js.map", + "main.js": "/static/js/main.2d70f3f4.chunk.js", + "main.js.map": "/static/js/main.2d70f3f4.chunk.js.map", "runtime-main.js": "/static/js/runtime-main.a136100e.js", "runtime-main.js.map": "/static/js/runtime-main.a136100e.js.map", "static/css/2.6b709c6b.chunk.css": "/static/css/2.6b709c6b.chunk.css", "static/js/2.81761772.chunk.js": "/static/js/2.81761772.chunk.js", "static/js/2.81761772.chunk.js.map": "/static/js/2.81761772.chunk.js.map", "index.html": "/index.html", - "precache-manifest.34f32a518005c0a720b623d8ecd2677c.js": "/precache-manifest.34f32a518005c0a720b623d8ecd2677c.js", + "precache-manifest.2b128e4fb818833787fd20757bbd369f.js": "/precache-manifest.2b128e4fb818833787fd20757bbd369f.js", "service-worker.js": "/service-worker.js", "static/css/2.6b709c6b.chunk.css.map": "/static/css/2.6b709c6b.chunk.css.map", "static/css/main.3b498017.chunk.css.map": "/static/css/main.3b498017.chunk.css.map", @@ -24,6 +24,6 @@ "static/css/2.6b709c6b.chunk.css", "static/js/2.81761772.chunk.js", "static/css/main.3b498017.chunk.css", - "static/js/main.6a1bf393.chunk.js" + "static/js/main.2d70f3f4.chunk.js" ] } \ No newline at end of file diff --git a/index.html b/index.html index 96c40d5..1415f27 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -jsGist
\ No newline at end of file +jsGist
\ No newline at end of file diff --git a/jsgist-runner.js b/jsgist-runner.js index 2236fc1..59d65a7 100644 --- a/jsgist-runner.js +++ b/jsgist-runner.js @@ -4,6 +4,23 @@ const params = Object.fromEntries(new URLSearchParams(window.location.search).entries()); const url = new URL(params.url); + const allow = [ + 'accelerometer', + 'bluetooth', + 'camera', + 'encrypted-media', + 'display-capture', + 'geolocation', + 'gyroscope', + 'microphone', + 'midi', + 'clipboard-read', + 'clipboard-write', + 'web-share', + 'serial', + 'xr-spatial-tracking', + ].map(v => `${v} *`).join('; '); + let iframe; async function startServiceWorker() { @@ -144,6 +161,7 @@ iframe { function insertInBlob(mainHTML, mainJS, mainCSS) { applyCSSToSelfToRunContentInIFrame(); const iframe = document.createElement('iframe'); + iframe.allow = allow; const html = makePageHTML(mainHTML, mainJS, mainCSS); registerSections(html); const blob = new Blob([html], {type: 'text/html'}); @@ -155,6 +173,7 @@ iframe { function insertInServiceWorker(mainHTML, mainJS, mainCSS) { applyCSSToSelfToRunContentInIFrame(); const iframe = document.createElement('iframe'); + iframe.allow = "accelerometer *; bluetooth *; camera *; encrypted-media *; display-capture *; geolocation *; gyroscope *; microphone *; midi *; clipboard-read *; clipboard-write *; web-share *; serial *; xr-spatial-tracking *" const html = makePageHTML(mainHTML, mainJS, mainCSS); registerSections(html); cacheFile('/user-jsgist.html', 'text/html', html); diff --git a/precache-manifest.34f32a518005c0a720b623d8ecd2677c.js b/precache-manifest.2b128e4fb818833787fd20757bbd369f.js similarity index 85% rename from precache-manifest.34f32a518005c0a720b623d8ecd2677c.js rename to precache-manifest.2b128e4fb818833787fd20757bbd369f.js index 2bf788c..467cd35 100644 --- a/precache-manifest.34f32a518005c0a720b623d8ecd2677c.js +++ b/precache-manifest.2b128e4fb818833787fd20757bbd369f.js @@ -1,6 +1,6 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([ { - "revision": "0f351a2065816d28222a30c32aaedfb4", + "revision": "ed0fb73403ca505cea0cd2285594285f", "url": "/index.html" }, { @@ -8,7 +8,7 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([ "url": "/static/css/2.6b709c6b.chunk.css" }, { - "revision": "4a7352ad2c6a0963ed6f", + "revision": "e33962698a7101623508", "url": "/static/css/main.3b498017.chunk.css" }, { @@ -20,8 +20,8 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([ "url": "/static/js/2.81761772.chunk.js.LICENSE.txt" }, { - "revision": "4a7352ad2c6a0963ed6f", - "url": "/static/js/main.6a1bf393.chunk.js" + "revision": "e33962698a7101623508", + "url": "/static/js/main.2d70f3f4.chunk.js" }, { "revision": "21d734a13edf31307f64", diff --git a/service-worker.js b/service-worker.js index 9316ea4..46fc662 100644 --- a/service-worker.js +++ b/service-worker.js @@ -14,7 +14,7 @@ importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js"); importScripts( - "/precache-manifest.34f32a518005c0a720b623d8ecd2677c.js" + "/precache-manifest.2b128e4fb818833787fd20757bbd369f.js" ); self.addEventListener('message', (event) => { diff --git a/static/js/main.2d70f3f4.chunk.js b/static/js/main.2d70f3f4.chunk.js new file mode 100644 index 0000000..c760ffa --- /dev/null +++ b/static/js/main.2d70f3f4.chunk.js @@ -0,0 +1,2 @@ +(this.webpackJsonpjsgist=this.webpackJsonpjsgist||[]).push([[0],{178:function(e,t,n){},179:function(e,t,n){"use strict";n.r(t);var a=n(0),r=n.n(a),i=n(76),o=n.n(i),s=n(3),c=n(5),l=n(16),u=function(){function e(){Object(s.a)(this,e),this.itemToSubscriptionMap=void 0,this.itemToSubscriptionMap=new Map}return Object(c.a)(e,[{key:"subscribe",value:function(e,t){this.unsubscribe(e,t);var n=this.itemToSubscriptionMap.get(e);n||(n=[],this.itemToSubscriptionMap.set(e,n)),n.push(t)}},{key:"unsubscribe",value:function(e,t){var n=this.itemToSubscriptionMap.get(e);if(n){var a=n.indexOf(t);a>=0&&(n.splice(a,1),0===n.length&&this.itemToSubscriptionMap.delete(e))}}},{key:"notify",value:function(e){var t=this.itemToSubscriptionMap.get(e);if(t){var n,a=Object(l.a)(t.slice());try{for(a.s();!(n=a.n()).done;){(0,n.value)()}}catch(r){a.e(r)}finally{a.f()}}}}]),e}();var d=new(function(){function e(t){var n=this;Object(s.a)(this,e),this.prefix=void 0,this.subscriptionManager=void 0,this._handleNewValue=function(e){var t=e.key;if(t&&t.startsWith(n.prefix)){var a=t.substr(n.prefix.length);n.subscriptionManager.notify(a)}},this.prefix="".concat(t,"-"),this.subscriptionManager=new u,window.addEventListener("storage",this._handleNewValue)}return Object(c.a)(e,[{key:"_addPrefix",value:function(e){return"".concat(this.prefix).concat(e)}},{key:"subscribe",value:function(e,t){this.subscriptionManager.subscribe(e,t)}},{key:"unsubscribe",value:function(e,t){this.subscriptionManager.unsubscribe(e,t)}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this._addPrefix(e);if(t){var a=sessionStorage.getItem(n);if(a)return a}return localStorage.getItem(n)}},{key:"set",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=this._addPrefix(e);n&&sessionStorage.setItem(a,t),localStorage.setItem(a,t),this.subscriptionManager.notify(e)}},{key:"delete",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this._addPrefix(e);t&&sessionStorage.removeItem(n),localStorage.removeItem(n),this.subscriptionManager.notify(e)}},{key:"cleanup",value:function(){window.removeEventListener("storage",this._handleNewValue)}}]),e}())("jsgist"),h=(n(94),n(95),document.createElement("div"));h.setAttribute("style","width:30px;height:30px;"),h.classList.add("scrollbar-test");var m=document.createElement("div");m.setAttribute("style","width:100%;height:40px"),h.appendChild(m),document.body.appendChild(h),30-h.firstChild.clientWidth&&document.body.classList.add("layout-scrollbar-obtrusive"),document.body.removeChild(h);var p=n(1),f=n.n(p),g=n(8),v=n(42),b=n(6),y=n(7);function E(e){return r.a.createElement("input",{type:"text",onChange:function(t){e.onChange(t.target.value)},placeholder:e.placeholder,value:e.value})}var w=n(20),k=n(4),S=n(9),j=n(53),O="/*bug-in-github-api-content-can-not-be-empty*/";function x(e){return e.content.startsWith(O)?e.content.substr(O.length):e.content}function C(e){var t=JSON.parse(e.files["jsGist.json"].content);return t.filenames?t.files=t.filenames.map((function(t){return{name:t,content:x(e.files[t])}})):t.files=Object.entries(e.files).filter((function(e){return"jsGist.json"!==Object(S.a)(e,1)[0]})).map((function(e){var t=Object(S.a)(e,2);return{name:t[0],content:x(t[1])}})).concat(t.files||[]),t}function M(e,t,n){var a=e.files.reduce((function(e,t){return e[t.name]={content:t.content.trim()?t.content:"".concat(O).concat(t.content)},e}),{}),r=Object(k.a)({},e),i={};if(a["jsGist.json"]=i,Object.keys(a).length===e.files.length+1?(delete r.files,r.filenames=e.files.map((function(e){return e.name}))):a={"jsGist.json":i},i.content=JSON.stringify(r),n){var o=Object.keys(a).map((function(e){return e.toLowerCase()}));if(!(o.includes("readme.md")||o.includes("readme.txt")||o.includes("readme"))){var s="## ".concat(e.name,"\n\n[view on jsgist](").concat(window.location.origin,"?src=").concat(n,")");a["README.md"]={content:s}}for(var c=0,l=Object.entries(a);c1&&void 0!==i[1]&&i[1],a=M(t,n),e.next=4,this.authorizedOctokit.gists.create(a);case 4:return r=e.sent,this._updateUserData(r.data),e.next=8,this.updateGist(r.data.id,t);case 8:return e.abrupt("return",e.sent);case 9:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"updateGist",value:function(){var e=Object(g.a)(f.a.mark((function e(t,n){var a,r;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=M(n,!1,t),e.next=3,this.authorizedOctokit.gists.update(a);case 3:return r=e.sent,e.abrupt("return",{id:r.data.id,name:r.data.description,date:r.data.updated_at,public:r.data.public});case 5:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}()},{key:"forkGist",value:function(){var e=Object(g.a)(f.a.mark((function e(t){var n;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.authorizedOctokit.gists.fork({gist_id:t});case 2:return n=e.sent,e.abrupt("return",{id:n.data.id});case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"deleteGist",value:function(){var e=Object(g.a)(f.a.mark((function e(t){var n;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.authorizedOctokit.gists.delete({gist_id:t});case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"createGistComment",value:function(){var e=Object(g.a)(f.a.mark((function e(t,n){var a;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.authorizedOctokit.gists.createComment({gist_id:t,body:n});case 2:if(!((a=e.sent).status<200||a.status>=300)){e.next=5;break}throw new Error(a.message);case 5:return e.abrupt("return",a.data);case 6:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}()},{key:"octokit",get:function(){return this.authorizedOctokit||this.unAuthorizedOctokit}}]),n}(Object(w.a)(EventTarget));function N(){return r.a.createElement("div",{className:"head"},r.a.createElement("div",null,r.a.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:window.location.origin},r.a.createElement("img",{src:"/resources/images/logo-small.svg",alt:"logo"}),window.location.hostname)),r.a.createElement("div",{className:"fix-help-contribute"},r.a.createElement("div",{className:"octocat"},r.a.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://github.com/greggman/jsgist/"},r.a.createElement("img",{alt:"github",src:"/resources/images/octocat-icon.svg"})))))}var L=function(e){Object(b.a)(n,e);var t=Object(y.a)(n);function n(){var e;Object(s.a)(this,n);for(var a=arguments.length,r=new Array(a),i=0;i--"),"."),r.a.createElement("p",null,"Example: ",r.a.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://jsgist.org/?src=f793cb359f2571409983351a6099d5d1"},"https://jsgist.org/?src=f793cb359f2571409983351a6099d5d1"))),r.a.createElement("li",null,"Save it manually somewhere else.",r.a.createElement("p",null,"If there's some other service that will provide a string via http get then copy and save the JSON there then create a URL in the form of ",r.a.createElement("code",null,"https://jsgist.org/?src="),". Note: you may have to escape the URL.")),r.a.createElement("li",null,"Save it as a bookmark or link",r.a.createElement("p",null,"In the SaveAs dialog there's a link that contains all the data for your benchmark.")))))}var U=n(15),T=n.n(U),_=n(14),A=n.n(_),D=n(18),P=/([a-z])([A-Z])/g,R=function(e,t,n){return"".concat(t,"-").concat(n)},G=function(e){return e.replace(P,R).toLowerCase()};function K(){for(var e=[],t=arguments.length,n=new Array(t),a=0;a=0?e.substr(t+1):e}(t.url||""),":",t.lineNo)))}))))}}]),n}(r.a.Component);function W(e,t){for(var n=new URL(e),a=new URLSearchParams(n.search),r=0,i=Object.entries(t);r=0&&r.splice(i,1),0===r.length&&(a.delete(e),0===a.size&&t&&q.delete(t))}}}function $(e,t,n){var a=e.get(t);if(a){var r,i=Object(l.a)(a);try{for(i.s();!(r=i.n()).done;){(0,r.value)(n)}}catch(o){i.e(o)}finally{i.f()}return!0}return!1}window.addEventListener("message",(function(e){var t=e.data,n=t.type,a=t.data,r=q.get(e.source);r&&$(r,n,a)||$(H,n,a)}));var X=["accelerometer","bluetooth","camera","encrypted-media","display-capture","geolocation","gyroscope","microphone","midi","clipboard-read","clipboard-write","web-share","serial","xr-spatial-tracking"].map((function(e){return"".concat(e," *")})).join("; "),Z=function(e){Object(b.a)(n,e);var t=Object(y.a)(n);function n(e){var a;return Object(s.a)(this,n),(a=t.call(this,e)).handleJSLog=function(e){a.context.logManager.addMsg(e)},a.handleJSError=function(e){a.context.logManager.addMsg(Object(k.a)(Object(k.a)({},e),{},{type:"error",showStack:!0}))},a.handleJSUnhandledRejection=function(e){a.context.logManager.addMsg(Object(k.a)(Object(k.a)({},e),{},{type:"error",showStack:!0}))},a.handleInfoMessages=function(e){a.context.logManager.addMsgs(e)},a.handleGimmeDaCodez=function(){a.iframe.contentWindow.postMessage({type:"run",data:a.data},"*")},a.handleMessage=function(e){var t=e.data,n=t.type,r=t.data,i=a.handlers[n];i&&i(r)},a.runnerRef=r.a.createRef(),a}return Object(c.a)(n,[{key:"componentDidMount",value:function(){var e=this,t=this.props.registerAPI,n=Object.fromEntries(new URLSearchParams(window.location.search).entries()).debug,a=Object(k.a)({},n&&{debug:n});t({run:function(t,n){e.data=t,e.removeIFrame();var r=document.createElement("iframe");r.allow=X,e.iframe=r,r.src=W("https://jsgistrunner.devcomments.org/runner-03.html",Object(k.a)({url:"https://jsgist.org/jsgist-runner.js"},a)),n&&(r.style.background="none"),e.runnerRef.current.appendChild(r)}}),B("gimmeDaCodez",null,this.handleGimmeDaCodez),B("jsLog",null,this.handleJSLog),B("jsError",null,this.handleJSError),B("jsUnhandledRejection",null,this.handleJSUnhandledRejection),B("infoMessages",null,this.handleInfoMessages)}},{key:"removeIFrame",value:function(){this.iframe&&(this.iframe.remove(),this.iframe.src="about:blank",this.iframe=void 0)}},{key:"componentWillUnmount",value:function(){this.removeIFrame(),Y("gimmeDaCodez",null,this.handleGimmeDaCodez),Y("jsLog",null,this.handleJSLog),Y("jsError",null,this.handleJSError),Y("jsUnhandledRejection",null,this.handleJSUnhandledRejection),Y("infoMessages",null,this.handleInfoMessages)}},{key:"render",value:function(){return r.a.createElement("div",{className:"runner",ref:this.runnerRef})}}]),n}(r.a.Component);Z.contextType=F;var Q=n(79),ee=(new T.a).compile(Q),te={};function ne(e){var t=te[e]||{subscriptions:new Set};return te[e]=t,t}function ae(e,t){var n=ne(e);return void 0!==t&&(n.value=t),n}function re(e){return te[e].value}function ie(e,t){var n=te[e];if(!n)throw new Error("no such track value: ".concat(e));n.value=t;var a,r=Object(v.a)(n.subscriptions.keys()),i=Object(l.a)(r);try{for(i.s();!(a=i.n()).done;){(0,a.value)(t,e)}}catch(o){i.e(o)}finally{i.f()}}function oe(e,t){ne(e).subscriptions.add(t)}function se(e,t){ne(e).subscriptions.delete(t)}var ce,le={name:"My jsGist",settings:{},files:[{name:"index.html",content:""},{name:"index.css",content:""},{name:"index.js",content:""}]};function ue(){var e="".concat(window.location.origin,"/resources/images/logo.svg");return JSON.parse(JSON.stringify({name:"jsGist",settings:{},files:[{name:"index.html",content:""},{name:"index.css",content:"\n html, body {\n margin: 0;\n width: 100%;\n height: 100%;\n background-image: url(".concat(e,");\n background-size: contain contain;\n background-position: center center;\n background-repeat: no-repeat no-repeat;\n }\n @media (prefers-color-scheme: dark) {\n html {\n background: #222;\n }\n }\n ")},{name:"index.js",content:""}]}))}function de(){return ce}ae("dataVersion",0),ae("updateVersion",0),ae("filesVersion",0);var he=function(e){return ie(e,re(e)+1)},me=function(e){return he("dataVersion")},pe=function(e){return he("filesVersion")};function fe(e,t){ce.files[e].name=t,me()}function ge(e,t){ce.files[e].content=t,me()}function ve(e){!function(e){if(!ee(e))throw new Error("data not valid:\n".concat(ee.errors.map((function(e){return"".concat(e.message,": ").concat(e.dataPath)}))))}(e),ce=e,he("updateVersion"),me(),pe()}ve(JSON.parse(JSON.stringify(le)));var be,ye=Object.fromEntries(new URLSearchParams(window.location.search).entries()),Ee=!ye.codeMirror&&!/webOS|iPhone|iPad|Android/.test(navigator.userAgent),we=!1,ke={layout:window.screen.width<540||window.screen.height<540?3:0,editor:Ee?"monaco":"codemirror",lineNumbers:!0,tabs:!1,showWhitespace:!1};function Se(e,t){be[e]=t;var n=JSON.stringify(be);d.set("ui-settings",n,!0),ie("settings",be)}function je(){return function(){if(!we){we=!0;try{if(!(be=JSON.parse(d.get("ui-settings",!0))))throw new Error("no settings")}catch(i){be=Object(k.a)({},ke)}for(var e=0,t=Object.entries(ke);e=0&&(u.matchTags=!0),r.a.createElement(Le.Controlled,{value:c,options:u,onBeforeChange:function(t,n,a){e.setState({value:a})},onChange:function(e,t,n){o(n)},editorDidMount:this.registerEditor})}}],[{key:"getDerivedStateFromProps",value:function(e,t){return t.hackKey!==e.hackKey?{hackKey:e.hackKey,value:e.value}:null}}]),n}(r.a.Component),_e=n(88);function Ae(e,t){var n,a=Object(l.a)(t);try{var r=function(){var t=n.value,a=e.findIndex((function(e){return e.name.toLowerCase().endsWith(t.toLowerCase())}));if(a>=0)return{v:a}};for(a.s();!(n=a.n()).done;){var i=r();if("object"===typeof i)return i.v}}catch(o){a.e(o)}finally{a.f()}return-1}function De(e,t){var n=e.findIndex((function(e){return e.name.toLowerCase()===t.toLowerCase}));if(n>=0)return n;for(var a=arguments.length,r=new Array(a>2?a-2:0),i=2;i1?t-1:0),a=1;a=0?e[r]:""}var Re=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:",";return Object.entries(e).map((function(e){var t=Object(S.a)(e,2),n=t[0],a=t[1];return"".concat(n,"=").concat(a)})).join(t)};var Ge=window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)"):{},Ke=function(){};function Fe(e){return Je.apply(this,arguments)}function Je(){return(Je=Object(g.a)(f.a.mark((function e(t){var n;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t);case 2:return n=e.sent,e.next=5,n.text();case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ve,We=(Ve=function(){var e=Object(g.a)(f.a.mark((function e(t){var n;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,Fe("/types/webgpu/dist/index.d.ts");case 3:n=e.sent,t.languages.typescript.javascriptDefaults.addExtraLib(n,"");case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),function(){var e=!1;e||(e=!0,Ve.apply(void 0,arguments))});var He=function(e){Object(b.a)(n,e);var t=Object(y.a)(n);function n(e){var a;Object(s.a)(this,n),(a=t.call(this,e)).handleEditorDidMount=function(e,t){a.editor=e,We(t),e.getModel().updateOptions({tabSize:2});var n=a.props.registerAPI;n&&n({goToLine:function(e,t){a.editor.focus(),a.editor.setPosition({lineNumber:e,column:t}),a.editor.revealPosition({lineNumber:e,column:t})},refresh:function(e){},focus:function(e){a.editor.focus()}})},a.registerEditor=function(e){a.editor=e};var r=e.value,i=e.hackKey;return a.state={value:r,hackKey:i},a}return Object(c.a)(n,[{key:"render",value:function(){var e=this.props,t=e.options,n=void 0===t?{}:t,a=e.onValueChange,i=void 0===a?Ke:a,o=e.ui,s=this.state.value,c=Ge.matches,l=function(e){var t=((null===e||void 0===e?void 0:e.mode)||"javascript").split("/").pop();return"gfm"===t?"markdown":t}(n.editor).split("/").pop();return r.a.createElement(_e.a,{theme:c?"vs-dark":"light",language:l,value:s,onChange:i,onMount:this.handleEditorDidMount,options:{minimap:{enabled:!1},lineNumbers:o.lineNumbers?"on":"off",glyphMargin:!1,folding:!1,insertSpaces:!o.tabs,renderWhitespace:o.showWhitespace}})}}],[{key:"getDerivedStateFromProps",value:function(e,t){return t.hackKey!==e.hackKey?{hackKey:e.hackKey,value:e.value}:null}}]),n}(r.a.Component),qe=function(e){Object(b.a)(n,e);var t=Object(y.a)(n);function n(){var e;Object(s.a)(this,n);for(var a=arguments.length,r=new Array(a),i=0;i=0&&(t[0]=e[0]),a.state.showResult&&(t[1]=e[1]),a.state.showLow&&(t[2]=e[2]),a.setState({sizes:e,lastSizes:t}),Se("layoutTabbed",a.state)},a.handleGoToLine=function(e){a.files.forEach((function(t,n){if(t.goToLine(e)){var r=a.props.data.files.findIndex((function(t){return t.name===e.section}));r!==a.state.currentNdx&&a.handleOnChange(r)}}))},a.handleOnChange=function(e){var t=a.state.currentNdx===e?-1:e;a.setState({currentNdx:t,sizes:ot(a.state.sizes,a.state.lastSizes,0,t>=0)}),Se("layoutTabbed",a.state)},a.toggleShowLog=function(){var e=!a.state.showLog;a.setState({showLog:e,sizes:ot(a.state.sizes,a.state.lastSizes,2,e)}),Se("layoutTabbed",a.state)},a.toggleShowResult=function(){var e=!a.state.showResult;a.setState({showResult:e,sizes:ot(a.state.sizes,a.state.lastSizes,1,e)}),Se("layoutTabbed",a.state)};var r=je().layoutTabbed;return a.state=it(r)?r:{showResult:!0,showLog:!0,currentNdx:2,sizes:[.45,.45,.1],lastSizes:[.45,.45,.1]},a.files=new Map,a.fileToKeyMap=new Map,a}return Object(c.a)(n,[{key:"getFileKey",value:function(e){var t=this.fileToKeyMap.get(e);return t||(t="".concat(Date.now(),"-").concat(Math.random()),this.fileToKeyMap.set(e,t)),t}},{key:"componentDidUpdate",value:function(){this.previousNdx!==this.state.currentNdx&&(this.previousNdx=this.state.currentNdx,this.files.forEach((function(e){e.refresh(),e.focus()})))}},{key:"render",value:function(){var e=this,t=this.props,n=t.hackKey,a=t.data,i=t.registerRunnerAPI,o=this.state,s=o.showResult,c=o.showLog,l=o.sizes,u=o.currentNdx,d=Object(k.a)({},!s&&{display:"none"}),h=Object(k.a)({},!c&&{display:"none"});return r.a.createElement("div",{className:"layout-tabbed"},r.a.createElement("div",{className:"layout-tabbed-top"},r.a.createElement("div",{className:"tab-tabs"},a.files.map((function(t,n){var a="ca".concat(e.getFileKey(t));return r.a.createElement(r.a.Fragment,{key:a},r.a.createElement("input",{type:"radio",name:"tabbed-files",id:a,checked:n===u,onClick:function(t){return e.handleOnChange(n)},onChange:function(e){return e}}),r.a.createElement("label",{htmlFor:a},t.name))})),r.a.createElement("input",{type:"checkbox",checked:s,onChange:this.toggleShowResult,id:"result"}),r.a.createElement("label",{htmlFor:"result"},"result"),r.a.createElement("input",{type:"checkbox",checked:c,onChange:this.toggleShowLog,id:"log"}),r.a.createElement("label",{htmlFor:"log"},"log"))),r.a.createElement(A.a,{direction:"vertical",minSize:0,sizes:l,onSetSizes:this.setSizes},r.a.createElement("div",{className:"tab-content"},a.files.map((function(t,a){var i="ca".concat(e.getFileKey(t));return r.a.createElement("div",{key:i,style:Object(k.a)({},a!==u&&{display:"none"})},r.a.createElement(Ye,{hackKey:n,desc:"filename",title:t.name,value:t.content,onTitleChange:function(e){return fe(a,e)},onValueChange:function(e){return ge(a,e)},register:e.handleRegister,unregister:e.handleUnregister}))}))),r.a.createElement("div",{className:"layout-tabbed-result",style:d},r.a.createElement(Z,{registerAPI:i})),r.a.createElement("div",{className:"layout-tabbed-log",style:h},r.a.createElement(V,{onGoToLine:this.handleGoToLine}))))}}]),n}(r.a.Component)],ct=function(e){Object(b.a)(n,e);var t=Object(y.a)(n);function n(){var e;Object(s.a)(this,n);for(var a=arguments.length,r=new Array(a),i=0;it.name.toLowerCase()?1:0};case"date":return function(e,t){return e.datet.date?1:0};case"public":return function(e,t){var n=e.public?1:0,a=t.public?1:0;return Math.sign(n-a)};case"check":return function(e,n){var a=t.has(e.id)?1:0,r=t.has(n.id)?1:0;return Math.sign(a-r)};default:throw new Error("unknown sortKey")}}(n,t);return e.slice().sort((function(e,t){return i(t,e)*r}))}function wt(e){var t=new lt.a({fields:["name"]});return t.addAll(Object.entries(e).map((function(e){var t=Object(S.a)(e,2);return{id:t[0],name:t[1].name}}))),t}function kt(e){var t=e.sortDir,n=e.selected,a=e.update;return r.a.createElement(r.a.Fragment,null,r.a.createElement("span",{onClick:function(){return a(n?"up"===t?"down":"up":t)},className:n?"current-sort-key":""},"up"===t?"\u25b2":"\u25bc"))}function St(e){for(var t,n=0,a=Object.values(e);nt)&&(t=i)}return t}ae("gists",ft()),d.subscribe("gists",(function(){ie("gists",ft())}));var jt=function(e){Object(b.a)(n,e);var t=Object(y.a)(n);function n(e){var a;Object(s.a)(this,n),(a=t.call(this,e)).handleNewGists=function(e){a.setState({gists:e,index:wt(e)})},a.toggleCheck=function(e){var t=new Set(a.state.checks);t.has(e)?t.delete(e):t.add(e),a.setState({checks:t})},a.onUserStatusChange=function(){a.forceUpdate(),a.context.userManager.getUserData()&&a.loadGists()},a.updateSort=function(e,t){a.setState({sortDir:t,sortKey:e,newFilter:!1})},a.handleKeyDown=function(e){a.setState({shift:e.shiftKey})},a.handleKeyUp=function(e){a.setState({shift:e.shiftKey})},a.loadGists=Object(g.a)(f.a.mark((function e(){var t,n,r,i,o,s;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.context,n=t.addError,r=t.github,a.setState({loading:!0}),e.prev=2,i=a.state.shift?{}:a.state.gists,o=St(i),e.next=7,r.getUserGists(o);case 7:s=e.sent,yt(s.reduce((function(e,t){return e[t.id]={name:t.description,date:t.updated_at,public:t.public},e}),Object(k.a)({},i))),e.next=15;break;case 12:e.prev=12,e.t0=e.catch(2),n("could not load gists: ".concat(e.t0));case 15:a.setState({loading:!1});case 16:case"end":return e.stop()}}),e,null,[[2,12]])}))),a.deleteSelected=Object(g.a)(f.a.mark((function e(){var t,n,r,i,o,s,c,l,u,d;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=a.state,n=t.checks,r=t.gists,i=[],n.forEach((function(e,t){r[e]&&i.push(e)})),o=a.context,s=o.addError,c=o.github,a.setState({loading:!0}),l=0,u=i;case 6:if(!(l=0&&r.a.createElement(r.a.Fragment,null,r.a.createElement("p",null,r.a.createElement(E,{className:"foobar",placeholder:"search:",value:c,onChange:function(t){e.setState({filter:t,newFilter:""!==t.trim()})}})),r.a.createElement("div",{className:"gists"},r.a.createElement("table",null,r.a.createElement("thead",null,r.a.createElement("tr",null,r.a.createElement("th",null,r.a.createElement(kt,{selected:"check"===p,sortDir:u,update:function(t){return e.updateSort("check",t)}})),r.a.createElement("th",null,r.a.createElement(kt,{selected:"name"===p,sortDir:u,update:function(t){return e.updateSort("name",t)}})),r.a.createElement("th",null,r.a.createElement(kt,{selected:"date"===p,sortDir:u,update:function(t){return e.updateSort("date",t)}})),r.a.createElement("th",null,r.a.createElement(kt,{selected:"public"===p,sortDir:u,update:function(t){return e.updateSort("public",t)}})))),r.a.createElement("tbody",null,g.map((function(t,n){return r.a.createElement("tr",{key:"g".concat(n)},r.a.createElement("td",null,r.a.createElement("input",{type:"checkbox",id:"gc".concat(n),checked:i.has(t.id),onChange:function(){return e.toggleCheck(t.id)}}),r.a.createElement("label",{htmlFor:"gc".concat(n)})),r.a.createElement("td",null,r.a.createElement("a",{onClick:e.clearBackup,href:"".concat(window.location.origin,"?src=").concat(encodeURIComponent(t.id))},t.name)),r.a.createElement("td",null,t.date.substring(0,10)),r.a.createElement("td",null,t.public?"":"\ud83d\udd12"))}))))),r.a.createElement("div",null,r.a.createElement("button",{onClick:this.deleteSelected},"Delete Selected Gists"))))}},{key:"render",value:function(){return this.context.userManager.getUserData()?this.renderLoad():this.renderLogin()}}]),n}(r.a.Component);function Ot(e){var t=Object(a.useState)(""),n=Object(S.a)(t,2),i=n[0],o=n[1],s=Object(a.useContext)(F).addError;return r.a.createElement("div",null,r.a.createElement("div",{style:{height:"100px"}},r.a.createElement(qe,{value:i,onValueChange:o})),r.a.createElement("p",null,r.a.createElement("button",{onClick:function(){var t=e.onLoad;try{ve(JSON.parse(i)),t()}catch(n){s("bad json: ".concat(n))}}},"Load JSON")))}function xt(e){var t=Object(a.useState)(""),n=Object(S.a)(t,2),i=n[0],o=n[1],s=Object(a.useContext)(F).addError;function c(){return(c=Object(g.a)(f.a.mark((function t(){var n,a;return f.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.onLoad,t.prev=1,t.next=4,fetch(i);case 4:return a=t.sent,t.next=7,a.json();case 7:ve(t.sent),n(),t.next=15;break;case 12:t.prev=12,t.t0=t.catch(1),s("could not load url: ".concat(t.t0));case 15:case"end":return t.stop()}}),t,null,[[1,12]])})))).apply(this,arguments)}return r.a.createElement("div",null,r.a.createElement(E,{value:i,onChange:o,placeholder:"url-to-json"}),r.a.createElement("p",null,r.a.createElement("button",{onClick:function(){return c.apply(this,arguments)}},"Load URL")))}function Ct(e){var t=e.heading,n=e.children;return r.a.createElement("div",{className:"section"},r.a.createElement("div",{className:"section-heading"},t),r.a.createElement("div",{className:"section-content"},n))}function Mt(e){var t=e.data,n=e.onLoad,a=e.onClose;return r.a.createElement(L,{title:"Load",className:"fixed-size-dialog",onClose:a},r.a.createElement(Ct,{heading:"Load Gist"},r.a.createElement(jt,{data:t,onLoad:n})),r.a.createElement(Ct,{heading:"Load URL"},r.a.createElement(xt,{data:t,onLoad:n})),r.a.createElement(Ct,{heading:"Load JSON"},r.a.createElement(Ot,{data:t,onLoad:n})))}jt.contextType=F;var zt=n(52),Nt=n(54),Lt=new TextEncoder,It=new TextDecoder,Ut=function(e){return e.startsWith("cb64,")||e.startsWith("b64,")};function Tt(e){var t=e.startsWith("cb64,"),n=t?"cb64,":"b64,",a=e.substr(n.length).replace(/-/g,"+").replace(/_/g,"/"),r=new Uint8Array(Object(zt.a)(a)),i=t?Object(Nt.b)(r):r,o=It.decode(i);return JSON.parse(o)}var _t=/^[a-z0-9]+$/i,At=function(e){return _t.test(e)};function Dt(e,t){return Pt.apply(this,arguments)}function Pt(){return(Pt=Object(g.a)(f.a.mark((function e(t,n){var a,r,i,o,s;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!At(t)){e.next=9;break}return e.next=3,n.getGist(t);case 3:return a=e.sent,r=a.data,i=a.rawData,e.abrupt("return",{data:r,id:t,rawData:i});case 9:if(!Ut(t)){e.next=13;break}return e.abrupt("return",{data:Tt(t)});case 13:return e.next=15,fetch(t);case 15:return o=e.sent,e.next=18,o.json();case 18:return s=e.sent,e.abrupt("return",{data:s});case 20:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Rt(e){var t=e.gistId,n=t||"f793cb359f2571409983351a6099d5d1";return r.a.createElement("div",null,r.a.createElement("div",{className:"markdown"},r.a.createElement("p",null,"You can embed a jsGist by creating an iframe pointing to"," ",r.a.createElement("code",null,"https://jsgist.org/embed.html?src=")," "," where"," ",r.a.createElement("code",null,"")," "," is one of the forms above. Either"," ",r.a.createElement("code",null,"?src=")," ","or"," ",r.a.createElement("code",null,"?src=")," ","or"," ",r.a.createElement("code",null,"?src=")," ",". You can also add "," ",r.a.createElement("code",null,"noheader=true")," "," if you don't want the header to appear. You can also just run them directly rather than put in an iframe. ",r.a.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://jsgist.org/embed.html?src=".concat(n)},"[example]")," ",r.a.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://jsgist.org/embed.html?src=".concat(n,"&noheader=true")},"[example no header]")),!!t&&r.a.createElement(r.a.Fragment,null,r.a.createElement("p",null,"For example to embed the current gist:"),r.a.createElement("pre",null,r.a.createElement("code",{style:{userSelect:"all"}},''))),r.a.createElement("p",null)))}var Gt=function(){var e=document.createElement("a");return e.style.display="none",document.body.appendChild(e),function(t,n){var a=window.URL.createObjectURL(t);e.href=a,e.download=n,e.click()}}();function Kt(e){return e.split("\n").map((function(e){return" ".concat(e)})).join("\n")}function Ft(e,t){var n=e.files,a=Pe(n,"index.html","html"),r=Pe(n,"index.js","js","js","javascript"),i=Pe(n,"index.css","css");return t?"\n\x3c!-- begin snippet: js hide: false console: true babel: false --\x3e\n\n\x3c!-- language: lang-js --\x3e\n\n\x3c!-- language: lang-css --\x3e\n\n".concat(Kt(i.content),"\n\n\x3c!-- language: lang-html --\x3e\n\n").concat(Kt(a.content),'\n \n\n\n`\n : `\n\n\n\n\n${indent4(mainJS.content)}\n\n\n\n${indent4(mainCSS.content)}\n\n\n\n${indent4(mainHTML.content)}\n\n\n`;\n\n}\n\nfunction openInCodepen(data) {\n const files = data.files;\n const mainHTML = getOrFind(files, 'index.html', 'html');\n const mainJS = getOrFind(files, 'index.js', 'js', 'js', 'javascript');\n const mainCSS = getOrFind(files, 'index.css', 'css');\n\n const pen = {\n title : data.name,\n description : data.name,\n editors : '101',\n html : mainHTML.content,\n css : mainCSS.content,\n js : mainJS.content,\n };\n\n const elem = document.createElement('div');\n elem.innerHTML = `\n
'\n \n \n \"
\"\n `;\n elem.querySelector('input[name=data]').value = JSON.stringify(pen);\n document.body.appendChild(elem);\n elem.querySelector('form').submit();\n document.body.removeChild(elem);\n}\n\nfunction openInJSFiddle(data) {\n const files = data.files;\n const mainHTML = getOrFind(files, 'index.html', 'html');\n const mainJS = getOrFind(files, 'index.js', 'js', 'js', 'javascript');\n const mainCSS = getOrFind(files, 'index.css', 'css');\n\n const elem = document.createElement('div');\n elem.innerHTML = `\n
\n \n \n \n \n \n \n
\n `;\n elem.querySelector('input[name=html]').value = mainHTML.content;\n elem.querySelector('input[name=css]').value = mainCSS.content;\n elem.querySelector('input[name=js]').value = mainJS.content;\n elem.querySelector('input[name=title]').value = data.name;\n document.body.appendChild(elem);\n elem.querySelector('form').submit();\n document.body.removeChild(elem);\n}\n\nfunction makeHTML(data, asModule) {\n const files = data.files;\n const mainHTML = getOrFind(files, 'index.html', 'html');\n const mainJS = getOrFind(files, 'index.js', 'js', 'js', 'javascript');\n const mainCSS = getOrFind(files, 'index.css', 'css');\n const isModule = asModule !== undefined ? asModule : /\\b(import|async|await)\\b/.test(mainJS.content);\n const module = isModule\n ? ' type=\"module\"'\n : '';\n return `\n\n \n \n \n ${escapeTextForHTMLContent(data.name)}\n \n \n \n${mainHTML.content}\n \n <${'script'}${module}>\n${mainJS.content}\n \n\n`;\n}\n\nexport default class Export extends React.Component {\n constructor(props) {\n super(props);\n const mainJS = getOrFind(props.data.files, 'index.js', 'js', 'js', 'javascript');\n this.state = {\n asModule: /\\bimport\\b/.test(mainJS.content), // random guess\n }\n }\n onChange = (asModule) => {\n this.setState({asModule});\n }\n exportToCodepen = () => {\n openInCodepen(this.props.data);\n }\n exportToJSFiddle = () => {\n openInJSFiddle(this.props.data);\n }\n saveToFile = () => {\n const {data} = this.props;\n const {asModule} = this.state;\n const html = makeHTML(data, asModule);\n const blob = new Blob([html], {type: 'text/html'});\n const filename = `jsgist-${data.name}.html`;\n saveData(blob, filename);\n }\n render() {\n const {data} = this.props;\n const {asModule} = this.state;\n return (\n
\n \n \n

StackOverflow Snippet (copy the code below paste into S.O.)

\n
\n
this.onChange(true)}/>
\n
this.onChange(false)}/>
\n

S.O. does not support es6 modules yet so picking \"As Module\" puts the code in a <script> in the HTML area.

\n
\n
\n
{makeSnippet(data, asModule)}
\n
\n \n
\n
\n

HTML (copy the code below paste into a file)

\n
\n
this.onChange(true)}/>
\n
this.onChange(false)}/>
\n
\n
\n
{makeHTML(data, asModule)}
\n
\n \n \n
\n
\n
\n );\n }\n}","import React from 'react';\nimport {classNames} from '../libs/css-utils.js';\nimport * as gists from '../libs/gists.js';\nimport ServiceContext from '../ServiceContext.js';\n\nexport default class SaveAsGist extends React.Component {\n constructor () {\n super();\n this.state = {\n saving: false,\n secret: false,\n };\n }\n componentDidMount() {\n const {userManager} = this.context;\n userManager.subscribe(this.onPatChange);\n }\n componentWillUnmount() {\n const {userManager} = this.context;\n userManager.unsubscribe(this.onPatChange);\n }\n onPatChange = () => {\n this.forceUpdate();\n }\n toggleSecret = () => {\n this.setState({secret: !this.state.secret});\n }\n saveNew = async() => {\n const {github, addError} = this.context;\n const {secret} = this.state;\n this.setState({saving: true});\n const {data, onSave, onClose} = this.props;\n let success = false;\n try {\n const {id, name, date, public: _public} = await github.createGist(data, secret);\n gists.addGist(id, name, date, _public);\n onSave(id);\n success = true;\n } catch (e) {\n addError(`could not create gist: ${e}`)\n }\n this.setState({saving: false});\n if (success) {\n onClose();\n }\n }\n saveOverExisting = async() => {\n const {github, addError} = this.context;\n this.setState({saving: true});\n const {data, gistId, onClose} = this.props;\n let success = false;\n try {\n const {id, name, date, public: _public} = await github.updateGist(gistId, data);\n gists.addGist(id, name, date, _public);\n success = true;\n } catch (e) {\n addError(`could not update gist: ${e}`)\n }\n this.setState({saving: false});\n if (success) {\n onClose();\n }\n }\n forkAndSave = async() => {\n const {github, addError} = this.context;\n const {data, gistId, onSave, onClose} = this.props;\n const {secret} = this.state;\n this.setState({saving: true});\n let success = false;\n try {\n const {id: newId} = await github.forkGist(gistId, secret);\n const {id, name, date, public: _public} = await github.updateGist(newId, data);\n gists.addGist(id, name, date, _public);\n onSave(id);\n success = true\n } catch (e) {\n addError(`could not fork and update gist: ${e}`);\n }\n this.setState({saving: false});\n if (success) {\n onClose();\n }\n }\n renderLogin() {\n const {userManager} = this.context;\n return (\n
\n Login with github\n
\n );\n }\n renderSave() {\n const {saving, secret} = this.state;\n const {userManager} = this.context;\n const userData = userManager.getUserData();\n const {gistId, gistOwnerId} = this.props;\n const canUpdate = userData && gistId && userData.id === gistOwnerId;\n const canFork = userData && gistId && userData.id !== gistOwnerId;\n return (\n
\n
\n Save to New Gist\n Update Current Gist\n Fork and Save Gist\n
\n
\n
\n \n \n
Warning:\n
    \n
  • You can not change a gist from public to secret
  • \n
  • Secret gists are still publicly accessible they're just unlisted
  • \n
\n (see docs)\n
\n
\n
\n );\n }\n render() {\n const {userManager} = this.context;\n const userData = userManager.getUserData();\n return userData ? this.renderSave() : this.renderLogin();\n }\n}\n\nSaveAsGist.contextType = ServiceContext;","import React from 'react';\n\nexport default function SaveAsJSON(props) {\n const {data} = props;\n return (\n
\n
\n Copy the text below, paste into the load ui or put somewhere on the net\n and make your own URL with {window.location.origin}?src=url-to-json.\n
\n
{JSON.stringify(data)}
\n \n
\n );\n}","import React from 'react';\n\nimport {jsonToCompressedBase64} from '../libs/compression.js';\n\nexport default function SaveAsURL(props) {\n const {data} = props;\n const src = jsonToCompressedBase64(data);\n const url = `${window.location.origin}?src=${encodeURIComponent(src)}`;\n return url.length < 8000\n ? (\n
\n
Copy / bookmark the link below
\n {url}\n
\n )\n : (\n
\n Too large to save as URL\n
\n )\n ;\n}\n","import React from 'react';\nimport Dialog from './Dialog.js';\nimport Embed from './Embed.js';\nimport Export from './Export.js';\nimport SaveAsGist from './SaveAsGist.js';\nimport SaveAsJSON from './SaveAsJSON.js';\nimport SaveAsURL from './SaveAsURL.js';\nimport Section from './Section.js';\n\nexport default function Save(props) {\n const {data, gistId, gistOwnerId, onSave, onClose} = props;\n return (\n \n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n )\n}\n","import React from 'react';\n\nimport Dialog from './Dialog.js';\nimport Section from './Section.js';\nimport ServiceContext from '../ServiceContext.js';\n\nimport verticalIcon from '../icons/vertical-layout.svg';\nimport horizontalIcon from '../icons/horizontal-layout.svg';\nimport twoByTwoIcon from '../icons/two-by-two-layout.svg';\nimport tabbedIcon from '../icons/tabbed-layout.svg';\n\nimport {classNames} from '../libs/css-utils.js';\nimport * as uiModel from '../libs/ui-model.js';\n\nfunction RadioOption(props) {\n const {children, onChange, selected} = props;\n return (\n
\n {children}\n
\n );\n}\n\nfunction Radio(props) {\n const {selected, onChange, children} = props;\n\n const newChildren = React.Children.map(children, (child) => {\n if (!React.isValidElement(child)) {\n return null;\n }\n\n const {result} = child.props;\n const isSelected = result === selected;\n\n //const id = childNdx;\n //childNdx += 1;\n return React.cloneElement(child, {\n //...child.props,\n selected: isSelected,\n onChange: () => onChange(result),\n });\n });\n\n return (\n
\n {newChildren}\n
\n );\n}\n\nfunction Checkbox(props) {\n const {id, label, checked, onChange} = props;\n const elemId = `checkbox-${id}`;\n return (\n
\n onChange(e.target.checked)}\n />\n \n
\n );\n}\n\nclass Logout extends React.Component {\n componentDidMount() {\n const {userManager} = this.context;\n userManager.subscribe(this.handleChange);\n }\n componentWillUnmount() {\n const {userManager} = this.context;\n userManager.unsubscribe(this.handleChange);\n }\n handleChange = () => {\n this.forceUpdate();\n }\n handleLogout = () => {\n const {userManager} = this.context;\n userManager.logout();\n }\n render() {\n const {userManager} = this.context;\n const userData = userManager.getUserData();\n return (!!userData &&\n
\n
Logged in as: \n {!!userData.login && }\n {!!userData.avatar_url && \"avatar\"/}\n
\n \n
\n );\n }\n}\n\nLogout.contextType = ServiceContext;\n\nexport default class Settings extends React.Component {\n //constructor(props) {\n // super(props);\n //}\n componentDidMount() {\n uiModel.subscribe(this.handleChange);\n }\n componentWillUnmount() {\n uiModel.unsubscribe(this.handleChange);\n }\n handleChange = () => {\n this.forceUpdate();\n }\n handleLayoutChange = (v) => {\n uiModel.set('layout', v);\n }\n handleEditorChange = (v) => {\n uiModel.set('editor', v);\n }\n handleLineNumbersChange = (v) => {\n uiModel.set('lineNumbers', v);\n }\n handleTabsChange = (v) => {\n uiModel.set('tabs', v);\n }\n handleShowWhitespaceChange = (v) => {\n uiModel.set('showWhitespace', v);\n }\n render() {\n const {onClose} = this.props;\n const {userManager} = this.context;\n const userData = userManager.getUserData();\n return (\n \n { !!userData && }\n
\n
\n \n \"vertical\"/\n \"horizontal\"/\n \"2x2\"\n \"tabbed\"\n \n
\n
\n
\n
\n \n
Monaco
\n
CodeMirror
\n
\n \n \n \n
\n
\n
\n );\n }\n}\n\nSettings.contextType = ServiceContext;\n","import React from 'react';\n\nexport default function Toolbar(props) {\n const {\n toolbarFns,\n fullscreen,\n } = props;\n const {\n handleRun,\n handleStop,\n handleSave,\n handleNew,\n handleLoad,\n handleFullscreen,\n handleSettings,\n handleHelp,\n } = toolbarFns;\n return (\n
\n \n \n \n \n \n \n \n \n
\n );\n}","import SubscriptionManager from './SubscriptionManager.ts';\n\nconst kUserManagerKey = 'foobar'; // not important\n\nexport default class UserManager {\n constructor({\n oauthManager,\n github,\n addError,\n }) {\n this.oauthManager = oauthManager;\n this.github = github;\n this.subscriptionManager = new SubscriptionManager();\n this.addError = addError;\n oauthManager.subscribe(this._handleNewAuth);\n this._handleNewAuth();\n this.userData = undefined;\n }\n /*\n {\n \"login\": \"greggman\",\n \"id\": 234804,\n \"node_id\": \"MDQ6VXNlcjIzNDgwNA==\",\n \"avatar_url\": \"https://avatars2.githubusercontent.com/u/234804?v=4\",\n \"gravatar_id\": \"\",\n \"url\": \"https://api.github.com/users/greggman\",\n \"html_url\": \"https://github.com/greggman\",\n \"followers_url\": \"https://api.github.com/users/greggman/followers\",\n \"following_url\": \"https://api.github.com/users/greggman/following{/other_user}\",\n \"gists_url\": \"https://api.github.com/users/greggman/gists{/gist_id}\",\n \"starred_url\": \"https://api.github.com/users/greggman/starred{/owner}{/repo}\",\n \"subscriptions_url\": \"https://api.github.com/users/greggman/subscriptions\",\n \"organizations_url\": \"https://api.github.com/users/greggman/orgs\",\n \"repos_url\": \"https://api.github.com/users/greggman/repos\",\n \"events_url\": \"https://api.github.com/users/greggman/events{/privacy}\",\n \"received_events_url\": \"https://api.github.com/users/greggman/received_events\",\n \"type\": \"User\",\n \"site_admin\": false,\n \"name\": \"Greggman\",\n \"company\": null,\n \"blog\": \"http://games.greggman.com\",\n \"location\": \"Earth\",\n \"email\": \"github@greggman.com\",\n \"hireable\": null,\n \"bio\": \"30 years of games\\r\\n5 years of Chrome\",\n \"twitter_username\": null,\n \"public_repos\": 283,\n \"public_gists\": 80,\n \"followers\": 1037,\n \"following\": 3,\n \"created_at\": \"2010-04-01T08:48:05Z\",\n \"updated_at\": \"2020-10-24T06:05:24Z\"\n }\n */\n getUserData() {\n return this.userData;\n }\n _handleNewAuth = async() => {\n this.userData = undefined;\n const pat = this.oauthManager.pat();\n this.github.setPat(pat);\n if (pat) {\n try {\n const data = await this.github.getAuthenticatedUser();\n this.userData = data;\n } catch (e) {\n this.addError(e);\n }\n }\n this.subscriptionManager.notify(kUserManagerKey);\n }\n login = () => {\n this.oauthManager.login();\n }\n logout = () => {\n this.oauthManager.logout();\n this.github.setPat()\n }\n subscribe(fn) {\n this.subscriptionManager.subscribe(kUserManagerKey, fn);\n }\n unsubscribe(fn) {\n this.subscriptionManager.unsubscribe(kUserManagerKey, fn);\n }\n cleanup() {\n this.oauthManager.unsubscribe(this._handleNewAuth);\n }\n}\n\n","import React from 'react';\n\nimport EditLine from './EditLine.js';\n// import Footer from './Footer.js';\nimport {storageManager} from '../globals.js';\nimport GitHub from '../libs/GitHub.js';\nimport Head from './Head.js';\nimport Help from './Help.js';\nimport IDE from './IDE.js';\nimport Load from './Load.js';\nimport {isGistId, loadGistFromSrc} from '../libs/loader.js';\nimport {LogManager} from './Log.js';\nimport * as model from '../libs/model.js';\nimport Save from './Save.js';\nimport ServiceContext from '../ServiceContext.js';\nimport Settings from './Settings.js';\nimport Toolbar from './Toolbar.js';\nimport * as uiModel from '../libs/ui-model.js';\nimport UserManager from '../libs/UserManager.js';\nimport * as winMsgMgr from '../libs/WindowMessageManager';\nimport query from '../libs/start-query.js';\n\nimport './App.css';\nimport { classNames } from '../libs/css-utils.js';\n\nconst noJSX = () => [];\nconst darkMatcher = window.matchMedia('(prefers-color-scheme: dark)');\n\nclass App extends React.Component {\n constructor(props) {\n super();\n this.state = {\n path: window.location.pathname,\n dark: darkMatcher.matches,\n fullscreen: !!query.fullscreen,\n loading: false,\n dialog: noJSX,\n gistId: '',\n messages: [],\n userData: {},\n updateVersion: 0,\n };\n this.github = new GitHub();\n this.oauthManager = props.oauthManager;\n this.backupManager = props.backupManager;\n this.logManager = new LogManager();\n this.userManager = new UserManager({\n oauthManager: this.oauthManager,\n github: this.github,\n addError: this.addError,\n });\n this.toolbarFns = {\n handleRun: this.handleRun,\n handleStop: this.handleStop,\n handleSave: this.handleSave,\n handleNew: this.handleNew,\n handleLoad: this.handleLoad,\n handleSettings: this.handleSettings,\n handleFullscreen: this.handleFullscreen,\n handleHelp: this.handleHelp,\n };\n }\n componentWillUnmount() {\n uiModel.unsubscribe(this.handleUIChange);\n this.userManager.cleanup();\n }\n componentDidMount() {\n uiModel.subscribe(this.handleUIChange);\n winMsgMgr.on('newGist', null, this.handleNewGist);\n this.github.addEventListener('userdata', (e) => {\n this.setState({\n userData: e.data,\n });\n });\n model.add('path', window.location.pathname);\n model.subscribe('path', (newValue) => {\n window.history.pushState({}, '', newValue);\n this.setState({\n path: newValue,\n });\n });\n // I still am not sure how I'm supposed to handle this.\n // Putting my model in the state itself seems wrong\n // and doesn't actually help since I'd have to \n // generate an entirely new state object to change any\n // nested property.\n //\n // Storing the data outside I see no way to tell\n // components to re-render except to call forceUpdate\n // which all the documentation says \"if you call this\n // you're doing it wrong\".\n //\n // Redux is a joke. 50 lines code needed to set\n // a single field. Repeat those 50 lines for every field.\n // Things like redux-tools make it less to type those\n // 50 lines but they still execute 50 to 500 lines of code\n // just to set a single value.\n model.subscribe(model.filesVersionKey, _ => {\n this.forceUpdate();\n });\n // this is a hack because I can't figure out how to\n // update the CodeMirror areas\n model.subscribe('updateVersion', _ => {\n this.setState({updateVersion: this.state.updateVersion + 1});\n });\n\n darkMatcher.addEventListener('change', () => {\n this.setState({dark: darkMatcher.matches});\n });\n\n if (query.newGist) {\n window.history.pushState({}, '', `${window.location.origin}`);\n window.opener.postMessage({type: 'gimmeDaCodez'}, '*');\n return;\n }\n\n const backup = this.backupManager.getBackup();\n let loaded = false;\n if (backup) {\n try {\n const data = JSON.parse(backup);\n if (data.href === window.location.href) {\n model.setData(data.data);\n const url = new URL(data.href);\n const {src} = Object.fromEntries(new URLSearchParams(url.search).entries());\n if (isGistId(src)) {\n this.setState({gistId: src, gistOwnerId: data.gistOwnerId});\n }\n loaded = true;\n this.addInfo('loaded backup from local storage')\n }\n } catch (e) {\n console.log('bad backup')\n }\n this.backupManager.clearBackup();\n }\n if (!loaded) {\n if (query.src) {\n this.loadData(query.src);\n }\n }\n this.updateTitle();\n }\n componentDidUpdate() {\n this.updateTitle();\n }\n updateTitle() {\n const data = model.getData();\n document.title = data.name || 'jsGist';\n }\n async loadData(src) {\n this.setState({loading: true});\n let success = true;\n let firstTry = true;\n for (;;) {\n try {\n const {data, id, rawData} = await loadGistFromSrc(src, this.github);\n model.setData(data);\n if (id) {\n this.setState({\n gistId: src,\n gistOwnerId: rawData?.owner?.id,\n });\n }\n break;\n } catch (e) {\n if (firstTry) {\n this.userManager.logout();\n firstTry = false;\n } else {\n success = false;\n console.warn(e);\n this.addError(`could not load jsGist: src=${src} ${e}`);\n break;\n }\n }\n }\n this.setState({loading: false});\n if (success) {\n this.handleRun();\n }\n }\n handleUIChange = () => {\n this.forceUpdate();\n }\n handleNewGist = (data) => {\n let success = true;\n try {\n model.setData(data);\n this.backupManager.clearBackup();\n } catch (e) {\n success = false;\n console.warn(e);\n this.addError(`could create new jsGist: ${e}`);\n }\n if (success) {\n this.handleRun();\n }\n };\n addMsg = (msg, className) => {\n switch (className) {\n case 'error':\n console.error(msg);\n break;\n default:\n console.log(msg);\n break;\n }\n this.setState({messages: [{msg: msg.toString(), className}, ...this.state.messages]});\n setTimeout(() => {\n this.setState({messages: this.state.messages.slice(0, this.state.messages.length - 1)});\n }, 5000);\n }\n addInfo = (msg) => this.addMsg(msg, 'info');\n addError = (msg) => this.addMsg(msg, 'error');\n closeDialog = () => {\n this.setState({dialog: noJSX});\n }\n registerRunnerAPI = (api) => {\n this.runnerAPI = api;\n this.handleStop();\n }\n handleNew = async() => {\n //this.backupManager.clearBackup();\n //window.location.href = window.location.origin; // causes a reload\n window.open('/?newGist=1', '_blank');\n }\n handleRun = async () => {\n this.backupManager.setBackup(JSON.stringify({\n href: window.location.href,\n data: model.getData(),\n gistOwnerId: this.state.gistOwnerId,\n }));\n this.logManager.clear();\n console.clear();\n this.runnerAPI.run(model.getData());\n }\n handleStop = async () => {\n this.runnerAPI.run(model.getBlankData(), true);\n }\n handleSave = async () => {\n this.setState({dialog: this.renderSave});\n }\n handleSettings = () => {\n this.setState({dialog: this.renderSettings});\n }\n handleFullscreen = () => {\n this.setState({fullscreen: !this.state.fullscreen});\n }\n handleHelp = () => {\n this.setState({dialog: this.renderHelp});\n }\n handleLoad = () => {\n this.setState({dialog: this.renderLoad});\n }\n handleOnLoad = async() => {\n this.setState({dialog: noJSX});\n this.handleRun();\n }\n handleOnSave = (gistId) => {\n window.history.pushState({}, '', `${window.location.origin}?src=${gistId}`);\n this.setState({\n gistId,\n gistOwnerId: this.userManager.getUserData().id,\n });\n }\n handleAbort = () => {\n this.abort();\n };\n renderHelp = () => {\n return ();\n }\n renderSettings = () => {\n return (\n \n );\n }\n renderLoad = () => {\n return (\n \n );\n }\n renderSave = () => {\n const data = model.getData();\n return (\n \n );\n }\n render() {\n const data = model.getData();\n const {\n loading,\n dialog,\n updateVersion: hackKey,\n userData,\n fullscreen,\n } = this.state;\n const editor = uiModel.get().editor;\n return (\n
\n \n
\n
\n
\n
\n model.setName(v)} />\n {!!userData.name && }\n {!!userData.avatarURL && \"avatar\"/}\n
\n
\n
\n \n \n
\n
\n {\n !loading &&\n
\n \n
\n }\n
\n {/*\n \n */}\n {dialog()}\n
\n {\n this.state.messages.map(({msg, className}, i) => (
{msg}
))\n }\n
\n
\n
\n );\n }\n}\n\nexport default App;\n","const backupKey = 'backup';\r\n\r\nexport default class BackupManager {\r\n #storageManager;\r\n\r\n constructor(storageManager) {\r\n this.#storageManager = storageManager;\r\n }\r\n getBackup() {\r\n return this.#storageManager.get(backupKey);\r\n }\r\n setBackup(data) {\r\n this.#storageManager.set(backupKey, data);\r\n }\r\n clearBackup() {\r\n this.#storageManager.delete(backupKey);\r\n }\r\n}","\nimport {clientId} from '../globals.js';\nimport {createURL} from './url.js';\nimport {createPopup} from './utils';\nimport StorageManager from './StorageManager';\nimport * as winMsgMgr from './WindowMessageManager';\n\nconst patKey = 'pat';\n\nconst getTokenURL = process.env.REACT_APP_OAUTH_HELPER_URL;\nif (!getTokenURL) {\n throw Error ('must set environment variable: OAUTH_HELPER_URL');\n}\n\nexport default class OAuthManager {\n private _popup?: Window;\n private _state?: string;\n private _storageManager: StorageManager;\n\n constructor(storageManager: StorageManager) {\n this._popup = undefined;\n this._state = undefined; // last state sent to auth\n this._storageManager = storageManager;\n winMsgMgr.on('auth', null, (data: any) => {\n this._closePopup();\n if (data.state === this._state) {\n this.requestToken(data);\n }\n });\n }\n // TODO: rename this and decide if Github should be connected\n pat() {\n return this._storageManager.get(patKey);\n }\n subscribe(fn: () => void) {\n this._storageManager.subscribe(patKey, fn);\n }\n unsubscribe(fn: () => void) {\n this._storageManager.unsubscribe(patKey, fn);\n }\n _closePopup() {\n if (this._popup) {\n this._popup.close();\n this._popup = undefined;\n }\n }\n requestToken = async (auth: any) => {\n try {\n const params = {\n client: clientId,\n code: auth.code,\n };\n const url = createURL(getTokenURL, params);\n const req = await fetch(url);\n const data = await req.json();\n if (!data.access_token) {\n throw new Error(JSON.stringify(data));\n }\n this._storageManager.set(patKey, data.access_token);\n } catch (e) {\n console.error(e);\n }\n }\n logout = () => {\n this._storageManager.delete(patKey);\n }\n login = () => {\n this._closePopup();\n this._state = `${Date.now()}-${Math.random()}`; // does this need to special? Seems like no\n const url = createURL('https://github.com/login/oauth/authorize', {\n client_id: clientId,\n scope: 'gist',\n state: this._state,\n });\n this._popup = createPopup(url);\n }\n}","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read https://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.0/8 are considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\n\nexport function register(config) {\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener('load', () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n 'This web app is being served cache-first by a service ' +\n 'worker. To learn more, visit https://bit.ly/CRA-PWA'\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl, config) {\n navigator.serviceWorker\n .register(swUrl)\n .then(registration => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n 'New content is available and will be used when all ' +\n 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log('Content is cached for offline use.');\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch(error => {\n console.error('Error during service worker registration:', error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl, {\n headers: { 'Service-Worker': 'script' },\n })\n .then(response => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get('content-type');\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf('javascript') === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log(\n 'No internet connection found. App is running in offline mode.'\n );\n });\n}\n\nexport function unregister() {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready\n .then(registration => {\n registration.unregister();\n })\n .catch(error => {\n console.error(error.message);\n });\n }\n}\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport {storageManager} from './globals.js';\nimport './index.css';\nimport './scrollbars.js';\nimport App from './components/App';\nimport BackupManager from './components/BackupManager.js';\nimport OAuthManager from './libs/OAuthManager';\nimport * as serviceWorker from './serviceWorker';\n\nconst oauthManager = new OAuthManager(storageManager);\nconst backupManager = new BackupManager(storageManager);\n\nReactDOM.render(\n \n \n ,\n document.getElementById('root')\n);\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: https://bit.ly/CRA-PWA\nserviceWorker.unregister();\n","module.exports = __webpack_public_path__ + \"static/media/vertical-layout.f248a432.svg\";","module.exports = __webpack_public_path__ + \"static/media/horizontal-layout.e3f3298b.svg\";","module.exports = __webpack_public_path__ + \"static/media/two-by-two-layout.23605ce8.svg\";","module.exports = __webpack_public_path__ + \"static/media/tabbed-layout.8a8b9bc8.svg\";"],"sourceRoot":""} \ No newline at end of file diff --git a/static/js/main.6a1bf393.chunk.js b/static/js/main.6a1bf393.chunk.js deleted file mode 100644 index be0a363..0000000 --- a/static/js/main.6a1bf393.chunk.js +++ /dev/null @@ -1,2 +0,0 @@ -(this.webpackJsonpjsgist=this.webpackJsonpjsgist||[]).push([[0],{178:function(e,t,n){},179:function(e,t,n){"use strict";n.r(t);var a=n(0),r=n.n(a),i=n(76),o=n.n(i),s=n(3),c=n(5),l=n(16),u=function(){function e(){Object(s.a)(this,e),this.itemToSubscriptionMap=void 0,this.itemToSubscriptionMap=new Map}return Object(c.a)(e,[{key:"subscribe",value:function(e,t){this.unsubscribe(e,t);var n=this.itemToSubscriptionMap.get(e);n||(n=[],this.itemToSubscriptionMap.set(e,n)),n.push(t)}},{key:"unsubscribe",value:function(e,t){var n=this.itemToSubscriptionMap.get(e);if(n){var a=n.indexOf(t);a>=0&&(n.splice(a,1),0===n.length&&this.itemToSubscriptionMap.delete(e))}}},{key:"notify",value:function(e){var t=this.itemToSubscriptionMap.get(e);if(t){var n,a=Object(l.a)(t.slice());try{for(a.s();!(n=a.n()).done;){(0,n.value)()}}catch(r){a.e(r)}finally{a.f()}}}}]),e}();var d=new(function(){function e(t){var n=this;Object(s.a)(this,e),this.prefix=void 0,this.subscriptionManager=void 0,this._handleNewValue=function(e){var t=e.key;if(t&&t.startsWith(n.prefix)){var a=t.substr(n.prefix.length);n.subscriptionManager.notify(a)}},this.prefix="".concat(t,"-"),this.subscriptionManager=new u,window.addEventListener("storage",this._handleNewValue)}return Object(c.a)(e,[{key:"_addPrefix",value:function(e){return"".concat(this.prefix).concat(e)}},{key:"subscribe",value:function(e,t){this.subscriptionManager.subscribe(e,t)}},{key:"unsubscribe",value:function(e,t){this.subscriptionManager.unsubscribe(e,t)}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this._addPrefix(e);if(t){var a=sessionStorage.getItem(n);if(a)return a}return localStorage.getItem(n)}},{key:"set",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=this._addPrefix(e);n&&sessionStorage.setItem(a,t),localStorage.setItem(a,t),this.subscriptionManager.notify(e)}},{key:"delete",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this._addPrefix(e);t&&sessionStorage.removeItem(n),localStorage.removeItem(n),this.subscriptionManager.notify(e)}},{key:"cleanup",value:function(){window.removeEventListener("storage",this._handleNewValue)}}]),e}())("jsgist"),h=(n(94),n(95),document.createElement("div"));h.setAttribute("style","width:30px;height:30px;"),h.classList.add("scrollbar-test");var m=document.createElement("div");m.setAttribute("style","width:100%;height:40px"),h.appendChild(m),document.body.appendChild(h),30-h.firstChild.clientWidth&&document.body.classList.add("layout-scrollbar-obtrusive"),document.body.removeChild(h);var p=n(1),f=n.n(p),g=n(8),v=n(42),b=n(6),y=n(7);function E(e){return r.a.createElement("input",{type:"text",onChange:function(t){e.onChange(t.target.value)},placeholder:e.placeholder,value:e.value})}var w=n(20),k=n(4),S=n(9),j=n(53),O="/*bug-in-github-api-content-can-not-be-empty*/";function x(e){return e.content.startsWith(O)?e.content.substr(O.length):e.content}function C(e){var t=JSON.parse(e.files["jsGist.json"].content);return t.filenames?t.files=t.filenames.map((function(t){return{name:t,content:x(e.files[t])}})):t.files=Object.entries(e.files).filter((function(e){return"jsGist.json"!==Object(S.a)(e,1)[0]})).map((function(e){var t=Object(S.a)(e,2);return{name:t[0],content:x(t[1])}})).concat(t.files||[]),t}function M(e,t,n){var a=e.files.reduce((function(e,t){return e[t.name]={content:t.content.trim()?t.content:"".concat(O).concat(t.content)},e}),{}),r=Object(k.a)({},e),i={};if(a["jsGist.json"]=i,Object.keys(a).length===e.files.length+1?(delete r.files,r.filenames=e.files.map((function(e){return e.name}))):a={"jsGist.json":i},i.content=JSON.stringify(r),n){var o=Object.keys(a).map((function(e){return e.toLowerCase()}));if(!(o.includes("readme.md")||o.includes("readme.txt")||o.includes("readme"))){var s="## ".concat(e.name,"\n\n[view on jsgist](").concat(window.location.origin,"?src=").concat(n,")");a["README.md"]={content:s}}for(var c=0,l=Object.entries(a);c1&&void 0!==i[1]&&i[1],a=M(t,n),e.next=4,this.authorizedOctokit.gists.create(a);case 4:return r=e.sent,this._updateUserData(r.data),e.next=8,this.updateGist(r.data.id,t);case 8:return e.abrupt("return",e.sent);case 9:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"updateGist",value:function(){var e=Object(g.a)(f.a.mark((function e(t,n){var a,r;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=M(n,!1,t),e.next=3,this.authorizedOctokit.gists.update(a);case 3:return r=e.sent,e.abrupt("return",{id:r.data.id,name:r.data.description,date:r.data.updated_at,public:r.data.public});case 5:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}()},{key:"forkGist",value:function(){var e=Object(g.a)(f.a.mark((function e(t){var n;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.authorizedOctokit.gists.fork({gist_id:t});case 2:return n=e.sent,e.abrupt("return",{id:n.data.id});case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"deleteGist",value:function(){var e=Object(g.a)(f.a.mark((function e(t){var n;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.authorizedOctokit.gists.delete({gist_id:t});case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"createGistComment",value:function(){var e=Object(g.a)(f.a.mark((function e(t,n){var a;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.authorizedOctokit.gists.createComment({gist_id:t,body:n});case 2:if(!((a=e.sent).status<200||a.status>=300)){e.next=5;break}throw new Error(a.message);case 5:return e.abrupt("return",a.data);case 6:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}()},{key:"octokit",get:function(){return this.authorizedOctokit||this.unAuthorizedOctokit}}]),n}(Object(w.a)(EventTarget));function N(){return r.a.createElement("div",{className:"head"},r.a.createElement("div",null,r.a.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:window.location.origin},r.a.createElement("img",{src:"/resources/images/logo-small.svg",alt:"logo"}),window.location.hostname)),r.a.createElement("div",{className:"fix-help-contribute"},r.a.createElement("div",{className:"octocat"},r.a.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://github.com/greggman/jsgist/"},r.a.createElement("img",{alt:"github",src:"/resources/images/octocat-icon.svg"})))))}var L=function(e){Object(b.a)(n,e);var t=Object(y.a)(n);function n(){var e;Object(s.a)(this,n);for(var a=arguments.length,r=new Array(a),i=0;i--"),"."),r.a.createElement("p",null,"Example: ",r.a.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://jsgist.org/?src=f793cb359f2571409983351a6099d5d1"},"https://jsgist.org/?src=f793cb359f2571409983351a6099d5d1"))),r.a.createElement("li",null,"Save it manually somewhere else.",r.a.createElement("p",null,"If there's some other service that will provide a string via http get then copy and save the JSON there then create a URL in the form of ",r.a.createElement("code",null,"https://jsgist.org/?src="),". Note: you may have to escape the URL.")),r.a.createElement("li",null,"Save it as a bookmark or link",r.a.createElement("p",null,"In the SaveAs dialog there's a link that contains all the data for your benchmark.")))))}var U=n(15),T=n.n(U),_=n(14),A=n.n(_),D=n(18),P=/([a-z])([A-Z])/g,R=function(e,t,n){return"".concat(t,"-").concat(n)},G=function(e){return e.replace(P,R).toLowerCase()};function K(){for(var e=[],t=arguments.length,n=new Array(t),a=0;a=0?e.substr(t+1):e}(t.url||""),":",t.lineNo)))}))))}}]),n}(r.a.Component);function W(e,t){for(var n=new URL(e),a=new URLSearchParams(n.search),r=0,i=Object.entries(t);r=0&&r.splice(i,1),0===r.length&&(a.delete(e),0===a.size&&t&&q.delete(t))}}}function $(e,t,n){var a=e.get(t);if(a){var r,i=Object(l.a)(a);try{for(i.s();!(r=i.n()).done;){(0,r.value)(n)}}catch(o){i.e(o)}finally{i.f()}return!0}return!1}window.addEventListener("message",(function(e){var t=e.data,n=t.type,a=t.data,r=q.get(e.source);r&&$(r,n,a)||$(H,n,a)}));var X=function(e){Object(b.a)(n,e);var t=Object(y.a)(n);function n(e){var a;return Object(s.a)(this,n),(a=t.call(this,e)).handleJSLog=function(e){a.context.logManager.addMsg(e)},a.handleJSError=function(e){a.context.logManager.addMsg(Object(k.a)(Object(k.a)({},e),{},{type:"error",showStack:!0}))},a.handleJSUnhandledRejection=function(e){a.context.logManager.addMsg(Object(k.a)(Object(k.a)({},e),{},{type:"error",showStack:!0}))},a.handleInfoMessages=function(e){a.context.logManager.addMsgs(e)},a.handleGimmeDaCodez=function(){a.iframe.contentWindow.postMessage({type:"run",data:a.data},"*")},a.handleMessage=function(e){var t=e.data,n=t.type,r=t.data,i=a.handlers[n];i&&i(r)},a.runnerRef=r.a.createRef(),a}return Object(c.a)(n,[{key:"componentDidMount",value:function(){var e=this,t=this.props.registerAPI,n=Object.fromEntries(new URLSearchParams(window.location.search).entries()).debug,a=Object(k.a)({},n&&{debug:n});t({run:function(t,n){e.data=t,e.removeIFrame();var r=document.createElement("iframe");e.iframe=r,r.src=W("https://jsgistrunner.devcomments.org/runner-03.html",Object(k.a)({url:"https://jsgist.org/jsgist-runner.js"},a)),n&&(r.style.background="none"),e.runnerRef.current.appendChild(r)}}),B("gimmeDaCodez",null,this.handleGimmeDaCodez),B("jsLog",null,this.handleJSLog),B("jsError",null,this.handleJSError),B("jsUnhandledRejection",null,this.handleJSUnhandledRejection),B("infoMessages",null,this.handleInfoMessages)}},{key:"removeIFrame",value:function(){this.iframe&&(this.iframe.remove(),this.iframe.src="about:blank",this.iframe=void 0)}},{key:"componentWillUnmount",value:function(){this.removeIFrame(),Y("gimmeDaCodez",null,this.handleGimmeDaCodez),Y("jsLog",null,this.handleJSLog),Y("jsError",null,this.handleJSError),Y("jsUnhandledRejection",null,this.handleJSUnhandledRejection),Y("infoMessages",null,this.handleInfoMessages)}},{key:"render",value:function(){return r.a.createElement("div",{className:"runner",ref:this.runnerRef})}}]),n}(r.a.Component);X.contextType=F;var Z=n(79),Q=(new T.a).compile(Z),ee={};function te(e){var t=ee[e]||{subscriptions:new Set};return ee[e]=t,t}function ne(e,t){var n=te(e);return void 0!==t&&(n.value=t),n}function ae(e){return ee[e].value}function re(e,t){var n=ee[e];if(!n)throw new Error("no such track value: ".concat(e));n.value=t;var a,r=Object(v.a)(n.subscriptions.keys()),i=Object(l.a)(r);try{for(i.s();!(a=i.n()).done;){(0,a.value)(t,e)}}catch(o){i.e(o)}finally{i.f()}}function ie(e,t){te(e).subscriptions.add(t)}function oe(e,t){te(e).subscriptions.delete(t)}var se,ce={name:"My jsGist",settings:{},files:[{name:"index.html",content:""},{name:"index.css",content:""},{name:"index.js",content:""}]};function le(){var e="".concat(window.location.origin,"/resources/images/logo.svg");return JSON.parse(JSON.stringify({name:"jsGist",settings:{},files:[{name:"index.html",content:""},{name:"index.css",content:"\n html, body {\n margin: 0;\n width: 100%;\n height: 100%;\n background-image: url(".concat(e,");\n background-size: contain contain;\n background-position: center center;\n background-repeat: no-repeat no-repeat;\n }\n @media (prefers-color-scheme: dark) {\n html {\n background: #222;\n }\n }\n ")},{name:"index.js",content:""}]}))}function ue(){return se}ne("dataVersion",0),ne("updateVersion",0),ne("filesVersion",0);var de=function(e){return re(e,ae(e)+1)},he=function(e){return de("dataVersion")},me=function(e){return de("filesVersion")};function pe(e,t){se.files[e].name=t,he()}function fe(e,t){se.files[e].content=t,he()}function ge(e){!function(e){if(!Q(e))throw new Error("data not valid:\n".concat(Q.errors.map((function(e){return"".concat(e.message,": ").concat(e.dataPath)}))))}(e),se=e,de("updateVersion"),he(),me()}ge(JSON.parse(JSON.stringify(ce)));var ve,be=Object.fromEntries(new URLSearchParams(window.location.search).entries()),ye=!be.codeMirror&&!/webOS|iPhone|iPad|Android/.test(navigator.userAgent),Ee=!1,we={layout:window.screen.width<540||window.screen.height<540?3:0,editor:ye?"monaco":"codemirror",lineNumbers:!0,tabs:!1,showWhitespace:!1};function ke(e,t){ve[e]=t;var n=JSON.stringify(ve);d.set("ui-settings",n,!0),re("settings",ve)}function Se(){return function(){if(!Ee){Ee=!0;try{if(!(ve=JSON.parse(d.get("ui-settings",!0))))throw new Error("no settings")}catch(i){ve=Object(k.a)({},we)}for(var e=0,t=Object.entries(we);e=0&&(u.matchTags=!0),r.a.createElement(Ne.Controlled,{value:c,options:u,onBeforeChange:function(t,n,a){e.setState({value:a})},onChange:function(e,t,n){o(n)},editorDidMount:this.registerEditor})}}],[{key:"getDerivedStateFromProps",value:function(e,t){return t.hackKey!==e.hackKey?{hackKey:e.hackKey,value:e.value}:null}}]),n}(r.a.Component),Te=n(88);function _e(e,t){var n,a=Object(l.a)(t);try{var r=function(){var t=n.value,a=e.findIndex((function(e){return e.name.toLowerCase().endsWith(t.toLowerCase())}));if(a>=0)return{v:a}};for(a.s();!(n=a.n()).done;){var i=r();if("object"===typeof i)return i.v}}catch(o){a.e(o)}finally{a.f()}return-1}function Ae(e,t){var n=e.findIndex((function(e){return e.name.toLowerCase()===t.toLowerCase}));if(n>=0)return n;for(var a=arguments.length,r=new Array(a>2?a-2:0),i=2;i1?t-1:0),a=1;a=0?e[r]:""}var Pe=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:",";return Object.entries(e).map((function(e){var t=Object(S.a)(e,2),n=t[0],a=t[1];return"".concat(n,"=").concat(a)})).join(t)};var Re=window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)"):{},Ge=function(){};function Ke(e){return Fe.apply(this,arguments)}function Fe(){return(Fe=Object(g.a)(f.a.mark((function e(t){var n;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t);case 2:return n=e.sent,e.next=5,n.text();case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Je,Ve=(Je=function(){var e=Object(g.a)(f.a.mark((function e(t){var n;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,Ke("/types/webgpu/dist/index.d.ts");case 3:n=e.sent,t.languages.typescript.javascriptDefaults.addExtraLib(n,"");case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),function(){var e=!1;e||(e=!0,Je.apply(void 0,arguments))});var We=function(e){Object(b.a)(n,e);var t=Object(y.a)(n);function n(e){var a;Object(s.a)(this,n),(a=t.call(this,e)).handleEditorDidMount=function(e,t){a.editor=e,Ve(t),e.getModel().updateOptions({tabSize:2});var n=a.props.registerAPI;n&&n({goToLine:function(e,t){a.editor.focus(),a.editor.setPosition({lineNumber:e,column:t}),a.editor.revealPosition({lineNumber:e,column:t})},refresh:function(e){},focus:function(e){a.editor.focus()}})},a.registerEditor=function(e){a.editor=e};var r=e.value,i=e.hackKey;return a.state={value:r,hackKey:i},a}return Object(c.a)(n,[{key:"render",value:function(){var e=this.props,t=e.options,n=void 0===t?{}:t,a=e.onValueChange,i=void 0===a?Ge:a,o=e.ui,s=this.state.value,c=Re.matches,l=function(e){var t=((null===e||void 0===e?void 0:e.mode)||"javascript").split("/").pop();return"gfm"===t?"markdown":t}(n.editor).split("/").pop();return r.a.createElement(Te.a,{theme:c?"vs-dark":"light",language:l,value:s,onChange:i,onMount:this.handleEditorDidMount,options:{minimap:{enabled:!1},lineNumbers:o.lineNumbers?"on":"off",glyphMargin:!1,folding:!1,insertSpaces:!o.tabs,renderWhitespace:o.showWhitespace}})}}],[{key:"getDerivedStateFromProps",value:function(e,t){return t.hackKey!==e.hackKey?{hackKey:e.hackKey,value:e.value}:null}}]),n}(r.a.Component),He=function(e){Object(b.a)(n,e);var t=Object(y.a)(n);function n(){var e;Object(s.a)(this,n);for(var a=arguments.length,r=new Array(a),i=0;i=0&&(t[0]=e[0]),a.state.showResult&&(t[1]=e[1]),a.state.showLow&&(t[2]=e[2]),a.setState({sizes:e,lastSizes:t}),ke("layoutTabbed",a.state)},a.handleGoToLine=function(e){a.files.forEach((function(t,n){if(t.goToLine(e)){var r=a.props.data.files.findIndex((function(t){return t.name===e.section}));r!==a.state.currentNdx&&a.handleOnChange(r)}}))},a.handleOnChange=function(e){var t=a.state.currentNdx===e?-1:e;a.setState({currentNdx:t,sizes:it(a.state.sizes,a.state.lastSizes,0,t>=0)}),ke("layoutTabbed",a.state)},a.toggleShowLog=function(){var e=!a.state.showLog;a.setState({showLog:e,sizes:it(a.state.sizes,a.state.lastSizes,2,e)}),ke("layoutTabbed",a.state)},a.toggleShowResult=function(){var e=!a.state.showResult;a.setState({showResult:e,sizes:it(a.state.sizes,a.state.lastSizes,1,e)}),ke("layoutTabbed",a.state)};var r=Se().layoutTabbed;return a.state=rt(r)?r:{showResult:!0,showLog:!0,currentNdx:2,sizes:[.45,.45,.1],lastSizes:[.45,.45,.1]},a.files=new Map,a.fileToKeyMap=new Map,a}return Object(c.a)(n,[{key:"getFileKey",value:function(e){var t=this.fileToKeyMap.get(e);return t||(t="".concat(Date.now(),"-").concat(Math.random()),this.fileToKeyMap.set(e,t)),t}},{key:"componentDidUpdate",value:function(){this.previousNdx!==this.state.currentNdx&&(this.previousNdx=this.state.currentNdx,this.files.forEach((function(e){e.refresh(),e.focus()})))}},{key:"render",value:function(){var e=this,t=this.props,n=t.hackKey,a=t.data,i=t.registerRunnerAPI,o=this.state,s=o.showResult,c=o.showLog,l=o.sizes,u=o.currentNdx,d=Object(k.a)({},!s&&{display:"none"}),h=Object(k.a)({},!c&&{display:"none"});return r.a.createElement("div",{className:"layout-tabbed"},r.a.createElement("div",{className:"layout-tabbed-top"},r.a.createElement("div",{className:"tab-tabs"},a.files.map((function(t,n){var a="ca".concat(e.getFileKey(t));return r.a.createElement(r.a.Fragment,{key:a},r.a.createElement("input",{type:"radio",name:"tabbed-files",id:a,checked:n===u,onClick:function(t){return e.handleOnChange(n)},onChange:function(e){return e}}),r.a.createElement("label",{htmlFor:a},t.name))})),r.a.createElement("input",{type:"checkbox",checked:s,onChange:this.toggleShowResult,id:"result"}),r.a.createElement("label",{htmlFor:"result"},"result"),r.a.createElement("input",{type:"checkbox",checked:c,onChange:this.toggleShowLog,id:"log"}),r.a.createElement("label",{htmlFor:"log"},"log"))),r.a.createElement(A.a,{direction:"vertical",minSize:0,sizes:l,onSetSizes:this.setSizes},r.a.createElement("div",{className:"tab-content"},a.files.map((function(t,a){var i="ca".concat(e.getFileKey(t));return r.a.createElement("div",{key:i,style:Object(k.a)({},a!==u&&{display:"none"})},r.a.createElement(Be,{hackKey:n,desc:"filename",title:t.name,value:t.content,onTitleChange:function(e){return pe(a,e)},onValueChange:function(e){return fe(a,e)},register:e.handleRegister,unregister:e.handleUnregister}))}))),r.a.createElement("div",{className:"layout-tabbed-result",style:d},r.a.createElement(X,{registerAPI:i})),r.a.createElement("div",{className:"layout-tabbed-log",style:h},r.a.createElement(V,{onGoToLine:this.handleGoToLine}))))}}]),n}(r.a.Component)],st=function(e){Object(b.a)(n,e);var t=Object(y.a)(n);function n(){var e;Object(s.a)(this,n);for(var a=arguments.length,r=new Array(a),i=0;it.name.toLowerCase()?1:0};case"date":return function(e,t){return e.datet.date?1:0};case"public":return function(e,t){var n=e.public?1:0,a=t.public?1:0;return Math.sign(n-a)};case"check":return function(e,n){var a=t.has(e.id)?1:0,r=t.has(n.id)?1:0;return Math.sign(a-r)};default:throw new Error("unknown sortKey")}}(n,t);return e.slice().sort((function(e,t){return i(t,e)*r}))}function Et(e){var t=new ct.a({fields:["name"]});return t.addAll(Object.entries(e).map((function(e){var t=Object(S.a)(e,2);return{id:t[0],name:t[1].name}}))),t}function wt(e){var t=e.sortDir,n=e.selected,a=e.update;return r.a.createElement(r.a.Fragment,null,r.a.createElement("span",{onClick:function(){return a(n?"up"===t?"down":"up":t)},className:n?"current-sort-key":""},"up"===t?"\u25b2":"\u25bc"))}function kt(e){for(var t,n=0,a=Object.values(e);nt)&&(t=i)}return t}ne("gists",pt()),d.subscribe("gists",(function(){re("gists",pt())}));var St=function(e){Object(b.a)(n,e);var t=Object(y.a)(n);function n(e){var a;Object(s.a)(this,n),(a=t.call(this,e)).handleNewGists=function(e){a.setState({gists:e,index:Et(e)})},a.toggleCheck=function(e){var t=new Set(a.state.checks);t.has(e)?t.delete(e):t.add(e),a.setState({checks:t})},a.onUserStatusChange=function(){a.forceUpdate(),a.context.userManager.getUserData()&&a.loadGists()},a.updateSort=function(e,t){a.setState({sortDir:t,sortKey:e,newFilter:!1})},a.handleKeyDown=function(e){a.setState({shift:e.shiftKey})},a.handleKeyUp=function(e){a.setState({shift:e.shiftKey})},a.loadGists=Object(g.a)(f.a.mark((function e(){var t,n,r,i,o,s;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.context,n=t.addError,r=t.github,a.setState({loading:!0}),e.prev=2,i=a.state.shift?{}:a.state.gists,o=kt(i),e.next=7,r.getUserGists(o);case 7:s=e.sent,bt(s.reduce((function(e,t){return e[t.id]={name:t.description,date:t.updated_at,public:t.public},e}),Object(k.a)({},i))),e.next=15;break;case 12:e.prev=12,e.t0=e.catch(2),n("could not load gists: ".concat(e.t0));case 15:a.setState({loading:!1});case 16:case"end":return e.stop()}}),e,null,[[2,12]])}))),a.deleteSelected=Object(g.a)(f.a.mark((function e(){var t,n,r,i,o,s,c,l,u,d;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=a.state,n=t.checks,r=t.gists,i=[],n.forEach((function(e,t){r[e]&&i.push(e)})),o=a.context,s=o.addError,c=o.github,a.setState({loading:!0}),l=0,u=i;case 6:if(!(l=0&&r.a.createElement(r.a.Fragment,null,r.a.createElement("p",null,r.a.createElement(E,{className:"foobar",placeholder:"search:",value:c,onChange:function(t){e.setState({filter:t,newFilter:""!==t.trim()})}})),r.a.createElement("div",{className:"gists"},r.a.createElement("table",null,r.a.createElement("thead",null,r.a.createElement("tr",null,r.a.createElement("th",null,r.a.createElement(wt,{selected:"check"===p,sortDir:u,update:function(t){return e.updateSort("check",t)}})),r.a.createElement("th",null,r.a.createElement(wt,{selected:"name"===p,sortDir:u,update:function(t){return e.updateSort("name",t)}})),r.a.createElement("th",null,r.a.createElement(wt,{selected:"date"===p,sortDir:u,update:function(t){return e.updateSort("date",t)}})),r.a.createElement("th",null,r.a.createElement(wt,{selected:"public"===p,sortDir:u,update:function(t){return e.updateSort("public",t)}})))),r.a.createElement("tbody",null,g.map((function(t,n){return r.a.createElement("tr",{key:"g".concat(n)},r.a.createElement("td",null,r.a.createElement("input",{type:"checkbox",id:"gc".concat(n),checked:i.has(t.id),onChange:function(){return e.toggleCheck(t.id)}}),r.a.createElement("label",{htmlFor:"gc".concat(n)})),r.a.createElement("td",null,r.a.createElement("a",{onClick:e.clearBackup,href:"".concat(window.location.origin,"?src=").concat(encodeURIComponent(t.id))},t.name)),r.a.createElement("td",null,t.date.substring(0,10)),r.a.createElement("td",null,t.public?"":"\ud83d\udd12"))}))))),r.a.createElement("div",null,r.a.createElement("button",{onClick:this.deleteSelected},"Delete Selected Gists"))))}},{key:"render",value:function(){return this.context.userManager.getUserData()?this.renderLoad():this.renderLogin()}}]),n}(r.a.Component);function jt(e){var t=Object(a.useState)(""),n=Object(S.a)(t,2),i=n[0],o=n[1],s=Object(a.useContext)(F).addError;return r.a.createElement("div",null,r.a.createElement("div",{style:{height:"100px"}},r.a.createElement(He,{value:i,onValueChange:o})),r.a.createElement("p",null,r.a.createElement("button",{onClick:function(){var t=e.onLoad;try{ge(JSON.parse(i)),t()}catch(n){s("bad json: ".concat(n))}}},"Load JSON")))}function Ot(e){var t=Object(a.useState)(""),n=Object(S.a)(t,2),i=n[0],o=n[1],s=Object(a.useContext)(F).addError;function c(){return(c=Object(g.a)(f.a.mark((function t(){var n,a;return f.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.onLoad,t.prev=1,t.next=4,fetch(i);case 4:return a=t.sent,t.next=7,a.json();case 7:ge(t.sent),n(),t.next=15;break;case 12:t.prev=12,t.t0=t.catch(1),s("could not load url: ".concat(t.t0));case 15:case"end":return t.stop()}}),t,null,[[1,12]])})))).apply(this,arguments)}return r.a.createElement("div",null,r.a.createElement(E,{value:i,onChange:o,placeholder:"url-to-json"}),r.a.createElement("p",null,r.a.createElement("button",{onClick:function(){return c.apply(this,arguments)}},"Load URL")))}function xt(e){var t=e.heading,n=e.children;return r.a.createElement("div",{className:"section"},r.a.createElement("div",{className:"section-heading"},t),r.a.createElement("div",{className:"section-content"},n))}function Ct(e){var t=e.data,n=e.onLoad,a=e.onClose;return r.a.createElement(L,{title:"Load",className:"fixed-size-dialog",onClose:a},r.a.createElement(xt,{heading:"Load Gist"},r.a.createElement(St,{data:t,onLoad:n})),r.a.createElement(xt,{heading:"Load URL"},r.a.createElement(Ot,{data:t,onLoad:n})),r.a.createElement(xt,{heading:"Load JSON"},r.a.createElement(jt,{data:t,onLoad:n})))}St.contextType=F;var Mt=n(52),zt=n(54),Nt=new TextEncoder,Lt=new TextDecoder,It=function(e){return e.startsWith("cb64,")||e.startsWith("b64,")};function Ut(e){var t=e.startsWith("cb64,"),n=t?"cb64,":"b64,",a=e.substr(n.length).replace(/-/g,"+").replace(/_/g,"/"),r=new Uint8Array(Object(Mt.a)(a)),i=t?Object(zt.b)(r):r,o=Lt.decode(i);return JSON.parse(o)}var Tt=/^[a-z0-9]+$/i,_t=function(e){return Tt.test(e)};function At(e,t){return Dt.apply(this,arguments)}function Dt(){return(Dt=Object(g.a)(f.a.mark((function e(t,n){var a,r,i,o,s;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!_t(t)){e.next=9;break}return e.next=3,n.getGist(t);case 3:return a=e.sent,r=a.data,i=a.rawData,e.abrupt("return",{data:r,id:t,rawData:i});case 9:if(!It(t)){e.next=13;break}return e.abrupt("return",{data:Ut(t)});case 13:return e.next=15,fetch(t);case 15:return o=e.sent,e.next=18,o.json();case 18:return s=e.sent,e.abrupt("return",{data:s});case 20:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Pt(e){var t=e.gistId,n=t||"f793cb359f2571409983351a6099d5d1";return r.a.createElement("div",null,r.a.createElement("div",{className:"markdown"},r.a.createElement("p",null,"You can embed a jsGist by creating an iframe pointing to"," ",r.a.createElement("code",null,"https://jsgist.org/embed.html?src=")," "," where"," ",r.a.createElement("code",null,"")," "," is one of the forms above. Either"," ",r.a.createElement("code",null,"?src=")," ","or"," ",r.a.createElement("code",null,"?src=")," ","or"," ",r.a.createElement("code",null,"?src=")," ",". You can also add "," ",r.a.createElement("code",null,"noheader=true")," "," if you don't want the header to appear. You can also just run them directly rather than put in an iframe. ",r.a.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://jsgist.org/embed.html?src=".concat(n)},"[example]")," ",r.a.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://jsgist.org/embed.html?src=".concat(n,"&noheader=true")},"[example no header]")),!!t&&r.a.createElement(r.a.Fragment,null,r.a.createElement("p",null,"For example to embed the current gist:"),r.a.createElement("pre",null,r.a.createElement("code",{style:{userSelect:"all"}},''))),r.a.createElement("p",null)))}var Rt=function(){var e=document.createElement("a");return e.style.display="none",document.body.appendChild(e),function(t,n){var a=window.URL.createObjectURL(t);e.href=a,e.download=n,e.click()}}();function Gt(e){return e.split("\n").map((function(e){return" ".concat(e)})).join("\n")}function Kt(e,t){var n=e.files,a=De(n,"index.html","html"),r=De(n,"index.js","js","js","javascript"),i=De(n,"index.css","css");return t?"\n\x3c!-- begin snippet: js hide: false console: true babel: false --\x3e\n\n\x3c!-- language: lang-js --\x3e\n\n\x3c!-- language: lang-css --\x3e\n\n".concat(Gt(i.content),"\n\n\x3c!-- language: lang-html --\x3e\n\n").concat(Gt(a.content),'\n \n\n\n`\n : `\n\n\n\n\n${indent4(mainJS.content)}\n\n\n\n${indent4(mainCSS.content)}\n\n\n\n${indent4(mainHTML.content)}\n\n\n`;\n\n}\n\nfunction openInCodepen(data) {\n const files = data.files;\n const mainHTML = getOrFind(files, 'index.html', 'html');\n const mainJS = getOrFind(files, 'index.js', 'js', 'js', 'javascript');\n const mainCSS = getOrFind(files, 'index.css', 'css');\n\n const pen = {\n title : data.name,\n description : data.name,\n editors : '101',\n html : mainHTML.content,\n css : mainCSS.content,\n js : mainJS.content,\n };\n\n const elem = document.createElement('div');\n elem.innerHTML = `\n
'\n \n \n \"
\"\n `;\n elem.querySelector('input[name=data]').value = JSON.stringify(pen);\n document.body.appendChild(elem);\n elem.querySelector('form').submit();\n document.body.removeChild(elem);\n}\n\nfunction openInJSFiddle(data) {\n const files = data.files;\n const mainHTML = getOrFind(files, 'index.html', 'html');\n const mainJS = getOrFind(files, 'index.js', 'js', 'js', 'javascript');\n const mainCSS = getOrFind(files, 'index.css', 'css');\n\n const elem = document.createElement('div');\n elem.innerHTML = `\n
\n \n \n \n \n \n \n
\n `;\n elem.querySelector('input[name=html]').value = mainHTML.content;\n elem.querySelector('input[name=css]').value = mainCSS.content;\n elem.querySelector('input[name=js]').value = mainJS.content;\n elem.querySelector('input[name=title]').value = data.name;\n document.body.appendChild(elem);\n elem.querySelector('form').submit();\n document.body.removeChild(elem);\n}\n\nfunction makeHTML(data, asModule) {\n const files = data.files;\n const mainHTML = getOrFind(files, 'index.html', 'html');\n const mainJS = getOrFind(files, 'index.js', 'js', 'js', 'javascript');\n const mainCSS = getOrFind(files, 'index.css', 'css');\n const isModule = asModule !== undefined ? asModule : /\\b(import|async|await)\\b/.test(mainJS.content);\n const module = isModule\n ? ' type=\"module\"'\n : '';\n return `\n\n \n \n \n ${escapeTextForHTMLContent(data.name)}\n \n \n \n${mainHTML.content}\n \n <${'script'}${module}>\n${mainJS.content}\n \n\n`;\n}\n\nexport default class Export extends React.Component {\n constructor(props) {\n super(props);\n const mainJS = getOrFind(props.data.files, 'index.js', 'js', 'js', 'javascript');\n this.state = {\n asModule: /\\bimport\\b/.test(mainJS.content), // random guess\n }\n }\n onChange = (asModule) => {\n this.setState({asModule});\n }\n exportToCodepen = () => {\n openInCodepen(this.props.data);\n }\n exportToJSFiddle = () => {\n openInJSFiddle(this.props.data);\n }\n saveToFile = () => {\n const {data} = this.props;\n const {asModule} = this.state;\n const html = makeHTML(data, asModule);\n const blob = new Blob([html], {type: 'text/html'});\n const filename = `jsgist-${data.name}.html`;\n saveData(blob, filename);\n }\n render() {\n const {data} = this.props;\n const {asModule} = this.state;\n return (\n
\n \n \n

StackOverflow Snippet (copy the code below paste into S.O.)

\n
\n
this.onChange(true)}/>
\n
this.onChange(false)}/>
\n

S.O. does not support es6 modules yet so picking \"As Module\" puts the code in a <script> in the HTML area.

\n
\n
\n
{makeSnippet(data, asModule)}
\n
\n \n
\n
\n

HTML (copy the code below paste into a file)

\n
\n
this.onChange(true)}/>
\n
this.onChange(false)}/>
\n
\n
\n
{makeHTML(data, asModule)}
\n
\n \n \n
\n
\n
\n );\n }\n}","import React from 'react';\nimport {classNames} from '../libs/css-utils.js';\nimport * as gists from '../libs/gists.js';\nimport ServiceContext from '../ServiceContext.js';\n\nexport default class SaveAsGist extends React.Component {\n constructor () {\n super();\n this.state = {\n saving: false,\n secret: false,\n };\n }\n componentDidMount() {\n const {userManager} = this.context;\n userManager.subscribe(this.onPatChange);\n }\n componentWillUnmount() {\n const {userManager} = this.context;\n userManager.unsubscribe(this.onPatChange);\n }\n onPatChange = () => {\n this.forceUpdate();\n }\n toggleSecret = () => {\n this.setState({secret: !this.state.secret});\n }\n saveNew = async() => {\n const {github, addError} = this.context;\n const {secret} = this.state;\n this.setState({saving: true});\n const {data, onSave, onClose} = this.props;\n let success = false;\n try {\n const {id, name, date, public: _public} = await github.createGist(data, secret);\n gists.addGist(id, name, date, _public);\n onSave(id);\n success = true;\n } catch (e) {\n addError(`could not create gist: ${e}`)\n }\n this.setState({saving: false});\n if (success) {\n onClose();\n }\n }\n saveOverExisting = async() => {\n const {github, addError} = this.context;\n this.setState({saving: true});\n const {data, gistId, onClose} = this.props;\n let success = false;\n try {\n const {id, name, date, public: _public} = await github.updateGist(gistId, data);\n gists.addGist(id, name, date, _public);\n success = true;\n } catch (e) {\n addError(`could not update gist: ${e}`)\n }\n this.setState({saving: false});\n if (success) {\n onClose();\n }\n }\n forkAndSave = async() => {\n const {github, addError} = this.context;\n const {data, gistId, onSave, onClose} = this.props;\n const {secret} = this.state;\n this.setState({saving: true});\n let success = false;\n try {\n const {id: newId} = await github.forkGist(gistId, secret);\n const {id, name, date, public: _public} = await github.updateGist(newId, data);\n gists.addGist(id, name, date, _public);\n onSave(id);\n success = true\n } catch (e) {\n addError(`could not fork and update gist: ${e}`);\n }\n this.setState({saving: false});\n if (success) {\n onClose();\n }\n }\n renderLogin() {\n const {userManager} = this.context;\n return (\n
\n Login with github\n
\n );\n }\n renderSave() {\n const {saving, secret} = this.state;\n const {userManager} = this.context;\n const userData = userManager.getUserData();\n const {gistId, gistOwnerId} = this.props;\n const canUpdate = userData && gistId && userData.id === gistOwnerId;\n const canFork = userData && gistId && userData.id !== gistOwnerId;\n return (\n
\n
\n Save to New Gist\n Update Current Gist\n Fork and Save Gist\n
\n
\n
\n \n \n
Warning:\n
    \n
  • You can not change a gist from public to secret
  • \n
  • Secret gists are still publicly accessible they're just unlisted
  • \n
\n (see docs)\n
\n
\n
\n );\n }\n render() {\n const {userManager} = this.context;\n const userData = userManager.getUserData();\n return userData ? this.renderSave() : this.renderLogin();\n }\n}\n\nSaveAsGist.contextType = ServiceContext;","import React from 'react';\n\nexport default function SaveAsJSON(props) {\n const {data} = props;\n return (\n
\n
\n Copy the text below, paste into the load ui or put somewhere on the net\n and make your own URL with {window.location.origin}?src=url-to-json.\n
\n
{JSON.stringify(data)}
\n \n
\n );\n}","import React from 'react';\n\nimport {jsonToCompressedBase64} from '../libs/compression.js';\n\nexport default function SaveAsURL(props) {\n const {data} = props;\n const src = jsonToCompressedBase64(data);\n const url = `${window.location.origin}?src=${encodeURIComponent(src)}`;\n return url.length < 8000\n ? (\n
\n
Copy / bookmark the link below
\n {url}\n
\n )\n : (\n
\n Too large to save as URL\n
\n )\n ;\n}\n","import React from 'react';\nimport Dialog from './Dialog.js';\nimport Embed from './Embed.js';\nimport Export from './Export.js';\nimport SaveAsGist from './SaveAsGist.js';\nimport SaveAsJSON from './SaveAsJSON.js';\nimport SaveAsURL from './SaveAsURL.js';\nimport Section from './Section.js';\n\nexport default function Save(props) {\n const {data, gistId, gistOwnerId, onSave, onClose} = props;\n return (\n \n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n )\n}\n","import React from 'react';\n\nimport Dialog from './Dialog.js';\nimport Section from './Section.js';\nimport ServiceContext from '../ServiceContext.js';\n\nimport verticalIcon from '../icons/vertical-layout.svg';\nimport horizontalIcon from '../icons/horizontal-layout.svg';\nimport twoByTwoIcon from '../icons/two-by-two-layout.svg';\nimport tabbedIcon from '../icons/tabbed-layout.svg';\n\nimport {classNames} from '../libs/css-utils.js';\nimport * as uiModel from '../libs/ui-model.js';\n\nfunction RadioOption(props) {\n const {children, onChange, selected} = props;\n return (\n
\n {children}\n
\n );\n}\n\nfunction Radio(props) {\n const {selected, onChange, children} = props;\n\n const newChildren = React.Children.map(children, (child) => {\n if (!React.isValidElement(child)) {\n return null;\n }\n\n const {result} = child.props;\n const isSelected = result === selected;\n\n //const id = childNdx;\n //childNdx += 1;\n return React.cloneElement(child, {\n //...child.props,\n selected: isSelected,\n onChange: () => onChange(result),\n });\n });\n\n return (\n
\n {newChildren}\n
\n );\n}\n\nfunction Checkbox(props) {\n const {id, label, checked, onChange} = props;\n const elemId = `checkbox-${id}`;\n return (\n
\n onChange(e.target.checked)}\n />\n \n
\n );\n}\n\nclass Logout extends React.Component {\n componentDidMount() {\n const {userManager} = this.context;\n userManager.subscribe(this.handleChange);\n }\n componentWillUnmount() {\n const {userManager} = this.context;\n userManager.unsubscribe(this.handleChange);\n }\n handleChange = () => {\n this.forceUpdate();\n }\n handleLogout = () => {\n const {userManager} = this.context;\n userManager.logout();\n }\n render() {\n const {userManager} = this.context;\n const userData = userManager.getUserData();\n return (!!userData &&\n
\n
Logged in as: \n {!!userData.login && }\n {!!userData.avatar_url && \"avatar\"/}\n
\n \n
\n );\n }\n}\n\nLogout.contextType = ServiceContext;\n\nexport default class Settings extends React.Component {\n //constructor(props) {\n // super(props);\n //}\n componentDidMount() {\n uiModel.subscribe(this.handleChange);\n }\n componentWillUnmount() {\n uiModel.unsubscribe(this.handleChange);\n }\n handleChange = () => {\n this.forceUpdate();\n }\n handleLayoutChange = (v) => {\n uiModel.set('layout', v);\n }\n handleEditorChange = (v) => {\n uiModel.set('editor', v);\n }\n handleLineNumbersChange = (v) => {\n uiModel.set('lineNumbers', v);\n }\n handleTabsChange = (v) => {\n uiModel.set('tabs', v);\n }\n handleShowWhitespaceChange = (v) => {\n uiModel.set('showWhitespace', v);\n }\n render() {\n const {onClose} = this.props;\n const {userManager} = this.context;\n const userData = userManager.getUserData();\n return (\n \n { !!userData && }\n
\n
\n \n \"vertical\"/\n \"horizontal\"/\n \"2x2\"\n \"tabbed\"\n \n
\n
\n
\n
\n \n
Monaco
\n
CodeMirror
\n
\n \n \n \n
\n
\n
\n );\n }\n}\n\nSettings.contextType = ServiceContext;\n","import React from 'react';\n\nexport default function Toolbar(props) {\n const {\n toolbarFns,\n fullscreen,\n } = props;\n const {\n handleRun,\n handleStop,\n handleSave,\n handleNew,\n handleLoad,\n handleFullscreen,\n handleSettings,\n handleHelp,\n } = toolbarFns;\n return (\n
\n \n \n \n \n \n \n \n \n
\n );\n}","import SubscriptionManager from './SubscriptionManager.ts';\n\nconst kUserManagerKey = 'foobar'; // not important\n\nexport default class UserManager {\n constructor({\n oauthManager,\n github,\n addError,\n }) {\n this.oauthManager = oauthManager;\n this.github = github;\n this.subscriptionManager = new SubscriptionManager();\n this.addError = addError;\n oauthManager.subscribe(this._handleNewAuth);\n this._handleNewAuth();\n this.userData = undefined;\n }\n /*\n {\n \"login\": \"greggman\",\n \"id\": 234804,\n \"node_id\": \"MDQ6VXNlcjIzNDgwNA==\",\n \"avatar_url\": \"https://avatars2.githubusercontent.com/u/234804?v=4\",\n \"gravatar_id\": \"\",\n \"url\": \"https://api.github.com/users/greggman\",\n \"html_url\": \"https://github.com/greggman\",\n \"followers_url\": \"https://api.github.com/users/greggman/followers\",\n \"following_url\": \"https://api.github.com/users/greggman/following{/other_user}\",\n \"gists_url\": \"https://api.github.com/users/greggman/gists{/gist_id}\",\n \"starred_url\": \"https://api.github.com/users/greggman/starred{/owner}{/repo}\",\n \"subscriptions_url\": \"https://api.github.com/users/greggman/subscriptions\",\n \"organizations_url\": \"https://api.github.com/users/greggman/orgs\",\n \"repos_url\": \"https://api.github.com/users/greggman/repos\",\n \"events_url\": \"https://api.github.com/users/greggman/events{/privacy}\",\n \"received_events_url\": \"https://api.github.com/users/greggman/received_events\",\n \"type\": \"User\",\n \"site_admin\": false,\n \"name\": \"Greggman\",\n \"company\": null,\n \"blog\": \"http://games.greggman.com\",\n \"location\": \"Earth\",\n \"email\": \"github@greggman.com\",\n \"hireable\": null,\n \"bio\": \"30 years of games\\r\\n5 years of Chrome\",\n \"twitter_username\": null,\n \"public_repos\": 283,\n \"public_gists\": 80,\n \"followers\": 1037,\n \"following\": 3,\n \"created_at\": \"2010-04-01T08:48:05Z\",\n \"updated_at\": \"2020-10-24T06:05:24Z\"\n }\n */\n getUserData() {\n return this.userData;\n }\n _handleNewAuth = async() => {\n this.userData = undefined;\n const pat = this.oauthManager.pat();\n this.github.setPat(pat);\n if (pat) {\n try {\n const data = await this.github.getAuthenticatedUser();\n this.userData = data;\n } catch (e) {\n this.addError(e);\n }\n }\n this.subscriptionManager.notify(kUserManagerKey);\n }\n login = () => {\n this.oauthManager.login();\n }\n logout = () => {\n this.oauthManager.logout();\n this.github.setPat()\n }\n subscribe(fn) {\n this.subscriptionManager.subscribe(kUserManagerKey, fn);\n }\n unsubscribe(fn) {\n this.subscriptionManager.unsubscribe(kUserManagerKey, fn);\n }\n cleanup() {\n this.oauthManager.unsubscribe(this._handleNewAuth);\n }\n}\n\n","import React from 'react';\n\nimport EditLine from './EditLine.js';\n// import Footer from './Footer.js';\nimport {storageManager} from '../globals.js';\nimport GitHub from '../libs/GitHub.js';\nimport Head from './Head.js';\nimport Help from './Help.js';\nimport IDE from './IDE.js';\nimport Load from './Load.js';\nimport {isGistId, loadGistFromSrc} from '../libs/loader.js';\nimport {LogManager} from './Log.js';\nimport * as model from '../libs/model.js';\nimport Save from './Save.js';\nimport ServiceContext from '../ServiceContext.js';\nimport Settings from './Settings.js';\nimport Toolbar from './Toolbar.js';\nimport * as uiModel from '../libs/ui-model.js';\nimport UserManager from '../libs/UserManager.js';\nimport * as winMsgMgr from '../libs/WindowMessageManager';\nimport query from '../libs/start-query.js';\n\nimport './App.css';\nimport { classNames } from '../libs/css-utils.js';\n\nconst noJSX = () => [];\nconst darkMatcher = window.matchMedia('(prefers-color-scheme: dark)');\n\nclass App extends React.Component {\n constructor(props) {\n super();\n this.state = {\n path: window.location.pathname,\n dark: darkMatcher.matches,\n fullscreen: !!query.fullscreen,\n loading: false,\n dialog: noJSX,\n gistId: '',\n messages: [],\n userData: {},\n updateVersion: 0,\n };\n this.github = new GitHub();\n this.oauthManager = props.oauthManager;\n this.backupManager = props.backupManager;\n this.logManager = new LogManager();\n this.userManager = new UserManager({\n oauthManager: this.oauthManager,\n github: this.github,\n addError: this.addError,\n });\n this.toolbarFns = {\n handleRun: this.handleRun,\n handleStop: this.handleStop,\n handleSave: this.handleSave,\n handleNew: this.handleNew,\n handleLoad: this.handleLoad,\n handleSettings: this.handleSettings,\n handleFullscreen: this.handleFullscreen,\n handleHelp: this.handleHelp,\n };\n }\n componentWillUnmount() {\n uiModel.unsubscribe(this.handleUIChange);\n this.userManager.cleanup();\n }\n componentDidMount() {\n uiModel.subscribe(this.handleUIChange);\n winMsgMgr.on('newGist', null, this.handleNewGist);\n this.github.addEventListener('userdata', (e) => {\n this.setState({\n userData: e.data,\n });\n });\n model.add('path', window.location.pathname);\n model.subscribe('path', (newValue) => {\n window.history.pushState({}, '', newValue);\n this.setState({\n path: newValue,\n });\n });\n // I still am not sure how I'm supposed to handle this.\n // Putting my model in the state itself seems wrong\n // and doesn't actually help since I'd have to \n // generate an entirely new state object to change any\n // nested property.\n //\n // Storing the data outside I see no way to tell\n // components to re-render except to call forceUpdate\n // which all the documentation says \"if you call this\n // you're doing it wrong\".\n //\n // Redux is a joke. 50 lines code needed to set\n // a single field. Repeat those 50 lines for every field.\n // Things like redux-tools make it less to type those\n // 50 lines but they still execute 50 to 500 lines of code\n // just to set a single value.\n model.subscribe(model.filesVersionKey, _ => {\n this.forceUpdate();\n });\n // this is a hack because I can't figure out how to\n // update the CodeMirror areas\n model.subscribe('updateVersion', _ => {\n this.setState({updateVersion: this.state.updateVersion + 1});\n });\n\n darkMatcher.addEventListener('change', () => {\n this.setState({dark: darkMatcher.matches});\n });\n\n if (query.newGist) {\n window.history.pushState({}, '', `${window.location.origin}`);\n window.opener.postMessage({type: 'gimmeDaCodez'}, '*');\n return;\n }\n\n const backup = this.backupManager.getBackup();\n let loaded = false;\n if (backup) {\n try {\n const data = JSON.parse(backup);\n if (data.href === window.location.href) {\n model.setData(data.data);\n const url = new URL(data.href);\n const {src} = Object.fromEntries(new URLSearchParams(url.search).entries());\n if (isGistId(src)) {\n this.setState({gistId: src, gistOwnerId: data.gistOwnerId});\n }\n loaded = true;\n this.addInfo('loaded backup from local storage')\n }\n } catch (e) {\n console.log('bad backup')\n }\n this.backupManager.clearBackup();\n }\n if (!loaded) {\n if (query.src) {\n this.loadData(query.src);\n }\n }\n this.updateTitle();\n }\n componentDidUpdate() {\n this.updateTitle();\n }\n updateTitle() {\n const data = model.getData();\n document.title = data.name || 'jsGist';\n }\n async loadData(src) {\n this.setState({loading: true});\n let success = true;\n let firstTry = true;\n for (;;) {\n try {\n const {data, id, rawData} = await loadGistFromSrc(src, this.github);\n model.setData(data);\n if (id) {\n this.setState({\n gistId: src,\n gistOwnerId: rawData?.owner?.id,\n });\n }\n break;\n } catch (e) {\n if (firstTry) {\n this.userManager.logout();\n firstTry = false;\n } else {\n success = false;\n console.warn(e);\n this.addError(`could not load jsGist: src=${src} ${e}`);\n break;\n }\n }\n }\n this.setState({loading: false});\n if (success) {\n this.handleRun();\n }\n }\n handleUIChange = () => {\n this.forceUpdate();\n }\n handleNewGist = (data) => {\n let success = true;\n try {\n model.setData(data);\n this.backupManager.clearBackup();\n } catch (e) {\n success = false;\n console.warn(e);\n this.addError(`could create new jsGist: ${e}`);\n }\n if (success) {\n this.handleRun();\n }\n };\n addMsg = (msg, className) => {\n switch (className) {\n case 'error':\n console.error(msg);\n break;\n default:\n console.log(msg);\n break;\n }\n this.setState({messages: [{msg: msg.toString(), className}, ...this.state.messages]});\n setTimeout(() => {\n this.setState({messages: this.state.messages.slice(0, this.state.messages.length - 1)});\n }, 5000);\n }\n addInfo = (msg) => this.addMsg(msg, 'info');\n addError = (msg) => this.addMsg(msg, 'error');\n closeDialog = () => {\n this.setState({dialog: noJSX});\n }\n registerRunnerAPI = (api) => {\n this.runnerAPI = api;\n this.handleStop();\n }\n handleNew = async() => {\n //this.backupManager.clearBackup();\n //window.location.href = window.location.origin; // causes a reload\n window.open('/?newGist=1', '_blank');\n }\n handleRun = async () => {\n this.backupManager.setBackup(JSON.stringify({\n href: window.location.href,\n data: model.getData(),\n gistOwnerId: this.state.gistOwnerId,\n }));\n this.logManager.clear();\n console.clear();\n this.runnerAPI.run(model.getData());\n }\n handleStop = async () => {\n this.runnerAPI.run(model.getBlankData(), true);\n }\n handleSave = async () => {\n this.setState({dialog: this.renderSave});\n }\n handleSettings = () => {\n this.setState({dialog: this.renderSettings});\n }\n handleFullscreen = () => {\n this.setState({fullscreen: !this.state.fullscreen});\n }\n handleHelp = () => {\n this.setState({dialog: this.renderHelp});\n }\n handleLoad = () => {\n this.setState({dialog: this.renderLoad});\n }\n handleOnLoad = async() => {\n this.setState({dialog: noJSX});\n this.handleRun();\n }\n handleOnSave = (gistId) => {\n window.history.pushState({}, '', `${window.location.origin}?src=${gistId}`);\n this.setState({\n gistId,\n gistOwnerId: this.userManager.getUserData().id,\n });\n }\n handleAbort = () => {\n this.abort();\n };\n renderHelp = () => {\n return ();\n }\n renderSettings = () => {\n return (\n \n );\n }\n renderLoad = () => {\n return (\n \n );\n }\n renderSave = () => {\n const data = model.getData();\n return (\n \n );\n }\n render() {\n const data = model.getData();\n const {\n loading,\n dialog,\n updateVersion: hackKey,\n userData,\n fullscreen,\n } = this.state;\n const editor = uiModel.get().editor;\n return (\n
\n \n
\n
\n
\n
\n model.setName(v)} />\n {!!userData.name && }\n {!!userData.avatarURL && \"avatar\"/}\n
\n
\n
\n \n \n
\n
\n {\n !loading &&\n
\n \n
\n }\n
\n {/*\n \n */}\n {dialog()}\n
\n {\n this.state.messages.map(({msg, className}, i) => (
{msg}
))\n }\n
\n
\n
\n );\n }\n}\n\nexport default App;\n","const backupKey = 'backup';\r\n\r\nexport default class BackupManager {\r\n #storageManager;\r\n\r\n constructor(storageManager) {\r\n this.#storageManager = storageManager;\r\n }\r\n getBackup() {\r\n return this.#storageManager.get(backupKey);\r\n }\r\n setBackup(data) {\r\n this.#storageManager.set(backupKey, data);\r\n }\r\n clearBackup() {\r\n this.#storageManager.delete(backupKey);\r\n }\r\n}","\nimport {clientId} from '../globals.js';\nimport {createURL} from './url.js';\nimport {createPopup} from './utils';\nimport StorageManager from './StorageManager';\nimport * as winMsgMgr from './WindowMessageManager';\n\nconst patKey = 'pat';\n\nconst getTokenURL = process.env.REACT_APP_OAUTH_HELPER_URL;\nif (!getTokenURL) {\n throw Error ('must set environment variable: OAUTH_HELPER_URL');\n}\n\nexport default class OAuthManager {\n private _popup?: Window;\n private _state?: string;\n private _storageManager: StorageManager;\n\n constructor(storageManager: StorageManager) {\n this._popup = undefined;\n this._state = undefined; // last state sent to auth\n this._storageManager = storageManager;\n winMsgMgr.on('auth', null, (data: any) => {\n this._closePopup();\n if (data.state === this._state) {\n this.requestToken(data);\n }\n });\n }\n // TODO: rename this and decide if Github should be connected\n pat() {\n return this._storageManager.get(patKey);\n }\n subscribe(fn: () => void) {\n this._storageManager.subscribe(patKey, fn);\n }\n unsubscribe(fn: () => void) {\n this._storageManager.unsubscribe(patKey, fn);\n }\n _closePopup() {\n if (this._popup) {\n this._popup.close();\n this._popup = undefined;\n }\n }\n requestToken = async (auth: any) => {\n try {\n const params = {\n client: clientId,\n code: auth.code,\n };\n const url = createURL(getTokenURL, params);\n const req = await fetch(url);\n const data = await req.json();\n if (!data.access_token) {\n throw new Error(JSON.stringify(data));\n }\n this._storageManager.set(patKey, data.access_token);\n } catch (e) {\n console.error(e);\n }\n }\n logout = () => {\n this._storageManager.delete(patKey);\n }\n login = () => {\n this._closePopup();\n this._state = `${Date.now()}-${Math.random()}`; // does this need to special? Seems like no\n const url = createURL('https://github.com/login/oauth/authorize', {\n client_id: clientId,\n scope: 'gist',\n state: this._state,\n });\n this._popup = createPopup(url);\n }\n}","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read https://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.0/8 are considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\n\nexport function register(config) {\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener('load', () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n 'This web app is being served cache-first by a service ' +\n 'worker. To learn more, visit https://bit.ly/CRA-PWA'\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl, config) {\n navigator.serviceWorker\n .register(swUrl)\n .then(registration => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n 'New content is available and will be used when all ' +\n 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log('Content is cached for offline use.');\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch(error => {\n console.error('Error during service worker registration:', error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl, {\n headers: { 'Service-Worker': 'script' },\n })\n .then(response => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get('content-type');\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf('javascript') === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log(\n 'No internet connection found. App is running in offline mode.'\n );\n });\n}\n\nexport function unregister() {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready\n .then(registration => {\n registration.unregister();\n })\n .catch(error => {\n console.error(error.message);\n });\n }\n}\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport {storageManager} from './globals.js';\nimport './index.css';\nimport './scrollbars.js';\nimport App from './components/App';\nimport BackupManager from './components/BackupManager.js';\nimport OAuthManager from './libs/OAuthManager';\nimport * as serviceWorker from './serviceWorker';\n\nconst oauthManager = new OAuthManager(storageManager);\nconst backupManager = new BackupManager(storageManager);\n\nReactDOM.render(\n \n \n ,\n document.getElementById('root')\n);\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: https://bit.ly/CRA-PWA\nserviceWorker.unregister();\n","module.exports = __webpack_public_path__ + \"static/media/vertical-layout.f248a432.svg\";","module.exports = __webpack_public_path__ + \"static/media/horizontal-layout.e3f3298b.svg\";","module.exports = __webpack_public_path__ + \"static/media/two-by-two-layout.23605ce8.svg\";","module.exports = __webpack_public_path__ + \"static/media/tabbed-layout.8a8b9bc8.svg\";"],"sourceRoot":""} \ No newline at end of file