@dodona/papyros 0.1.91-tar → 0.1.94

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 CHANGED
@@ -34,25 +34,19 @@ export interface WorkerAutocompleteContext {
34
34
  text: string;
35
35
  } | null;
36
36
  }
37
- export declare abstract class Backend {
38
- protected syncExtras: SyncExtras;
37
+ export declare abstract class Backend<Extras extends SyncExtras = SyncExtras> {
38
+ protected extras: Extras;
39
39
  protected onEvent: (e: BackendEvent) => any;
40
40
  /**
41
- * Constructor is limited as it is meant to be used as a WebWorker
42
- * These are then exposed via Comlink. Proper initialization occurs
43
- * in the launch method when the worker is started
44
- * @param {Array<string>} syncMethods The methods to expose
41
+ * Constructor is limited as it is meant to be used as a WebWorker
42
+ * Proper initialization occurs in the launch method when the worker is started
43
+ * Synchronously exposing methods should be done here
45
44
  */
46
- constructor(syncMethods?: string[]);
45
+ constructor();
47
46
  /**
48
47
  * @return {any} The function to expose methods for Comsync to allow interrupting
49
48
  */
50
49
  protected syncExpose(): any;
51
- /**
52
- * Expose all the methods that should support being interrupted
53
- * @param {Array<string>} syncMethods The names of the methods to expose
54
- */
55
- protected exposeMethods(syncMethods: Array<string>): void;
56
50
  /**
57
51
  * Initialize the backend by doing all setup-related work
58
52
  * @param {function(BackendEvent):void} onEvent Callback for when events occur
@@ -61,13 +55,15 @@ export declare abstract class Backend {
61
55
  launch(onEvent: (e: BackendEvent) => void): Promise<void>;
62
56
  /**
63
57
  * Executes the given code
58
+ * @param {Extras} extras Helper properties to run code
64
59
  * @param {string} code The code to run
65
60
  * @return {Promise<void>} Promise of execution
66
61
  */
67
- abstract runCode(extras: SyncExtras, code: string): Promise<void>;
62
+ abstract runCode(extras: Extras, code: string): Promise<void>;
68
63
  /**
69
64
  * Converts the context to a cloneable object containing useful properties
70
65
  * to generate autocompletion suggestions with
66
+ * Class instances are not passable to workers, so we extract the useful information
71
67
  * @param {CompletionContext} context Current context to autocomplete for
72
68
  * @param {RegExp} expr Expression to match the previous token with
73
69
  * @return {WorkerAutocompleteContext} Completion context that can be passed as a message
@@ -25,9 +25,9 @@ export interface BackendEvent {
25
25
  /**
26
26
  * The actual data stored in this event
27
27
  */
28
- data: string;
28
+ data: any;
29
29
  /**
30
30
  * The format used for the data to help with parsing
31
31
  */
32
- contentType: string;
32
+ contentType?: string;
33
33
  }
@@ -8,29 +8,37 @@ import { SyncClient } from "comsync";
8
8
  * @param {BackendEvent} e The published event
9
9
  */
10
10
  declare type BackendEventListener = (e: BackendEvent) => void;
11
- declare class Cacheable<T> {
12
- private cached;
13
- private createFn;
14
- constructor(createFn: () => T);
15
- get(): T;
16
- }
17
11
  /**
18
12
  * Abstract class to implement the singleton pattern
19
13
  * Static methods group functionality
20
14
  */
21
15
  export declare abstract class BackendManager {
22
- static createWorkerMap: Map<ProgrammingLanguage, Cacheable<SyncClient<Backend>>>;
23
- static channel: Channel;
16
+ /**
17
+ * Map programming languages to Backend constructors
18
+ */
19
+ private static createBackendMap;
20
+ /**
21
+ * Map to cache Backends per ProgrammingLanguage
22
+ */
23
+ private static backendMap;
24
24
  /**
25
25
  * Map an event type to interested subscribers
26
26
  * Uses an Array to maintain order of subscription
27
27
  */
28
28
  static subscriberMap: Map<BackendEventType, Array<BackendEventListener>>;
29
- private static buildSyncClientMap;
30
29
  /**
31
- * Start a backend for the given language, while storing the worker
30
+ * The channel used to communicate with the SyncClients
31
+ */
32
+ static channel: Channel;
33
+ /**
34
+ * @param {ProgrammingLanguage} language The language to support
35
+ * @param {Function} backendCreator The constructor for a SyncClient
36
+ */
37
+ static registerBackend(language: ProgrammingLanguage, backendCreator: () => SyncClient<Backend>): void;
38
+ /**
39
+ * Start a backend for the given language and cache for reuse
32
40
  * @param {ProgrammingLanguage} language The programming language supported by the backend
33
- * @return {Remote<Backend>} A Comlink proxy for the Backend
41
+ * @return {SyncClient<Backend>} A SyncClient for the Backend
34
42
  */
35
43
  static startBackend(language: ProgrammingLanguage): SyncClient<Backend>;
36
44
  /**
@@ -17,4 +17,4 @@ export declare const LOCALE_SELECT_ID: string;
17
17
  export declare const PROGRAMMING_LANGUAGE_SELECT_ID: string;
18
18
  export declare const DEFAULT_PROGRAMMING_LANGUAGE = ProgrammingLanguage.Python;
19
19
  export declare const DEFAULT_LOCALE = "nl";
20
- export declare const DEFAULT_SERVICE_WORKER = "inputServiceWorker.js";
20
+ export declare const DEFAULT_SERVICE_WORKER = "InputServiceWorker.js";
package/dist/Library.d.ts CHANGED
@@ -4,7 +4,6 @@ import { InputManager, InputMode } from "./InputManager";
4
4
  import { OutputManager } from "./OutputManager";
5
5
  import { Papyros } from "./Papyros";
6
6
  import { CodeRunner, RunState } from "./CodeRunner";
7
- import { InputWorker } from "./workers/input/InputWorker";
8
7
  export * from "./ProgrammingLanguage";
9
8
  export type { BackendEvent };
10
- export { Papyros, CodeEditor, RunState, CodeRunner, InputManager, InputMode, OutputManager, InputWorker };
9
+ export { Papyros, CodeEditor, RunState, CodeRunner, InputManager, InputMode, OutputManager, };