@dodona/papyros 0.3.1 → 0.3.5
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 +43 -27
- package/dist/Backend.d.ts +31 -0
- package/dist/BackendEvent.d.ts +2 -1
- package/dist/BackendManager.d.ts +5 -0
- package/dist/CodeEditor.d.ts +6 -2
- package/dist/CodeRunner.d.ts +29 -3
- package/dist/Constants.d.ts +6 -0
- package/dist/InputManager.d.ts +1 -2
- package/dist/Library.d.ts +8 -5
- package/dist/Library.js +1 -0
- package/dist/OutputManager.d.ts +3 -3
- package/dist/Papyros.d.ts +3 -3
- package/dist/input/BatchInputHandler.d.ts +1 -1
- package/dist/input/InteractiveInputHandler.d.ts +2 -2
- package/dist/input/UserInputHandler.d.ts +7 -1
- package/dist/util/HTMLShapes.d.ts +2 -2
- package/dist/util/Rendering.d.ts +2 -2
- package/dist/util/Util.d.ts +6 -0
- package/dist/workers/input/InputWorker.js +1 -0
- package/package.json +3 -7
package/dist/OutputManager.d.ts
CHANGED
|
@@ -41,13 +41,13 @@ export declare class OutputManager extends Renderable {
|
|
|
41
41
|
/**
|
|
42
42
|
* Retrieve the parent element containing all output parts
|
|
43
43
|
*/
|
|
44
|
-
get outputArea()
|
|
44
|
+
private get outputArea();
|
|
45
45
|
/**
|
|
46
46
|
* Render an element in the next position of the output area
|
|
47
47
|
* @param {string} html Safe string version of the next child to render
|
|
48
48
|
* @param {boolean} isNewElement Whether this a newly generated element
|
|
49
49
|
*/
|
|
50
|
-
renderNextElement
|
|
50
|
+
private renderNextElement;
|
|
51
51
|
/**
|
|
52
52
|
* Convert a piece of text to a span element for displaying
|
|
53
53
|
* @param {string} text The text content for the span
|
|
@@ -71,5 +71,5 @@ export declare class OutputManager extends Renderable {
|
|
|
71
71
|
* Clear the contents of the output area
|
|
72
72
|
*/
|
|
73
73
|
reset(): void;
|
|
74
|
-
onRunEnd
|
|
74
|
+
private onRunEnd;
|
|
75
75
|
}
|
package/dist/Papyros.d.ts
CHANGED
|
@@ -72,15 +72,15 @@ export declare class Papyros extends Renderable<PapyrosRenderOptions> {
|
|
|
72
72
|
/**
|
|
73
73
|
* Config used to initialize Papyros
|
|
74
74
|
*/
|
|
75
|
-
config
|
|
75
|
+
private config;
|
|
76
76
|
/**
|
|
77
77
|
* Component to run code entered by the user
|
|
78
78
|
*/
|
|
79
|
-
codeRunner: CodeRunner;
|
|
79
|
+
readonly codeRunner: CodeRunner;
|
|
80
80
|
/**
|
|
81
81
|
* Component to handle output generated by the user's code
|
|
82
82
|
*/
|
|
83
|
-
outputManager: OutputManager;
|
|
83
|
+
readonly outputManager: OutputManager;
|
|
84
84
|
/**
|
|
85
85
|
* Construct a new Papyros instance
|
|
86
86
|
* @param {PapyrosConfig} config Properties to configure this instance
|
|
@@ -16,7 +16,7 @@ export declare class BatchInputHandler extends UserInputHandler {
|
|
|
16
16
|
* @param {function()} inputCallback Callback for when the user has entered a value
|
|
17
17
|
*/
|
|
18
18
|
constructor(inputCallback: () => void);
|
|
19
|
-
|
|
19
|
+
toggle(active: boolean): void;
|
|
20
20
|
getInputMode(): InputMode;
|
|
21
21
|
/**
|
|
22
22
|
* Retrieve the lines of input that the user has given so far
|
|
@@ -8,12 +8,12 @@ export declare class InteractiveInputHandler extends UserInputHandler {
|
|
|
8
8
|
/**
|
|
9
9
|
* Retrieve the button that users can click to send their input
|
|
10
10
|
*/
|
|
11
|
-
get sendButton()
|
|
11
|
+
private get sendButton();
|
|
12
12
|
getInputMode(): InputMode;
|
|
13
13
|
hasNext(): boolean;
|
|
14
14
|
next(): string;
|
|
15
15
|
waitWithPrompt(waiting: boolean, prompt?: string): void;
|
|
16
|
-
|
|
16
|
+
toggle(): void;
|
|
17
17
|
onRunStart(): void;
|
|
18
18
|
onRunEnd(): void;
|
|
19
19
|
protected _render(options: RenderOptions): void;
|
|
@@ -26,7 +26,13 @@ export declare abstract class UserInputHandler extends Renderable {
|
|
|
26
26
|
* @return {string} The next value
|
|
27
27
|
*/
|
|
28
28
|
abstract next(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Method to call when a new run has started
|
|
31
|
+
*/
|
|
29
32
|
abstract onRunStart(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Method to call when the run ended
|
|
35
|
+
*/
|
|
30
36
|
abstract onRunEnd(): void;
|
|
31
37
|
/**
|
|
32
38
|
* Retrieve the InputMode corresponding to this handler
|
|
@@ -37,7 +43,7 @@ export declare abstract class UserInputHandler extends Renderable {
|
|
|
37
43
|
* Enable or disable this UserInputHandler
|
|
38
44
|
* @param {boolean} active Whether this component is active
|
|
39
45
|
*/
|
|
40
|
-
abstract
|
|
46
|
+
abstract toggle(active: boolean): void;
|
|
41
47
|
/**
|
|
42
48
|
* Retrieve the HTMLInputElement for this InputHandler
|
|
43
49
|
*/
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @param {string} borderColors The tailwind color classes for the borders of the circle
|
|
5
5
|
* @return {string} A string representation of the circle
|
|
6
6
|
*/
|
|
7
|
-
export declare
|
|
7
|
+
export declare function renderSpinningCircle(id: string, borderColors: string): string;
|
|
8
8
|
/**
|
|
9
9
|
* Wrap text (best a single character) in a circle to provide information to the user
|
|
10
10
|
* @param {string} content The symbol in the circle, e.g. ? of !
|
|
@@ -12,4 +12,4 @@ export declare const spinningCircle: (id: string, borderColors: string) => strin
|
|
|
12
12
|
* @param {string} colorClasses The classes to color the content
|
|
13
13
|
* @return {string} A string representation of the circle with content
|
|
14
14
|
*/
|
|
15
|
-
export declare
|
|
15
|
+
export declare function renderInCircle(content: string, title: string, colorClasses: string): string;
|
package/dist/util/Rendering.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ export declare function renderButton(options: ButtonOptions): string;
|
|
|
74
74
|
* @param {T} selected The initially selected element in the list, if any
|
|
75
75
|
* @return {string} The string representation of the select options
|
|
76
76
|
*/
|
|
77
|
-
export declare function renderSelectOptions<T>(options: Array<T>, optionText: (option: T) => string, selected?: T): string;
|
|
77
|
+
export declare function renderSelectOptions<T extends string>(options: Array<T>, optionText: (option: T) => string, selected?: T): string;
|
|
78
78
|
/**
|
|
79
79
|
* Build a string representation of an HTML label element
|
|
80
80
|
* @param {string} labelText Optional text to display in a label
|
|
@@ -92,7 +92,7 @@ export declare function renderLabel(labelText: string | undefined, forElement: s
|
|
|
92
92
|
* @param {string} labelText Optional text to display in a label
|
|
93
93
|
* @return {string} The string representation of the select element
|
|
94
94
|
*/
|
|
95
|
-
export declare function renderSelect<T>(selectId: string, options: Array<T>, optionText: (option: T) => string, selected?: T, labelText?: string): string;
|
|
95
|
+
export declare function renderSelect<T extends string>(selectId: string, options: Array<T>, optionText: (option: T) => string, selected?: T, labelText?: string): string;
|
|
96
96
|
/**
|
|
97
97
|
* Helper superclass to handle storing options used during rendering
|
|
98
98
|
* to allow re-rendering without needing to explicitly store used options each time
|
package/dist/util/Util.d.ts
CHANGED
|
@@ -39,4 +39,10 @@ export declare function removeSelection(selectId: string): void;
|
|
|
39
39
|
*/
|
|
40
40
|
export declare function parseData(data: string, contentType?: string): any;
|
|
41
41
|
export declare function downloadResults(data: string, filename: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Obtain the url of the current page without hashes, identifiers, query params, ...
|
|
44
|
+
* @param {boolean} endingSlash Whether the url should end in a slash
|
|
45
|
+
* @return {string} The current url
|
|
46
|
+
*/
|
|
47
|
+
export declare function cleanCurrentUrl(endingSlash?: boolean): string;
|
|
42
48
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Papyros=t():e.Papyros=t()}(self,(()=>(()=>{var e={137:e=>{self,e.exports=(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{isServiceWorkerRequest:()=>s,serviceWorkerFetchListener:()=>i,asyncSleep:()=>u,ServiceWorkerError:()=>a,writeMessageAtomics:()=>c,writeMessageServiceWorker:()=>f,writeMessage:()=>l,makeChannel:()=>d,makeAtomicsChannel:()=>y,makeServiceWorkerChannel:()=>p,readMessage:()=>h,syncSleep:()=>v,uuidv4:()=>g});var r=function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{a(n.next(e))}catch(e){s(e)}}function u(e){try{a(n.throw(e))}catch(e){s(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,u)}a((n=n.apply(e,t||[])).next())}))};const n="__SyncMessageServiceWorkerInput__",o="__sync-message-v2__";function s(e){return"string"!=typeof e&&(e=e.request.url),e.includes(n)}function i(){const e={},t={};return n=>{const{url:i}=n.request;return!!s(i)&&(n.respondWith(function(){return r(this,void 0,void 0,(function*(){function r(e){const t={message:e,version:o};return new Response(JSON.stringify(t),{status:200})}if(i.endsWith("/read")){const{messageId:o,timeout:s}=yield n.request.json(),i=e[o];return i?(delete e[o],r(i)):yield new Promise((e=>{t[o]=e,setTimeout((function(){delete t[o],e(new Response("",{status:408}))}),s)}))}if(i.endsWith("/write")){const{message:o,messageId:s}=yield n.request.json(),i=t[s];return i?(i(r(o)),delete t[s]):e[s]=o,r({early:!i})}if(i.endsWith("/version"))return new Response(o,{status:200})}))}()),!0)}}function u(e){return new Promise((t=>setTimeout(t,e)))}class a extends Error{constructor(e,t){super(`Received status ${t} from ${e}. Ensure the service worker is registered and active.`),this.url=e,this.status=t,this.type="ServiceWorkerError",Object.setPrototypeOf(this,a.prototype)}}function c(e,t){const r=(new TextEncoder).encode(JSON.stringify(t)),{data:n,meta:o}=e;if(r.length>n.length)throw new Error("Message is too big, increase bufferSize when making channel.");n.set(r,0),Atomics.store(o,0,r.length),Atomics.store(o,1,1),Atomics.notify(o,1)}function f(e,t,n){return r(this,void 0,void 0,(function*(){yield navigator.serviceWorker.ready;const r=e.baseUrl+"/write",s=Date.now();for(;;){const i={message:t,messageId:n},c=yield fetch(r,{method:"POST",body:JSON.stringify(i)});if(200===c.status&&(yield c.json()).version===o)return;if(!(Date.now()-s<e.timeout))throw new a(r,c.status);yield u(100)}}))}function l(e,t,n){return r(this,void 0,void 0,(function*(){"atomics"===e.type?c(e,t):yield f(e,t,n)}))}function d(e={}){return"undefined"!=typeof SharedArrayBuffer?y(e.atomics):"serviceWorker"in navigator?p(e.serviceWorker):null}function y({bufferSize:e}={}){return{type:"atomics",data:new Uint8Array(new SharedArrayBuffer(e||131072)),meta:new Int32Array(new SharedArrayBuffer(2*Int32Array.BYTES_PER_ELEMENT))}}function p(e={}){return{type:"serviceWorker",baseUrl:(e.scope||"/")+n,timeout:e.timeout||5e3}}function m(e,t){return e>0?+e:t}function h(e,t,{checkInterrupt:r,checkTimeout:n,timeout:s}={}){const i=performance.now();n=m(n,r?100:5e3);const u=m(s,Number.POSITIVE_INFINITY);let c;if("atomics"===e.type){const{data:t,meta:r}=e;c=()=>{if("timed-out"===Atomics.wait(r,1,0,n))return null;{const e=Atomics.exchange(r,0,0),n=t.slice(0,e);Atomics.store(r,1,0);const o=(new TextDecoder).decode(n);return JSON.parse(o)}}}else c=()=>{const r=new XMLHttpRequest,s=e.baseUrl+"/read";r.open("POST",s,!1);const u={messageId:t,timeout:n};r.send(JSON.stringify(u));const{status:c}=r;if(408===c)return null;if(200===c){const e=JSON.parse(r.responseText);return e.version!==o?null:e.message}if(performance.now()-i<e.timeout)return null;throw new a(s,c)};for(;;){const e=u-(performance.now()-i);if(e<=0)return null;n=Math.min(n,e);const t=c();if(null!==t)return t;if(null==r?void 0:r())return null}}function v(e,t){if(e=m(e,0))if("undefined"!=typeof SharedArrayBuffer){const t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));t[0]=0,Atomics.wait(t,0,0,e)}else h(t,`sleep ${e} ${g()}`,{timeout:e})}let g;return g="randomUUID"in crypto?function(){return crypto.randomUUID()}:function(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>{const t=Number(e);return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)}))},t})()}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{InputWorker:()=>s});var e=r(137),t=function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{a(n.next(e))}catch(e){s(e)}}function u(e){try{a(n.throw(e))}catch(e){s(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,u)}a((n=n.apply(e,t||[])).next())}))},o=function(e,t){var r,n,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},s=function(){function r(t){void 0===t&&(t=""),this.hostName=t,this.syncMessageListener=(0,e.serviceWorkerFetchListener)()}return r.prototype.handleInputRequest=function(e){return t(this,void 0,void 0,(function(){var t;return o(this,(function(r){return this.syncMessageListener(e)?[2,!0]:(t=e.request.url,this.hostName&&t.includes(this.hostName)?(e.respondWith(fetch(e.request).then((function(e){var t=new Headers(e.headers);return t.set("Cross-Origin-Embedder-Policy","require-corp"),t.set("Cross-Origin-Opener-Policy","same-origin"),t.set("Cross-Origin-Resource-Policy","cross-origin"),new Response(e.body,{status:e.status||200,statusText:e.statusText,headers:t})}))),[2,!0]):[2,!1])}))}))},r}()})(),n})()));
|
package/package.json
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dodona/papyros",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"homepage": ".",
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@types/escape-html": "^1.0.1",
|
|
8
8
|
"@types/i18n-js": "^3.8.2",
|
|
9
9
|
"@types/jest": "27.4.1",
|
|
10
|
-
"@types/serviceworker": "^0.0.
|
|
10
|
+
"@types/serviceworker": "^0.0.43",
|
|
11
11
|
"@typescript-eslint/eslint-plugin": "^5.21.0",
|
|
12
12
|
"@typescript-eslint/parser": "^5.21.0",
|
|
13
13
|
"autoprefixer": "^10.4.0",
|
|
14
14
|
"css-loader": "^6.5.1",
|
|
15
15
|
"eslint": "^7.11.0",
|
|
16
16
|
"eslint-config-google": "^0.14.0",
|
|
17
|
-
"eslint-plugin-flowtype": "^7.0.0",
|
|
18
|
-
"eslint-plugin-import": "^2.22.1",
|
|
19
17
|
"eslint-plugin-jest": "^26.1.5",
|
|
20
|
-
"eslint-webpack-plugin": "^3.1.1",
|
|
21
18
|
"i18n-extract": "^0.6.7",
|
|
22
19
|
"jest": "27.0.0",
|
|
23
20
|
"postcss": "^8.3.11",
|
|
24
21
|
"postcss-import": "^14.0.2",
|
|
25
22
|
"postcss-loader": "^6.2.0",
|
|
26
|
-
"raw-loader": "^4.0.2",
|
|
27
23
|
"style-loader": "^3.3.1",
|
|
28
24
|
"tailwindcss": "^3.0.24",
|
|
29
25
|
"terser-webpack-plugin": "^5.3.1",
|
|
@@ -51,7 +47,7 @@
|
|
|
51
47
|
"comsync": "^0.0.8",
|
|
52
48
|
"escape-html": "^1.0.3",
|
|
53
49
|
"i18n-js": "^3.8.0",
|
|
54
|
-
"pyodide-worker-runner": "^0.0.
|
|
50
|
+
"pyodide-worker-runner": "^0.0.10",
|
|
55
51
|
"sync-message": "^0.0.10"
|
|
56
52
|
},
|
|
57
53
|
"scripts": {
|