8000 remove old code and bypass some warning by fpliger · Pull Request #59 · pyscript/pyscript · GitHub
[go: up one dir, main page]

Skip to content

remove old code and bypass some warning #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clean pyscript.ts
  • Loading branch information
fpliger committed Apr 28, 2022
commit 99c79acc78fca3d9517feb2d5a5cc9e6b80da0c3
2 changes: 1 addition & 1 deletion pyscriptjs/src/components/pyinputbox.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseEvalElement } from './base';
import { addClasses, ltrim, htmlDecode } from '../utils';
import { addClasses, htmlDecode } from '../utils';

export class PyInputBox extends BaseEvalElement {
shadow: ShadowRoot;
Expand Down
2 changes: 1 addition & 1 deletion
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { keymap } from '@codemirror/view';
import { defaultKeymap } from '@codemirror/commands';
import { oneDarkTheme } from '@codemirror/theme-one-dark';

import { componentDetailsNavOpen, currentComponentDetails, loadedEnvironments, mode, pyodideLoaded } from '../stores';
import { componentDetailsNavOpen, loadedEnvironments, mode, pyodideLoaded } from '../stores';
import { addClasses } from '../utils';
import { BaseEvalElement } from './base';

Expand Down
55 changes: 1 addition & 54 deletions pyscriptjs/src/components/pyscript.ts
8000
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import { EditorState } from '@codemirror/basic-setup';
import { python } from '@codemirror/lang-python';
import { StateCommand } from '@codemirror/state';
import { keymap } from '@codemirror/view';
import { defaultKeymap } from '@codemirror/commands';
import { oneDarkTheme } from '@codemirror/theme-one-dark';

import {
addInitializer,
addPostInitializer,
addToScriptsQueue,
componentDetailsNavOpen,
loadedEnvironments,
mode,
pyodideLoaded,
Expand All @@ -21,7 +13,6 @@ import { BaseEvalElement } from './base';
let pyodideReadyPromise;
let environments;
let currentMode;
let handlersCollected = false;

pyodideLoaded.subscribe(value => {
pyodideReadyPromise = value;
Expand All @@ -30,11 +21,6 @@ loadedEnvironments.subscribe(value => {
environments = value;
});

let propertiesNavOpen;
componentDetailsNavOpen.subscribe(value => {
propertiesNavOpen = value;
});

mode.subscribe(value => {
currentMode = value;
});
Expand All @@ -45,44 +31,6 @@ type PyodideInterface = {
registerJsModule(name: string, module: object): void;
};

// TODO: This should be used as base for generic scripts that need exectutoin
// from PyScript to initializers, etc...
class Script {
source: string;
state: string;
output: string;

constructor(source: string, output: string) {
this.output = output;
this.source = source;
this.state = 'waiting';
}

async evaluate() {
console.log('evaluate');
const pyodide = await pyodideReadyPromise;
// debugger
try {
// let source = this.editor.state.doc.toString();
let output;
if (this.source.includes('asyncio')) {
output = await pyodide.runPythonAsync(this.source);
} else {
output = pyodide.runPython(this.source);
}

if (this.output) {
// this.editorOut.innerHTML = s;
}
// if (output !== undefined){
// this.addToOutput(output);
// }
} catch (err) {
console.log('OOOPS, this happened: ', err);
// this.addToOutput(err);
}
}
}

export class PyScript extends BaseEvalElement {
constructor() {
Expand Down Expand Up @@ -207,7 +155,6 @@ async function initHandlers() {
// // pyodide.runPython(handlerCode);
// }
}
handlersCollected = true;

matches = document.querySelectorAll('[pys-onKeyDown]');
for (const el of matches) {
Expand All @@ -222,7 +169,7 @@ async function mountElements() {
console.log('Collecting nodes to be mounted into python namespace...');
const pyodide = await pyodideReadyPromise;
const matches: NodeListOf<HTMLElement> = document.querySelectorAll('[py-mount]');
let output;

let source = '';
for (const el of matches) {
< 40BF span class='blob-code-inner blob-code-marker ' data-code-marker=" "> let mountName = el.getAttribute('py-mount');
Expand Down
0