@dodona/papyros 0.1.32-action → 0.1.33

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 CHANGED
@@ -12,29 +12,22 @@
12
12
  </a>
13
13
  </p>
14
14
 
15
- Papyros is a programming scratchpad in the browser. It allows running arbitrary
16
- in various programming languages directly in your browser, no installation required.
15
+ Papyros is a programming scratchpad in the browser. It allows running code
16
+ directly in your browser, no installation required. Right now, the focus in on providing a great experience for Python, while also supporting JavaScript.
17
17
  By taking away obstacles between students and coding, the learning experience becomes
18
- smoother and less error-prone.
19
-
20
- Papyros aims to be:
21
-
22
- - **Easy to use** by having minimal installation instructions and an intuitive user interface
23
- - **Flexible** to support many programming languages
18
+ smoother and less error-prone.
24
19
 
25
20
  Currently, Papyros provides support for the following programming languages:
26
21
  - Python, powered by [Pyodide](https://pyodide.org/en/stable/)
27
22
  - JavaScript, powered by your browser
28
23
 
29
- ## Installation
24
+ ## Using Papyros in your own project
30
25
 
31
26
  You can install Papyros on your system using npm:
32
27
  ```shell
33
28
  npm install -g @dodona/papyros
34
29
  ```
35
30
 
36
- ## Usage
37
-
38
31
  Papyros currently supports two modes of operation: stand-alone and embedded.
39
32
 
40
33
  In stand-alone mode, Papyros runs as a full application in the browser.
@@ -10,5 +10,6 @@ export declare class CodeEditor {
10
10
  setLanguage(language: ProgrammingLanguage, editorPlaceHolder: string): void;
11
11
  setIndentLength(indentLength: number): void;
12
12
  getCode(): string;
13
+ setCode(code: string): void;
13
14
  focus(): void;
14
15
  }
@@ -12,6 +12,7 @@ export declare const SEND_INPUT_BTN_ID = "send-input-btn";
12
12
  export declare const SWITCH_INPUT_MODE_A_ID = "switch-input-mode";
13
13
  export declare const PROGRAMMING_LANGUAGE_SELECT_ID = "programming-language-select";
14
14
  export declare const DEFAULT_PROGRAMMING_LANGUAGE = ProgrammingLanguage.Python;
15
+ export declare const EXAMPLE_SELECT_ID = "example-select";
15
16
  export declare const LOCALE_SELECT_ID = "locale-select";
16
17
  export declare const DEFAULT_LOCALE = "nl";
17
18
  export declare const INPUT_RELATIVE_URL = "/__papyros_input";
@@ -0,0 +1,19 @@
1
+ import { PapyrosEvent } from "./PapyrosEvent";
2
+ export interface FriendlyError {
3
+ name: string;
4
+ traceback?: string;
5
+ info?: string;
6
+ why?: string;
7
+ what?: string;
8
+ where?: string;
9
+ }
10
+ export declare class OutputManager {
11
+ outputArea: HTMLElement;
12
+ constructor(outputWrapperId: string);
13
+ renderNextElement(html: string): void;
14
+ spanify(text: string, ignoreEmpty?: boolean): string;
15
+ showOutput(output: PapyrosEvent): void;
16
+ showError(error: FriendlyError | string): void;
17
+ onRunStart(): void;
18
+ onRunEnd(): void;
19
+ }
package/dist/Papyros.d.ts CHANGED
@@ -6,6 +6,7 @@ import { InputManager, InputMode } from "./InputManager";
6
6
  import { PapyrosEvent } from "./PapyrosEvent";
7
7
  import { ProgrammingLanguage } from "./ProgrammingLanguage";
8
8
  import { StatusPanel } from "./StatusPanel";
9
+ import { OutputManager } from "./OutputManager";
9
10
  declare enum PapyrosState {
10
11
  Loading = "loading",
11
12
  Running = "running",
@@ -38,10 +39,12 @@ export declare class Papyros {
38
39
  stateManager: PapyrosStateManager;
39
40
  codeState: PapyrosCodeState;
40
41
  inputManager: InputManager;
42
+ outputManager: OutputManager;
41
43
  constructor(programmingLanguage: ProgrammingLanguage, inputMode: InputMode);
42
44
  get state(): PapyrosState;
43
45
  launch(): Promise<Papyros>;
44
46
  setProgrammingLanguage(programmingLanguage: ProgrammingLanguage): Promise<void>;
47
+ setCode(code: string): void;
45
48
  startBackend(): Promise<void>;
46
49
  static fromElement(parent: HTMLElement, config: PapyrosConfig): Promise<Papyros>;
47
50
  onError(e: PapyrosEvent): void;
@@ -2,4 +2,5 @@ export interface PapyrosEvent {
2
2
  type: "input" | "output" | "script" | "success" | "error";
3
3
  data: string;
4
4
  runId: number;
5
+ content?: string;
5
6
  }
@@ -1,7 +1,4 @@
1
1
  export declare class StatusPanel {
2
- onRun: () => void;
3
- constructor(onRun: () => void);
4
- initialize(): void;
5
2
  get statusSpinner(): HTMLElement;
6
3
  get statusText(): HTMLElement;
7
4
  showSpinner(show: boolean): void;
@@ -0,0 +1,6 @@
1
+ import { ProgrammingLanguage } from "../ProgrammingLanguage";
2
+ export declare function getExamples(language: ProgrammingLanguage): {
3
+ [key: string]: string;
4
+ };
5
+ export declare function getExampleNames(language: ProgrammingLanguage): Array<string>;
6
+ export declare function getCodeForExample(language: ProgrammingLanguage, name: string): string;
@@ -0,0 +1,5 @@
1
+ export declare const JAVASCRIPT_EXAMPLES: {
2
+ "Hello world!": string;
3
+ Input: string;
4
+ Fibonacci: string;
5
+ };
@@ -0,0 +1,11 @@
1
+ export declare const PYTHON_EXAMPLES: {
2
+ "Hello, World!": string;
3
+ Input: string;
4
+ Fibonacci: string;
5
+ Doctests: string;
6
+ Async: string;
7
+ Erroneous: string;
8
+ Unicode: string;
9
+ Files: string;
10
+ Matplotlib: string;
11
+ };