@dodona/papyros 0.1.57 → 0.1.61
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 +33 -1
- package/dist/Backend.d.ts +3 -4
- package/dist/Constants.d.ts +0 -1
- package/dist/InputManager.d.ts +3 -4
- package/dist/Papyros.d.ts +1 -2
- package/dist/index.js +1 -1
- package/dist/inputServiceWorker.js +1 -1
- package/dist/workers/input/InputWorker.d.ts +2 -4
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Papyros=e():t.Papyros=e()}(self,(function(){return(()=>{"use strict";var t,e={};(t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})})(e),function(t){t.Python="Python",t.JavaScript="JavaScript"}(t||(t={})),t.Python;var n=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function s(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}))},r=function(t,e){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=e.call(t,u)}catch(t){i=[6,t],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 t(t,e){void 0===e&&(e="__papyros_input"),this.hostName=t,this.suffix=e,this.input=""}return t.prototype.waitForInput=function(){return n(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return this.input?[3,2]:[4,(1e3,new Promise((function(t){return setTimeout(t,1e3)})))];case 1:return e.sent(),[3,0];case 2:return t=Promise.resolve(new Response(this.input)),this.input="",[2,t]}}))}))},t.prototype.handleInputRequest=function(t){return n(this,void 0,void 0,(function(){var e,n,o=this;return r(this,(function(r){return(e=t.request.url).includes(this.suffix)?("GET"===(n=t.request.method)?t.respondWith(this.waitForInput()):"POST"===n?t.respondWith(t.request.json().then((function(t){return o.input=t.input,new Response("input stored: "+o.input)}))):t.respondWith(Promise.reject(new Error("Unsupported method ".concat(n," for ").concat(this.suffix)))),[2,!0]):e.includes(this.hostName)?(t.respondWith(fetch(t.request).then((function(t){var e=new Headers(t.headers);return e.set("Cross-Origin-Embedder-Policy","require-corp"),e.set("Cross-Origin-Opener-Policy","same-origin"),e.set("Cross-Origin-Resource-Policy","cross-origin"),new Response(t.body,{status:t.status||200,statusText:t.statusText,headers:e})}))),[2,!0]):[2,!1]}))}))},t}(),i=new o(location.host);return addEventListener("fetch",(function(t){return e=this,n=void 0,o=function(){return function(t,e){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=e.call(t,u)}catch(t){i=[6,t],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(e){switch(e.label){case 0:return[4,i.handleInputRequest(t)];case 1:return e.sent()||t.respondWith(fetch(t.request)),[2]}}))},new((r=void 0)||(r=Promise))((function(t,i){function u(t){try{a(o.next(t))}catch(t){i(t)}}function s(t){try{a(o.throw(t))}catch(t){i(t)}}function a(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(u,s)}a((o=o.apply(e,n||[])).next())}));var e,n,r,o})),addEventListener("install",(function(t){t.waitUntil(skipWaiting())})),addEventListener("activate",(function(t){t.waitUntil(clients.claim())})),e})()}));
|
|
1
|
+
(()=>{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,{serviceWorkerFetchListener:()=>u,asyncSleep:()=>c,ServiceWorkerError:()=>f,writeMessageAtomics:()=>p,writeMessageServiceWorker:()=>h,writeMessage:()=>d,makeChannel:()=>v,makeAtomicsChannel:()=>y,makeServiceWorkerChannel:()=>w,readMessage:()=>m,syncSleep:()=>g,uuidv4:()=>l});var r,n=(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))},i=function(e,t){var r,n,o,i,a={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(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},a="__SyncMessageServiceWorkerInput__",s="__sync-message-v2__";function u(){var e={},t={};return function(r){var n=r.request.url;return!!n.includes(a)&&(r.respondWith(function(){return o(this,void 0,void 0,(function(){function o(e){var t={message:e,version:s};return new Response(JSON.stringify(t),{status:200})}var a,u,c,l,f,p,h,d;return i(this,(function(i){switch(i.label){case 0:return n.endsWith("/read")?[4,r.request.json()]:[3,5];case 1:return a=i.sent(),u=a.messageId,c=a.timeout,(l=e[u])?(delete e[u],[2,o(l)]):[3,2];case 2:return[4,new Promise((function(e){t[u]=e,setTimeout((function(){delete t[u],e(new Response("",{status:408}))}),c)}))];case 3:return[2,i.sent()];case 4:return[3,8];case 5:return n.endsWith("/write")?[4,r.request.json()]:[3,7];case 6:return f=i.sent(),p=f.message,h=f.messageId,(d=t[h])?(d(o(p)),delete t[h]):e[h]=p,[2,o({early:!d})];case 7:if(n.endsWith("/version"))return[2,new Response(s,{status:200})];i.label=8;case 8:return[2]}}))}))}()),!0)}}function c(e){return new Promise((function(t){return setTimeout(t,e)}))}var l,f=function(e){function t(r,n){var o=e.call(this,"Received status ".concat(n," from ").concat(r,". Ensure the service worker is registered and active."))||this;return o.url=r,o.status=n,Object.setPrototypeOf(o,t.prototype),o}return n(t,e),t}(Error);function p(e,t){var r=(new TextEncoder).encode(JSON.stringify(t)),n=e.data,o=e.meta;if(r.length>n.length)throw"Input is too long";n.set(r,0),Atomics.store(o,0,r.length),Atomics.store(o,1,1),Atomics.notify(o,1)}function h(e,t,r){return o(this,void 0,void 0,(function(){var n,o,a,u,l;return i(this,(function(i){switch(i.label){case 0:return[4,navigator.serviceWorker.ready];case 1:i.sent(),n=e.baseUrl+"/write",o=Date.now(),i.label=2;case 2:return a={message:t,messageId:r},[4,fetch(n,{method:"POST",body:JSON.stringify(a)})];case 3:return u=i.sent(),(l=200===u.status)?[4,u.json()]:[3,5];case 4:l=i.sent().version===s,i.label=5;case 5:return l?[2]:Date.now()-o<e.timeout?[4,c(100)]:[3,7];case 6:return i.sent(),[3,2];case 7:throw new f(n,u.status);case 8:return[2]}}))}))}function d(e,t,r){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return"atomics"!==e.type?[3,1]:(p(e,t),[3,3]);case 1:return[4,h(e,t,r)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))}function v(e){return void 0===e&&(e={}),"undefined"!=typeof SharedArrayBuffer?y(e.atomics):"serviceWorker"in navigator?w(e.serviceWorker):null}function y(e){var t=(void 0===e?{}:e).bufferSize;return{type:"atomics",data:new Uint8Array(new SharedArrayBuffer(t||131072)),meta:new Int32Array(new SharedArrayBuffer(2*Int32Array.BYTES_PER_ELEMENT))}}function w(e){return void 0===e&&(e={}),{type:"serviceWorker",baseUrl:(e.scope||"/")+a,timeout:e.timeout||5e3}}function b(e,t){return e>0?+e:t}function m(e,t,r){var n=void 0===r?{}:r,o=n.checkInterrupt,i=n.checkTimeout,a=n.timeout,u=performance.now();i=b(i,o?100:5e3);var c,l=b(a,Number.POSITIVE_INFINITY);if("atomics"===e.type){var p=e.data,h=e.meta;c=function(){if("timed-out"===Atomics.wait(h,1,0,i))return null;var e=Atomics.exchange(h,0,0),t=p.slice(0,e);Atomics.store(h,1,0);var r=(new TextDecoder).decode(t);return JSON.parse(r)}}else c=function(){var r=new XMLHttpRequest,n=e.baseUrl+"/read";r.open("POST",n,!1);var o={messageId:t,timeout:i};r.send(JSON.stringify(o));var a=r.status;if(408===a)return null;if(200===a){var c=JSON.parse(r.responseText);return c.version!==s?null:c.message}if(performance.now()-u<e.timeout)return null;throw new f(n,a)};for(;;){var d=l-(performance.now()-u);if(d<=0)return null;i=Math.min(i,d);var v=c();if(null!==v)return v;if(null==o?void 0:o())return null}}function g(e,t){if(e=b(e,0))if("undefined"!=typeof SharedArrayBuffer){var r=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));r[0]=0,Atomics.wait(r,0,0,e)}else m(t,"sleep ".concat(e," ").concat(l()),{timeout:e})}return l="randomUUID"in crypto?function(){return crypto.randomUUID()}:function(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(function(e){var 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 i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}(()=>{"use strict";var e=r(137),t=function(){function t(t){this.syncMessageListener=(0,e.serviceWorkerFetchListener)(),this.hostName=t}return t.prototype.handleInputRequest=function(e){return t=this,r=void 0,o=function(){var t;return function(e,t){var r,n,o,i,a={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(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,(function(r){return this.syncMessageListener(e)?[2,!0]:e.request.url.includes(this.hostName)?(t=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(t),[2,!0]):[2,!1]}))},new((n=void 0)||(n=Promise))((function(e,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function s(e){try{u(o.throw(e))}catch(e){i(e)}}function u(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n((function(e){e(r)}))).then(a,s)}u((o=o.apply(t,r||[])).next())}));var t,r,n,o},t}(),n=new t(location.host);addEventListener("fetch",(function(e){return t=this,r=void 0,i=function(){return function(e,t){var r,n,o,i,a={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(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=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,n.handleInputRequest(e)];case 1:return t.sent()||e.respondWith(fetch(e.request)),[2]}}))},new((o=void 0)||(o=Promise))((function(e,n){function a(e){try{u(i.next(e))}catch(e){n(e)}}function s(e){try{u(i.throw(e))}catch(e){n(e)}}function u(t){var r;t.done?e(t.value):(r=t.value,r instanceof o?r:new o((function(e){e(r)}))).then(a,s)}u((i=i.apply(t,r||[])).next())}));var t,r,o,i})),addEventListener("install",(function(e){e.waitUntil(skipWaiting())})),addEventListener("activate",(function(e){e.waitUntil(clients.claim())}))})()})();
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export declare class InputWorker {
|
|
2
2
|
hostName: string;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
constructor(hostName: string, suffix?: string);
|
|
6
|
-
waitForInput(): Promise<Response>;
|
|
3
|
+
syncMessageListener: (e: FetchEvent) => boolean;
|
|
4
|
+
constructor(hostName: string);
|
|
7
5
|
handleInputRequest(event: FetchEvent): Promise<boolean>;
|
|
8
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dodona/papyros",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.61",
|
|
4
4
|
"private": false,
|
|
5
5
|
"homepage": ".",
|
|
6
6
|
"devDependencies": {
|
|
@@ -52,13 +52,13 @@
|
|
|
52
52
|
"@codemirror/state": "^0.19.6",
|
|
53
53
|
"comlink": "^4.3.1",
|
|
54
54
|
"escape-html": "^1.0.3",
|
|
55
|
-
"i18n-js": "^3.8.0"
|
|
55
|
+
"i18n-js": "^3.8.0",
|
|
56
|
+
"sync-message": "^0.0.8"
|
|
56
57
|
},
|
|
57
58
|
"scripts": {
|
|
58
59
|
"start": "webpack serve --mode development",
|
|
59
60
|
"build:package": "webpack build --mode production --env=entry=./src/Library.ts",
|
|
60
61
|
"build:app": "webpack build --mode production --env=entry=./src/App.ts",
|
|
61
|
-
"install:worker": "bash scripts/InstallWorker.sh",
|
|
62
62
|
"test": "echo No tests defined yet",
|
|
63
63
|
"lint": "eslint --ext '.js' --ext '.ts' src",
|
|
64
64
|
"validate:translations": "node scripts/ValidateTranslations.js"
|