@dodona/papyros 4.1.1 → 4.1.2

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.
Files changed (168) hide show
  1. package/dist/Library.d.ts +11 -0
  2. package/dist/Library.js +11 -0
  3. package/dist/Library.js.map +1 -0
  4. package/dist/ProgrammingLanguage.d.ts +7 -0
  5. package/dist/ProgrammingLanguage.js +9 -0
  6. package/dist/ProgrammingLanguage.js.map +1 -0
  7. package/dist/backend/Backend.d.ts +92 -0
  8. package/dist/backend/Backend.js +79 -0
  9. package/dist/backend/Backend.js.map +1 -0
  10. package/dist/backend/workers/javascript/JavaScriptWorker.d.ts +39 -0
  11. package/dist/backend/workers/javascript/JavaScriptWorker.js +158 -0
  12. package/dist/backend/workers/javascript/JavaScriptWorker.js.map +1 -0
  13. package/dist/backend/workers/javascript/worker.d.ts +1 -0
  14. package/dist/backend/workers/javascript/worker.js +5 -0
  15. package/dist/backend/workers/javascript/worker.js.map +1 -0
  16. package/dist/backend/workers/python/PythonWorker.d.ts +32 -0
  17. package/dist/backend/workers/python/PythonWorker.js +117 -0
  18. package/dist/backend/workers/python/PythonWorker.js.map +1 -0
  19. package/dist/backend/workers/python/python_package.tar.gz.load_by_url +0 -0
  20. package/dist/backend/workers/python/worker.d.ts +1 -0
  21. package/dist/backend/workers/python/worker.js +5 -0
  22. package/dist/backend/workers/python/worker.js.map +1 -0
  23. package/dist/communication/BackendEvent.d.ts +33 -0
  24. package/dist/communication/BackendEvent.js +18 -0
  25. package/dist/communication/BackendEvent.js.map +1 -0
  26. package/dist/communication/BackendEventQueue.d.ts +59 -0
  27. package/dist/communication/BackendEventQueue.js +96 -0
  28. package/dist/communication/BackendEventQueue.js.map +1 -0
  29. package/dist/communication/BackendManager.d.ts +68 -0
  30. package/dist/communication/BackendManager.js +99 -0
  31. package/dist/communication/BackendManager.js.map +1 -0
  32. package/dist/communication/InputServiceWorker.d.ts +1 -0
  33. package/dist/communication/InputServiceWorker.js +37 -0
  34. package/dist/communication/InputServiceWorker.js.map +1 -0
  35. package/dist/communication/InputWorker.d.ts +22 -0
  36. package/dist/communication/InputWorker.js +63 -0
  37. package/dist/communication/InputWorker.js.map +1 -0
  38. package/dist/frontend/components/CodeRunner.d.ts +9 -0
  39. package/dist/frontend/components/CodeRunner.js +60 -0
  40. package/dist/frontend/components/CodeRunner.js.map +1 -0
  41. package/dist/frontend/components/Debugger.d.ts +7 -0
  42. package/dist/frontend/components/Debugger.js +75 -0
  43. package/dist/frontend/components/Debugger.js.map +1 -0
  44. package/dist/frontend/components/Input.d.ts +13 -0
  45. package/dist/frontend/components/Input.js +60 -0
  46. package/dist/frontend/components/Input.js.map +1 -0
  47. package/dist/frontend/components/Output.d.ts +14 -0
  48. package/dist/frontend/components/Output.js +157 -0
  49. package/dist/frontend/components/Output.js.map +1 -0
  50. package/dist/frontend/components/PapyrosElement.d.ts +8 -0
  51. package/dist/frontend/components/PapyrosElement.js +24 -0
  52. package/dist/frontend/components/PapyrosElement.js.map +1 -0
  53. package/dist/frontend/components/app/App.d.ts +24 -0
  54. package/dist/frontend/components/app/App.js +207 -0
  55. package/dist/frontend/components/app/App.js.map +1 -0
  56. package/dist/frontend/components/app/ExamplePicker.d.ts +7 -0
  57. package/dist/frontend/components/app/ExamplePicker.js +36 -0
  58. package/dist/frontend/components/app/ExamplePicker.js.map +1 -0
  59. package/dist/frontend/components/app/LanguagePicker.d.ts +7 -0
  60. package/dist/frontend/components/app/LanguagePicker.js +33 -0
  61. package/dist/frontend/components/app/LanguagePicker.js.map +1 -0
  62. package/dist/frontend/components/app/ProgrammingLanguagePicker.d.ts +7 -0
  63. package/dist/frontend/components/app/ProgrammingLanguagePicker.js +38 -0
  64. package/dist/frontend/components/app/ProgrammingLanguagePicker.js.map +1 -0
  65. package/dist/frontend/components/app/examples/JavaScriptExamples.d.ts +5 -0
  66. package/dist/frontend/components/app/examples/JavaScriptExamples.js +16 -0
  67. package/dist/frontend/components/app/examples/JavaScriptExamples.js.map +1 -0
  68. package/dist/frontend/components/app/examples/PythonExamples.d.ts +14 -0
  69. package/dist/frontend/components/app/examples/PythonExamples.js +163 -0
  70. package/dist/frontend/components/app/examples/PythonExamples.js.map +1 -0
  71. package/dist/frontend/components/app/themes/ThemePicker.d.ts +11 -0
  72. package/dist/frontend/components/app/themes/ThemePicker.js +48 -0
  73. package/dist/frontend/components/app/themes/ThemePicker.js.map +1 -0
  74. package/dist/frontend/components/app/themes/ThemedButton.d.ts +9 -0
  75. package/dist/frontend/components/app/themes/ThemedButton.js +53 -0
  76. package/dist/frontend/components/app/themes/ThemedButton.js.map +1 -0
  77. package/dist/frontend/components/code_mirror/BatchInputEditor.d.ts +8 -0
  78. package/dist/frontend/components/code_mirror/BatchInputEditor.js +51 -0
  79. package/dist/frontend/components/code_mirror/BatchInputEditor.js.map +1 -0
  80. package/dist/frontend/components/code_mirror/CodeEditor.d.ts +24 -0
  81. package/dist/frontend/components/code_mirror/CodeEditor.js +204 -0
  82. package/dist/frontend/components/code_mirror/CodeEditor.js.map +1 -0
  83. package/dist/frontend/components/code_mirror/CodeMirrorEditor.d.ts +22 -0
  84. package/dist/frontend/components/code_mirror/CodeMirrorEditor.js +111 -0
  85. package/dist/frontend/components/code_mirror/CodeMirrorEditor.js.map +1 -0
  86. package/dist/frontend/components/code_mirror/Extensions.d.ts +15 -0
  87. package/dist/frontend/components/code_mirror/Extensions.js +164 -0
  88. package/dist/frontend/components/code_mirror/Extensions.js.map +1 -0
  89. package/dist/frontend/components/code_mirror/MaterialTheme.d.ts +5 -0
  90. package/dist/frontend/components/code_mirror/MaterialTheme.js +115 -0
  91. package/dist/frontend/components/code_mirror/MaterialTheme.js.map +1 -0
  92. package/dist/frontend/components/code_runner/ButtonLint.d.ts +9 -0
  93. package/dist/frontend/components/code_runner/ButtonLint.js +72 -0
  94. package/dist/frontend/components/code_runner/ButtonLint.js.map +1 -0
  95. package/dist/frontend/components/code_runner/Code.d.ts +7 -0
  96. package/dist/frontend/components/code_runner/Code.js +48 -0
  97. package/dist/frontend/components/code_runner/Code.js.map +1 -0
  98. package/dist/frontend/components/code_runner/RunState.d.ts +7 -0
  99. package/dist/frontend/components/code_runner/RunState.js +41 -0
  100. package/dist/frontend/components/code_runner/RunState.js.map +1 -0
  101. package/dist/frontend/components/input/BatchInput.d.ts +9 -0
  102. package/dist/frontend/components/input/BatchInput.js +53 -0
  103. package/dist/frontend/components/input/BatchInput.js.map +1 -0
  104. package/dist/frontend/components/input/InteractiveInput.d.ts +13 -0
  105. package/dist/frontend/components/input/InteractiveInput.js +71 -0
  106. package/dist/frontend/components/input/InteractiveInput.js.map +1 -0
  107. package/dist/frontend/state/Constants.d.ts +38 -0
  108. package/dist/frontend/state/Constants.js +111 -0
  109. package/dist/frontend/state/Constants.js.map +1 -0
  110. package/dist/frontend/state/Debugger.d.ts +23 -0
  111. package/dist/frontend/state/Debugger.js +86 -0
  112. package/dist/frontend/state/Debugger.js.map +1 -0
  113. package/dist/frontend/state/Examples.d.ts +11 -0
  114. package/dist/frontend/state/Examples.js +36 -0
  115. package/dist/frontend/state/Examples.js.map +1 -0
  116. package/dist/frontend/state/I18n.d.ts +16 -0
  117. package/dist/frontend/state/I18n.js +75 -0
  118. package/dist/frontend/state/I18n.js.map +1 -0
  119. package/dist/frontend/state/InputOutput.d.ts +64 -0
  120. package/dist/frontend/state/InputOutput.js +146 -0
  121. package/dist/frontend/state/InputOutput.js.map +1 -0
  122. package/dist/frontend/state/Papyros.d.ts +40 -0
  123. package/dist/frontend/state/Papyros.js +115 -0
  124. package/dist/frontend/state/Papyros.js.map +1 -0
  125. package/dist/frontend/state/Runner.d.ts +123 -0
  126. package/dist/frontend/state/Runner.js +372 -0
  127. package/dist/frontend/state/Runner.js.map +1 -0
  128. package/dist/frontend/state/Test.d.ts +10 -0
  129. package/dist/frontend/state/Test.js +43 -0
  130. package/dist/frontend/state/Test.js.map +1 -0
  131. package/dist/frontend/state/Translations.d.ts +178 -0
  132. package/dist/frontend/state/Translations.js +187 -0
  133. package/dist/frontend/state/Translations.js.map +1 -0
  134. package/dist/frontend/state/themes/blue-dark.d.ts +2 -0
  135. package/dist/frontend/state/themes/blue-dark.js +56 -0
  136. package/dist/frontend/state/themes/blue-dark.js.map +1 -0
  137. package/dist/frontend/state/themes/blue-light.d.ts +2 -0
  138. package/dist/frontend/state/themes/blue-light.js +56 -0
  139. package/dist/frontend/state/themes/blue-light.js.map +1 -0
  140. package/dist/frontend/state/themes/green-dark.d.ts +2 -0
  141. package/dist/frontend/state/themes/green-dark.js +56 -0
  142. package/dist/frontend/state/themes/green-dark.js.map +1 -0
  143. package/dist/frontend/state/themes/green-light.d.ts +2 -0
  144. package/dist/frontend/state/themes/green-light.js +56 -0
  145. package/dist/frontend/state/themes/green-light.js.map +1 -0
  146. package/dist/frontend/state/themes/red-dark.d.ts +2 -0
  147. package/dist/frontend/state/themes/red-dark.js +56 -0
  148. package/dist/frontend/state/themes/red-dark.js.map +1 -0
  149. package/dist/frontend/state/themes/red-light.d.ts +2 -0
  150. package/dist/frontend/state/themes/red-light.js +56 -0
  151. package/dist/frontend/state/themes/red-light.js.map +1 -0
  152. package/dist/util/Logging.d.ts +15 -0
  153. package/dist/util/Logging.js +30 -0
  154. package/dist/util/Logging.js.map +1 -0
  155. package/dist/util/Util.d.ts +8 -0
  156. package/dist/util/Util.js +48 -0
  157. package/dist/util/Util.js.map +1 -0
  158. package/package.json +1 -1
  159. package/dist/assets/__vite-browser-external-9wXp6ZBx.js +0 -1
  160. package/dist/assets/__vite-browser-external-BIHI7g3E.js +0 -1
  161. package/dist/assets/index-C1AWjGcU.js +0 -2202
  162. package/dist/assets/manifest-BaVmi6rC.json +0 -15
  163. package/dist/assets/python_package.tar.gz-B8aMWvGt.load_by_url +0 -0
  164. package/dist/assets/worker-BhABRh01.js +0 -5
  165. package/dist/assets/worker-C2Ju1j5g.js +0 -110
  166. package/dist/index.html +0 -26
  167. package/dist/manifest.json +0 -15
  168. package/dist/robots.txt +0 -3
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Enum representing all possible types for supported events
3
+ */
4
+ export var BackendEventType;
5
+ (function (BackendEventType) {
6
+ BackendEventType["Start"] = "start";
7
+ BackendEventType["End"] = "end";
8
+ BackendEventType["Input"] = "input";
9
+ BackendEventType["Output"] = "output";
10
+ BackendEventType["Sleep"] = "sleep";
11
+ BackendEventType["Error"] = "error";
12
+ BackendEventType["Interrupt"] = "interrupt";
13
+ BackendEventType["Loading"] = "loading";
14
+ BackendEventType["Frame"] = "frame";
15
+ BackendEventType["FrameChange"] = "frame-change";
16
+ BackendEventType["Stop"] = "stop";
17
+ })(BackendEventType || (BackendEventType = {}));
18
+ //# sourceMappingURL=BackendEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BackendEvent.js","sourceRoot":"","sources":["../../src/communication/BackendEvent.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,gBAYX;AAZD,WAAY,gBAAgB;IACxB,mCAAe,CAAA;IACf,+BAAW,CAAA;IACX,mCAAe,CAAA;IACf,qCAAiB,CAAA;IACjB,mCAAe,CAAA;IACf,mCAAe,CAAA;IACf,2CAAuB,CAAA;IACvB,uCAAmB,CAAA;IACnB,mCAAe,CAAA;IACf,gDAA4B,CAAA;IAC5B,iCAAa,CAAA;AACjB,CAAC,EAZW,gBAAgB,KAAhB,gBAAgB,QAY3B"}
@@ -0,0 +1,59 @@
1
+ import { BackendEvent, BackendEventType } from "./BackendEvent";
2
+ /**
3
+ * Queue to limit the amount of messages sent between threads
4
+ * This prevents communication issues which arise either in Comlink
5
+ * or in the WebWorker message passing code
6
+ */
7
+ export declare class BackendEventQueue {
8
+ /**
9
+ * Function to process events in the queue
10
+ */
11
+ private callback;
12
+ /**
13
+ * The time in milliseconds before sending events through
14
+ */
15
+ private flushTime;
16
+ /**
17
+ * Queue storing the BackendEvents before flushing
18
+ */
19
+ private queue;
20
+ /**
21
+ * Time in milliseconds when the last flush occurred
22
+ */
23
+ private lastFlushTime;
24
+ /**
25
+ * Decoder to convert data to strings
26
+ */
27
+ private decoder;
28
+ /**
29
+ * @param {function(BackendEvent):void} callback Function to process events in the queue
30
+ * @param {number} flushTime The time in milliseconds before sending events through
31
+ */
32
+ constructor(callback: (e: BackendEvent) => void, flushTime?: number);
33
+ /**
34
+ * Add an element to the queue
35
+ * @param {BackendEventType} type The type of the event
36
+ * @param {string | BufferSource | number} text The data for the event
37
+ * @param {string | any} extra Extra data for the event
38
+ * If string, interpreted as the contentType
39
+ * If anything else, it should contain a contentType
40
+ * If the contentType is not textual, an error is thrown
41
+ */
42
+ put(type: BackendEventType, text: string | BufferSource | number, extra: string | any): void;
43
+ /**
44
+ * @return {boolean} Whether the queue contents should be flushed
45
+ */
46
+ protected shouldFlush(): boolean;
47
+ /**
48
+ * Reset the queue contents for a new run
49
+ */
50
+ reset(): void;
51
+ /**
52
+ * Flush the queue contents using the callback
53
+ */
54
+ flush(): void;
55
+ /**
56
+ * @param {Function} callback The event-consuming callback
57
+ */
58
+ setCallback(callback: (e: BackendEvent) => void): void;
59
+ }
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Queue to limit the amount of messages sent between threads
3
+ * This prevents communication issues which arise either in Comlink
4
+ * or in the WebWorker message passing code
5
+ */
6
+ export class BackendEventQueue {
7
+ /**
8
+ * @param {function(BackendEvent):void} callback Function to process events in the queue
9
+ * @param {number} flushTime The time in milliseconds before sending events through
10
+ */
11
+ constructor(callback, flushTime = 100) {
12
+ this.callback = callback;
13
+ this.flushTime = flushTime;
14
+ this.queue = [];
15
+ this.lastFlushTime = new Date().getTime();
16
+ this.decoder = new TextDecoder();
17
+ }
18
+ /**
19
+ * Add an element to the queue
20
+ * @param {BackendEventType} type The type of the event
21
+ * @param {string | BufferSource | number} text The data for the event
22
+ * @param {string | any} extra Extra data for the event
23
+ * If string, interpreted as the contentType
24
+ * If anything else, it should contain a contentType
25
+ * If the contentType is not textual, an error is thrown
26
+ */
27
+ put(type, text, extra) {
28
+ let stringData;
29
+ if (typeof text === "number") {
30
+ stringData = text.toString();
31
+ }
32
+ else if (typeof text !== "string") {
33
+ stringData = this.decoder.decode(text);
34
+ }
35
+ else {
36
+ stringData = text;
37
+ }
38
+ let extraArgs = {};
39
+ let contentType = "text/plain";
40
+ if (extra) {
41
+ if (typeof extra === "string") {
42
+ contentType = extra;
43
+ }
44
+ else {
45
+ contentType = extra["contentType"];
46
+ delete extra["contentType"];
47
+ extraArgs = extra;
48
+ }
49
+ }
50
+ if (this.queue.length === 0 ||
51
+ !contentType.startsWith("text") || // Non textual cannot be combined
52
+ this.queue[this.queue.length - 1].type !== type || // Different type
53
+ // Can't be combined if contentType doesn't match
54
+ this.queue[this.queue.length - 1].contentType !== contentType) {
55
+ this.queue.push(Object.assign({ type: type, data: stringData, contentType: contentType }, extraArgs));
56
+ }
57
+ else {
58
+ // Same kind of event, combine into one
59
+ this.queue[this.queue.length - 1].data += stringData;
60
+ }
61
+ if (this.shouldFlush()) {
62
+ this.flush();
63
+ }
64
+ }
65
+ /**
66
+ * @return {boolean} Whether the queue contents should be flushed
67
+ */
68
+ shouldFlush() {
69
+ return (this.queue.length > 1 || // different types of Events present
70
+ new Date().getTime() - this.lastFlushTime > this.flushTime);
71
+ }
72
+ /**
73
+ * Reset the queue contents for a new run
74
+ */
75
+ reset() {
76
+ this.queue = [];
77
+ this.lastFlushTime = new Date().getTime();
78
+ }
79
+ /**
80
+ * Flush the queue contents using the callback
81
+ */
82
+ flush() {
83
+ this.queue.forEach((e) => {
84
+ this.callback(e);
85
+ });
86
+ this.queue = [];
87
+ this.lastFlushTime = new Date().getTime();
88
+ }
89
+ /**
90
+ * @param {Function} callback The event-consuming callback
91
+ */
92
+ setCallback(callback) {
93
+ this.callback = callback;
94
+ }
95
+ }
96
+ //# sourceMappingURL=BackendEventQueue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BackendEventQueue.js","sourceRoot":"","sources":["../../src/communication/BackendEventQueue.ts"],"names":[],"mappings":"AAEA;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I,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;IAC9C,CAAC;IAED;;OAEG;IACI,WAAW,CAAC,QAAmC;QAClD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;CACJ"}
@@ -0,0 +1,68 @@
1
+ import { Backend } from "../backend/Backend";
2
+ import { ProgrammingLanguage } from "../ProgrammingLanguage";
3
+ import { BackendEvent, BackendEventType } from "./BackendEvent";
4
+ import { Channel } from "sync-message";
5
+ import { SyncClient } from "comsync";
6
+ /**
7
+ * Callback type definition for subscribers
8
+ * @param {BackendEvent} e The published event
9
+ */
10
+ type BackendEventListener = (e: BackendEvent) => void;
11
+ /**
12
+ * Abstract class to implement the singleton pattern
13
+ * Static methods group functionality
14
+ */
15
+ export declare abstract class BackendManager {
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
+ /**
25
+ * Map an event type to interested subscribers
26
+ * Uses an Array to maintain order of subscription
27
+ */
28
+ private static subscriberMap;
29
+ /**
30
+ * Whether the BackendManager is publishing events
31
+ */
32
+ private static halted;
33
+ /**
34
+ * The channel used to communicate with the SyncClients
35
+ */
36
+ static channel: Channel;
37
+ /**
38
+ * @param {ProgrammingLanguage} language The language to support
39
+ * @param {Function} backendCreator The constructor for a SyncClient
40
+ */
41
+ static registerBackend(language: ProgrammingLanguage, backendCreator: () => SyncClient<Backend>): void;
42
+ /**
43
+ * Start a backend for the given language and cache for reuse
44
+ * @param {ProgrammingLanguage} language The programming language supported by the backend
45
+ * @return {SyncClient<Backend>} A SyncClient for the Backend
46
+ */
47
+ static getBackend(language: ProgrammingLanguage): SyncClient<Backend>;
48
+ /**
49
+ * Remove a backend for the given language
50
+ * @param {ProgrammingLanguage} language The programming language supported by the backend
51
+ * @return {boolean} Whether the remove operation had any effect
52
+ */
53
+ static removeBackend(language: ProgrammingLanguage): boolean;
54
+ /**
55
+ * Register a callback for when an event of a certain type is published
56
+ * @param {BackendEventType} type The type of event to subscribe to
57
+ * @param {BackendEventListener} subscriber Callback for when an event
58
+ * of the given type is published
59
+ */
60
+ static subscribe(type: BackendEventType, subscriber: BackendEventListener): void;
61
+ /**
62
+ * Publish an event, notifying all listeners for its type
63
+ * @param {BackendEventType} e The event to publish
64
+ */
65
+ static publish(e: BackendEvent): void;
66
+ private static halt;
67
+ }
68
+ export {};
@@ -0,0 +1,99 @@
1
+ import { ProgrammingLanguage } from "../ProgrammingLanguage";
2
+ import { BackendEventType } from "./BackendEvent";
3
+ import { LogType, papyrosLog } from "../util/Logging";
4
+ import { makeChannel } from "sync-message";
5
+ import { SyncClient } from "comsync";
6
+ import { PyodideClient } from "pyodide-worker-runner";
7
+ /**
8
+ * Abstract class to implement the singleton pattern
9
+ * Static methods group functionality
10
+ */
11
+ export class BackendManager {
12
+ /**
13
+ * @param {ProgrammingLanguage} language The language to support
14
+ * @param {Function} backendCreator The constructor for a SyncClient
15
+ */
16
+ static registerBackend(language, backendCreator) {
17
+ BackendManager.removeBackend(language);
18
+ BackendManager.createBackendMap.set(language, backendCreator);
19
+ }
20
+ /**
21
+ * Start a backend for the given language and cache for reuse
22
+ * @param {ProgrammingLanguage} language The programming language supported by the backend
23
+ * @return {SyncClient<Backend>} A SyncClient for the Backend
24
+ */
25
+ static getBackend(language) {
26
+ if (this.backendMap.has(language)) {
27
+ // Cached
28
+ return this.backendMap.get(language);
29
+ }
30
+ else if (this.createBackendMap.has(language)) {
31
+ // Create and then cache
32
+ const syncClient = this.createBackendMap.get(language)();
33
+ this.backendMap.set(language, syncClient);
34
+ return syncClient;
35
+ }
36
+ else {
37
+ throw new Error(`${language} is not yet supported.`);
38
+ }
39
+ }
40
+ /**
41
+ * Remove a backend for the given language
42
+ * @param {ProgrammingLanguage} language The programming language supported by the backend
43
+ * @return {boolean} Whether the remove operation had any effect
44
+ */
45
+ static removeBackend(language) {
46
+ this.backendMap.delete(language);
47
+ return this.createBackendMap.delete(language);
48
+ }
49
+ /**
50
+ * Register a callback for when an event of a certain type is published
51
+ * @param {BackendEventType} type The type of event to subscribe to
52
+ * @param {BackendEventListener} subscriber Callback for when an event
53
+ * of the given type is published
54
+ */
55
+ static subscribe(type, subscriber) {
56
+ if (!this.subscriberMap.has(type)) {
57
+ this.subscriberMap.set(type, []);
58
+ }
59
+ const subscribers = this.subscriberMap.get(type);
60
+ if (!subscribers.includes(subscriber)) {
61
+ subscribers.push(subscriber);
62
+ }
63
+ }
64
+ /**
65
+ * Publish an event, notifying all listeners for its type
66
+ * @param {BackendEventType} e The event to publish
67
+ */
68
+ static publish(e) {
69
+ papyrosLog(LogType.Debug, "Publishing event: ", e);
70
+ if (e.type === BackendEventType.Start) {
71
+ BackendManager.halted = false;
72
+ }
73
+ if ((!BackendManager.halted || e.type === BackendEventType.FrameChange) && this.subscriberMap.has(e.type)) {
74
+ this.subscriberMap.get(e.type).forEach((cb) => cb(e));
75
+ }
76
+ }
77
+ static halt() {
78
+ BackendManager.halted = true;
79
+ }
80
+ }
81
+ /**
82
+ * Initialise the fields and setup the maps
83
+ */
84
+ (() => {
85
+ BackendManager.channel = makeChannel();
86
+ BackendManager.createBackendMap = new Map();
87
+ BackendManager.backendMap = new Map();
88
+ BackendManager.subscriberMap = new Map();
89
+ BackendManager.registerBackend(ProgrammingLanguage.Python, () => new PyodideClient(() => new Worker(new URL("../backend/workers/python/worker", import.meta.url), {
90
+ type: "module",
91
+ }), BackendManager.channel));
92
+ BackendManager.registerBackend(ProgrammingLanguage.JavaScript, () => new SyncClient(() => new Worker(new URL("../backend/workers/javascript/worker", import.meta.url), {
93
+ type: "module",
94
+ }), BackendManager.channel));
95
+ BackendManager.halted = false;
96
+ BackendManager.subscribe(BackendEventType.End, () => BackendManager.halt());
97
+ BackendManager.subscribe(BackendEventType.Interrupt, () => BackendManager.halt());
98
+ })();
99
+ //# sourceMappingURL=BackendManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ /**
11
+ * Default service worker to process user input using HTTP requests
12
+ */
13
+ // Import service worker provided by the Papyros-package
14
+ import { InputWorker } from "./InputWorker";
15
+ // Strip away the filename of the script to obtain the scope
16
+ // let domain = location.href;
17
+ // domain = domain.slice(0, domain.lastIndexOf("/") + 1);
18
+ const domain = ""; // Disable SharedArrayBuffers to use same environment as Dodona
19
+ const inputHandler = new InputWorker(domain);
20
+ addEventListener("fetch", function (event) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ if (!(yield inputHandler.handleInputRequest(event))) {
23
+ // Not a Papyros-specific request
24
+ // Fetch as we would handle a normal request
25
+ // Default action is to let browser handle it by not responding here
26
+ return;
27
+ }
28
+ });
29
+ });
30
+ // Prevent needing to reload page to have working input
31
+ addEventListener("install", function (event) {
32
+ event.waitUntil(skipWaiting());
33
+ });
34
+ addEventListener("activate", function (event) {
35
+ event.waitUntil(clients.claim());
36
+ });
37
+ //# sourceMappingURL=InputServiceWorker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InputServiceWorker.js","sourceRoot":"","sources":["../../src/communication/InputServiceWorker.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;GAEG;AACH,wDAAwD;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,4DAA4D;AAC5D,8BAA8B;AAC9B,yDAAyD;AACzD,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,+DAA+D;AAClF,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;AAE7C,gBAAgB,CAAC,OAAO,EAAE,UAAgB,KAAiB;;QACvD,IAAI,CAAC,CAAC,MAAM,YAAY,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YAClD,iCAAiC;YACjC,4CAA4C;YAC5C,oEAAoE;YACpE,OAAO;QACX,CAAC;IACL,CAAC;CAAA,CAAC,CAAC;AACH,uDAAuD;AACvD,gBAAgB,CAAC,SAAS,EAAE,UAAU,KAAsB;IACxD,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;AACnC,CAAC,CAAC,CAAC;AACH,gBAAgB,CAAC,UAAU,EAAE,UAAU,KAAsB;IACzD,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC"}
@@ -0,0 +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
+ */
8
+ export declare class InputWorker {
9
+ private hostName;
10
+ private syncMessageListener;
11
+ /**
12
+ * Create a worker for a specific domain
13
+ * @param {string} hostName Optional name of the host domain
14
+ */
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
+ */
21
+ handleInputRequest(event: FetchEvent): Promise<boolean>;
22
+ }
@@ -0,0 +1,63 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { serviceWorkerFetchListener } from "sync-message";
11
+ /**
12
+ * Class that is used in a service worker to allow synchronous communication
13
+ * between threads. This is achieved in two different ways.
14
+ * Responses can be modified by attaching headers allowing the use of shared memory.
15
+ * Requests to certain endpoints can be used with synchronous requests
16
+ * to achieve the same goal.
17
+ */
18
+ export class InputWorker {
19
+ /**
20
+ * Create a worker for a specific domain
21
+ * @param {string} hostName Optional name of the host domain
22
+ */
23
+ constructor(hostName = "") {
24
+ this.hostName = hostName;
25
+ this.syncMessageListener = serviceWorkerFetchListener();
26
+ }
27
+ /**
28
+ * Process and potentially handle a fetch request from the application
29
+ * @param {FetchEvent} event The event denoting a request to a url
30
+ * @return {boolean} Whether the event was handled
31
+ */
32
+ handleInputRequest(event) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ // Special requests targeted at getting input from the user
35
+ if (this.syncMessageListener(event)) {
36
+ return true;
37
+ }
38
+ const url = event.request.url;
39
+ if (this.hostName && url.includes(this.hostName)) {
40
+ // requests to our own domain
41
+ event.respondWith(fetch(event.request).then((response) => {
42
+ // Add new headers to be able to use SharedArrayBuffers
43
+ // if the browser supports them
44
+ const newHeaders = new Headers(response.headers);
45
+ newHeaders.set("Cross-Origin-Embedder-Policy", "require-corp");
46
+ newHeaders.set("Cross-Origin-Opener-Policy", "same-origin");
47
+ newHeaders.set("Cross-Origin-Resource-Policy", "cross-origin");
48
+ const moddedResponse = new Response(response.body, {
49
+ status: response.status || 200,
50
+ statusText: response.statusText,
51
+ headers: newHeaders,
52
+ });
53
+ return moddedResponse;
54
+ }));
55
+ return true;
56
+ }
57
+ else {
58
+ return false;
59
+ }
60
+ });
61
+ }
62
+ }
63
+ //# sourceMappingURL=InputWorker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InputWorker.js","sourceRoot":"","sources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BACtB,CAAC,CAAC;oBACH,OAAO,cAAc,CAAC;gBAC1B,CAAC,CAAC,CACL,CAAC;gBACF,OAAO,IAAI,CAAC;YAChB,CAAC;iBAAM,CAAC;gBACJ,OAAO,KAAK,CAAC;YACjB,CAAC;QACL,CAAC;KAAA;CACJ"}
@@ -0,0 +1,9 @@
1
+ import { PapyrosElement } from "./PapyrosElement";
2
+ import { CSSResult, TemplateResult } from "lit";
3
+ import "./code_runner/Code";
4
+ import "./code_runner/RunState";
5
+ import "./code_runner/ButtonLint";
6
+ export declare class CodeRunner extends PapyrosElement {
7
+ static get styles(): CSSResult;
8
+ protected render(): TemplateResult;
9
+ }
@@ -0,0 +1,60 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { customElement } from "lit/decorators.js";
8
+ import { PapyrosElement } from "./PapyrosElement";
9
+ import { css, html } from "lit";
10
+ import "./code_runner/Code";
11
+ import "./code_runner/RunState";
12
+ import "./code_runner/ButtonLint";
13
+ let CodeRunner = class CodeRunner extends PapyrosElement {
14
+ static get styles() {
15
+ return css `
16
+ :host {
17
+ width: 100%;
18
+ display: flex;
19
+ flex-direction: column;
20
+ border-radius: 0.5rem;
21
+ }
22
+
23
+ div {
24
+ flex-grow: 1;
25
+ min-height: 0;
26
+ position: relative;
27
+ }
28
+
29
+ p-run-state {
30
+ position: absolute;
31
+ bottom: 0;
32
+ right: 6px;
33
+ background-color: var(--md-sys-color-surface-container);
34
+ padding: 0.25rem 1rem;
35
+ border-top-right-radius: 1rem;
36
+ border-top-left-radius: 1rem;
37
+ }
38
+
39
+ p-button-lint {
40
+ background-color: var(--md-sys-color-surface-container);
41
+ }
42
+ `;
43
+ }
44
+ render() {
45
+ return html `
46
+ <div>
47
+ <p-code .papyros=${this.papyros}></p-code>
48
+ ${this.papyros.runner.stateMessage ? html `<p-run-state .papyros=${this.papyros}></p-run-state>` : ""}
49
+ </div>
50
+ <p-button-lint .papyros=${this.papyros}>
51
+ <slot name="buttons"></slot>
52
+ </p-button-lint>
53
+ `;
54
+ }
55
+ };
56
+ CodeRunner = __decorate([
57
+ customElement("p-code-runner")
58
+ ], CodeRunner);
59
+ export { CodeRunner };
60
+ //# sourceMappingURL=CodeRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeRunner.js","sourceRoot":"","sources":["../../../src/frontend/components/CodeRunner.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,GAAG,EAAa,IAAI,EAAkB,MAAM,KAAK,CAAC;AAC3D,OAAO,oBAAoB,CAAC;AAC5B,OAAO,wBAAwB,CAAC;AAChC,OAAO,0BAA0B,CAAC;AAG3B,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,cAAc;IAC1C,MAAM,KAAK,MAAM;QACb,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;SA2BT,CAAC;IACN,CAAC;IAEkB,MAAM;QACrB,OAAO,IAAI,CAAA;;mCAEgB,IAAI,CAAC,OAAO;kBAC7B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAA,yBAAyB,IAAI,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAC,EAAE;;sCAE9E,IAAI,CAAC,OAAO;;;SAGzC,CAAC;IACN,CAAC;CACJ,CAAA;AA3CY,UAAU;IADtB,aAAa,CAAC,eAAe,CAAC;GAClB,UAAU,CA2CtB"}
@@ -0,0 +1,7 @@
1
+ import { CSSResult, TemplateResult } from "lit";
2
+ import "@dodona/trace-component";
3
+ import { PapyrosElement } from "./PapyrosElement";
4
+ export declare class Debugger extends PapyrosElement {
5
+ static get styles(): CSSResult;
6
+ protected render(): TemplateResult;
7
+ }
@@ -0,0 +1,75 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { css, html } from "lit";
8
+ import "@dodona/trace-component";
9
+ import { customElement } from "lit/decorators.js";
10
+ import { PapyrosElement } from "./PapyrosElement";
11
+ let Debugger = class Debugger extends PapyrosElement {
12
+ static get styles() {
13
+ return css `
14
+ :host {
15
+ /* Base / surface */
16
+ --tc-surface-color: var(--md-sys-color-surface-container);
17
+ --tc-on-surface-color: var(--md-sys-color-on-surface);
18
+ --tc-surface-container-color: var(--md-sys-color-surface-container-highest);
19
+ --tc-outline-color: var(--md-sys-color-outline);
20
+ --tc-outline-variant-color: var(--md-sys-color-outline-variant);
21
+ --tc-primary-color: var(--md-sys-color-primary);
22
+
23
+ /* Secondary */
24
+ --tc-secondary-surface-color: var(
25
+ --md-sys-color-secondary-surface,
26
+ var(--md-sys-color-secondary-container)
27
+ );
28
+ --tc-secondary-on-surface-color: var(
29
+ --md-sys-color-on-secondary-surface,
30
+ var(--md-sys-color-on-secondary-container)
31
+ );
32
+ --tc-secondary-surface-container-color: var(--md-sys-color-secondary-container);
33
+ --tc-secondary-outline-color: var(--md-sys-color-secondary-outline, var(--md-sys-color-outline));
34
+ --tc-secondary-color: var(--md-sys-color-secondary);
35
+
36
+ /* Tertiary */
37
+ --tc-tertiary-surface-color: var(
38
+ --md-sys-color-tertiary-surface,
39
+ var(--md-sys-color-tertiary-container)
40
+ );
41
+ --tc-tertiary-on-surface-color: var(
42
+ --md-sys-color-on-tertiary-surface,
43
+ var(--md-sys-color-on-tertiary-container)
44
+ );
45
+ --tc-tertiary-surface-container-color: var(--md-sys-color-tertiary-container);
46
+ --tc-tertiary-outline-color: var(--md-sys-color-tertiary-outline, var(--md-sys-color-outline));
47
+ --tc-tertiary-color: var(--md-sys-color-tertiary);
48
+ }
49
+
50
+ .place-holder {
51
+ color: var(--md-sys-color-on-surface);
52
+ opacity: 0.5;
53
+ }
54
+ `;
55
+ }
56
+ render() {
57
+ var _a;
58
+ if (!this.papyros.debugger.active || this.papyros.debugger.trace.length === 0) {
59
+ return html `<div class="place-holder">${this.t("Papyros.debug_placeholder")}</div>`;
60
+ }
61
+ return html `<tc-trace
62
+ .trace=${this.papyros.debugger.trace}
63
+ .translations=${this.papyros.i18n.getTranslations("Papyros.debugger")}
64
+ .selectedFrame=${(_a = this.papyros.debugger.activeFrame) !== null && _a !== void 0 ? _a : 0}
65
+ @frame-change=${(e) => {
66
+ this.papyros.debugger.activeFrame = e.detail.frame;
67
+ }}
68
+ ></tc-trace>`;
69
+ }
70
+ };
71
+ Debugger = __decorate([
72
+ customElement("p-debugger")
73
+ ], Debugger);
74
+ export { Debugger };
75
+ //# sourceMappingURL=Debugger.js.map