Repository navigation
fix(vrowzer): give both Workers a default index.html when ready() gets none - #71
Merged
Merged
Conversation
…s none The Web Worker wrote a default /index.html during setup, but the Service Worker, which serves the preview HTML, never got one. A ready() without /index.html, as in the README usage example, therefore left the preview without HTML: since #69 it reported one 404 load error and stayed blank. initialize() now adds a default /index.html to the files it copies from ready() when they have none, and sends it to both Workers. The default is minimal: an empty #app element and a module script that loads /main.js. An /index.html given to ready() is used as before.
setupVirtualFiles() wrote a default /index.html in the Web Worker. The Service Worker serves the preview HTML and never had this default, so it was never served. The vrowzer runtime now sends the same default /index.html to both Workers when ready() gets none, so the Web Worker no longer writes its own. /public/.gitkeep is still written.
Opened with ?files=readme-example, the playground gives ready() only the /main.js of the README usage example. A new test opens it in a new browser context, which has a Service Worker of its own, and checks that the preview shows "Hello!", as the example expects. Without the default /index.html, the preview stays blank and the test times out.
The README section of ready() and the JSDoc of VrowzerConfig.files say that, without /index.html, Vrowzer uses a default one: an empty #app element and a module script that loads /main.js. The API references are regenerated.
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.
Closes #70
ready()without/index.html, as in the README usage example, now shows a preview: the runtime gives both Workers the same default/index.html.Cause
The Web Worker wrote a default
/index.htmlduring setup. But the Service Worker, which serves the preview HTML from its own virtual filesystem, never got one. Aready()without/index.htmltherefore left the preview without HTML. Since #69, the preview reported one 404 load error and stayed blank.The README usage example passes only
/main.js, which writes into#app, so following it showed no preview.Fix
initialize()adds a default/index.htmlto the files it copies fromready()when they have none, and sends it to both Workers. An/index.htmlgiven toready()is used as before.<div id="app">and a module script that loads/main.js.setupVirtualFiles(), so the default lives in one place. The Web Worker receives the HTML from the Service Worker, and its default never reached a preview.ready()and the JSDoc ofVrowzerConfig.filesdescribe the default. The API references are regenerated. The README examples are unchanged and now work as written.The Web Worker's old default also had a global CSS reset (
* { margin: 0; padding: 0; box-sizing: border-box; }), body padding and a "Loading..." placeholder. They are left out: they would clash with the user's CSS, and the old default never reached a preview.Behavior change
A
ready()without/index.htmlshows the default page, instead of a blank preview with a 404 load error. A preview always loads/index.html, so no working setup depended on its absence. Deleting/index.htmlafterready()still leads to a 404, as before.Not included
/src/main.ts. The default loads/main.js./index.htmlsends the default, which can replace the/index.htmlof another instance, as any file with the same path already can.Tests
Unit tests:
index-file-sync.test.ts: aready()without/index.htmlsends the same default to both Workers, with#appand/main.js. The existing test that gives an/index.htmlpasses unchanged, so a given/index.htmlis not replaced. The test from fix(vrowzer): write binary files given to ready() as bytes in both Workers #66 that compares theV_FS_INITfiles now expects the default as well.transformer.test.ts:setupWorker()no longer writes/index.html.The new checks failed before the change.
Integration test in the shared playground: opened with
?files=readme-example, the playground givesready()only the/main.jsof the README usage example. The test opens it in a new browser context, which has a Service Worker of its own, and checks that the preview shows "Hello!". Without the default, the preview stays blank and the test times out.Validated locally with:
vp run test:unit: 119 files, 1,915 testsvp run test:integration:vrowzer: 70 passed and 1 conditional skip, in three runsvp run test:e2e: 46 passed, 6 existingtest.skip