Repository navigation
Veyra Live Server 1.4.0: phone testing, browser console, API proxy, S… - #31
Merged
Merged
Conversation
…PA mode - Keeps your place: after a live reload the page returns to the same scroll position (in the shared browser script, so Veyra Studio gets it too). - Browser console in VS Code: console.log, warnings, errors and unhandled promise rejections from the page appear in a new "Browser Console" output, with an error count in the status bar. The script is injected at the top of <head> in this mode so it hears every message; Veyra Studio's injection is unchanged. - Test on your phone: "Share on Your Network" serves on the LAN (off by default, asks once), shows and copies the network address. - API proxy (veyraLiveServer.proxy): any method, path, query and body, streamed, with a clear 502 page when the backend is down. - Single-page apps (veyraLiveServer.spa): routes get the root index.html. - Smarter reloads: only changes inside the served folder count, plus veyraLiveServer.ignore globs. - Changing any of these settings restarts Live Server. - README, changelog and veyraeditor.com/live-server updated. Tests: 15 server tests (7 new, with a real backend for the proxy), a browser run in Chromium (console forwarding, scroll restore, CSS swap) and the integration test in VS Code 1.144. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| const text = html.toString("latin1").toLowerCase(); // latin1 keeps byte offsets | ||
| let index = -1; | ||
| if (withConsole) { | ||
| const head = /<head(\s[^>]*)?>/.exec(text); |
| if (!urlPath.endsWith("/")) return reply(301, { Location: urlPath + "/" }); | ||
| const index = ["index.html", "index.htm"].map(name => path.join(file, name)).find(p => fs.existsSync(p) && fs.statSync(p).isFile()); | ||
| if (index) return reply(200, { "Content-Type": mime(index) }, inject(fs.readFileSync(index))); | ||
| const index = ["index.html", "index.htm"].map(name => path.join(file!, name)).find(p => fs.existsSync(p) && fs.statSync(p).isFile()); |
| if (!urlPath.endsWith("/")) return reply(301, { Location: urlPath + "/" }); | ||
| const index = ["index.html", "index.htm"].map(name => path.join(file, name)).find(p => fs.existsSync(p) && fs.statSync(p).isFile()); | ||
| if (index) return reply(200, { "Content-Type": mime(index) }, inject(fs.readFileSync(index))); | ||
| const index = ["index.html", "index.htm"].map(name => path.join(file!, name)).find(p => fs.existsSync(p) && fs.statSync(p).isFile()); |
| const index = ["index.html", "index.htm"].map(name => path.join(file, name)).find(p => fs.existsSync(p) && fs.statSync(p).isFile()); | ||
| if (index) return reply(200, { "Content-Type": mime(index) }, inject(fs.readFileSync(index))); | ||
| const index = ["index.html", "index.htm"].map(name => path.join(file!, name)).find(p => fs.existsSync(p) && fs.statSync(p).isFile()); | ||
| if (index) return reply(200, { "Content-Type": mime(index) }, inject(fs.readFileSync(index), withConsole)); |
| } | ||
| if (isHtml(file)) return reply(200, { "Content-Type": mime(file) }, inject(fs.readFileSync(file))); | ||
| file = file!; | ||
| if (isHtml(file)) return reply(200, { "Content-Type": mime(file) }, inject(fs.readFileSync(file), withConsole)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…PA mode
Tests: 15 server tests (7 new, with a real backend for the proxy), a browser run in Chromium (console forwarding, scroll restore, CSS swap) and the integration test in VS Code 1.144.