@dodona/papyros 0.1.3-action → 0.1.5
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/LICENSE +0 -0
- package/README.md +4 -11
- package/{lib/index.d.ts → dist/App.d.ts} +0 -0
- package/{lib → dist}/Backend.d.ts +2 -1
- package/{lib → dist}/BackendManager.d.ts +0 -0
- package/dist/CodeEditor.d.ts +23 -0
- package/{lib → dist}/Constants.d.ts +4 -1
- package/{lib → dist}/InputManager.d.ts +3 -2
- package/dist/InputServiceWorker.d.ts +1 -0
- package/dist/OutputManager.d.ts +23 -0
- package/{lib → dist}/Papyros.d.ts +18 -4
- package/{lib → dist}/PapyrosEvent.d.ts +1 -0
- package/{lib → dist}/ProgrammingLanguage.d.ts +0 -0
- package/{lib → dist}/StatusPanel.d.ts +2 -4
- package/dist/examples/Examples.d.ts +6 -0
- package/dist/examples/JavaScriptExamples.d.ts +5 -0
- package/dist/examples/PythonExamples.d.ts +11 -0
- package/dist/index.js +2 -0
- package/dist/index.js.LICENSE.txt +7 -0
- package/dist/inputServiceWorker.js +1 -0
- package/dist/library.d.ts +9 -0
- package/dist/util/HTMLShapes.d.ts +2 -0
- package/{lib → dist}/util/Logging.d.ts +0 -0
- package/dist/util/Util.d.ts +15 -0
- package/dist/workers/input/InputWorker.d.ts +8 -0
- package/{lib → dist}/workers/javascript/JavaScriptWorker.worker.d.ts +0 -0
- package/dist/workers/python/Pyodide.d.ts +9 -0
- package/{lib → dist}/workers/python/PythonWorker.worker.d.ts +0 -0
- package/package.json +12 -6
- package/lib/CodeEditor.d.ts +0 -14
- package/lib/index.js +0 -1
- package/lib/library.d.ts +0 -9
- package/lib/util/Util.d.ts +0 -6
- package/lib/workers/python/init.py.d.ts +0 -1
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
@@ -12,29 +12,22 @@
|
|
|
12
12
|
</a>
|
|
13
13
|
</p>
|
|
14
14
|
|
|
15
|
-
Papyros is a programming scratchpad in the browser. It allows running
|
|
16
|
-
|
|
15
|
+
Papyros is a programming scratchpad in the browser. It allows running code
|
|
16
|
+
directly in your browser, no installation required. Right now, the focus in on providing a great experience for Python, while also supporting JavaScript.
|
|
17
17
|
By taking away obstacles between students and coding, the learning experience becomes
|
|
18
|
-
smoother and less error-prone.
|
|
19
|
-
|
|
20
|
-
Papyros aims to be:
|
|
21
|
-
|
|
22
|
-
- **Easy to use** by having minimal installation instructions and an intuitive user interface
|
|
23
|
-
- **Flexible** to support many programming languages
|
|
18
|
+
smoother and less error-prone.
|
|
24
19
|
|
|
25
20
|
Currently, Papyros provides support for the following programming languages:
|
|
26
21
|
- Python, powered by [Pyodide](https://pyodide.org/en/stable/)
|
|
27
22
|
- JavaScript, powered by your browser
|
|
28
23
|
|
|
29
|
-
##
|
|
24
|
+
## Using Papyros in your own project
|
|
30
25
|
|
|
31
26
|
You can install Papyros on your system using npm:
|
|
32
27
|
```shell
|
|
33
28
|
npm install -g @dodona/papyros
|
|
34
29
|
```
|
|
35
30
|
|
|
36
|
-
## Usage
|
|
37
|
-
|
|
38
31
|
Papyros currently supports two modes of operation: stand-alone and embedded.
|
|
39
32
|
|
|
40
33
|
In stand-alone mode, Papyros runs as a full application in the browser.
|
|
File without changes
|
|
@@ -6,11 +6,12 @@ export declare abstract class Backend {
|
|
|
6
6
|
/**
|
|
7
7
|
* Initialize the backend, setting up any globals required
|
|
8
8
|
* @param {function(PapyrosEvent):void} onEvent Callback for when events occur
|
|
9
|
+
* @param {string} hostname Base URL for input
|
|
9
10
|
* @param {Uint8Array} inputTextArray Optional shared buffer for input
|
|
10
11
|
* @param {Int32Array} inputMetaData Optional shared buffer for metadata about input
|
|
11
12
|
* @return {Promise<void>} Promise of launching
|
|
12
13
|
*/
|
|
13
|
-
launch(onEvent: (e: PapyrosEvent) => void, inputTextArray?: Uint8Array, inputMetaData?: Int32Array): Promise<void>;
|
|
14
|
+
launch(onEvent: (e: PapyrosEvent) => void, hostname: string, inputTextArray?: Uint8Array, inputMetaData?: Int32Array): Promise<void>;
|
|
14
15
|
abstract _runCodeInternal(code: string): Promise<any>;
|
|
15
16
|
/**
|
|
16
17
|
* Validate and run arbitrary code
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LanguageSupport } from "@codemirror/language";
|
|
2
|
+
import { Compartment, Extension } from "@codemirror/state";
|
|
3
|
+
import { ProgrammingLanguage } from "./ProgrammingLanguage";
|
|
4
|
+
import { EditorView } from "@codemirror/view";
|
|
5
|
+
import { RenderOptions } from "./util/Util";
|
|
6
|
+
export declare class CodeEditor {
|
|
7
|
+
editorView: EditorView;
|
|
8
|
+
languageCompartment: Compartment;
|
|
9
|
+
indentCompartment: Compartment;
|
|
10
|
+
placeholderCompartment: Compartment;
|
|
11
|
+
panelCompartment: Compartment;
|
|
12
|
+
constructor(language: ProgrammingLanguage, editorPlaceHolder: string, initialCode?: string, indentLength?: number);
|
|
13
|
+
render(options: RenderOptions, panel?: HTMLElement): HTMLElement;
|
|
14
|
+
setLanguage(language: ProgrammingLanguage, editorPlaceHolder: string): void;
|
|
15
|
+
setIndentLength(indentLength: number): void;
|
|
16
|
+
setPanel(panel: HTMLElement): void;
|
|
17
|
+
getCode(): string;
|
|
18
|
+
setCode(code: string): void;
|
|
19
|
+
focus(): void;
|
|
20
|
+
static getIndentUnit(indentLength: number): string;
|
|
21
|
+
static getLanguageSupport(language: ProgrammingLanguage): LanguageSupport;
|
|
22
|
+
static getExtensions(): Array<Extension>;
|
|
23
|
+
}
|
|
@@ -4,6 +4,7 @@ export declare const OUTPUT_TA_ID = "code-output-area";
|
|
|
4
4
|
export declare const INPUT_AREA_WRAPPER_ID = "code-input-area-wrapper";
|
|
5
5
|
export declare const INPUT_TA_ID = "code-input-area";
|
|
6
6
|
export declare const EDITOR_WRAPPER_ID = "code-area";
|
|
7
|
+
export declare const PANEL_WRAPPER_ID = "code-status-panel";
|
|
7
8
|
export declare const STATE_SPINNER_ID = "state-spinner";
|
|
8
9
|
export declare const APPLICATION_STATE_TEXT_ID = "application-state-text";
|
|
9
10
|
export declare const RUN_BTN_ID = "run-code-btn";
|
|
@@ -12,6 +13,8 @@ export declare const SEND_INPUT_BTN_ID = "send-input-btn";
|
|
|
12
13
|
export declare const SWITCH_INPUT_MODE_A_ID = "switch-input-mode";
|
|
13
14
|
export declare const PROGRAMMING_LANGUAGE_SELECT_ID = "programming-language-select";
|
|
14
15
|
export declare const DEFAULT_PROGRAMMING_LANGUAGE = ProgrammingLanguage.Python;
|
|
16
|
+
export declare const EXAMPLE_SELECT_ID = "example-select";
|
|
15
17
|
export declare const LOCALE_SELECT_ID = "locale-select";
|
|
16
18
|
export declare const DEFAULT_LOCALE = "nl";
|
|
17
|
-
export declare const
|
|
19
|
+
export declare const DEFAULT_SERVICE_WORKER = "inputServiceWorker.js";
|
|
20
|
+
export declare const INPUT_RELATIVE_URL = "__papyros_input";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PapyrosEvent } from "./PapyrosEvent";
|
|
2
|
+
import { RenderOptions } from "./util/Util";
|
|
2
3
|
export declare enum InputMode {
|
|
3
4
|
Interactive = "interactive",
|
|
4
5
|
Batch = "batch"
|
|
@@ -8,7 +9,7 @@ interface InputSession {
|
|
|
8
9
|
lineNr: number;
|
|
9
10
|
}
|
|
10
11
|
export declare class InputManager {
|
|
11
|
-
|
|
12
|
+
renderOptions: RenderOptions;
|
|
12
13
|
inputMode: InputMode;
|
|
13
14
|
waiting: boolean;
|
|
14
15
|
batchInput: string;
|
|
@@ -20,7 +21,7 @@ export declare class InputManager {
|
|
|
20
21
|
constructor(onSend: () => void, inputMode: InputMode);
|
|
21
22
|
get enterButton(): HTMLButtonElement;
|
|
22
23
|
get inputArea(): HTMLInputElement;
|
|
23
|
-
|
|
24
|
+
render(options?: RenderOptions): void;
|
|
24
25
|
setInputMode(inputMode: InputMode): void;
|
|
25
26
|
setWaiting(waiting: boolean, prompt?: string): void;
|
|
26
27
|
sendLine(): Promise<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PapyrosEvent } from "./PapyrosEvent";
|
|
2
|
+
import { RenderOptions } from "./util/Util";
|
|
3
|
+
export interface FriendlyError {
|
|
4
|
+
name: string;
|
|
5
|
+
traceback?: string;
|
|
6
|
+
info?: string;
|
|
7
|
+
why?: string;
|
|
8
|
+
what?: string;
|
|
9
|
+
where?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class OutputManager {
|
|
12
|
+
outputAreaId: string;
|
|
13
|
+
options: RenderOptions;
|
|
14
|
+
get outputArea(): HTMLElement;
|
|
15
|
+
renderNextElement(html: string): void;
|
|
16
|
+
spanify(text: string, ignoreEmpty?: boolean): string;
|
|
17
|
+
showOutput(output: PapyrosEvent): void;
|
|
18
|
+
showError(error: FriendlyError | string): void;
|
|
19
|
+
render(options: RenderOptions): HTMLElement;
|
|
20
|
+
reset(): void;
|
|
21
|
+
onRunStart(): void;
|
|
22
|
+
onRunEnd(): void;
|
|
23
|
+
}
|
|
@@ -5,7 +5,9 @@ import { CodeEditor } from "./CodeEditor";
|
|
|
5
5
|
import { InputManager, InputMode } from "./InputManager";
|
|
6
6
|
import { PapyrosEvent } from "./PapyrosEvent";
|
|
7
7
|
import { ProgrammingLanguage } from "./ProgrammingLanguage";
|
|
8
|
+
import { RenderOptions } from "./util/Util";
|
|
8
9
|
import { StatusPanel } from "./StatusPanel";
|
|
10
|
+
import { OutputManager } from "./OutputManager";
|
|
9
11
|
declare enum PapyrosState {
|
|
10
12
|
Loading = "loading",
|
|
11
13
|
Running = "running",
|
|
@@ -16,17 +18,17 @@ declare enum PapyrosState {
|
|
|
16
18
|
declare class PapyrosStateManager {
|
|
17
19
|
state: PapyrosState;
|
|
18
20
|
statusPanel: StatusPanel;
|
|
19
|
-
runButton: HTMLButtonElement;
|
|
20
|
-
stopButton: HTMLButtonElement;
|
|
21
|
+
get runButton(): HTMLButtonElement;
|
|
22
|
+
get stopButton(): HTMLButtonElement;
|
|
21
23
|
constructor(statusPanel: StatusPanel);
|
|
22
24
|
setState(state: PapyrosState, message?: string): void;
|
|
25
|
+
render(options: RenderOptions): HTMLElement;
|
|
23
26
|
}
|
|
24
27
|
interface PapyrosCodeState {
|
|
25
28
|
programmingLanguage: ProgrammingLanguage;
|
|
26
29
|
editor: CodeEditor;
|
|
27
30
|
backend: Remote<Backend>;
|
|
28
31
|
runId: number;
|
|
29
|
-
outputArea: HTMLInputElement;
|
|
30
32
|
}
|
|
31
33
|
interface PapyrosConfig {
|
|
32
34
|
standAlone: boolean;
|
|
@@ -34,20 +36,32 @@ interface PapyrosConfig {
|
|
|
34
36
|
locale: string;
|
|
35
37
|
inputMode: InputMode;
|
|
36
38
|
}
|
|
39
|
+
interface PapyrosRenderOptions {
|
|
40
|
+
papyros: RenderOptions;
|
|
41
|
+
code?: RenderOptions;
|
|
42
|
+
panel?: RenderOptions;
|
|
43
|
+
input?: RenderOptions;
|
|
44
|
+
output?: RenderOptions;
|
|
45
|
+
}
|
|
37
46
|
export declare class Papyros {
|
|
38
47
|
stateManager: PapyrosStateManager;
|
|
39
48
|
codeState: PapyrosCodeState;
|
|
40
49
|
inputManager: InputManager;
|
|
50
|
+
outputManager: OutputManager;
|
|
41
51
|
constructor(programmingLanguage: ProgrammingLanguage, inputMode: InputMode);
|
|
42
52
|
get state(): PapyrosState;
|
|
43
53
|
launch(): Promise<Papyros>;
|
|
44
54
|
setProgrammingLanguage(programmingLanguage: ProgrammingLanguage): Promise<void>;
|
|
55
|
+
setCode(code: string): void;
|
|
56
|
+
getCode(): string;
|
|
45
57
|
startBackend(): Promise<void>;
|
|
46
|
-
static fromElement(
|
|
58
|
+
static fromElement(config: PapyrosConfig, renderOptions: PapyrosRenderOptions): Papyros;
|
|
59
|
+
static configureInput(allowReload: boolean, serviceWorkerPath: string): Promise<boolean>;
|
|
47
60
|
onError(e: PapyrosEvent): void;
|
|
48
61
|
onInput(e: PapyrosEvent): Promise<void>;
|
|
49
62
|
onMessage(e: PapyrosEvent): void;
|
|
50
63
|
runCode(): Promise<void>;
|
|
51
64
|
stop(): Promise<void>;
|
|
65
|
+
render(standAlone: boolean, programmingLanguage: ProgrammingLanguage, locale: string, renderOptions: PapyrosRenderOptions): void;
|
|
52
66
|
}
|
|
53
67
|
export {};
|
|
File without changes
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
import { RenderOptions } from "./util/Util";
|
|
1
2
|
export declare class StatusPanel {
|
|
2
|
-
onRun: () => void;
|
|
3
|
-
constructor(onRun: () => void);
|
|
4
|
-
initialize(): void;
|
|
5
3
|
get statusSpinner(): HTMLElement;
|
|
6
4
|
get statusText(): HTMLElement;
|
|
7
5
|
showSpinner(show: boolean): void;
|
|
8
6
|
setStatus(status: string): void;
|
|
9
|
-
render(
|
|
7
|
+
render(options: RenderOptions): HTMLElement;
|
|
10
8
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ProgrammingLanguage } from "../ProgrammingLanguage";
|
|
2
|
+
export declare function getExamples(language: ProgrammingLanguage): {
|
|
3
|
+
[key: string]: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function getExampleNames(language: ProgrammingLanguage): Array<string>;
|
|
6
|
+
export declare function getCodeForExample(language: ProgrammingLanguage, name: string): string;
|