Repository navigation
Expand file tree
/
Copy patheditor.html
More file actions
225 lines (223 loc) · 19.9 KB
/
Copy patheditor.html
File metadata and controls
225 lines (223 loc) · 19.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#55448c">
<meta name="description" content="Build MicroPython programs with blocks and connect to your board.">
<link rel="icon" type="image/png" href="./icons/icon-192.png">
<link rel="apple-touch-icon" href="./icons/apple-touch-icon.png">
<link rel="stylesheet" href="./src/styles/editor.css">
<title data-i18n="title">PyBlocks</title>
</head>
<body>
<header class="app-toolbar">
<a class="app-brand" href="./">
<img src="./icons/logo.png" width="32" height="32" alt="">
<strong data-i18n="title">PyBlocks</strong>
</a>
<nav class="app-menu" aria-label="Application">
<a id="my-projects" href="./projects.html" data-i18n="projectsTitle">My Projects</a>
<button id="open-firmware" type="button" data-i18n="firmwareMenu" data-i18n-title="firmwareTitle" title="Install MicroPython firmware">Firmware</button>
<button id="toggle-language" type="button" aria-label="切换语言" title="切换语言"><span id="language-icon" aria-hidden="true">中</span></button>
<button id="toggle-theme" type="button" aria-label="切换主题" title="切换主题"></button>
</nav>
</header>
<main id="editor-panels">
<section id="blocks-panel" class="panel" aria-labelledby="workspace-label">
<div class="panel-heading">
<div class="project-meta">
<h1 id="workspace-label"><input id="project-name" type="text" maxlength="120" data-i18n-aria="projectNamePrompt" aria-label="Project name" autocomplete="off" spellcheck="false"></h1>
</div>
<div class="code-actions project-actions">
<button id="save-project" type="button" data-i18n-title="projectSave" data-i18n-aria="projectSave" title="Save" aria-label="Save"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12l4 4v12a2 2 0 0 1-2 2Z"/><path d="M7 3v6h10V3M7 21v-8h10v8"/></svg></button>
<button id="import-project" type="button" data-i18n-title="projectImport" data-i18n-aria="projectImport" title="Import" aria-label="Import"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M12 15V3m-5 5 5-5 5 5M4 16v4a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-4"/></svg></button>
<button id="export-project" type="button" data-i18n-title="projectExport" data-i18n-aria="projectExport" title="Export" aria-label="Export"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3v12m-5-5 5 5 5-5M4 16v4a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-4"/></svg></button>
</div>
</div>
<input id="project-file" type="file" accept=".json,application/json" hidden>
<div id="workspace">
<section id="files-panel" class="toolbox-panel" aria-label="Files" hidden>
<div class="device-files-actions">
<button id="refresh-files" type="button"></button>
<button id="add-file" type="button" data-i18n="addFile" disabled>Add File</button>
</div>
<input id="local-device-file" type="file" hidden>
<p class="device-files-note" data-i18n="deviceFilesNote">File operations interrupt and restart the board program.</p>
<p id="device-files-status" role="status"></p>
<div class="device-files-directory">
<button id="files-parent" type="button" data-i18n="filesParent" hidden>Up</button>
<code id="files-path"></code>
</div>
<ul id="device-file-list"></ul>
</section>
<section id="libraries-panel" class="toolbox-panel" aria-labelledby="libraries-title" hidden>
<h3 id="libraries-title" data-i18n="libraries">Libraries</h3>
<p data-i18n="librariesNote">Python modules saved with this project and uploaded when you flash.</p>
<button id="add-library" type="button" data-i18n="addLibrary">Add .py File</button>
<input id="library-file" type="file" accept=".py" hidden>
<p id="libraries-status" role="status"></p>
<ul id="library-list"></ul>
</section>
</div>
</section>
<div id="panel-resizer" class="resize-handle horizontal-resize" role="separator" tabindex="0" aria-orientation="vertical" aria-controls="blocks-panel right-panels" data-i18n-aria="resizePanels" aria-label="Resize workspace and right panels"></div>
<div id="right-panels">
<section id="device-panel" class="panel" aria-labelledby="device-label">
<div class="panel-heading">
<div class="device-meta">
<h2 id="device-label" data-i18n="deviceHeading">Device</h2>
<div class="device-identity"><span id="deployment-device" role="status"></span></div>
</div>
<div class="device-heading-actions" role="group" aria-labelledby="device-label">
<button id="change-device" type="button" data-i18n-title="changeDevice" data-i18n-aria="changeDevice" title="Change device" aria-label="Change device" hidden><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M3 7h17m-4-4 4 4-4 4M21 17H4m4-4-4 4 4 4"/></svg></button>
<button id="change-slot" type="button" data-i18n-title="changeSlot" data-i18n-aria="changeSlot" title="Change slot" aria-label="Change slot" hidden><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M5 9h14M5 15h14M10 3 8 21M16 3l-2 18"/></svg></button>
<button id="serial-interrupt" type="button" data-i18n-title="serialInterruptHint" data-i18n-aria="serialInterrupt" title="Stop" aria-label="Stop" hidden disabled><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="6" y="6" width="12" height="12" rx="1"/></svg></button>
<button id="spike-stop" type="button" data-i18n-title="serialInterrupt" data-i18n-aria="serialInterrupt" title="Stop" aria-label="Stop" hidden disabled><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="6" y="6" width="12" height="12" rx="1"/></svg></button>
<button id="serial-reset" type="button" data-i18n-title="serialResetHint" data-i18n-aria="serialReset" title="Soft reset" aria-label="Soft reset" hidden disabled><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M3 11a9 9 0 1 1 3 7M3 4v7h7"/></svg></button>
<button id="serial-connect" type="button" title="Connect" aria-label="Connect" disabled><svg class="connect-icon" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M9 3v5m6-5v5M7 8h10v3a5 5 0 0 1-10 0V8Zm5 8v5"/></svg><svg class="disconnect-icon" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M9 3v5m6-5v5M7 8h10v3a5 5 0 0 1-10 0V8Zm5 8v5M3 3l18 18"/></svg></button>
<button id="upload" type="button" data-i18n-title="flashButton" data-i18n-aria="flashButton" title="Upload and run" aria-label="Upload and run"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="m8 5 11 7-11 7V5Z"/></svg></button>
</div>
</div>
<section id="serial-panel" class="serial-panel" data-i18n-aria="serialOutput" aria-label="Console output">
<div class="console-body">
<button id="serial-clear" type="button" data-i18n-title="serialClear" data-i18n-aria="serialClear" title="Clear" aria-label="Clear" disabled><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13M10 11v5m4-5v5"/></svg></button>
<pre id="serial-output" data-i18n-aria="serialOutput" aria-label="Console output" tabindex="0"></pre>
</div>
<form id="serial-input-form" class="serial-input-form" hidden>
<input id="serial-input" type="text" data-i18n-aria="serialInput" aria-label="Serial input"
autocomplete="off" autocapitalize="off" spellcheck="false" disabled>
<select id="serial-line-ending" data-i18n-aria="serialLineEnding" aria-label="Line ending" disabled>
<option value="CR">CR</option><option value="LF">LF</option><option value="CRLF">CRLF</option>
<option value="NONE" data-i18n="serialNoEnding">None</option>
</select>
<button id="serial-send" type="submit" data-i18n="serialSend" disabled>Send</button>
</form>
</section>
</section>
<div id="output-resizer" class="resize-handle vertical-resize" role="separator" tabindex="0" aria-orientation="horizontal" aria-controls="device-panel code-panel" data-i18n-aria="resizeOutput" aria-label="Resize device and code panels"></div>
<section id="code-panel" class="panel" aria-labelledby="code-label">
<div class="panel-heading">
<h2 id="code-label" data-i18n="codeHeading">Code</h2>
<div class="code-actions">
<button id="use-block-code" type="button" data-i18n="useGeneratedCode" hidden>Use generated code</button>
<button id="download" type="button" data-i18n-title="downloadHint" data-i18n="downloadButton">Download</button>
<button id="toggle-code" type="button" aria-expanded="true" aria-controls="code-body">Collapse</button>
</div>
</div>
<div id="code-body">
<p id="code-error" role="status"></p>
<textarea id="python" aria-labelledby="code-label" spellcheck="false"
autocapitalize="off" autocomplete="off" wrap="off"></textarea>
</div>
</section>
</div>
</main>
<dialog id="spike-device-dialog" aria-labelledby="spike-device-title">
<div class="spike-dialog-layout">
<div class="spike-dialog-overview">
<header class="spike-device-summary">
<img class="spike-device-image" src="./icons/spike-hub.svg" alt="" width="108" height="108">
<div class="spike-device-meta">
<h2 id="spike-device-title">LEGO SPIKE Prime</h2>
<p id="spike-device-version"></p>
<p id="spike-device-protocol"></p>
<p class="spike-device-detected"><svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="m8 12 3 3 5-6"/></svg><span data-i18n="spikeDeviceDetected">Device detected</span></p>
</div>
</header>
<section class="spike-capabilities" aria-labelledby="spike-capabilities-title">
<h3 id="spike-capabilities-title" data-i18n="spikeCapabilitiesTitle">Available capabilities</h3>
<ul class="spike-capability-grid">
<li><svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M9 3v18m6-18v18M3 9h18M3 15h18"/></svg><span data-i18n="spikeFeatureMatrix">LED matrix</span></li>
<li><svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="5"/></svg><span data-i18n="buttons">Buttons</span></li>
<li><svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M20 11a8 8 0 1 0-2 7M20 4v7h-7"/></svg><span data-i18n="spikeFeatureMotor">Motor control</span></li>
<li><svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="m15.5 8.5-2 5-5 2 2-5 5-2Z"/></svg><span data-i18n="spikeFeatureMotion">Motion sensing</span></li>
<li><svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="8" width="20" height="8" rx="2" transform="rotate(45 12 12)"/><path d="m8 6-2 2m6 2-2 2m6 2-2 2"/></svg><span data-i18n="spikeFeatureDistance">Distance sensor</span></li>
<li><svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3a9 9 0 1 0 0 18h1a2 2 0 0 0 1-3.7 1.5 1.5 0 0 1 .8-2.8h2A4.2 4.2 0 0 0 21 10c0-4-4-7-9-7Z"/><circle cx="7.5" cy="10" r=".9"/><circle cx="11" cy="6.8" r=".9"/><circle cx="15.5" cy="8" r=".9"/></svg><span data-i18n="spikeFeatureColor">Color sensor</span></li>
</ul>
<p class="spike-capability-note" data-i18n="spikeCapabilityNote">Some capabilities require compatible external motors or sensors.</p>
</section>
</div>
<div class="spike-dialog-deployment">
<fieldset id="spike-slot-fieldset">
<legend data-i18n="spikeSlotLabel">Program slot</legend>
<div id="spike-device-slot" class="spike-slot-grid"></div>
</fieldset>
<p id="spike-device-warning" class="spike-slot-note" aria-live="polite"></p>
<div class="dialog-actions spike-dialog-actions">
<button id="spike-device-cancel" type="button" data-i18n="spikeCancel">Cancel</button>
<button id="spike-device-confirm" class="primary" type="button"></button>
</div>
</div>
</div>
</dialog>
<dialog id="firmware-dialog" aria-labelledby="firmware-title">
<h2 id="firmware-title" data-i18n="firmwareTitle">Install MicroPython firmware</h2>
<p data-i18n="firmwareIntro">Choose a device family, then connect and detect its hardware.</p>
<section id="firmware-select-step" aria-labelledby="firmware-step-select">
<h3 id="firmware-step-select" data-i18n="firmwareStepSelect">1. Choose and connect</h3>
<fieldset id="firmware-family" class="firmware-families">
<legend data-i18n="firmwareFamily">Device family</legend>
<label class="board-card"><input type="radio" name="firmware-family" value="esp32" checked><strong>ESP32</strong></label>
<label class="board-card"><input type="radio" name="firmware-family" value="m5stack"><strong>M5Stack</strong></label>
<label class="board-card"><input type="radio" name="firmware-family" value="microbit"><strong>Micro:bit</strong></label>
<label class="board-card"><input type="radio" name="firmware-family" value="stm32"><strong>STM32</strong></label>
<label class="board-card"><input type="radio" name="firmware-family" value="raspberry"><strong>Raspberry Pi</strong></label>
</fieldset>
<label for="firmware-model" data-i18n="firmwareModel">Model</label>
<select id="firmware-model"></select>
<p id="firmware-model-hint" class="firmware-hint"></p>
</section>
<section id="firmware-review" aria-labelledby="firmware-step-review" hidden>
<h3 id="firmware-step-review" data-i18n="firmwareStepReview">2. Review and install</h3>
<dl class="firmware-details">
<dt data-i18n="firmwareDetectedChip">Detected chip</dt><dd id="firmware-chip"></dd>
<dt data-i18n="firmwareDetectedCapacity">Flash capacity</dt><dd id="firmware-capacity"></dd>
<dt data-i18n="firmwareModel">Model</dt><dd id="firmware-resolved-model"></dd>
<dt data-i18n="firmwareImage">Firmware</dt><dd id="firmware-image"></dd>
</dl>
<div id="firmware-manual-capacity" hidden>
<label for="firmware-capacity-choice" data-i18n="firmwareManualCapacity">Flash capacity (manual confirmation)</label>
<select id="firmware-capacity-choice"></select>
<p class="firmware-hint" data-i18n="firmwareManualHint">Could not detect capacity. Select it only from your hardware specifications.</p>
</div>
<div id="firmware-stm32-file" hidden>
<label for="firmware-dfu-image" data-i18n="firmwareSTM32FileLabel">Official board-specific .dfu file</label>
<input id="firmware-dfu-image" type="file" accept=".dfu">
<label><input id="firmware-dfu-confirm" type="checkbox"> <span data-i18n="firmwareSTM32Confirm">I have verified the exact board, crystal and flash variant and selected its firmware.</span></label>
<p class="firmware-hint" data-i18n="firmwareSTM32ReviewHint">USB DFU does not identify the exact board. File CRC and flash geometry checks cannot prove board compatibility.</p>
</div>
<div id="firmware-upstream" hidden>
<a id="firmware-image-url" target="_blank" rel="noopener noreferrer" data-i18n="firmwareDownloadOriginal">Download original firmware</a>
<label for="firmware-local-image" data-i18n="firmwareLocalImage">Use local copy (optional)</label>
<input id="firmware-local-image" type="file" accept=".bin,.hex,.uf2">
<p class="firmware-hint" data-i18n="firmwareLocalHint">If automatic download is blocked, download the original image and select it here. The same SHA-256 check applies.</p>
</div>
<p id="firmware-match" role="status"></p>
<button id="firmware-suggestion" type="button" hidden></button>
<p id="firmware-capabilities" class="firmware-hint"></p>
</section>
<a id="firmware-more" class="firmware-more" href="https://micropython.org/download/" target="_blank" rel="noopener noreferrer"><span>No matching firmware? Browse MicroPython downloads</span><span aria-hidden="true">↗</span></a>
<p id="firmware-warning" class="dialog-warning" data-i18n="firmwareWarning" hidden>Installation replaces the program and files on your board. Back up anything you need before continuing.</p>
<p id="firmware-status" role="status" aria-live="polite"></p>
<progress id="firmware-progress" max="1" aria-label="Firmware installation progress" hidden></progress>
<div class="dialog-actions">
<button id="firmware-close" type="button" data-i18n="closeButton">Close</button>
<button id="firmware-reselect" type="button" data-i18n="firmwareReselect" hidden>Choose another device</button>
<button id="firmware-connect" type="button" data-i18n="firmwareConnect">Connect board</button>
<button id="firmware-install" class="primary" type="button" data-i18n="firmwareInstall" hidden>Install firmware</button>
</div>
</dialog>
<div class="toast-stack">
<div id="project-toast" class="toast" hidden>
<span id="project-toast-message" role="status" aria-live="polite" aria-atomic="true"></span>
<button id="project-toast-dismiss" type="button" data-i18n-title="closeButton" data-i18n-aria="closeButton" aria-label="Close" title="Close">×</button>
</div>
<div id="device-toast" class="toast" hidden>
<span id="device-toast-message" role="status" aria-live="polite" aria-atomic="true"></span>
<button id="device-toast-dismiss" type="button" data-i18n-title="closeButton" data-i18n-aria="closeButton" aria-label="Close" title="Close">×</button>
</div>
</div>
<script type="module" src="/src/main.js"></script>
</body>
</html>