mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-18 03:05:35 +00:00
8 lines
18 KiB
Plaintext
8 lines
18 KiB
Plaintext
{
|
|
"version": 3,
|
|
"sources": ["../node_modules/file-saver/src/FileSaver.js", "../src/common/recorder.ts", "../src/platform/_index.ts"],
|
|
"sourcesContent": ["/*\n* FileSaver.js\n* A saveAs() FileSaver implementation.\n*\n* By Eli Grey, http://eligrey.com\n*\n* License : https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md (MIT)\n* source : http://purl.eligrey.com/github/FileSaver.js\n*/\n\n// The one and only way of getting global scope in all environments\n// https://stackoverflow.com/q/3277182/1008999\nvar _global = typeof window === 'object' && window.window === window\n ? window : typeof self === 'object' && self.self === self\n ? self : typeof global === 'object' && global.global === global\n ? global\n : this\n\nfunction bom (blob, opts) {\n if (typeof opts === 'undefined') opts = { autoBom: false }\n else if (typeof opts !== 'object') {\n console.warn('Deprecated: Expected third argument to be a object')\n opts = { autoBom: !opts }\n }\n\n // prepend BOM for UTF-8 XML and text/* types (including HTML)\n // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF\n if (opts.autoBom && /^\\s*(?:text\\/\\S*|application\\/xml|\\S*\\/\\S*\\+xml)\\s*;.*charset\\s*=\\s*utf-8/i.test(blob.type)) {\n return new Blob([String.fromCharCode(0xFEFF), blob], { type: blob.type })\n }\n return blob\n}\n\nfunction download (url, name, opts) {\n var xhr = new XMLHttpRequest()\n xhr.open('GET', url)\n xhr.responseType = 'blob'\n xhr.onload = function () {\n saveAs(xhr.response, name, opts)\n }\n xhr.onerror = function () {\n console.error('could not download file')\n }\n xhr.send()\n}\n\nfunction corsEnabled (url) {\n var xhr = new XMLHttpRequest()\n // use sync to avoid popup blocker\n xhr.open('HEAD', url, false)\n try {\n xhr.send()\n } catch (e) {}\n return xhr.status >= 200 && xhr.status <= 299\n}\n\n// `a.click()` doesn't work for all browsers (#465)\nfunction click (node) {\n try {\n node.dispatchEvent(new MouseEvent('click'))\n } catch (e) {\n var evt = document.createEvent('MouseEvents')\n evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80,\n 20, false, false, false, false, 0, null)\n node.dispatchEvent(evt)\n }\n}\n\n// Detect WebView inside a native macOS app by ruling out all browsers\n// We just need to check for 'Safari' because all other browsers (besides Firefox) include that too\n// https://www.whatismybrowser.com/guides/the-latest-user-agent/macos\nvar isMacOSWebView = _global.navigator && /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent)\n\nvar saveAs = _global.saveAs || (\n // probably in some web worker\n (typeof window !== 'object' || window !== _global)\n ? function saveAs () { /* noop */ }\n\n // Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView\n : ('download' in HTMLAnchorElement.prototype && !isMacOSWebView)\n ? function saveAs (blob, name, opts) {\n var URL = _global.URL || _global.webkitURL\n var a = document.createElement('a')\n name = name || blob.name || 'download'\n\n a.download = name\n a.rel = 'noopener' // tabnabbing\n\n // TODO: detect chrome extensions & packaged apps\n // a.target = '_blank'\n\n if (typeof blob === 'string') {\n // Support regular links\n a.href = blob\n if (a.origin !== location.origin) {\n corsEnabled(a.href)\n ? download(blob, name, opts)\n : click(a, a.target = '_blank')\n } else {\n click(a)\n }\n } else {\n // Support blobs\n a.href = URL.createObjectURL(blob)\n setTimeout(function () { URL.revokeObjectURL(a.href) }, 4E4) // 40s\n setTimeout(function () { click(a) }, 0)\n }\n }\n\n // Use msSaveOrOpenBlob as a second approach\n : 'msSaveOrOpenBlob' in navigator\n ? function saveAs (blob, name, opts) {\n name = name || blob.name || 'download'\n\n if (typeof blob === 'string') {\n if (corsEnabled(blob)) {\n download(blob, name, opts)\n } else {\n var a = document.createElement('a')\n a.href = blob\n a.target = '_blank'\n setTimeout(function () { click(a) })\n }\n } else {\n navigator.msSaveOrOpenBlob(bom(blob, opts), name)\n }\n }\n\n // Fallback to using FileReader and a popup\n : function saveAs (blob, name, opts, popup) {\n // Open a popup immediately do go around popup blocker\n // Mostly only available on user interaction and the fileReader is async so...\n popup = popup || open('', '_blank')\n if (popup) {\n popup.document.title =\n popup.document.body.innerText = 'downloading...'\n }\n\n if (typeof blob === 'string') return download(blob, name, opts)\n\n var force = blob.type === 'application/octet-stream'\n var isSafari = /constructor/i.test(_global.HTMLElement) || _global.safari\n var isChromeIOS = /CriOS\\/[\\d]+/.test(navigator.userAgent)\n\n if ((isChromeIOS || (force && isSafari) || isMacOSWebView) && typeof FileReader !== 'undefined') {\n // Safari doesn't allow downloading of blob URLs\n var reader = new FileReader()\n reader.onloadend = function () {\n var url = reader.result\n url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, 'data:attachment/file;')\n if (popup) popup.location.href = url\n else location = url\n popup = null // reverse-tabnabbing #460\n }\n reader.readAsDataURL(blob)\n } else {\n var URL = _global.URL || _global.webkitURL\n var url = URL.createObjectURL(blob)\n if (popup) popup.location = url\n else location.href = url\n popup = null // reverse-tabnabbing #460\n setTimeout(function () { URL.revokeObjectURL(url) }, 4E4) // 40s\n }\n }\n)\n\n_global.saveAs = saveAs.saveAs = saveAs\n\nif (typeof module !== 'undefined') {\n module.exports = saveAs;\n}\n", "\nimport { Platform, EmuState, EmuControlsState, EmuRecorder } from \"./baseplatform\";\nimport { getNoiseSeed, setNoiseSeed } from \"./emu\";\n\n// RECORDER\n\ntype FrameRec = {controls:EmuControlsState, seed:number};\n\nexport class StateRecorderImpl implements EmuRecorder {\n \n checkpointInterval : number = 10;\n callbackStateChanged : () => void;\n callbackNewCheckpoint : (state:EmuState) => void;\n maxCheckpoints : number = 300;\n \n platform : Platform;\n checkpoints : EmuState[];\n framerecs : FrameRec[];\n frameCount : number;\n lastSeekFrame : number;\n lastSeekStep : number;\n lastStepCount : number;\n \n constructor(platform : Platform) {\n this.reset();\n this.platform = platform;\n }\n\n reset() {\n this.checkpoints = [];\n this.framerecs = [];\n this.frameCount = 0;\n this.lastSeekFrame = 0;\n this.lastSeekStep = 0;\n this.lastStepCount = 0;\n if (this.callbackStateChanged) this.callbackStateChanged();\n }\n\n frameRequested() : boolean {\n var controls = {\n controls:this.platform.saveControlsState(),\n seed:getNoiseSeed()\n };\n var requested = false;\n // are we replaying? then we don't need to save a frame, just replace controls\n if (this.lastSeekFrame < this.frameCount) {\n this.loadControls(this.lastSeekFrame);\n } else {\n // record the control state, if available\n if (this.platform.saveControlsState) {\n this.framerecs.push(controls);\n }\n // time to save next frame?\n requested = (this.frameCount++ % this.checkpointInterval) == 0;\n }\n this.lastSeekFrame++;\n this.lastSeekStep = 0;\n if (this.callbackStateChanged) this.callbackStateChanged();\n return requested;\n }\n \n numFrames() : number {\n return this.frameCount;\n }\n \n currentFrame() : number {\n return this.lastSeekFrame;\n }\n\n currentStep() : number {\n return this.lastSeekStep;\n }\n\n recordFrame(state : EmuState) {\n this.checkpoints.push(state);\n if (this.callbackNewCheckpoint) this.callbackNewCheckpoint(state);\n // checkpoints full?\n if (this.checkpoints.length > this.maxCheckpoints) {\n this.checkpoints.shift(); // remove 1st checkpoint\n this.framerecs = this.framerecs.slice(this.checkpointInterval);\n this.lastSeekFrame -= this.checkpointInterval;\n this.frameCount -= this.checkpointInterval;\n if (this.callbackStateChanged) this.callbackStateChanged();\n }\n }\n\n getStateAtOrBefore(frame : number) : {frame : number, state : EmuState} {\n // initial frame?\n if (frame <= 0 && this.checkpoints.length > 0)\n return {frame:0, state:this.checkpoints[0]};\n\n var bufidx = Math.floor(frame / this.checkpointInterval);\n var foundidx = bufidx < this.checkpoints.length ? bufidx : this.checkpoints.length-1;\n var foundframe = foundidx * this.checkpointInterval;\n return {frame:foundframe, state:this.checkpoints[foundidx]};\n }\n\n loadFrame(seekframe : number, seekstep? : number) : number {\n seekframe |= 0;\n seekstep |= 0;\n if (seekframe == this.lastSeekFrame && seekstep == this.lastSeekStep) {\n return seekframe; // already set to this frame\n }\n // TODO: what if < 1?\n let {frame,state} = this.getStateAtOrBefore(seekframe-1);\n if (state) {\n var numSteps = 0;\n this.platform.pause();\n this.platform.loadState(state);\n // seek to frame index\n while (frame < seekframe) {\n if (frame < this.framerecs.length) {\n this.loadControls(frame);\n }\n frame++;\n numSteps = this.platform.advance(frame < seekframe); // TODO: infinite loop?\n }\n // TODO: if first frame, we must figure out # of steps\n if (frame == 0) {\n numSteps = this.platform.advance(true);\n this.platform.loadState(state);\n }\n // seek to step index\n // TODO: what if advance() returns clocks, but steps use insns?\n if (seekstep > 0 && this.platform.advanceFrameClock) { \n seekstep = this.platform.advanceFrameClock(null, seekstep);\n }\n // record new values\n this.lastSeekFrame = seekframe;\n this.lastSeekStep = seekstep;\n this.lastStepCount = numSteps;\n return seekframe;\n } else {\n return -1;\n }\n }\n \n loadControls(frame : number) {\n if (this.platform.loadControlsState)\n this.platform.loadControlsState(this.framerecs[frame].controls);\n setNoiseSeed(this.framerecs[frame].seed);\n }\n \n getLastCheckpoint() : EmuState {\n return this.checkpoints.length && this.checkpoints[this.checkpoints.length-1];\n }\n}\n\n", "// hard-code platform files for esbuild code-splitting\n\nexport function importPlatform(name: string) : Promise<any> {\n switch (name) {\n case \"apple2\": return import(\"../platform/apple2\");\n case \"arm32\": return import(\"../platform/arm32\");\n case \"astrocade\": return import(\"../platform/astrocade\");\n case \"atari7800\": return import(\"../platform/atari7800\");\n case \"atari8\": return import(\"../platform/atari8\");\n case \"basic\": return import(\"../platform/basic\");\n case \"c64\": return import(\"../platform/c64\");\n case \"coleco\": return import(\"../platform/coleco\");\n case \"cpc\": return import(\"../platform/cpc\");\n case \"devel\": return import(\"../platform/devel\");\n case \"galaxian\": return import(\"../platform/galaxian\");\n case \"kim1\": return import(\"../platform/kim1\");\n case \"markdown\": return import(\"../platform/markdown\");\n case \"msx\": return import(\"../platform/msx\");\n case \"mw8080bw\": return import(\"../platform/mw8080bw\");\n case \"nes\": return import(\"../platform/nes\");\n case \"script\": return import(\"../platform/script\");\n case \"sms\": return import(\"../platform/sms\");\n case \"sound_konami\": return import(\"../platform/sound_konami\");\n case \"sound_williams\": return import(\"../platform/sound_williams\");\n case \"vcs\": return import(\"../platform/vcs\");\n case \"vector\": return import(\"../platform/vector\");\n case \"vectrex\": return import(\"../platform/vectrex\");\n case \"verilog\": return import(\"../platform/verilog\");\n case \"vic20\": return import(\"../platform/vic20\");\n case \"vicdual\": return import(\"../platform/vicdual\");\n case \"williams\": return import(\"../platform/williams\");\n case \"x86\": return import(\"../platform/x86\");\n case \"zmachine\": return import(\"../platform/zmachine\");\n case \"zx\": return import(\"../platform/zx\");\n default: throw new Error(`Platform not recognized: '${name}'`)\n }\n }\n \n "],
|
|
"mappings": "oPAkBA,WAAc,EAAM,EAAM,CAAA,MACJ,AAAhB,OAAO,IAAS,YAAa,EAAO,CAAE,QAAO,IACxB,AAAhB,MAAO,IAAS,UACvB,SAAQ,KAAK,sDACb,EAAO,CAAE,QAAS,CAAC,IAKjB,EAAK,SAAW,6EAA6E,KAAK,EAAK,MAClG,GAAI,MAAK,CAAA,SAA8B,GAAO,CAAE,KAAM,EAAK,OAE7D,EAGT,WAAmB,EAAK,EAAM,EAAM,CAClC,GAAI,GAAM,GAAI,gBACd,EAAI,KAAK,MAAO,GAChB,EAAI,aAAe,OACnB,EAAI,OAAS,UAAY,CACvB,EAAO,EAAI,SAAU,EAAM,IAE7B,EAAI,QAAU,UAAY,CACxB,QAAQ,MAAM,4BAEhB,EAAI,OAGN,WAAsB,EAAK,CACzB,GAAI,GAAM,GAAI,gBAEd,EAAI,KAAK,OAAQ,EAAjB,IACA,GAAI,CACF,EAAI,aACG,EAAP,EACF,MAAqB,MAAd,EAAI,QAA+B,KAAd,EAAI,OAIlC,WAAgB,EAAM,CACpB,GAAI,CACF,EAAK,cAAc,GAAI,YAAW,gBAC3B,EAAP,CACA,GAAI,GAAM,SAAS,YAAY,eAC/B,EAAI,eAAe,QAAnB,GAAA,GAAwC,OAAQ,EAAG,EAAG,EAAG,GACnC,GADtB,GAAA,GAAA,GAAA,GACsD,EAAG,MACzD,EAAK,cAAc,IAEtB,GAtDG,GAA4B,AAAlB,MAAO,S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