@pyscript/core 0.6.18 → 0.6.20
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.
- package/dist/{codemirror-CYQioq7P.js → codemirror-Bv8pV2Yw.js} +2 -2
- package/dist/{codemirror-CYQioq7P.js.map → codemirror-Bv8pV2Yw.js.map} +1 -1
- package/dist/{codemirror_commands-CQkUEN52.js → codemirror_commands-Danbs0HK.js} +2 -2
- package/dist/{codemirror_commands-CQkUEN52.js.map → codemirror_commands-Danbs0HK.js.map} +1 -1
- package/dist/{codemirror_lang-python-D6XFbhta.js → codemirror_lang-python-OPBjc7he.js} +2 -2
- package/dist/{codemirror_lang-python-D6XFbhta.js.map → codemirror_lang-python-OPBjc7he.js.map} +1 -1
- package/dist/{codemirror_language-BXIPubDH.js → codemirror_language-iajYij_0.js} +2 -2
- package/dist/{codemirror_language-BXIPubDH.js.map → codemirror_language-iajYij_0.js.map} +1 -1
- package/dist/{codemirror_view-epWNLlvw.js → codemirror_view--0hK615P.js} +2 -2
- package/dist/codemirror_view--0hK615P.js.map +1 -0
- package/dist/core-CT_We0Hq.js +2 -0
- package/dist/core-CT_We0Hq.js.map +1 -0
- package/dist/core.js +1 -1
- package/dist/{deprecations-manager-BVTYC3QR.js → deprecations-manager-DviCtx5R.js} +2 -2
- package/dist/{deprecations-manager-BVTYC3QR.js.map → deprecations-manager-DviCtx5R.js.map} +1 -1
- package/dist/{donkey-CORBMIqR.js → donkey-CmdsUkCZ.js} +2 -2
- package/dist/{donkey-CORBMIqR.js.map → donkey-CmdsUkCZ.js.map} +1 -1
- package/dist/{error-6hIUqRYs.js → error-OKc4sJdf.js} +2 -2
- package/dist/{error-6hIUqRYs.js.map → error-OKc4sJdf.js.map} +1 -1
- package/dist/{index-BuWusYhv.js → index-yFOz2zgP.js} +2 -2
- package/dist/{index-BuWusYhv.js.map → index-yFOz2zgP.js.map} +1 -1
- package/dist/{mpy-Cf0S-dUv.js → mpy-CgEoKhG2.js} +2 -2
- package/dist/{mpy-Cf0S-dUv.js.map → mpy-CgEoKhG2.js.map} +1 -1
- package/dist/{py-7HTcDr-e.js → py-DXjrkgFV.js} +2 -2
- package/dist/py-DXjrkgFV.js.map +1 -0
- package/dist/{py-editor-CTbZNG5W.js → py-editor-CnqOPHvQ.js} +2 -2
- package/dist/{py-editor-CTbZNG5W.js.map → py-editor-CnqOPHvQ.js.map} +1 -1
- package/dist/{py-terminal-DsuPASk5.js → py-terminal-BDmTDdFl.js} +2 -2
- package/dist/{py-terminal-DsuPASk5.js.map → py-terminal-BDmTDdFl.js.map} +1 -1
- package/package.json +6 -6
- package/src/plugins/py-terminal/py.js +12 -0
- package/dist/codemirror_view-epWNLlvw.js.map +0 -1
- package/dist/core-BSuItnUE.js +0 -2
- package/dist/core-BSuItnUE.js.map +0 -1
- package/dist/py-7HTcDr-e.js.map +0 -1
package/dist/py-7HTcDr-e.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"py-7HTcDr-e.js","sources":["../src/plugins/py-terminal/py.js"],"sourcesContent":["// PyScript py-terminal plugin\nimport { defineProperties } from \"polyscript/exports\";\nimport { hooks } from \"../../core.js\";\n\nconst bootstrapped = new WeakSet();\n\n// this callback will be serialized as string and it never needs\n// to be invoked multiple times. Each xworker here is bootstrapped\n// only once thanks to the `sync.is_pyterminal()` check.\nconst workerReady = ({ interpreter, io, run, type }, { sync }) => {\n if (type !== \"py\" || !sync.is_pyterminal()) return;\n\n run(\n [\n \"from polyscript import currentScript as _\",\n \"__terminal__ = _.terminal\",\n \"del _\",\n ].join(\";\"),\n );\n\n let data = \"\";\n const { pyterminal_read, pyterminal_write } = sync;\n const decoder = new TextDecoder();\n const generic = {\n isatty: false,\n write(buffer) {\n data = decoder.decode(buffer);\n pyterminal_write(data);\n return buffer.length;\n },\n };\n\n io.stderr = (error) => {\n pyterminal_write(String(error.message || error));\n };\n\n interpreter.setStdout(generic);\n interpreter.setStderr(generic);\n interpreter.setStdin({\n isatty: false,\n stdin: () => pyterminal_read(data),\n });\n};\n\nexport default async (element) => {\n // lazy load these only when a valid terminal is found\n const [{ Terminal }, { Readline }, { FitAddon }, { WebLinksAddon }] =\n await Promise.all([\n import(/* webpackIgnore: true */ \"../../3rd-party/xterm.js\"),\n import(\n /* webpackIgnore: true */ \"../../3rd-party/xterm-readline.js\"\n ),\n import(\n /* webpackIgnore: true */ \"../../3rd-party/xterm_addon-fit.js\"\n ),\n import(\n /* webpackIgnore: true */ \"../../3rd-party/xterm_addon-web-links.js\"\n ),\n ]);\n\n const readline = new Readline();\n\n // common main thread initialization for both worker\n // or main case, bootstrapping the terminal on its target\n const init = (options) => {\n let target = element;\n const selector = element.getAttribute(\"target\");\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(\"py-terminal\");\n target.style.display = \"block\";\n element.after(target);\n }\n const terminal = new Terminal({\n theme: {\n background: \"#191A19\",\n foreground: \"#F5F2E7\",\n },\n ...options,\n });\n const fitAddon = new FitAddon();\n terminal.loadAddon(fitAddon);\n terminal.loadAddon(readline);\n terminal.loadAddon(new WebLinksAddon());\n terminal.open(target);\n fitAddon.fit();\n terminal.focus();\n defineProperties(element, {\n terminal: { value: terminal },\n process: {\n value: async (code) => {\n for (const line of code.split(/(?:\\r\\n|\\r|\\n)/)) {\n terminal.paste(`${line}`);\n terminal.write(\"\\r\\n\");\n do {\n await new Promise((resolve) =>\n setTimeout(resolve, 0),\n );\n } while (!readline.activeRead?.resolve);\n readline.activeRead.resolve(line);\n }\n },\n },\n });\n return terminal;\n };\n\n // branch logic for the worker\n if (element.hasAttribute(\"worker\")) {\n // add a hook on the main thread to setup all sync helpers\n // also bootstrapping the XTerm target on main *BUT* ...\n hooks.main.onWorker.add(function worker(_, xworker) {\n // ... as multiple workers will add multiple callbacks\n // be sure no xworker is ever initialized twice!\n if (bootstrapped.has(xworker)) return;\n bootstrapped.add(xworker);\n\n // still cleanup this callback for future scripts/workers\n hooks.main.onWorker.delete(worker);\n\n init({\n disableStdin: false,\n cursorBlink: true,\n cursorStyle: \"block\",\n lineHeight: 1.2,\n });\n\n xworker.sync.is_pyterminal = () => true;\n xworker.sync.pyterminal_read = readline.read.bind(readline);\n xworker.sync.pyterminal_write = readline.write.bind(readline);\n });\n\n // setup remote thread JS/Python code for whenever the\n // worker is ready to become a terminal\n hooks.worker.onReady.add(workerReady);\n } else {\n // in the main case, just bootstrap XTerm without\n // allowing any input as that's not possible / awkward\n hooks.main.onReady.add(function main({ interpreter, io, run, type }) {\n if (type !== \"py\") return;\n\n console.warn(\"py-terminal is read only on main thread\");\n hooks.main.onReady.delete(main);\n\n // on main, it's easy to trash and clean the current terminal\n globalThis.__py_terminal__ = init({\n disableStdin: true,\n cursorBlink: false,\n cursorStyle: \"underline\",\n });\n run(\"from js import __py_terminal__ as __terminal__\");\n delete globalThis.__py_terminal__;\n\n io.stderr = (error) => {\n readline.write(String(error.message || error));\n };\n\n let data = \"\";\n const decoder = new TextDecoder();\n const generic = {\n isatty: false,\n write(buffer) {\n data = decoder.decode(buffer);\n readline.write(data);\n return buffer.length;\n },\n };\n interpreter.setStdout(generic);\n interpreter.setStderr(generic);\n interpreter.setStdin({\n isatty: false,\n stdin: () => readline.read(data),\n });\n });\n }\n};\n"],"names":["bootstrapped","WeakSet","workerReady","interpreter","io","run","type","sync","is_pyterminal","join","data","pyterminal_read","pyterminal_write","decoder","TextDecoder","generic","isatty","write","buffer","decode","length","stderr","error","String","message","setStdout","setStderr","setStdin","stdin","py","async","element","Terminal","Readline","FitAddon","WebLinksAddon","Promise","all","import","readline","init","options","target","selector","getAttribute","document","getElementById","querySelector","Error","createElement","style","display","after","terminal","theme","background","foreground","fitAddon","loadAddon","open","fit","focus","defineProperties","value","process","code","line","split","paste","resolve","setTimeout","activeRead","hasAttribute","hooks","main","onWorker","add","worker","_","xworker","has","delete","disableStdin","cursorBlink","cursorStyle","lineHeight","read","bind","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