From 7ee32a4be08041cf29eb7619df4e7ca5a79bc80f Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sun, 6 Dec 2026 01:40:29 +0100 Subject: [PATCH 01/10] Link the light bridge page into the HTTPS browser tests --- test/web/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/web/CMakeLists.txt b/test/web/CMakeLists.txt index 477bb6a4..522dfa9e 100644 --- a/test/web/CMakeLists.txt +++ b/test/web/CMakeLists.txt @@ -312,7 +312,7 @@ if(_browser_tests_available) file(STRINGS "${_tls_fixture}/spki.txt" _tls_spki LIMIT_COUNT 1) webfront_add_test_program(webtest_tls JasmineTest.cpp WITH_WEBTEST DEFINITIONS WEBFRONT_TEST_TLS_FIXTURE="${_tls_fixture}" WEBFRONT_TEST_MEDIA_FILE="${CMAKE_CURRENT_SOURCE_DIR}/fixtures/media/seek.webm") - target_sources(webtest_tls PRIVATE RestartableServer.cpp) + target_sources(webtest_tls PRIVATE RestartableServer.cpp ../unit/BridgeLightPage.cpp) target_link_libraries(webtest_tls PRIVATE WebFront_boing) endif() else() From 1f8bbead1bd2f5d75ec3124cd8e0f89caaa93307 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sun, 6 Dec 2026 01:40:29 +0100 Subject: [PATCH 02/10] Move the Life React component to its own module (#763) --- docs/REACT.md | 8 +++-- examples/life/react/Life.tsx | 55 ++++++++++++++++++++++++++++ examples/life/react/LifeReact.cpp | 2 +- examples/life/react/main.tsx | 59 +++++-------------------------- test/cmake/PrepareWfProject.cmake | 3 ++ test/web/suite/tsconfig.json | 3 +- 6 files changed, 75 insertions(+), 55 deletions(-) create mode 100644 examples/life/react/Life.tsx diff --git a/docs/REACT.md b/docs/REACT.md index 0d104201..62964467 100644 --- a/docs/REACT.md +++ b/docs/REACT.md @@ -78,17 +78,19 @@ simulation, released on disconnect. The original Life starter remains available. Build the `WebFrontLifeReact` CMake target. The application only creates an empty project directory when it is missing (without argument `./life-project`); -it does not copy the example's sources. Use a new directory, so that no existing project is touched: `mkdir` fails if it exists and `cp -n` never overwrites a file. Copy `main.tsx` and +it does not copy the example's sources. Use a new directory, so that no existing project is touched: `mkdir` fails if it exists and `cp -n` never overwrites a file. Copy `main.tsx`, `Life.tsx` and `webfront.project.json` from `examples/life/react/` into that directory first, then start the application: ```sh mkdir life-react-project -cp -n examples/life/react/main.tsx examples/life/react/webfront.project.json life-react-project/ +cp -n examples/life/react/main.tsx examples/life/react/Life.tsx examples/life/react/webfront.project.json life-react-project/ ./build/examples/WebFrontLifeReact life-react-project ``` -In its terminal, run `wf install`, then `wf preview`. The configured registry must +In its terminal, run `wf install`, then `wf preview` (or `wf dev`: editing the rendering in +`Life.tsx` then keeps the grid, the generation and the connection, see +[hot replacement](DEVELOPER_ENVIRONMENT.md#hot-replacement); `main.tsx` only starts the page, so a change of it reloads). The configured registry must carry `@webfront/react@0.2.0` and its dependency `@webfront/store@0.1.0`; this change prepares the archive but does not publish to npm. The repository's test registry already carries the package. For a local evaluation, configure the driver with `--registry-dir /test/web/self-build-project/build-registry`; diff --git a/examples/life/react/Life.tsx b/examples/life/react/Life.tsx new file mode 100644 index 00000000..98af10ee --- /dev/null +++ b/examples/life/react/Life.tsx @@ -0,0 +1,55 @@ +import React, {useEffect, useRef, useState} from 'react'; +import {Island, useStore, type DomInterpreter, type Store} from '@webfront/react'; + +// The live cells as bits, the generation and the population, published by C++. +export type Board = [Uint8Array, number, number]; + +export function Life({started, store, toggle, dom}: { + started: boolean; + store: Store; + toggle: (index: number) => void; + dom: DomInterpreter; +}) { + const [cells, generation, population] = useStore(store); + const [cursor, setCursor] = useState(0); + // The live region speaks once the keyboard is used: the chosen cell and its state, again when C++ changes it. + const [keyboard, setKeyboard] = useState(false); + const alive = (cells[cursor >> 3] & (1 << (cursor & 7))) !== 0; + const said = keyboard ? `Row ${(cursor >> 5) + 1}, column ${cursor % 32 + 1}: ${alive ? 'alive' : 'dead'}` : ''; + const canvas = useRef(null); + useEffect(() => { + const context = canvas.current!.getContext('2d')!; + for (let i = 0; i < 1024; ++i) { + context.fillStyle = cells[i >> 3] & (1 << (i & 7)) ? '#81efbd' : '#16362c'; + context.fillRect((i % 32) * 12, (i >> 5) * 12, 11, 11); + } + context.strokeStyle = '#ffd27d'; + context.strokeRect((cursor % 32) * 12 + .5, (cursor >> 5) * 12 + .5, 10, 10); + }, [cells, cursor]); + return
+

Game of Life · React + C++ island

+

Generation {generation} · {population} living cells

+ { + const steps: Record = {ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1]}; + if (Object.hasOwn(steps, event.key)) { + const [dx, dy] = steps[event.key]; + setCursor(((cursor >> 5) + dy + 32) % 32 * 32 + (cursor % 32 + dx + 32) % 32); + } else if (started && (event.key === ' ' || event.key === 'Enter')) toggle(cursor); + else return; + event.preventDefault(); + setKeyboard(true); + }} + onClick={event => { + if (!started) return; + const rect = event.currentTarget.getBoundingClientRect(); + const x = Math.floor((event.clientX - rect.left) * 32 / rect.width); + const y = Math.floor((event.clientY - rect.top) * 32 / rect.height); + toggle(y * 32 + x); + }}/> + +

{said}

+
; +} diff --git a/examples/life/react/LifeReact.cpp b/examples/life/react/LifeReact.cpp index 8e11417a..f7afe830 100644 --- a/examples/life/react/LifeReact.cpp +++ b/examples/life/react/LifeReact.cpp @@ -24,7 +24,7 @@ int main(int argc, char** argv) { std::cerr << "Usage: WebFrontLifeReact [--port ] []\n" "Without argument the project is ./" << webfront::demo::LifeDeveloperOptions::defaultProject - << ", created empty when missing: copy main.tsx and webfront.project.json from examples/life/react/ into it first.\n"; + << ", created empty when missing: copy main.tsx, Life.tsx and webfront.project.json from examples/life/react/ into it first.\n"; return 2; } try { diff --git a/examples/life/react/main.tsx b/examples/life/react/main.tsx index 59488b5b..dd024420 100644 --- a/examples/life/react/main.tsx +++ b/examples/life/react/main.tsx @@ -1,6 +1,8 @@ -import React, {StrictMode, useEffect, useRef, useState} from 'react'; +import React, {StrictMode} from 'react'; import {createRoot} from 'react-dom/client'; -import {Island, createStore, useStore} from '@webfront/react'; +import {createStore} from '@webfront/react'; +// The component has its own module: `wf dev` replaces it in place (Fast Refresh), keeping the store and the connection. +import {Life, type Board} from './Life'; // The optional interpreter is served by WebFront, not bundled into the adapter. const interpreterUrl = '/webfront-dom.mjs'; @@ -14,56 +16,13 @@ declare const webFront: { async function main() { const {installDomInterpreter} = await import(interpreterUrl); const dom = installDomInterpreter(webFront); - const store = createStore<[Uint8Array, number, number]>('life', [new Uint8Array(128), 0, 0]); + const store = createStore('life', [new Uint8Array(128), 0, 0]); const toggle = (index: number) => void webFront.cppFunction('life.react.toggle')(index).catch(showError); - function Life({started}: {started: boolean}) { - const [cells, generation, population] = useStore(store); - const [cursor, setCursor] = useState(0); - // The live region speaks once the keyboard is used: the chosen cell and its state, again when C++ changes it. - const [keyboard, setKeyboard] = useState(false); - const alive = (cells[cursor >> 3] & (1 << (cursor & 7))) !== 0; - const said = keyboard ? `Row ${(cursor >> 5) + 1}, column ${cursor % 32 + 1}: ${alive ? 'alive' : 'dead'}` : ''; - const canvas = useRef(null); - useEffect(() => { - const context = canvas.current!.getContext('2d')!; - for (let i = 0; i < 1024; ++i) { - context.fillStyle = cells[i >> 3] & (1 << (i & 7)) ? '#81efbd' : '#16362c'; - context.fillRect((i % 32) * 12, (i >> 5) * 12, 11, 11); - } - context.strokeStyle = '#ffd27d'; - context.strokeRect((cursor % 32) * 12 + .5, (cursor >> 5) * 12 + .5, 10, 10); - }, [cells, cursor]); - return
-

Game of Life · React + C++ island

-

Generation {generation} · {population} living cells

- { - const steps: Record = {ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1]}; - if (Object.hasOwn(steps, event.key)) { - const [dx, dy] = steps[event.key]; - setCursor(((cursor >> 5) + dy + 32) % 32 * 32 + (cursor % 32 + dx + 32) % 32); - } else if (started && (event.key === ' ' || event.key === 'Enter')) toggle(cursor); - else return; - event.preventDefault(); - setKeyboard(true); - }} - onClick={event => { - if (!started) return; - const rect = event.currentTarget.getBoundingClientRect(); - const x = Math.floor((event.clientX - rect.left) * 32 / rect.width); - const y = Math.floor((event.clientY - rect.top) * 32 / rect.height); - toggle(y * 32 + x); - }}/> - -

{said}

-
; - } function showError(error: unknown) { document.getElementById('error')!.textContent = String(error); } + const board = {dom, store, toggle}; const root = createRoot(document.getElementById('root')!); try { - root.render(); + root.render(); // Wait for the committed Island before lending it to C++; store reception is already installed. const deadline = performance.now() + 5000; while (!document.querySelector('[data-testid="cpp-panel"]')) { @@ -73,7 +32,7 @@ async function main() { await dom.connect(); await webFront.cppFunction('life.react.start')(); // Survive a lost connection: keep what the page showed then, and hand it to the new C++ session. - let kept: [Uint8Array, number, number] | null = null; + let kept: Board | null = null; webFront.reconnect = true; webFront.onDisconnect(() => { kept ??= store.getSnapshot(); }); webFront.onReconnect(() => void (async () => { @@ -83,7 +42,7 @@ async function main() { await webFront.cppFunction('life.react.restore')(cells, generation); kept = null; })().catch(showError)); - root.render(); + root.render(); } catch (error) { root.unmount(); store.dispose(); diff --git a/test/cmake/PrepareWfProject.cmake b/test/cmake/PrepareWfProject.cmake index 22bd6d3b..f6d13fda 100644 --- a/test/cmake/PrepareWfProject.cmake +++ b/test/cmake/PrepareWfProject.cmake @@ -29,4 +29,7 @@ if(LIFE_REACT) get_filename_component(entry_directory "${PROJECT}/${life_react_entry}" DIRECTORY) file(MAKE_DIRECTORY "${entry_directory}") file(COPY_FILE "${LIFE_REACT}" "${PROJECT}/${life_react_entry}") + # The component the example's entry imports. + get_filename_component(life_react_source "${LIFE_REACT}" DIRECTORY) + file(COPY "${life_react_source}/Life.tsx" DESTINATION "${entry_directory}") endif() diff --git a/test/web/suite/tsconfig.json b/test/web/suite/tsconfig.json index 9f414696..ef6206a2 100644 --- a/test/web/suite/tsconfig.json +++ b/test/web/suite/tsconfig.json @@ -18,6 +18,7 @@ "types/store.ts", "types/services.ts", "types/pty.ts", - "pages/life-react.tsx" + "pages/life-react.tsx", + "pages/Life.tsx" ] } From 46828789e46cbae2ee1acf487d3676debdbf5db6 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sun, 6 Dec 2026 01:40:29 +0100 Subject: [PATCH 03/10] Replace modules in place in wf dev with React Fast Refresh and import.meta.hot (#763) --- js/developer/environment/bundler.mjs | 28 +- js/developer/environment/bundles.json | 14 +- js/developer/environment/compiler.mjs | 21 +- js/developer/environment/development.mjs | 70 ++- js/developer/environment/hot-preamble.mjs | 10 + js/developer/environment/hot-runtime.mjs | 127 +++++ js/developer/environment/hot.mjs | 128 ++++++ js/developer/environment/refresh.mjs | 12 + js/developer/scripts/build.mjs | 18 +- js/developer/tools/bundle-inputs.json | 4 + js/developer/webfront-packages.lock.json | 512 +++++++++++++++------ js/developer/webfront.project.json | 5 +- test/cmake/AssembleDeveloperFixtures.cmake | 2 + test/developer/specs/development-specs.mjs | 2 +- test/developer/specs/hot-specs.mjs | 114 +++++ test/web/CMakeLists.txt | 4 +- test/web/DeveloperTest.cpp | 9 +- test/web/developer-specs.mjs | 120 +++++ test/web/registry-packages.json | 12 + 19 files changed, 1038 insertions(+), 174 deletions(-) create mode 100644 js/developer/environment/hot-preamble.mjs create mode 100644 js/developer/environment/hot-runtime.mjs create mode 100644 js/developer/environment/hot.mjs create mode 100644 js/developer/environment/refresh.mjs create mode 100644 test/developer/specs/hot-specs.mjs diff --git a/js/developer/environment/bundler.mjs b/js/developer/environment/bundler.mjs index a5ff5c5f..82f946e5 100644 --- a/js/developer/environment/bundler.mjs +++ b/js/developer/environment/bundler.mjs @@ -49,7 +49,7 @@ export function virtualPlugin(lock, packages, readProject) { return virtualPluginWith(lock, packages, readProject, new Map()); } -function virtualPluginWith(lock, packages, readProject, loaded) { +export function virtualPluginWith(lock, packages, readProject, loaded) { const {read, find} = createFinder(packages, readProject, loaded, lock); const load = namespace => async args => { const bytes = loaded.get(`${namespace}:${args.path}`) ?? await read(namespace, args.path); @@ -65,12 +65,13 @@ function virtualPluginWith(lock, packages, readProject, loaded) { }}; } -function applicationOptions({entry, lock, packages, readProject}) { +function applicationOptions({entry, lock, packages, readProject, loaded = new Map()}) { return {entryPoints: [entry], bundle: true, write: false, outdir: '/output', entryNames: 'app', assetNames: 'assets/[name]-[hash]', format: 'esm', platform: 'browser', target: 'es2020', jsx: 'automatic', minify: true, - define: {'process.env.NODE_ENV': '"production"'}, legalComments: 'inline', - plugins: [virtualPlugin(lock, packages, readProject)]}; + // No hot replacement outside `wf dev`: the branches that use import.meta.hot are dropped. + define: {'process.env.NODE_ENV': '"production"', 'import.meta.hot': 'undefined'}, legalComments: 'inline', + plugins: [virtualPluginWith(lock, packages, readProject, loaded)]}; } const outputFiles = result => new Map(result.outputFiles.map(file => [file.path.replace(/^\/output\//, ''), file.contents])); @@ -79,10 +80,21 @@ export async function bundle(esbuild, options) { return outputFiles(await esbuild.build(applicationOptions(options))); } -/** One esbuild context for repeated builds; the virtual filesystem is read again on every rebuild. */ -export async function bundleContext(esbuild, options) { - const context = await esbuild.context(applicationOptions(options)); - return {rebuild: async () => outputFiles(await context.rebuild()), dispose: () => context.dispose()}; +/** + * One esbuild context for repeated builds; the virtual filesystem is read again on every rebuild. With `hot`, the result + * is {files, hot, reason} as hot.mjs gives it. + */ +export async function bundleContext(esbuild, {hot, ...options}) { + const loaded = new Map(); + const context = await esbuild.context({...applicationOptions({...options, loaded}), metafile: Boolean(hot)}); + return { + async rebuild() { + const result = await context.rebuild(); + const files = outputFiles(result); + return hot ? hot.build({...options, files, metafile: result.metafile, sources: loaded}) : {files}; + }, + dispose: () => context.dispose(), + }; } // Node.js built-in modules: a script importing one fails while it is loaded, unless a locked package of that name diff --git a/js/developer/environment/bundles.json b/js/developer/environment/bundles.json index 464658a5..6ef883ed 100644 --- a/js/developer/environment/bundles.json +++ b/js/developer/environment/bundles.json @@ -21,7 +21,7 @@ "js/developer/environment/automation.mjs": "708a6a72925c8f667160e3b76e9da9e96139b281e37844a3467b064ccee2586a", "js/developer/environment/accessibility-tree.mjs": "af4487259737706d9c997ccee13f91c376d0a915eeda25f06b975135e524c192", "js/developer/environment/bindings.mjs": "10e6f3958b84f0efbad23a7da5a751d8654e8c46922da3eb5dc44081ef392677", - "js/developer/environment/development.mjs": "2bbf0970097f412fd08e5c2124c736a2260f8180ad41ae037689f5d3729e1370", + "js/developer/environment/development.mjs": "1118d9c91ae9c0b942458df4e6e21102eb596b1c3cd6b833e6fdf51f06e5a678", "js/developer/environment/testing.mjs": "ab830e23a018d4f9ed9cf57071e63341e5dca7720d2ceac9baaba20786f96ffd", "js/developer/environment/terminal.mjs": "26bcc86f2e34a181f3d9e57b8a94a972aeb06cb636e14c7d5a935231c3c64f48", "js/developer/environment/workspace.mjs": "3d11d99228593b2b3af95e3537a3e62b9569e5bfac2387403bd51ed621be8f38", @@ -37,8 +37,12 @@ "js/developer/environment/commands.mjs": "264dd9246d998f21988bffb1f1b096fc8087e29e66b5e9c4f6345529568c5b51", "js/developer/environment/files.mjs": "199336f7f3d23f6370da352993bf4686738b1f394b79aa9883769d19824540e0", "js/developer/environment/dependencies.mjs": "7f536e30584b10822dea6b5642fd584e5935c58f90a271ee70a03d3023e9dd34", - "js/developer/environment/compiler.mjs": "0158931132aa9b43b7bbbd01de6fa4fc34fce8c65515d593dd494930f7a1910f", - "js/developer/environment/bundler.mjs": "48658151aae4fa5ad54c9fa3386ef4095b793de0f3ad242f95e8e5de0cd0ce4d", + "js/developer/environment/compiler.mjs": "697e1c9fbb97e27ea8eb1321918e55771abe807588ab5a24bbdc55d7fb645a26", + "js/developer/environment/bundler.mjs": "3557ac43865177f3a4d5635d83683c72eaa91f06f995345293fbff5d396ff6ce", + "js/developer/environment/hot.mjs": "7f168ece76f67f42a58b07549b8d462dac9cdd2511d14c6f10808abbbc0f4265", + "js/developer/environment/hot-runtime.mjs": "1817b258b40adafb34c7942a6b4af4b4580bf3640471bbf233517eda42b2afda", + "js/developer/environment/hot-preamble.mjs": "29f7415fdfe3a6227f87738defec4d8d89a613043d47685d30874e1e90436aa3", + "js/developer/environment/refresh.mjs": "7e4a25c0dd702ef23159e462d048805ac56daaba94a1a5abcf3828e1e1dbddaf", "js/developer/environment/entry.mjs": "afc3c0555a6383d75af678fef31d5c6cb8a355c3b62208a72ef2ce9453115c9c", "js/developer/environment/conditions.mjs": "7f0ecba239480831e38985ccffd4c82309949924f4eb9d938e4ad1b09f5f36ed", "js/developer/environment/io.mjs": "21af39f07c7eb863908c1df768e3c31de1c6eb8ff757c2a287c4a47c76855db6", @@ -64,8 +68,8 @@ "js/developer/tools/distribution.json": "133bfe97f126d35ad1e40250290b88b72f49b995409723105fce59df101ad50d", "js/developer/tools/archive.mjs": "da63bb9d796ddfd24ed945b15c53f66a0400eb177886fd4f1c8fd10cafb5a91b", "js/developer/tools/distribution.mjs": "43dfdccc912693db46fd095fd78ae79325abab672d99f89fd569914ef3499cad", - "js/developer/scripts/build.mjs": "82a9b92942d904a6a98bf0ba1dcdb6a9ef44867f5568475b46097508d1e6e931", - "js/developer/webfront.project.json": "7870620b217258e9843bedf474cbba188939f84208c3387bcd4c7f23c79d4f11", + "js/developer/scripts/build.mjs": "27d759235705433fc942b6bca2f2833273125a265e89884f953c85320cbe68ae", + "js/developer/webfront.project.json": "1e6058e1c905f39ab4e1f794e71e208847543c804fa30d85cf20e71d306329d1", "js/core/bootstrap/bootstrap.bundle.mjs": "18a0567efa928fddbaa3f8d16a4d1e8440f21709ff2e3058d10ba406b2e9b66d", "js/developer/environment/packages.bundle.mjs": "f148187eab89acb6b959fc273d985a45850c9c42cccb200091173895655a8826", "include/webfront/system/DeveloperReleaseData.hpp": "527927cc77e8874dd12553faa76149405e772e97197b611b3b89e9f1136a2c5b" diff --git a/js/developer/environment/compiler.mjs b/js/developer/environment/compiler.mjs index e9bb6769..deb2bda3 100644 --- a/js/developer/environment/compiler.mjs +++ b/js/developer/environment/compiler.mjs @@ -1,5 +1,6 @@ import * as esbuild from 'esbuild-wasm'; import {bundle, bundleScript, bundleTests, bundleContext} from './bundler.mjs'; +import {hotBuilder} from './hot.mjs'; const pending = new Map(); let nextId = 0; @@ -10,6 +11,16 @@ const readProject = path => new Promise((resolve, reject) => { }); const initialized = esbuild.initialize({wasmURL: new URL('./esbuild.wasm', import.meta.url).href, worker: false}); let context, contextKey; +// Both are files of the environment beside this Worker, read for hot previews only. +let preambleText, refreshModule; +async function hotOptions() { + preambleText ??= await fetch(new URL('./hot-preamble.js', import.meta.url).href).then(response => { + if (!response.ok) throw new Error('Cannot read hot-preamble.js of the environment'); + return response.text(); + }); + return hotBuilder(esbuild, {preamble: preambleText, + refresh: () => refreshModule ??= import(new URL('./refresh.mjs', import.meta.url).href)}); +} const bundlers = {build: bundle, script: bundleScript, tests: bundleTests}; self.onmessage = async ({data}) => { if (data.type === 'read-result') { @@ -23,18 +34,18 @@ self.onmessage = async ({data}) => { if (!Object.hasOwn(bundlers, data.type)) return; try { await initialized; - let files; + let files, hot, reason; if (data.incremental) { - const key = JSON.stringify([data.entry, data.lock]); + const key = JSON.stringify([data.entry, data.lock, Boolean(data.hot)]); if (key !== contextKey) { await context?.dispose(); contextKey = undefined; - context = await bundleContext(esbuild, {...data, readProject}); + context = await bundleContext(esbuild, {entry: data.entry, lock: data.lock, readProject, hot: data.hot && await hotOptions()}); contextKey = key; } - files = await context.rebuild(); + ({files, hot, reason} = await context.rebuild()); } else files = await bundlers[data.type](esbuild, {...data, readProject}); - self.postMessage({type: 'result', files}); + self.postMessage({type: 'result', files, hot, reason}); } catch (error) { self.postMessage({type: 'error', error: error.message, diagnostics: error.errors?.map(({text, location}) => ({text, location}))}); } diff --git a/js/developer/environment/development.mjs b/js/developer/environment/development.mjs index 4438024e..4379e376 100644 --- a/js/developer/environment/development.mjs +++ b/js/developer/environment/development.mjs @@ -66,7 +66,7 @@ export function compilerSession(bridge, signal, createWorker = () => new Worker( response = {error: error.message}; } if (!closed && pending) worker.postMessage({type: 'read-result', id: data.id, ...response}); - } else if (data.type === 'result') finish(null, data.files); + } else if (data.type === 'result') finish(null, Object.assign(data.files, {hot: data.hot, hotReason: data.reason})); else if (data.type === 'error') finish(Object.assign(new Error(data.error), {diagnostics: data.diagnostics})); }; if (signal?.aborted) abort(); @@ -120,12 +120,54 @@ export const previewHook = "