@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
package/dist/mpy-CQiuZcjW.js
DELETED
@@ -1,255 +0,0 @@
|
|
1
|
-
import { e as exportedHooks, i as inputFailure, d as defineProperties } from './core-D2ytnMSk.js';
|
2
|
-
|
3
|
-
// PyScript pyodide terminal plugin
|
4
|
-
|
5
|
-
const bootstrapped = new WeakSet();
|
6
|
-
|
7
|
-
// this callback will be serialized as string and it never needs
|
8
|
-
// to be invoked multiple times. Each xworker here is bootstrapped
|
9
|
-
// only once thanks to the `sync.is_pyterminal()` check.
|
10
|
-
const workerReady = ({ interpreter, io, run, type }, { sync }) => {
|
11
|
-
if (type !== "mpy" || !sync.is_pyterminal()) return;
|
12
|
-
|
13
|
-
const { pyterminal_ready, pyterminal_read, pyterminal_write } = sync;
|
14
|
-
|
15
|
-
interpreter.registerJsModule("_pyscript_input", {
|
16
|
-
input: pyterminal_read,
|
17
|
-
});
|
18
|
-
|
19
|
-
run(
|
20
|
-
[
|
21
|
-
"from _pyscript_input import input",
|
22
|
-
"from polyscript import currentScript as _",
|
23
|
-
"__terminal__ = _.terminal",
|
24
|
-
"del _",
|
25
|
-
].join(";"),
|
26
|
-
);
|
27
|
-
|
28
|
-
const missingReturn = new Uint8Array([13]);
|
29
|
-
io.stdout = (buffer) => {
|
30
|
-
if (buffer[0] === 10) pyterminal_write(missingReturn);
|
31
|
-
pyterminal_write(buffer);
|
32
|
-
};
|
33
|
-
io.stderr = (error) => {
|
34
|
-
pyterminal_write(String(error.message || error));
|
35
|
-
};
|
36
|
-
|
37
|
-
// tiny shim of the code module with only interact
|
38
|
-
// to bootstrap a REPL like environment
|
39
|
-
interpreter.registerJsModule("code", {
|
40
|
-
interact() {
|
41
|
-
const encoder = new TextEncoderStream();
|
42
|
-
encoder.readable.pipeTo(
|
43
|
-
new WritableStream({
|
44
|
-
write(buffer) {
|
45
|
-
for (const c of buffer) interpreter.replProcessChar(c);
|
46
|
-
},
|
47
|
-
}),
|
48
|
-
);
|
49
|
-
|
50
|
-
const writer = encoder.writable.getWriter();
|
51
|
-
sync.pyterminal_stream_write = (buffer) => writer.write(buffer);
|
52
|
-
|
53
|
-
interpreter.replInit();
|
54
|
-
},
|
55
|
-
});
|
56
|
-
|
57
|
-
pyterminal_ready();
|
58
|
-
};
|
59
|
-
|
60
|
-
var mpy = async (element) => {
|
61
|
-
// lazy load these only when a valid terminal is found
|
62
|
-
const [{ Terminal }, { FitAddon }, { WebLinksAddon }] = await Promise.all([
|
63
|
-
import(/* webpackIgnore: true */ './xterm-eU6F6YKE.js'),
|
64
|
-
import(/* webpackIgnore: true */ './xterm_addon-fit-Cotzxdkz.js'),
|
65
|
-
import(
|
66
|
-
/* webpackIgnore: true */ './xterm_addon-web-links-DoNfCjeX.js'
|
67
|
-
),
|
68
|
-
]);
|
69
|
-
|
70
|
-
const terminalOptions = {
|
71
|
-
disableStdin: false,
|
72
|
-
cursorBlink: true,
|
73
|
-
cursorStyle: "block",
|
74
|
-
};
|
75
|
-
|
76
|
-
let stream;
|
77
|
-
|
78
|
-
// common main thread initialization for both worker
|
79
|
-
// or main case, bootstrapping the terminal on its target
|
80
|
-
const init = () => {
|
81
|
-
let target = element;
|
82
|
-
const selector = element.getAttribute("target");
|
83
|
-
if (selector) {
|
84
|
-
target =
|
85
|
-
document.getElementById(selector) ||
|
86
|
-
document.querySelector(selector);
|
87
|
-
if (!target) throw new Error(`Unknown target ${selector}`);
|
88
|
-
} else {
|
89
|
-
target = document.createElement("py-terminal");
|
90
|
-
target.style.display = "block";
|
91
|
-
element.after(target);
|
92
|
-
}
|
93
|
-
const terminal = new Terminal({
|
94
|
-
theme: {
|
95
|
-
background: "#191A19",
|
96
|
-
foreground: "#F5F2E7",
|
97
|
-
},
|
98
|
-
...terminalOptions,
|
99
|
-
});
|
100
|
-
const fitAddon = new FitAddon();
|
101
|
-
terminal.loadAddon(fitAddon);
|
102
|
-
terminal.loadAddon(new WebLinksAddon());
|
103
|
-
terminal.open(target);
|
104
|
-
fitAddon.fit();
|
105
|
-
terminal.focus();
|
106
|
-
defineProperties(element, {
|
107
|
-
terminal: { value: terminal },
|
108
|
-
process: {
|
109
|
-
value: async (code) => {
|
110
|
-
for (const line of code.split(/(?:\r\n|\r|\n)/)) {
|
111
|
-
await stream.write(`${line}\r`);
|
112
|
-
}
|
113
|
-
},
|
114
|
-
},
|
115
|
-
});
|
116
|
-
return terminal;
|
117
|
-
};
|
118
|
-
|
119
|
-
// branch logic for the worker
|
120
|
-
if (element.hasAttribute("worker")) {
|
121
|
-
// add a hook on the main thread to setup all sync helpers
|
122
|
-
// also bootstrapping the XTerm target on main *BUT* ...
|
123
|
-
exportedHooks.main.onWorker.add(function worker(_, xworker) {
|
124
|
-
// ... as multiple workers will add multiple callbacks
|
125
|
-
// be sure no xworker is ever initialized twice!
|
126
|
-
if (bootstrapped.has(xworker)) return;
|
127
|
-
bootstrapped.add(xworker);
|
128
|
-
|
129
|
-
// still cleanup this callback for future scripts/workers
|
130
|
-
exportedHooks.main.onWorker.delete(worker);
|
131
|
-
|
132
|
-
const terminal = init();
|
133
|
-
|
134
|
-
const { sync } = xworker;
|
135
|
-
|
136
|
-
// handle the read mode on input
|
137
|
-
let promisedChunks = null;
|
138
|
-
let readChunks = "";
|
139
|
-
|
140
|
-
sync.is_pyterminal = () => true;
|
141
|
-
|
142
|
-
// put the terminal in a read-only state
|
143
|
-
// frees the worker on \r
|
144
|
-
sync.pyterminal_read = (buffer) => {
|
145
|
-
terminal.write(buffer);
|
146
|
-
promisedChunks = Promise.withResolvers();
|
147
|
-
return promisedChunks.promise;
|
148
|
-
};
|
149
|
-
|
150
|
-
// write if not reading input
|
151
|
-
sync.pyterminal_write = (buffer) => {
|
152
|
-
if (!promisedChunks) terminal.write(buffer);
|
153
|
-
};
|
154
|
-
|
155
|
-
// add the onData terminal listener which forwards to the worker
|
156
|
-
// everything typed in a queued char-by-char way
|
157
|
-
sync.pyterminal_ready = () => {
|
158
|
-
let queue = Promise.resolve();
|
159
|
-
stream = {
|
160
|
-
write: (buffer) =>
|
161
|
-
(queue = queue.then(() =>
|
162
|
-
sync.pyterminal_stream_write(buffer),
|
163
|
-
)),
|
164
|
-
};
|
165
|
-
terminal.onData((buffer) => {
|
166
|
-
if (promisedChunks) {
|
167
|
-
// handle backspace on input
|
168
|
-
if (buffer === "\x7f") {
|
169
|
-
// avoid over-greedy backspace
|
170
|
-
if (readChunks.length) {
|
171
|
-
readChunks = readChunks.slice(0, -1);
|
172
|
-
// override previous char position
|
173
|
-
// put an empty space to clear the char
|
174
|
-
// move back position again
|
175
|
-
buffer = "\b \b";
|
176
|
-
} else buffer = "";
|
177
|
-
} else readChunks += buffer;
|
178
|
-
if (buffer) {
|
179
|
-
terminal.write(buffer);
|
180
|
-
if (readChunks.endsWith("\r")) {
|
181
|
-
terminal.write("\n");
|
182
|
-
promisedChunks.resolve(readChunks.slice(0, -1));
|
183
|
-
promisedChunks = null;
|
184
|
-
readChunks = "";
|
185
|
-
}
|
186
|
-
}
|
187
|
-
} else {
|
188
|
-
stream.write(buffer);
|
189
|
-
}
|
190
|
-
});
|
191
|
-
};
|
192
|
-
});
|
193
|
-
|
194
|
-
// setup remote thread JS/Python code for whenever the
|
195
|
-
// worker is ready to become a terminal
|
196
|
-
exportedHooks.worker.onReady.add(workerReady);
|
197
|
-
} else {
|
198
|
-
// ⚠️ In an ideal world the inputFailure should never be used on main.
|
199
|
-
// However, Pyodide still can't compete with MicroPython REPL mode
|
200
|
-
// so while it's OK to keep that entry on main as default, we need
|
201
|
-
// to remove it ASAP from `mpy` use cases, otherwise MicroPython would
|
202
|
-
// also throw whenever an `input(...)` is required / digited.
|
203
|
-
exportedHooks.main.codeBeforeRun.delete(inputFailure);
|
204
|
-
|
205
|
-
// in the main case, just bootstrap XTerm without
|
206
|
-
// allowing any input as that's not possible / awkward
|
207
|
-
exportedHooks.main.onReady.add(function main({ interpreter, io, run, type }) {
|
208
|
-
if (type !== "mpy") return;
|
209
|
-
|
210
|
-
exportedHooks.main.onReady.delete(main);
|
211
|
-
|
212
|
-
const terminal = init();
|
213
|
-
|
214
|
-
const missingReturn = new Uint8Array([13]);
|
215
|
-
io.stdout = (buffer) => {
|
216
|
-
if (buffer[0] === 10) terminal.write(missingReturn);
|
217
|
-
terminal.write(buffer);
|
218
|
-
};
|
219
|
-
|
220
|
-
// expose the __terminal__ one-off reference
|
221
|
-
globalThis.__py_terminal__ = terminal;
|
222
|
-
run(
|
223
|
-
[
|
224
|
-
"from js import prompt as input",
|
225
|
-
"from js import __py_terminal__ as __terminal__",
|
226
|
-
].join(";"),
|
227
|
-
);
|
228
|
-
delete globalThis.__py_terminal__;
|
229
|
-
|
230
|
-
// NOTE: this is NOT the same as the one within
|
231
|
-
// the onWorkerReady callback!
|
232
|
-
interpreter.registerJsModule("code", {
|
233
|
-
interact() {
|
234
|
-
const encoder = new TextEncoderStream();
|
235
|
-
encoder.readable.pipeTo(
|
236
|
-
new WritableStream({
|
237
|
-
write(buffer) {
|
238
|
-
for (const c of buffer)
|
239
|
-
interpreter.replProcessChar(c);
|
240
|
-
},
|
241
|
-
}),
|
242
|
-
);
|
243
|
-
|
244
|
-
stream = encoder.writable.getWriter();
|
245
|
-
terminal.onData((buffer) => stream.write(buffer));
|
246
|
-
|
247
|
-
interpreter.replInit();
|
248
|
-
},
|
249
|
-
});
|
250
|
-
});
|
251
|
-
}
|
252
|
-
};
|
253
|
-
|
254
|
-
export { mpy as default };
|
255
|
-
//# sourceMappingURL=mpy-CQiuZcjW.js.map
|
package/dist/py-BgH4mprx.js
DELETED
@@ -1,182 +0,0 @@
|
|
1
|
-
import { e as exportedHooks, d as defineProperties } from './core-D2ytnMSk.js';
|
2
|
-
|
3
|
-
// PyScript py-terminal plugin
|
4
|
-
|
5
|
-
const bootstrapped = new WeakSet();
|
6
|
-
|
7
|
-
// this callback will be serialized as string and it never needs
|
8
|
-
// to be invoked multiple times. Each xworker here is bootstrapped
|
9
|
-
// only once thanks to the `sync.is_pyterminal()` check.
|
10
|
-
const workerReady = ({ interpreter, io, run, type }, { sync }) => {
|
11
|
-
if (type !== "py" || !sync.is_pyterminal()) return;
|
12
|
-
|
13
|
-
run(
|
14
|
-
[
|
15
|
-
"from polyscript import currentScript as _",
|
16
|
-
"__terminal__ = _.terminal",
|
17
|
-
"del _",
|
18
|
-
].join(";"),
|
19
|
-
);
|
20
|
-
|
21
|
-
let data = "";
|
22
|
-
const { pyterminal_read, pyterminal_write } = sync;
|
23
|
-
const decoder = new TextDecoder();
|
24
|
-
const generic = {
|
25
|
-
isatty: false,
|
26
|
-
write(buffer) {
|
27
|
-
data = decoder.decode(buffer);
|
28
|
-
pyterminal_write(data);
|
29
|
-
return buffer.length;
|
30
|
-
},
|
31
|
-
};
|
32
|
-
|
33
|
-
io.stderr = (error) => {
|
34
|
-
pyterminal_write(String(error.message || error));
|
35
|
-
};
|
36
|
-
|
37
|
-
interpreter.setStdout(generic);
|
38
|
-
interpreter.setStderr(generic);
|
39
|
-
interpreter.setStdin({
|
40
|
-
isatty: false,
|
41
|
-
stdin: () => pyterminal_read(data),
|
42
|
-
});
|
43
|
-
};
|
44
|
-
|
45
|
-
var py = async (element) => {
|
46
|
-
// lazy load these only when a valid terminal is found
|
47
|
-
const [{ Terminal }, { Readline }, { FitAddon }, { WebLinksAddon }] =
|
48
|
-
await Promise.all([
|
49
|
-
import(/* webpackIgnore: true */ './xterm-eU6F6YKE.js'),
|
50
|
-
import(
|
51
|
-
/* webpackIgnore: true */ './xterm-readline-C7HDczqS.js'
|
52
|
-
),
|
53
|
-
import(
|
54
|
-
/* webpackIgnore: true */ './xterm_addon-fit-Cotzxdkz.js'
|
55
|
-
),
|
56
|
-
import(
|
57
|
-
/* webpackIgnore: true */ './xterm_addon-web-links-DoNfCjeX.js'
|
58
|
-
),
|
59
|
-
]);
|
60
|
-
|
61
|
-
const readline = new Readline();
|
62
|
-
|
63
|
-
// common main thread initialization for both worker
|
64
|
-
// or main case, bootstrapping the terminal on its target
|
65
|
-
const init = (options) => {
|
66
|
-
let target = element;
|
67
|
-
const selector = element.getAttribute("target");
|
68
|
-
if (selector) {
|
69
|
-
target =
|
70
|
-
document.getElementById(selector) ||
|
71
|
-
document.querySelector(selector);
|
72
|
-
if (!target) throw new Error(`Unknown target ${selector}`);
|
73
|
-
} else {
|
74
|
-
target = document.createElement("py-terminal");
|
75
|
-
target.style.display = "block";
|
76
|
-
element.after(target);
|
77
|
-
}
|
78
|
-
const terminal = new Terminal({
|
79
|
-
theme: {
|
80
|
-
background: "#191A19",
|
81
|
-
foreground: "#F5F2E7",
|
82
|
-
},
|
83
|
-
...options,
|
84
|
-
});
|
85
|
-
const fitAddon = new FitAddon();
|
86
|
-
terminal.loadAddon(fitAddon);
|
87
|
-
terminal.loadAddon(readline);
|
88
|
-
terminal.loadAddon(new WebLinksAddon());
|
89
|
-
terminal.open(target);
|
90
|
-
fitAddon.fit();
|
91
|
-
terminal.focus();
|
92
|
-
defineProperties(element, {
|
93
|
-
terminal: { value: terminal },
|
94
|
-
process: {
|
95
|
-
value: async (code) => {
|
96
|
-
for (const line of code.split(/(?:\r\n|\r|\n)/)) {
|
97
|
-
terminal.paste(`${line}`);
|
98
|
-
terminal.write("\r\n");
|
99
|
-
do {
|
100
|
-
await new Promise((resolve) =>
|
101
|
-
setTimeout(resolve, 0),
|
102
|
-
);
|
103
|
-
} while (!readline.activeRead?.resolve);
|
104
|
-
readline.activeRead.resolve(line);
|
105
|
-
}
|
106
|
-
},
|
107
|
-
},
|
108
|
-
});
|
109
|
-
return terminal;
|
110
|
-
};
|
111
|
-
|
112
|
-
// branch logic for the worker
|
113
|
-
if (element.hasAttribute("worker")) {
|
114
|
-
// add a hook on the main thread to setup all sync helpers
|
115
|
-
// also bootstrapping the XTerm target on main *BUT* ...
|
116
|
-
exportedHooks.main.onWorker.add(function worker(_, xworker) {
|
117
|
-
// ... as multiple workers will add multiple callbacks
|
118
|
-
// be sure no xworker is ever initialized twice!
|
119
|
-
if (bootstrapped.has(xworker)) return;
|
120
|
-
bootstrapped.add(xworker);
|
121
|
-
|
122
|
-
// still cleanup this callback for future scripts/workers
|
123
|
-
exportedHooks.main.onWorker.delete(worker);
|
124
|
-
|
125
|
-
init({
|
126
|
-
disableStdin: false,
|
127
|
-
cursorBlink: true,
|
128
|
-
cursorStyle: "block",
|
129
|
-
});
|
130
|
-
|
131
|
-
xworker.sync.is_pyterminal = () => true;
|
132
|
-
xworker.sync.pyterminal_read = readline.read.bind(readline);
|
133
|
-
xworker.sync.pyterminal_write = readline.write.bind(readline);
|
134
|
-
});
|
135
|
-
|
136
|
-
// setup remote thread JS/Python code for whenever the
|
137
|
-
// worker is ready to become a terminal
|
138
|
-
exportedHooks.worker.onReady.add(workerReady);
|
139
|
-
} else {
|
140
|
-
// in the main case, just bootstrap XTerm without
|
141
|
-
// allowing any input as that's not possible / awkward
|
142
|
-
exportedHooks.main.onReady.add(function main({ interpreter, io, run, type }) {
|
143
|
-
if (type !== "py") return;
|
144
|
-
|
145
|
-
console.warn("py-terminal is read only on main thread");
|
146
|
-
exportedHooks.main.onReady.delete(main);
|
147
|
-
|
148
|
-
// on main, it's easy to trash and clean the current terminal
|
149
|
-
globalThis.__py_terminal__ = init({
|
150
|
-
disableStdin: true,
|
151
|
-
cursorBlink: false,
|
152
|
-
cursorStyle: "underline",
|
153
|
-
});
|
154
|
-
run("from js import __py_terminal__ as __terminal__");
|
155
|
-
delete globalThis.__py_terminal__;
|
156
|
-
|
157
|
-
io.stderr = (error) => {
|
158
|
-
readline.write(String(error.message || error));
|
159
|
-
};
|
160
|
-
|
161
|
-
let data = "";
|
162
|
-
const decoder = new TextDecoder();
|
163
|
-
const generic = {
|
164
|
-
isatty: false,
|
165
|
-
write(buffer) {
|
166
|
-
data = decoder.decode(buffer);
|
167
|
-
readline.write(data);
|
168
|
-
return buffer.length;
|
169
|
-
},
|
170
|
-
};
|
171
|
-
interpreter.setStdout(generic);
|
172
|
-
interpreter.setStderr(generic);
|
173
|
-
interpreter.setStdin({
|
174
|
-
isatty: false,
|
175
|
-
stdin: () => readline.read(data),
|
176
|
-
});
|
177
|
-
});
|
178
|
-
}
|
179
|
-
};
|
180
|
-
|
181
|
-
export { py as default };
|
182
|
-
//# sourceMappingURL=py-BgH4mprx.js.map
|