1 line
12 KiB
Plaintext
1 line
12 KiB
Plaintext
|
{"version":3,"names":["isMacLike","test","navigator","platform","refreshShortcut","window","onload","document","getElementById","innerHTML","Page","render","onReloadClicked","xhr","XMLHttpRequest","open","location","origin","send","state","isDark","localStorage","getItem","matchMedia","matches","isPriorityMaintained","status","type","visibilityState","setState","partialState","Object","assign","statusNode","textContent","error","reason","linkNode","querySelector","href","grayIcon","blueIcon","orangeIcon","darkCheckbox","body","classList","toggle","checked","setItem","maintainPriorityCheckbox","silence","volume","play","pause","toggleDarkTheme","togglePriorityMaintenance","connectToDebuggerProxy","ws","WebSocket","host","worker","createJSRuntime","Worker","onmessage","message","JSON","stringify","data","onbeforeunload","updateVisibility","shutdownJSRuntime","terminate","postMessage","method","onopen","object","parse","$event","console","clear","replyID","id","onclose","warn","setTimeout","addEventListener"],"sources":["../../src/ui/index.js"],"sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n/* eslint-env browser */\nimport './index.css';\nimport blueIcon from './assets/blue-icon.png';\nimport grayIcon from './assets/gray-icon.png';\nimport orangeIcon from './assets/orange-icon.png';\n\nconst isMacLike = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);\nconst refreshShortcut = isMacLike ? '⌘R' : 'Ctrl R';\nwindow.onload = function () {\n if (!isMacLike) {\n document.getElementById('shortcut').innerHTML = 'Ctrl⇧J';\n }\n Page.render();\n};\n\nwindow.onReloadClicked = function () {\n var xhr = new XMLHttpRequest();\n xhr.open('GET', `${window.location.origin}/reload`, true);\n xhr.send();\n};\n\nconst Page = (window.Page = {\n state: {\n isDark:\n localStorage.getItem('darkTheme') === null\n ? window.matchMedia('(prefers-color-scheme: dark)').matches\n : localStorage.getItem('darkTheme') === 'on',\n isPriorityMaintained: localStorage.getItem('maintainPriority') === 'on',\n status: {type: 'disconnected'},\n visibilityState: document.visibilityState,\n },\n\n setState(partialState) {\n Page.state = Object.assign({}, Page.state, partialState);\n Page.render();\n },\n\n render() {\n const {isDark, isPriorityMaintained, status, visibilityState} = Page.state;\n\n const statusNode = document.getElementById('status');\n switch (status.type) {\n case 'connected':\n statusNode.textContent = 'Debugger session active.';\n break;\n case 'error':\n statusNode.textContent =\n status.error.reason ||\n 'Disconnected from proxy. Attempting reconnection. Is node server running?';\n break;\n case 'connecting':\n case 'disconnected':\n // Fall through.\n default:\n statusNode.innerHTML =\n 'Waiting, press <span class=\"shortcut\">' +\n refreshShortcut +\n '</span> in simulator to reload and connect.';\n break;\n }\n\n const linkNode = document.querySelector('link[rel=icon]');\n if (status.type === 'disconnected' || status.type === 'error') {\n linkNode.href = grayIcon;\n } else {\n if (visibilityState === 'visible' || isPriorityMaintained) {\n linkNode.href = blueIcon;\n } else {\n linkNode.href = orangeIcon;\n }\n }\n\n const darkCheckbox = document.getElementById('dark');\n document.body.classList.toggle('dark', isDark);\n darkCheckbox.checked = isDark;\n localStorage.setItem('darkTheme', isDark ? 'on' : '');\n\n const maintainPriorityCheckbox = document.getElementById(\n 'maintain-priority',\n );\n const silence = document.getElementById('silence');\n silence.volume = 0.1;\n if (isPriorityMaintained) {\n silence.play();\n } else {\n silence.pause();\n }\n maintainPriorityCheckbox.checked = isPri
|