{"version":3,"sources":["App.tsx","serviceWorker.ts","index.tsx"],"names":["require","SomeExamples","initialState","JSON","parse","atob","window","location","hash","slice","e","console","log","calcFirstLineNumber","cellIndex","cellContent","firstLineNumber","index","split","length","Examples","props","className","examples","map","i","title","url","key","onClick","setTimeout","reload","href","Settings","vimEnabled","onChangeVimEnabled","checked","onChange","Cell","cellResult","onChangeText","initialContent","onNewCell","onRemoveCell","focus","onEval","redrawCounter","useState","content","setContent","useEffect","onEvalRef","useRef","current","value","selection","ranges","options","mode","theme","lineNumbers","keyMap","editor","data","onKeyDown","event","shiftKey","getValue","preventDefault","altKey","stdOut","join","returnVal","stringify","err","App","setVim","setCellContent","setRedrawCounter","setErr","cellResults","setCellResults","useCallback","a","cells","c","script","produce","draft","_","fetch","method","body","then","x","json","res","name","stack","btoa","v","t","s","ds","f","splice","Boolean","hostname","match","ReactDOM","render","document","getElementById","navigator","serviceWorker","ready","registration","unregister"],"mappings":"kTAKAA,EAAQ,IACRA,EAAQ,IACRA,EAAQ,IACRA,EAAQ,IACRA,EAAQ,IACRA,EAAQ,IAER,IAAMC,EAAwC,CAC5C,CACE,cACA,8XAEF,CACE,cACA,kUAEF,CACE,6BACA,uiCAQAC,EAA6B,GACjC,IACEA,EAAeC,KAAKC,MAAMC,KAAKC,OAAOC,SAASC,KAAKC,MAAM,KAC1D,MAAOC,IACTC,QAAQC,IAAIV,GAEZ,IAQMW,EAAsB,SAACC,EAAmBC,GAE9C,IADA,IAAIC,EAAkB,EACbC,EAAQ,EAAGA,EAAQH,EAAWG,IACrCD,GAAmBD,EAAYE,GAAOC,MAAM,MAAMC,OAEpD,OAAOH,GAuHHI,EAAW,SAACC,GAChB,OACE,yBAAKC,UAAU,YACb,yCACA,4BACGD,EAAME,SAASC,KAAI,WAAeC,GAAf,uBAAEC,EAAF,KAASC,EAAT,YAClB,4BACE,uBACEC,IAAKH,EACLI,QAAS,kBAAMC,YAAW,kBAAMxB,OAAOC,SAASwB,WAAU,KAC1DC,KAAML,G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EAAD,CACEY,WAAYA,EACZC,mBAAoB,SAAAiE,GAClBxB,EAAOwB,MAGV1B,GAAO,yBAAKpD,UAAU,WAAWoD,GACjC3D,EAAYS,KAAI,SAAC4E,EAAG3E,GACnB,OACE,kBAAC,EAAD,CACEG,IAAKH,EACLgB,eAAgB2D,EAChB5D,aAAc,SAAA6D,GAAC,OACbxB,GAAe,SAACyB,GACd,OAAOf,YAAQe,GAAG,SAAAC,GAChBA,EAAG9E,GAAK4E,SAIdzD,MAAOnB,IAAMV,EAAYI,OAAS,EAClC2B,cAAeA,EACfP,WAAYyC,EAAYvD,GACxBoB,OAAQA,EACRX,WAAYA,EACZlB,gBAAiBH,EAAoBY,EAAGV,GACxC2B,UAAW,WACTmC,GAAe,SAAAyB,GAAC,4BACXA,GADW,CAEd,2DAGJ3D,aAAc,WACZkC,GAAe,SAAAyB,GACb,OAAOf,YAAQe,GAAG,SAAAC,GAChB,IAAMC,EAAID,EAAGE,OAAOhF,EAAG,GACvBd,QAAQC,IAAI,WAAYa,EAAG+E,SAG/B1B,GAAiB,SAAAO,GAAC,OAAIA,EAAI,WAKlC,kBAAC,EAAD,CAAU9D,SAAUtB,MCxJNyG,QACW,cAA7BpG,OAAOC,SAASoG,UAEe,UAA7BrG,OAAOC,SAASoG,UAEhBrG,OAAOC,SAASoG,SAASC,MACvB,2DCZNC,IAASC,OAAO,kBAAC,EAAD,MAASC,SAASC,eAAe,SDmI3C,kBAAmBC,WACrBA,UAAUC,cAAcC,MAAMtB,MAAK,SAAAuB,GACjCA,EAAaC,kB","file":"static/js/main.2b252e1f.chunk.js","sourcesContent":["import React, { useState, useEffect, useCallback, useRef } from \"react\";\nimport { UnControlled as CodeMirror } from \"react-codemirror2\";\nimport \"./App.css\";\nimport Switch from \"react-switch\";\nimport produce from \"immer\";\nrequire(\"codemirror/lib/codemirror.css\");\nrequire(\"codemirror/theme/material.css\");\nrequire(\"codemirror/theme/neat.css\");\nrequire(\"codemirror/mode/clojure/clojure.js\");\nrequire(\"codemirror/keymap/vim.js\");\nrequire(\"codemirror/mode/javascript/javascript.js\");\n\nconst SomeExamples: Array<[string, string]> = [\n [\n \"Hello Emoji\",\n \"/#eyJ2aW1FbmFibGVkIjp0cnVlLCJjZWxsQ29udGVudCI6WyI7OyBQdWxsIGluIGVtb2ppIG9uZSBmcm9tIG5wbVxuKGRlZiBlbW9qaSAobnBtIFwiZW1vamlvbmVcIikpXG5cbjs7IFNvbWUgc3VnYXJcbihkZWZuIHNob3J0LT5lbW9qaSBbc10gXG4gIChqc0NhbGxNZXRob2QgZW1vamkgXCJzaG9ydG5hbWVUb1VuaWNvZGVcIiBzKSlcblxuKHByaW50bG4gXCJIZWxsbyBXb3JsZCFcIiAoc2hvcnQtPmVtb2ppIFwiOndhdmU6XCIpKVxuOzsgUHJlc3MgU2hpZnQrRW50ZXIgdG8gcnVuIHRoaXMiXX0=\"\n ],\n [\n \"Flip a coin\",\n \"/#eyJ2aW1FbmFibGVkIjpmYWxzZSwiY2VsbENvbnRlbnQiOlsiOzsgUHVsbCB0aGUgXCJyYW5kb21cIiBwYWNrYWdlIGZyb20gbnBtXG4oZGVmIHIgKG5wbSBcInJhbmRvbVwiKSlcbjs7IFByaW50IGhlYWRzIG9yIHRhaWxzIHJhbmRvbWx5XG4ocHJpbnRsbiAoaWYgKGpzQ2FsbE1ldGhvZCByIFwiYm9vbGVhblwiKSBcImhlYWRzXCIgXCJ0YWlsc1wiKSlcbjs7IFByZXNzIFNoaWZ0K0VudGVyIHRvIHJ1biB0aGlzIl19\"\n ],\n [\n \"Bart – Estimated Time\",\n \"/#eyJ2aW1FbmFibGVkIjp0cnVlLCJjZWxsQ29udGVudCI6WyI7OyBQdWxsIHRoZSBcInJhbmRvbVwiIHBhY2thZ2UgZnJvbSBucG1cbihkZWYgcmVxdWVzdCAobnBtIFwic3luY3JlcXVlc3RcIikpXG4oZGVmIHBhcnNlSlNPTiAobnBtIFwicGFyc2UtanNvblwiKSlcblxuKGRlZm4gZXRkLXVybCBbc3RhdGlvbiBkaXJdIFxuICAoc3RyIFwiaHR0cDovL2FwaS5iYXJ0Lmdvdi9hcGkvZXRkLmFzcHg/Y21kPWV0ZCZvcmlnPVwiIHN0YXRpb24gXCIma2V5PU1XOVMtRTdTTC0yNkRVLVZWOFYmanNvbj15JmRpcj1cIiBkaXIpKVxuXG47OyBQcmVzcyBTaGlmdCtFbnRlciB0byBydW4gdGhpc1xuKGRlZiByZXN1bHQgKGpzLT5jbGogKGpzQ2FsbE1ldGhvZCByZXF1ZXN0IFwic3luY1wiIChldGQtdXJsIFwiV09BS1wiIFwiU1wiKSAjKGZuIFthXSAocHJpbnRsbiBhKSkpKSlcblxuKGRlZiBiYXJ0LWRhdGEgKGpzLT5jbGogKHBhcnNlSlNPTiAoZ2V0LWluIHJlc3VsdCBbXCJyZXNwb25zZVwiLCBcImJvZHlcIl0pKSkpXG4oZGVmIGFsbC1lc3RpbWF0ZXNcbiAoZmxhdHRlblxuICAgKG1hcCAjKGdldCAlIFwiZXRkXCIpXG4gICAgIChnZXQtaW4gYmFydC1kYXRhIFtcInJvb3RcIiBcInN0YXRpb25cIl0pKSkpXG5cbihkZWYgbmV4dC10cmFpbi10by1TRi1mcm9tLVdPQUtcbiAobWFwICMoJSBcIm1pbnV0ZXNcIilcbiAgICAgIChmbGF0dGVuXG4gICAgICAgKG1hcCAjKCUgXCJlc3RpbWF0ZVwiKSBhbGwtZXN0aW1hdGVzICkpKSlcblxuKGNsai0+anMgbmV4dC10cmFpbi10by1TRi1mcm9tLVdPQUspIl19\"\n ]\n];\n\ntype initialState = {\n vimEnabled?: boolean;\n cellContent?: Array;\n};\nlet initialState: initialState = {};\ntry {\n initialState = JSON.parse(atob(window.location.hash.slice(1)));\n} catch (e) {}\nconsole.log(initialState);\n\nconst defaultFirstCell = `;; Pull the \"random\" package from npm\n(def r (npm \"random\"))\n;; Print heads or tails randomly\n(println (if (jsCallMethod r \"boolean\") \"heads\" \"tails\"))\n;; Press Shift+Enter to run this code\n\n;; Press Option/Alt+Enter to start a new cell`;\n\nconst calcFirstLineNumber = (cellIndex: number, cellContent: Array) => {\n let firstLineNumber = 1;\n for (let index = 0; index < cellIndex; index++) {\n firstLineNumber += cellContent[index].split(\"\\n\").length;\n }\n return firstLineNumber;\n};\n\nconst evalClj = (body: string) =>\n fetch(\"https://untitled-sbly98eppinw.runkit.sh/\", {\n method: \"POST\",\n body\n }).then(x => x.json());\n\ntype CellResult = {\n returnVal: any;\n stdOut: Array;\n err?: string;\n};\n\nconst App = () => {\n const [vimEnabled, setVim] = useState(initialState.vimEnabled || false);\n const [cellContent, setCellContent] = useState>(\n initialState.cellContent || [defaultFirstCell]\n );\n const [redrawCounter, setRedrawCounter] = useState(0);\n\n const [err, setErr] = useState(null);\n\n const [cellResults, setCellResults] = useState>([]);\n\n const onEval = useCallback(async () => {\n // Format to handle multi cell\n const cells = cellContent\n .map(c => `(__nextCellBlock) (__pushRes (do ${c}\\n))\\n`)\n .join(\"\\n\");\n const script = `(do ${cells})`;\n\n // Loading state\n setCellResults(cellResults => {\n return produce(cellResults, draft => {\n return cellContent.map((_, i) => {\n return {\n stdOut: [\"Loading\"],\n returnVal: null\n };\n });\n });\n });\n\n const res = await evalClj(script);\n\n if (res && res.name && res.name === \"Error\") {\n setErr(res.stack);\n } else if (res.map) {\n res.map((cellResult: [Array, string], i: number) =>\n setCellResults(cellResults => {\n return produce(cellResults, draft => {\n draft[i] = {\n stdOut: cellResult[0],\n returnVal: cellResult[1]\n };\n });\n })\n );\n }\n }, [cellContent, setCellResults, setErr]);\n\n useEffect(() => {\n setErr(null);\n window.location.hash = btoa(JSON.stringify({ vimEnabled, cellContent }));\n }, [vimEnabled, cellContent]);\n\n return (\n
\n
CljKit
\n {\n setVim(v);\n }}\n />\n {err &&
{err}
}\n {cellContent.map((v, i) => {\n return (\n \n setCellContent((s: Array) => {\n return produce(s, ds => {\n ds[i] = t;\n });\n })\n }\n focus={i === cellContent.length - 1}\n redrawCounter={redrawCounter}\n cellResult={cellResults[i]}\n onEval={onEval}\n vimEnabled={vimEnabled}\n firstLineNumber={calcFirstLineNumber(i, cellContent)}\n onNewCell={() => {\n setCellContent(s => [\n ...s,\n \";; Type some Clj code here. Shift+Enter runs it.\\n\"\n ]);\n }}\n onRemoveCell={() => {\n setCellContent(s => {\n return produce(s, ds => {\n const f = ds.splice(i, 1);\n console.log(\"removing\", i, f);\n });\n });\n setRedrawCounter(c => c + 1);\n }}\n />\n );\n })}\n \n
\n );\n};\n\nconst Examples = (props: { examples: Array<[string, string]> }) => {\n return (\n
\n

Examples:

\n
    \n {props.examples.map(([title, url], i) => (\n
  • \n setTimeout(() => window.location.reload(), 10)}\n href={url}\n >\n {title}\n \n
  • \n ))}\n
\n
\n );\n};\n\ntype SettingsProp = {\n vimEnabled: boolean;\n onChangeVimEnabled: (v: boolean) => void;\n};\nconst Settings = ({ vimEnabled, onChangeVimEnabled }: SettingsProp) => {\n return (\n
\n Enable Vim\n \n
\n );\n};\n\ntype CellProps = {\n vimEnabled: boolean;\n onChangeText: (t: string) => void;\n redrawCounter: number;\n initialContent?: string;\n onNewCell: () => void;\n onRemoveCell: () => void;\n onEval: (s: string) => void;\n cellResult?: CellResult;\n focus?: boolean;\n firstLineNumber: number;\n};\n\nconst Cell = ({\n cellResult,\n vimEnabled,\n onChangeText,\n initialContent,\n firstLineNumber,\n onNewCell,\n onRemoveCell,\n focus,\n onEval,\n redrawCounter\n}: CellProps) => {\n // Hack to not rerender when this prop changes\n const [content, setContent] = useState(initialContent);\n useEffect(() => {\n setContent(initialContent);\n }, [redrawCounter]); // eslint-disable-line\n // Codemirror doesn't update properly?\n const onEvalRef = useRef(onEval);\n useEffect(() => {\n onEvalRef.current = onEval;\n }, [onEval]);\n return (\n
\n {\n onChangeText(value);\n }}\n onKeyDown={(editor, event) => {\n // @ts-ignore\n if (event.key === \"Enter\" && event.shiftKey) {\n const content = editor.getValue();\n event.preventDefault();\n onEvalRef.current(content);\n\n // evalClj(content).then(result => setEvalResult(result));\n // @ts-ignore\n } else if (event.key === \"Enter\" && event.altKey) {\n event.preventDefault();\n onNewCell();\n }\n }}\n />\n
\n \n
\n {cellResult && (\n <>\n {cellResult.stdOut.length !== 0 && (\n
{\" \" + cellResult.stdOut.join(\" \")}
\n )}\n {cellResult && cellResult.returnVal && (\n
 => {JSON.stringify(cellResult.returnVal)} 
\n )}\n {cellResult && cellResult.err &&
 => {cellResult.err} 
}\n \n )}\n
\n );\n};\n\nexport default App;\n\n// const opts = (outBuf) => ({bindings: {\n// println: (...x) => { outBuf[outBuf.length - 1][0].push(...(x.map(t => JSON.stringify(t))), \"\\n\"); },\n\n// __nextCellBlock: () => { outBuf.push([[]]); },\n// __pushRes: () => {},\n// npm: dynamicRequire,\n// jsCall: (f, t, ...args) => f.call(t, ...args),\n// jsCallMethod: (o, m, ...args) => o[m].call(o, ...args),\n// jsGet: (o, k) => o[k],\n// }})\n// sci.evalString(`(println \"hello world\")`, opts([]))\n// // require(\"request-promise\")\n// // require('request')\n// opts([]).bindings.npm(\"request\")\n// opts([]).bindings.println(\"hi\")\n\n// // opts.bindings.npm(\"request-promise\")\n\n// // sci.evalString(`(do\n// // (npm \"request\")\n// // (println (npm \"request-promise\"))\n// // 3\n// // )`, opts([]))\n\n// const eval = s => {\n// const outBuf = []\n// const res = sci.evalString(s, opts(outBuf))\n// if (outBuf[outBuf.length - 1][1] === undefined) {\n// outBuf[outBuf.length -1][1] = res\n// }\n// return outBuf\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.1/8 is 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\ntype Config = {\n onSuccess?: (registration: ServiceWorkerRegistration) => void;\n onUpdate?: (registration: ServiceWorkerRegistration) => void;\n};\n\nexport function register(config?: 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(\n (process as { env: { [key: string]: string } }).env.PUBLIC_URL,\n window.location.href\n );\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: string, config?: 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: string, config?: Config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl)\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.then(registration => {\n registration.unregister();\n });\n }\n}\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.css';\nimport App from './App';\nimport * as serviceWorker from './serviceWorker';\n\nReactDOM.render(, document.getElementById('root'));\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"],"sourceRoot":""}