@pyscript/core 0.6.29 → 0.6.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/{core-48kkWjDt.js → core-DnOjzQS_.js} +3 -3
  2. package/dist/{core-48kkWjDt.js.map → core-DnOjzQS_.js.map} +1 -1
  3. package/dist/core.css +1 -1
  4. package/dist/core.js +1 -1
  5. package/dist/{deprecations-manager-D27-JUzZ.js → deprecations-manager-BKGF65fL.js} +2 -2
  6. package/dist/{deprecations-manager-D27-JUzZ.js.map → deprecations-manager-BKGF65fL.js.map} +1 -1
  7. package/dist/{donkey-BSnvaf2W.js → donkey-Oqo7W5b8.js} +2 -2
  8. package/dist/{donkey-BSnvaf2W.js.map → donkey-Oqo7W5b8.js.map} +1 -1
  9. package/dist/{error-C_pdTAsr.js → error-Dr1sICUr.js} +2 -2
  10. package/dist/{error-C_pdTAsr.js.map → error-Dr1sICUr.js.map} +1 -1
  11. package/dist/{mpy-B3-cB4Jl.js → mpy-Bj7Nqy2i.js} +2 -2
  12. package/dist/{mpy-B3-cB4Jl.js.map → mpy-Bj7Nqy2i.js.map} +1 -1
  13. package/dist/{py-DMt-1eD0.js → py-B2TFi7-Q.js} +2 -2
  14. package/dist/{py-DMt-1eD0.js.map → py-B2TFi7-Q.js.map} +1 -1
  15. package/dist/py-editor-CVOs6pzi.js +2 -0
  16. package/dist/py-editor-CVOs6pzi.js.map +1 -0
  17. package/dist/{py-game-DwDD-1Ga.js → py-game-BJyQhVm5.js} +2 -2
  18. package/dist/{py-game-DwDD-1Ga.js.map → py-game-BJyQhVm5.js.map} +1 -1
  19. package/dist/{py-terminal-BcOH2o_i.js → py-terminal-CpQPAjog.js} +2 -2
  20. package/dist/{py-terminal-BcOH2o_i.js.map → py-terminal-CpQPAjog.js.map} +1 -1
  21. package/package.json +2 -2
  22. package/src/core.css +8 -8
  23. package/src/plugins/py-editor.js +28 -4
  24. package/src/stdlib/pyscript/display.py +9 -8
  25. package/src/stdlib/pyscript/events.py +4 -2
  26. package/src/stdlib/pyscript/flatted.py +3 -3
  27. package/src/stdlib/pyscript/fs.py +22 -6
  28. package/src/stdlib/pyscript/magic_js.py +1 -0
  29. package/src/stdlib/pyscript/media.py +1 -2
  30. package/src/stdlib/pyscript/storage.py +6 -4
  31. package/src/stdlib/pyscript/util.py +1 -1
  32. package/src/stdlib/pyscript/web.py +27 -20
  33. package/src/stdlib/pyscript/websocket.py +1 -1
  34. package/src/stdlib/pyscript/workers.py +5 -3
  35. package/src/stdlib/pyscript.js +9 -9
  36. package/src/sync.js +4 -4
  37. package/types/sync.d.ts +2 -2
  38. package/dist/py-editor-Cv3sdTcg.js +0 -2
  39. package/dist/py-editor-Cv3sdTcg.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"py-editor-Cv3sdTcg.js","sources":["../src/plugins/py-editor.js"],"sourcesContent":["// PyScript py-editor plugin\nimport { Hook, XWorker, dedent, defineProperties } from \"polyscript/exports\";\nimport { TYPES, offline_interpreter, relative_url, stdlib } from \"../core.js\";\nimport { notify } from \"./error.js\";\nimport codemirror from \"./codemirror.js\";\n\nconst RUN_BUTTON = `<svg style=\"height:20px;width:20px;vertical-align:-.125em;transform-origin:center;overflow:visible;color:green\" viewBox=\"0 0 384 512\" aria-hidden=\"true\" role=\"img\" xmlns=\"http://www.w3.org/2000/svg\"><g transform=\"translate(192 256)\" transform-origin=\"96 0\"><g transform=\"translate(0,0) scale(1,1)\"><path d=\"M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z\" fill=\"currentColor\" transform=\"translate(-192 -256)\"></path></g></g></svg>`;\n\nlet id = 0;\nconst getID = (type) => `${type}-editor-${id++}`;\n\nconst envs = new Map();\nconst configs = new Map();\n\nconst hooks = {\n worker: {\n codeBeforeRun: () => stdlib,\n // works on both Pyodide and MicroPython\n onReady: ({ runAsync, io }, { sync }) => {\n io.stdout = io.buffered(sync.write);\n io.stderr = io.buffered(sync.writeErr);\n sync.revoke();\n sync.runAsync = runAsync;\n },\n },\n};\n\nconst validate = (config, result) => {\n if (typeof result === \"boolean\") throw `Invalid source: ${config}`;\n return result;\n};\n\nasync function execute({ currentTarget }) {\n const { env, pySrc, outDiv } = this;\n const hasRunButton = !!currentTarget;\n\n if (hasRunButton) {\n currentTarget.disabled = true;\n outDiv.innerHTML = \"\";\n }\n\n if (!envs.has(env)) {\n const srcLink = URL.createObjectURL(new Blob([\"\"]));\n const details = {\n type: this.interpreter,\n serviceWorker: this.serviceWorker,\n };\n const { config } = this;\n if (config) {\n // verify that config can be parsed and used\n try {\n details.configURL = relative_url(config);\n if (config.endsWith(\".toml\")) {\n const [{ parse }, toml] = await Promise.all([\n import(\n /* webpackIgnore: true */ \"../3rd-party/toml.js\"\n ),\n fetch(config).then((r) => r.ok && r.text()),\n ]);\n details.config = parse(validate(config, toml));\n } else if (config.endsWith(\".json\")) {\n const json = await fetch(config).then(\n (r) => r.ok && r.json(),\n );\n details.config = validate(config, json);\n } else {\n details.configURL = relative_url(\"./config.txt\");\n details.config = JSON.parse(config);\n }\n details.version = offline_interpreter(details.config);\n } catch (error) {\n notify(error);\n return;\n }\n } else {\n details.config = {};\n }\n\n const xworker = XWorker.call(new Hook(null, hooks), srcLink, details);\n\n // expose xworker like in terminal or other workers to allow\n // creation and destruction of editors on the fly\n if (hasRunButton) {\n for (const type of TYPES.keys()) {\n const editor = currentTarget.closest(`.${type}-editor-box`);\n const script = editor?.parentNode?.previousElementSibling;\n if (script) {\n defineProperties(script, { xworker: { value: xworker } });\n break;\n }\n }\n }\n\n const { sync } = xworker;\n const { promise, resolve } = Promise.withResolvers();\n envs.set(env, promise);\n sync.revoke = () => {\n URL.revokeObjectURL(srcLink);\n resolve(xworker);\n };\n }\n\n // wait for the env then set the target div\n // before executing the current code\n return envs.get(env).then((xworker) => {\n xworker.onerror = ({ error }) => {\n if (hasRunButton) {\n outDiv.insertAdjacentHTML(\n \"beforeend\",\n `<span style='color:red'>${\n error.message || error\n }</span>\\n`,\n );\n }\n console.error(error);\n };\n\n const enable = () => {\n if (hasRunButton) currentTarget.disabled = false;\n };\n const { sync } = xworker;\n sync.write = (str) => {\n if (hasRunButton) outDiv.innerText += `${str}\\n`;\n else console.log(str);\n };\n sync.writeErr = (str) => {\n if (hasRunButton) {\n outDiv.insertAdjacentHTML(\n \"beforeend\",\n `<span style='color:red'>${str}</span>\\n`,\n );\n } else {\n notify(str);\n console.error(str);\n }\n };\n sync.runAsync(pySrc).then(enable, enable);\n });\n}\n\nconst makeRunButton = (handler, type) => {\n const runButton = document.createElement(\"button\");\n runButton.className = `absolute ${type}-editor-run-button`;\n runButton.innerHTML = RUN_BUTTON;\n runButton.setAttribute(\"aria-label\", \"Python Script Run Button\");\n runButton.addEventListener(\"click\", async (event) => {\n runButton.blur();\n await handler.handleEvent(event);\n });\n return runButton;\n};\n\nconst makeEditorDiv = (handler, type) => {\n const editorDiv = document.createElement(\"div\");\n editorDiv.className = `${type}-editor-input`;\n editorDiv.setAttribute(\"aria-label\", \"Python Script Area\");\n\n const runButton = makeRunButton(handler, type);\n const editorShadowContainer = document.createElement(\"div\");\n\n // avoid outer elements intercepting key events (reveal as example)\n editorShadowContainer.addEventListener(\"keydown\", (event) => {\n event.stopPropagation();\n });\n\n editorDiv.append(runButton, editorShadowContainer);\n\n return editorDiv;\n};\n\nconst makeOutDiv = (type) => {\n const outDiv = document.createElement(\"div\");\n outDiv.className = `${type}-editor-output`;\n outDiv.id = `${getID(type)}-output`;\n return outDiv;\n};\n\nconst makeBoxDiv = (handler, type) => {\n const boxDiv = document.createElement(\"div\");\n boxDiv.className = `${type}-editor-box`;\n\n const editorDiv = makeEditorDiv(handler, type);\n const outDiv = makeOutDiv(type);\n boxDiv.append(editorDiv, outDiv);\n\n return [boxDiv, outDiv, editorDiv.querySelector(\"button\")];\n};\n\nconst init = async (script, type, interpreter) => {\n const [\n { basicSetup, EditorView },\n { Compartment },\n { python },\n { indentUnit },\n { keymap },\n { defaultKeymap, indentWithTab },\n ] = await Promise.all([\n codemirror.core,\n codemirror.state,\n codemirror.python,\n codemirror.language,\n codemirror.view,\n codemirror.commands,\n ]);\n\n let isSetup = script.hasAttribute(\"setup\");\n const hasConfig = script.hasAttribute(\"config\");\n const serviceWorker = script.getAttribute(\"service-worker\");\n const env = `${interpreter}-${script.getAttribute(\"env\") || getID(type)}`;\n\n // helps preventing too lazy ServiceWorker initialization on button run\n if (serviceWorker) {\n new XWorker(\"data:application/javascript,postMessage(0)\", {\n type: \"dummy\",\n serviceWorker,\n }).onmessage = ({ target }) => target.terminate();\n }\n\n if (hasConfig && configs.has(env)) {\n throw new SyntaxError(\n configs.get(env)\n ? `duplicated config for env: ${env}`\n : `unable to add a config to the env: ${env}`,\n );\n }\n\n configs.set(env, hasConfig);\n\n let source = script.textContent;\n\n // verify the src points to a valid file that can be parsed\n const { src } = script;\n if (src) {\n try {\n source = validate(\n src,\n await fetch(src).then((b) => b.ok && b.text()),\n );\n } catch (error) {\n notify(error);\n return;\n }\n }\n\n const context = {\n // allow the listener to be overridden at distance\n handleEvent: execute,\n serviceWorker,\n interpreter,\n env,\n config: hasConfig && script.getAttribute(\"config\"),\n get pySrc() {\n return isSetup ? source : editor.state.doc.toString();\n },\n get outDiv() {\n return isSetup ? null : outDiv;\n },\n };\n\n let target;\n defineProperties(script, {\n target: { get: () => target },\n handleEvent: {\n get: () => context.handleEvent,\n set: (callback) => {\n // do not bother with logic if it was set back as its original handler\n if (callback === execute) context.handleEvent = execute;\n // in every other case be sure that if the listener override returned\n // `false` nothing happens, otherwise keep doing what it always did\n else {\n context.handleEvent = async (event) => {\n // trap the currentTarget ASAP (if any)\n // otherwise it gets lost asynchronously\n const { currentTarget } = event;\n // augment a code snapshot before invoking the override\n defineProperties(event, {\n code: { value: context.pySrc },\n });\n // avoid executing the default handler if the override returned `false`\n if ((await callback(event)) !== false)\n await execute.call(context, { currentTarget });\n };\n }\n },\n },\n code: {\n get: () => context.pySrc,\n set: (insert) => {\n if (isSetup) return;\n editor.update([\n editor.state.update({\n changes: {\n from: 0,\n to: editor.state.doc.length,\n insert,\n },\n }),\n ]);\n },\n },\n process: {\n /**\n * Simulate a setup node overriding the source to evaluate.\n * @param {string} code the Python code to evaluate.\n * @param {boolean} asRunButtonAction invoke the `Run` button handler.\n * @returns {Promise<...>} fulfill once code has been evaluated.\n */\n value(code, asRunButtonAction = false) {\n if (asRunButtonAction) return listener();\n const wasSetup = isSetup;\n const wasSource = source;\n isSetup = true;\n source = code;\n const restore = () => {\n isSetup = wasSetup;\n source = wasSource;\n };\n return context\n .handleEvent({ currentTarget: null })\n .then(restore, restore);\n },\n },\n });\n\n const notifyEditor = () => {\n const event = new Event(`${type}-editor`, { bubbles: true });\n script.dispatchEvent(event);\n };\n\n if (isSetup) {\n await context.handleEvent({ currentTarget: null });\n notifyEditor();\n return;\n }\n\n const selector = script.getAttribute(\"target\");\n\n if (selector) {\n target =\n document.getElementById(selector) ||\n document.querySelector(selector);\n if (!target) throw new Error(`Unknown target ${selector}`);\n } else {\n target = document.createElement(`${type}-editor`);\n target.style.display = \"block\";\n script.after(target);\n }\n\n if (!target.id) target.id = getID(type);\n if (!target.hasAttribute(\"exec-id\")) target.setAttribute(\"exec-id\", 0);\n if (!target.hasAttribute(\"root\")) target.setAttribute(\"root\", target.id);\n\n // @see https://github.com/JeffersGlass/mkdocs-pyscript/blob/main/mkdocs_pyscript/js/makeblocks.js\n const [boxDiv, outDiv, runButton] = makeBoxDiv(context, type);\n boxDiv.dataset.env = script.hasAttribute(\"env\") ? env : interpreter;\n\n const inputChild = boxDiv.querySelector(`.${type}-editor-input > div`);\n const parent = inputChild.attachShadow({ mode: \"open\" });\n // avoid inheriting styles from the outer component\n parent.innerHTML = `<style> :host { all: initial; }</style>`;\n\n target.appendChild(boxDiv);\n\n const doc = dedent(script.textContent).trim();\n\n // preserve user indentation, if any\n const indentation = /^([ \\t]+)/m.test(doc) ? RegExp.$1 : \" \";\n\n const listener = () => runButton.click();\n const editor = new EditorView({\n extensions: [\n indentUnit.of(indentation),\n new Compartment().of(python()),\n keymap.of([\n ...defaultKeymap,\n { key: \"Ctrl-Enter\", run: listener, preventDefault: true },\n { key: \"Cmd-Enter\", run: listener, preventDefault: true },\n { key: \"Shift-Enter\", run: listener, preventDefault: true },\n // @see https://codemirror.net/examples/tab/\n indentWithTab,\n ]),\n basicSetup,\n ],\n foldGutter: true,\n gutters: [\"CodeMirror-linenumbers\", \"CodeMirror-foldgutter\"],\n parent,\n doc,\n });\n\n editor.focus();\n notifyEditor();\n};\n\n// avoid too greedy MutationObserver operations at distance\nlet timeout = 0;\n\n// avoid delayed initialization\nlet queue = Promise.resolve();\n\n// reset interval value then check for new scripts\nconst resetTimeout = () => {\n timeout = 0;\n pyEditor();\n};\n\n// triggered both ASAP on the living DOM and via MutationObserver later\nconst pyEditor = () => {\n if (timeout) return;\n timeout = setTimeout(resetTimeout, 250);\n for (const [type, interpreter] of TYPES) {\n const selector = `script[type=\"${type}-editor\"]`;\n for (const script of document.querySelectorAll(selector)) {\n // avoid any further bootstrap by changing the type as active\n script.type += \"-active\";\n // don't await in here or multiple calls might happen\n // while the first script is being initialized\n queue = queue.then(() => init(script, type, interpreter));\n }\n }\n return queue;\n};\n\nnew MutationObserver(pyEditor).observe(document, {\n childList: true,\n subtree: true,\n});\n\n// try to check the current document ASAP\nexport default pyEditor();\n"],"names":["id","getID","type","envs","Map","configs","hooks","worker","codeBeforeRun","stdlib","onReady","runAsync","io","sync","stdout","buffered","write","stderr","writeErr","revoke","validate","config","result","async","execute","currentTarget","env","pySrc","outDiv","this","hasRunButton","disabled","innerHTML","has","srcLink","URL","createObjectURL","Blob","details","interpreter","serviceWorker","configURL","relative_url","endsWith","parse","toml","Promise","all","import","fetch","then","r","ok","text","json","JSON","version","offline_interpreter","error","notify","xworker","XWorker","call","Hook","TYPES","keys","editor","closest","script","parentNode","previousElementSibling","defineProperties","value","promise","resolve","withResolvers","set","revokeObjectURL","get","onerror","insertAdjacentHTML","message","console","enable","str","innerText","log","makeEditorDiv","handler","editorDiv","document","createElement","className","setAttribute","runButton","addEventListener","event","blur","handleEvent","makeRunButton","editorShadowContainer","stopPropagation","append","makeBoxDiv","boxDiv","makeOutDiv","querySelector","init","basicSetup","EditorView","Compartment","python","indentUnit","keymap","defaultKeymap","indentWithTab","codemirror","core","state","language","view","commands","isSetup","hasAttribute","hasConfig","getAttribute","onmessage","target","terminate","SyntaxError","source","textContent","src","b","context","doc","toString","callback","code","insert","update","changes","from","to","length","process","asRunButtonAction","listener","wasSetup","wasSource","restore","notifyEditor","Event","bubbles","dispatchEvent","selector","getElementById","Error","style","display","after","dataset","parent","attachShadow","mode","appendChild","dedent","trim","indentation","test","RegExp","$1","click","extensions","of","key","run","preventDefault","foldGutter","gutters","focus","timeout","queue","resetTimeout","pyEditor","setTimeout","querySelectorAll","MutationObserver","observe","childList","subtree","pyEditor$1"],"mappings":"4IAQA,IAAIA,EAAK,EACT,MAAMC,EAASC,GAAS,GAAGA,YAAeF,MAEpCG,EAAO,IAAIC,IACXC,EAAU,IAAID,IAEdE,EAAQ,CACVC,OAAQ,CACJC,cAAe,IAAMC,EAErBC,QAAS,EAAGC,WAAUC,OAAQC,WAC1BD,EAAGE,OAASF,EAAGG,SAASF,EAAKG,OAC7BJ,EAAGK,OAASL,EAAGG,SAASF,EAAKK,UAC7BL,EAAKM,SACLN,EAAKF,SAAWA,CAAQ,IAK9BS,EAAW,CAACC,EAAQC,KACtB,GAAsB,kBAAXA,EAAsB,KAAM,mBAAmBD,IAC1D,OAAOC,CAAM,EAGjBC,eAAeC,GAAQC,cAAEA,IACrB,MAAMC,IAAEA,EAAGC,MAAEA,EAAKC,OAAEA,GAAWC,KACzBC,IAAiBL,EAOvB,GALIK,IACAL,EAAcM,UAAW,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