@dodona/papyros 3.0.1 → 4.0.0-beta.1
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 +114 -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 +330 -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 -26
- 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
package/README.md
CHANGED
|
@@ -12,113 +12,174 @@
|
|
|
12
12
|
</a>
|
|
13
13
|
</p>
|
|
14
14
|
|
|
15
|
-
Papyros is a programming scratchpad in the browser. It allows running code
|
|
16
|
-
|
|
17
|
-
By taking away obstacles between students and coding, the learning experience becomes
|
|
18
|
-
smoother and less error-prone.
|
|
15
|
+
Papyros is a programming scratchpad in the browser. It allows running code directly in your browser, no installation required.
|
|
16
|
+
Right now, the focus is on providing a great experience for Python, while also supporting JavaScript.
|
|
17
|
+
By taking away obstacles between students and coding, the learning experience becomes smoother and less error-prone.
|
|
19
18
|
|
|
20
19
|
Currently, Papyros provides support for the following programming languages:
|
|
21
20
|
- Python, powered by [Pyodide](https://pyodide.org/en/stable/)
|
|
22
21
|
- JavaScript, powered by your browser
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
---
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
- npm:
|
|
28
|
-
```shell
|
|
29
|
-
npm install @dodona/papyros
|
|
30
|
-
```
|
|
31
|
-
- yarn:
|
|
32
|
-
```shell
|
|
33
|
-
yarn add @dodona/papyros
|
|
34
|
-
```
|
|
25
|
+
## Try it Online
|
|
35
26
|
|
|
36
|
-
|
|
27
|
+
Start coding directly in your [browser](https://papyros.dodona.be/).
|
|
37
28
|
|
|
38
|
-
|
|
39
|
-
This includes extra UI elements to allow selecting a locale, a programming language, ...
|
|
29
|
+
---
|
|
40
30
|
|
|
41
|
-
|
|
42
|
-
as the user knows for what purpose Papyros is being used. For example, when used in the
|
|
43
|
-
scope of a Python exercise in Dodona, there is no need to support other programming languages.
|
|
44
|
-
The locale should also match that of the actual application.
|
|
31
|
+
## Use papyros in your project
|
|
45
32
|
|
|
46
|
-
|
|
47
|
-
Papyros instance with a `PapyrosConfig` object.
|
|
48
|
-
The following options are supported:
|
|
33
|
+
### Installation
|
|
49
34
|
|
|
50
|
-
|
|
51
|
-
- `programmingLanguage`: The [programming language](/src/ProgrammingLanguage.ts) to use in the CodeEditor and Backend.
|
|
52
|
-
- `locale`: The locale to use, currently English and Dutch translations are provided.
|
|
53
|
-
- `inputMode`: How the users can provide input, according to the [InputMode enum](/src/InputManager.ts)
|
|
54
|
-
- `example`: Optional name of the selected example, only appliccable in standAlone-mode
|
|
55
|
-
- `channelOptions`: Optional options to provide to the [sync-message](https://github.com/alexmojaki/sync-message) channel. Extra is the serviceWorkerName, which is the relative pathname to the service worker script
|
|
35
|
+
Install via npm or yarn:
|
|
56
36
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
- `outputOptions`: for the panel that displays the output of the code
|
|
37
|
+
```shell
|
|
38
|
+
npm install @dodona/papyros
|
|
39
|
+
# or
|
|
40
|
+
yarn add @dodona/papyros
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Setup input handling
|
|
65
44
|
|
|
66
|
-
|
|
45
|
+
Running interactive programs in the browser requires special handling of synchronous input.
|
|
46
|
+
Papyros supports two approaches (via [`sync-message`](https://github.com/alexmojaki/sync-message)):
|
|
67
47
|
|
|
68
|
-
|
|
69
|
-
|
|
48
|
+
#### COOP/COEP headers
|
|
49
|
+
Add the following HTTP headers to your server responses:
|
|
70
50
|
|
|
71
|
-
The most efficient and practical way is using SharedArrayBuffers, which requires the presence of certain HTTP headers.
|
|
72
|
-
The following headers must be set on resources using Papyros.
|
|
73
51
|
```yaml
|
|
74
52
|
{
|
|
75
53
|
"Cross-Origin-Opener-Policy": "same-origin",
|
|
76
54
|
"Cross-Origin-Embedder-Policy": "require-corp"
|
|
77
55
|
}
|
|
78
56
|
```
|
|
79
|
-
|
|
57
|
+
These headers are required to enable `SharedArrayBuffer`, which is the preferred way to handle synchronous input.
|
|
58
|
+
They need to be set on all assets that are loaded, including scripts, images, fonts, etc.
|
|
80
59
|
|
|
81
|
-
|
|
82
|
-
If
|
|
83
|
-
|
|
60
|
+
#### Service Worker
|
|
61
|
+
If you cannot set these headers, you can use a service worker to handle input.
|
|
62
|
+
We provide a compiled and minified version of the `InputServiceWorker` in the `dist` folder.
|
|
63
|
+
You need to serve this file from the root of your domain (i.e. `/input-sw.js`).
|
|
64
|
+
You can then register the service worker in your application before launching: `papyros.serviceWorkerName = 'input-sw.js';`.
|
|
84
65
|
|
|
85
|
-
|
|
66
|
+
---
|
|
86
67
|
|
|
87
|
-
|
|
88
|
-
- the [programming language](/src/ProgrammingLanguage.ts) of the contents (for e.g. syntax higlighting)
|
|
89
|
-
- the displayed placeholder
|
|
90
|
-
- the indentation unit
|
|
91
|
-
- the shown panel
|
|
92
|
-
- the autocompletion source
|
|
93
|
-
- the linting source
|
|
94
|
-
- the theme used to style the editor
|
|
68
|
+
## Usage
|
|
95
69
|
|
|
96
|
-
|
|
70
|
+
### Minimal setup
|
|
97
71
|
|
|
98
|
-
|
|
72
|
+
If you only want to use the state and runner logic without UI components:
|
|
99
73
|
|
|
100
|
-
|
|
74
|
+
```ts
|
|
75
|
+
import { papyros } from "@dodona/papyros/Papyros";
|
|
101
76
|
|
|
102
|
-
|
|
77
|
+
papyros.launch(); // heavy operation, loads workers and Pyodide
|
|
78
|
+
papyros.runner.code = "print(input())";
|
|
103
79
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
80
|
+
papyros.io.subscribe(
|
|
81
|
+
() => (papyros.io.awaitingInput ? papyros.io.provideInput("foo") : ""),
|
|
82
|
+
"awaitingInput"
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
await papyros.runner.start();
|
|
86
|
+
console.log(papyros.runner.io.output[0].content);
|
|
107
87
|
```
|
|
108
88
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
89
|
+
### Minimal setup with components
|
|
90
|
+
|
|
91
|
+
Papyros provides four web components for visualization.
|
|
92
|
+
Each expects a `papyros` state instance, but defaults to the global `papyros`.
|
|
93
|
+
|
|
94
|
+
```html
|
|
95
|
+
<script type="module">
|
|
96
|
+
import { papyros } from "@dodona/papyros/Papyros";
|
|
97
|
+
import "@dodona/papyros/components";
|
|
98
|
+
|
|
99
|
+
papyros.launch();
|
|
100
|
+
</script>
|
|
101
|
+
|
|
102
|
+
<p-code-runner></p-code-runner>
|
|
103
|
+
<p-debugger></p-debugger>
|
|
104
|
+
<p-input></p-input>
|
|
105
|
+
<p-output></p-output>
|
|
112
106
|
```
|
|
113
107
|
|
|
114
|
-
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Theming
|
|
111
|
+
|
|
112
|
+
Papyros uses [Material Web Components](https://github.com/material-components/material-web) for buttons, inputs, sliders, etc.
|
|
113
|
+
All styling is driven by Material color system CSS variables (`--md-sys-color-...`).
|
|
114
|
+
Generate your own theme using the [Material Theme Builder](https://material-foundation.github.io/material-theme-builder/).
|
|
115
|
+
|
|
116
|
+
* Three example themes (light + dark) are provided via `papyros.constants.themes`.
|
|
117
|
+
* A theme picker component is available out of the box.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Structure
|
|
122
|
+
|
|
123
|
+
The codebase organized into clear layers:
|
|
124
|
+
|
|
125
|
+
* `backend`: code execution functionality (runs in Web Workers)
|
|
126
|
+
* `communication`: helpers to connect frontend and backend
|
|
127
|
+
* `frontend`: all browser-side code
|
|
128
|
+
* `state`: state management (e.g. execution state, debugger, input/output)
|
|
129
|
+
* `components`: visualization of that state, as Lit web components
|
|
130
|
+
|
|
131
|
+
### Components
|
|
132
|
+
|
|
133
|
+
#### `<p-code-runner>`
|
|
134
|
+
|
|
135
|
+
A [CodeMirror 6](https://codemirror.net/6/) editor to edit, run, and debug code.
|
|
136
|
+
Additional buttons can be added via the `.buttons` slot.
|
|
137
|
+
|
|
138
|
+
#### `<p-input>`
|
|
139
|
+
|
|
140
|
+
Lets users provide input (batch or interactive), passed to `papyros.io`.
|
|
141
|
+
|
|
142
|
+
#### `<p-output>`
|
|
143
|
+
|
|
144
|
+
Visualizes program output: stdout, stderr, and images.
|
|
145
|
+
|
|
146
|
+
#### `<p-debugger>`
|
|
147
|
+
|
|
148
|
+
Displays execution traces using [`@dodona/json-tracer`](https://github.com/dodona-edu/json-tracer).
|
|
149
|
+
|
|
150
|
+
### State API
|
|
151
|
+
|
|
152
|
+
A `Papyros` instance contains multiple logical parts:
|
|
153
|
+
|
|
154
|
+
* `papyros.constants`: general settings, constants, and themes (can be overridden).
|
|
155
|
+
* `papyros.debugger`: debug frames and currently active frame.
|
|
156
|
+
* `papyros.examples`: available code examples.
|
|
157
|
+
* `papyros.i18n`: translations (extend or override as needed).
|
|
158
|
+
* `papyros.io`: input/output handling. Subscribe to `awaitingInput` to supply input when needed.
|
|
159
|
+
* `papyros.runner`: code, execution state, programming language. Run code with `papyros.runner.start()`.
|
|
160
|
+
* `papyros.test`: test code (appended to the code document).
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Development
|
|
165
|
+
|
|
115
166
|
```shell
|
|
167
|
+
# Clone the repository:
|
|
168
|
+
git clone git@github.com:dodona-edu/papyros.git
|
|
169
|
+
cd papyros
|
|
170
|
+
# Install dependencies:
|
|
171
|
+
yarn install
|
|
172
|
+
# Build the python packages:
|
|
173
|
+
yarn setup
|
|
174
|
+
# Start a local server with live reload:
|
|
116
175
|
yarn start
|
|
117
176
|
```
|
|
118
177
|
|
|
119
|
-
|
|
120
|
-
You can view the results in your browser by visting http://localhost:8080.
|
|
121
|
-
|
|
122
|
-
## Try it online
|
|
178
|
+
## Publishing
|
|
123
179
|
|
|
124
|
-
|
|
180
|
+
```shell
|
|
181
|
+
# Build as library
|
|
182
|
+
yarn build:lib
|
|
183
|
+
# Publish to npm
|
|
184
|
+
yarn publish
|
|
185
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Components.js","sourceRoot":"","sources":["../src/Components.ts"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,CAAC;AACrC,OAAO,8BAA8B,CAAC;AACtC,OAAO,kCAAkC,CAAC;AAC1C,OAAO,gCAAgC,CAAC"}
|
package/dist/Papyros.d.ts
CHANGED
|
@@ -1,117 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The language to use
|
|
20
|
-
*/
|
|
21
|
-
locale: string;
|
|
22
|
-
/**
|
|
23
|
-
* The InputMode to use
|
|
24
|
-
*/
|
|
25
|
-
inputMode: InputMode;
|
|
26
|
-
/**
|
|
27
|
-
* The selected code example
|
|
28
|
-
*/
|
|
29
|
-
example?: string;
|
|
30
|
-
/**
|
|
31
|
-
* Configuration for the input channel
|
|
32
|
-
*/
|
|
33
|
-
channelOptions?: {
|
|
34
|
-
serviceWorkerName?: string;
|
|
35
|
-
root?: string;
|
|
36
|
-
} & AtomicsChannelOptions & ServiceWorkerChannelOptions;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Options for rendering Papyros
|
|
40
|
-
*/
|
|
41
|
-
export interface PapyrosRenderOptions {
|
|
42
|
-
/**
|
|
43
|
-
* Options to render Papyros itself, only used in standAlone mode
|
|
44
|
-
*/
|
|
45
|
-
standAloneOptions?: RenderOptions;
|
|
46
|
-
/**
|
|
47
|
-
* RenderOptions for the code editor
|
|
48
|
-
*/
|
|
49
|
-
codeEditorOptions?: RenderOptions;
|
|
50
|
-
/**
|
|
51
|
-
* RenderOptions for the status panel in the editor
|
|
52
|
-
*/
|
|
53
|
-
statusPanelOptions?: RenderOptions;
|
|
54
|
-
/**
|
|
55
|
-
* RenderOptions for the input field
|
|
56
|
-
*/
|
|
57
|
-
inputOptions?: InputManagerRenderOptions;
|
|
58
|
-
/**
|
|
59
|
-
* RenderOptions for the output field
|
|
60
|
-
*/
|
|
61
|
-
outputOptions?: RenderOptions;
|
|
62
|
-
/**
|
|
63
|
-
* Whether to render in dark mode
|
|
64
|
-
*/
|
|
65
|
-
darkMode?: boolean;
|
|
66
|
-
traceOptions?: RenderOptions;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Class that manages multiple components to form a coding scratchpad
|
|
70
|
-
*/
|
|
71
|
-
export declare class Papyros extends Renderable<PapyrosRenderOptions> {
|
|
72
|
-
/**
|
|
73
|
-
* Config used to initialize Papyros
|
|
74
|
-
*/
|
|
75
|
-
private config;
|
|
76
|
-
/**
|
|
77
|
-
* Component to run code entered by the user
|
|
78
|
-
*/
|
|
79
|
-
readonly codeRunner: CodeRunner;
|
|
80
|
-
/**
|
|
81
|
-
* Construct a new Papyros instance
|
|
82
|
-
* @param {PapyrosConfig} config Properties to configure this instance
|
|
83
|
-
*/
|
|
84
|
-
constructor(config: PapyrosConfig);
|
|
85
|
-
/**
|
|
86
|
-
* @return {RunState} The current state of the user's code
|
|
87
|
-
*/
|
|
88
|
-
getState(): RunState;
|
|
1
|
+
import { State } from "@dodona/lit-state";
|
|
2
|
+
import { Debugger } from "./frontend/state/Debugger";
|
|
3
|
+
import { Runner } from "./frontend/state/Runner";
|
|
4
|
+
import { InputOutput } from "./frontend/state/InputOutput";
|
|
5
|
+
import { Constants } from "./frontend/state/Constants";
|
|
6
|
+
import { Examples } from "./frontend/state/Examples";
|
|
7
|
+
import { I18n } from "./frontend/state/I18n";
|
|
8
|
+
import { Test } from "./frontend/state/Test";
|
|
9
|
+
export declare class Papyros extends State {
|
|
10
|
+
readonly debugger: Debugger;
|
|
11
|
+
readonly runner: Runner;
|
|
12
|
+
readonly io: InputOutput;
|
|
13
|
+
readonly constants: Constants;
|
|
14
|
+
readonly examples: Examples;
|
|
15
|
+
readonly i18n: I18n;
|
|
16
|
+
readonly test: Test;
|
|
17
|
+
serviceWorkerName: string;
|
|
89
18
|
/**
|
|
90
19
|
* Launch this instance of Papyros, making it ready to run code
|
|
91
20
|
* @return {Promise<Papyros>} Promise of launching, chainable
|
|
92
21
|
*/
|
|
93
22
|
launch(): Promise<Papyros>;
|
|
94
|
-
/**
|
|
95
|
-
* Set the used programming language to the given one to allow editing and running code
|
|
96
|
-
* @param {ProgrammingLanguage} programmingLanguage The language to use
|
|
97
|
-
*/
|
|
98
|
-
setProgrammingLanguage(programmingLanguage: ProgrammingLanguage): Promise<void>;
|
|
99
|
-
/**
|
|
100
|
-
* @param {string} locale The locale to use
|
|
101
|
-
*/
|
|
102
|
-
setLocale(locale: string): void;
|
|
103
|
-
/**
|
|
104
|
-
* @param {boolean} darkMode Whether to use dark mode
|
|
105
|
-
*/
|
|
106
|
-
setDarkMode(darkMode: boolean): void;
|
|
107
|
-
/**
|
|
108
|
-
* @param {string} code The code to use in the editor
|
|
109
|
-
*/
|
|
110
|
-
setCode(code: string): void;
|
|
111
|
-
/**
|
|
112
|
-
* @return {string} The currently written code
|
|
113
|
-
*/
|
|
114
|
-
getCode(): string;
|
|
115
23
|
/**
|
|
116
24
|
* Configure how user input is handled within Papyros
|
|
117
25
|
* By default, we will try to use SharedArrayBuffers
|
|
@@ -120,22 +28,5 @@ export declare class Papyros extends Renderable<PapyrosRenderOptions> {
|
|
|
120
28
|
* @return {Promise<boolean>} Promise of configuring input
|
|
121
29
|
*/
|
|
122
30
|
private configureInput;
|
|
123
|
-
protected _render(renderOptions: PapyrosRenderOptions): void;
|
|
124
|
-
/**
|
|
125
|
-
* Add a button to the status panel within Papyros
|
|
126
|
-
* @param {ButtonOptions} options Options to render the button with
|
|
127
|
-
* @param {function} onClick Listener for click events on the button
|
|
128
|
-
*/
|
|
129
|
-
addButton(options: ButtonOptions, onClick: () => void): void;
|
|
130
|
-
/**
|
|
131
|
-
* @param {ProgrammingLanguage} language The language to check
|
|
132
|
-
* @return {boolean} Whether Papyros supports this language by default
|
|
133
|
-
*/
|
|
134
|
-
static supportsProgrammingLanguage(language: string): boolean;
|
|
135
|
-
/**
|
|
136
|
-
* Convert a string to a ProgrammingLanguage
|
|
137
|
-
* @param {string} language The language to convert
|
|
138
|
-
* @return {ProgrammingLanguage | undefined} The ProgrammingLanguage, or undefined if not supported
|
|
139
|
-
*/
|
|
140
|
-
static toProgrammingLanguage(language: string): ProgrammingLanguage | undefined;
|
|
141
31
|
}
|
|
32
|
+
export declare const papyros: Papyros;
|