UNPKG

3.56 kBHTMLView Raw
1<!DOCTYPE html>
2<html>
3 <head>
4 <title>React Developer Tools</title>
5 <meta charset="utf8" />
6 <style>
7 html {
8 display: flex;
9 font-family: sans-serif;
10 }
11 body {
12 margin: 0;
13 padding: 0;
14 flex: 1;
15 display: flex;
16 }
17 #container {
18 display: flex;
19 position: fixed;
20 top: 0;
21 left: 0;
22 right: 0;
23 bottom: 0;
24 background-color: white;
25 }
26 #logs {
27 position: fixed;
28 top: 0;
29 left: 0;
30 white-space: pre;
31 }
32 #waiting {
33 flex-direction: column;
34 text-align: center;
35 font-family: sans-serif;
36 color: #aaa;
37 flex: 1;
38 overflow: auto;
39 }
40 #waiting h2 {
41 padding: 30px;
42 }
43 #waiting p {
44 padding: 0;
45 margin: 0;
46 }
47 .input {
48 display: inline-block;
49 max-width: 100%;
50 font-weight: 100;
51 border: 1px solid #aaa;
52 padding: 0.125rem 0.25rem;
53 margin: 0.125rem;
54 color: #666;
55 }
56 #loading-status {
57 margin-top: 10px;
58 }
59 </style>
60 </head>
61 <body>
62 <div id="container">
63 <div id="waiting" style="-webkit-user-select: none; -webkit-app-region: drag;">
64 <h2>Waiting for React to connect…</h2>
65 <div>
66 <h4>React Native</h4>
67 <div>The active app will automatically connect in a few seconds.</div>
68 <br />
69 <h4>React DOM</h4>
70 <div>
71 Add <span class="input" contenteditable="true" id="localhost"></span><br />
72 or <span class="input" contenteditable="true" id="byip"></span>
73 </div>
74 <div>
75 to the top of the page you want to debug,
76 <br />
77 <b>before</b> importing React DOM.
78 </div>
79 </div>
80 <br />
81 <br />
82 <div id="loading-status">Starting the server…</div>
83 </div>
84 </div>
85 <script>
86 const port = process.env.PORT || 8097;
87 const localIp = require("ip").address();
88 const $ = document.querySelector.bind(document);
89
90 function selectAll(event) {
91 const element = event.target;
92 if (window.getSelection) {
93 const selection = window.getSelection();
94 const range = document.createRange();
95 range.selectNodeContents(element);
96 selection.removeAllRanges();
97 selection.addRange(range);
98 }
99 }
100
101 const $localhost = $("#localhost");
102 $localhost.innerText = `<script src="http://localhost:${port}"></` + 'script>';
103 $localhost.addEventListener('click', selectAll);
104 $localhost.addEventListener('focus', selectAll);
105
106 const $byIp = $("#byip");
107 $byIp.innerText = `<script src="http://${localIp}:${port}"></` + 'script>';
108 $byIp.addEventListener('click', selectAll);
109 $byIp.addEventListener('focus', selectAll);
110
111 let devtools;
112 try {
113 devtools = require("react-devtools-core/standalone").default;
114 } catch (err) {
115 alert(
116 err.toString() +
117 "\n\nDid you run `yarn` and `yarn run build` in packages/react-devtools-core?"
118 );
119 }
120 window.devtools = devtools;
121 window.server = devtools
122 .setContentDOMNode(document.getElementById("container"))
123 .setStatusListener(function(status) {
124 document.getElementById("loading-status").innerText = status;
125 })
126 .startServer(port);
127 </script>
128 </body>
129</html>