@dodona/papyros 0.1.62 → 0.1.90
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/dist/App.js +1 -0
- package/dist/Backend.d.ts +16 -6
- package/dist/Backend.js +1 -0
- package/dist/BackendManager.d.ts +10 -1
- package/dist/BackendManager.js +1 -0
- package/dist/CodeEditor.d.ts +86 -0
- package/dist/CodeEditor.js +1 -0
- package/dist/Constants.d.ts +17 -16
- package/dist/Constants.js +1 -0
- package/dist/InputManager.d.ts +24 -16
- package/dist/InputManager.js +1 -0
- package/dist/{inputServiceWorker.js → InputServiceWorker.js} +1 -1
- package/dist/{library.d.ts → Library.d.ts} +3 -2
- package/dist/Library.js +1 -0
- package/dist/OutputManager.d.ts +59 -5
- package/dist/OutputManager.js +1 -0
- package/dist/Papyros.d.ts +176 -33
- package/dist/Papyros.js +1 -0
- package/dist/PapyrosEvent.d.ts +19 -3
- package/dist/PapyrosEvent.js +1 -0
- package/dist/ProgrammingLanguage.d.ts +3 -0
- package/dist/ProgrammingLanguage.js +1 -0
- package/dist/RunListener.d.ts +13 -0
- package/dist/RunListener.js +1 -0
- package/dist/RunStateManager.d.ts +67 -0
- package/dist/RunStateManager.js +1 -0
- package/dist/Translations.js +1 -0
- package/dist/examples/Examples.js +1 -0
- package/dist/examples/JavaScriptExamples.js +1 -0
- package/dist/examples/PythonExamples.js +1 -0
- package/dist/input/BatchInputHandler.d.ts +32 -0
- package/dist/input/BatchInputHandler.js +1 -0
- package/dist/input/InteractiveInputHandler.d.ts +28 -0
- package/dist/input/InteractiveInputHandler.js +1 -0
- package/dist/input/UserInputHandler.d.ts +70 -0
- package/dist/input/UserInputHandler.js +1 -0
- package/dist/util/HTMLShapes.d.ts +13 -0
- package/dist/util/HTMLShapes.js +1 -0
- package/dist/util/Logging.d.ts +9 -0
- package/dist/util/Logging.js +1 -0
- package/dist/util/Util.d.ts +94 -2
- package/dist/util/Util.js +1 -0
- package/dist/workers/input/InputWorker.d.ts +19 -3
- package/dist/workers/input/InputWorker.js +1 -0
- package/dist/workers/python/Pyodide.d.ts +19 -0
- package/dist/workers/python/Pyodide.js +1 -0
- package/package.json +6 -5
- package/dist/StatusPanel.d.ts +0 -8
- package/dist/index.js +0 -2
- package/dist/index.js.LICENSE.txt +0 -7
package/dist/Constants.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { ProgrammingLanguage } from "./ProgrammingLanguage";
|
|
2
|
-
export declare const MAIN_APP_ID
|
|
3
|
-
export declare const OUTPUT_TA_ID
|
|
4
|
-
export declare const INPUT_AREA_WRAPPER_ID
|
|
5
|
-
export declare const INPUT_TA_ID
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
2
|
+
export declare const MAIN_APP_ID: string;
|
|
3
|
+
export declare const OUTPUT_TA_ID: string;
|
|
4
|
+
export declare const INPUT_AREA_WRAPPER_ID: string;
|
|
5
|
+
export declare const INPUT_TA_ID: string;
|
|
6
|
+
export declare const USER_INPUT_WRAPPER_ID: string;
|
|
7
|
+
export declare const EDITOR_WRAPPER_ID: string;
|
|
8
|
+
export declare const PANEL_WRAPPER_ID: string;
|
|
9
|
+
export declare const STATE_SPINNER_ID: string;
|
|
10
|
+
export declare const APPLICATION_STATE_TEXT_ID: string;
|
|
11
|
+
export declare const RUN_BTN_ID: string;
|
|
12
|
+
export declare const STOP_BTN_ID: string;
|
|
13
|
+
export declare const SEND_INPUT_BTN_ID: string;
|
|
14
|
+
export declare const SWITCH_INPUT_MODE_A_ID: string;
|
|
15
|
+
export declare const EXAMPLE_SELECT_ID: string;
|
|
16
|
+
export declare const LOCALE_SELECT_ID: string;
|
|
17
|
+
export declare const PROGRAMMING_LANGUAGE_SELECT_ID: string;
|
|
15
18
|
export declare const DEFAULT_PROGRAMMING_LANGUAGE = ProgrammingLanguage.Python;
|
|
16
|
-
export declare const EXAMPLE_SELECT_ID = "example-select";
|
|
17
|
-
export declare const LOCALE_SELECT_ID = "locale-select";
|
|
18
19
|
export declare const DEFAULT_LOCALE = "nl";
|
|
19
|
-
export declare const DEFAULT_SERVICE_WORKER = "
|
|
20
|
+
export declare const DEFAULT_SERVICE_WORKER = "InputServiceWorker.js";
|
|
@@ -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,(function(){return(()=>{"use strict";var e={905:(e,t,r)=>{var o;r.d(t,{ProgrammingLanguage:()=>o}),function(e){e.Python="Python",e.JavaScript="JavaScript"}(o||(o={}))}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var a=t[o]={exports:{}};return e[o](a,a.exports,r),a.exports}r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},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 o={};return(()=>{r.r(o),r.d(o,{MAIN_APP_ID:()=>n,OUTPUT_TA_ID:()=>a,INPUT_AREA_WRAPPER_ID:()=>_,INPUT_TA_ID:()=>p,USER_INPUT_WRAPPER_ID:()=>P,EDITOR_WRAPPER_ID:()=>i,PANEL_WRAPPER_ID:()=>u,STATE_SPINNER_ID:()=>c,APPLICATION_STATE_TEXT_ID:()=>E,RUN_BTN_ID:()=>I,STOP_BTN_ID:()=>s,SEND_INPUT_BTN_ID:()=>T,SWITCH_INPUT_MODE_A_ID:()=>A,EXAMPLE_SELECT_ID:()=>d,LOCALE_SELECT_ID:()=>l,PROGRAMMING_LANGUAGE_SELECT_ID:()=>D,DEFAULT_PROGRAMMING_LANGUAGE:()=>f,DEFAULT_LOCALE:()=>y,DEFAULT_SERVICE_WORKER:()=>R});var e=r(905);function t(e){return"__papyros-".concat(e)}var n=t("papyros"),a=t("code-output-area"),_=t("code-input-area-wrapper"),p=t("code-input-area"),P=t("user-input-wrapper"),i=t("code-area"),u=t("code-status-panel"),c=t("state-spinner"),E=t("application-state-text"),I=t("run-code-btn"),s=t("stop-btn"),T=t("send-input-btn"),A=t("switch-input-mode"),d=t("example-select"),l=t("locale-select"),D=t("programming-language-select"),f=e.ProgrammingLanguage.Python,y="nl",R="InputServiceWorker.js"})(),o})()}));
|
package/dist/InputManager.d.ts
CHANGED
|
@@ -1,32 +1,40 @@
|
|
|
1
1
|
import { PapyrosEvent } from "./PapyrosEvent";
|
|
2
2
|
import { RenderOptions } from "./util/Util";
|
|
3
3
|
import { Channel } from "sync-message";
|
|
4
|
+
import { UserInputHandler } from "./input/UserInputHandler";
|
|
5
|
+
import { RunListener } from "./RunListener";
|
|
4
6
|
export declare enum InputMode {
|
|
5
7
|
Interactive = "interactive",
|
|
6
8
|
Batch = "batch"
|
|
7
9
|
}
|
|
8
10
|
export declare const INPUT_MODES: InputMode[];
|
|
9
|
-
interface
|
|
10
|
-
|
|
11
|
+
export interface InputData {
|
|
12
|
+
prompt: string;
|
|
13
|
+
messageId: string;
|
|
11
14
|
}
|
|
12
|
-
export declare class InputManager {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
export declare class InputManager implements RunListener {
|
|
16
|
+
private _inputMode;
|
|
17
|
+
private inputHandlers;
|
|
18
|
+
private renderOptions;
|
|
19
|
+
_waiting: boolean;
|
|
20
|
+
prompt: string;
|
|
17
21
|
onSend: () => void;
|
|
18
|
-
session: InputSession;
|
|
19
22
|
channel: Channel;
|
|
20
23
|
messageId: string;
|
|
21
24
|
constructor(onSend: () => void, inputMode: InputMode);
|
|
22
|
-
|
|
23
|
-
get
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
private buildInputHandlerMap;
|
|
26
|
+
get inputMode(): InputMode;
|
|
27
|
+
set inputMode(inputMode: InputMode);
|
|
28
|
+
get inputHandler(): UserInputHandler;
|
|
29
|
+
render(options: RenderOptions): void;
|
|
30
|
+
set waiting(waiting: boolean);
|
|
31
|
+
sendLine(): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Asynchronously handle an input request by prompting the user for input
|
|
34
|
+
* @param {PapyrosEvent} e Event containing the input data
|
|
35
|
+
* @return {Promise<void>} Promise of handling the request
|
|
36
|
+
*/
|
|
37
|
+
onInput(e: PapyrosEvent): Promise<void>;
|
|
29
38
|
onRunStart(): void;
|
|
30
39
|
onRunEnd(): void;
|
|
31
40
|
}
|
|
32
|
-
export {};
|
|
@@ -0,0 +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(()=>{var t={13:function(t,e,n){var r,o;o=this,r=function(){return function(t){"use strict";var e=t&&t.I18n||{},n=Array.prototype.slice,r=function(t){return("0"+t.toString()).substr(-2)},o=function(t,e){return h("round",t,-e).toFixed(e)},i=function(t){var e=typeof t;return"function"===e||"object"===e},a=function(t){return"function"==typeof t},u=function(t){return null!=t},s=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)},l=function(t){return"string"==typeof t||"[object String]"===Object.prototype.toString.call(t)},c=function(t){return"number"==typeof t||"[object Number]"===Object.prototype.toString.call(t)},p=function(t){return!0===t||!1===t},f=function(t){return null===t},h=function(t,e,n){return void 0===n||0==+n?Math[t](e):(e=+e,n=+n,isNaN(e)||"number"!=typeof n||n%1!=0?NaN:(e=e.toString().split("e"),+((e=(e=Math[t](+(e[0]+"e"+(e[1]?+e[1]-n:-n)))).toString().split("e"))[0]+"e"+(e[1]?+e[1]+n:n))))},d=function(t,e){return a(t)?t(e):t},y=function(t,e){var n,r;for(n in e)e.hasOwnProperty(n)&&(r=e[n],l(r)||c(r)||p(r)||s(r)||f(r)?t[n]=r:(null==t[n]&&(t[n]={}),y(t[n],r)));return t},g={day_names:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbr_day_names:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],month_names:[null,"January","February","March","April","May","June","July","August","September","October","November","December"],abbr_month_names:[null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],meridian:["AM","PM"]},m={precision:3,separator:".",delimiter:",",strip_insignificant_zeros:!1},v={unit:"$",precision:2,format:"%u%n",sign_first:!0,delimiter:",",separator:"."},b={unit:"%",precision:3,format:"%n%u",separator:".",delimiter:""},w=[null,"kb","mb","gb","tb"],_={defaultLocale:"en",locale:"en",defaultSeparator:".",placeholder:/(?:\{\{|%\{)(.*?)(?:\}\}?)/gm,fallbacks:!1,translations:{},missingBehaviour:"message",missingTranslationPrefix:""};return e.reset=function(){var t;for(t in _)this[t]=_[t]},e.initializeOptions=function(){var t;for(t in _)u(this[t])||(this[t]=_[t])},e.initializeOptions(),e.locales={},e.locales.get=function(t){var n=this[t]||this[e.locale]||this.default;return a(n)&&(n=n(t)),!1===s(n)&&(n=[n]),n},e.locales.default=function(t){var n=[],r=[];return t&&n.push(t),!t&&e.locale&&n.push(e.locale),e.fallbacks&&e.defaultLocale&&n.push(e.defaultLocale),n.forEach((function(t){var n=t.split("-"),o=null,i=null;3===n.length?(o=[n[0],n[1]].join("-"),i=n[0]):2===n.length&&(o=n[0]),-1===r.indexOf(t)&&r.push(t),e.fallbacks&&[o,i].forEach((function(e){null!=e&&e!==t&&-1===r.indexOf(e)&&r.push(e)}))})),n.length||n.push("en"),r},e.pluralization={},e.pluralization.get=function(t){return this[t]||this[e.locale]||this.default},e.pluralization.default=function(t){switch(t){case 0:return["zero","other"];case 1:return["one"];default:return["other"]}},e.currentLocale=function(){return this.locale||this.defaultLocale},e.isSet=u,e.lookup=function(t,e){e=e||{};var n,r,o,i,a=this.locales.get(e.locale).slice();for(o=this.getFullScope(t,e);a.length;)if(n=a.shift(),r=o.split(e.separator||this.defaultSeparator),i=this.translations[n]){for(;r.length&&null!=(i=i[r.shift()]););if(null!=i)return i}if(u(e.defaultValue))return d(e.defaultValue,t)},e.pluralizationLookupWithoutFallback=function(t,e,n){var r,o,a=this.pluralization.get(e)(t);if(i(n))for(;a.length;)if(r=a.shift(),u(n[r])){o=n[r];break}return o},e.pluralizationLookup=function(t,e,n){n=n||{};var r,o,a,s,l=this.locales.get(n.locale).slice();for(e=this.getFullScope(e,n);l.length;)if(r=l.shift(),o=e.split(n.separator||this.defaultSeparator),a=this.translations[r]){for(;o.length&&(a=a[o.shift()],i(a));)0===o.length&&(s=this.pluralizationLookupWithoutFallback(t,r,a));if(null!=s)break}return null==s&&u(n.defaultValue)&&(s=i(n.defaultValue)?this.pluralizationLookupWithoutFallback(t,n.locale,n.defaultValue):n.defaultValue,a=n.defaultValue),{message:s,translations:a}},e.meridian=function(){var t=this.lookup("time"),e=this.lookup("date");return t&&t.am&&t.pm?[t.am,t.pm]:e&&e.meridian?e.meridian:g.meridian},e.prepareOptions=function(){for(var t,e=n.call(arguments),r={};e.length;)if("object"==typeof(t=e.shift()))for(var o in t)t.hasOwnProperty(o)&&(u(r[o])||(r[o]=t[o]));return r},e.createTranslationOptions=function(t,e){var n=[{scope:t}];return u(e.defaults)&&(n=n.concat(e.defaults)),u(e.defaultValue)&&n.push({message:e.defaultValue}),n},e.translate=function(t,e){e=e||{};var n,r=this.createTranslationOptions(t,e),o=t,a=this.prepareOptions(e);return delete a.defaultValue,r.some((function(e){if(u(e.scope)?(o=e.scope,n=this.lookup(o,a)):u(e.message)&&(n=d(e.message,t)),null!=n)return!0}),this)?("string"==typeof n?n=this.interpolate(n,e):s(n)?n=n.map((function(t){return"string"==typeof t?this.interpolate(t,e):t}),this):i(n)&&u(e.count)&&(n=this.pluralize(e.count,o,e)),n):this.missingTranslation(t,e)},e.interpolate=function(t,e){if(null==t)return t;e=e||{};var n,r,o,i,a=t.match(this.placeholder);if(!a)return t;for(;a.length;)o=(n=a.shift()).replace(this.placeholder,"$1"),r=u(e[o])?e[o].toString().replace(/\$/gm,"_#$#_"):o in e?this.nullPlaceholder(n,t,e):this.missingPlaceholder(n,t,e),i=new RegExp(n.replace(/{/gm,"\\{").replace(/}/gm,"\\}")),t=t.replace(i,r);return t.replace(/_#\$#_/g,"$")},e.pluralize=function(t,e,n){var r,o;return n=this.prepareOptions({count:String(t)},n),void 0===(o=this.pluralizationLookup(t,e,n)).translations||null==o.translations?this.missingTranslation(e,n):void 0!==o.message&&null!=o.message?this.interpolate(o.message,n):(r=this.pluralization.get(n.locale),this.missingTranslation(e+"."+r(t)[0],n))},e.missingTranslation=function(t,e){if("guess"===this.missingBehaviour){var n=t.split(".").slice(-1)[0];return(this.missingTranslationPrefix.length>0?this.missingTranslationPrefix:"")+n.replace(/_/g," ").replace(/([a-z])([A-Z])/g,(function(t,e,n){return e+" "+n.toLowerCase()}))}return'[missing "'+[null!=e&&null!=e.locale?e.locale:this.currentLocale(),this.getFullScope(t,e)].join(e.separator||this.defaultSeparator)+'" translation]'},e.missingPlaceholder=function(t,e,n){return"[missing "+t+" value]"},e.nullPlaceholder=function(){return e.missingPlaceholder.apply(e,arguments)},e.toNumber=function(t,e){e=this.prepareOptions(e,this.lookup("number.format"),m);var n,r,i=t<0,a=o(Math.abs(t),e.precision).toString().split("."),u=[],s=e.format||"%n",l=i?"-":"";for(t=a[0],n=a[1];t.length>0;)u.unshift(t.substr(Math.max(0,t.length-3),3)),t=t.substr(0,t.length-3);return r=u.join(e.delimiter),e.strip_insignificant_zeros&&n&&(n=n.replace(/0+$/,"")),e.precision>0&&n&&(r+=e.separator+n),r=(s=e.sign_first?"%s"+s:s.replace("%n","%s%n")).replace("%u",e.unit).replace("%n",r).replace("%s",l)},e.toCurrency=function(t,e){return e=this.prepareOptions(e,this.lookup("number.currency.format",e),this.lookup("number.format",e),v),this.toNumber(t,e)},e.localize=function(t,e,n){switch(n||(n={}),t){case"currency":return this.toCurrency(e,n);case"number":return t=this.lookup("number.format",n),this.toNumber(e,t);case"percentage":return this.toPercentage(e,n);default:var r;return r=t.match(/^(date|time)/)?this.toTime(t,e,n):e.toString(),this.interpolate(r,n)}},e.parseDate=function(t){var e,n,r;if(null==t)return t;if("object"==typeof t)return t;if(e=t.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2}):(\d{2})([\.,]\d{1,3})?)?(Z|\+00:?00)?/)){for(var o=1;o<=6;o++)e[o]=parseInt(e[o],10)||0;e[2]-=1,r=e[7]?1e3*("0"+e[7]):null,n=e[8]?new Date(Date.UTC(e[1],e[2],e[3],e[4],e[5],e[6],r)):new Date(e[1],e[2],e[3],e[4],e[5],e[6],r)}else"number"==typeof t?(n=new Date).setTime(t):t.match(/([A-Z][a-z]{2}) ([A-Z][a-z]{2}) (\d+) (\d+:\d+:\d+) ([+-]\d+) (\d+)/)?(n=new Date).setTime(Date.parse([RegExp.$1,RegExp.$2,RegExp.$3,RegExp.$6,RegExp.$4,RegExp.$5].join(" "))):(t.match(/\d+ \d+:\d+:\d+ [+-]\d+ \d+/),(n=new Date).setTime(Date.parse(t)));return n},e.strftime=function(t,n,o){o=this.lookup("date",o);var i=e.meridian();if(o||(o={}),o=this.prepareOptions(o,g),isNaN(t.getTime()))throw new Error("I18n.strftime() requires a valid date object, but received an invalid date.");var a=t.getDay(),u=t.getDate(),s=t.getFullYear(),l=t.getMonth()+1,c=t.getHours(),p=c,f=c>11?1:0,h=t.getSeconds(),d=t.getMinutes(),y=t.getTimezoneOffset(),m=Math.floor(Math.abs(y/60)),v=Math.abs(y)-60*m,b=(y>0?"-":"+")+(m.toString().length<2?"0"+m:m)+(v.toString().length<2?"0"+v:v);return p>12?p-=12:0===p&&(p=12),n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=n.replace("%a",o.abbr_day_names[a])).replace("%A",o.day_names[a])).replace("%b",o.abbr_month_names[l])).replace("%B",o.month_names[l])).replace("%d",r(u))).replace("%e",u)).replace("%-d",u)).replace("%H",r(c))).replace("%-H",c)).replace("%k",c)).replace("%I",r(p))).replace("%-I",p)).replace("%l",p)).replace("%m",r(l))).replace("%-m",l)).replace("%M",r(d))).replace("%-M",d)).replace("%p",i[f])).replace("%P",i[f].toLowerCase())).replace("%S",r(h))).replace("%-S",h)).replace("%w",a)).replace("%y",r(s))).replace("%-y",r(s).replace(/^0+/,""))).replace("%Y",s)).replace("%z",b)).replace("%Z",b)},e.toTime=function(t,e,n){var r=this.parseDate(e),o=this.lookup(t,n);if(null==r)return r;var i=r.toString();return i.match(/invalid/i)?i:o?this.strftime(r,o,n):i},e.toPercentage=function(t,e){return e=this.prepareOptions(e,this.lookup("number.percentage.format",e),this.lookup("number.format",e),b),this.toNumber(t,e)},e.toHumanSize=function(t,e){for(var n,r,o,i=1024,a=t,u=0;a>=i&&u<4;)a/=i,u+=1;return 0===u?(o=this.getFullScope("number.human.storage_units.units.byte",e),n=this.t(o,{count:a}),r=0):(o=this.getFullScope("number.human.storage_units.units."+w[u],e),n=this.t(o),r=a-Math.floor(a)==0?0:1),e=this.prepareOptions(e,{unit:n,precision:r,format:"%n%u",delimiter:""}),this.toNumber(a,e)},e.getFullScope=function(t,e){return e=e||{},s(t)&&(t=t.join(e.separator||this.defaultSeparator)),e.scope&&(t=[e.scope,t].join(e.separator||this.defaultSeparator)),t},e.extend=function(t,e){return void 0===t&&void 0===e?{}:y(t,e)},e.t=e.translate.bind(e),e.l=e.localize.bind(e),e.p=e.pluralize.bind(e),e}(o)}.call(e,n,e,t),void 0===r||(t.exports=r)},137:t=>{self,t.exports=(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{serviceWorkerFetchListener:()=>s,asyncSleep:()=>l,ServiceWorkerError:()=>p,writeMessageAtomics:()=>f,writeMessageServiceWorker:()=>h,writeMessage:()=>d,makeChannel:()=>y,makeAtomicsChannel:()=>g,makeServiceWorkerChannel:()=>m,readMessage:()=>b,syncSleep:()=>w,uuidv4:()=>c});var n,r=(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},i=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)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 a.label++,{value:i[1],done:!1};case 5:a.label++,r=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=e.call(t,a)}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,u])}}},a="__SyncMessageServiceWorkerInput__",u="__sync-message-v2__";function s(){var t={},e={};return function(n){var r=n.request.url;return!!r.includes(a)&&(n.respondWith(function(){return o(this,void 0,void 0,(function(){function o(t){var e={message:t,version:u};return new Response(JSON.stringify(e),{status:200})}var a,s,l,c,p,f,h,d;return i(this,(function(i){switch(i.label){case 0:return r.endsWith("/read")?[4,n.request.json()]:[3,5];case 1:return a=i.sent(),s=a.messageId,l=a.timeout,(c=t[s])?(delete t[s],[2,o(c)]):[3,2];case 2:return[4,new Promise((function(t){e[s]=t,setTimeout((function(){delete e[s],t(new Response("",{status:408}))}),l)}))];case 3:return[2,i.sent()];case 4:return[3,8];case 5:return r.endsWith("/write")?[4,n.request.json()]:[3,7];case 6:return p=i.sent(),f=p.message,h=p.messageId,(d=e[h])?(d(o(f)),delete e[h]):t[h]=f,[2,o({early:!d})];case 7:if(r.endsWith("/version"))return[2,new Response(u,{status:200})];i.label=8;case 8:return[2]}}))}))}()),!0)}}function l(t){return new Promise((function(e){return setTimeout(e,t)}))}var c,p=function(t){function e(n,r){var o=t.call(this,"Received status ".concat(r," from ").concat(n,". Ensure the service worker is registered and active."))||this;return o.url=n,o.status=r,Object.setPrototypeOf(o,e.prototype),o}return r(e,t),e}(Error);function f(t,e){var n=(new TextEncoder).encode(JSON.stringify(e)),r=t.data,o=t.meta;if(n.length>r.length)throw"Input is too long";r.set(n,0),Atomics.store(o,0,n.length),Atomics.store(o,1,1),Atomics.notify(o,1)}function h(t,e,n){return o(this,void 0,void 0,(function(){var r,o,a,s,c;return i(this,(function(i){switch(i.label){case 0:return[4,navigator.serviceWorker.ready];case 1:i.sent(),r=t.baseUrl+"/write",o=Date.now(),i.label=2;case 2:return a={message:e,messageId:n},[4,fetch(r,{method:"POST",body:JSON.stringify(a)})];case 3:return s=i.sent(),(c=200===s.status)?[4,s.json()]:[3,5];case 4:c=i.sent().version===u,i.label=5;case 5:return c?[2]:Date.now()-o<t.timeout?[4,l(100)]:[3,7];case 6:return i.sent(),[3,2];case 7:throw new p(r,s.status);case 8:return[2]}}))}))}function d(t,e,n){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return"atomics"!==t.type?[3,1]:(f(t,e),[3,3]);case 1:return[4,h(t,e,n)];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))}function y(t){return void 0===t&&(t={}),"undefined"!=typeof SharedArrayBuffer?g(t.atomics):"serviceWorker"in navigator?m(t.serviceWorker):null}function g(t){var e=(void 0===t?{}:t).bufferSize;return{type:"atomics",data:new Uint8Array(new SharedArrayBuffer(e||131072)),meta:new Int32Array(new SharedArrayBuffer(2*Int32Array.BYTES_PER_ELEMENT))}}function m(t){return void 0===t&&(t={}),{type:"serviceWorker",baseUrl:(t.scope||"/")+a,timeout:t.timeout||5e3}}function v(t,e){return t>0?+t:e}function b(t,e,n){var r=void 0===n?{}:n,o=r.checkInterrupt,i=r.checkTimeout,a=r.timeout,s=performance.now();i=v(i,o?100:5e3);var l,c=v(a,Number.POSITIVE_INFINITY);if("atomics"===t.type){var f=t.data,h=t.meta;l=function(){if("timed-out"===Atomics.wait(h,1,0,i))return null;var t=Atomics.exchange(h,0,0),e=f.slice(0,t);Atomics.store(h,1,0);var n=(new TextDecoder).decode(e);return JSON.parse(n)}}else l=function(){var n=new XMLHttpRequest,r=t.baseUrl+"/read";n.open("POST",r,!1);var o={messageId:e,timeout:i};n.send(JSON.stringify(o));var a=n.status;if(408===a)return null;if(200===a){var l=JSON.parse(n.responseText);return l.version!==u?null:l.message}if(performance.now()-s<t.timeout)return null;throw new p(r,a)};for(;;){var d=c-(performance.now()-s);if(d<=0)return null;i=Math.min(i,d);var y=l();if(null!==y)return y;if(null==o?void 0:o())return null}}function w(t,e){if(t=v(t,0))if("undefined"!=typeof SharedArrayBuffer){var n=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));n[0]=0,Atomics.wait(n,0,0,t)}else b(e,"sleep ".concat(t," ").concat(c()),{timeout:t})}return c="randomUUID"in crypto?function(){return crypto.randomUUID()}:function(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(function(t){var e=Number(t);return(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)}))},e})()},738:(t,e,n)=>{"use strict";n.d(e,{INPUT_TA_ID:()=>i,USER_INPUT_WRAPPER_ID:()=>a,SEND_INPUT_BTN_ID:()=>u,SWITCH_INPUT_MODE_A_ID:()=>s});var r=n(905);function o(t){return"__papyros-".concat(t)}o("papyros"),o("code-output-area"),o("code-input-area-wrapper");var i=o("code-input-area"),a=o("user-input-wrapper"),u=(o("code-area"),o("code-status-panel"),o("state-spinner"),o("application-state-text"),o("run-code-btn"),o("stop-btn"),o("send-input-btn")),s=o("switch-input-mode");o("example-select"),o("locale-select"),o("programming-language-select"),r.ProgrammingLanguage.Python},934:(t,e,n)=>{"use strict";n.r(e),n.d(e,{InputMode:()=>r,INPUT_MODES:()=>h,InputManager:()=>d});var r,o=n(13),i=n(738),a=n(155),u=n(924),s=n(137),l=n(410),c=n(64),p=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},f=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)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 a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.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=e.call(t,a)}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,u])}}};!function(t){t.Interactive="interactive",t.Batch="batch"}(r||(r={}));var h=[r.Batch,r.Interactive],d=function(){function t(t,e){this.messageId="",this._inputMode=e,this.channel=(0,s.makeChannel)(),this.onSend=t,this._waiting=!1,this.prompt="",this.inputHandlers=this.buildInputHandlerMap(),this.renderOptions={}}return t.prototype.buildInputHandlerMap=function(){var t=this,e=new l.InteractiveInputHandler((function(){return t.sendLine()}),i.INPUT_TA_ID,i.SEND_INPUT_BTN_ID),n=new c.BatchInputHandler((function(){return t.sendLine()}),i.INPUT_TA_ID);return new Map([[r.Interactive,e],[r.Batch,n]])},Object.defineProperty(t.prototype,"inputMode",{get:function(){return this._inputMode},set:function(t){this.inputHandler.onToggle(!1),this._inputMode=t,this.render(this.renderOptions),this.inputHandler.onToggle(!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"inputHandler",{get:function(){return this.inputHandlers.get(this.inputMode)},enumerable:!1,configurable:!0}),t.prototype.render=function(t){var e=this;this.renderOptions=t;var n=this.inputMode===r.Interactive?r.Batch:r.Interactive;(0,u.renderWithOptions)(t,'\n<div id="'.concat(i.USER_INPUT_WRAPPER_ID,'">\n</div>\n<a id="').concat(i.SWITCH_INPUT_MODE_A_ID,'" data-value="').concat(n,'"\nclass="flex flex-row-reverse hover:cursor-pointer text-blue-500">\n ').concat((0,o.t)("Papyros.input_modes.switch_to_".concat(n)),"\n</a>")),(0,u.addListener)(i.SWITCH_INPUT_MODE_A_ID,(function(t){return e.inputMode=t}),"click","data-value"),this.inputHandler.render({parentElementId:i.USER_INPUT_WRAPPER_ID}),this.inputHandler.waitWithPrompt(this._waiting,this.prompt)},Object.defineProperty(t.prototype,"waiting",{set:function(t){this._waiting=t,this.inputHandler.waitWithPrompt(t,this.prompt)},enumerable:!1,configurable:!0}),t.prototype.sendLine=function(){return p(this,void 0,void 0,(function(){var t;return f(this,(function(e){switch(e.label){case 0:return this.inputHandler.hasNext()?(t=this.inputHandler.next(),(0,a.papyrosLog)(a.LogType.Debug,"Sending input to user: "+t),[4,(0,s.writeMessage)(this.channel,t,this.messageId)]):[3,2];case 1:return e.sent(),this.waiting=!1,this.onSend(),[3,3];case 2:(0,a.papyrosLog)(a.LogType.Debug,"Had no input to send, still waiting!"),this.waiting=!0,e.label=3;case 3:return[2]}}))}))},t.prototype.onInput=function(t){return p(this,void 0,void 0,(function(){var e;return f(this,(function(n){return(0,a.papyrosLog)(a.LogType.Debug,"Handling input request in Papyros"),e=(0,u.parseEventData)(t),this.messageId=e.messageId,this.prompt=e.prompt,[2,this.sendLine()]}))}))},t.prototype.onRunStart=function(){this.waiting=!1,this.inputHandler.onRunStart()},t.prototype.onRunEnd=function(){this.prompt="",this.inputHandler.onRunEnd(),this.waiting=!1},t}()},905:(t,e,n)=>{"use strict";var r;n.d(e,{ProgrammingLanguage:()=>r}),function(t){t.Python="Python",t.JavaScript="JavaScript"}(r||(r={}))},64:(t,e,n)=>{"use strict";n.d(e,{BatchInputHandler:()=>s});var r,o=n(934),i=n(924),a=n(171),u=(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),s=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.lineNr=0,r.previousInput="",r}return u(e,t),e.prototype.onToggle=function(t){t?this.inputArea.value=this.previousInput:this.previousInput=this.inputArea.value},e.prototype.getInputMode=function(){return o.InputMode.Batch},Object.defineProperty(e.prototype,"lines",{get:function(){var t=this.inputArea.value.split("\n");return t[t.length-1]||t.splice(t.length-1),t},enumerable:!1,configurable:!0}),e.prototype.hasNext=function(){return this.lineNr<this.lines.length},e.prototype.next=function(){var t=this.lines[this.lineNr];return this.lineNr+=1,t},e.prototype.onRunStart=function(){this.lineNr=0},e.prototype.onRunEnd=function(){},e.prototype.render=function(t){var e=this,n=(0,i.renderWithOptions)(t,'\n<textarea id="'.concat(this.inputAreaId,'" \nclass="border-2 h-auto w-full max-h-1/4 px-1 overflow-auto\nfocus:outline-none focus:ring-1 focus:ring-blue-500" rows="5">\n</textarea>'));return this.inputArea.addEventListener("keydown",(function(t){e.waiting&&"enter"===t.key.toLowerCase()&&(e.lines.length<e.lineNr&&(e.lineNr=e.lines.length-1),e.onInput())})),n},e}(a.UserInputHandler)},410:(t,e,n)=>{"use strict";n.d(e,{InteractiveInputHandler:()=>s});var r,o=n(934),i=n(924),a=n(171),u=(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),s=function(t){function e(e,n,r){var o=t.call(this,e,n)||this;return o.sendButtonId=r,o}return u(e,t),Object.defineProperty(e.prototype,"sendButton",{get:function(){return(0,i.getElement)(this.sendButtonId)},enumerable:!1,configurable:!0}),e.prototype.getInputMode=function(){return o.InputMode.Interactive},e.prototype.hasNext=function(){return this.waiting},e.prototype.next=function(){var t=this.inputArea.value;return this.inputArea.value="",t},e.prototype.waitWithPrompt=function(e,n){t.prototype.waitWithPrompt.call(this,e,n),this.sendButton.disabled=!e,this.inputArea.disabled=!e,this.inputArea.disabled&&(this.inputArea.setAttribute("placeholder",""),this.inputArea.setAttribute("title",(0,i.t)("Papyros.input_disabled")))},e.prototype.onToggle=function(){this.reset()},e.prototype.onRunStart=function(){this.reset()},e.prototype.onRunEnd=function(){},e.prototype.render=function(t){var e=this,n=(0,i.renderWithOptions)(t,'\n<div class="flex flex-row">\n <input id="'.concat(this.inputAreaId,'" type="text"\n class="border border-transparent w-full mr-0.5 px-1\n disabled:cursor-not-allowed focus:outline-none focus:ring-1 focus:ring-blue-500">\n </input>\n <button id="').concat(this.sendButtonId,'" type="button"\n class="text-black bg-white border-2 px-4\n disabled:opacity-50 disabled:cursor-wait">\n ').concat((0,i.t)("Papyros.enter"),"\n </button>\n</div>"));return(0,i.getElement)(this.sendButtonId).addEventListener("click",(function(){return e.onInput()})),this.inputArea.addEventListener("keydown",(function(t){e.waiting&&"enter"===t.key.toLowerCase()&&e.onInput()})),n},e}(a.UserInputHandler)},171:(t,e,n)=>{"use strict";n.d(e,{UserInputHandler:()=>o});var r=n(924),o=function(){function t(t,e){this.waiting=!1,this.onInput=t,this.inputAreaId=e}return Object.defineProperty(t.prototype,"inputArea",{get:function(){return(0,r.getElement)(this.inputAreaId)},enumerable:!1,configurable:!0}),t.prototype.waitWithPrompt=function(t,e){var n=this;void 0===e&&(e=""),this.waiting=t,this.inputArea.setAttribute("placeholder",e||(0,r.t)("Papyros.input_placeholder.".concat(this.getInputMode()))),t&&setTimeout((function(){return n.inputArea.focus()}),0)},t.prototype.reset=function(){this.inputArea.value=""},t}()},155:(t,e,n)=>{"use strict";n.d(e,{LogType:()=>r,papyrosLog:()=>a});var r,o=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},i=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};!function(t){t[t.Debug=0]="Debug",t[t.Error=1]="Error",t[t.Important=2]="Important"}(r||(r={}));function a(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var a=t!==r.Debug;a&&(t===r.Error?console.error.apply(console,i([],o(e),!1)):console.log.apply(console,i([],o(e),!1)))}},924:(t,e,n)=>{"use strict";n.d(e,{t:()=>l,addListener:()=>c,getElement:()=>p,renderWithOptions:()=>f,parseEventData:()=>h});var r=n(13),o=n.n(r),i=(n(963),n(155)),a=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},u=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},s=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},l=o().t;function c(t,e,n,r){void 0===n&&(n="change"),void 0===r&&(r="value");var o=p(t);o.addEventListener(n,(function(){e(o[r]||o.getAttribute(r))}))}function p(t){return"string"==typeof t?document.getElementById(t):t}function f(t,e){var n,r,o,i=p(t.parentElementId);if(t.classNames&&(n=i.classList).add.apply(n,s([],u(t.classNames.split(" ")),!1)),t.attributes)try{for(var l=a(t.attributes.entries()),c=l.next();!c.done;c=l.next()){var f=u(c.value,2),h=f[0],d=f[1];i.setAttribute(h,d)}}catch(t){r={error:t}}finally{try{c&&!c.done&&(o=l.return)&&o.call(l)}finally{if(r)throw r.error}}return"string"==typeof e?i.innerHTML=e:i.replaceChildren(e),i}function h(t){var e=t.data,n=u(t.contentType.split("/"),2),r=n[0],o=n[1];switch(r){case"text":switch(o){case"plain":return e;case"json":return JSON.parse(e)}break;case"img":if("png;base64"===o)return e}return(0,i.papyrosLog)(i.LogType.Important,"Unhandled content type: ".concat(t.contentType)),e}},963:t=>{}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,n),i.exports}return n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n(934)})()}));
|
|
@@ -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(()=>{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:()=>d,writeMessage:()=>y,makeChannel:()=>h,makeAtomicsChannel:()=>v,makeServiceWorkerChannel:()=>b,readMessage:()=>w,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,d,y;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,d=f.messageId,(y=t[d])?(y(o(p)),delete t[d]):e[d]=p,[2,o({early:!y})];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 d(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 y(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,d(e,t,r)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))}function h(e){return void 0===e&&(e={}),"undefined"!=typeof SharedArrayBuffer?v(e.atomics):"serviceWorker"in navigator?b(e.serviceWorker):null}function v(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 b(e){return void 0===e&&(e={}),{type:"serviceWorker",baseUrl:(e.scope||"/")+a,timeout:e.timeout||5e3}}function m(e,t){return e>0?+e:t}function w(e,t,r){var n=void 0===r?{}:r,o=n.checkInterrupt,i=n.checkTimeout,a=n.timeout,u=performance.now();i=m(i,o?100:5e3);var c,l=m(a,Number.POSITIVE_INFINITY);if("atomics"===e.type){var p=e.data,d=e.meta;c=function(){if("timed-out"===Atomics.wait(d,1,0,i))return null;var e=Atomics.exchange(d,0,0),t=p.slice(0,e);Atomics.store(d,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 y=l-(performance.now()-u);if(y<=0)return null;i=Math.min(i,y);var h=c();if(null!==h)return h;if(null==o?void 0:o())return null}}function g(e,t){if(e=m(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 w(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}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);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}(),o=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,o.handleInputRequest(e)];case 1:return t.sent()||e.respondWith(fetch(e.request)),[2]}}))},new((n=void 0)||(n=Promise))((function(e,o){function a(e){try{u(i.next(e))}catch(e){o(e)}}function s(e){try{u(i.throw(e))}catch(e){o(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((i=i.apply(t,r||[])).next())}));var t,r,n,i})),addEventListener("install",(function(e){e.waitUntil(skipWaiting())})),addEventListener("activate",(function(e){e.waitUntil(clients.claim())}))})(),n})()}));
|
|
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(()=>{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:()=>d,writeMessage:()=>y,makeChannel:()=>h,makeAtomicsChannel:()=>v,makeServiceWorkerChannel:()=>b,readMessage:()=>w,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,d,y;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,d=f.messageId,(y=t[d])?(y(o(p)),delete t[d]):e[d]=p,[2,o({early:!y})];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 d(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 y(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,d(e,t,r)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))}function h(e){return void 0===e&&(e={}),"undefined"!=typeof SharedArrayBuffer?v(e.atomics):"serviceWorker"in navigator?b(e.serviceWorker):null}function v(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 b(e){return void 0===e&&(e={}),{type:"serviceWorker",baseUrl:(e.scope||"/")+a,timeout:e.timeout||5e3}}function m(e,t){return e>0?+e:t}function w(e,t,r){var n=void 0===r?{}:r,o=n.checkInterrupt,i=n.checkTimeout,a=n.timeout,u=performance.now();i=m(i,o?100:5e3);var c,l=m(a,Number.POSITIVE_INFINITY);if("atomics"===e.type){var p=e.data,d=e.meta;c=function(){if("timed-out"===Atomics.wait(d,1,0,i))return null;var e=Atomics.exchange(d,0,0),t=p.slice(0,e);Atomics.store(d,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 y=l-(performance.now()-u);if(y<=0)return null;i=Math.min(i,y);var h=c();if(null!==h)return h;if(null==o?void 0:o())return null}}function g(e,t){if(e=m(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 w(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})()},566:(e,t,r)=>{"use strict";r.d(t,{InputWorker:()=>a});var n=r(137),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=a.trys,(o=o.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=function(){function e(e){void 0===e&&(e=""),this.hostName=e,this.syncMessageListener=(0,n.serviceWorkerFetchListener)()}return e.prototype.handleInputRequest=function(e){return o(this,void 0,void 0,(function(){var t;return i(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])}))}))},e}()}},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}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);var e=r(566),t=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())}))},o=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=a.trys,(o=o.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])}}},i=location.href;i=i.slice(0,i.lastIndexOf("/")+1);var a=new e.InputWorker(i);addEventListener("fetch",(function(e){return t(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,a.handleInputRequest(e)];case 1:return t.sent(),[2]}}))}))})),addEventListener("install",(function(e){e.waitUntil(skipWaiting())})),addEventListener("activate",(function(e){e.waitUntil(clients.claim())}))})(),n})()}));
|
|
@@ -3,7 +3,8 @@ 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 {
|
|
6
|
+
import { RunStateManager, RunState } from "./RunStateManager";
|
|
7
|
+
import { InputWorker } from "./workers/input/InputWorker";
|
|
7
8
|
export * from "./ProgrammingLanguage";
|
|
8
9
|
export type { PapyrosEvent };
|
|
9
|
-
export { Papyros, CodeEditor,
|
|
10
|
+
export { Papyros, CodeEditor, RunState, RunStateManager, InputManager, InputMode, OutputManager, InputWorker };
|