@dodona/papyros 0.1.42 → 0.1.52

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.
@@ -1 +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,(function(){return(()=>{const e=location.href.replace("inputServiceWorker.js",""),t={input:""};function n(e){return new Promise((t=>setTimeout(t,e)))}return addEventListener("fetch",(function(s){const i=s.request.url;let o;i.includes(e)?i.includes("__papyros_input")?"GET"===s.request.method?o=async function(){for(;!t.input;)await n(1e3);const e=Promise.resolve(new Response(t.input));return t.input="",e}():"POST"===s.request.method&&(o=s.request.json().then((e=>(t.input=e.input,new Response("input stored: "+t.input))))):o=fetch(s.request).then((e=>{const 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})})):o=fetch(s.request),s.respondWith(o)})),addEventListener("install",(function(e){e.waitUntil(skipWaiting())})),addEventListener("activate",(function(e){e.waitUntil(clients.claim())})),{}})()}));
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,(function(){return(()=>{"use strict";var e,t={};(e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})})(t),function(e){e.Python="Python",e.JavaScript="JavaScript"}(e||(e={})),e.Python;var n=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,s)}a((r=r.apply(e,t||[])).next())}))},r=function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},o=function(){function e(e,t){void 0===t&&(t="__papyros_input"),this.hostName=e,this.suffix=t,this.input=""}return e.prototype.waitForInput=function(){return n(this,void 0,void 0,(function(){var e;return r(this,(function(t){switch(t.label){case 0:return this.input?[3,2]:[4,(1e3,new Promise((function(e){return setTimeout(e,1e3)})))];case 1:return t.sent(),[3,0];case 2:return e=Promise.resolve(new Response(this.input)),this.input="",[2,e]}}))}))},e.prototype.handleInputRequest=function(e){return n(this,void 0,void 0,(function(){var t,n,o=this;return r(this,(function(r){return(t=e.request.url).includes(this.hostName)?(n=Promise.resolve(new Response),t.includes(this.suffix)?"GET"===e.request.method?n=this.waitForInput():"POST"===e.request.method&&(n=e.request.json().then((function(e){return o.input=e.input,new Response("input stored: "+o.input)}))):n=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})})),e.respondWith(n),[2,!0]):[2,!1]}))}))},e}(),i=new o(location.host);return addEventListener("fetch",(function(e){return t=this,n=void 0,o=function(){return function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,(function(t){switch(t.label){case 0:return[4,i.handleInputRequest(e)];case 1:return t.sent()||e.respondWith(fetch(e.request)),[2]}}))},new((r=void 0)||(r=Promise))((function(e,i){function u(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o.throw(e))}catch(e){i(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(e){e(n)}))).then(u,s)}a((o=o.apply(t,n||[])).next())}));var t,n,r,o})),addEventListener("install",(function(e){e.waitUntil(skipWaiting())})),addEventListener("activate",(function(e){e.waitUntil(clients.claim())})),t})()}));
package/dist/library.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { CodeEditor } from "./CodeEditor";
2
- import { InputManager } from "./InputManager";
2
+ import { InputManager, InputMode } from "./InputManager";
3
3
  import { OutputManager } from "./OutputManager";
4
4
  import { Papyros } from "./Papyros";
5
5
  import { PapyrosEvent } from "./PapyrosEvent";
6
- import { ProgrammingLanguage } from "./ProgrammingLanguage";
7
6
  import { StatusPanel } from "./StatusPanel";
7
+ export * from "./ProgrammingLanguage";
8
8
  export type { PapyrosEvent };
9
- export { Papyros, CodeEditor, StatusPanel, InputManager, OutputManager, ProgrammingLanguage };
9
+ export { Papyros, CodeEditor, StatusPanel, InputManager, InputMode, OutputManager, };
@@ -1,3 +1,2 @@
1
1
  export declare const svgCircle: (id: string, color: string) => string;
2
- export declare const svgTriangle = "";
3
- export declare const inCircle: (content: string, title?: string | undefined) => string;
2
+ export declare const inCircle: (content: string, title: string, color: string) => string;
@@ -0,0 +1,8 @@
1
+ export declare class InputWorker {
2
+ hostName: string;
3
+ suffix: string;
4
+ input: string;
5
+ constructor(hostName: string, suffix?: string);
6
+ waitForInput(): Promise<Response>;
7
+ handleInputRequest(event: FetchEvent): Promise<boolean>;
8
+ }
@@ -0,0 +1,9 @@
1
+ export interface Pyodide {
2
+ runPython: (code: string, globals?: any) => any;
3
+ runPythonAsync: (code: string) => Promise<void>;
4
+ loadPackagesFromImports: (code: string) => Promise<void>;
5
+ loadPackage: (names: string | string[]) => Promise<void>;
6
+ globals: Map<string, any>;
7
+ }
8
+ export declare const PYODIDE_INDEX_URL: string;
9
+ export declare const PYODIDE_JS_URL: string;
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@dodona/papyros",
3
- "version": "0.1.42",
3
+ "version": "0.1.52",
4
4
  "private": false,
5
5
  "homepage": ".",
6
6
  "devDependencies": {
7
7
  "@babel/traverse": "^7.16.3",
8
8
  "@types/escape-html": "^1.0.1",
9
9
  "@types/i18n-js": "^3.8.2",
10
+ "@types/serviceworker": "^0.0.36",
10
11
  "@typescript-eslint/eslint-plugin": "^4.5.0",
11
12
  "@typescript-eslint/parser": "^4.5.0",
12
13
  "autoprefixer": "^10.4.0",
@@ -55,8 +56,9 @@
55
56
  },
56
57
  "scripts": {
57
58
  "start": "webpack serve --mode development",
58
- "build:package": "webpack build --mode production --env=entry=./src/library.ts",
59
+ "build:package": "webpack build --mode production --env=entry=./src/Library.ts",
59
60
  "build:app": "webpack build --mode production --env=entry=./src/App.ts",
61
+ "install:worker": "bash scripts/InstallWorker.sh",
60
62
  "test": "echo No tests defined yet",
61
63
  "lint": "eslint --ext '.js' --ext '.ts' src",
62
64
  "validate:translations": "node scripts/ValidateTranslations.js"