1 | <!DOCTYPE html>
|
2 | <html>
|
3 | <head>
|
4 | <title>React Developer Tools</title>
|
5 | <meta charset="utf8" />
|
6 | <style>
|
7 | html {
|
8 | height: 100%;
|
9 | font-family: sans-serif;
|
10 | }
|
11 | body {
|
12 | height: 100%;
|
13 | margin: 0;
|
14 | padding: 0;
|
15 | background-color: #fff;
|
16 | color: #777d88;
|
17 | }
|
18 |
|
19 | .container {
|
20 | height: 100%;
|
21 | display: flex;
|
22 | flex-direction: column;
|
23 | align-items: center;
|
24 | justify-content: center;
|
25 | overflow: auto;
|
26 | padding: 1rem;
|
27 | }
|
28 | p {
|
29 | padding: 0;
|
30 | margin: 0;
|
31 | }
|
32 |
|
33 | .input {
|
34 | display: block;
|
35 | font-weight: 100;
|
36 | padding: 0 0.25rem;
|
37 | border: 1px solid #aaa;
|
38 | background-color: #fff;
|
39 | color: #666;
|
40 | }
|
41 |
|
42 | .link {
|
43 | color: #1478fa;
|
44 | text-decoration: none;
|
45 | }
|
46 | .link:hover {
|
47 | text-decoration: underline;
|
48 | }
|
49 |
|
50 | .waiting-header {
|
51 | padding: 0.5rem;
|
52 | display: inline-block;
|
53 | position: absolute;
|
54 | right: 0.5rem;
|
55 | top: 0.5rem;
|
56 | border-radius: 0.25rem;
|
57 | background-color: rgba(0,1,2,.6);
|
58 | color: white;
|
59 | border: none;
|
60 | font-weight: 100;
|
61 | font-style: italic;
|
62 | }
|
63 |
|
64 | .boxes {
|
65 | display: flex;
|
66 | flex-direction: column;
|
67 | align-items: stretch;
|
68 | justify-content: center;
|
69 | }
|
70 | .box {
|
71 | text-align: center;
|
72 | border-radius: 0.5rem;
|
73 | background-color: #f7f7f7;
|
74 | border: 1px solid #eee;
|
75 | color: #777d88;
|
76 | padding: 1rem;
|
77 | margin-top: 1rem;
|
78 | }
|
79 | .box:first-of-type {
|
80 | margin-top: 0;
|
81 | }
|
82 |
|
83 | .box-header {
|
84 | text-align: center;
|
85 | color: #5f6673;
|
86 | font-size: 1.25rem;
|
87 | margin-bottom: 0.5rem;
|
88 | }
|
89 | .box-content {
|
90 | line-height: 1.5rem;
|
91 | }
|
92 |
|
93 | #loading-status {
|
94 | text-align: center;
|
95 | margin-top: 1rem;
|
96 | }
|
97 | </style>
|
98 | </head>
|
99 | <body>
|
100 | <div id="container" class="container" style="-webkit-user-select: none; -webkit-app-region: drag;">
|
101 | <div class="waiting-header">Waiting for React to connect…</div>
|
102 | <div class="boxes">
|
103 | <div class="box">
|
104 | <div class="box-header">React Native</div>
|
105 | <div class="box-content">
|
106 | Open the <a
|
107 | id="rn-help-link"
|
108 | class="link"
|
109 | target="_blank"
|
110 | href="https://facebook.github.io/react-native/docs/debugging#accessing-the-in-app-developer-menu"
|
111 | >in-app developer menu</a> to connect.
|
112 | </div>
|
113 | </div>
|
114 | <div class="box">
|
115 | <div class="box-header">React DOM</div>
|
116 | <div class="box-content">
|
117 | Add one of the following:
|
118 | <span class="input" contenteditable="true" id="localhost"></span>
|
119 | <span class="input" contenteditable="true" id="byip"></span>
|
120 | to the top of the page you want to debug,
|
121 | <br />
|
122 | <strong>before</strong> importing React DOM.
|
123 | </div>
|
124 | </div>
|
125 | <div id="loading-status">Starting the server…</div>
|
126 | </div>
|
127 | </div>
|
128 | <script>
|
129 | const port = process.env.PORT || 8097;
|
130 | const localIp = require("ip").address();
|
131 | const $ = document.querySelector.bind(document);
|
132 |
|
133 | function selectAll(event) {
|
134 | const element = event.target;
|
135 | if (window.getSelection) {
|
136 | const selection = window.getSelection();
|
137 | const range = document.createRange();
|
138 | range.selectNodeContents(element);
|
139 | selection.removeAllRanges();
|
140 | selection.addRange(range);
|
141 | }
|
142 | }
|
143 |
|
144 | const link = $('#rn-help-link');
|
145 | link.addEventListener('click', event => {
|
146 | event.preventDefault();
|
147 | require('electron').shell.openExternal(link.href);
|
148 | });
|
149 |
|
150 | const $localhost = $("#localhost");
|
151 | $localhost.innerText = `<script src="http://localhost:${port}"></` + 'script>';
|
152 | $localhost.addEventListener('click', selectAll);
|
153 | $localhost.addEventListener('focus', selectAll);
|
154 |
|
155 | const $byIp = $("#byip");
|
156 | $byIp.innerText = `<script src="http://${localIp}:${port}"></` + 'script>';
|
157 | $byIp.addEventListener('click', selectAll);
|
158 | $byIp.addEventListener('focus', selectAll);
|
159 |
|
160 | let devtools;
|
161 | try {
|
162 | devtools = require("react-devtools-core/standalone").default;
|
163 | } catch (err) {
|
164 | alert(
|
165 | err.toString() +
|
166 | "\n\nDid you run `yarn` and `yarn run build` in packages/react-devtools-core?"
|
167 | );
|
168 | }
|
169 | window.devtools = devtools;
|
170 | window.server = devtools
|
171 | .setContentDOMNode(document.getElementById("container"))
|
172 | .setStatusListener(function(status) {
|
173 | const element = document.getElementById("loading-status");
|
174 | if (element) {
|
175 | element.innerText = status;
|
176 | }
|
177 | })
|
178 | .startServer(port);
|
179 | </script>
|
180 | </body>
|
181 | </html>
|