@pyscript/core 0.6.11 → 0.6.12

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.
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-CL2MCT5A.js","sources":["../src/plugins/error.js"],"sourcesContent":["// PyScript Error Plugin\nimport { buffered } from \"polyscript/exports\";\nconsole.log('error.js');\nimport(\"../core.js\").then(console.log);\nimport { hooks } from \"../core.js\";\n\nlet dontBotherDOM = false;\nexport function notOnDOM() {\n dontBotherDOM = true;\n}\n\nhooks.main.onReady.add(function override(pyScript) {\n // be sure this override happens only once\n hooks.main.onReady.delete(override);\n\n // trap generic `stderr` to propagate to it regardless\n const { stderr } = pyScript.io;\n\n const cb = (error, ...rest) => {\n notify(error.message || error);\n // let other plugins or stderr hook, if any, do the rest\n return stderr(error, ...rest);\n };\n\n // override it with our own logic\n pyScript.io.stderr = pyScript.type === \"py\" ? cb : buffered(cb);\n\n // be sure uncaught Python errors are also visible\n addEventListener(\"error\", ({ message }) => {\n if (message.startsWith(\"Uncaught PythonError\")) notify(message);\n });\n});\n\n// Error hook utilities\n\n// Custom function to show notifications\n\n/**\n * Add a banner to the top of the page, notifying the user of an error\n * @param {string} message\n */\nexport function notify(message) {\n if (dontBotherDOM) return;\n const div = document.createElement(\"div\");\n div.className = \"py-error\";\n div.textContent = message;\n div.style.cssText = `\n border: 1px solid red;\n background: #ffdddd;\n color: black;\n font-family: courier, monospace;\n white-space: pre;\n overflow-x: auto;\n padding: 8px;\n margin-top: 8px;\n `;\n document.body.append(div);\n}\n"],"names":["console","log","import","then","dontBotherDOM","notOnDOM","notify","message","div","document","createElement","className","textContent","style","cssText","body","append","hooks","main","onReady","add","override","pyScript","delete","stderr","io","cb","error","rest","type","buffered","addEventListener","startsWith"],"mappings":"yCAEAA,QAAQC,IAAI,YACZC,OAAO,aAAcC,KAAKH,QAAQC,KAGlC,IAAIG,GAAgB,EACb,SAASC,IACZD,GAAgB,CACpB,CAgCO,SAASE,EAAOC,GACnB,GAAIH,EAAe,OACnB,MAAMI,EAAMC,SAASC,cAAc,OACnCF,EAAIG,UAAY,WAChBH,EAAII,YAAcL,EAClBC,EAAIK,MAAMC,QAAU,6MAUpBL,SAASM,KAAKC,OAAOR,EACzB,CA9CAS,EAAMC,KAAKC,QAAQC,KAAI,SAASC,EAASC,GAErCL,EAAMC,KAAKC,QAAQI,OAAOF,GAG1B,MAAMG,OAAEA,GAAWF,EAASG,GAEtBC,EAAK,CAACC,KAAUC,KAClBtB,EAAOqB,EAAMpB,SAAWoB,GAEjBH,EAAOG,KAAUC,IAI5BN,EAASG,GAAGD,OAA2B,OAAlBF,EAASO,KAAgBH,EAAKI,EAASJ,GAG5DK,iBAAiB,SAAS,EAAGxB,cACrBA,EAAQyB,WAAW,yBAAyB1B,EAAOC,EAAQ,GAEvE"}