@pyscript/core 0.2.9 → 0.3.0
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/dev.cjs +31 -0
- package/dist/core.js +4 -3
- package/dist/core.js.map +1 -1
- package/dist/error-96hMSEw8.js +2 -0
- package/dist/error-96hMSEw8.js.map +1 -0
- package/docs/README.md +1 -1
- package/package.json +15 -5
- package/src/core.js +164 -134
- package/src/exceptions.js +4 -2
- package/src/fetch.js +1 -1
- package/src/hooks.js +85 -22
- package/src/plugins/error.js +2 -2
- package/src/plugins-helper.js +26 -0
- package/types/core.d.ts +5 -16
- package/types/hooks.d.ts +37 -12
- package/types/plugins-helper.d.ts +2 -0
- package/dist/error-q53fTtv2.js +0 -2
- package/dist/error-q53fTtv2.js.map +0 -1
package/types/hooks.d.ts
CHANGED
@@ -1,13 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
export function main(name: any): any;
|
2
|
+
export function worker(name: any): any;
|
3
|
+
export function codeFor(branch: any): {};
|
4
|
+
export function createFunction(self: any, name: any): any;
|
5
|
+
export namespace hooks {
|
6
|
+
namespace main {
|
7
|
+
let onWorker: Set<Function>;
|
8
|
+
let onReady: Set<Function>;
|
9
|
+
let onBeforeRun: Set<Function>;
|
10
|
+
let onBeforeRunAsync: Set<Function>;
|
11
|
+
let onAfterRun: Set<Function>;
|
12
|
+
let onAfterRunAsync: Set<Function>;
|
13
|
+
let codeBeforeRun: Set<string>;
|
14
|
+
let codeBeforeRunAsync: Set<string>;
|
15
|
+
let codeAfterRun: Set<string>;
|
16
|
+
let codeAfterRunAsync: Set<string>;
|
17
|
+
}
|
18
|
+
namespace worker {
|
19
|
+
let onReady_1: Set<Function>;
|
20
|
+
export { onReady_1 as onReady };
|
21
|
+
let onBeforeRun_1: Set<Function>;
|
22
|
+
export { onBeforeRun_1 as onBeforeRun };
|
23
|
+
let onBeforeRunAsync_1: Set<Function>;
|
24
|
+
export { onBeforeRunAsync_1 as onBeforeRunAsync };
|
25
|
+
let onAfterRun_1: Set<Function>;
|
26
|
+
export { onAfterRun_1 as onAfterRun };
|
27
|
+
let onAfterRunAsync_1: Set<Function>;
|
28
|
+
export { onAfterRunAsync_1 as onAfterRunAsync };
|
29
|
+
let codeBeforeRun_1: Set<string>;
|
30
|
+
export { codeBeforeRun_1 as codeBeforeRun };
|
31
|
+
let codeBeforeRunAsync_1: Set<string>;
|
32
|
+
export { codeBeforeRunAsync_1 as codeBeforeRunAsync };
|
33
|
+
let codeAfterRun_1: Set<string>;
|
34
|
+
export { codeAfterRun_1 as codeAfterRun };
|
35
|
+
let codeAfterRunAsync_1: Set<string>;
|
36
|
+
export { codeAfterRunAsync_1 as codeAfterRunAsync };
|
37
|
+
}
|
12
38
|
}
|
13
|
-
export default _default;
|
package/dist/error-q53fTtv2.js
DELETED
@@ -1,2 +0,0 @@
|
|
1
|
-
import{hooks as e}from"./core.js";function r(e){const r=document.createElement("div");r.className="py-error",r.textContent=e,r.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 ",document.body.append(r)}e.onInterpreterReady.add((function n(t){e.onInterpreterReady.delete(n);const{stderr:o}=t.io;t.io.stderr=(e,...n)=>(r(e.message||e),o(e,...n)),addEventListener("error",(({message:e})=>{e.startsWith("Uncaught PythonError")&&r(e)}))}));export{r as notify};
|
2
|
-
//# sourceMappingURL=error-q53fTtv2.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"error-q53fTtv2.js","sources":["../src/plugins/error.js"],"sourcesContent":["// PyScript Error Plugin\nimport { hooks } from \"../core.js\";\n\nhooks.onInterpreterReady.add(function override(pyScript) {\n // be sure this override happens only once\n hooks.onInterpreterReady.delete(override);\n\n // trap generic `stderr` to propagate to it regardless\n const { stderr } = pyScript.io;\n\n // override it with our own logic\n pyScript.io.stderr = (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 // 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 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":["notify","message","div","document","createElement","className","textContent","style","cssText","body","append","hooks","onInterpreterReady","add","override","pyScript","delete","stderr","io","error","rest","addEventListener","startsWith"],"mappings":"kCA+BO,SAASA,EAAOC,GACnB,MAAMC,EAAMC,SAASC,cAAc,OACnCF,EAAIG,UAAY,WAChBH,EAAII,YAAcL,EAClBC,EAAIK,MAAMC,QAAU,6MAUpBL,SAASM,KAAKC,OAAOR,EACzB,CA3CAS,EAAMC,mBAAmBC,KAAI,SAASC,EAASC,GAE3CJ,EAAMC,mBAAmBI,OAAOF,GAGhC,MAAMG,OAAEA,GAAWF,EAASG,GAG5BH,EAASG,GAAGD,OAAS,CAACE,KAAUC,KAC5BpB,EAAOmB,EAAMlB,SAAWkB,GAEjBF,EAAOE,KAAUC,IAI5BC,iBAAiB,SAAS,EAAGpB,cACrBA,EAAQqB,WAAW,yBAAyBtB,EAAOC,EAAQ,GAEvE"}
|