{"version":3,"sources":["node_modules/browser-pack/_prelude.js","js-dos-ts/js-dos-build.ts","js-dos-ts/js-dos-cache-db.ts","js-dos-ts/js-dos-cache-noop.ts","js-dos-ts/js-dos-cache.ts","js-dos-ts/js-dos-ci.ts","js-dos-ts/js-dos-conf.ts","js-dos-ts/js-dos-fs.ts","js-dos-ts/js-dos-host.ts","js-dos-ts/js-dos-module.ts","js-dos-ts/js-dos-options.ts","js-dos-ts/js-dos-ui.ts","js-dos-ts/js-dos-xhr.ts","js-dos-ts/js-dos.ts"],"names":["r","e","n","t","o","i","f","c","require","u","a","Error","code","p","exports","call","length","1","module","Build","version","wasmSize","jsSize","CacheDb","onready","onerror","_this","this","_classCallCheck","storeName","indexedDB","window","mozIndexedDB","webkitIndexedDB","msIndexedDB","openRequest","open","event","onsuccess","db","result","onupgradeneeded","createObjectStore","key","data","onflush","transaction","oncomplete","objectStore","put","ondata","request","get","each","onend","_this2","openCursor","cursor","target","toString","value","continue","default","CacheNoop","js_dos_cache_db_1","js_dos_cache_noop_1","msg","log","DosCommandInterface","dos","shellInputQueue","shellInputClients","em","api","ping","_len","arguments","args","Array","_key","onping","canvas","width","height","_len2","cmd","_key2","Promise","resolve","reject","push","_iteratorNormalCompletion","_didIteratorError","_iteratorError","undefined","_step","_iterator","Symbol","iterator","next","done","err","return","requestShellInput","_this3","send","terminate","error","sendKeyPress","onframe","buffer","maxLength","shift","cmdLength","lengthBytesUTF8","stringToUTF8","_iteratorNormalCompletion2","_didIteratorError2","_iteratorError2","_step2","_iterator2","tick","jsdosconf","js_dos_xhr_1","DosFS","syncingPromise","lastSyncTime","fs","FS","registerTickListener","Date","now","syncFs","registerPauseListener","registerTerminateListener","path","chdir","url","persistentMount","type","parts","normalizePath","split","createPath","extractArchiveInCwd","Xhr","cache","responseType","fail","progress","total","loaded","onprogress","success","bytes","Uint8Array","_malloc","HEAPU8","set","retcode","_extract_zip","_free","writeOk","then","catch","mount","filesystems","IDBFS","syncfs","readOk","warn","file","body","ArrayBuffer","replace","RegExp","filename","trim","createDataFile","begin","end","part","startedAt","console","endsWith","substr","readed","readFile","_a","createFile","js_dos_build_1","DosHost","wasmSupported","global","wdosboxPromise","WebAssembly","_typeof","instantiate","compile","wmodule","Module","of","Instance","polyfill","Math","imul","b","al","bl","fround","x","clz32","trunc","ceil","floor","WDOSBOX","ondosbox","instantiateWasm","compileDosBox","instance","setTimeout","message","buildTotal","wasmUrl","status","response","promise","onreject","reason","wasmModule","info","receiveInstance","eval","Host","js_dos_ci_1","js_dos_conf_1","js_dos_fs_1","js_dos_options_1","js_dos_ui_1","DosModule","_possibleConstructorReturn","__proto__","Object","getPrototypeOf","isValid","ci","ui","tickListeners","pauseListeners","resumeListeners","terminateListeners","registerDefaultListeners","DosOptions","hidden","visibilityChange","document","mozHidden","msHidden","webkitHidden","addEventListener","pause","resume","dosbox","wdosboxUrl","DosUi","stage","SDL","defaults","widht","copyOnLock","discardOnLock","opaqueFrontBuffer","_this4","main","detach","unshift","callMain","listener","l","_iteratorNormalCompletion3","_didIteratorError3","_iteratorError3","_step3","_iterator3","_iteratorNormalCompletion4","_didIteratorError4","_iteratorError4","_step4","_iterator4","css","overlayHtml","getElementById","style","createElement","id","innerHTML","head","appendChild","parentElement","className","_container","replaceChild","overlay","container","childById","loaderMessage","show","onprogressFallback","round","hide","setAttribute","parent","childElementCount","child","children","options","resource","method","makeHttpRequest","xhr","XMLHttpRequest","setRequestHeader","overrideMimeType","progressListner","evt","errorListener","onreadystatechange","onReadyStateChange","readyState","max","indexOf","js_dos_cache_1","js_dos_host_1","js_dos_module_1","Dos","dosReadyPromise","assign","resolveDosBox","ready","runtime"],"mappings":"CAAA,SAAAA,EAAAC,EAAAC,EAAAC,GAAA,SAAAC,EAAAC,EAAAC,GAAA,IAAAJ,EAAAG,GAAA,CAAA,IAAAJ,EAAAI,GAAA,CAAA,IAAAE,EAAA,mBAAAC,SAAAA,QAAA,IAAAF,GAAAC,EAAA,OAAAA,EAAAF,GAAA,GAAA,GAAA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AI9F,gBAEtC,GAAItM,KAAKgS,QAAQvK,KAEpB,OADAzH,KAAKgS,QAAQvK,KAAKzH,KAAKiS,SAAUjS,KAAKoS,IAAI/F,OAAQ,6BACpCrM,KAAKgS,QAAQvK,cA3E3CtI,EAAAmI,IAAAA,gHCXA,IAAA0L,EAAAnU,EAAA,kBAKAoU,EAAApU,EAAA,iBACAqU,EAAArU,EAAA,mBAWA,SAAgBsU,EAAI7P,EAA2B0O,GAC3C,IAyDMoB,EAzDU,IAAIxP,QAAoB,SAACC,EAASC,GAC9C,IAAMvE,EAAS,IAAI2T,EAAA9F,UAAU9J,EAAQO,GAEhCmO,IACDA,EAAU,IAGTA,EAAQlS,UACTkS,EAAQlS,QAAU,SAACoM,GAEftC,QAAQ5E,MAAMkH,KAKtBqB,OAAO8F,OAAO9T,EAAQyS,GAQtB,IAAMlS,EAAUP,EAAOO,QACvBP,EAAOO,QAAU,SAACoM,GACdpI,EAAOoI,GAWPD,WATW,WAGH1M,EAAOO,QAFPA,GACAA,EAAQoM,GACSpM,GAEAP,EAAOyF,OAIjB,IAGnBzF,EAAOsE,UACFtE,EAAOkO,SAIZuF,EAAA7Q,QAAU5C,EAAQ,SAACgI,GAGf0L,EAAAnG,KAAKwG,cAAc/T,EAAOqP,WAAYrH,EAAOhI,OAiBrD,OANA6T,EAAgBG,MAAQ,SAAC1T,GAIrB,OAHAuT,EAAgB5K,KAAK,SAACgL,GAClB3T,EAAQ2T,EAAQpN,GAAIoN,EAAQlE,QAEzB8D,GAEJA,EAjEXjU,EAAAgU,IAAAA,EAyFC/S,OAAe+S,IAAMA","file":"js-dos.js","sourcesContent":["(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=\"function\"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error(\"Cannot find module '\"+i+\"'\");throw a.code=\"MODULE_NOT_FOUND\",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u=\"function\"==typeof require&&require,i=0;i generateBuildInfo\n\nexport const Build = {\n version: \"6.22.19 (5571198f515709ee6898e89a25b33091704ed1be)\",\n wasmSize: 2167869,\n jsSize: 472944,\n};\n","import { ICache } from \"./js-dos-cache\";\n\nexport default class CacheDb implements ICache {\n\n public version: string;\n private storeName: string = \"files\";\n private indexedDB: IDBFactory;\n private db: IDBDatabase;\n\n constructor(version: string, onready: (cache: ICache) => void, onerror: (msg: string) => void) {\n this.version = version;\n this.indexedDB = window.indexedDB || (window as any).mozIndexedDB\n || (window as any).webkitIndexedDB || (window as any).msIndexedDB;\n\n if (!this.indexedDB) {\n onerror(\"Indexed db is not supported on this host\");\n return;\n }\n\n const openRequest = this.indexedDB.open(\"gpx-bigstorage (\" + version + \")\", 1);\n openRequest.onerror = (event) => {\n onerror(\"Can't open cache database\");\n };\n openRequest.onsuccess = (event) => {\n this.db = openRequest.result;\n onready(this);\n };\n openRequest.onupgradeneeded = (event) => {\n try {\n this.db = openRequest.result;\n this.db.onerror = (event) => {\n onerror(\"Can't upgrade cache database\");\n };\n\n this.db.createObjectStore(this.storeName);\n } catch (e) {\n onerror(\"Can't upgrade cache database\");\n }\n };\n }\n\n public put(key: string, data: any, onflush: () => void) {\n const transaction = this.db.transaction(this.storeName, \"readwrite\");\n transaction.oncomplete = () => onflush();\n transaction.objectStore(this.storeName).put(data, key);\n }\n\n public get(key: string, ondata: (data: any) => void, onerror: (msg: string) => void) {\n const transaction = this.db.transaction(this.storeName, \"readonly\");\n const request = transaction.objectStore(this.storeName).get(key);\n request.onerror = () => onerror(\"Can't read value for key '\" + key + \"'\");\n request.onsuccess = () => {\n if (request.result) {\n ondata(request.result);\n } else {\n onerror(\"Result is empty for key '\" + key + \"', result: \" + request.result);\n }\n };\n }\n\n public forEach(each: (key: string, value: any) => void, onend: () => void) {\n const transaction = this.db.transaction(this.storeName, \"readonly\");\n const request = transaction.objectStore(this.storeName).openCursor();\n request.onerror = () => onerror(\"Can't open cursor on \" + this.storeName);\n request.onsuccess = (event) => {\n const cursor = (event.target as any).result as IDBCursorWithValue;\n if (cursor) {\n each(cursor.key.toString(), cursor.value);\n cursor.continue();\n } else {\n onend();\n }\n };\n }\n}\n","import { ICache } from \"./js-dos-cache\";\n\nexport default class CacheNoop implements ICache {\n public put(key: string, data: any, onflush: () => void) {\n // nothing\n }\n\n public get(key: string, ondata: (data: any) => void, onerror: (msg: string) => void) {\n onerror(\"Cache is not supported on this host\");\n }\n\n public forEach(each: (key: string, value: any) => void, onend: () => void) {\n onend();\n }\n}\n","import CacheDb from \"./js-dos-cache-db\";\nimport CacheNoop from \"./js-dos-cache-noop\";\nimport { DosModule } from \"./js-dos-module\";\n\nexport interface ICache {\n put: (key: string, data: any, onflush: () => void) => void;\n get: (key: string, ondata: (data: any) => void, onerror: (msg: string) => void) => void;\n forEach: (each: (key: string, value: any) => void, onend: () => void) => void;\n}\n\nexport default function openCache(module: DosModule, onready: (cache: ICache) => void) {\n new CacheDb(module.version, onready, (msg: string) => {\n module.log(\"ERR! Can't initalize cache, cause: \" + msg);\n onready(new CacheNoop());\n });\n}\n","// # DosCommandInterface\n// Is abstraction that allows you to control runned instance of js-dos\nimport { Dos } from \"./js-dos\";\nimport { DosModule } from \"./js-dos-module\";\nimport { Xhr } from \"./js-dos-xhr\";\n\nexport class DosCommandInterface {\n public dos: DosModule;\n private em: typeof Module;\n private api: LowLevelApi;\n private onready: (ci: DosCommandInterface) => void;\n\n private shellInputQueue: string[] = [];\n private shellInputClients: Array<() => void> = [];\n\n constructor(dos: DosModule, onready: (ci: DosCommandInterface) => void) {\n this.dos = dos;\n this.em = (dos as any);\n this.api = (dos as any);\n this.api.ping = (msg: string, ...args: any[]) => {\n this.onping(msg, args);\n };\n this.onready = onready;\n }\n\n // * `width()` - return dosbox window width in pixels\n public width() {\n return this.dos.canvas.width;\n }\n\n // * `height()` - return dosbox window height in pixels\n public height() {\n return this.dos.canvas.height;\n }\n\n // * `shell([cmd1, cmd2, ...])` - executes passed commands\n // in dosbox shell if it's runned, returns Promise that\n // resolves when commands sequence is executed\n public shell(...cmd: string[]) {\n if (cmd.length === 0) {\n return;\n }\n\n return new Promise((resolve, reject) => {\n this.shellInputClients.push(resolve);\n for (const next of cmd) {\n this.shellInputQueue.push(next);\n }\n this.requestShellInput();\n });\n }\n\n // * `screenshot()` - get screnshot of canvas as ImageData\n public screenshot() {\n return new Promise((resolve) => {\n this.api.send(\"screenshot\", \"\", (data) => {\n resolve(data);\n });\n });\n }\n\n // * `exit()` - immediately exit from runtime\n public exit() {\n try {\n this.dos.terminate();\n this.api.send(\"exit\");\n } catch (e) {\n return 0;\n }\n\n this.dos.error(\"Runtime is still alive!\");\n return -1;\n }\n\n private sendKeyPress(code: number) {\n this.api.send(\"sdl_key_event\", code + \"\");\n }\n\n private requestShellInput() {\n this.sendKeyPress(13);\n }\n\n private onping(msg: string, args: any[]) {\n switch (msg) {\n case \"ready\":\n this.onready(this);\n break;\n case \"frame\":\n this.onframe();\n break;\n case \"shell_input\":\n if (this.shellInputQueue.length === 0) {\n return;\n }\n\n const buffer: number = args[0];\n const maxLength: number = args[1];\n\n const cmd = this.shellInputQueue.shift();\n const cmdLength = (this.em as any).lengthBytesUTF8(cmd) + 1;\n\n if (cmdLength > maxLength) {\n this.dos.onerror(\"Can't execute cmd '\" + cmd +\n \"', because it's bigger then max cmd length \" + maxLength);\n return;\n }\n\n (this.em as any).stringToUTF8(cmd, buffer, cmdLength);\n\n if (this.shellInputQueue.length === 0) {\n for (const resolve of this.shellInputClients) {\n resolve();\n }\n this.shellInputClients = [];\n } else {\n this.requestShellInput();\n }\n default:\n /* do nothing */\n }\n }\n\n private onframe() {\n this.dos.tick();\n }\n}\n\ninterface LowLevelApi {\n send: (event: string, msg?: any, callback?: (msg: string) => void) => void;\n ping: (msg: string) => void;\n}\n","// # js-dos default config\n// This is default config for dosbox.\n\n/* tslint:disable:max-line-length */\nexport const jsdosconf = `\n# This is the configurationfile for DOSBox 0.74. (Please use the latest version of DOSBox)\n# Lines starting with a # are commentlines and are ignored by DOSBox.\n# They are used to (briefly) document the effect of each option.\n\n[sdl]\n# fullscreen: Start dosbox directly in fullscreen. (Press ALT-Enter to go back)\n# fulldouble: Use double buffering in fullscreen. It can reduce screen flickering, but it can also result in a slow DOSBox.\n# fullresolution: What resolution to use for fullscreen: original or fixed size (e.g. 1024x768).\n# Using your monitor's native resolution with aspect=true might give the best results.\n# If you end up with small window on a large screen, try an output different from surface.\n# windowresolution: Scale the window to this size IF the output device supports hardware scaling.\n# (output=surface does not!)\n# output: What video system to use for output.\n# Possible values: surface, overlay, opengl, openglnb.\n# autolock: Mouse will automatically lock, if you click on the screen. (Press CTRL-F10 to unlock)\n# sensitivity: Mouse sensitivity.\n# waitonerror: Wait before closing the console if dosbox has an error.\n# priority: Priority levels for dosbox. Second entry behind the comma is for when dosbox is not focused/minimized.\n# pause is only valid for the second entry.\n# Possible values: lowest, lower, normal, higher, highest, pause.\n# mapperfile: File used to load/save the key/event mappings from. Resetmapper only works with the defaul value.\n# usescancodes: Avoid usage of symkeys, might not work on all operating systems.\n\nfullscreen=false\nfulldouble=false\nfullresolution=original\nwindowresolution=original\noutput=surface\nautolock=false\nsensitivity=100\nwaitonerror=true\npriority=higher,normal\nmapperfile=mapper-jsdos.map\nusescancodes=true\nvsync=false\n\n[dosbox]\n# language: Select another language file.\n# machine: The type of machine tries to emulate.\n# Possible values: hercules, cga, tandy, pcjr, ega, vgaonly, svga_s3, svga_et3000, svga_et4000, svga_paradise, vesa_nolfb, vesa_oldvbe.\n# captures: Directory where things like wave, midi, screenshot get captured.\n# memsize: Amount of memory DOSBox has in megabytes.\n# This value is best left at its default to avoid problems with some games,\n# though few games might require a higher value.\n# There is generally no speed advantage when raising this value.\n\nlanguage=\nmachine=svga_s3\ncaptures=capture\nmemsize=16\n\n[render]\n# frameskip: How many frames DOSBox skips before drawing one.\n# aspect: Do aspect correction, if your output method doesn't support scaling this can slow things down!.\n# scaler: Scaler used to enlarge/enhance low resolution modes.\n# If 'forced' is appended, then the scaler will be used even if the result might not be desired.\n# Possible values: none, normal2x, normal3x, advmame2x, advmame3x, advinterp2x, advinterp3x, hq2x, hq3x, 2xsai, super2xsai, supereagle, tv2x, tv3x, rgb2x, rgb3x, scan2x, scan3x.\n\nframeskip=0\naspect=false\nscaler=normal2x\n\n[cpu]\n# core: CPU Core used in emulation. auto will switch to dynamic if available and appropriate.\n# Possible values: auto, dynamic, normal, simple.\n# cputype: CPU Type used in emulation. auto is the fastest choice.\n# Possible values: auto, 386, 386_slow, 486_slow, pentium_slow, 386_prefetch.\n# cycles: Amount of instructions DOSBox tries to emulate each millisecond.\n# Setting this value too high results in sound dropouts and lags.\n# Cycles can be set in 3 ways:\n# 'auto' tries to guess what a game needs.\n# It usually works, but can fail for certain games.\n# 'fixed #number' will set a fixed amount of cycles. This is what you usually need if 'auto' fails.\n# (Example: fixed 4000).\n# 'max' will allocate as much cycles as your computer is able to handle.\n#\n# Possible values: auto, fixed, max.\n# cycleup: Amount of cycles to decrease/increase with keycombo.(CTRL-F11/CTRL-F12)\n# cycledown: Setting it lower than 100 will be a percentage.\n\ncore=auto\ncputype=auto\ncycles=auto\ncycleup=10\ncycledown=20\n\n[mixer]\n# nosound: Enable silent mode, sound is still emulated though.\n# rate: Mixer sample rate, setting any device's rate higher than this will probably lower their sound quality.\n# Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716.\n# blocksize: Mixer block size, larger blocks might help sound stuttering but sound will also be more lagged.\n# Possible values: 1024, 2048, 4096, 8192, 512, 256.\n# prebuffer: How many milliseconds of data to keep on top of the blocksize.\n\nnosound=false\nrate=44100\nblocksize=1024\nprebuffer=20\n\n[midi]\n# mpu401: Type of MPU-401 to emulate.\n# Possible values: intelligent, uart, none.\n# mididevice: Device that will receive the MIDI data from MPU-401.\n# Possible values: default, win32, alsa, oss, coreaudio, coremidi, none.\n# midiconfig: Special configuration options for the device driver. This is usually the id of the device you want to use.\n# See the README/Manual for more details.\n\nmpu401=intelligent\nmididevice=default\nmidiconfig=\n\n[sblaster]\n# sbtype: Type of Soundblaster to emulate. gb is Gameblaster.\n# Possible values: sb1, sb2, sbpro1, sbpro2, sb16, gb, none.\n# sbbase: The IO address of the soundblaster.\n# Possible values: 220, 240, 260, 280, 2a0, 2c0, 2e0, 300.\n# irq: The IRQ number of the soundblaster.\n# Possible values: 7, 5, 3, 9, 10, 11, 12.\n# dma: The DMA number of the soundblaster.\n# Possible values: 1, 5, 0, 3, 6, 7.\n# hdma: The High DMA number of the soundblaster.\n# Possible values: 1, 5, 0, 3, 6, 7.\n# sbmixer: Allow the soundblaster mixer to modify the DOSBox mixer.\n# oplmode: Type of OPL emulation. On 'auto' the mode is determined by sblaster type. All OPL modes are Adlib-compatible, except for 'cms'.\n# Possible values: auto, cms, opl2, dualopl2, opl3, none.\n# oplemu: Provider for the OPL emulation. compat might provide better quality (see oplrate as well).\n# Possible values: default, compat, fast.\n# oplrate: Sample rate of OPL music emulation. Use 49716 for highest quality (set the mixer rate accordingly).\n# Possible values: 44100, 49716, 48000, 32000, 22050, 16000, 11025, 8000.\n\nsbtype=sb16\nsbbase=220\nirq=7\ndma=1\nhdma=5\nsbmixer=true\noplmode=auto\noplemu=default\noplrate=44100\n\n[gus]\n# gus: Enable the Gravis Ultrasound emulation.\n# gusrate: Sample rate of Ultrasound emulation.\n# Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716.\n# gusbase: The IO base address of the Gravis Ultrasound.\n# Possible values: 240, 220, 260, 280, 2a0, 2c0, 2e0, 300.\n# gusirq: The IRQ number of the Gravis Ultrasound.\n# Possible values: 5, 3, 7, 9, 10, 11, 12.\n# gusdma: The DMA channel of the Gravis Ultrasound.\n# Possible values: 3, 0, 1, 5, 6, 7.\n# ultradir: Path to Ultrasound directory. In this directory\n# there should be a MIDI directory that contains\n# the patch files for GUS playback. Patch sets used\n# with Timidity should work fine.\n\ngus=false\ngusrate=44100\ngusbase=240\ngusirq=5\ngusdma=3\nultradir=C:\\ULTRASND\n\n[speaker]\n# pcspeaker: Enable PC-Speaker emulation.\n# pcrate: Sample rate of the PC-Speaker sound generation.\n# Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716.\n# tandy: Enable Tandy Sound System emulation. For 'auto', emulation is present only if machine is set to 'tandy'.\n# Possible values: auto, on, off.\n# tandyrate: Sample rate of the Tandy 3-Voice generation.\n# Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716.\n# disney: Enable Disney Sound Source emulation. (Covox Voice Master and Speech Thing compatible).\n\npcspeaker=true\npcrate=44100\ntandy=auto\ntandyrate=44100\ndisney=true\n\n[joystick]\n# joysticktype: Type of joystick to emulate: auto (default), none,\n# 2axis (supports two joysticks),\n# 4axis (supports one joystick, first joystick used),\n# 4axis_2 (supports one joystick, second joystick used),\n# fcs (Thrustmaster), ch (CH Flightstick).\n# none disables joystick emulation.\n# auto chooses emulation depending on real joystick(s).\n# (Remember to reset dosbox's mapperfile if you saved it earlier)\n# Possible values: auto, 2axis, 4axis, 4axis_2, fcs, ch, none.\n# timed: enable timed intervals for axis. Experiment with this option, if your joystick drifts (away).\n# autofire: continuously fires as long as you keep the button pressed.\n# swap34: swap the 3rd and the 4th axis. can be useful for certain joysticks.\n# buttonwrap: enable button wrapping at the number of emulated buttons.\n\njoysticktype=auto\ntimed=true\nautofire=false\nswap34=false\nbuttonwrap=false\n\n[serial]\n# serial1: set type of device connected to com port.\n# Can be disabled, dummy, modem, nullmodem, directserial.\n# Additional parameters must be in the same line in the form of\n# parameter:value. Parameter for all types is irq (optional).\n# for directserial: realport (required), rxdelay (optional).\n# (realport:COM1 realport:ttyS0).\n# for modem: listenport (optional).\n# for nullmodem: server, rxdelay, txdelay, telnet, usedtr,\n# transparent, port, inhsocket (all optional).\n# Example: serial1=modem listenport:5000\n# Possible values: dummy, disabled, modem, nullmodem, directserial.\n# serial2: see serial1\n# Possible values: dummy, disabled, modem, nullmodem, directserial.\n# serial3: see serial1\n# Possible values: dummy, disabled, modem, nullmodem, directserial.\n# serial4: see serial1\n# Possible values: dummy, disabled, modem, nullmodem, directserial.\n\nserial1=dummy\nserial2=dummy\nserial3=disabled\nserial4=disabled\n\n[dos]\n# xms: Enable XMS support.\n# ems: Enable EMS support.\n# umb: Enable UMB support.\n# keyboardlayout: Language code of the keyboard layout (or none).\n\nxms=true\nems=true\numb=true\nkeyboardlayout=auto\n\n[ipx]\n# ipx: Enable ipx over UDP/IP emulation.\n\nipx=false\n\n[autoexec]\n# Lines in this section will be run at startup.\n# You can put your MOUNT lines here.\n\n# https://js-dos.com\n# █▀▀▀▀▀█ █ ▄▄▄▀▀█ █▀▀▀▀▀█\n# █ ███ █ ██▄ █ ▀ ▄ █ ███ █\n# █ ▀▀▀ █ ▄██ ▀ ▀▀█ █ ▀▀▀ █\n# ▀▀▀▀▀▀▀ ▀ █▄▀▄▀ █ ▀▀▀▀▀▀▀\n# █▀▄▄█▀▀▄▄ ▀ ▀█▄▄▄▄ ▀▄█▀█▀\n# █▀ ▀ ▀▀▄ █▀ ▄ ▄▀▀▀▄ █▀█▄\n# ▄ ▄▄ █▀▀▄ ▄▀▄▀▀█ ▀▀▄▀▀█▀\n# ▄▀▀█▀▀ █▀█▀█▀▀▄ ▀██▀█▄\n# ▀▀▀ ▀ ▀ █▄█ ▀█▄▄█▀▀▀█▀▀\n# █▀▀▀▀▀█ ▄▄▄ ▄ ▄ █ ▀ █▄▄▄▄\n# █ ███ █ ▀█▀▀▄▀▀▄████▀▀█▄█\n# █ ▀▀▀ █ ▄▀▀█▀█▀▄ ▀▀▄▄█▄█ \n# ▀▀▀▀▀▀▀ ▀ ▀▀ ▀ ▀ ▀▀▀\n`;\n","// # DosFS\n// API for working with file system of dosbox\n\nimport CacheNoop from \"./js-dos-cache-noop\";\nimport { DosModule } from \"./js-dos-module\";\nimport { Xhr } from \"./js-dos-xhr\";\n\nexport class DosFS {\n private dos: DosModule;\n private em: typeof Module;\n private fs: any;\n private syncingPromise: Promise | null = null;\n private lastSyncTime = 0;\n\n constructor(dos: DosModule) {\n this.dos = dos;\n this.em = dos as any;\n this.fs = (dos as any).FS;\n\n // Sync fs to indexed db periodically\n this.dos.registerTickListener(() => {\n if (Date.now() - this.lastSyncTime < 5000) {\n return;\n }\n this.lastSyncTime = Date.now();\n this.syncFs();\n });\n this.dos.registerPauseListener(() => this.syncFs());\n this.dos.registerTerminateListener(() => this.syncFs());\n }\n\n public chdir(path: string) {\n this.fs.chdir(path);\n }\n\n // ### extract\n public extract(url: string, persistentMount: string = \"/\", type: string = \"zip\") {\n // download archive by given url and then extract it in cwd (cwd will be mounted as C:)\n //\n // * `url` - url for downloading archive\n // * `persistentMount` - is a path to mount archive contents, by default mount point is '/' which\n // is a MEMFS that is live only in one ssesion. It means that after restart all progress will be erased.\n // If you set some path (any), then this path will be stored across sessions in indexed db. It means\n // that progress will be there after browser restart.\n // * `type` - archive type **only zip is supported**\n //\n // this method will return `Promise`, that will be resolved\n // on success with empty object or rejected\n\n persistentMount = this.normalizePath(persistentMount);\n\n const parts = persistentMount.split(\"/\");\n this.createPath(parts, 0, parts.length);\n this.chdir(persistentMount);\n\n const extractArchiveInCwd = () => {\n return new Promise((resolve, reject) => {\n if (type !== \"zip\") {\n reject(\"Only ZIP archive is supported\");\n return;\n }\n\n new Xhr(url, {\n cache: new CacheNoop(),\n responseType: \"arraybuffer\",\n fail: (msg) => reject(msg),\n progress: (total, loaded) => this.dos.onprogress(\"Downloading \" + url, total, loaded),\n success: (data: ArrayBuffer) => {\n const bytes = new Uint8Array(data);\n const buffer = this.em._malloc(bytes.length);\n this.em.HEAPU8.set(bytes, buffer);\n const retcode = (this.em as any)._extract_zip(buffer, bytes.length);\n this.em._free(buffer);\n\n if (retcode === 0) {\n this.writeOk(persistentMount);\n this.syncFs().then(resolve).catch(reject);\n } else {\n reject(\"Can't extract zip, retcode \" + retcode + \", see more info in logs\");\n }\n },\n });\n });\n };\n\n if (persistentMount === \"/\" || persistentMount.length === 0) {\n return extractArchiveInCwd();\n }\n\n return new Promise((resolve, reject) => {\n if (this.lastSyncTime > 0) {\n reject(\"Can't create persistent mount point, after syncing process starts\");\n return;\n }\n\n this.fs.mount(this.fs.filesystems.IDBFS, {}, persistentMount);\n this.fs.syncfs(true, (err: any) => {\n if (err) {\n reject(\"Can't restore FS from indexed db, cause: \" + err);\n return;\n }\n\n if (!this.readOk(persistentMount)) {\n this.dos.warn(\"Indexed db contains broken FS, resetting...\");\n extractArchiveInCwd().then(resolve).catch(reject);\n return;\n }\n\n resolve();\n });\n });\n }\n\n // ### createFile\n public createFile(file: string, body: ArrayBuffer | Uint8Array | string) {\n // [synchronous] allow to create file in FS, you can pass absolute path.\n // All directories will be created\n //\n // body can be string or ArrayBuffer or Uint8Array\n\n if (body instanceof ArrayBuffer) {\n body = new Uint8Array(body);\n }\n\n // windows style path are also valid, but **drive letter is ignored**\n // if you pass only filename, then file will be writed in root \"/\" directory\n file = file.replace(new RegExp(\"^[a-zA-z]+:\"), \"\") .replace(new RegExp(\"\\\\\\\\\", \"g\"), \"/\");\n const parts = file.split(\"/\");\n\n if (parts.length === 0) {\n this.dos.onerror(\"Can't create file '\" + file + \"', because it's not valid file path\");\n return;\n }\n\n const filename = parts[parts.length - 1].trim();\n\n if (filename.length === 0) {\n this.dos.onerror(\"Can't create file '\" + file + \"', because file name is empty\");\n return;\n }\n\n /* i < parts.length - 1, because last part is file name */\n const path = this.createPath(parts, 0, parts.length - 1);\n this.fs.createDataFile(path, filename, body, true, true, true);\n }\n\n private createPath(parts: string[], begin: number, end: number) {\n let path = \"\";\n for (let i = begin; i < end; ++i) {\n const part = parts[i].trim();\n if (part.length === 0) {\n continue;\n }\n\n this.fs.createPath(path, part, true, true);\n path = path + \"/\" + part;\n }\n\n return path;\n }\n\n private syncFs() {\n if (this.syncingPromise) {\n return this.syncingPromise;\n }\n\n this.syncingPromise = new Promise((resolve, reject) => {\n const startedAt = Date.now();\n this.fs.syncfs(false, (err: any) => {\n if (err) {\n this.dos.error(\"Can't sync FS to indexed db, cause: \" + err);\n reject(err);\n }\n this.syncingPromise = null;\n this.lastSyncTime = Date.now();\n resolve();\n console.log(\"========++> FS SYNCED, ms: \" + (Date.now() - startedAt));\n });\n });\n\n return this.syncingPromise;\n }\n\n private normalizePath(path: string) {\n if (path.length === 0 || path[0] !== \"/\") {\n path = \"/\" + path;\n }\n\n if (path.length > 1 && path.endsWith(\"/\")) {\n path = path.substr(0, path.length - 1);\n }\n\n return path;\n }\n\n private readOk(path: string) {\n try {\n const readed = this.fs.readFile(path + \"/state.fs\");\n return readed[0] === 79 && readed[1] === 70;\n } catch {\n return false;\n }\n }\n\n private writeOk(path: string) {\n this.createFile(path + \"/state.fs\", new Uint8Array([79, 70])); // Ok\n }\n\n}\n","// # DosHost\n// This class is used to detect and provide information about\n// features that supported in current environment\n\n/* tslint:disable:member-ordering */\nimport { Build } from \"./js-dos-build\";\nimport { ICache } from \"./js-dos-cache\";\nimport { DosModule } from \"./js-dos-module\";\nimport { Xhr } from \"./js-dos-xhr\";\n\nclass DosHost {\n\n public wasmSupported = false;\n public global = window as any;\n\n private wdosboxPromise: Promise = null;\n\n constructor() {\n this.global.exports = {};\n\n // ### WebAssembly\n // Host able to detect is WebAssembly supported or not,\n // this information is stored in `Host.wasmSupported` variable\n try {\n if (typeof WebAssembly === \"object\" &&\n typeof WebAssembly.instantiate === \"function\" &&\n typeof WebAssembly.compile === \"function\") {\n\n const wmodule = new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));\n if (wmodule instanceof WebAssembly.Module) {\n this.wasmSupported = new WebAssembly.Instance(wmodule) instanceof WebAssembly.Instance;\n }\n }\n } catch (error) {\n /* do nothing WebAssembly is not supported */\n }\n\n // ### polyfill\n // Host also provides limited set of polyfills to support legacy browsers\n this.polyfill();\n }\n\n // Currently polyfill contains implementations for:\n // `Math.imul`, `Math.fround`, `Math.clz32`, `Math.trunc`\n /* tslint:disable:no-bitwise */\n /* tslint:disable:only-arrow-functions */\n private polyfill() {\n if (!Math.imul || Math.imul(0xffffffff, 5) !== -5) {\n Math.imul = function imul(a: any, b: any) {\n const ah = a >>> 16;\n const al = a & 0xffff;\n const bh = b >>> 16;\n const bl = b & 0xffff;\n return (al * bl + ((ah * bl + al * bh) << 16)) | 0;\n };\n }\n Math.imul = Math.imul;\n\n if (!Math.fround) {\n Math.fround = function(x) { return x; };\n }\n Math.fround = Math.fround;\n\n if (!Math.clz32) {\n Math.clz32 = function(x) {\n x = x >>> 0;\n for (let i = 0; i < 32; i++) {\n if (x & (1 << (31 - i))) { return i; }\n }\n return 32;\n };\n }\n Math.clz32 = Math.clz32;\n\n if (!Math.trunc) {\n Math.trunc = function(x) {\n return x < 0 ? Math.ceil(x) : Math.floor(x);\n };\n }\n Math.trunc = Math.trunc;\n }\n\n // ### resolveDosBox\n // `resolveDosBox` is another important task of DosHost\n public resolveDosBox(url: string, cache: ICache, module: DosModule) {\n // When dosbox is resolved, WDOSBOX module is set to\n // global variable `exports.WDOSBOX`. This variable is\n // used to prevent next loads of same dosbox module.\n if (this.global.exports.WDOSBOX) {\n module.ondosbox(this.global.exports.WDOSBOX, this.global.exports.instantiateWasm);\n return;\n }\n\n if (!this.wasmSupported) {\n module.onerror(\"WebAssembly is not supported, can't resolve wdosbox\");\n return;\n }\n\n if (this.wdosboxPromise === null) {\n this.wdosboxPromise = this.compileDosBox(url, cache, module);\n }\n\n this.wdosboxPromise.then((instance: any) => {\n /* leave promise scope */\n const fn = () => {\n this.wdosboxPromise = null;\n module.ondosbox(this.global.exports.WDOSBOX, this.global.exports.instantiateWasm);\n };\n setTimeout(fn, 1);\n }, (message: string) => {\n /* leave promise scope */\n const fn = () => {\n this.wdosboxPromise = null;\n module.onerror(message);\n };\n setTimeout(fn, 1);\n });\n }\n\n // If dosbox is not yet resolved, then:\n private compileDosBox(url: string, cache: ICache, module: DosModule) {\n const buildTotal = Build.wasmSize + Build.jsSize;\n return new Promise((resolve, reject) => {\n const wasmUrl = url.replace(\".js\", \".wasm.js\");\n\n // * Host downloads `wdosbox` asm + js scripts\n new Xhr(wasmUrl, {\n cache,\n responseType: \"arraybuffer\",\n progress: (total, loaded) => {\n if (module.onprogress) {\n module.onprogress(\"Resolving DosBox\", buildTotal, loaded);\n }\n },\n fail: (url: string, status: number, message: string) => {\n reject(\"Can't download wasm, code: \" + status +\n \", message: \" + message + \", url: \" + url);\n },\n success: (response: any) => {\n // * Compile dosbox wasm module\n const promise = WebAssembly.compile(response);\n const onreject = (reason: any) => {\n reject(reason + \"\");\n };\n promise.catch(onreject);\n promise.then((wasmModule) => {\n this.global.exports.instantiateWasm = (info: any, receiveInstance: any) => {\n // * Instaniate it for each new dosbox runtime\n return WebAssembly.instantiate(wasmModule, info)\n .catch(onreject)\n .then((instance) => {\n receiveInstance(instance, wasmModule);\n });\n };\n\n new Xhr(url, {\n cache,\n progress: (total, loaded) => {\n if (module.onprogress) {\n module.onprogress(\"Resolving DosBox\", buildTotal, Build.wasmSize + loaded);\n }\n },\n fail: (url: string, status: number, message: string) => {\n reject(\"Can't download wdosbox.js, code: \" + status +\n \", message: \" + message + \", url: \" + url);\n },\n success: (response: string) => {\n module.onprogress(\"Resolving DosBox\", buildTotal, buildTotal);\n\n response +=\n /* tslint:disable:no-eval */\n eval.call(window, response);\n /* tslint:enable:no-eval */\n resolve(this.global.exports.WDOSBOX);\n },\n });\n });\n },\n });\n });\n }\n\n}\n\nexport const Host = new DosHost();\n","// # DosModule\n// DosModule is [emscripten module object](https://kripken.github.io/emscripten-site/docs/api_reference/module.html),\n// with additional functionality\nimport { DosRuntime } from \"./js-dos\";\nimport { Build } from \"./js-dos-build\";\nimport { DosCommandInterface } from \"./js-dos-ci\";\nimport { jsdosconf } from \"./js-dos-conf\";\nimport { DosFS } from \"./js-dos-fs\";\nimport { DosOptions } from \"./js-dos-options\";\nimport { DosUi } from \"./js-dos-ui\";\n\nexport class DosModule extends DosOptions {\n public isValid: boolean = false;\n public canvas: HTMLCanvasElement = null;\n public version = Build.version;\n private ci: Promise = null;\n private instance: any;\n private fs: DosFS = null;\n private ui: DosUi = null;\n private onready: (runtime: DosRuntime) => void;\n\n private tickListeners: Array< () => void > = [];\n private pauseListeners: Array< () => void > = [];\n private resumeListeners: Array< () => void > = [];\n private terminateListeners: Array< () => void > = [];\n\n constructor(canvas: HTMLCanvasElement, onready: (runtime: DosRuntime) => void) {\n super();\n this.canvas = canvas;\n this.onready = onready;\n\n this.registerDefaultListeners();\n }\n\n private registerDefaultListeners() {\n let hidden: string;\n let visibilityChange: string;\n\n if (typeof document.hidden !== \"undefined\") {\n hidden = \"hidden\";\n visibilityChange = \"visibilitychange\";\n } else if (typeof (document as any).mozHidden !== \"undefined\") {\n hidden = \"mozHidden\";\n visibilityChange = \"mozvisibilitychange\";\n } else if (typeof (document as any).msHidden !== \"undefined\") {\n hidden = \"msHidden\";\n visibilityChange = \"msvisibilitychange\";\n } else if (typeof (document as any).webkitHidden !== \"undefined\") {\n hidden = \"webkitHidden\";\n visibilityChange = \"webkitvisibilitychange\";\n }\n\n document.addEventListener(visibilityChange, () => {\n (document as any)[hidden] ? this.pause() : this.resume();\n }, false);\n\n window.addEventListener(\"beforeunload\", () => {\n this.terminate();\n });\n }\n\n // ### logging\n // DosModule implements simply logging features:\n // `debug`, `info`, `warn`, `error` methods\n public debug(message: string) {\n this.log(\"[DEBUG] \" + message);\n }\n\n public info(message: string) {\n this.log(\"[INFO] \" + message);\n }\n\n public warn(message: string) {\n this.log(\"[WARN] \" + message);\n }\n\n public error(message: string) {\n this.log(\"[ERROR] \" + message);\n }\n\n // ### ondosbox\n public ondosbox(dosbox: any, instantiateWasm: any) {\n this.info(\"DosBox resolved\");\n (this as any).instantiateWasm = instantiateWasm;\n this.instance = new dosbox(this);\n }\n // Method `ondosbox` is called when\n // [Host](https://js-dos.com/6.22/docs/api/generate.html?page=js-dos-host) is resolved.\n // This method instaniate wasm dosbox module with `this` as emscripten\n // module object. It means that emscripten will call\n // `this.onRuntimeInitialized` when runtime will be ready\n\n public resolve() {\n if (!this.wdosboxUrl) {\n this.wdosboxUrl = \"wdosbox.js\";\n }\n\n if (!this.log) {\n /* tslint:disable:no-console */\n this.log = (message: string) => console.log(message);\n }\n\n if (!this.canvas) {\n this.onerror(\"canvas field is required, but not set!\");\n return;\n }\n\n if (!this.onprogress) {\n this.ui = new DosUi(this);\n this.onprogress = (stage, total, loaded) => this.ui.onprogress(stage, total, loaded);\n }\n\n // ### sdl defaults\n // DosModule overrides defaults for emscripten SDL wrapper\n // for maximum performance\n (this as any).SDL = {\n defaults: {\n widht: 320,\n height: 200,\n copyOnLock: false,\n discardOnLock: true,\n opaqueFrontBuffer: false,\n },\n };\n\n this.isValid = true;\n }\n\n // ### onRuntimeInitialized\n public onRuntimeInitialized() {\n const mainFn = (args?: string[]) => {\n // When emscripten runtime is initialized and main\n // function is called:\n //\n // * DosModule detach [auto ui](https://js-dos.com/6.22/docs/api/generate.html?page=js-dos-ui)\n if (this.ui !== null) {\n this.ui.detach();\n this.ui = null;\n }\n\n if (!args) {\n args = [];\n }\n\n this.fs.chdir(\"/\");\n\n // * Write default [dosbox.conf](https://js-dos.com/6.22/docs/api/generate.html?page=js-dos-conf)\n // file to user directory\n this.fs.createFile(\"/home/web_user/.dosbox/dosbox-jsdos.conf\", jsdosconf);\n // * Mount emscripten FS as drive c:\n args.unshift(\"-userconf\", \"-c\", \"mount c .\", \"-c\", \"c:\");\n // * Run dosbox with passed arguments and resolve\n // [DosCommandInterface](https://js-dos.com/6.22/docs/api/generate.html?page=js-dos-ci)\n (this as any).callMain(args);\n return new Promise((resolve) => {\n new DosCommandInterface(this, (ci: DosCommandInterface) => {\n resolve(ci);\n });\n });\n };\n this.fs = new DosFS(this);\n this.onready({\n fs: this.fs,\n main: mainFn,\n });\n }\n\n // ### registerTickListener\n // registred tick listener it will be called each frame\n public registerTickListener(listener: () => void) {\n this.tickListeners.push(listener);\n }\n\n // ### registerPauseListener\n // registred tick listener it will be called each frame\n public registerPauseListener(listener: () => void) {\n this.pauseListeners.push(listener);\n }\n\n // ### registerResumeListener\n // registred tick listener it will be called each frame\n public registerResumeListener(listener: () => void) {\n this.resumeListeners.push(listener);\n }\n\n // ### registerTerminateListener\n // registred tick listener it will be called each frame\n public registerTerminateListener(listener: () => void) {\n this.terminateListeners.push(listener);\n }\n\n // ### tick\n // tick is called internally each frame, no need to call\n // it manually\n public tick() {\n for (const l of this.tickListeners) {\n l();\n }\n }\n\n // ### pause\n // pause is called when dosbox tab became inactive\n public pause() {\n for (const l of this.pauseListeners) {\n l();\n }\n }\n\n // ### tick\n // resume is called when dosbox tab became active\n public resume() {\n for (const l of this.resumeListeners) {\n l();\n }\n }\n\n // ### tick\n // terminate is called when dosbox tab is closed\n public terminate() {\n for (const l of this.terminateListeners) {\n l();\n }\n }\n\n}\n","// # DosOptions\n// Is a options object that you pass to constructor of\n// [Dos](https://js-dos.com/6.22/docs/api/generate.html?page=js-dos)\n// class, to configure emulation layer\nimport { DosCommandInterface } from \"./js-dos-ci\";\nimport { DosFS } from \"./js-dos-fs\";\n\nexport class DosOptions {\n\n // ### onprogress\n public onprogress?: (stage: string, total: number, loaded: number) => void;\n // progress event listener, it is fired when loading progress is changed\n // if this function is not set, then\n // [auto ui](https://js-dos.com/6.22/docs/api/generate.html?page=js-dos-ui) will be used\n // to show progress\n //\n // * `stage` - current loading stage\n // * `total` - total bytes to download on current stage\n // * `loaded` - downloaded bytes\n\n // ### onerror\n public onerror?: (message: string) => void;\n // this function is called when error happens\n //\n // * `message` - infomation about error\n\n // ### log\n public log?: (message: string) => void;\n // you can provide log function, to override logging, by default js-dos uses console.log as implementation\n\n // ### wdosboxUrl\n public wdosboxUrl?: string;\n // you can set alternative url for downloading js-dos script, default is 'wdosbox.js'\n\n}\n","// # JsDosUi\n// Optional ui module for js-dos.\n// This ui will be applied if client did not set `onprogress` in\n// [DosOptions](https://js-dos.com/6.22/docs/api/generate.html?page=js-dos-options)\nimport { DosModule } from \"./js-dos-module\";\n\nexport class DosUi {\n private canvas: HTMLCanvasElement;\n private dos: DosModule;\n\n private overlay: HTMLDivElement;\n private loaderMessage: HTMLDivElement;\n private hidden: boolean;\n\n constructor(dos: DosModule) {\n this.dos = dos;\n this.canvas = dos.canvas;\n\n // ### How it works\n // This ui replace canvas element with div .dosbox-container,\n // that contains original canvas and .dosbox-overlay as children\n // You can change style of ui by editing css for this two classes\n\n try {\n if (document.getElementById(\"js-dos-ui-css\") === null) {\n const style = document.createElement(\"style\") as HTMLStyleElement;\n style.id = \"js-dos-ui-css\";\n style.innerHTML = this.css;\n document.head.appendChild(style);\n }\n\n if (this.canvas.parentElement.className !== \"dosbox-container\") {\n const container = document.createElement(\"div\") as HTMLDivElement;\n container.className = \"dosbox-container\";\n\n const parent = this.canvas.parentElement;\n parent.replaceChild(container, this.canvas);\n container.appendChild(this.canvas);\n\n const overlay = document.createElement(\"div\") as HTMLDivElement;\n overlay.className = \"dosbox-overlay\";\n container.appendChild(overlay);\n\n overlay.innerHTML = this.overlayHtml;\n }\n\n const container = this.canvas.parentElement;\n this.overlay = this.childById(container, \"dosbox-overlay\");\n this.loaderMessage = this.childById(this.overlay, \"dosbox-loader-message\");\n\n this.hidden = true;\n this.show();\n } catch (e) {\n this.onprogress = this.onprogressFallback;\n }\n }\n\n public onprogress(stage: string, total: number, loaded: number) {\n const message = stage + \" \" + Math.round(loaded * 100 / total * 10) / 10 + \"%\";\n this.loaderMessage.innerHTML = message;\n this.dos.info(message);\n\n if (loaded >= total) {\n this.hide();\n } else {\n this.show();\n }\n }\n\n public detach() {\n this.hide();\n this.onprogress = this.onprogressFallback;\n }\n\n public hide() {\n if (this.hidden) {\n return;\n }\n this.hidden = true;\n this.overlay.setAttribute(\"style\", \"display: none\");\n }\n\n public show() {\n if (!this.hidden) {\n return;\n }\n this.hidden = false;\n this.overlay.setAttribute(\"style\", \"display: block\");\n }\n\n private onprogressFallback(stage: string, total: number, loaded: number) {\n this.dos.info(stage + \" \" + loaded * 100 / total + \"%\");\n }\n\n private childById(parent: Element, className: string) {\n if (parent === null) {\n return null;\n }\n\n for (let i = 0; i < parent.childElementCount; ++i) {\n let child = parent.children[i];\n if (child.className === className) {\n return child as HTMLDivElement;\n }\n\n child = this.childById(child, className);\n if (child !== null) {\n return child as HTMLDivElement;\n }\n }\n\n return null;\n }\n\n // ### Style\n /* tslint:disable:member-ordering */\n /* tslint:disable:max-line-length */\n private css: string = `\n .dosbox-container { position: relative; min-width: 320px; min-height: 200px; display: inline-block; }\n .dosbox-overlay, .dosbox-loader { position: absolute; left: 0; right: 0; top: 0; bottom: 0; background-color: rgba(51, 51, 51, 0.7); }\n .dosbox-start { text-align: center; position: absolute; left: 0; right: 0; bottom: 50%; color: #f80; font-size: 1.5em; text-decoration: underline; cursor: pointer; }\n .dosbox-overlay a { color: #f80; }\n .dosbox-powered { position: absolute; right: 1em; bottom: 1em; font-size: 0.8em; color: #9C9C9C; }\n .dosbox-loader-message { text-align: center; position: absolute; left: 0; right: 0; bottom: 50%; margin: 0 0 -3em 0; box-sizing: border-box; color: #f80; font-size: 1.5em; }\n @-moz-keyframes loading { 0% { left: 0; } 50% { left: 8.33333em; } 100% { left: 0; } } @-webkit-keyframes loading { 0% { left: 0; } 50% { left: 8.33333em; } 100% { left: 0; } } @keyframes loading { 0% { left: 0; } 50% { left: 8.33333em; } 100% { left: 0; } } .st-loader { width: 10em; height: 2.5em; position: absolute; top: 50%; left: 50%; margin: -1.25em 0 0 -5em; box-sizing: border-box; }\n .st-loader:before, .st-loader:after { content: \"\"; display: block; position: absolute; top: 0; bottom: 0; width: 1.25em; box-sizing: border-box; border: 0.25em solid #f80; }\n .st-loader:before { left: -0.76923em; border-right: 0; }\n .st-loader:after { right: -0.76923em; border-left: 0; }\n .st-loader .equal { display: block; position: absolute; top: 50%; margin-top: -0.5em; left: 4.16667em; height: 1em; width: 1.66667em; border: 0.25em solid #f80; box-sizing: border-box; border-width: 0.25em 0; -moz-animation: loading 1.5s infinite ease-in-out; -webkit-animation: loading 1.5s infinite ease-in-out; animation: loading 1.5s infinite ease-in-out; background: #f80; }\n `;\n\n // ### Template\n /* tslint:disable:member-ordering */\n /* tslint:disable:max-line-length */\n private overlayHtml: string = `\n
\n
\n \n
\n
\n
\n
\n Powered by  js-dos.com (6.22)\n
\n `;\n}\n","import { ICache } from \"./js-dos-cache\";\nimport CacheNoop from \"./js-dos-cache-noop\";\n\n// # Xhr\n// `Xhr` is small wrapper over XMLHttpRequest, that provides some\n// handy methods\n\n// You can configre Xhr with XhrOptions object:\ninterface XhrOptions {\n cache: ICache;\n method?: string;\n success?: (response: any) => void;\n progress?: (total: number, loaded: number) => void;\n fail?: (url: string, status: number, message: string) => void;\n data?: string;\n responseType?: XMLHttpRequestResponseType;\n}\n// * `method` - \"GET\" | \"POST\"\n// * `success` - callback when resource is downloaded\n// * `progress` - callback for progress\n// * `fail` - fail callback\n// * `data` - data for POST request, should typeof `application/x-www-form-urlencoded`\n// * `responseType` - XMLHttpRequestResponseType\n\n// Class Xhr does not have any public methods\nexport class Xhr {\n private cache: ICache;\n private resource: string;\n private options: XhrOptions;\n private xhr: XMLHttpRequest;\n private total: number = 0;\n private loaded: number = 0;\n\n constructor(url: string, options: XhrOptions) {\n this.resource = url;\n this.options = options;\n this.options.method = options.method || \"GET\";\n this.cache = options.cache || new CacheNoop();\n\n if (this.options.method === \"GET\") {\n this.cache.get(this.resource, (data) => {\n this.options.success(data);\n }, () => {\n this.makeHttpRequest();\n });\n }\n }\n\n private makeHttpRequest() {\n this.xhr = new XMLHttpRequest();\n this.xhr.open(this.options.method, this.resource, true);\n if (this.options.method === \"POST\") {\n this.xhr.setRequestHeader(\"Content-type\", \"application/x-www-form-urlencoded\");\n }\n this.xhr.overrideMimeType(\"text/plain; charset=x-user-defined\");\n\n let progressListner;\n if (typeof (progressListner = this.xhr).addEventListener === \"function\") {\n progressListner.addEventListener(\"progress\", (evt) => {\n this.total = evt.total;\n this.loaded = evt.loaded;\n if (this.options.progress) {\n return this.options.progress(evt.total, evt.loaded);\n }\n });\n }\n\n let errorListener;\n if (typeof (errorListener = this.xhr).addEventListener === \"function\") {\n errorListener.addEventListener(\"error\", (evt) => {\n if (this.options.fail) {\n this.options.fail(this.resource, this.xhr.status, \"connection problem\");\n return delete this.options.fail;\n }\n });\n }\n this.xhr.onreadystatechange = () => {\n return this.onReadyStateChange();\n };\n if (this.options.responseType) {\n this.xhr.responseType = this.options.responseType;\n }\n this.xhr.send(this.options.data);\n }\n\n private onReadyStateChange() {\n if (this.xhr.readyState === 4) {\n if (this.xhr.status === 200) {\n if (this.options.success) {\n const total = Math.max(this.total, this.loaded);\n this.options.progress(total, total);\n\n if (this.options.method === \"GET\" && this.resource.indexOf(\"?\") < 0) {\n this.cache.put(this.resource, this.xhr.response, () => { /**/ });\n }\n\n return this.options.success(this.xhr.response);\n }\n } else if (this.options.fail) {\n this.options.fail(this.resource, this.xhr.status, \"connection problem\");\n return delete this.options.fail;\n }\n }\n }\n\n}\n","\n// # Example\n// ```javascript\n// Dos(canvas).ready((fs, main) => {\n// fs.extract(\"digger.zip\").then(() => {\n// main([\"-c\", \"DIGGER.COM\"])\n// });\n// });\n// ```\n// Dos function is entry point that provides emulation layer.\n// As emulation layer js-dos uses [DosBox ported to emscripten](https://github.com/dreamlayers/em-dosbox/#compiling).\n\n// # Dos\n\nimport openCache from \"./js-dos-cache\";\nimport CacheDb from \"./js-dos-cache-db\";\nimport CacheNoop from \"./js-dos-cache-noop\";\nimport { DosCommandInterface } from \"./js-dos-ci\";\nimport { DosFS } from \"./js-dos-fs\";\nimport { Host } from \"./js-dos-host\";\nimport { DosModule } from \"./js-dos-module\";\nimport { DosOptions } from \"./js-dos-options\";\n\n// When you call `Dos(canvas, options)` js-dos behind the scene will download\n// dosbox and prepare it to start. This function will return `Promise`\n// that will be resolved when dosbox is ready. In case of error promise\n// will be rejected.\n//\n// * `canvas`: HTMLCanvasElement - this canvas element is used as window for dosbox\n// * `options`: [DosOptions](https://js-dos.com/6.22/docs/api/generate.html?page=js-dos-options) -\n// optional configuration object\nexport function Dos(canvas: HTMLCanvasElement, options?: DosOptions) {\n const promise = new Promise((resolve, reject) => {\n const module = new DosModule(canvas, resolve);\n\n if (!options) {\n options = {};\n }\n\n if (!options.onerror) {\n options.onerror = (message: string) => {\n /* tslint:disable:no-console */\n console.error(message);\n /* tslint:enable:no-console */\n };\n }\n\n Object.assign(module, options);\n\n // ### Error handling\n // Error handling should support both ways:\n //\n // * Through rejecting of promise\n // * Fire onerror function of DosOptions object\n\n const onerror = module.onerror;\n module.onerror = (message: string) => {\n reject(message);\n\n const fn = () => {\n if (onerror) {\n onerror(message);\n module.onerror = onerror;\n } else {\n module.onerror = module.error;\n }\n };\n\n setTimeout(fn, 1);\n };\n\n module.resolve();\n if (!module.isValid) {\n return;\n }\n\n openCache(module, (cache) => {\n // See [Host](https://js-dos.com/6.22/docs/api/generate.html?page=js-dos-host)\n // to understand resolving of emulation layer (dosbox).\n Host.resolveDosBox(module.wdosboxUrl, cache, module);\n });\n\n });\n\n// ### DosReadyPromise\n// Is a Promise object with additional method ready.\n// Method `ready` is just a wrapper over `then` method that\n// split resolved object into meaningful parts.\n\n const dosReadyPromise = (promise as unknown) as DosReadyPromise;\n dosReadyPromise.ready = (onready) => {\n dosReadyPromise.then((runtime: DosRuntime) => {\n onready(runtime.fs, runtime.main);\n });\n return dosReadyPromise;\n };\n return dosReadyPromise;\n}\n\nexport type DosMainFn = (args?: string[]) => Promise;\n\n// Plain promise will be resolved with `DosRuntime` interface, that\n// includes:\n//\n// * `fs`: [DosFS](https://js-dos.com/6.22/docs/api/generate.html?page=js-dos-fs) -\n// API for working with dosbox filesystem\n// * `main`: DosMainFn - a function that you should call to actuall start\n// dosbox. It's like a main function in C++, or shell command line. This function\n// will return Promise of [DosCommandInterface](https://js-dos.com/6.22/docs/api/generate.html?page=js-dos-ci).\n// You can use it to control runned dosbox.\nexport interface DosRuntime {\n fs: DosFS;\n main: DosMainFn;\n}\n\nexport interface DosReadyPromise extends Promise {\n // `onready` - callback that receive DosRuntime splitted by fields\n ready: (onready: (fs: DosFS, main: DosMainFn) => void) => Promise;\n}\n\n(window as any).Dos = Dos;\n"]}