@dodona/papyros 0.1.702 → 0.1.923-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 +67 -13
- package/dist/BackendEvent.d.ts +33 -0
- package/dist/BackendManager.d.ts +55 -3
- package/dist/CodeEditor.d.ts +96 -2
- package/dist/CodeRunner.d.ts +102 -0
- package/dist/Constants.d.ts +17 -16
- package/dist/InputManager.d.ts +21 -21
- package/dist/{library.d.ts → Library.d.ts} +4 -4
- package/dist/OutputManager.d.ts +60 -8
- package/dist/Papyros.d.ts +112 -47
- package/dist/ProgrammingLanguage.d.ts +3 -0
- package/dist/RunListener.d.ts +13 -0
- package/dist/examples/PythonExamples.d.ts +1 -0
- 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/util/HTMLShapes.d.ts +13 -0
- package/dist/util/Logging.d.ts +9 -0
- package/dist/util/Util.d.ts +88 -2
- package/dist/workers/input/InputWorker.d.ts +18 -2
- package/package.json +14 -10
- package/dist/PapyrosEvent.d.ts +0 -6
- package/dist/StatusPanel.d.ts +0 -17
- package/dist/index.js +0 -2
- package/dist/index.js.LICENSE.txt +0 -7
- package/dist/inputServiceWorker.js +0 -1
- package/dist/workers/python/Pyodide.d.ts +0 -9
package/dist/Papyros.d.ts
CHANGED
|
@@ -1,70 +1,135 @@
|
|
|
1
1
|
import "./Papyros.css";
|
|
2
|
-
import {
|
|
3
|
-
import { Backend } from "./Backend";
|
|
4
|
-
import { CodeEditor } from "./CodeEditor";
|
|
5
|
-
import { InputManager, InputMode } from "./InputManager";
|
|
6
|
-
import { PapyrosEvent } from "./PapyrosEvent";
|
|
2
|
+
import { InputMode } from "./InputManager";
|
|
7
3
|
import { ProgrammingLanguage } from "./ProgrammingLanguage";
|
|
8
4
|
import { RenderOptions, ButtonOptions } from "./util/Util";
|
|
9
|
-
import {
|
|
5
|
+
import { RunState, CodeRunner } from "./CodeRunner";
|
|
10
6
|
import { OutputManager } from "./OutputManager";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
AwaitingInput = "awaiting_input",
|
|
15
|
-
Stopping = "stopping",
|
|
16
|
-
Ready = "ready"
|
|
17
|
-
}
|
|
18
|
-
declare class PapyrosStateManager {
|
|
19
|
-
state: PapyrosState;
|
|
20
|
-
statusPanel: StatusPanel;
|
|
21
|
-
get runButton(): HTMLButtonElement;
|
|
22
|
-
get stopButton(): HTMLButtonElement;
|
|
23
|
-
constructor(statusPanel: StatusPanel, onRunClicked: () => void, onStopClicked: () => void);
|
|
24
|
-
setState(state: PapyrosState, message?: string): void;
|
|
25
|
-
render(options: RenderOptions): HTMLElement;
|
|
26
|
-
}
|
|
27
|
-
interface PapyrosCodeState {
|
|
28
|
-
programmingLanguage: ProgrammingLanguage;
|
|
29
|
-
editor: CodeEditor;
|
|
30
|
-
backend: Remote<Backend>;
|
|
31
|
-
runId: number;
|
|
32
|
-
}
|
|
7
|
+
/**
|
|
8
|
+
* Configuration options for this instance of Papyros
|
|
9
|
+
*/
|
|
33
10
|
interface PapyrosConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Whether Papyros is run in standAlone mode or embedded in an application
|
|
13
|
+
*/
|
|
34
14
|
standAlone: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The programming language to use
|
|
17
|
+
*/
|
|
35
18
|
programmingLanguage: ProgrammingLanguage;
|
|
19
|
+
/**
|
|
20
|
+
* The language to use
|
|
21
|
+
*/
|
|
36
22
|
locale: string;
|
|
23
|
+
/**
|
|
24
|
+
* The InputMode to use
|
|
25
|
+
*/
|
|
37
26
|
inputMode: InputMode;
|
|
38
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Options for rendering Papyros
|
|
30
|
+
*/
|
|
39
31
|
interface PapyrosRenderOptions {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Options to render Papyros itself, only used in standAlone mode
|
|
34
|
+
*/
|
|
35
|
+
standAloneOptions?: RenderOptions;
|
|
36
|
+
/**
|
|
37
|
+
* RenderOptions for the code editor
|
|
38
|
+
*/
|
|
39
|
+
codeEditorOptions?: RenderOptions;
|
|
40
|
+
/**
|
|
41
|
+
* RenderOptions for the status panel in the editor
|
|
42
|
+
*/
|
|
43
|
+
statusPanelOptions?: RenderOptions;
|
|
44
|
+
/**
|
|
45
|
+
* RenderOptions for the input field
|
|
46
|
+
*/
|
|
47
|
+
inputOptions?: RenderOptions;
|
|
48
|
+
/**
|
|
49
|
+
* RenderOptions for the output field
|
|
50
|
+
*/
|
|
51
|
+
outputOptions?: RenderOptions;
|
|
45
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Class that manages multiple components to form a coding scratchpad
|
|
55
|
+
*/
|
|
46
56
|
export declare class Papyros {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Config used to initialize Papyros
|
|
59
|
+
*/
|
|
60
|
+
config: PapyrosConfig;
|
|
61
|
+
/**
|
|
62
|
+
* Component to run code entered by the user
|
|
63
|
+
*/
|
|
64
|
+
codeRunner: CodeRunner;
|
|
65
|
+
/**
|
|
66
|
+
* Component to handle output generated by the user's code
|
|
67
|
+
*/
|
|
50
68
|
outputManager: OutputManager;
|
|
51
|
-
|
|
52
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Whether this instance has been launched
|
|
71
|
+
*/
|
|
72
|
+
private launched;
|
|
73
|
+
/**
|
|
74
|
+
* Construct a new Papyros instance
|
|
75
|
+
* @param {PapyrosConfig} config Properties to configure this instance
|
|
76
|
+
*/
|
|
77
|
+
constructor(config: PapyrosConfig);
|
|
78
|
+
/**
|
|
79
|
+
* @return {RunState} The current state of the user's code
|
|
80
|
+
*/
|
|
81
|
+
getState(): RunState;
|
|
82
|
+
/**
|
|
83
|
+
* Launch this instance of Papyros, making it ready to run code
|
|
84
|
+
* @return {Promise<Papyros>} Promise of launching, chainable
|
|
85
|
+
*/
|
|
53
86
|
launch(): Promise<Papyros>;
|
|
87
|
+
/**
|
|
88
|
+
* Set the used programming language to the given one to allow editing and running code
|
|
89
|
+
* @param {ProgrammingLanguage} programmingLanguage The language to use
|
|
90
|
+
*/
|
|
54
91
|
setProgrammingLanguage(programmingLanguage: ProgrammingLanguage): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* @param {string} code The code to use in the editor
|
|
94
|
+
*/
|
|
55
95
|
setCode(code: string): void;
|
|
96
|
+
/**
|
|
97
|
+
* @return {string} The currently written code
|
|
98
|
+
*/
|
|
56
99
|
getCode(): string;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Configure how user input is handled within Papyros
|
|
102
|
+
* By default, we will try to use SharedArrayBuffers
|
|
103
|
+
* If this option is not available, the optional arguments become relevant
|
|
104
|
+
* They are needed to register a service worker to handle communication between threads
|
|
105
|
+
* @param {string} serviceWorkerRoot URL for the directory where the service worker lives
|
|
106
|
+
* @param {string} serviceWorkerName The name of the file containing the script
|
|
107
|
+
* @param {boolean} allowReload Whether we are allowed to force a reload of the page
|
|
108
|
+
* This allows using SharedArrayBuffers without configuring the HTTP headers yourself
|
|
109
|
+
* @return {Promise<boolean>} Promise of configuring input
|
|
110
|
+
*/
|
|
111
|
+
configureInput(serviceWorkerRoot?: string, serviceWorkerName?: string): Promise<boolean>;
|
|
112
|
+
/**
|
|
113
|
+
* Render Papyros with the given options
|
|
114
|
+
* @param {PapyrosRenderOptions} renderOptions Options to use
|
|
115
|
+
*/
|
|
116
|
+
render(renderOptions: PapyrosRenderOptions): void;
|
|
117
|
+
/**
|
|
118
|
+
* Add a button to the status panel within Papyros
|
|
119
|
+
* @param {ButtonOptions} options Options to render the button with
|
|
120
|
+
* @param {function} onClick Listener for click events on the button
|
|
121
|
+
*/
|
|
66
122
|
addButton(options: ButtonOptions, onClick: () => void): void;
|
|
123
|
+
/**
|
|
124
|
+
* @param {ProgrammingLanguage} language The language to check
|
|
125
|
+
* @return {boolean} Whether Papyros supports this language by default
|
|
126
|
+
*/
|
|
67
127
|
static supportsProgrammingLanguage(language: string): boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Convert a string to a ProgrammingLanguage
|
|
130
|
+
* @param {string} language The language to convert
|
|
131
|
+
* @return {ProgrammingLanguage | undefined} The ProgrammingLanguage, or undefined if not supported
|
|
132
|
+
*/
|
|
68
133
|
static toProgrammingLanguage(language: string): ProgrammingLanguage | undefined;
|
|
69
134
|
}
|
|
70
135
|
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for components that maintain state based on runs of code
|
|
3
|
+
*/
|
|
4
|
+
export interface RunListener {
|
|
5
|
+
/**
|
|
6
|
+
* Inform this listener that a new run started
|
|
7
|
+
*/
|
|
8
|
+
onRunStart(): void;
|
|
9
|
+
/**
|
|
10
|
+
* Inform this listener that the run ended
|
|
11
|
+
*/
|
|
12
|
+
onRunEnd(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { InputMode } from "../InputManager";
|
|
2
|
+
import { RenderOptions } from "../util/Util";
|
|
3
|
+
import { UserInputHandler } from "./UserInputHandler";
|
|
4
|
+
export declare class BatchInputHandler extends UserInputHandler {
|
|
5
|
+
/**
|
|
6
|
+
* The index of the next line in lines to send
|
|
7
|
+
*/
|
|
8
|
+
private lineNr;
|
|
9
|
+
/**
|
|
10
|
+
* The previous input of the user
|
|
11
|
+
* Is restored upon switching back to InputMode.Batch
|
|
12
|
+
*/
|
|
13
|
+
private previousInput;
|
|
14
|
+
/**
|
|
15
|
+
* Construct a new BatchInputHandler
|
|
16
|
+
* @param {function()} inputCallback Callback for when the user has entered a value
|
|
17
|
+
*/
|
|
18
|
+
constructor(inputCallback: () => void);
|
|
19
|
+
onToggle(active: boolean): void;
|
|
20
|
+
getInputMode(): InputMode;
|
|
21
|
+
/**
|
|
22
|
+
* Retrieve the lines of input that the user has given so far
|
|
23
|
+
* @return {Array<string>} The entered lines
|
|
24
|
+
*/
|
|
25
|
+
protected get lines(): Array<string>;
|
|
26
|
+
hasNext(): boolean;
|
|
27
|
+
next(): string;
|
|
28
|
+
onRunStart(): void;
|
|
29
|
+
onRunEnd(): void;
|
|
30
|
+
render(options: RenderOptions): HTMLElement;
|
|
31
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { InputMode } from "../InputManager";
|
|
2
|
+
import { RenderOptions } from "../util/Util";
|
|
3
|
+
import { UserInputHandler } from "./UserInputHandler";
|
|
4
|
+
/**
|
|
5
|
+
* Input handler that takes input from the user in an interactive fashion
|
|
6
|
+
*/
|
|
7
|
+
export declare class InteractiveInputHandler extends UserInputHandler {
|
|
8
|
+
/**
|
|
9
|
+
* Retrieve the button that users can click to send their input
|
|
10
|
+
*/
|
|
11
|
+
get sendButton(): HTMLButtonElement;
|
|
12
|
+
getInputMode(): InputMode;
|
|
13
|
+
hasNext(): boolean;
|
|
14
|
+
next(): string;
|
|
15
|
+
waitWithPrompt(waiting: boolean, prompt?: string): void;
|
|
16
|
+
onToggle(): void;
|
|
17
|
+
onRunStart(): void;
|
|
18
|
+
onRunEnd(): void;
|
|
19
|
+
render(options: RenderOptions): HTMLElement;
|
|
20
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { InputMode } from "../InputManager";
|
|
2
|
+
import { RenderOptions } from "../util/Util";
|
|
3
|
+
/**
|
|
4
|
+
* Base class for components that handle input from the user
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class UserInputHandler {
|
|
7
|
+
/**
|
|
8
|
+
* Whether we are waiting for the user to input data
|
|
9
|
+
*/
|
|
10
|
+
protected waiting: boolean;
|
|
11
|
+
protected inputCallback: () => void;
|
|
12
|
+
/**
|
|
13
|
+
* Construct a new UserInputHandler
|
|
14
|
+
* @param {function()} inputCallback Callback for when the user has entered a value
|
|
15
|
+
*/
|
|
16
|
+
constructor(inputCallback: () => void);
|
|
17
|
+
/**
|
|
18
|
+
* Whether this handler has input ready
|
|
19
|
+
*/
|
|
20
|
+
abstract hasNext(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Consume and return the next input value
|
|
23
|
+
*
|
|
24
|
+
* Assumes hasNext() has been called and returned true,
|
|
25
|
+
* otherwise behaviour can produce incorrect results
|
|
26
|
+
* @return {string} The next value
|
|
27
|
+
*/
|
|
28
|
+
abstract next(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Render this UserInputHandler with the given options
|
|
31
|
+
* @param {RenderOptions} options The options to use while rendering
|
|
32
|
+
* @return {HTMLElement} The parent with the new content
|
|
33
|
+
*/
|
|
34
|
+
abstract render(options: RenderOptions): HTMLElement;
|
|
35
|
+
abstract onRunStart(): void;
|
|
36
|
+
abstract onRunEnd(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Retrieve the InputMode corresponding to this handler
|
|
39
|
+
* @return {InputMode} The InputMode enum value
|
|
40
|
+
*/
|
|
41
|
+
abstract getInputMode(): InputMode;
|
|
42
|
+
/**
|
|
43
|
+
* Enable or disable this UserInputHandler
|
|
44
|
+
* @param {boolean} active Whether this component is active
|
|
45
|
+
*/
|
|
46
|
+
abstract onToggle(active: boolean): void;
|
|
47
|
+
/**
|
|
48
|
+
* Retrieve the HTMLInputElement for this InputHandler
|
|
49
|
+
*/
|
|
50
|
+
get inputArea(): HTMLInputElement;
|
|
51
|
+
/**
|
|
52
|
+
* Wait for input of the user for a certain prompt
|
|
53
|
+
* @param {boolean} waiting Whether we are waiting for input
|
|
54
|
+
* @param {string} prompt Optional message to display if waiting
|
|
55
|
+
*/
|
|
56
|
+
waitWithPrompt(waiting: boolean, prompt?: string): void;
|
|
57
|
+
/**
|
|
58
|
+
* Helper method to reset internal state
|
|
59
|
+
*/
|
|
60
|
+
protected reset(): void;
|
|
61
|
+
}
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Draw a circle using an HTML svg element
|
|
3
|
+
* @param {string} id HTML id for this element
|
|
4
|
+
* @param {string} color The color of the circle
|
|
5
|
+
* @return {string} A string representation of the circle
|
|
6
|
+
*/
|
|
1
7
|
export declare const svgCircle: (id: string, color: string) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Wrap text (best a single character) in a circle to provide information to the user
|
|
10
|
+
* @param {string} content The symbol in the circle, e.g. ? of !
|
|
11
|
+
* @param {string} title The information to display when hovering over the element
|
|
12
|
+
* @param {string} color The color of the circle and the symbol
|
|
13
|
+
* @return {string} A string representation of the circle with content
|
|
14
|
+
*/
|
|
2
15
|
export declare const inCircle: (content: string, title: string, color: string) => string;
|
package/dist/util/Logging.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum representing the importance of a log message
|
|
3
|
+
* This is helpful for debugging while allowing filtering in production
|
|
4
|
+
*/
|
|
1
5
|
export declare enum LogType {
|
|
2
6
|
Debug = 0,
|
|
3
7
|
Error = 1,
|
|
4
8
|
Important = 2
|
|
5
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Helper method to log useful information at runtime
|
|
12
|
+
* @param {LogType} logType The importance of this log message
|
|
13
|
+
* @param {any[]} args The data to log
|
|
14
|
+
*/
|
|
6
15
|
export declare function papyrosLog(logType: LogType, ...args: any[]): void;
|
package/dist/util/Util.d.ts
CHANGED
|
@@ -1,21 +1,107 @@
|
|
|
1
1
|
import I18n from "i18n-js";
|
|
2
2
|
export declare const t: typeof I18n.t;
|
|
3
|
+
/**
|
|
4
|
+
* Add the translations for Papyros to the I18n instance
|
|
5
|
+
*/
|
|
3
6
|
export declare function loadTranslations(): void;
|
|
4
7
|
export declare function getLocales(): Array<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Constructs the options for use within an HTML select element
|
|
10
|
+
* @param {Array<T>} options All options to display in the list
|
|
11
|
+
* @param {function(T):string} optionText Function to convert the elements to a string
|
|
12
|
+
* @param {T} selected The initially selected element in the list, if any
|
|
13
|
+
* @return {string} The string representation of the select options
|
|
14
|
+
*/
|
|
5
15
|
export declare function getSelectOptions<T>(options: Array<T>, optionText: (option: T) => string, selected?: T): string;
|
|
16
|
+
/**
|
|
17
|
+
* Constructs an HTML select element
|
|
18
|
+
* @param {string} selectId The HTML id for the element
|
|
19
|
+
* @param {Array<T>} options to display in the list
|
|
20
|
+
* @param {function(T):string} optionText to convert elements to a string
|
|
21
|
+
* @param {T} selected The initially selected element in the list, if any
|
|
22
|
+
* @param {string} labelText Optional text to display in a label
|
|
23
|
+
* @return {string} The string representation of the select element
|
|
24
|
+
*/
|
|
6
25
|
export declare function renderSelect<T>(selectId: string, options: Array<T>, optionText: (option: T) => string, selected?: T, labelText?: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Interface for options to use while rendering a button element
|
|
28
|
+
*/
|
|
7
29
|
export interface ButtonOptions {
|
|
30
|
+
/**
|
|
31
|
+
* The HTML id of the button
|
|
32
|
+
*/
|
|
8
33
|
id: string;
|
|
34
|
+
/**
|
|
35
|
+
* The text to display in the button, can also be HTML
|
|
36
|
+
*/
|
|
9
37
|
buttonText: string;
|
|
38
|
+
/**
|
|
39
|
+
* Optional classes to apply to the button
|
|
40
|
+
*/
|
|
10
41
|
extraClasses?: string;
|
|
11
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Construct a HTML button string from the given options
|
|
45
|
+
* @param {ButtonOptions} options The options for the button
|
|
46
|
+
* @return {string} HTML string for the button
|
|
47
|
+
*/
|
|
12
48
|
export declare function renderButton(options: ButtonOptions): string;
|
|
13
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Helper type to access a HTML element, either via its id or the element itself
|
|
51
|
+
*/
|
|
52
|
+
declare type ElementIdentifier = string | HTMLElement;
|
|
53
|
+
/**
|
|
54
|
+
* Add a listener to an HTML element for an event on an attribute
|
|
55
|
+
* Element attributes tend to be strings, but string Enums can also be used
|
|
56
|
+
* by using the type-parameter T
|
|
57
|
+
* @param {ElementIdentifier} elementId Identifier for the element
|
|
58
|
+
* @param {function(T)} onEvent The listener for the event
|
|
59
|
+
* @param {string} eventType The type of the event
|
|
60
|
+
* @param {string} attribute The attribute affected by the event
|
|
61
|
+
*/
|
|
62
|
+
export declare function addListener<T extends string>(elementId: ElementIdentifier, onEvent: (e: T) => void, eventType?: string, attribute?: string): void;
|
|
63
|
+
/**
|
|
64
|
+
* Unset the selected item of a select element to prevent a default selection
|
|
65
|
+
* @param {ElementIdentifier} selectId Identifier for the select element
|
|
66
|
+
*/
|
|
14
67
|
export declare function removeSelection(selectId: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* Useful options for rendering an element
|
|
70
|
+
*/
|
|
15
71
|
export interface RenderOptions {
|
|
72
|
+
/**
|
|
73
|
+
* String identifier for the parent in which the element will be rendered
|
|
74
|
+
*/
|
|
16
75
|
parentElementId: string;
|
|
76
|
+
/**
|
|
77
|
+
* Names of HTML classes to be added to the element, separated by 1 space
|
|
78
|
+
*/
|
|
17
79
|
classNames?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Extra attributes to add to the element, such as style or data
|
|
82
|
+
*/
|
|
18
83
|
attributes?: Map<string, string>;
|
|
19
84
|
}
|
|
20
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Resolve an ElementIdentifier to the corresponding HTLMElement
|
|
87
|
+
* @param {ElementIdentifier} elementId The identifier for the element
|
|
88
|
+
* @return {T} The corresponding element
|
|
89
|
+
*/
|
|
90
|
+
export declare function getElement<T extends HTMLElement>(elementId: ElementIdentifier): T;
|
|
91
|
+
/**
|
|
92
|
+
* Renders an element with the given options
|
|
93
|
+
* @param {RenderOptions} options Options to be used while rendering
|
|
94
|
+
* @param {string | HTMLElement} content What to fill the parent with.
|
|
95
|
+
* If the content is a string, it should be properly formatted HTML
|
|
96
|
+
* @return {HTMLElement} The parent with the new child
|
|
97
|
+
*/
|
|
21
98
|
export declare function renderWithOptions(options: RenderOptions, content: string | HTMLElement): HTMLElement;
|
|
99
|
+
/**
|
|
100
|
+
* Parse the data contained within a PapyrosEvent using its contentType
|
|
101
|
+
* Supported content types are: text/plain, text/json, img/png;base64
|
|
102
|
+
* @param {string} data The data to parse
|
|
103
|
+
* @param {string} contentType The content type of the data
|
|
104
|
+
* @return {any} The parsed data
|
|
105
|
+
*/
|
|
106
|
+
export declare function parseData(data: string, contentType?: string): any;
|
|
107
|
+
export {};
|
|
@@ -1,6 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class that is used in a service worker to allow synchronous communication
|
|
3
|
+
* between threads. This is achieved in two different ways.
|
|
4
|
+
* Responses can be modified by attaching headers allowing the use of shared memory.
|
|
5
|
+
* Requests to certain endpoints can be used with synchronous requests
|
|
6
|
+
* to achieve the same goal.
|
|
7
|
+
*/
|
|
1
8
|
export declare class InputWorker {
|
|
2
|
-
hostName
|
|
3
|
-
syncMessageListener
|
|
9
|
+
private hostName;
|
|
10
|
+
private syncMessageListener;
|
|
11
|
+
/**
|
|
12
|
+
* Create a worker for a specific domain
|
|
13
|
+
* @param {string} hostName The name of the host domain
|
|
14
|
+
*/
|
|
4
15
|
constructor(hostName: string);
|
|
16
|
+
/**
|
|
17
|
+
* Process and potentially handle a fetch request from the application
|
|
18
|
+
* @param {FetchEvent} event The event denoting a request to a url
|
|
19
|
+
* @return {boolean} Whether the event was handled
|
|
20
|
+
*/
|
|
5
21
|
handleInputRequest(event: FetchEvent): Promise<boolean>;
|
|
6
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dodona/papyros",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.923-tar",
|
|
4
4
|
"private": false,
|
|
5
5
|
"homepage": ".",
|
|
6
6
|
"devDependencies": {
|
|
@@ -31,9 +31,10 @@
|
|
|
31
31
|
"ts-jest": "^27.0.7",
|
|
32
32
|
"ts-loader": "^9.2.6",
|
|
33
33
|
"typescript": "^4.1.2",
|
|
34
|
-
"
|
|
35
|
-
"webpack
|
|
36
|
-
"webpack-
|
|
34
|
+
"url-loader": "^4.1.1",
|
|
35
|
+
"webpack": "^5.70.0",
|
|
36
|
+
"webpack-cli": "^4.9.2",
|
|
37
|
+
"webpack-dev-server": "^4.7.4",
|
|
37
38
|
"worker-loader": "^3.0.8"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
@@ -51,14 +52,17 @@
|
|
|
51
52
|
"@codemirror/search": "^0.19.3",
|
|
52
53
|
"@codemirror/state": "^0.19.6",
|
|
53
54
|
"comlink": "^4.3.1",
|
|
55
|
+
"comsync": "^0.0.7",
|
|
54
56
|
"escape-html": "^1.0.3",
|
|
55
57
|
"i18n-js": "^3.8.0",
|
|
56
|
-
"
|
|
58
|
+
"pyodide-worker-runner": "^0.0.8",
|
|
59
|
+
"sync-message": "^0.0.9"
|
|
57
60
|
},
|
|
58
61
|
"scripts": {
|
|
59
|
-
"start": "webpack serve --mode development",
|
|
60
|
-
"
|
|
61
|
-
"build:app": "
|
|
62
|
+
"start": "yarn setup && webpack serve --mode development",
|
|
63
|
+
"setup": "bash scripts/setup.sh",
|
|
64
|
+
"build:app": "bash scripts/build_package.sh development",
|
|
65
|
+
"build:library": "bash scripts/build_package.sh production",
|
|
62
66
|
"test": "echo No tests defined yet",
|
|
63
67
|
"lint": "eslint --ext '.js' --ext '.ts' src",
|
|
64
68
|
"validate:translations": "node scripts/ValidateTranslations.js"
|
|
@@ -82,6 +86,6 @@
|
|
|
82
86
|
"bugs": {
|
|
83
87
|
"url": "https://github.com/dodona-edu/papyros/issues"
|
|
84
88
|
},
|
|
85
|
-
"main": "./dist/
|
|
86
|
-
"types": "./dist/
|
|
89
|
+
"main": "./dist/Library.js",
|
|
90
|
+
"types": "./dist/Library.d.ts"
|
|
87
91
|
}
|
package/dist/PapyrosEvent.d.ts
DELETED
package/dist/StatusPanel.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ButtonOptions, RenderOptions } from "./util/Util";
|
|
2
|
-
interface DynamicButton {
|
|
3
|
-
id: string;
|
|
4
|
-
buttonHTML: string;
|
|
5
|
-
onClick: () => void;
|
|
6
|
-
}
|
|
7
|
-
export declare class StatusPanel {
|
|
8
|
-
buttons: Array<DynamicButton>;
|
|
9
|
-
constructor();
|
|
10
|
-
addButton(options: ButtonOptions, onClick: () => void): void;
|
|
11
|
-
get statusSpinner(): HTMLElement;
|
|
12
|
-
get statusText(): HTMLElement;
|
|
13
|
-
showSpinner(show: boolean): void;
|
|
14
|
-
setStatus(status: string): void;
|
|
15
|
-
render(options: RenderOptions): HTMLElement;
|
|
16
|
-
}
|
|
17
|
-
export {};
|