@dodona/papyros 0.1.922-tar → 0.1.926-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 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,10 +55,11 @@ 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
@@ -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
  /**
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, };