@pyscript/core 0.6.9 → 0.6.10
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-CAEZ6Sg7.js +2 -0
- package/dist/{codemirror-1dOfKU91.js.map → codemirror-CAEZ6Sg7.js.map} +1 -1
- package/dist/codemirror_commands-BPM8HxXO.js +2 -0
- package/dist/{codemirror_commands-CKMxnUcp.js.map → codemirror_commands-BPM8HxXO.js.map} +1 -1
- package/dist/codemirror_lang-python-DvjhpaK2.js +2 -0
- package/dist/{codemirror_lang-python-D9DYtDWr.js.map → codemirror_lang-python-DvjhpaK2.js.map} +1 -1
- package/dist/codemirror_language-4kk4Aqm3.js +2 -0
- package/dist/{codemirror_language-B5lTPv2c.js.map → codemirror_language-4kk4Aqm3.js.map} +1 -1
- package/dist/codemirror_state-1d1uncXx.js +2 -0
- package/dist/{codemirror_state-n1sFh2hh.js.map → codemirror_state-1d1uncXx.js.map} +1 -1
- package/dist/codemirror_view-aIuSN42d.js +2 -0
- package/dist/{codemirror_view-1a1gCrKZ.js.map → codemirror_view-aIuSN42d.js.map} +1 -1
- package/dist/core-Djc_-F2E.js +2 -0
- package/dist/core-Djc_-F2E.js.map +1 -0
- package/dist/core.css +1 -75
- package/dist/core.js +1 -1
- package/dist/deprecations-manager-CJPk1tJA.js +2 -0
- package/dist/{deprecations-manager-Cf_aFUPK.js.map → deprecations-manager-CJPk1tJA.js.map} +1 -1
- package/dist/donkey-B8oMxGx2.js +2 -0
- package/dist/{donkey-Cc8svH2Q.js.map → donkey-B8oMxGx2.js.map} +1 -1
- package/dist/error-B9FssCEE.js +2 -0
- package/dist/error-B9FssCEE.js.map +1 -0
- package/dist/index-DqgFLybq.js +2 -0
- package/dist/{index-BVFrv_QY.js.map → index-DqgFLybq.js.map} +1 -1
- package/dist/mpy-DHvNziqy.js +2 -0
- package/dist/{mpy-CQiuZcjW.js.map → mpy-DHvNziqy.js.map} +1 -1
- package/dist/py-C5GQdsZt.js +2 -0
- package/dist/{py-BgH4mprx.js.map → py-C5GQdsZt.js.map} +1 -1
- package/dist/py-editor-Bux-ztRb.js +2 -0
- package/dist/{py-editor-Dzsa3rsF.js.map → py-editor-Bux-ztRb.js.map} +1 -1
- package/dist/py-terminal-SqxsB6JH.js +2 -0
- package/dist/{py-terminal-BX_wPoTi.js.map → py-terminal-SqxsB6JH.js.map} +1 -1
- package/dist/storage.js +1 -421
- package/dist/storage.js.map +1 -1
- package/dist/toml-CvAfdf9_.js +3 -0
- package/dist/toml-CvAfdf9_.js.map +1 -0
- package/dist/toml-DiUM0_qs.js +3 -0
- package/dist/{toml-CkEFU7ly.js.map → toml-DiUM0_qs.js.map} +1 -1
- package/dist/xterm-BY7uk_OU.js +2 -0
- package/dist/xterm-BY7uk_OU.js.map +1 -0
- package/dist/xterm-readline-CZfBw7ic.js +2 -0
- package/dist/xterm-readline-CZfBw7ic.js.map +1 -0
- package/dist/xterm_addon-fit--gyF3PcZ.js +2 -0
- package/dist/xterm_addon-fit--gyF3PcZ.js.map +1 -0
- package/dist/xterm_addon-web-links-Cnej-nJ6.js +2 -0
- package/dist/xterm_addon-web-links-Cnej-nJ6.js.map +1 -0
- package/dist/zip-Bf48tRr5.js +2 -0
- package/dist/zip-Bf48tRr5.js.map +1 -0
- package/package.json +1 -1
- package/src/core.js +2 -2
- package/src/plugins/error.js +1 -1
- package/src/stdlib/pyscript.js +13 -13
- package/dist/codemirror-1dOfKU91.js +0 -1832
- package/dist/codemirror_commands-CKMxnUcp.js +0 -1714
- package/dist/codemirror_lang-python-D9DYtDWr.js +0 -2462
- package/dist/codemirror_language-B5lTPv2c.js +0 -5337
- package/dist/codemirror_state-n1sFh2hh.js +0 -3930
- package/dist/codemirror_view-1a1gCrKZ.js +0 -11428
- package/dist/core-D2ytnMSk.js +0 -4349
- package/dist/core-D2ytnMSk.js.map +0 -1
- package/dist/deprecations-manager-Cf_aFUPK.js +0 -29
- package/dist/donkey-Cc8svH2Q.js +0 -170
- package/dist/error-DWoeKPDI.js +0 -59
- package/dist/error-DWoeKPDI.js.map +0 -1
- package/dist/index-BVFrv_QY.js +0 -1911
- package/dist/mpy-CQiuZcjW.js +0 -255
- package/dist/py-BgH4mprx.js +0 -182
- package/dist/py-editor-Dzsa3rsF.js +0 -433
- package/dist/py-terminal-BX_wPoTi.js +0 -61
- package/dist/toml-CkEFU7ly.js +0 -103
- package/dist/toml-DTuPg5as.js +0 -5
- package/dist/toml-DTuPg5as.js.map +0 -1
- package/dist/xterm-eU6F6YKE.js +0 -10
- package/dist/xterm-eU6F6YKE.js.map +0 -1
- package/dist/xterm-readline-C7HDczqS.js +0 -501
- package/dist/xterm-readline-C7HDczqS.js.map +0 -1
- package/dist/xterm_addon-fit-Cotzxdkz.js +0 -10
- package/dist/xterm_addon-fit-Cotzxdkz.js.map +0 -1
- package/dist/xterm_addon-web-links-DoNfCjeX.js +0 -10
- package/dist/xterm_addon-web-links-DoNfCjeX.js.map +0 -1
- package/dist/zip-Cj6c-tjp.js +0 -13
- package/dist/zip-Cj6c-tjp.js.map +0 -1
@@ -1,29 +0,0 @@
|
|
1
|
-
import { e as exportedHooks } from './core-D2ytnMSk.js';
|
2
|
-
import { notify } from './error-DWoeKPDI.js';
|
3
|
-
|
4
|
-
// PyScript Derepcations Plugin
|
5
|
-
|
6
|
-
// react lazily on PyScript bootstrap
|
7
|
-
exportedHooks.main.onReady.add(checkDeprecations);
|
8
|
-
exportedHooks.main.onWorker.add(checkDeprecations);
|
9
|
-
|
10
|
-
/**
|
11
|
-
* Check that there are no scripts loading from pyscript.net/latest
|
12
|
-
*/
|
13
|
-
function checkDeprecations() {
|
14
|
-
const scripts = document.querySelectorAll("script");
|
15
|
-
for (const script of scripts) checkLoadingScriptsFromLatest(script.src);
|
16
|
-
}
|
17
|
-
|
18
|
-
/**
|
19
|
-
* Check if src being loaded from pyscript.net/latest and display a notification if true
|
20
|
-
* * @param {string} src
|
21
|
-
*/
|
22
|
-
function checkLoadingScriptsFromLatest(src) {
|
23
|
-
if (/\/pyscript\.net\/latest/.test(src)) {
|
24
|
-
notify(
|
25
|
-
"Loading scripts from latest is deprecated and will be removed soon. Please use a specific version instead.",
|
26
|
-
);
|
27
|
-
}
|
28
|
-
}
|
29
|
-
//# sourceMappingURL=deprecations-manager-Cf_aFUPK.js.map
|
package/dist/donkey-Cc8svH2Q.js
DELETED
@@ -1,170 +0,0 @@
|
|
1
|
-
import { a as dedent, f as assign } from './core-D2ytnMSk.js';
|
2
|
-
|
3
|
-
const { get } = Reflect;
|
4
|
-
|
5
|
-
const methods = [
|
6
|
-
'preventDefault',
|
7
|
-
'stopPropagation',
|
8
|
-
'stopImmediatePropagation',
|
9
|
-
];
|
10
|
-
|
11
|
-
const once = { once: true };
|
12
|
-
|
13
|
-
// avoid event.preventDefault throwing due illegal Proxy invocation
|
14
|
-
const bound = (e, value) => typeof value === 'function' ? value.bind(e) : value;
|
15
|
-
|
16
|
-
// traps the `event.currentTarget` to be sure it's available later on
|
17
|
-
class Handler {
|
18
|
-
#currentTarget;
|
19
|
-
constructor(currentTarget) {
|
20
|
-
this.#currentTarget = currentTarget;
|
21
|
-
}
|
22
|
-
get(e, name) {
|
23
|
-
// Did you know? event.currentTarget disappears from events on
|
24
|
-
// next tick, which is why this proxy handler needs to exist.
|
25
|
-
return name === 'currentTarget' ? this.#currentTarget : bound(e, get(e, name));
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
/**
|
30
|
-
* Add a listener that result as a Promise, fulfilled when the event happens once or rejected if the optional provided signal is aborted.
|
31
|
-
* @param {Element} element
|
32
|
-
* @param {string} type
|
33
|
-
* @param {{ signal?:AbortSignal, capture?:boolean, passive?:boolean, preventDefault?:boolean, stopPropagation?:boolean, stopImmediatePropagation?:boolean }?} options
|
34
|
-
* @returns {Promise<Event,Event>}
|
35
|
-
*/
|
36
|
-
var addPromiseListener = (element, type, options = null) => new Promise(
|
37
|
-
(resolve, reject) => {
|
38
|
-
const handler = new Handler(element);
|
39
|
-
if (options.signal) {
|
40
|
-
const abort = event => reject(new Proxy(event, handler));
|
41
|
-
options.signal.addEventListener('abort', abort, once);
|
42
|
-
if (options.signal.aborted)
|
43
|
-
return options.signal.dispatchEvent(new Event('abort'));
|
44
|
-
}
|
45
|
-
element.addEventListener(
|
46
|
-
type,
|
47
|
-
(event) => {
|
48
|
-
for (const method of methods) {
|
49
|
-
if (options[method]) event[method]();
|
50
|
-
}
|
51
|
-
resolve(new Proxy(event, handler));
|
52
|
-
},
|
53
|
-
{ ...options, ...once }
|
54
|
-
);
|
55
|
-
}
|
56
|
-
);
|
57
|
-
|
58
|
-
const { stringify } = JSON;
|
59
|
-
|
60
|
-
const invoke = (name, args) => `${name}(code, ${args.join(", ")})`;
|
61
|
-
|
62
|
-
const donkey = ({ type = "py", persistent, terminal, config }) => {
|
63
|
-
const args = persistent ? ["globals()", "__locals__"] : ["{}", "{}"];
|
64
|
-
|
65
|
-
const src = URL.createObjectURL(
|
66
|
-
new Blob([
|
67
|
-
[
|
68
|
-
// this array is to better minify this code once in production
|
69
|
-
"from pyscript import sync, config",
|
70
|
-
'__message__ = lambda e,v: f"\x1b[31m\x1b[1m{e.__name__}\x1b[0m: {v}"',
|
71
|
-
"__locals__ = {}",
|
72
|
-
'if config["type"] == "py":',
|
73
|
-
" import sys",
|
74
|
-
" def __error__(_):",
|
75
|
-
" info = sys.exc_info()",
|
76
|
-
" return __message__(info[0], info[1])",
|
77
|
-
"else:",
|
78
|
-
" __error__ = lambda e: __message__(e.__class__, e.value)",
|
79
|
-
"def execute(code):",
|
80
|
-
` try: return ${invoke("exec", args)};`,
|
81
|
-
" except Exception as e: print(__error__(e));",
|
82
|
-
"def evaluate(code):",
|
83
|
-
` try: return ${invoke("eval", args)};`,
|
84
|
-
" except Exception as e: print(__error__(e));",
|
85
|
-
"sync.execute = execute",
|
86
|
-
"sync.evaluate = evaluate",
|
87
|
-
].join("\n"),
|
88
|
-
]),
|
89
|
-
);
|
90
|
-
|
91
|
-
// create the script that exposes the code to execute or evaluate
|
92
|
-
const script = assign(document.createElement("script"), { type, src });
|
93
|
-
script.toggleAttribute("worker", true);
|
94
|
-
script.toggleAttribute("terminal", true);
|
95
|
-
if (terminal) script.setAttribute("target", terminal);
|
96
|
-
if (config) {
|
97
|
-
script.setAttribute(
|
98
|
-
"config",
|
99
|
-
typeof config === "string" ? config : stringify(config),
|
100
|
-
);
|
101
|
-
}
|
102
|
-
|
103
|
-
return addPromiseListener(
|
104
|
-
document.body.appendChild(script),
|
105
|
-
`${type}:done`,
|
106
|
-
{ stopPropagation: true },
|
107
|
-
).then(() => {
|
108
|
-
URL.revokeObjectURL(src);
|
109
|
-
return script;
|
110
|
-
});
|
111
|
-
};
|
112
|
-
|
113
|
-
const utils = async (options) => {
|
114
|
-
const script = await donkey(options);
|
115
|
-
const { xworker, process, terminal } = script;
|
116
|
-
const { execute, evaluate } = xworker.sync;
|
117
|
-
script.remove();
|
118
|
-
return {
|
119
|
-
xworker,
|
120
|
-
process,
|
121
|
-
terminal,
|
122
|
-
execute,
|
123
|
-
evaluate,
|
124
|
-
};
|
125
|
-
};
|
126
|
-
|
127
|
-
var donkey$1 = async (options = {}) => {
|
128
|
-
let farmer = await utils(options);
|
129
|
-
let working = false;
|
130
|
-
const kill = () => {
|
131
|
-
if (farmer) {
|
132
|
-
farmer.xworker.terminate();
|
133
|
-
farmer.terminal.dispose();
|
134
|
-
farmer = null;
|
135
|
-
}
|
136
|
-
working = false;
|
137
|
-
};
|
138
|
-
const reload = async () => {
|
139
|
-
kill();
|
140
|
-
farmer = await utils(options);
|
141
|
-
};
|
142
|
-
const asyncTask = (method) => async (code) => {
|
143
|
-
// race condition ... a new task has been
|
144
|
-
// assigned while the previous one didn't finish
|
145
|
-
if (working) await reload();
|
146
|
-
working = true;
|
147
|
-
try {
|
148
|
-
return await farmer[method](dedent(code));
|
149
|
-
} catch (e) {
|
150
|
-
console.error(e);
|
151
|
-
} finally {
|
152
|
-
working = false;
|
153
|
-
}
|
154
|
-
};
|
155
|
-
const asyncMethod = (method) => async () => {
|
156
|
-
if (working) await reload();
|
157
|
-
else farmer?.terminal[method]();
|
158
|
-
};
|
159
|
-
return {
|
160
|
-
process: asyncTask("process"),
|
161
|
-
execute: asyncTask("execute"),
|
162
|
-
evaluate: asyncTask("evaluate"),
|
163
|
-
clear: asyncMethod("clear"),
|
164
|
-
reset: asyncMethod("reset"),
|
165
|
-
kill,
|
166
|
-
};
|
167
|
-
};
|
168
|
-
|
169
|
-
export { donkey$1 as default };
|
170
|
-
//# sourceMappingURL=donkey-Cc8svH2Q.js.map
|
package/dist/error-DWoeKPDI.js
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
import { e as exportedHooks, b as buffered } from './core-D2ytnMSk.js';
|
2
|
-
|
3
|
-
// PyScript Error Plugin
|
4
|
-
|
5
|
-
let dontBotherDOM = false;
|
6
|
-
function notOnDOM() {
|
7
|
-
dontBotherDOM = true;
|
8
|
-
}
|
9
|
-
|
10
|
-
exportedHooks.main.onReady.add(function override(pyScript) {
|
11
|
-
// be sure this override happens only once
|
12
|
-
exportedHooks.main.onReady.delete(override);
|
13
|
-
|
14
|
-
// trap generic `stderr` to propagate to it regardless
|
15
|
-
const { stderr } = pyScript.io;
|
16
|
-
|
17
|
-
const cb = (error, ...rest) => {
|
18
|
-
notify(error.message || error);
|
19
|
-
// let other plugins or stderr hook, if any, do the rest
|
20
|
-
return stderr(error, ...rest);
|
21
|
-
};
|
22
|
-
|
23
|
-
// override it with our own logic
|
24
|
-
pyScript.io.stderr = pyScript.type === "py" ? cb : buffered(cb);
|
25
|
-
|
26
|
-
// be sure uncaught Python errors are also visible
|
27
|
-
addEventListener("error", ({ message }) => {
|
28
|
-
if (message.startsWith("Uncaught PythonError")) notify(message);
|
29
|
-
});
|
30
|
-
});
|
31
|
-
|
32
|
-
// Error hook utilities
|
33
|
-
|
34
|
-
// Custom function to show notifications
|
35
|
-
|
36
|
-
/**
|
37
|
-
* Add a banner to the top of the page, notifying the user of an error
|
38
|
-
* @param {string} message
|
39
|
-
*/
|
40
|
-
function notify(message) {
|
41
|
-
if (dontBotherDOM) return;
|
42
|
-
const div = document.createElement("div");
|
43
|
-
div.className = "py-error";
|
44
|
-
div.textContent = message;
|
45
|
-
div.style.cssText = `
|
46
|
-
border: 1px solid red;
|
47
|
-
background: #ffdddd;
|
48
|
-
color: black;
|
49
|
-
font-family: courier, monospace;
|
50
|
-
white-space: pre;
|
51
|
-
overflow-x: auto;
|
52
|
-
padding: 8px;
|
53
|
-
margin-top: 8px;
|
54
|
-
`;
|
55
|
-
document.body.append(div);
|
56
|
-
}
|
57
|
-
|
58
|
-
export { notOnDOM, notify };
|
59
|
-
//# sourceMappingURL=error-DWoeKPDI.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"error-DWoeKPDI.js","sources":["../src/plugins/error.js"],"sourcesContent":["// PyScript Error Plugin\nimport { buffered } from \"polyscript/exports\";\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;\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