@dodona/papyros 3.0.2 → 4.0.0-beta.2
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/README.md +133 -72
- package/dist/Components.d.ts +4 -0
- package/dist/Components.js +5 -0
- package/dist/Components.js.map +1 -0
- package/dist/Papyros.d.ts +18 -127
- package/dist/Papyros.js +39 -211
- package/dist/Papyros.js.map +1 -1
- package/dist/{Backend.d.ts → backend/Backend.d.ts} +3 -12
- package/dist/{Backend.js → backend/Backend.js} +4 -17
- package/dist/backend/Backend.js.map +1 -0
- package/dist/{workers → backend/workers}/javascript/JavaScriptWorker.js +1 -1
- package/dist/backend/workers/javascript/JavaScriptWorker.js.map +1 -0
- package/dist/backend/workers/javascript/worker.js.map +1 -0
- package/dist/{workers → backend/workers}/python/PythonWorker.d.ts +2 -2
- package/dist/{workers → backend/workers}/python/PythonWorker.js +2 -2
- package/dist/backend/workers/python/PythonWorker.js.map +1 -0
- package/dist/backend/workers/python/python_package.tar.gz.load_by_url +0 -0
- package/dist/backend/workers/python/worker.js.map +1 -0
- package/dist/communication/BackendEvent.js.map +1 -0
- package/dist/{BackendEventQueue.d.ts → communication/BackendEventQueue.d.ts} +1 -36
- package/dist/{BackendEventQueue.js → communication/BackendEventQueue.js} +2 -45
- package/dist/communication/BackendEventQueue.js.map +1 -0
- package/dist/{BackendManager.d.ts → communication/BackendManager.d.ts} +2 -2
- package/dist/{BackendManager.js → communication/BackendManager.js} +4 -4
- package/dist/communication/BackendManager.js.map +1 -0
- package/dist/communication/InputServiceWorker.js +37 -0
- package/dist/communication/InputServiceWorker.js.map +1 -0
- package/dist/communication/InputWorker.js.map +1 -0
- package/dist/frontend/components/CodeRunner.d.ts +9 -0
- package/dist/frontend/components/CodeRunner.js +60 -0
- package/dist/frontend/components/CodeRunner.js.map +1 -0
- package/dist/frontend/components/Debugger.d.ts +7 -0
- package/dist/frontend/components/Debugger.js +62 -0
- package/dist/frontend/components/Debugger.js.map +1 -0
- package/dist/frontend/components/Input.d.ts +17 -0
- package/dist/frontend/components/Input.js +73 -0
- package/dist/frontend/components/Input.js.map +1 -0
- package/dist/frontend/components/Output.d.ts +14 -0
- package/dist/frontend/components/Output.js +154 -0
- package/dist/frontend/components/Output.js.map +1 -0
- package/dist/frontend/components/PapyrosElement.d.ts +8 -0
- package/dist/frontend/components/PapyrosElement.js +24 -0
- package/dist/frontend/components/PapyrosElement.js.map +1 -0
- package/dist/frontend/components/app/App.d.ts +24 -0
- package/dist/frontend/components/app/App.js +204 -0
- package/dist/frontend/components/app/App.js.map +1 -0
- package/dist/frontend/components/app/ExamplePicker.d.ts +7 -0
- package/dist/frontend/components/app/ExamplePicker.js +35 -0
- package/dist/frontend/components/app/ExamplePicker.js.map +1 -0
- package/dist/frontend/components/app/LanguagePicker.d.ts +7 -0
- package/dist/frontend/components/app/LanguagePicker.js +35 -0
- package/dist/frontend/components/app/LanguagePicker.js.map +1 -0
- package/dist/frontend/components/app/ProgrammingLanguagePicker.d.ts +7 -0
- package/dist/frontend/components/app/ProgrammingLanguagePicker.js +39 -0
- package/dist/frontend/components/app/ProgrammingLanguagePicker.js.map +1 -0
- package/dist/frontend/components/app/examples/JavaScriptExamples.js.map +1 -0
- package/dist/frontend/components/app/examples/PythonExamples.js.map +1 -0
- package/dist/frontend/components/app/themes/ThemePicker.d.ts +11 -0
- package/dist/frontend/components/app/themes/ThemePicker.js +47 -0
- package/dist/frontend/components/app/themes/ThemePicker.js.map +1 -0
- package/dist/frontend/components/app/themes/ThemedButton.d.ts +9 -0
- package/dist/frontend/components/app/themes/ThemedButton.js +43 -0
- package/dist/frontend/components/app/themes/ThemedButton.js.map +1 -0
- package/dist/frontend/components/code_mirror/BatchInputEditor.d.ts +8 -0
- package/dist/frontend/components/code_mirror/BatchInputEditor.js +54 -0
- package/dist/frontend/components/code_mirror/BatchInputEditor.js.map +1 -0
- package/dist/frontend/components/code_mirror/CodeEditor.d.ts +24 -0
- package/dist/frontend/components/code_mirror/CodeEditor.js +206 -0
- package/dist/frontend/components/code_mirror/CodeEditor.js.map +1 -0
- package/dist/frontend/components/code_mirror/CodeMirrorEditor.d.ts +20 -0
- package/dist/frontend/components/code_mirror/CodeMirrorEditor.js +99 -0
- package/dist/frontend/components/code_mirror/CodeMirrorEditor.js.map +1 -0
- package/dist/frontend/components/code_mirror/Extensions.d.ts +15 -0
- package/dist/frontend/components/code_mirror/Extensions.js +169 -0
- package/dist/frontend/components/code_mirror/Extensions.js.map +1 -0
- package/dist/frontend/components/code_mirror/MaterialTheme.d.ts +5 -0
- package/dist/frontend/components/code_mirror/MaterialTheme.js +109 -0
- package/dist/frontend/components/code_mirror/MaterialTheme.js.map +1 -0
- package/dist/frontend/components/code_runner/ButtonLint.d.ts +9 -0
- package/dist/frontend/components/code_runner/ButtonLint.js +76 -0
- package/dist/frontend/components/code_runner/ButtonLint.js.map +1 -0
- package/dist/frontend/components/code_runner/Code.d.ts +7 -0
- package/dist/frontend/components/code_runner/Code.js +46 -0
- package/dist/frontend/components/code_runner/Code.js.map +1 -0
- package/dist/frontend/components/code_runner/RunState.d.ts +7 -0
- package/dist/frontend/components/code_runner/RunState.js +41 -0
- package/dist/frontend/components/code_runner/RunState.js.map +1 -0
- package/dist/frontend/components/input/BatchInput.d.ts +19 -0
- package/dist/frontend/components/input/BatchInput.js +92 -0
- package/dist/frontend/components/input/BatchInput.js.map +1 -0
- package/dist/frontend/components/input/InteractiveInput.d.ts +13 -0
- package/dist/frontend/components/input/InteractiveInput.js +73 -0
- package/dist/frontend/components/input/InteractiveInput.js.map +1 -0
- package/dist/frontend/state/Constants.d.ts +38 -0
- package/dist/frontend/state/Constants.js +108 -0
- package/dist/frontend/state/Constants.js.map +1 -0
- package/dist/frontend/state/Debugger.d.ts +23 -0
- package/dist/frontend/state/Debugger.js +80 -0
- package/dist/frontend/state/Debugger.js.map +1 -0
- package/dist/frontend/state/Examples.d.ts +11 -0
- package/dist/frontend/state/Examples.js +36 -0
- package/dist/frontend/state/Examples.js.map +1 -0
- package/dist/frontend/state/I18n.d.ts +16 -0
- package/dist/frontend/state/I18n.js +75 -0
- package/dist/frontend/state/I18n.js.map +1 -0
- package/dist/frontend/state/InputOutput.d.ts +55 -0
- package/dist/frontend/state/InputOutput.js +93 -0
- package/dist/frontend/state/InputOutput.js.map +1 -0
- package/dist/frontend/state/Runner.d.ts +118 -0
- package/dist/frontend/state/Runner.js +334 -0
- package/dist/frontend/state/Runner.js.map +1 -0
- package/dist/frontend/state/Test.d.ts +11 -0
- package/dist/frontend/state/Test.js +59 -0
- package/dist/frontend/state/Test.js.map +1 -0
- package/dist/frontend/state/Translations.d.ts +178 -0
- package/dist/frontend/state/Translations.js +188 -0
- package/dist/frontend/state/Translations.js.map +1 -0
- package/dist/frontend/state/themes/blue-dark.d.ts +2 -0
- package/dist/frontend/state/themes/blue-dark.js +55 -0
- package/dist/frontend/state/themes/blue-dark.js.map +1 -0
- package/dist/frontend/state/themes/blue-light.d.ts +2 -0
- package/dist/frontend/state/themes/blue-light.js +55 -0
- package/dist/frontend/state/themes/blue-light.js.map +1 -0
- package/dist/frontend/state/themes/green-dark.d.ts +2 -0
- package/dist/frontend/state/themes/green-dark.js +55 -0
- package/dist/frontend/state/themes/green-dark.js.map +1 -0
- package/dist/frontend/state/themes/green-light.d.ts +2 -0
- package/dist/frontend/state/themes/green-light.js +55 -0
- package/dist/frontend/state/themes/green-light.js.map +1 -0
- package/dist/frontend/state/themes/red-dark.d.ts +2 -0
- package/dist/frontend/state/themes/red-dark.js +55 -0
- package/dist/frontend/state/themes/red-dark.js.map +1 -0
- package/dist/frontend/state/themes/red-light.d.ts +2 -0
- package/dist/frontend/state/themes/red-light.js +55 -0
- package/dist/frontend/state/themes/red-light.js.map +1 -0
- package/dist/util/Util.d.ts +1 -4
- package/dist/util/Util.js +7 -8
- package/dist/util/Util.js.map +1 -1
- package/package.json +13 -21
- package/dist/App.d.ts +0 -1
- package/dist/App.js +0 -76
- package/dist/App.js.map +0 -1
- package/dist/Backend.js.map +0 -1
- package/dist/BackendEvent.js.map +0 -1
- package/dist/BackendEventQueue.js.map +0 -1
- package/dist/BackendManager.js.map +0 -1
- package/dist/CodeRunner.d.ts +0 -188
- package/dist/CodeRunner.js +0 -548
- package/dist/CodeRunner.js.map +0 -1
- package/dist/Constants.d.ts +0 -31
- package/dist/Constants.js +0 -36
- package/dist/Constants.js.map +0 -1
- package/dist/Debugger.d.ts +0 -18
- package/dist/Debugger.js +0 -86
- package/dist/Debugger.js.map +0 -1
- package/dist/InputManager.d.ts +0 -38
- package/dist/InputManager.js +0 -101
- package/dist/InputManager.js.map +0 -1
- package/dist/InputServiceWorker.js.map +0 -1
- package/dist/Library.d.ts +0 -12
- package/dist/Library.js +0 -9
- package/dist/Library.js.map +0 -1
- package/dist/OutputManager.d.ts +0 -90
- package/dist/OutputManager.js +0 -172
- package/dist/OutputManager.js.map +0 -1
- package/dist/Papyros.css +0 -657
- package/dist/Translations.d.ts +0 -180
- package/dist/Translations.js +0 -191
- package/dist/Translations.js.map +0 -1
- package/dist/editor/BatchInputEditor.d.ts +0 -41
- package/dist/editor/BatchInputEditor.js +0 -80
- package/dist/editor/BatchInputEditor.js.map +0 -1
- package/dist/editor/CodeEditor.d.ts +0 -81
- package/dist/editor/CodeEditor.js +0 -213
- package/dist/editor/CodeEditor.js.map +0 -1
- package/dist/editor/CodeMirrorEditor.d.ts +0 -133
- package/dist/editor/CodeMirrorEditor.js +0 -169
- package/dist/editor/CodeMirrorEditor.js.map +0 -1
- package/dist/editor/DarkTheme.d.ts +0 -1
- package/dist/editor/DarkTheme.js +0 -72
- package/dist/editor/DarkTheme.js.map +0 -1
- package/dist/editor/DebugExtension.d.ts +0 -11
- package/dist/editor/DebugExtension.js +0 -70
- package/dist/editor/DebugExtension.js.map +0 -1
- package/dist/editor/Gutters.d.ts +0 -109
- package/dist/editor/Gutters.js +0 -201
- package/dist/editor/Gutters.js.map +0 -1
- package/dist/editor/LineEffectExtension.d.ts +0 -13
- package/dist/editor/LineEffectExtension.js +0 -48
- package/dist/editor/LineEffectExtension.js.map +0 -1
- package/dist/editor/TestCodeExtension.d.ts +0 -21
- package/dist/editor/TestCodeExtension.js +0 -134
- package/dist/editor/TestCodeExtension.js.map +0 -1
- package/dist/examples/Examples.d.ts +0 -6
- package/dist/examples/Examples.js +0 -23
- package/dist/examples/Examples.js.map +0 -1
- package/dist/examples/JavaScriptExamples.js.map +0 -1
- package/dist/examples/PythonExamples.js.map +0 -1
- package/dist/input/BatchInputHandler.d.ts +0 -55
- package/dist/input/BatchInputHandler.js +0 -131
- package/dist/input/BatchInputHandler.js.map +0 -1
- package/dist/input/InteractiveInputHandler.d.ts +0 -27
- package/dist/input/InteractiveInputHandler.js +0 -89
- package/dist/input/InteractiveInputHandler.js.map +0 -1
- package/dist/input/UserInputHandler.d.ts +0 -68
- package/dist/input/UserInputHandler.js +0 -39
- package/dist/input/UserInputHandler.js.map +0 -1
- package/dist/util/HTMLShapes.d.ts +0 -15
- package/dist/util/HTMLShapes.js +0 -25
- package/dist/util/HTMLShapes.js.map +0 -1
- package/dist/util/Rendering.d.ts +0 -120
- package/dist/util/Rendering.js +0 -142
- package/dist/util/Rendering.js.map +0 -1
- package/dist/workers/input/InputWorker.js.map +0 -1
- package/dist/workers/javascript/JavaScriptWorker.js.map +0 -1
- package/dist/workers/javascript/worker.js.map +0 -1
- package/dist/workers/python/PythonWorker.js.map +0 -1
- package/dist/workers/python/python_package.tar.gz.load_by_url +0 -0
- package/dist/workers/python/worker.js.map +0 -1
- /package/dist/{workers → backend/workers}/javascript/JavaScriptWorker.d.ts +0 -0
- /package/dist/{workers → backend/workers}/javascript/worker.d.ts +0 -0
- /package/dist/{workers → backend/workers}/javascript/worker.js +0 -0
- /package/dist/{workers → backend/workers}/python/worker.d.ts +0 -0
- /package/dist/{workers → backend/workers}/python/worker.js +0 -0
- /package/dist/{BackendEvent.d.ts → communication/BackendEvent.d.ts} +0 -0
- /package/dist/{BackendEvent.js → communication/BackendEvent.js} +0 -0
- /package/dist/{InputServiceWorker.d.ts → communication/InputServiceWorker.d.ts} +0 -0
- /package/dist/{workers/input → communication}/InputWorker.d.ts +0 -0
- /package/dist/{workers/input → communication}/InputWorker.js +0 -0
- /package/dist/{examples → frontend/components/app/examples}/JavaScriptExamples.d.ts +0 -0
- /package/dist/{examples → frontend/components/app/examples}/JavaScriptExamples.js +0 -0
- /package/dist/{examples → frontend/components/app/examples}/PythonExamples.d.ts +0 -0
- /package/dist/{examples → frontend/components/app/examples}/PythonExamples.js +0 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { BackendManager } from "../../communication/BackendManager";
|
|
8
|
+
import { BackendEventType } from "../../communication/BackendEvent";
|
|
9
|
+
import { State, stateProperty } from "@dodona/lit-state";
|
|
10
|
+
export class Debugger extends State {
|
|
11
|
+
set active(active) {
|
|
12
|
+
this._active = active;
|
|
13
|
+
this.reset();
|
|
14
|
+
}
|
|
15
|
+
get active() {
|
|
16
|
+
return this._active;
|
|
17
|
+
}
|
|
18
|
+
constructor(papyros) {
|
|
19
|
+
super();
|
|
20
|
+
this.frameStates = [];
|
|
21
|
+
this.activeFrame = undefined;
|
|
22
|
+
this.trace = [];
|
|
23
|
+
this._active = false;
|
|
24
|
+
this.papyros = papyros;
|
|
25
|
+
this.reset();
|
|
26
|
+
BackendManager.subscribe(BackendEventType.Start, () => {
|
|
27
|
+
this.reset();
|
|
28
|
+
});
|
|
29
|
+
BackendManager.subscribe(BackendEventType.Frame, e => {
|
|
30
|
+
const frame = JSON.parse(e.data);
|
|
31
|
+
const frameState = {
|
|
32
|
+
line: frame.line,
|
|
33
|
+
outputs: this.papyros.io.output.length,
|
|
34
|
+
inputs: this.papyros.io.inputs.length
|
|
35
|
+
};
|
|
36
|
+
this.frameStates = [...this.frameStates, frameState];
|
|
37
|
+
this.trace = [...this.trace, frame];
|
|
38
|
+
if (this.frameStates.length >= this.papyros.constants.maxDebugFrames) {
|
|
39
|
+
this.papyros.runner.stop();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
reset() {
|
|
44
|
+
this.frameStates = [];
|
|
45
|
+
this.currentOutputs = 0;
|
|
46
|
+
this.currentInputs = 0;
|
|
47
|
+
this.trace = [];
|
|
48
|
+
}
|
|
49
|
+
get activeFrameState() {
|
|
50
|
+
if (this.activeFrame === undefined) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
return this.frameStates[this.activeFrame];
|
|
54
|
+
}
|
|
55
|
+
get debugLine() {
|
|
56
|
+
var _a;
|
|
57
|
+
return (_a = this.activeFrameState) === null || _a === void 0 ? void 0 : _a.line;
|
|
58
|
+
}
|
|
59
|
+
get debugOutputs() {
|
|
60
|
+
var _a;
|
|
61
|
+
return (_a = this.activeFrameState) === null || _a === void 0 ? void 0 : _a.outputs;
|
|
62
|
+
}
|
|
63
|
+
get debugUsedInputs() {
|
|
64
|
+
var _a;
|
|
65
|
+
return (_a = this.activeFrameState) === null || _a === void 0 ? void 0 : _a.inputs;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
__decorate([
|
|
69
|
+
stateProperty
|
|
70
|
+
], Debugger.prototype, "frameStates", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
stateProperty
|
|
73
|
+
], Debugger.prototype, "activeFrame", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
stateProperty
|
|
76
|
+
], Debugger.prototype, "trace", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
stateProperty
|
|
79
|
+
], Debugger.prototype, "_active", void 0);
|
|
80
|
+
//# sourceMappingURL=Debugger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Debugger.js","sourceRoot":"","sources":["../../../src/frontend/state/Debugger.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAQzD,MAAM,OAAO,QAAS,SAAQ,KAAK;IAW/B,IAAW,MAAM,CAAC,MAAe;QAC7B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QAEtB,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAED,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,YAAY,OAAgB;QACxB,KAAK,EAAE,CAAC;QAnBJ,gBAAW,GAAiB,EAAE,CAAC;QAEhC,gBAAW,GAAuB,SAAS,CAAC;QAE5C,UAAK,GAAY,EAAE,CAAC;QAEnB,YAAO,GAAY,KAAK,CAAC;QAc7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,EAAE,CAAC;QAEb,cAAc,CAAC,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,GAAG,EAAE;YAClD,IAAI,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,cAAc,CAAC,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE;YACjD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACjC,MAAM,UAAU,GAAG;gBACf,IAAI,EAAE,KAAK,CAAC,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6CACqC;AAE5C;IADN,aAAa;uCACa;AAEnB;IADP,aAAa;yCACmB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { State } from "@dodona/lit-state";
|
|
2
|
+
import { ProgrammingLanguage } from "../../ProgrammingLanguage";
|
|
3
|
+
import { Papyros } from "../../Papyros";
|
|
4
|
+
export declare class Examples extends State {
|
|
5
|
+
papyros: Papyros;
|
|
6
|
+
private examples;
|
|
7
|
+
constructor(papyros: Papyros);
|
|
8
|
+
setExamples(language: ProgrammingLanguage, examples: Record<string, string>): void;
|
|
9
|
+
get names(): Array<string>;
|
|
10
|
+
getExampleCode(name: string): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { State, StateMap, stateProperty } from "@dodona/lit-state";
|
|
8
|
+
import { ProgrammingLanguage } from "../../ProgrammingLanguage";
|
|
9
|
+
import { JAVASCRIPT_EXAMPLES } from "../components/app/examples/JavaScriptExamples";
|
|
10
|
+
import { PYTHON_EXAMPLES } from "../components/app/examples/PythonExamples";
|
|
11
|
+
export class Examples extends State {
|
|
12
|
+
constructor(papyros) {
|
|
13
|
+
super();
|
|
14
|
+
this.examples = new StateMap();
|
|
15
|
+
this.papyros = papyros;
|
|
16
|
+
this.setExamples(ProgrammingLanguage.JavaScript, JAVASCRIPT_EXAMPLES);
|
|
17
|
+
this.setExamples(ProgrammingLanguage.Python, PYTHON_EXAMPLES);
|
|
18
|
+
}
|
|
19
|
+
setExamples(language, examples) {
|
|
20
|
+
this.examples.set(language, examples);
|
|
21
|
+
}
|
|
22
|
+
get names() {
|
|
23
|
+
var _a;
|
|
24
|
+
const language = this.papyros.runner.programmingLanguage;
|
|
25
|
+
return Object.keys((_a = this.examples.get(language)) !== null && _a !== void 0 ? _a : {});
|
|
26
|
+
}
|
|
27
|
+
getExampleCode(name) {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
const language = this.papyros.runner.programmingLanguage;
|
|
30
|
+
return (_b = (_a = this.examples.get(language)) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : "";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
__decorate([
|
|
34
|
+
stateProperty
|
|
35
|
+
], Examples.prototype, "examples", void 0);
|
|
36
|
+
//# sourceMappingURL=Examples.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Examples.js","sourceRoot":"","sources":["../../../src/frontend/state/Examples.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAE5E,MAAM,OAAO,QAAS,SAAQ,KAAK;IAK/B,YAAY,OAAgB;QACxB,KAAK,EAAE,CAAC;QAHJ,aAAQ,GAAG,IAAI,QAAQ,EAA+C,CAAC;QAI3E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,UAAU,EAAE,mBAAmB,CAAC,CAAC;QACtE,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAClE,CAAC;IAEM,WAAW,CAAC,QAA6B,EAAE,QAAgC;QAC9E,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAED,IAAW,KAAK;;QACZ,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAC;QACzD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,mCAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;IAEM,cAAc,CAAC,IAAY;;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAC;QACzD,OAAO,MAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,0CAAG,IAAI,CAAC,mCAAI,EAAE,CAAC;IACrD,CAAC;CACJ;AAtBW;IADP,aAAa;0CACiE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { State } from "@dodona/lit-state";
|
|
2
|
+
export type Translations = {
|
|
3
|
+
[key: string]: string | Translations;
|
|
4
|
+
};
|
|
5
|
+
export declare class I18n extends State {
|
|
6
|
+
private readonly polyglot;
|
|
7
|
+
private readonly translations;
|
|
8
|
+
private _locale;
|
|
9
|
+
get availableLocales(): string[];
|
|
10
|
+
setTranslations(locale: string, translations: Translations): void;
|
|
11
|
+
set locale(locale: string);
|
|
12
|
+
get locale(): string;
|
|
13
|
+
t(phrase: string, options?: Record<string, any>): string;
|
|
14
|
+
getTranslations(key?: string): Translations | undefined;
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { State, StateMap, stateProperty } from "@dodona/lit-state";
|
|
8
|
+
import Polyglot from "node-polyglot";
|
|
9
|
+
import { DUTCH_TRANSLATION, ENGLISH_TRANSLATION } from "./Translations";
|
|
10
|
+
export class I18n extends State {
|
|
11
|
+
get availableLocales() {
|
|
12
|
+
return [...this.translations.keys()];
|
|
13
|
+
}
|
|
14
|
+
setTranslations(locale, translations) {
|
|
15
|
+
this.translations.set(locale, translations);
|
|
16
|
+
if (this.locale === locale) {
|
|
17
|
+
this.dispatchStateEvent("t");
|
|
18
|
+
this.polyglot.replace(this.translations.get(locale));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
set locale(locale) {
|
|
22
|
+
if (this.translations.has(locale)) {
|
|
23
|
+
this.dispatchStateEvent("t");
|
|
24
|
+
this._locale = locale;
|
|
25
|
+
this.polyglot.locale(locale);
|
|
26
|
+
this.polyglot.replace(this.translations.get(locale));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
throw new Error(`Locale ${locale} not loaded`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
get locale() {
|
|
33
|
+
return this._locale;
|
|
34
|
+
}
|
|
35
|
+
t(phrase, options) {
|
|
36
|
+
this.recordRead("t");
|
|
37
|
+
return this.polyglot.t(phrase, options);
|
|
38
|
+
}
|
|
39
|
+
getTranslations(key) {
|
|
40
|
+
if (!this.translations.has(this.locale)) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
if (!key) {
|
|
44
|
+
return this.translations.get(this.locale);
|
|
45
|
+
}
|
|
46
|
+
const keys = key.split(".");
|
|
47
|
+
let record = this.translations.get(this.locale);
|
|
48
|
+
for (const k of keys) {
|
|
49
|
+
if (typeof record === "string" || !(k in record)) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
record = record[k];
|
|
53
|
+
}
|
|
54
|
+
if (typeof record === "string") {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
return record;
|
|
58
|
+
}
|
|
59
|
+
constructor() {
|
|
60
|
+
super();
|
|
61
|
+
this.polyglot = new Polyglot();
|
|
62
|
+
this.translations = new StateMap();
|
|
63
|
+
this._locale = "en";
|
|
64
|
+
this.polyglot.locale(this.locale);
|
|
65
|
+
this.setTranslations("en", ENGLISH_TRANSLATION);
|
|
66
|
+
this.setTranslations("nl", DUTCH_TRANSLATION);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
__decorate([
|
|
70
|
+
stateProperty
|
|
71
|
+
], I18n.prototype, "_locale", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
stateProperty
|
|
74
|
+
], I18n.prototype, "locale", null);
|
|
75
|
+
//# sourceMappingURL=I18n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"I18n.js","sourceRoot":"","sources":["../../../src/frontend/state/I18n.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAIxE,MAAM,OAAO,IAAK,SAAQ,KAAK;IAM3B,IAAI,gBAAgB;QAChB,OAAO,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IAEM,eAAe,CAAC,MAAc,EAAE,YAA0B;QAC7D,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QA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,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,GAA0B,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAE,CAAC;QACxE,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;YACnB,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC;gBAC/C,OAAO,SAAS,CAAC;YACrB,CAAC;YACD,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACvB,CAAC;QACD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;QACI,KAAK,EAAE,CAAC;QA5DK,aAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC1B,iBAAY,GAAG,IAAI,QAAQ,EAAwB,CAAC;QAE7D,YAAO,GAAW,IAAI,CAAC;QA0D3B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAA;QAC/C,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAClD,CAAC;CACJ;AA9DW;IADP,aAAa;qCACiB;AA0B/B;IADC,aAAa;kCAGb"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { State } from "@dodona/lit-state";
|
|
2
|
+
import { Papyros } from "../../Papyros";
|
|
3
|
+
/**
|
|
4
|
+
* Shape of Error objects that are easy to interpret
|
|
5
|
+
*/
|
|
6
|
+
export interface FriendlyError {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the Error
|
|
9
|
+
*/
|
|
10
|
+
name: string;
|
|
11
|
+
/**
|
|
12
|
+
* Traceback for where in the code the Error occurred
|
|
13
|
+
*/
|
|
14
|
+
traceback?: string;
|
|
15
|
+
/**
|
|
16
|
+
* General information about this type of Error
|
|
17
|
+
*/
|
|
18
|
+
info?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Information about what went wrong in this case
|
|
21
|
+
*/
|
|
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
|
+
*/
|
|
30
|
+
where?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare enum OutputType {
|
|
33
|
+
stdout = "stdout",
|
|
34
|
+
stderr = "stderr",
|
|
35
|
+
img = "img"
|
|
36
|
+
}
|
|
37
|
+
export type OutputEntry = {
|
|
38
|
+
type: OutputType;
|
|
39
|
+
content: string | FriendlyError;
|
|
40
|
+
contentType?: string;
|
|
41
|
+
};
|
|
42
|
+
export declare class InputOutput extends State {
|
|
43
|
+
private papyros;
|
|
44
|
+
inputs: string[];
|
|
45
|
+
output: OutputEntry[];
|
|
46
|
+
prompt: string;
|
|
47
|
+
awaitingInput: boolean;
|
|
48
|
+
constructor(papyros: Papyros);
|
|
49
|
+
logError(error: FriendlyError | string): void;
|
|
50
|
+
logImage(imageData: string, contentType?: string): void;
|
|
51
|
+
logOutput(output: string): void;
|
|
52
|
+
provideInput(input: string): void;
|
|
53
|
+
clearInputs(): void;
|
|
54
|
+
reset(): void;
|
|
55
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { State, stateProperty } from "@dodona/lit-state";
|
|
8
|
+
import { BackendManager } from "../../communication/BackendManager";
|
|
9
|
+
import { BackendEventType } from "../../communication/BackendEvent";
|
|
10
|
+
import { parseData } from "../../util/Util";
|
|
11
|
+
export var OutputType;
|
|
12
|
+
(function (OutputType) {
|
|
13
|
+
OutputType["stdout"] = "stdout";
|
|
14
|
+
OutputType["stderr"] = "stderr";
|
|
15
|
+
OutputType["img"] = "img";
|
|
16
|
+
})(OutputType || (OutputType = {}));
|
|
17
|
+
export class InputOutput extends State {
|
|
18
|
+
constructor(papyros) {
|
|
19
|
+
super();
|
|
20
|
+
this.inputs = [];
|
|
21
|
+
this.output = [];
|
|
22
|
+
this.prompt = "";
|
|
23
|
+
this.awaitingInput = false;
|
|
24
|
+
this.papyros = papyros;
|
|
25
|
+
this.reset();
|
|
26
|
+
BackendManager.subscribe(BackendEventType.Start, () => this.reset());
|
|
27
|
+
BackendManager.subscribe(BackendEventType.Output, e => {
|
|
28
|
+
const data = parseData(e.data, e.contentType);
|
|
29
|
+
if (e.contentType && e.contentType.startsWith("img")) {
|
|
30
|
+
this.logImage(data, e.contentType);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
this.logOutput(data);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
BackendManager.subscribe(BackendEventType.Error, e => {
|
|
37
|
+
const data = parseData(e.data, e.contentType);
|
|
38
|
+
this.logError(data);
|
|
39
|
+
});
|
|
40
|
+
BackendManager.subscribe(BackendEventType.Input, e => {
|
|
41
|
+
this.prompt = e.data || "";
|
|
42
|
+
this.awaitingInput = true;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
logError(error) {
|
|
46
|
+
this.output = [...this.output, { type: OutputType.stderr, content: error }];
|
|
47
|
+
}
|
|
48
|
+
logImage(imageData, contentType = "img/png") {
|
|
49
|
+
this.output = [...this.output, { type: OutputType.img, content: imageData, contentType }];
|
|
50
|
+
}
|
|
51
|
+
logOutput(output) {
|
|
52
|
+
// lines have been merged to limit the number of events
|
|
53
|
+
// we split them again here, to simplify overflow detection
|
|
54
|
+
const lines = output.split("\n");
|
|
55
|
+
if (lines.length > 1) {
|
|
56
|
+
this.output = [...this.output,
|
|
57
|
+
...lines.slice(0, -1).map(line => ({ type: OutputType.stdout, content: line + "\n" })),
|
|
58
|
+
{ type: OutputType.stdout, content: lines[lines.length - 1] }
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.output = [...this.output, { type: OutputType.stdout, content: output }];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
provideInput(input) {
|
|
66
|
+
this.inputs = [...this.inputs, input];
|
|
67
|
+
this.papyros.runner.provideInput(input);
|
|
68
|
+
this.prompt = "";
|
|
69
|
+
this.awaitingInput = false;
|
|
70
|
+
}
|
|
71
|
+
clearInputs() {
|
|
72
|
+
this.inputs = [];
|
|
73
|
+
}
|
|
74
|
+
reset() {
|
|
75
|
+
this.inputs = [];
|
|
76
|
+
this.output = [];
|
|
77
|
+
this.prompt = "";
|
|
78
|
+
this.awaitingInput = false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
__decorate([
|
|
82
|
+
stateProperty
|
|
83
|
+
], InputOutput.prototype, "inputs", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
stateProperty
|
|
86
|
+
], InputOutput.prototype, "output", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
stateProperty
|
|
89
|
+
], InputOutput.prototype, "prompt", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
stateProperty
|
|
92
|
+
], InputOutput.prototype, "awaitingInput", void 0);
|
|
93
|
+
//# sourceMappingURL=InputOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InputOutput.js","source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CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC;gBACtF,EAAE,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE;aAChE,CAAC;QACN,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QACjF,CAAC;IACL,CAAC;IAEM,YAAY,CAAC,KAAa;QAC7B,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC/B,CAAC;IAEM,WAAW;QACd,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACrB,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC/B,CAAC;CACJ;AAtEO;IADH,aAAa;2CACY;AAEtB;IADH,aAAa;2CACiB;AAE3B;IADH,aAAa;2CACU;AAEpB;IADH,aAAa;kDACqB"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { SyncClient } from "comsync";
|
|
2
|
+
import { Backend, RunMode, WorkerDiagnostic } from "../../backend/Backend";
|
|
3
|
+
import { State } from "@dodona/lit-state";
|
|
4
|
+
import { Papyros } from "../../Papyros";
|
|
5
|
+
import { ProgrammingLanguage } from "../../ProgrammingLanguage";
|
|
6
|
+
/**
|
|
7
|
+
* Enum representing the possible states while processing code
|
|
8
|
+
*/
|
|
9
|
+
export declare enum RunState {
|
|
10
|
+
Loading = "loading",
|
|
11
|
+
Running = "running",
|
|
12
|
+
AwaitingInput = "awaiting_input",
|
|
13
|
+
Stopping = "stopping",
|
|
14
|
+
Ready = "ready"
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Interface to represent information required when handling loading events
|
|
18
|
+
*/
|
|
19
|
+
export interface LoadingData {
|
|
20
|
+
/**
|
|
21
|
+
* List of module names that are being loaded
|
|
22
|
+
*/
|
|
23
|
+
modules: Array<string>;
|
|
24
|
+
/**
|
|
25
|
+
* The status of the import
|
|
26
|
+
*/
|
|
27
|
+
status: "loading" | "loaded" | "failed";
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Helper component to manage and visualize the current RunState
|
|
31
|
+
*/
|
|
32
|
+
export declare class Runner extends State {
|
|
33
|
+
/**
|
|
34
|
+
* The currently used programming language
|
|
35
|
+
*/
|
|
36
|
+
private _programmingLanguage;
|
|
37
|
+
get programmingLanguage(): ProgrammingLanguage;
|
|
38
|
+
set programmingLanguage(value: ProgrammingLanguage);
|
|
39
|
+
/**
|
|
40
|
+
* The backend that executes the code asynchronously
|
|
41
|
+
*/
|
|
42
|
+
backend: Promise<SyncClient<Backend>>;
|
|
43
|
+
/**
|
|
44
|
+
* Current state of the program
|
|
45
|
+
*/
|
|
46
|
+
state: RunState;
|
|
47
|
+
/**
|
|
48
|
+
* An explanatory message about the current state
|
|
49
|
+
*/
|
|
50
|
+
stateMessage: string;
|
|
51
|
+
/**
|
|
52
|
+
* Previous state to restore when loading is done
|
|
53
|
+
*/
|
|
54
|
+
private previousState;
|
|
55
|
+
/**
|
|
56
|
+
* Array of packages that are being installed
|
|
57
|
+
*/
|
|
58
|
+
loadingPackages: Array<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Time at which the setState call occurred
|
|
61
|
+
*/
|
|
62
|
+
runStartTime: number;
|
|
63
|
+
/**
|
|
64
|
+
* The code we are working with
|
|
65
|
+
*/
|
|
66
|
+
_code: string;
|
|
67
|
+
get code(): string;
|
|
68
|
+
set code(value: string);
|
|
69
|
+
/**
|
|
70
|
+
* Async getter for the linting diagnostics of the current code
|
|
71
|
+
*/
|
|
72
|
+
lintSource(): Promise<WorkerDiagnostic[]>;
|
|
73
|
+
/**
|
|
74
|
+
* available run modes for the current code
|
|
75
|
+
*/
|
|
76
|
+
runModes: Array<RunMode>;
|
|
77
|
+
/**
|
|
78
|
+
* The global state where we are part of
|
|
79
|
+
*/
|
|
80
|
+
private papyros;
|
|
81
|
+
constructor(papyros: Papyros);
|
|
82
|
+
/**
|
|
83
|
+
* Stops the current run and resets the state of the program
|
|
84
|
+
* Regular and debug output is cleared
|
|
85
|
+
* @return {Promise<void>} Returns when the program has been reset
|
|
86
|
+
*/
|
|
87
|
+
reset(): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Start the backend to enable running code
|
|
90
|
+
*/
|
|
91
|
+
launch(): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Execute the code in the editor
|
|
94
|
+
* @param {RunMode} mode The mode to run with
|
|
95
|
+
* @return {Promise<void>} Promise of running the code
|
|
96
|
+
*/
|
|
97
|
+
start(mode?: RunMode): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Interrupt the currently running code
|
|
100
|
+
* @return {Promise<void>} Returns when the code has been interrupted
|
|
101
|
+
*/
|
|
102
|
+
stop(): Promise<void>;
|
|
103
|
+
provideInput(input: string): Promise<void>;
|
|
104
|
+
provideFiles(inlinedFiles: Record<string, string>, hrefFiles: Record<string, string>): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Show the current state of the program to the user
|
|
107
|
+
* @param {RunState} state The current state of the run
|
|
108
|
+
* @param {string} message Optional message to indicate the state
|
|
109
|
+
*/
|
|
110
|
+
setState(state: RunState, message?: string): void;
|
|
111
|
+
/**
|
|
112
|
+
* Callback to handle loading events
|
|
113
|
+
* @param {BackendEvent} e The loading event
|
|
114
|
+
*/
|
|
115
|
+
private onLoad;
|
|
116
|
+
private onStart;
|
|
117
|
+
private updateRunModes;
|
|
118
|
+
}
|