@pyscript/core 0.4.17 → 0.4.18
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-ZDIr9iJj.js → codemirror-Da0uB6D0.js} +2 -2
- package/dist/{codemirror-ZDIr9iJj.js.map → codemirror-Da0uB6D0.js.map} +1 -1
- package/dist/{codemirror_commands-NWDrre9v.js → codemirror_commands-Cda0Zxd7.js} +2 -2
- package/dist/{codemirror_commands-NWDrre9v.js.map → codemirror_commands-Cda0Zxd7.js.map} +1 -1
- package/dist/{codemirror_lang-python-dHfsE0jo.js → codemirror_lang-python-DIyWB5tk.js} +2 -2
- package/dist/{codemirror_lang-python-dHfsE0jo.js.map → codemirror_lang-python-DIyWB5tk.js.map} +1 -1
- package/dist/{codemirror_language-BPcKWOkU.js → codemirror_language-DCl5sMoK.js} +2 -2
- package/dist/{codemirror_language-BPcKWOkU.js.map → codemirror_language-DCl5sMoK.js.map} +1 -1
- package/dist/codemirror_view-Bz8y6BoV.js +2 -0
- package/dist/codemirror_view-Bz8y6BoV.js.map +1 -0
- package/dist/core-7i5zvfk2.js +3 -0
- package/dist/core-7i5zvfk2.js.map +1 -0
- package/dist/core.js +1 -1
- package/dist/{deprecations-manager-Cmjq5S3L.js → deprecations-manager-BoA07KcH.js} +2 -2
- package/dist/{deprecations-manager-Cmjq5S3L.js.map → deprecations-manager-BoA07KcH.js.map} +1 -1
- package/dist/{error-BxcTyvWj.js → error-qAhGjnmt.js} +2 -2
- package/dist/{error-BxcTyvWj.js.map → error-qAhGjnmt.js.map} +1 -1
- package/dist/{index-Db1V4drY.js → index-2LL_kWLg.js} +2 -2
- package/dist/{index-Db1V4drY.js.map → index-2LL_kWLg.js.map} +1 -1
- package/dist/py-editor-BpFGlXIt.js +2 -0
- package/dist/py-editor-BpFGlXIt.js.map +1 -0
- package/dist/{py-terminal-Co-qwesG.js → py-terminal-K6pA-YwA.js} +2 -2
- package/dist/{py-terminal-Co-qwesG.js.map → py-terminal-K6pA-YwA.js.map} +1 -1
- package/dist/xterm_addon-fit--gyF3PcZ.js.map +1 -1
- package/package.json +9 -9
- package/src/3rd-party/xterm_addon-fit.js +1 -1
- package/src/plugins/py-editor.js +2 -2
- package/types/core.d.ts +0 -1
- package/dist/codemirror_view-DJFeHd78.js +0 -2
- package/dist/codemirror_view-DJFeHd78.js.map +0 -1
- package/dist/core-Dc5oF8yr.js +0 -3
- package/dist/core-Dc5oF8yr.js.map +0 -1
- package/dist/py-editor-Sk1Kgwbe.js +0 -2
- package/dist/py-editor-Sk1Kgwbe.js.map +0 -1
- package/dist.zip +0 -0
@@ -0,0 +1,2 @@
|
|
1
|
+
import{T as t,d as e,X as r,H as n,s as o}from"./core-7i5zvfk2.js";let i=0;const s=t=>`${t}-editor-${i++}`,a=new Map,c=new Map,l={worker:{codeBeforeRun:()=>o,onReady:({runAsync:t,io:e},{sync:r})=>{e.stdout=e.buffered(r.write),e.stderr=e.buffered(r.writeErr),r.revoke(),r.runAsync=t}}};async function u({currentTarget:t}){const{env:e,pySrc:o,outDiv:i}=this,s=!!t;if(s&&(t.disabled=!0,i.innerHTML=""),!a.has(e)){const t=URL.createObjectURL(new Blob([""])),o={type:this.interpreter},{config:i}=this;if(i){o.configURL=i;const{parse:t}=i.endsWith(".toml")?await import("./toml-CvAfdf9_.js"):JSON;o.config=t(await fetch(i).then((t=>t.text())))}const s=r.call(new n(null,l),t,o),{sync:c}=s,{promise:u,resolve:d}=Promise.withResolvers();a.set(e,u),c.revoke=()=>{URL.revokeObjectURL(t),d(s)}}a.get(e).then((e=>{e.onerror=({error:t})=>{s&&(i.innerHTML+=`<span style='color:red'>${t.message||t}</span>\n`),console.error(t)};const r=()=>{s&&(t.disabled=!1)},{sync:n}=e;n.write=t=>{s&&(i.innerText+=`${t}\n`)},n.writeErr=t=>{s&&(i.innerHTML+=`<span style='color:red'>${t}</span>\n`)},n.runAsync(o).then(r,r)}))}const d=(t,e)=>{const r=document.createElement("div");r.className=`${e}-editor-input`,r.setAttribute("aria-label","Python Script Area");const n=((t,e)=>{const r=document.createElement("button");return r.className=`absolute ${e}-editor-run-button`,r.innerHTML='<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>',r.setAttribute("aria-label","Python Script Run Button"),r.addEventListener("click",t),r})(t,e),o=document.createElement("div");return o.addEventListener("keydown",(t=>{t.stopPropagation()})),r.append(n,o),r},m=(t,e)=>{const r=document.createElement("div");r.className=`${e}-editor-box`;const n=d(t,e),o=(t=>{const e=document.createElement("div");return e.className=`${t}-editor-output`,e.id=`${s(t)}-output`,e})(e);return r.append(n,o),[r,o]},p=async(t,r,n)=>{const[{basicSetup:o,EditorView:i},{Compartment:a},{python:l},{indentUnit:d},{keymap:p},{defaultKeymap:f}]=await Promise.all([import("./codemirror-Da0uB6D0.js"),import("./codemirror_state-BKbyfKsm.js"),import("./codemirror_lang-python-DIyWB5tk.js"),import("./codemirror_language-DCl5sMoK.js").then((function(t){return t.x})),import("./codemirror_view-Bz8y6BoV.js").then((function(t){return t.q})),import("./codemirror_commands-Cda0Zxd7.js")]),h=t.hasAttribute("setup"),g=t.hasAttribute("config"),v=`${n}-${t.getAttribute("env")||s(r)}`;if(g&&c.has(v))throw new SyntaxError(c.get(v)?`duplicated config for env: ${v}`:`unable to add a config to the env: ${v}`);c.set(v,g);const y=t.src?await fetch(t.src).then((t=>t.text())):t.textContent,b={interpreter:n,env:v,config:g&&new URL(t.getAttribute("config"),location.href).href,get pySrc(){return h?y:k.state.doc.toString()},get outDiv(){return h?null:A}};if(h)return void u.call(b,{currentTarget:null});const w=t.getAttribute("target");let $;if(w){if($=document.getElementById(w)||document.querySelector(w),!$)throw new Error(`Unknown target ${w}`)}else $=document.createElement(`${r}-editor`),$.style.display="block",t.after($);$.id||($.id=s(r)),$.hasAttribute("exec-id")||$.setAttribute("exec-id",0),$.hasAttribute("root")||$.setAttribute("root",$.id);const E=u.bind(b),[x,A]=m(E,r);x.dataset.env=t.hasAttribute("env")?v:n;const L=x.querySelector(`.${r}-editor-input > div`).attachShadow({mode:"open"});L.innerHTML="<style> :host { all: initial; }</style>",$.appendChild(x);const C=e(t.textContent).trim(),S=/^(\s+)/m.test(C)?RegExp.$1:" ",k=new i({extensions:[d.of(S),(new a).of(l()),p.of([...f,{key:"Ctrl-Enter",run:E,preventDefault:!0},{key:"Cmd-Enter",run:E,preventDefault:!0},{key:"Shift-Enter",run:E,preventDefault:!0}]),o],parent:L,doc:C});k.focus()};let f=0,h=Promise.resolve();const g=()=>{f=0,v()},v=()=>{if(!f){f=setTimeout(g,250);for(const[e,r]of t){const t=`script[type="${e}-editor"]`;for(const n of document.querySelectorAll(t))n.type+="-active",h=h.then((()=>p(n,e,r)))}return h}};new MutationObserver(v).observe(document,{childList:!0,subtree:!0});var y=v();export{y as default};
|
2
|
+
//# sourceMappingURL=py-editor-BpFGlXIt.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"py-editor-BpFGlXIt.js","sources":["../src/plugins/py-editor.js"],"sourcesContent":["// PyScript py-editor plugin\nimport { Hook, XWorker, dedent } from \"polyscript/exports\";\nimport { TYPES, stdlib } from \"../core.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\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 = { type: this.interpreter };\n const { config } = this;\n if (config) {\n details.configURL = config;\n const { parse } = config.endsWith(\".toml\")\n ? await import(/* webpackIgnore: true */ \"../3rd-party/toml.js\")\n : JSON;\n details.config = parse(await fetch(config).then((r) => r.text()));\n }\n\n const xworker = XWorker.call(new Hook(null, hooks), srcLink, details);\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 envs.get(env).then((xworker) => {\n xworker.onerror = ({ error }) => {\n if (hasRunButton) {\n outDiv.innerHTML += `<span style='color:red'>${\n error.message || error\n }</span>\\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 };\n sync.writeErr = (str) => {\n if (hasRunButton) {\n outDiv.innerHTML += `<span style='color:red'>${str}</span>\\n`;\n }\n };\n sync.runAsync(pySrc).then(enable, enable);\n });\n}\n\nconst makeRunButton = (listener, 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\", listener);\n return runButton;\n};\n\nconst makeEditorDiv = (listener, 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(listener, 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 = (listener, type) => {\n const boxDiv = document.createElement(\"div\");\n boxDiv.className = `${type}-editor-box`;\n\n const editorDiv = makeEditorDiv(listener, type);\n const outDiv = makeOutDiv(type);\n boxDiv.append(editorDiv, outDiv);\n\n return [boxDiv, outDiv];\n};\n\nconst init = async (script, type, interpreter) => {\n const [\n { basicSetup, EditorView },\n { Compartment },\n { python },\n { indentUnit },\n { keymap },\n { defaultKeymap },\n ] = await Promise.all([\n import(/* webpackIgnore: true */ \"../3rd-party/codemirror.js\"),\n import(/* webpackIgnore: true */ \"../3rd-party/codemirror_state.js\"),\n import(\n /* webpackIgnore: true */ \"../3rd-party/codemirror_lang-python.js\"\n ),\n import(/* webpackIgnore: true */ \"../3rd-party/codemirror_language.js\"),\n import(/* webpackIgnore: true */ \"../3rd-party/codemirror_view.js\"),\n import(/* webpackIgnore: true */ \"../3rd-party/codemirror_commands.js\"),\n ]);\n\n const isSetup = script.hasAttribute(\"setup\");\n const hasConfig = script.hasAttribute(\"config\");\n const env = `${interpreter}-${script.getAttribute(\"env\") || getID(type)}`;\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 const source = script.src\n ? await fetch(script.src).then((b) => b.text())\n : script.textContent;\n const context = {\n interpreter,\n env,\n config:\n hasConfig &&\n new URL(script.getAttribute(\"config\"), location.href).href,\n get pySrc() {\n return isSetup ? source : editor.state.doc.toString();\n },\n get outDiv() {\n return isSetup ? null : outDiv;\n },\n };\n\n if (isSetup) {\n execute.call(context, { currentTarget: null });\n return;\n }\n\n const selector = script.getAttribute(\"target\");\n\n let 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(`${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 listener = execute.bind(context);\n const [boxDiv, outDiv] = makeBoxDiv(listener, 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 = /^(\\s+)/m.test(doc) ? RegExp.$1 : \" \";\n\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 ]),\n basicSetup,\n ],\n parent,\n doc,\n });\n\n editor.focus();\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","async","execute","currentTarget","env","pySrc","outDiv","this","hasRunButton","disabled","innerHTML","has","srcLink","URL","createObjectURL","Blob","details","interpreter","config","configURL","parse","endsWith","import","JSON","fetch","then","r","text","xworker","XWorker","call","Hook","promise","resolve","Promise","withResolvers","set","revokeObjectURL","get","onerror","error","message","console","enable","str","innerText","makeEditorDiv","listener","editorDiv","document","createElement","className","setAttribute","runButton","addEventListener","makeRunButton","editorShadowContainer","event","stopPropagation","append","makeBoxDiv","boxDiv","makeOutDiv","init","script","basicSetup","EditorView","Compartment","python","indentUnit","keymap","defaultKeymap","all","n","x","q","isSetup","hasAttribute","hasConfig","getAttribute","SyntaxError","source","src","b","textContent","context","location","href","editor","state","doc","toString","selector","target","getElementById","querySelector","Error","style","display","after","bind","dataset","parent","attachShadow","mode","appendChild","dedent","trim","indentation","test","RegExp","$1","extensions","of","key","run","preventDefault","focus","timeout","queue","resetTimeout","pyEditor","setTimeout","TYPES","querySelectorAll","MutationObserver","observe","childList","subtree","pyEditor$1"],"mappings":"mEAMA,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,IAKpCS,eAAeC,GAAQC,cAAEA,IACrB,MAAMC,IAAEA,EAAGC,MAAEA,EAAKC,OAAEA,GAAWC,KACzBC,IAAiBL,EAOvB,GALIK,IACAL,EAAcM,UAAW,EACzBH,EAAOI,UAAY,KAGlB1B,EAAK2B,IAAIP,GAAM,CAChB,MAAMQ,EAAUC,IAAIC,gBAAgB,IAAIC,KAAK,CAAC,MACxCC,EAAU,CAAEjC,KAAMwB,KAAKU,cACvBC,OAAEA,GAAWX,KACnB,GAAIW,EAAQ,CACRF,EAAQG,UAAYD,EACpB,MAAME,MAAEA,GAAUF,EAAOG,SAAS,eACtBC,OAAiC,sBACvCC,KACNP,EAAQE,OAASE,QAAYI,MAAMN,GAAQO,MAAMC,GAAMA,EAAEC,SAC5D,CAED,MAAMC,EAAUC,EAAQC,KAAK,IAAIC,EAAK,KAAM5C,GAAQyB,EAASI,IAEvDtB,KAAEA,GAASkC,GACXI,QAAEA,EAAOC,QAAEA,GAAYC,QAAQC,gBACrCnD,EAAKoD,IAAIhC,EAAK4B,GACdtC,EAAKM,OAAS,KACVa,IAAI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BhC,GAE3C5B,EAAOjF,MAAQ,UAGfwI,EAAQA,EAAM9F,MAAK,IAAMsC,EAAKC,EAAQjF,EAAMkC,IAEnD,CACD,OAAOsG,CAZa,CAYR,EAGhB,IAAIM,iBAAiBJ,GAAUK,QAAQ7E,SAAU,CAC7C8E,WAAW,EACXC,SAAS,IAIb,IAAAC,EAAeR"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{T as e,c as t,e as r,a as n}from"./core-
|
2
|
-
//# sourceMappingURL=py-terminal-
|
1
|
+
import{T as e,c as t,e as r,a as n}from"./core-7i5zvfk2.js";import{notify as i}from"./error-qAhGjnmt.js";const o=[],s=e=>{throw i(e),new Error(e)},a=({attributes:{worker:e}})=>!e,d=new WeakSet;let l=!0;const c=({interpreter:e,io:t,run:r,type:n},{sync:i})=>{if(!i.is_pyterminal())return;r("from polyscript import currentScript as _; __terminal__ = _.terminal; del _");let o="";const{pyterminal_read:s,pyterminal_write:a}=i,d=new TextDecoder,l={isatty:!1,write:e=>(o=d.decode(e),a(o),e.length)};if(t.stderr=e=>{a(String(e.message||e))},"mpy"===n){e.registerJsModule("_pyscript_input",{input:s}),r("from _pyscript_input import input");const n=e=>{const t=[];let r=0;return n=>{let i=0;for(const o of n)t.push(o),r?r--:194<=o&&o<=223?r=1:224<=o&&o<=239?r=2:240<=o&&o<=244&&(r=3),r||(i+=t.length,e(new Uint8Array(t.splice(0))));return i}};t.stdout=n(l.write),e.registerJsModule("code",{interact(){let r="",i=1;const o=new TextEncoder,l=[],c=n((e=>{l.push(...e),a(d.decode(e))}));t.stdout=e=>i++>r.length?c(e):0,e.replInit(),function t(){const n=d.decode(new Uint8Array(l.splice(0))),a=`${s(n.split("\n").at(-1))}\r`;i=0,r=o.encode(a);for(const t of r)e.replProcessChar(t);t()}()}})}else e.setStdout(l),e.setStderr(l),e.setStdin({isatty:!1,stdin:()=>s(o)})},m=async e=>{const[{Terminal:t},{Readline:i},{FitAddon:o}]=await Promise.all([import("./xterm-DqawCVsv.js"),import("./xterm-readline-D247p8vq.js"),import("./xterm_addon-fit--gyF3PcZ.js")]),s=new i,a=r=>{let i=e;const a=e.getAttribute("target");if(a){if(i=document.getElementById(a)||document.querySelector(a),!i)throw new Error(`Unknown target ${a}`)}else i=document.createElement("py-terminal"),i.style.display="block",e.after(i);const d=new t({theme:{background:"#191A19",foreground:"#F5F2E7"},...r}),l=new o;return d.loadAddon(l),d.loadAddon(s),d.open(i),l.fit(),d.focus(),n(e,"terminal",{value:d}),d};e.hasAttribute("worker")?(r.main.onWorker.add((function e(t,n){d.has(n)||(d.add(n),r.main.onWorker.delete(e),a({disableStdin:!1,cursorBlink:!0,cursorStyle:"block"}),n.sync.is_pyterminal=()=>!0,n.sync.pyterminal_read=s.read.bind(s),n.sync.pyterminal_write=s.write.bind(s))})),r.worker.onReady.add(c)):r.main.onReady.add((function e({interpreter:t,io:n,run:i,type:o}){console.warn("py-terminal is read only on main thread"),r.main.onReady.delete(e),globalThis.__py_terminal__=a({disableStdin:!0,cursorBlink:!1,cursorStyle:"underline"}),i("from js import __py_terminal__ as __terminal__"),delete globalThis.__py_terminal__,n.stderr=e=>{s.write(String(e.message||e))},"mpy"===o&&(t.setStdin=Object,t.setStderr=Object,t.setStdout=({write:e})=>{n.stdout=e});let d="";const l=new TextDecoder,c={isatty:!1,write:e=>(d=l.decode(e),s.write(d),e.length)};t.setStdout(c),t.setStderr(c),t.setStdin({isatty:!1,stdin:()=>s.read(d)})}))};for(const r of e.keys()){const e=`script[type="${r}"][terminal],${r}-script[terminal]`;o.push(e),t.set(e,(async e=>{const t=document.querySelectorAll(o.join(","));[].filter.call(t,a).length>1&&s("You can use at most 1 main terminal"),l&&(l=!1,document.head.append(Object.assign(document.createElement("link"),{rel:"stylesheet",href:new URL("./xterm.css",import.meta.url)}))),await m(e)}))}
|
2
|
+
//# sourceMappingURL=py-terminal-K6pA-YwA.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"py-terminal-Co-qwesG.js","sources":["../src/plugins/py-terminal.js"],"sourcesContent":["// PyScript py-terminal plugin\nimport { TYPES, hooks } from \"../core.js\";\nimport { notify } from \"./error.js\";\nimport { customObserver, defineProperty } from \"polyscript/exports\";\n\n// will contain all valid selectors\nconst SELECTORS = [];\n\n// show the error on main and\n// stops the module from keep executing\nconst notifyAndThrow = (message) => {\n notify(message);\n throw new Error(message);\n};\n\nconst onceOnMain = ({ attributes: { worker } }) => !worker;\n\nconst bootstrapped = new WeakSet();\n\nlet addStyle = true;\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 (!sync.is_pyterminal()) return;\n\n // in workers it's always safe to grab the polyscript currentScript\n // the ugly `_` dance is due MicroPython not able to import via:\n // `from polyscript.currentScript import terminal as __terminal__`\n run(\n \"from polyscript import currentScript as _; __terminal__ = _.terminal; del _\",\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 // This part works already in both Pyodide and MicroPython\n io.stderr = (error) => {\n pyterminal_write(String(error.message || error));\n };\n\n // MicroPython has no code or code.interact()\n // This part patches it in a way that simulates\n // the code.interact() module in Pyodide.\n if (type === \"mpy\") {\n // monkey patch global input otherwise broken in MicroPython\n interpreter.registerJsModule(\"_pyscript_input\", {\n input: pyterminal_read,\n });\n run(\"from _pyscript_input import input\");\n\n // this is needed to avoid truncated unicode in MicroPython\n // the reason is that `linebuffer` false just send one byte\n // per time and readline here doesn't like it much.\n // MicroPython also has issues with code-points and\n // replProcessChar(byte) but that function accepts only\n // one byte per time so ... we have an issue!\n // @see https://github.com/pyscript/pyscript/pull/2018\n // @see https://github.com/WebReflection/buffer-points\n const bufferPoints = (stdio) => {\n const bytes = [];\n let needed = 0;\n return (buffer) => {\n let written = 0;\n for (const byte of buffer) {\n bytes.push(byte);\n // @see https://encoding.spec.whatwg.org/#utf-8-bytes-needed\n if (needed) needed--;\n else if (0xc2 <= byte && byte <= 0xdf) needed = 1;\n else if (0xe0 <= byte && byte <= 0xef) needed = 2;\n else if (0xf0 <= byte && byte <= 0xf4) needed = 3;\n if (!needed) {\n written += bytes.length;\n stdio(new Uint8Array(bytes.splice(0)));\n }\n }\n return written;\n };\n };\n\n io.stdout = bufferPoints(generic.write);\n\n // tiny shim of the code module with only interact\n // to bootstrap a REPL like environment\n interpreter.registerJsModule(\"code\", {\n interact() {\n let input = \"\";\n let length = 1;\n\n const encoder = new TextEncoder();\n const acc = [];\n const handlePoints = bufferPoints((buffer) => {\n acc.push(...buffer);\n pyterminal_write(decoder.decode(buffer));\n });\n\n // avoid duplicating the output produced by the input\n io.stdout = (buffer) =>\n length++ > input.length ? handlePoints(buffer) : 0;\n\n interpreter.replInit();\n\n // loop forever waiting for user inputs\n (function repl() {\n const out = decoder.decode(new Uint8Array(acc.splice(0)));\n // print in current line only the last line produced by the REPL\n const data = `${pyterminal_read(out.split(\"\\n\").at(-1))}\\r`;\n length = 0;\n input = encoder.encode(data);\n for (const c of input) interpreter.replProcessChar(c);\n repl();\n })();\n },\n });\n } else {\n interpreter.setStdout(generic);\n interpreter.setStderr(generic);\n interpreter.setStdin({\n isatty: false,\n stdin: () => pyterminal_read(data),\n });\n }\n};\n\nconst pyTerminal = async (element) => {\n // lazy load these only when a valid terminal is found\n const [{ Terminal }, { Readline }, { FitAddon }] = await Promise.all([\n import(/* webpackIgnore: true */ \"../3rd-party/xterm.js\"),\n import(/* webpackIgnore: true */ \"../3rd-party/xterm-readline.js\"),\n import(/* webpackIgnore: true */ \"../3rd-party/xterm_addon-fit.js\"),\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.open(target);\n fitAddon.fit();\n terminal.focus();\n defineProperty(element, \"terminal\", { value: terminal });\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 });\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 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 if (type === \"mpy\") {\n interpreter.setStdin = Object; // as no-op\n interpreter.setStderr = Object; // as no-op\n interpreter.setStdout = ({ write }) => {\n io.stdout = write;\n };\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\nfor (const key of TYPES.keys()) {\n const selector = `script[type=\"${key}\"][terminal],${key}-script[terminal]`;\n SELECTORS.push(selector);\n customObserver.set(selector, async (element) => {\n // we currently support only one terminal on main as in \"classic\"\n const terminals = document.querySelectorAll(SELECTORS.join(\",\"));\n if ([].filter.call(terminals, onceOnMain).length > 1)\n notifyAndThrow(\"You can use at most 1 main terminal\");\n\n // import styles lazily\n if (addStyle) {\n addStyle = false;\n document.head.append(\n Object.assign(document.createElement(\"link\"), {\n rel: \"stylesheet\",\n href: new URL(\"./xterm.css\", import.meta.url),\n }),\n );\n }\n\n await pyTerminal(element);\n });\n}\n"],"names":["SELECTORS","notifyAndThrow","message","notify","Error","onceOnMain","attributes","worker","bootstrapped","WeakSet","addStyle","workerReady","interpreter","io","run","type","sync","is_pyterminal","data","pyterminal_read","pyterminal_write","decoder","TextDecoder","generic","isatty","write","buffer","decode","length","stderr","error","String","registerJsModule","input","bufferPoints","stdio","bytes","needed","written","byte","push","Uint8Array","splice","stdout","interact","encoder","TextEncoder","acc","handlePoints","replInit","repl","out","split","at","encode","c","replProcessChar","setStdout","setStderr","setStdin","stdin","pyTerminal","async","element","Terminal","Readline","FitAddon","Promise","all","import","readline","init","options","target","selector","getAttribute","document","getElementById","querySelector","createElement","style","display","after","terminal","theme","background","foreground","fitAddon","loadAddon","open","fit","focus","defineProperty","value","hasAttribute","hooks","main","onWorker","add","_","xworker","has","delete","disableStdin","cursorBlink","cursorStyle","read","bind","onReady","console","warn","globalThis","__py_terminal__","Object","key","TYPES","keys","customObserver","set","terminals","querySelectorAll","join","filter","call","head","append","assign","rel","href","URL","url"],"mappings":"yGAMA,MAAMA,EAAY,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UyH,KAAK,MACvD,GAAGC,OAAOC,KAAKJ,EAAWlH,GAAYuB,OAAS,GAC/C3B,EAAe,uCAGfS,IACAA,GAAW,EACXkE,SAASgD,KAAKC,OACVZ,OAAOa,OAAOlD,SAASG,cAAc,QAAS,CAC1CgD,IAAK,aACLC,KAAM,IAAIC,IAAI,0BAA2BC,eAK/CrE,EAAWE,EAAQ,GAEjC"}
|
1
|
+
{"version":3,"file":"py-terminal-K6pA-YwA.js","sources":["../src/plugins/py-terminal.js"],"sourcesContent":["// PyScript py-terminal plugin\nimport { TYPES, hooks } from \"../core.js\";\nimport { notify } from \"./error.js\";\nimport { customObserver, defineProperty } from \"polyscript/exports\";\n\n// will contain all valid selectors\nconst SELECTORS = [];\n\n// show the error on main and\n// stops the module from keep executing\nconst notifyAndThrow = (message) => {\n notify(message);\n throw new Error(message);\n};\n\nconst onceOnMain = ({ attributes: { worker } }) => !worker;\n\nconst bootstrapped = new WeakSet();\n\nlet addStyle = true;\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 (!sync.is_pyterminal()) return;\n\n // in workers it's always safe to grab the polyscript currentScript\n // the ugly `_` dance is due MicroPython not able to import via:\n // `from polyscript.currentScript import terminal as __terminal__`\n run(\n \"from polyscript import currentScript as _; __terminal__ = _.terminal; del _\",\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 // This part works already in both Pyodide and MicroPython\n io.stderr = (error) => {\n pyterminal_write(String(error.message || error));\n };\n\n // MicroPython has no code or code.interact()\n // This part patches it in a way that simulates\n // the code.interact() module in Pyodide.\n if (type === \"mpy\") {\n // monkey patch global input otherwise broken in MicroPython\n interpreter.registerJsModule(\"_pyscript_input\", {\n input: pyterminal_read,\n });\n run(\"from _pyscript_input import input\");\n\n // this is needed to avoid truncated unicode in MicroPython\n // the reason is that `linebuffer` false just send one byte\n // per time and readline here doesn't like it much.\n // MicroPython also has issues with code-points and\n // replProcessChar(byte) but that function accepts only\n // one byte per time so ... we have an issue!\n // @see https://github.com/pyscript/pyscript/pull/2018\n // @see https://github.com/WebReflection/buffer-points\n const bufferPoints = (stdio) => {\n const bytes = [];\n let needed = 0;\n return (buffer) => {\n let written = 0;\n for (const byte of buffer) {\n bytes.push(byte);\n // @see https://encoding.spec.whatwg.org/#utf-8-bytes-needed\n if (needed) needed--;\n else if (0xc2 <= byte && byte <= 0xdf) needed = 1;\n else if (0xe0 <= byte && byte <= 0xef) needed = 2;\n else if (0xf0 <= byte && byte <= 0xf4) needed = 3;\n if (!needed) {\n written += bytes.length;\n stdio(new Uint8Array(bytes.splice(0)));\n }\n }\n return written;\n };\n };\n\n io.stdout = bufferPoints(generic.write);\n\n // tiny shim of the code module with only interact\n // to bootstrap a REPL like environment\n interpreter.registerJsModule(\"code\", {\n interact() {\n let input = \"\";\n let length = 1;\n\n const encoder = new TextEncoder();\n const acc = [];\n const handlePoints = bufferPoints((buffer) => {\n acc.push(...buffer);\n pyterminal_write(decoder.decode(buffer));\n });\n\n // avoid duplicating the output produced by the input\n io.stdout = (buffer) =>\n length++ > input.length ? handlePoints(buffer) : 0;\n\n interpreter.replInit();\n\n // loop forever waiting for user inputs\n (function repl() {\n const out = decoder.decode(new Uint8Array(acc.splice(0)));\n // print in current line only the last line produced by the REPL\n const data = `${pyterminal_read(out.split(\"\\n\").at(-1))}\\r`;\n length = 0;\n input = encoder.encode(data);\n for (const c of input) interpreter.replProcessChar(c);\n repl();\n })();\n },\n });\n } else {\n interpreter.setStdout(generic);\n interpreter.setStderr(generic);\n interpreter.setStdin({\n isatty: false,\n stdin: () => pyterminal_read(data),\n });\n }\n};\n\nconst pyTerminal = async (element) => {\n // lazy load these only when a valid terminal is found\n const [{ Terminal }, { Readline }, { FitAddon }] = await Promise.all([\n import(/* webpackIgnore: true */ \"../3rd-party/xterm.js\"),\n import(/* webpackIgnore: true */ \"../3rd-party/xterm-readline.js\"),\n import(/* webpackIgnore: true */ \"../3rd-party/xterm_addon-fit.js\"),\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.open(target);\n fitAddon.fit();\n terminal.focus();\n defineProperty(element, \"terminal\", { value: terminal });\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 });\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 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 if (type === \"mpy\") {\n interpreter.setStdin = Object; // as no-op\n interpreter.setStderr = Object; // as no-op\n interpreter.setStdout = ({ write }) => {\n io.stdout = write;\n };\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\nfor (const key of TYPES.keys()) {\n const selector = `script[type=\"${key}\"][terminal],${key}-script[terminal]`;\n SELECTORS.push(selector);\n customObserver.set(selector, async (element) => {\n // we currently support only one terminal on main as in \"classic\"\n const terminals = document.querySelectorAll(SELECTORS.join(\",\"));\n if ([].filter.call(terminals, onceOnMain).length > 1)\n notifyAndThrow(\"You can use at most 1 main terminal\");\n\n // import styles lazily\n if (addStyle) {\n addStyle = false;\n document.head.append(\n Object.assign(document.createElement(\"link\"), {\n rel: \"stylesheet\",\n href: new URL(\"./xterm.css\", import.meta.url),\n }),\n );\n }\n\n await pyTerminal(element);\n });\n}\n"],"names":["SELECTORS","notifyAndThrow","message","notify","Error","onceOnMain","attributes","worker","bootstrapped","WeakSet","addStyle","workerReady","interpreter","io","run","type","sync","is_pyterminal","data","pyterminal_read","pyterminal_write","decoder","TextDecoder","generic","isatty","write","buffer","decode","length","stderr","error","String","registerJsModule","input","bufferPoints","stdio","bytes","needed","written","byte","push","Uint8Array","splice","stdout","interact","encoder","TextEncoder","acc","handlePoints","replInit","repl","out","split","at","encode","c","replProcessChar","setStdout","setStderr","setStdin","stdin","pyTerminal","async","element","Terminal","Readline","FitAddon","Promise","all","import","readline","init","options","target","selector","getAttribute","document","getElementById","querySelector","createElement","style","display","after","terminal","theme","background","foreground","fitAddon","loadAddon","open","fit","focus","defineProperty","value","hasAttribute","hooks","main","onWorker","add","_","xworker","has","delete","disableStdin","cursorBlink","cursorStyle","read","bind","onReady","console","warn","globalThis","__py_terminal__","Object","key","TYPES","keys","customObserver","set","terminals","querySelectorAll","join","filter","call","head","append","assign","rel","href","URL","url"],"mappings":"yGAMA,MAAMA,EAAY,GAIZC,EAAkBC,IAEpB,MADAC,EAAOD,GACD,IAAIE,MAAMF,EAAQ,EAGtBG,EAAa,EAAGC,YAAcC,cAAgBA,EAE9CC,EAAe,IAAIC,QAEzB,IAAIC,GAAW,EAKf,MAAMC,EAAc,EAAGC,cAAaC,KAAIC,MAAKC,SAAUC,WACnD,IAAKA,EAAKC,gBAAiB,OAK3BH,EACI,+EAGJ,IAAII,EAAO,GACX,MAAMC,gBAAEA,EAAeC,iBAAEA,GAAqBJ,EACxCK,EAAU,IAAIC,YACdC,EAAU,CACZC,QAAQ,EACRC,MAAMC,IACFR,EAAOG,EAAQM,OAAOD,GACtBN,EAAiBF,GACVQ,EAAOE,SAYtB,GAPAf,EAAGgB,OAAUC,IACTV,EAAiBW,OAAOD,EAAM5B,SAAW4B,GAAO,EAMvC,QAATf,EAAgB,CAEhBH,EAAYoB,iBAAiB,kBAAmB,CAC5CC,MAAOd,IAEXL,EAAI,qCAUJ,MAAMoB,EAAgBC,IAClB,MAAMC,EAAQ,GACd,IAAIC,EAAS,EACb,OAAQX,IACJ,IAAIY,EAAU,EACd,IAAK,MAAMC,KAAQb,EACfU,EAAMI,KAAKD,GAEPF,EAAQA,IACH,KAAQE,GAAQA,GAAQ,IAAMF,EAAS,EACvC,KAAQE,GAAQA,GAAQ,IAAMF,EAAS,EACvC,KAAQE,GAAQA,GAAQ,MAAMF,EAAS,GAC3CA,IACDC,GAAWF,EAAMR,OACjBO,EAAM,IAAIM,WAAWL,EAAMM,OAAO,MAG1C,OAAOJ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,UAAUnC,GACtBX,EAAY+C,SAAS,CACjBnC,QAAQ,EACRoC,MAAO,IAAMU,EAASoC,KAAKxF,IAE3C,GACK,EAGL,IAAK,MAAMgG,KAAOC,EAAMC,OAAQ,CAC5B,MAAM1C,EAAW,gBAAgBwC,iBAAmBA,qBACpDlH,EAAUwC,KAAKkC,GACf2C,EAAeC,IAAI5C,GAAUZ,MAAOC,IAEhC,MAAMwD,EAAY3C,SAAS4C,iBAAiBxH,EAAUyH,KAAK,MACvD,GAAGC,OAAOC,KAAKJ,EAAWlH,GAAYuB,OAAS,GAC/C3B,EAAe,uCAGfS,IACAA,GAAW,EACXkE,SAASgD,KAAKC,OACVZ,OAAOa,OAAOlD,SAASG,cAAc,QAAS,CAC1CgD,IAAK,aACLC,KAAM,IAAIC,IAAI,0BAA2BC,eAK/CrE,EAAWE,EAAQ,GAEjC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"xterm_addon-fit--gyF3PcZ.js","sources":["../src/3rd-party/xterm_addon-fit.js"],"sourcesContent":["/**\n * Bundled by jsDelivr using Rollup v2.79.1 and Terser v5.19.2.\n * Original file: /npm/@xterm/addon-fit@0.
|
1
|
+
{"version":3,"file":"xterm_addon-fit--gyF3PcZ.js","sources":["../src/3rd-party/xterm_addon-fit.js"],"sourcesContent":["/**\n * Bundled by jsDelivr using Rollup v2.79.1 and Terser v5.19.2.\n * Original file: /npm/@xterm/addon-fit@0.10.0/lib/addon-fit.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\nvar e,t,r={exports:{}};self;var s=r.exports=(e=t={},Object.defineProperty(e,\"__esModule\",{value:!0}),e.FitAddon=void 0,e.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){const e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;const t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal)return;if(!this._terminal.element||!this._terminal.element.parentElement)return;const e=this._terminal._core,t=e._renderService.dimensions;if(0===t.css.cell.width||0===t.css.cell.height)return;const r=0===this._terminal.options.scrollback?0:e.viewport.scrollBarWidth,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue(\"height\")),o=Math.max(0,parseInt(s.getPropertyValue(\"width\"))),n=window.getComputedStyle(this._terminal.element),l=i-(parseInt(n.getPropertyValue(\"padding-top\"))+parseInt(n.getPropertyValue(\"padding-bottom\"))),a=o-(parseInt(n.getPropertyValue(\"padding-right\"))+parseInt(n.getPropertyValue(\"padding-left\")))-r;return{cols:Math.max(2,Math.floor(a/t.css.cell.width)),rows:Math.max(1,Math.floor(l/t.css.cell.height))}}},t),i=r.exports.FitAddon,o=r.exports.__esModule;export{i as FitAddon,o as __esModule,s as default};\n"],"names":["e","t","r","exports","s","Object","defineProperty","value","FitAddon","activate","this","_terminal","dispose","fit","proposeDimensions","isNaN","cols","rows","_core","_renderService","clear","resize","element","parentElement","dimensions","css","cell","width","height","options","scrollback","viewport","scrollBarWidth","window","getComputedStyle","i","parseInt","getPropertyValue","o","Math","max","n","l","a","floor","__esModule"],"mappings":"AAMA,IAAIA,EAAEC,EAAEC,EAAE,CAACC,QAAQ,CAAE,GAAWC,EAAEF,EAAEC,SAASH,EAAEC,EAAE,CAAA,EAAGI,OAAOC,eAAeN,EAAE,aAAa,CAACO,OAAM,IAAKP,EAAEQ,cAAS,EAAOR,EAAEQ,SAAS,MAAM,QAAAC,CAAST,GAAGU,KAAKC,UAAUX,CAAC,CAAC,OAAAY,IAAW,GAAAC,GAAM,MAAMb,EAAEU,KAAKI,oBAAoB,IAAId,IAAIU,KAAKC,WAAWI,MAAMf,EAAEgB,OAAOD,MAAMf,EAAEiB,MAAM,OAAO,MAAMhB,EAAES,KAAKC,UAAUO,MAAMR,KAAKC,UAAUM,OAAOjB,EAAEiB,MAAMP,KAAKC,UAAUK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"module": "./index.js",
|
@@ -20,7 +20,7 @@
|
|
20
20
|
},
|
21
21
|
"scripts": {
|
22
22
|
"server": "npx static-handler --coi .",
|
23
|
-
"build": "npm run build:3rd-party && npm run build:stdlib && npm run build:plugins && npm run build:core && eslint src/ && npm run ts && npm run test:mpy",
|
23
|
+
"build": "export ESLINT_USE_FLAT_CONFIG=false; npm run build:3rd-party && npm run build:stdlib && npm run build:plugins && npm run build:core && eslint src/ && npm run ts && npm run test:mpy",
|
24
24
|
"build:core": "rm -rf dist && rollup --config rollup/core.config.js && cp src/3rd-party/*.css dist/",
|
25
25
|
"build:plugins": "node rollup/plugins.cjs",
|
26
26
|
"build:stdlib": "node rollup/stdlib.cjs",
|
@@ -42,7 +42,7 @@
|
|
42
42
|
"dependencies": {
|
43
43
|
"@ungap/with-resolvers": "^0.1.0",
|
44
44
|
"basic-devtools": "^0.1.6",
|
45
|
-
"polyscript": "^0.12.
|
45
|
+
"polyscript": "^0.12.3",
|
46
46
|
"sticky-module": "^0.1.1",
|
47
47
|
"to-json-callback": "^0.1.1",
|
48
48
|
"type-checked-collections": "^0.1.7"
|
@@ -52,21 +52,21 @@
|
|
52
52
|
"@codemirror/lang-python": "^6.1.5",
|
53
53
|
"@codemirror/language": "^6.10.1",
|
54
54
|
"@codemirror/state": "^6.4.1",
|
55
|
-
"@codemirror/view": "^6.26.
|
56
|
-
"@playwright/test": "^1.
|
55
|
+
"@codemirror/view": "^6.26.2",
|
56
|
+
"@playwright/test": "^1.43.0",
|
57
57
|
"@rollup/plugin-commonjs": "^25.0.7",
|
58
58
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
59
59
|
"@rollup/plugin-terser": "^0.4.4",
|
60
60
|
"@webreflection/toml-j0.4": "^1.1.3",
|
61
|
-
"@xterm/addon-fit": "^0.
|
61
|
+
"@xterm/addon-fit": "^0.10.0",
|
62
62
|
"chokidar": "^3.6.0",
|
63
63
|
"codemirror": "^6.0.1",
|
64
|
-
"eslint": "^
|
65
|
-
"rollup": "^4.14.
|
64
|
+
"eslint": "^9.0.0",
|
65
|
+
"rollup": "^4.14.1",
|
66
66
|
"rollup-plugin-postcss": "^4.0.2",
|
67
67
|
"rollup-plugin-string": "^3.0.0",
|
68
68
|
"static-handler": "^0.4.3",
|
69
|
-
"typescript": "^5.4.
|
69
|
+
"typescript": "^5.4.4",
|
70
70
|
"xterm": "^5.3.0",
|
71
71
|
"xterm-readline": "^1.1.1"
|
72
72
|
},
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
* Bundled by jsDelivr using Rollup v2.79.1 and Terser v5.19.2.
|
3
|
-
* Original file: /npm/@xterm/addon-fit@0.
|
3
|
+
* Original file: /npm/@xterm/addon-fit@0.10.0/lib/addon-fit.js
|
4
4
|
*
|
5
5
|
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
6
6
|
*/
|
package/src/plugins/py-editor.js
CHANGED
@@ -15,8 +15,8 @@ const hooks = {
|
|
15
15
|
codeBeforeRun: () => stdlib,
|
16
16
|
// works on both Pyodide and MicroPython
|
17
17
|
onReady: ({ runAsync, io }, { sync }) => {
|
18
|
-
io.stdout = (
|
19
|
-
io.stderr = (
|
18
|
+
io.stdout = io.buffered(sync.write);
|
19
|
+
io.stderr = io.buffered(sync.writeErr);
|
20
20
|
sync.revoke();
|
21
21
|
sync.runAsync = runAsync;
|
22
22
|
},
|
package/types/core.d.ts
CHANGED
@@ -51,5 +51,4 @@ declare const exportedHooks: {
|
|
51
51
|
};
|
52
52
|
declare const exportedConfig: {};
|
53
53
|
declare const exportedWhenDefined: (type: string) => Promise<any>;
|
54
|
-
import sync from "./sync.js";
|
55
54
|
export { stdlib, TYPES, exportedPyWorker as PyWorker, exportedMPWorker as MPWorker, exportedHooks as hooks, exportedConfig as config, exportedWhenDefined as whenDefined };
|