@dodona/papyros 0.1.61 → 0.1.91-tar
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/Backend.d.ts +72 -13
- package/dist/BackendEvent.d.ts +33 -0
- package/dist/BackendManager.d.ts +47 -3
- package/dist/CodeEditor.d.ts +96 -2
- package/dist/CodeRunner.d.ts +102 -0
- package/dist/Constants.d.ts +16 -15
- package/dist/InputManager.d.ts +21 -21
- package/dist/Library.d.ts +10 -0
- package/dist/OutputManager.d.ts +60 -8
- package/dist/Papyros.d.ts +121 -48
- package/dist/ProgrammingLanguage.d.ts +3 -0
- package/dist/RunListener.d.ts +13 -0
- package/dist/examples/PythonExamples.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/input/BatchInputHandler.d.ts +31 -0
- package/dist/input/InteractiveInputHandler.d.ts +20 -0
- package/dist/input/UserInputHandler.d.ts +61 -0
- package/dist/inputServiceWorker.js +1 -1
- package/dist/util/HTMLShapes.d.ts +13 -0
- package/dist/util/Logging.d.ts +9 -0
- package/dist/util/Util.d.ts +94 -2
- package/dist/workers/input/InputWorker.d.ts +18 -2
- package/dist/workers/python/Pyodide.d.ts +23 -0
- package/dist/workers/python/PythonWorker.worker.d.ts +2 -0
- package/dist/workers/python/package.tar +0 -0
- package/package.json +7 -3
- package/dist/PapyrosEvent.d.ts +0 -6
- package/dist/StatusPanel.d.ts +0 -8
- package/dist/library.d.ts +0 -9
package/dist/Backend.d.ts
CHANGED
|
@@ -1,22 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CompletionContext, CompletionResult } from "@codemirror/autocomplete";
|
|
2
|
+
import { BackendEvent } from "./BackendEvent";
|
|
3
|
+
import { SyncExtras } from "comsync";
|
|
4
|
+
/**
|
|
5
|
+
* Interface to represent the CodeMirror CompletionContext in a worker
|
|
6
|
+
*/
|
|
7
|
+
export interface WorkerAutocompleteContext {
|
|
8
|
+
/**
|
|
9
|
+
* Whether the autocompletion was explicitly requested (using keybindings)
|
|
10
|
+
*/
|
|
11
|
+
explicit: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The absolute position in the CodeMirror document
|
|
14
|
+
*/
|
|
15
|
+
pos: number;
|
|
16
|
+
/**
|
|
17
|
+
* The line number of the cursor while completing (1-based)
|
|
18
|
+
*/
|
|
19
|
+
line: number;
|
|
20
|
+
/**
|
|
21
|
+
* The column number of the cursor while completing (1-based)
|
|
22
|
+
*/
|
|
23
|
+
column: number;
|
|
24
|
+
/**
|
|
25
|
+
* The full text to autocomplete for
|
|
26
|
+
*/
|
|
27
|
+
text: string;
|
|
28
|
+
/**
|
|
29
|
+
* The match before the cursor (determined by a regex)
|
|
30
|
+
*/
|
|
31
|
+
before: {
|
|
32
|
+
from: number;
|
|
33
|
+
to: number;
|
|
34
|
+
text: string;
|
|
35
|
+
} | null;
|
|
36
|
+
}
|
|
3
37
|
export declare abstract class Backend {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
38
|
+
protected syncExtras: SyncExtras;
|
|
39
|
+
protected onEvent: (e: BackendEvent) => any;
|
|
40
|
+
/**
|
|
41
|
+
* Constructor is limited as it is meant to be used as a WebWorker
|
|
42
|
+
* These are then exposed via Comlink. Proper initialization occurs
|
|
43
|
+
* in the launch method when the worker is started
|
|
44
|
+
* @param {Array<string>} syncMethods The methods to expose
|
|
45
|
+
*/
|
|
46
|
+
constructor(syncMethods?: string[]);
|
|
7
47
|
/**
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
48
|
+
* @return {any} The function to expose methods for Comsync to allow interrupting
|
|
49
|
+
*/
|
|
50
|
+
protected syncExpose(): any;
|
|
51
|
+
/**
|
|
52
|
+
* Expose all the methods that should support being interrupted
|
|
53
|
+
* @param {Array<string>} syncMethods The names of the methods to expose
|
|
54
|
+
*/
|
|
55
|
+
protected exposeMethods(syncMethods: Array<string>): void;
|
|
56
|
+
/**
|
|
57
|
+
* Initialize the backend by doing all setup-related work
|
|
58
|
+
* @param {function(BackendEvent):void} onEvent Callback for when events occur
|
|
11
59
|
* @return {Promise<void>} Promise of launching
|
|
12
60
|
*/
|
|
13
|
-
launch(onEvent: (e:
|
|
14
|
-
abstract _runCodeInternal(code: string): Promise<any>;
|
|
61
|
+
launch(onEvent: (e: BackendEvent) => void): Promise<void>;
|
|
15
62
|
/**
|
|
16
|
-
*
|
|
63
|
+
* Executes the given code
|
|
17
64
|
* @param {string} code The code to run
|
|
18
|
-
* @param {string} runId The uuid for this execution
|
|
19
65
|
* @return {Promise<void>} Promise of execution
|
|
20
66
|
*/
|
|
21
|
-
runCode(
|
|
67
|
+
abstract runCode(extras: SyncExtras, code: string): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Converts the context to a cloneable object containing useful properties
|
|
70
|
+
* to generate autocompletion suggestions with
|
|
71
|
+
* @param {CompletionContext} context Current context to autocomplete for
|
|
72
|
+
* @param {RegExp} expr Expression to match the previous token with
|
|
73
|
+
* @return {WorkerAutocompleteContext} Completion context that can be passed as a message
|
|
74
|
+
*/
|
|
75
|
+
static convertCompletionContext(context: CompletionContext, expr?: RegExp): WorkerAutocompleteContext;
|
|
76
|
+
/**
|
|
77
|
+
* Generate autocompletion suggestions for the given context
|
|
78
|
+
* @param {WorkerAutocompleteContext} context Context to autcomplete in
|
|
79
|
+
*/
|
|
80
|
+
abstract autocomplete(context: WorkerAutocompleteContext): Promise<CompletionResult | null>;
|
|
22
81
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum representing all possible types for supported events
|
|
3
|
+
*/
|
|
4
|
+
export declare enum BackendEventType {
|
|
5
|
+
Start = "start",
|
|
6
|
+
End = "end",
|
|
7
|
+
Input = "input",
|
|
8
|
+
Output = "output",
|
|
9
|
+
Sleep = "sleep",
|
|
10
|
+
Error = "error",
|
|
11
|
+
Interrupt = "interrupt"
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* All possible types for ease of iteration
|
|
15
|
+
*/
|
|
16
|
+
export declare const BACKEND_EVENT_TYPES: BackendEventType[];
|
|
17
|
+
/**
|
|
18
|
+
* Interface for events used for communication between threads
|
|
19
|
+
*/
|
|
20
|
+
export interface BackendEvent {
|
|
21
|
+
/**
|
|
22
|
+
* The type of action generating this event
|
|
23
|
+
*/
|
|
24
|
+
type: BackendEventType;
|
|
25
|
+
/**
|
|
26
|
+
* The actual data stored in this event
|
|
27
|
+
*/
|
|
28
|
+
data: string;
|
|
29
|
+
/**
|
|
30
|
+
* The format used for the data to help with parsing
|
|
31
|
+
*/
|
|
32
|
+
contentType: string;
|
|
33
|
+
}
|
package/dist/BackendManager.d.ts
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
|
-
import { Remote } from "comlink";
|
|
2
1
|
import { Backend } from "./Backend";
|
|
3
2
|
import { ProgrammingLanguage } from "./ProgrammingLanguage";
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { BackendEvent, BackendEventType } from "./BackendEvent";
|
|
4
|
+
import { Channel } from "sync-message";
|
|
5
|
+
import { SyncClient } from "comsync";
|
|
6
|
+
/**
|
|
7
|
+
* Callback type definition for subscribers
|
|
8
|
+
* @param {BackendEvent} e The published event
|
|
9
|
+
*/
|
|
10
|
+
declare type BackendEventListener = (e: BackendEvent) => void;
|
|
11
|
+
declare class Cacheable<T> {
|
|
12
|
+
private cached;
|
|
13
|
+
private createFn;
|
|
14
|
+
constructor(createFn: () => T);
|
|
15
|
+
get(): T;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Abstract class to implement the singleton pattern
|
|
19
|
+
* Static methods group functionality
|
|
20
|
+
*/
|
|
21
|
+
export declare abstract class BackendManager {
|
|
22
|
+
static createWorkerMap: Map<ProgrammingLanguage, Cacheable<SyncClient<Backend>>>;
|
|
23
|
+
static channel: Channel;
|
|
24
|
+
/**
|
|
25
|
+
* Map an event type to interested subscribers
|
|
26
|
+
* Uses an Array to maintain order of subscription
|
|
27
|
+
*/
|
|
28
|
+
static subscriberMap: Map<BackendEventType, Array<BackendEventListener>>;
|
|
29
|
+
private static buildSyncClientMap;
|
|
30
|
+
/**
|
|
31
|
+
* Start a backend for the given language, while storing the worker
|
|
32
|
+
* @param {ProgrammingLanguage} language The programming language supported by the backend
|
|
33
|
+
* @return {Remote<Backend>} A Comlink proxy for the Backend
|
|
34
|
+
*/
|
|
35
|
+
static startBackend(language: ProgrammingLanguage): SyncClient<Backend>;
|
|
36
|
+
/**
|
|
37
|
+
* Register a callback for when an event of a certain type is published
|
|
38
|
+
* @param {BackendEventType} type The type of event to subscribe to
|
|
39
|
+
* @param {BackendEventListener} subscriber Callback for when an event
|
|
40
|
+
* of the given type is published
|
|
41
|
+
*/
|
|
42
|
+
static subscribe(type: BackendEventType, subscriber: BackendEventListener): void;
|
|
43
|
+
/**
|
|
44
|
+
* Publish an event, notifying all listeners for its type
|
|
45
|
+
* @param {BackendEventType} e The event to publish
|
|
46
|
+
*/
|
|
47
|
+
static publish(e: BackendEvent): void;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
package/dist/CodeEditor.d.ts
CHANGED
|
@@ -2,22 +2,116 @@ import { LanguageSupport } from "@codemirror/language";
|
|
|
2
2
|
import { Compartment, Extension } from "@codemirror/state";
|
|
3
3
|
import { ProgrammingLanguage } from "./ProgrammingLanguage";
|
|
4
4
|
import { EditorView } from "@codemirror/view";
|
|
5
|
+
import { CompletionSource } from "@codemirror/autocomplete";
|
|
5
6
|
import { RenderOptions } from "./util/Util";
|
|
7
|
+
/**
|
|
8
|
+
* Component that provides useful features to users writing code
|
|
9
|
+
*/
|
|
6
10
|
export declare class CodeEditor {
|
|
11
|
+
/**
|
|
12
|
+
* Reference to the user interface of the editor
|
|
13
|
+
*/
|
|
7
14
|
editorView: EditorView;
|
|
15
|
+
/**
|
|
16
|
+
* Compartment to change language at runtime
|
|
17
|
+
*/
|
|
8
18
|
languageCompartment: Compartment;
|
|
19
|
+
/**
|
|
20
|
+
* Compartment to configure indentation level at runtime
|
|
21
|
+
*/
|
|
9
22
|
indentCompartment: Compartment;
|
|
23
|
+
/**
|
|
24
|
+
* Compartment to configure the placeholder at runtime
|
|
25
|
+
*/
|
|
10
26
|
placeholderCompartment: Compartment;
|
|
27
|
+
/**
|
|
28
|
+
* Compartment to configure the panel at runtime
|
|
29
|
+
*/
|
|
11
30
|
panelCompartment: Compartment;
|
|
12
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Compartment to configure the autocompletion at runtime
|
|
33
|
+
*/
|
|
34
|
+
autocompletionCompartment: Compartment;
|
|
35
|
+
/**
|
|
36
|
+
* Construct a new CodeEditor
|
|
37
|
+
* @param {ProgrammingLanguage} language The used programming language
|
|
38
|
+
* @param {string} editorPlaceHolder The placeholder for the editor
|
|
39
|
+
* @param {string} initialCode The initial code to display
|
|
40
|
+
* @param {number} indentLength The length in spaces for the indent unit
|
|
41
|
+
*/
|
|
42
|
+
constructor(initialCode?: string, indentLength?: number);
|
|
43
|
+
/**
|
|
44
|
+
* Render the editor with the given options and panel
|
|
45
|
+
* @param {RenderOptions} options Options for rendering
|
|
46
|
+
* @param {HTMLElement} panel The panel to display at the bottom
|
|
47
|
+
* @return {HTMLElement} The rendered element
|
|
48
|
+
*/
|
|
13
49
|
render(options: RenderOptions, panel?: HTMLElement): HTMLElement;
|
|
14
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Set the language that is currently used
|
|
52
|
+
* @param {ProgrammingLanguage} language The language to use
|
|
53
|
+
*/
|
|
54
|
+
setLanguage(language: ProgrammingLanguage): void;
|
|
55
|
+
/**
|
|
56
|
+
* @param {CompletionSource} completionSource Function to obtain autocomplete results
|
|
57
|
+
*/
|
|
58
|
+
setCompletionSource(completionSource: CompletionSource): void;
|
|
59
|
+
/**
|
|
60
|
+
* Set the length in spaces of the indentation unit
|
|
61
|
+
* @param {number} indentLength The number of spaces to use
|
|
62
|
+
*/
|
|
15
63
|
setIndentLength(indentLength: number): void;
|
|
64
|
+
/**
|
|
65
|
+
* Set the panel that is displayed at the bottom of the editor
|
|
66
|
+
* @param {HTMLElement} panel The panel to display
|
|
67
|
+
*/
|
|
16
68
|
setPanel(panel: HTMLElement): void;
|
|
69
|
+
/**
|
|
70
|
+
* @return {string} The code within the editor
|
|
71
|
+
*/
|
|
17
72
|
getCode(): string;
|
|
73
|
+
/**
|
|
74
|
+
* @param {string} code The new code to be shown in the editor
|
|
75
|
+
*/
|
|
18
76
|
setCode(code: string): void;
|
|
77
|
+
/**
|
|
78
|
+
* Put focus on the CodeEditor
|
|
79
|
+
*/
|
|
19
80
|
focus(): void;
|
|
81
|
+
/**
|
|
82
|
+
* @param {number} indentLength The amount of spaces to use
|
|
83
|
+
* @return {string} The indentation unit to use
|
|
84
|
+
*/
|
|
20
85
|
static getIndentUnit(indentLength: number): string;
|
|
86
|
+
/**
|
|
87
|
+
* @param {ProgrammingLanguage} language The language to support
|
|
88
|
+
* @return {LanguageSupport} CodeMirror LanguageSupport for the language
|
|
89
|
+
*/
|
|
21
90
|
static getLanguageSupport(language: ProgrammingLanguage): LanguageSupport;
|
|
91
|
+
/**
|
|
92
|
+
* - [syntax highlighting depending on the language](#getLanguageSupport)
|
|
93
|
+
* - [line numbers](#gutter.lineNumbers)
|
|
94
|
+
* - [special character highlighting](#view.highlightSpecialChars)
|
|
95
|
+
* - [the undo history](#history.history)
|
|
96
|
+
* - [a fold gutter](#fold.foldGutter)
|
|
97
|
+
* - [custom selection drawing](#view.drawSelection)
|
|
98
|
+
* - [multiple selections](#state.EditorState^allowMultipleSelections)
|
|
99
|
+
* - [reindentation on input](#language.indentOnInput)
|
|
100
|
+
* - [the default highlight style](#highlight.defaultHighlightStyle) (as fallback)
|
|
101
|
+
* - [bracket matching](#matchbrackets.bracketMatching)
|
|
102
|
+
* - [bracket closing](#closebrackets.closeBrackets)
|
|
103
|
+
* - [autocompletion](#autocomplete.autocompletion)
|
|
104
|
+
* - [rectangular selection](#rectangular-selection.rectangularSelection)
|
|
105
|
+
* - [active line highlighting](#view.highlightActiveLine)
|
|
106
|
+
* - [active line gutter highlighting](#gutter.highlightActiveLineGutter)
|
|
107
|
+
* - [selection match highlighting](#search.highlightSelectionMatches)
|
|
108
|
+
* Keymaps:
|
|
109
|
+
* - [the default command bindings](#commands.defaultKeymap)
|
|
110
|
+
* - [search](#search.searchKeymap)
|
|
111
|
+
* - [commenting](#comment.commentKeymap)
|
|
112
|
+
* - [linting](#lint.lintKeymap)
|
|
113
|
+
* - [indenting with tab](#commands.indentWithTab)
|
|
114
|
+
* @return {Array<Extension} Default extensions to use
|
|
115
|
+
*/
|
|
22
116
|
static getExtensions(): Array<Extension>;
|
|
23
117
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { CodeEditor } from "./CodeEditor";
|
|
2
|
+
import { InputManager } from "./InputManager";
|
|
3
|
+
import { ProgrammingLanguage } from "./ProgrammingLanguage";
|
|
4
|
+
import { ButtonOptions, RenderOptions } from "./util/Util";
|
|
5
|
+
/**
|
|
6
|
+
* Enum representing the possible states while processing code
|
|
7
|
+
*/
|
|
8
|
+
export declare enum RunState {
|
|
9
|
+
Loading = "loading",
|
|
10
|
+
Running = "running",
|
|
11
|
+
AwaitingInput = "awaiting_input",
|
|
12
|
+
Stopping = "stopping",
|
|
13
|
+
Ready = "ready"
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Helper component to manage and visualize the current RunState
|
|
17
|
+
*/
|
|
18
|
+
export declare class CodeRunner {
|
|
19
|
+
/**
|
|
20
|
+
* The currently used programming language
|
|
21
|
+
*/
|
|
22
|
+
private programmingLanguage;
|
|
23
|
+
/**
|
|
24
|
+
* The editor in which the code is written
|
|
25
|
+
*/
|
|
26
|
+
readonly editor: CodeEditor;
|
|
27
|
+
/**
|
|
28
|
+
* Component to request and handle input from the user
|
|
29
|
+
*/
|
|
30
|
+
readonly inputManager: InputManager;
|
|
31
|
+
/**
|
|
32
|
+
* The backend that executes the code asynchronously
|
|
33
|
+
*/
|
|
34
|
+
private backend;
|
|
35
|
+
/**
|
|
36
|
+
* Current state of the program
|
|
37
|
+
*/
|
|
38
|
+
private state;
|
|
39
|
+
/**
|
|
40
|
+
* Buttons managed by this component
|
|
41
|
+
*/
|
|
42
|
+
private buttons;
|
|
43
|
+
/**
|
|
44
|
+
* Construct a new RunStateManager with the given listeners
|
|
45
|
+
* @param {ProgrammingLanguage} programmingLanguage The language to use
|
|
46
|
+
*/
|
|
47
|
+
constructor(programmingLanguage: ProgrammingLanguage);
|
|
48
|
+
/**
|
|
49
|
+
* Start the backend to enable running code
|
|
50
|
+
*/
|
|
51
|
+
start(): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Interrupt the currently running code
|
|
54
|
+
* @return {Promise<void>} Promise of stopping
|
|
55
|
+
*/
|
|
56
|
+
stop(): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Set the used programming language to the given one to allow editing and running code
|
|
59
|
+
* @param {ProgrammingLanguage} programmingLanguage The language to use
|
|
60
|
+
*/
|
|
61
|
+
setProgrammingLanguage(programmingLanguage: ProgrammingLanguage): Promise<void>;
|
|
62
|
+
getProgrammingLanguage(): ProgrammingLanguage;
|
|
63
|
+
/**
|
|
64
|
+
* Get the button to run the code
|
|
65
|
+
*/
|
|
66
|
+
get runButton(): HTMLButtonElement;
|
|
67
|
+
/**
|
|
68
|
+
* Get the button to interrupt the code
|
|
69
|
+
*/
|
|
70
|
+
get stopButton(): HTMLButtonElement;
|
|
71
|
+
/**
|
|
72
|
+
* Show or hide the spinning circle, representing a running animation
|
|
73
|
+
* @param {boolean} show Whether to show the spinner
|
|
74
|
+
*/
|
|
75
|
+
showSpinner(show: boolean): void;
|
|
76
|
+
/**
|
|
77
|
+
* Show the current state of the program to the user
|
|
78
|
+
* @param {RunState} state The current state of the run
|
|
79
|
+
* @param {string} message Optional message to indicate the state
|
|
80
|
+
*/
|
|
81
|
+
setState(state: RunState, message?: string): void;
|
|
82
|
+
getState(): RunState;
|
|
83
|
+
/**
|
|
84
|
+
* Add a button to display to the user
|
|
85
|
+
* @param {ButtonOptions} options Options for rendering the button
|
|
86
|
+
* @param {function} onClick Listener for click events on the button
|
|
87
|
+
*/
|
|
88
|
+
addButton(options: ButtonOptions, onClick: () => void): void;
|
|
89
|
+
/**
|
|
90
|
+
* Render the RunStateManager with the given options
|
|
91
|
+
* @param {RenderOptions} statusPanelOptions Options for rendering the panel
|
|
92
|
+
* @param {RenderOptions} inputOptions Options for rendering the InputManager
|
|
93
|
+
* @param {RenderOptions} codeEditorOptions Options for rendering the editor
|
|
94
|
+
* @return {HTMLElement} The rendered RunStateManager
|
|
95
|
+
*/
|
|
96
|
+
render(statusPanelOptions: RenderOptions, inputOptions: RenderOptions, codeEditorOptions: RenderOptions): HTMLElement;
|
|
97
|
+
/**
|
|
98
|
+
* Run the code that is currently present in the editor
|
|
99
|
+
* @return {Promise<void>} Promise of running the code
|
|
100
|
+
*/
|
|
101
|
+
runCode(): Promise<void>;
|
|
102
|
+
}
|
package/dist/Constants.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { ProgrammingLanguage } from "./ProgrammingLanguage";
|
|
2
|
-
export declare const MAIN_APP_ID
|
|
3
|
-
export declare const OUTPUT_TA_ID
|
|
4
|
-
export declare const INPUT_AREA_WRAPPER_ID
|
|
5
|
-
export declare const INPUT_TA_ID
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
2
|
+
export declare const MAIN_APP_ID: string;
|
|
3
|
+
export declare const OUTPUT_TA_ID: string;
|
|
4
|
+
export declare const INPUT_AREA_WRAPPER_ID: string;
|
|
5
|
+
export declare const INPUT_TA_ID: string;
|
|
6
|
+
export declare const USER_INPUT_WRAPPER_ID: string;
|
|
7
|
+
export declare const EDITOR_WRAPPER_ID: string;
|
|
8
|
+
export declare const PANEL_WRAPPER_ID: string;
|
|
9
|
+
export declare const STATE_SPINNER_ID: string;
|
|
10
|
+
export declare const APPLICATION_STATE_TEXT_ID: string;
|
|
11
|
+
export declare const RUN_BTN_ID: string;
|
|
12
|
+
export declare const STOP_BTN_ID: string;
|
|
13
|
+
export declare const SEND_INPUT_BTN_ID: string;
|
|
14
|
+
export declare const SWITCH_INPUT_MODE_A_ID: string;
|
|
15
|
+
export declare const EXAMPLE_SELECT_ID: string;
|
|
16
|
+
export declare const LOCALE_SELECT_ID: string;
|
|
17
|
+
export declare const PROGRAMMING_LANGUAGE_SELECT_ID: string;
|
|
15
18
|
export declare const DEFAULT_PROGRAMMING_LANGUAGE = ProgrammingLanguage.Python;
|
|
16
|
-
export declare const EXAMPLE_SELECT_ID = "example-select";
|
|
17
|
-
export declare const LOCALE_SELECT_ID = "locale-select";
|
|
18
19
|
export declare const DEFAULT_LOCALE = "nl";
|
|
19
20
|
export declare const DEFAULT_SERVICE_WORKER = "inputServiceWorker.js";
|
package/dist/InputManager.d.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BackendEvent } from "./BackendEvent";
|
|
2
2
|
import { RenderOptions } from "./util/Util";
|
|
3
|
-
import {
|
|
3
|
+
import { UserInputHandler } from "./input/UserInputHandler";
|
|
4
4
|
export declare enum InputMode {
|
|
5
5
|
Interactive = "interactive",
|
|
6
6
|
Batch = "batch"
|
|
7
7
|
}
|
|
8
8
|
export declare const INPUT_MODES: InputMode[];
|
|
9
|
-
interface InputSession {
|
|
10
|
-
lineNr: number;
|
|
11
|
-
}
|
|
12
9
|
export declare class InputManager {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
get enterButton(): HTMLButtonElement;
|
|
23
|
-
get inputArea(): HTMLInputElement;
|
|
24
|
-
render(options?: RenderOptions): void;
|
|
10
|
+
private inputMode;
|
|
11
|
+
private inputHandlers;
|
|
12
|
+
private renderOptions;
|
|
13
|
+
private waiting;
|
|
14
|
+
private prompt;
|
|
15
|
+
private sendInput;
|
|
16
|
+
constructor(sendInput: (input: string) => void);
|
|
17
|
+
private buildInputHandlerMap;
|
|
18
|
+
getInputMode(): InputMode;
|
|
25
19
|
setInputMode(inputMode: InputMode): void;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
get inputHandler(): UserInputHandler;
|
|
21
|
+
render(options: RenderOptions): void;
|
|
22
|
+
waitWithPrompt(waiting: boolean, prompt?: string): void;
|
|
23
|
+
onUserInput(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Asynchronously handle an input request by prompting the user for input
|
|
26
|
+
* @param {BackendEvent} e Event containing the input data
|
|
27
|
+
* @return {Promise<void>} Promise of handling the request
|
|
28
|
+
*/
|
|
29
|
+
onInputRequest(e: BackendEvent): Promise<void>;
|
|
29
30
|
onRunStart(): void;
|
|
30
31
|
onRunEnd(): void;
|
|
31
32
|
}
|
|
32
|
-
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BackendEvent } from "./BackendEvent";
|
|
2
|
+
import { CodeEditor } from "./CodeEditor";
|
|
3
|
+
import { InputManager, InputMode } from "./InputManager";
|
|
4
|
+
import { OutputManager } from "./OutputManager";
|
|
5
|
+
import { Papyros } from "./Papyros";
|
|
6
|
+
import { CodeRunner, RunState } from "./CodeRunner";
|
|
7
|
+
import { InputWorker } from "./workers/input/InputWorker";
|
|
8
|
+
export * from "./ProgrammingLanguage";
|
|
9
|
+
export type { BackendEvent };
|
|
10
|
+
export { Papyros, CodeEditor, RunState, CodeRunner, InputManager, InputMode, OutputManager, InputWorker };
|
package/dist/OutputManager.d.ts
CHANGED
|
@@ -1,23 +1,75 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BackendEvent } from "./BackendEvent";
|
|
2
2
|
import { RenderOptions } from "./util/Util";
|
|
3
|
+
/**
|
|
4
|
+
* Shape of Error objects that are easy to interpret
|
|
5
|
+
*/
|
|
3
6
|
export interface FriendlyError {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the Error
|
|
9
|
+
*/
|
|
4
10
|
name: string;
|
|
11
|
+
/**
|
|
12
|
+
* Traceback for where in the code the Error occurred
|
|
13
|
+
*/
|
|
5
14
|
traceback?: string;
|
|
15
|
+
/**
|
|
16
|
+
* General information about this type of Error
|
|
17
|
+
*/
|
|
6
18
|
info?: string;
|
|
7
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Information about what went wrong in this case
|
|
21
|
+
*/
|
|
8
22
|
what?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Information about why this is wrong and how to fix it
|
|
25
|
+
*/
|
|
26
|
+
why?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Where specifically in the source code the Error occurred
|
|
29
|
+
*/
|
|
9
30
|
where?: string;
|
|
10
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Component for displaying code output or errors to the user
|
|
34
|
+
*/
|
|
11
35
|
export declare class OutputManager {
|
|
12
|
-
outputAreaId: string;
|
|
13
36
|
options: RenderOptions;
|
|
37
|
+
constructor();
|
|
38
|
+
/**
|
|
39
|
+
* Retrieve the parent element containing all output parts
|
|
40
|
+
*/
|
|
14
41
|
get outputArea(): HTMLElement;
|
|
42
|
+
/**
|
|
43
|
+
* Render an element in the next position of the output area
|
|
44
|
+
* @param {string} html Safe string version of the next child to render
|
|
45
|
+
*/
|
|
15
46
|
renderNextElement(html: string): void;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Convert a piece of text to a span element for displaying
|
|
49
|
+
* @param {string} text The text content for the span
|
|
50
|
+
* @param {boolean} ignoreEmpty Whether to remove empty lines in the text
|
|
51
|
+
* @param {string} className Optional class name for the span
|
|
52
|
+
* @return {string} String version of the created span
|
|
53
|
+
*/
|
|
54
|
+
spanify(text: string, ignoreEmpty?: boolean, className?: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Display output to the user, based on its content type
|
|
57
|
+
* @param {BackendEvent} output Event containing the output data
|
|
58
|
+
*/
|
|
59
|
+
showOutput(output: BackendEvent): void;
|
|
60
|
+
/**
|
|
61
|
+
* Display an error to the user
|
|
62
|
+
* @param {BackendEvent} error Event containing the error data
|
|
63
|
+
*/
|
|
64
|
+
showError(error: BackendEvent): void;
|
|
65
|
+
/**
|
|
66
|
+
* Render the OutputManager with the given options
|
|
67
|
+
* @param {RenderOptions} options Options for rendering
|
|
68
|
+
* @return {HTMLElement} The rendered output area
|
|
69
|
+
*/
|
|
19
70
|
render(options: RenderOptions): HTMLElement;
|
|
71
|
+
/**
|
|
72
|
+
* Clear the contents of the output area
|
|
73
|
+
*/
|
|
20
74
|
reset(): void;
|
|
21
|
-
onRunStart(): void;
|
|
22
|
-
onRunEnd(): void;
|
|
23
75
|
}
|