1
- import { EditorState } from '@codemirror/basic-setup' ;
2
- import { python } from '@codemirror/lang-python' ;
3
- import { StateCommand } from '@codemirror/state' ;
4
- import { keymap } from '@codemirror/view' ;
5
- import { defaultKeymap } from '@codemirror/commands' ;
6
- import { oneDarkTheme } from '@codemirror/theme-one-dark' ;
7
-
8
1
import {
9
2
addInitializer ,
10
3
addPostInitializer ,
11
4
addToScriptsQueue ,
12
- componentDetailsNavOpen ,
13
5
loadedEnvironments ,
14
6
mode ,
15
7
pyodideLoaded ,
@@ -21,7 +13,6 @@ import { BaseEvalElement } from './base';
21
13
let pyodideReadyPromise ;
22
14
let environments ;
23
15
let currentMode ;
24
- let handlersCollected = false ;
25
16
26
17
pyodideLoaded . subscribe ( value => {
27
18
pyodideReadyPromise = value ;
@@ -30,11 +21,6 @@ loadedEnvironments.subscribe(value => {
30
21
environments = value ;
31
22
} ) ;
32
23
33
- let propertiesNavOpen ;
34
- componentDetailsNavOpen . subscribe ( value => {
35
- propertiesNavOpen = value ;
36
- } ) ;
37
-
38
24
mode . subscribe ( value => {
39
25
currentMode = value ;
40
26
} ) ;
@@ -45,44 +31,6 @@ type PyodideInterface = {
45
31
registerJsModule ( name : string , module : object ) : void ;
46
32
} ;
47
33
48
- // TODO: This should be used as base for generic scripts that need exectutoin
49
- // from PyScript to initializers, etc...
50
- class Script {
51
- source : string ;
52
- state : string ;
53
- output : string ;
54
-
55
- constructor ( source : string , output : string ) {
56
- this . output = output ;
57
- this . source = source ;
58
- this . state = 'waiting' ;
59
- }
60
-
61
- async evaluate ( ) {
62
- console . log ( 'evaluate' ) ;
63
- const pyodide = await pyodideReadyPromise ;
64
- // debugger
65
- try {
66
- // let source = this.editor.state.doc.toString();
67
- let output ;
68
- if ( this . source . includes ( 'asyncio' ) ) {
69
- output = await pyodide . runPythonAsync ( this . source ) ;
70
- } else {
71
- output = pyodide . runPython ( this . source ) ;
72
- }
73
-
74
- if ( this . output ) {
75
- // this.editorOut.innerHTML = s;
76
- }
77
- // if (output !== undefined){
78
- // this.addToOutput(output);
79
- // }
80
- } catch ( err ) {
81
- console . log ( 'OOOPS, this happened: ' , err ) ;
82
- // this.addToOutput(err);
83
- }
84
- }
85
- }
86
34
87
35
export class PyScript extends BaseEvalElement {
88
36
constructor ( ) {
@@ -207,7 +155,6 @@ async function initHandlers() {
207
155
// // pyodide.runPython(handlerCode);
208
156
// }
209
157
}
210
- handlersCollected = true ;
211
158
212
159
matches = document . querySelectorAll ( '[pys-onKeyDown]' ) ;
213
160
for ( const el of matches ) {
@@ -222,7 +169,7 @@ async function mountElements() {
222
169
console . log ( 'Collecting nodes to be mounted into python namespace...' ) ;
223
170
const pyodide = await pyodideReadyPromise ;
224
171
const matches : NodeListOf < HTMLElement > = document . querySelectorAll ( '[py-mount]' ) ;
225
- let output ;
172
+
226
173
let source = '' ;
227
174
for ( const el of matches ) {
228
175
let mountName = el . getAttribute ( 'py-mount' ) ;
0 commit comments