@dodona/papyros 0.1.58 → 0.1.62
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 +33 -1
- package/dist/Papyros.d.ts +1 -2
- package/dist/index.js +1 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -44,6 +44,38 @@ The following options are supported:
|
|
|
44
44
|
- standAlone: Whether to operate in stand-alone or embedded mode as described above.
|
|
45
45
|
- locale: The locale to use, currently English and Dutch translations are provided.
|
|
46
46
|
- programmingLanguage: The language to use in the CodeEditor and Backend
|
|
47
|
+
- inputMode: How the users can provide input, according to the [InputMode enum](/src/InputManager.ts)
|
|
48
|
+
|
|
49
|
+
Furthermore, you can provide fine-grained configuration in embedded mode by providing RenderOptions
|
|
50
|
+
to each main component in the application. You minimally need to specify the ID of the parent element.
|
|
51
|
+
You can also specify attributes, such as style or data, or classNames to be used.
|
|
52
|
+
The main components are the following:
|
|
53
|
+
- code -> the CodeEditor
|
|
54
|
+
- panel -> the StatusPanel in the CodeEditor
|
|
55
|
+
- input -> The field for the user input
|
|
56
|
+
- output -> The panel for output of the code
|
|
57
|
+
|
|
58
|
+
### User input
|
|
59
|
+
|
|
60
|
+
Important to note is that handling asynchronous input in a synchronous way is not straightforward.
|
|
61
|
+
This requires advanced features which are not available by default in your browser. We support two options
|
|
62
|
+
|
|
63
|
+
The most efficient and practical way is using SharedArrayBuffers, which requires the presence of certain HTTP headers.
|
|
64
|
+
The following headers must be set on resources using Papyros.
|
|
65
|
+
```json
|
|
66
|
+
'Cross-Origin-Opener-Policy': 'same-origin',
|
|
67
|
+
'Cross-Origin-Embedder-Policy': 'require-corp'
|
|
68
|
+
```
|
|
69
|
+
If you are also embedding other components (such as iframes) in those pages, you will also need to set
|
|
70
|
+
'Cross-Origin-Resource-Policy' to 'cross-origin' to make them work correctly. In order to limit the effect of this
|
|
71
|
+
change, it is advised to restrict access using the 'Access-Control-Allow-Origin'-header to prevent abuse of including code.
|
|
72
|
+
|
|
73
|
+
If you would like to use this project without enabling these HTTP headers, we provide a solution using a service worker.
|
|
74
|
+
If your application does not use a service worker yet, a default service worker is pre-built and included in the package.
|
|
75
|
+
Simply copy the file located [here](dist/inputServiceWorker.js) to a location of choice in your application where it can be served.
|
|
76
|
+
Then, before launching your instance of Papyros, make a call to configureInput with the location of the folder and the name of the file.
|
|
77
|
+
|
|
78
|
+
If you already use a service worker, simply include our functionality in your existing worker using imports. An example can be found [here](src/InputServiceWorker.ts). Afterwards, inform Papyros of this using configureInput as above.
|
|
47
79
|
|
|
48
80
|
## Documentation
|
|
49
81
|
|
|
@@ -71,4 +103,4 @@ You can view the results in your browser by visting http://localhost:8080.
|
|
|
71
103
|
|
|
72
104
|
## Try it online
|
|
73
105
|
|
|
74
|
-
Start coding immediately in your [browser](https://
|
|
106
|
+
Start coding immediately in your [browser](https://papyros.dodona.be/).
|
package/dist/Papyros.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ interface PapyrosConfig {
|
|
|
37
37
|
inputMode: InputMode;
|
|
38
38
|
}
|
|
39
39
|
interface PapyrosRenderOptions {
|
|
40
|
-
papyros
|
|
40
|
+
papyros?: RenderOptions;
|
|
41
41
|
code?: RenderOptions;
|
|
42
42
|
panel?: RenderOptions;
|
|
43
43
|
input?: RenderOptions;
|
|
@@ -48,7 +48,6 @@ export declare class Papyros {
|
|
|
48
48
|
codeState: PapyrosCodeState;
|
|
49
49
|
inputManager: InputManager;
|
|
50
50
|
outputManager: OutputManager;
|
|
51
|
-
inputURL: string;
|
|
52
51
|
constructor(programmingLanguage: ProgrammingLanguage, inputMode: InputMode);
|
|
53
52
|
get state(): PapyrosState;
|
|
54
53
|
launch(): Promise<Papyros>;
|