@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,11 @@
1
+ import "./frontend/components/Input";
2
+ import "./frontend/components/Output";
3
+ import "./frontend/components/CodeRunner";
4
+ import "./frontend/components/Debugger";
5
+ import { Papyros, papyros } from "./frontend/state/Papyros";
6
+ import { InputMode } from "./frontend/state/InputOutput";
7
+ import { RunMode } from "./backend/Backend";
8
+ import { ProgrammingLanguage } from "./ProgrammingLanguage";
9
+ import { OutputType, FriendlyError } from "./frontend/state/InputOutput";
10
+ export { Papyros, InputMode, RunMode, ProgrammingLanguage, OutputType, papyros };
11
+ export type { FriendlyError };
@@ -0,0 +1,11 @@
1
+ import "./frontend/components/Input";
2
+ import "./frontend/components/Output";
3
+ import "./frontend/components/CodeRunner";
4
+ import "./frontend/components/Debugger";
5
+ import { Papyros, papyros } from "./frontend/state/Papyros";
6
+ import { InputMode } from "./frontend/state/InputOutput";
7
+ import { RunMode } from "./backend/Backend";
8
+ import { ProgrammingLanguage } from "./ProgrammingLanguage";
9
+ import { OutputType } from "./frontend/state/InputOutput";
10
+ export { Papyros, InputMode, RunMode, ProgrammingLanguage, OutputType, papyros };
11
+ //# sourceMappingURL=Library.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Library.js","sourceRoot":"","sources":["../src/Library.ts"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,CAAC;AACrC,OAAO,8BAA8B,CAAC;AACtC,OAAO,kCAAkC,CAAC;AAC1C,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAiB,MAAM,8BAA8B,CAAC;AAEzE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * String enum representing programming languages supported by Papyros
3
+ */
4
+ export declare enum ProgrammingLanguage {
5
+ Python = "Python",
6
+ JavaScript = "JavaScript"
7
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * String enum representing programming languages supported by Papyros
3
+ */
4
+ export var ProgrammingLanguage;
5
+ (function (ProgrammingLanguage) {
6
+ ProgrammingLanguage["Python"] = "Python";
7
+ ProgrammingLanguage["JavaScript"] = "JavaScript";
8
+ })(ProgrammingLanguage || (ProgrammingLanguage = {}));
9
+ //# sourceMappingURL=ProgrammingLanguage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProgrammingLanguage.js","sourceRoot":"","sources":["../src/ProgrammingLanguage.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC3B,wCAAiB,CAAA;IACjB,gDAAyB,CAAA;AAC7B,CAAC,EAHW,mBAAmB,KAAnB,mBAAmB,QAG9B"}
@@ -0,0 +1,92 @@
1
+ import { BackendEvent } from "../communication/BackendEvent";
2
+ import { SyncExtras } from "comsync";
3
+ import { BackendEventQueue } from "../communication/BackendEventQueue";
4
+ export interface WorkerDiagnostic {
5
+ /**
6
+ * 1-based index of the starting line containing the issue
7
+ */
8
+ lineNr: number;
9
+ /**
10
+ * 0-based index of the column in the starting line
11
+ */
12
+ columnNr: number;
13
+ /**
14
+ * 1-based index of the ending line containing the issue
15
+ * Can be the same as lineNr
16
+ */
17
+ endLineNr: number;
18
+ /**
19
+ * 0-based index of the column in the ending line
20
+ */
21
+ endColumnNr: number;
22
+ /**
23
+ * Severity of the issue
24
+ */
25
+ severity: "info" | "warning" | "error";
26
+ /**
27
+ * Message describing the issue
28
+ */
29
+ message: string;
30
+ }
31
+ export declare enum RunMode {
32
+ Run = "run",
33
+ Debug = "debug",
34
+ Doctest = "doctest"
35
+ }
36
+ export declare abstract class Backend<Extras extends SyncExtras = SyncExtras> {
37
+ /**
38
+ * SyncExtras object that grants access to helpful methods
39
+ * for synchronous operations
40
+ */
41
+ protected extras: Extras;
42
+ /**
43
+ * Callback to handle events published by this Backend
44
+ */
45
+ protected onEvent: (e: BackendEvent) => any;
46
+ /**
47
+ * Queue to handle published events without overloading the thread
48
+ */
49
+ protected queue: BackendEventQueue;
50
+ /**
51
+ * Constructor is limited as it is meant to be used as a WebWorker
52
+ * Proper initialization occurs in the launch method when the worker is started
53
+ * Synchronously exposing methods should be done here
54
+ */
55
+ constructor();
56
+ /**
57
+ * @return {any} The function to expose methods for Comsync to allow interrupting
58
+ */
59
+ protected syncExpose(): any;
60
+ /**
61
+ * Initialize the backend by doing all setup-related work
62
+ * @param {function(BackendEvent):void} onEvent Callback for when events occur
63
+ * @return {Promise<void>} Promise of launching
64
+ */
65
+ launch(onEvent: (e: BackendEvent) => void): Promise<void>;
66
+ /**
67
+ * Determine whether the modes supported by this Backend are active
68
+ * @param {string} code The current code in the editor
69
+ * @return {Array<RunMode>} The run modes of this Backend
70
+ */
71
+ runModes(code: string): Array<RunMode>;
72
+ /**
73
+ * Executes the given code
74
+ * @param {Extras} extras Helper properties to run code
75
+ * @param {string} code The code to run
76
+ * @param {string} mode The mode to run the code in
77
+ * @return {Promise<void>} Promise of execution
78
+ */
79
+ abstract runCode(extras: Extras, code: string, mode?: string): Promise<void>;
80
+ /**
81
+ * Generate linting suggestions for the given code
82
+ * @param {string} code The code to lint
83
+ */
84
+ abstract lintCode(code: string): Promise<Array<WorkerDiagnostic>>;
85
+ /**
86
+ * Provide files to be used by the backend
87
+ * @param {Record<string, string>} inlineFiles Map of file names to their contents
88
+ * @param {Record<string, string>} hrefFiles Map of file names to URLS with their contents
89
+ * @return {Promise<void>} Resolves when the files are present in the backend
90
+ */
91
+ provideFiles(inlineFiles: Record<string, string>, hrefFiles: Record<string, string>): Promise<void>;
92
+ }
@@ -0,0 +1,79 @@
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 { BackendEventType } from "../communication/BackendEvent";
11
+ import { syncExpose } from "comsync";
12
+ import { BackendEventQueue } from "../communication/BackendEventQueue";
13
+ export var RunMode;
14
+ (function (RunMode) {
15
+ RunMode["Run"] = "run";
16
+ RunMode["Debug"] = "debug";
17
+ RunMode["Doctest"] = "doctest";
18
+ })(RunMode || (RunMode = {}));
19
+ export class Backend {
20
+ /**
21
+ * Constructor is limited as it is meant to be used as a WebWorker
22
+ * Proper initialization occurs in the launch method when the worker is started
23
+ * Synchronously exposing methods should be done here
24
+ */
25
+ constructor() {
26
+ this.extras = {};
27
+ this.onEvent = () => {
28
+ // Empty, initialized in launch
29
+ };
30
+ this.runCode = this.syncExpose()(this.runCode.bind(this));
31
+ this.queue = {};
32
+ }
33
+ /**
34
+ * @return {any} The function to expose methods for Comsync to allow interrupting
35
+ */
36
+ syncExpose() {
37
+ return syncExpose;
38
+ }
39
+ /**
40
+ * Initialize the backend by doing all setup-related work
41
+ * @param {function(BackendEvent):void} onEvent Callback for when events occur
42
+ * @return {Promise<void>} Promise of launching
43
+ */
44
+ launch(onEvent) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ this.onEvent = (e) => {
47
+ onEvent(e);
48
+ if (e.type === BackendEventType.Sleep) {
49
+ return this.extras.syncSleep(e.data);
50
+ }
51
+ else if (e.type === BackendEventType.Input) {
52
+ return this.extras.readMessage();
53
+ }
54
+ };
55
+ this.queue = new BackendEventQueue(this.onEvent.bind(this));
56
+ return Promise.resolve();
57
+ });
58
+ }
59
+ /**
60
+ * Determine whether the modes supported by this Backend are active
61
+ * @param {string} code The current code in the editor
62
+ * @return {Array<RunMode>} The run modes of this Backend
63
+ */
64
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
65
+ runModes(code) {
66
+ return [];
67
+ }
68
+ /**
69
+ * Provide files to be used by the backend
70
+ * @param {Record<string, string>} inlineFiles Map of file names to their contents
71
+ * @param {Record<string, string>} hrefFiles Map of file names to URLS with their contents
72
+ * @return {Promise<void>} Resolves when the files are present in the backend
73
+ */
74
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
75
+ provideFiles(inlineFiles, hrefFiles) {
76
+ return Promise.resolve();
77
+ }
78
+ }
79
+ //# sourceMappingURL=Backend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Backend.js","sourceRoot":"","sources":["../../src/backend/Backend.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAc,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AA8BvE,MAAM,CAAN,IAAY,OAIX;AAJD,WAAY,OAAO;IACf,sBAAW,CAAA;IACX,0BAAe,CAAA;IACf,8BAAmB,CAAA;AACvB,CAAC,EAJW,OAAO,KAAP,OAAO,QAIlB;AAED,MAAM,OAAgB,OAAO;IAczB;;;;OAIG;IACH;QACI,IAAI,CAAC,MAAM,GAAG,EAAY,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,GAAG,EAAE;YAChB,+BAA+B;QACnC,CAAC,CAAC;QACF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1D,IAAI,CAAC,KAAK,GAAG,EAAuB,CAAC;IACzC,CAAC;IAED;;OAEG;IACO,UAAU;QAChB,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACU,MAAM,CAAC,OAAkC;;YAClD,IAAI,CAAC,OAAO,GAAG,CAAC,CAAe,EAAE,EAAE;gBAC/B,OAAO,CAAC,CAAC,CAAC,CAAC;gBACX,IAAI,CAAC,CAAC,IAAI,KAAK,gBAAgB,CAAC,KAAK,EAAE,CAAC;oBACpC,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBACzC,CAAC;qBAAM,IAAI,CAAC,CAAC,IAAI,KAAK,gBAAgB,CAAC,KAAK,EAAE,CAAC;oBAC3C,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;gBACrC,CAAC;YACL,CAAC,CAAC;YACF,IAAI,CAAC,KAAK,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAC5D,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC;KAAA;IAED;;;;OAIG;IACH,6DAA6D;IACtD,QAAQ,CAAC,IAAY;QACxB,OAAO,EAAE,CAAC;IACd,CAAC;IAiBD;;;;;OAKG;IACH,6DAA6D;IACtD,YAAY,CAAC,WAAmC,EAAE,SAAiC;QACtF,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ"}
@@ -0,0 +1,39 @@
1
+ import { Backend, WorkerDiagnostic } from "../../Backend";
2
+ import { SyncExtras } from "comsync";
3
+ /**
4
+ * Implementation of a JavaScript backend for Papyros
5
+ * by using eval and overriding some builtins
6
+ */
7
+ export declare class JavaScriptWorker extends Backend<SyncExtras> {
8
+ /**
9
+ * Convert varargs to a string, similar to how the console does it
10
+ * @param {any[]} args The values to join into a string
11
+ * @return {string} The string representation
12
+ */
13
+ private static stringify;
14
+ /**
15
+ * Prompt the user for input with a message
16
+ * @param {string} text The message to show when asking for input
17
+ * @return {string} The value the user gave
18
+ */
19
+ private prompt;
20
+ /**
21
+ * Print values to the output screen
22
+ * @param {any[]} args The values to log
23
+ */
24
+ private consoleLog;
25
+ /**
26
+ * Print values to the error screen
27
+ * @param {any[]} args The error values to log
28
+ */
29
+ private consoleError;
30
+ /**
31
+ * Helper method to generate suggestions based on properties in an object
32
+ * @param {number} from Where in the document the autocompletion starts
33
+ * @param {any} object Object with properties that might be relevant
34
+ * @return {CompletionResult} Autocompletion suggestions
35
+ */
36
+ private static completeProperties;
37
+ runCode(extras: SyncExtras, code: string): Promise<any>;
38
+ lintCode(): Promise<Array<WorkerDiagnostic>>;
39
+ }
@@ -0,0 +1,158 @@
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 { Backend } from "../../Backend";
11
+ import { BackendEventType } from "../../../communication/BackendEvent";
12
+ /**
13
+ * Implementation of a JavaScript backend for Papyros
14
+ * by using eval and overriding some builtins
15
+ */
16
+ export class JavaScriptWorker extends Backend {
17
+ /**
18
+ * Convert varargs to a string, similar to how the console does it
19
+ * @param {any[]} args The values to join into a string
20
+ * @return {string} The string representation
21
+ */
22
+ static stringify(...args) {
23
+ const asString = args
24
+ .map((a) => {
25
+ if (Array.isArray(a)) {
26
+ return JSON.stringify(a);
27
+ }
28
+ else if (typeof a === "string") {
29
+ return a;
30
+ }
31
+ else if (typeof a === "number") {
32
+ return a + "";
33
+ }
34
+ else if (typeof a === "object" && "toString" in a) {
35
+ let aString = a.toString();
36
+ if (aString === "[object Object]") {
37
+ // useless toString, so use JSON
38
+ aString = JSON.stringify(a);
39
+ }
40
+ return aString;
41
+ }
42
+ else {
43
+ return JSON.stringify(args);
44
+ }
45
+ })
46
+ .join(" ");
47
+ return asString;
48
+ }
49
+ /**
50
+ * Prompt the user for input with a message
51
+ * @param {string} text The message to show when asking for input
52
+ * @return {string} The value the user gave
53
+ */
54
+ prompt(text = "") {
55
+ return this.onEvent({
56
+ type: BackendEventType.Input,
57
+ data: text,
58
+ contentType: "text/plain",
59
+ });
60
+ }
61
+ /**
62
+ * Print values to the output screen
63
+ * @param {any[]} args The values to log
64
+ */
65
+ consoleLog(...args) {
66
+ this.queue.put(BackendEventType.Output, JavaScriptWorker.stringify(...args) + "\n", "text/plain");
67
+ }
68
+ /**
69
+ * Print values to the error screen
70
+ * @param {any[]} args The error values to log
71
+ */
72
+ consoleError(...args) {
73
+ this.queue.put(BackendEventType.Error, JavaScriptWorker.stringify(...args) + "\n", "text/plain");
74
+ }
75
+ /**
76
+ * Helper method to generate suggestions based on properties in an object
77
+ * @param {number} from Where in the document the autocompletion starts
78
+ * @param {any} object Object with properties that might be relevant
79
+ * @return {CompletionResult} Autocompletion suggestions
80
+ */
81
+ static completeProperties(from, object) {
82
+ const options = Object.keys(object).map((name) => {
83
+ return {
84
+ label: name,
85
+ type: typeof object[name] === "function" ? "function" : "variable",
86
+ };
87
+ });
88
+ return {
89
+ from,
90
+ options,
91
+ validFor: /^[\w$]*$/,
92
+ };
93
+ }
94
+ runCode(extras, code) {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ this.extras = extras;
97
+ this.queue.reset();
98
+ // Builtins to store before execution and restore afterwards
99
+ // Workers do not have access to prompt
100
+ const oldContent = {
101
+ "console.log": console.log,
102
+ "console.error": console.error,
103
+ };
104
+ // Overrides for the builtins
105
+ const newContext = {
106
+ prompt: this.prompt.bind(this),
107
+ "console.log": this.consoleLog.bind(this),
108
+ "console.error": this.consoleError.bind(this),
109
+ };
110
+ // Override the builtins
111
+ new Function("ctx", Object.keys(newContext)
112
+ .map((k) => `${k} = ctx['${k}'];`)
113
+ .join("\n"))(newContext);
114
+ let result;
115
+ try {
116
+ // run the user's code
117
+ this.onEvent({
118
+ type: BackendEventType.Start,
119
+ contentType: "text/plain",
120
+ data: "RunCode",
121
+ });
122
+ result = yield eval(code);
123
+ }
124
+ catch (error) {
125
+ // try to create a friendly traceback
126
+ Error.captureStackTrace(error);
127
+ result = yield this.onEvent({
128
+ type: BackendEventType.Error,
129
+ contentType: "application/json",
130
+ data: {
131
+ name: error.constructor.name,
132
+ what: error.message,
133
+ traceback: error.stack,
134
+ },
135
+ });
136
+ }
137
+ finally {
138
+ // restore the old builtins
139
+ new Function("ctx", Object.keys(oldContent)
140
+ .map((k) => `${k} = ctx['${k}'];`)
141
+ .join("\n"))(oldContent);
142
+ this.queue.flush();
143
+ this.onEvent({
144
+ type: BackendEventType.End,
145
+ contentType: "text/plain",
146
+ data: "CodeFinished",
147
+ });
148
+ }
149
+ return result;
150
+ });
151
+ }
152
+ lintCode() {
153
+ return __awaiter(this, void 0, void 0, function* () {
154
+ return Promise.resolve([]);
155
+ });
156
+ }
157
+ }
158
+ //# sourceMappingURL=JavaScriptWorker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JavaScriptWorker.js","sourceRoot":"","sources":["../../../../src/backend/workers/javascript/JavaScriptWorker.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAoB,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAGvE;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,OAAmB;IACrD;;;;OAIG;IACK,MAAM,CAAC,SAAS,CAAC,GAAG,IAAW;QACnC,MAAM,QAAQ,GAAG,IAAI;aAChB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YACP,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnB,OAAO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,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC/B,CAAC;KAAA;CACJ"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import * as Comlink from "comlink";
2
+ import { JavaScriptWorker } from "./JavaScriptWorker";
3
+ const worker = new JavaScriptWorker();
4
+ Comlink.expose(worker);
5
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../../src/backend/workers/javascript/worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC;AACtC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { Backend, RunMode, WorkerDiagnostic } from "../../Backend";
2
+ import { BackendEvent } from "../../../communication/BackendEvent";
3
+ import { PyodideExtras } from "pyodide-worker-runner";
4
+ /**
5
+ * Implementation of a Python backend for Papyros
6
+ * Powered by Pyodide (https://pyodide.org/)
7
+ */
8
+ export declare class PythonWorker extends Backend<PyodideExtras> {
9
+ private pyodide;
10
+ private papyros;
11
+ /**
12
+ * Promise to asynchronously install imports needed by the code
13
+ */
14
+ private installPromise;
15
+ constructor();
16
+ private static convert;
17
+ /**
18
+ * @return {any} Function to expose a method with Pyodide support
19
+ */
20
+ protected syncExpose(): any;
21
+ private static getPyodide;
22
+ launch(onEvent: (e: BackendEvent) => void): Promise<void>;
23
+ /**
24
+ * Helper method to install imports and prevent race conditions with double downloading
25
+ * @param {string} code The code containing import statements
26
+ */
27
+ private installImports;
28
+ runModes(code: string): Array<RunMode>;
29
+ runCode(extras: PyodideExtras, code: string, mode?: string): Promise<any>;
30
+ lintCode(code: string): Promise<Array<WorkerDiagnostic>>;
31
+ provideFiles(inlineFiles: Record<string, string>, hrefFiles: Record<string, string>): Promise<void>;
32
+ }
@@ -0,0 +1,117 @@
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 { Backend, RunMode } from "../../Backend";
11
+ import { pyodideExpose, loadPyodideAndPackage } from "pyodide-worker-runner";
12
+ const pythonPackageUrl = new URL("./python_package.tar.gz.load_by_url", import.meta.url).href;
13
+ /**
14
+ * Implementation of a Python backend for Papyros
15
+ * Powered by Pyodide (https://pyodide.org/)
16
+ */
17
+ export class PythonWorker extends Backend {
18
+ constructor() {
19
+ super();
20
+ this.pyodide = {};
21
+ this.installPromise = null;
22
+ }
23
+ static convert(data) {
24
+ return data.toJs ? data.toJs({ dict_converter: Object.fromEntries }) : data;
25
+ }
26
+ /**
27
+ * @return {any} Function to expose a method with Pyodide support
28
+ */
29
+ syncExpose() {
30
+ return pyodideExpose;
31
+ }
32
+ static getPyodide() {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ return yield loadPyodideAndPackage({ url: pythonPackageUrl, format: ".tgz" });
35
+ });
36
+ }
37
+ launch(onEvent) {
38
+ const _super = Object.create(null, {
39
+ launch: { get: () => super.launch }
40
+ });
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ yield _super.launch.call(this, onEvent);
43
+ this.pyodide = yield PythonWorker.getPyodide();
44
+ // Python calls our function with a PyProxy dict or a Js Map,
45
+ // These must be converted to a PapyrosEvent (JS Object) to allow message passing
46
+ this.papyros = this.pyodide.pyimport("papyros").Papyros.callKwargs({
47
+ callback: (e) => {
48
+ const converted = PythonWorker.convert(e);
49
+ return this.onEvent(converted);
50
+ },
51
+ buffer_constructor: (cb) => {
52
+ this.queue.setCallback(cb);
53
+ return this.queue;
54
+ },
55
+ });
56
+ // preload micropip to allow installing packages
57
+ yield this.pyodide.loadPackage("micropip");
58
+ });
59
+ }
60
+ /**
61
+ * Helper method to install imports and prevent race conditions with double downloading
62
+ * @param {string} code The code containing import statements
63
+ */
64
+ installImports(code) {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ var _a;
67
+ if (this.installPromise == null) {
68
+ this.installPromise = (_a = this.papyros) === null || _a === void 0 ? void 0 : _a.install_imports.callKwargs({
69
+ source_code: code,
70
+ ignore_missing: true,
71
+ });
72
+ }
73
+ yield this.installPromise;
74
+ this.installPromise = null;
75
+ });
76
+ }
77
+ runModes(code) {
78
+ var _a;
79
+ let modes = super.runModes(code);
80
+ if ((_a = this.papyros) === null || _a === void 0 ? void 0 : _a.has_doctests(code)) {
81
+ modes = [RunMode.Doctest, ...modes];
82
+ }
83
+ modes = [RunMode.Debug, ...modes];
84
+ return modes;
85
+ }
86
+ runCode(extras_1, code_1) {
87
+ return __awaiter(this, arguments, void 0, function* (extras, code, mode = "exec") {
88
+ var _a;
89
+ this.extras = extras;
90
+ if (extras.interruptBuffer) {
91
+ this.pyodide.setInterruptBuffer(extras.interruptBuffer);
92
+ }
93
+ yield this.installImports(code);
94
+ return yield ((_a = this.papyros) === null || _a === void 0 ? void 0 : _a.run_async.callKwargs({
95
+ source_code: code,
96
+ mode: mode,
97
+ }));
98
+ });
99
+ }
100
+ lintCode(code) {
101
+ return __awaiter(this, void 0, void 0, function* () {
102
+ var _a;
103
+ yield this.installImports(code);
104
+ return PythonWorker.convert(((_a = this.papyros) === null || _a === void 0 ? void 0 : _a.lint(code)) || []);
105
+ });
106
+ }
107
+ provideFiles(inlineFiles, hrefFiles) {
108
+ return __awaiter(this, void 0, void 0, function* () {
109
+ var _a;
110
+ yield ((_a = this.papyros) === null || _a === void 0 ? void 0 : _a.provide_files.callKwargs({
111
+ inline_files: JSON.stringify(inlineFiles),
112
+ href_files: JSON.stringify(hrefFiles),
113
+ }));
114
+ });
115
+ }
116
+ }
117
+ //# sourceMappingURL=PythonWorker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PythonWorker.js","sourceRoot":"","sources":["../../../../src/backend/workers/python/PythonWorker.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAoB,MAAM,eAAe,CAAC;AAInE,OAAO,EAAE,aAAa,EAAiB,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,qCAAqC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;AAE9F;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,OAAsB;IAOpD;QACI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,EAAsB,CAAC;QACtC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC/B,CAAC;IAEO,MAAM,CAAC,OAAO,CAAC,IAAS;QAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAChF,CAAC;IAED;;OAEG;IACgB,UAAU;QACzB,OAAO,aAAa,CAAC;IACzB,CAAC;IAEO,MAAM,CAAO,UAAU;;YAC3B,OAAO,MAAM,qBAAqB,CAAC,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAClF,CAAC;KAAA;IAEY,MAAM,CAAC,OAAkC;;;;;YAClD,MAAM,OAAM,MAAM,YAAC,OAAO,CAAC,CAAC;YAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,YAAY,CAAC,UAAU,EAAE,CAAC;YAC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C,OAAO,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC;QAClC,OAAO,KAAK,CAAC;IACjB,CAAC;IAEqB,OAAO;6DAAC,MAAqB,EAAE,IAAY,EAAE,IAAI,GAAG,MAAM;;YAC5E,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;gBACzB,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;YAC5D,CAAC;YACD,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAChC,OAAO,MAAM,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,SAAS,CAAC,UAAU,CAAC;gBAC5C,WAAW,EAAE,IAAI;gBACjB,IAAI,EAAE,IAAI;aACb,CAAC,CAAA,CAAC;QACP,CAAC;KAAA;IAEqB,QAAQ,CAAC,IAAY;;;YACvC,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAChC,OAAO,YAAY,CAAC,OAAO,CAAC,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,IAAI,CAAC,KAAI,EAAE,CAAC,CAAC;QAChE,CAAC;KAAA;IAEqB,YAAY,CAC9B,WAAmC,EACnC,SAAiC;;;YAEjC,MAAM,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,aAAa,CAAC,UAAU,CAAC;gBACzC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;gBACzC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;aACxC,CAAC,CAAA,CAAC;QACP,CAAC;KAAA;CACJ"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import * as Comlink from "comlink";
2
+ import { PythonWorker } from "./PythonWorker";
3
+ const worker = new PythonWorker();
4
+ Comlink.expose(worker);
5
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../../src/backend/workers/python/worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;AAClC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Enum representing all possible types for supported events
3
+ */
4
+ export declare enum BackendEventType {
5
+ Start = "start",
6
+ End = "end",
7
+ Input = "input",
8
+ Output = "output",
9
+ Sleep = "sleep",
10
+ Error = "error",
11
+ Interrupt = "interrupt",
12
+ Loading = "loading",
13
+ Frame = "frame",
14
+ FrameChange = "frame-change",
15
+ Stop = "stop"
16
+ }
17
+ /**
18
+ * Interface for events used for communication between threads
19
+ */
20
+ export interface BackendEvent {
21
+ /**
22
+ * The type of action generating this event
23
+ */
24
+ type: BackendEventType;
25
+ /**
26
+ * The actual data stored in this event
27
+ */
28
+ data: any;
29
+ /**
30
+ * The format used for the data to help with parsing
31
+ */
32
+ contentType?: string;
33
+ }