From b01077338810f138d89feacef334a5ebf6252e14 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Tue, 10 Nov 2026 23:21:20 +0100 Subject: [PATCH 01/11] Open the developer page on the interface and float the terminal behind an icon (#539) The environment's mount lays the page out: the terminal alone while the project has no published preview, then the interface over the whole window with the terminal in a floating, movable window that an icon or F9 opens and collapses. Collapsing only hides the terminal, so its session is kept. The place of the window is remembered per project. --- js/developer/environment/runtime.mjs | 20 +- js/developer/environment/workspace.mjs | 300 +++++++++++++++++++++++ js/developer/tools/bundle-inputs.json | 1 + js/developer/webfront.project.json | 1 + test/developer/specs/workspace-specs.mjs | 143 +++++++++++ 5 files changed, 461 insertions(+), 4 deletions(-) create mode 100644 js/developer/environment/workspace.mjs create mode 100644 test/developer/specs/workspace-specs.mjs diff --git a/js/developer/environment/runtime.mjs b/js/developer/environment/runtime.mjs index bb1d6cf3..6a85e886 100644 --- a/js/developer/environment/runtime.mjs +++ b/js/developer/environment/runtime.mjs @@ -17,6 +17,7 @@ import {parseTestOptions, specFiles, jasmineCore, runnerFiles, runInFrame, repor import {generateProvider, applicationPage} from './embed.mjs'; import {typescriptPackage, parseCheckOptions, checkHost} from './typecheck.mjs'; import {pinnedStarters} from './bootstrap.mjs'; +import {createWorkspace, isManaged} from './workspace.mjs'; import {connectAutomation as connectAgent, clipText, automationHelp, onAutomationNotice} from './automation.mjs'; const encoder = new TextEncoder(); @@ -539,8 +540,11 @@ export async function complete(line, {bridge, cppCommands = new Map()}) { * Mounts the terminal in `element`. Each page has its own session: its history comes from the project, its C++ * commands run in this browser's session. `onExit(code)` ends the session after exit (by default, closes the window). * `fitToElement: false` keeps the terminal's size as set by terminal.resize() instead of following the element's. + * With a `preview` frame, the first terminal mounted lays the page out (workspace.mjs): the terminal alone while the + * project has no interface, then the interface over the whole window and the terminal in a floating window that an icon + * opens and collapses. `workspace: false` leaves the page as it is. */ -export async function mount({bridge, config, terminal: element, preview, onExit, fitToElement = true}) { +export async function mount({bridge, config, terminal: element, preview, onExit, fitToElement = true, workspace: layout = true}) { setManifestDirectory(config?.manifestDirectory); const link = document.createElement('link'); link.rel = 'stylesheet'; @@ -555,6 +559,7 @@ export async function mount({bridge, config, terminal: element, preview, onExit, terminal.unicode.activeVersion = unicodeProvider.version; const fit = new FitAddon(); terminal.loadAddon(fit); + const workspace = layout && preview && !isManaged(preview) ? await createWorkspace({bridge, element, frame: preview}) : null; terminal.open(element); fit.fit(); const write = text => terminal.write(text); @@ -574,15 +579,22 @@ export async function mount({bridge, config, terminal: element, preview, onExit, run: (line, signal) => runLine(line, {...context, editor, signal, write: text => editor.write(text)}), complete: line => complete(line, context)}); terminal.onResize(() => editor.resized()); - if (fitToElement) new ResizeObserver(() => fit.fit()).observe(element); + // An element without a size is not laid out: fitting to it would shrink the terminal and reflow its lines. + const fitTerminal = () => { if (element.clientWidth && element.clientHeight) fit.fit(); }; + if (fitToElement) new ResizeObserver(fitTerminal).observe(element); terminal.onData(data => editor.handle(data)); // Automation must be visible to the person using the terminal: say so once it is connected, grants and attach path included. onAutomationNotice(text => { write(`\r\x1b[K\x1b[33m${text}\x1b[0m\r\n`); if (!editor.busy) editor.showPrompt(); + workspace?.open({focus: false}); // a collapsed terminal would hide the notice }); editor.showPrompt(); for (const data of early) editor.handle(data); - terminal.focus(); - return {terminal, editor}; + if (workspace) { + // The interface the project already has fills the window; the keys go to it while the terminal is collapsed. + if (workspace.interfaceExists) showPreview(preview); + workspace.attach({focus: () => terminal.focus(), fit: fitToElement ? fitTerminal : undefined}); + } else terminal.focus(); + return {terminal, editor, workspace}; } diff --git a/js/developer/environment/workspace.mjs b/js/developer/environment/workspace.mjs new file mode 100644 index 00000000..102d729f --- /dev/null +++ b/js/developer/environment/workspace.mjs @@ -0,0 +1,300 @@ +// The layout of the developer page: the terminal alone while the project has no interface, then the interface over the +// whole window with the terminal in a floating, movable window that an icon opens and collapses. The terminal is mounted +// once in its window and never moves in the document afterwards: collapsing only hides it, so the session, a running +// command, the line being typed and the scrollback are kept. The interface stays in the preview frame. +import {call, readProject, publish} from './io.mjs'; + +const encoder = new TextEncoder(); +const decoder = new TextDecoder(); + +// --- Existing interface ---------------------------------------------------------------------------------------- + +/** Where wf dev and wf preview publish the interface; a publication replaces it whole, so a failed build keeps the last one. */ +export const previewDirectory = '.webfront/developer/preview'; + +/** Whether the project already has an interface to show: a published preview with its page. */ +export async function hasInterface(bridge) { + try { return JSON.parse(decoder.decode(await call(bridge, 'list', previewDirectory))).includes('index.html'); } + catch { return false; } // no preview directory yet +} + +// --- States ---------------------------------------------------------------------------------------------------- + +/** terminal: no interface, the terminal fills the window; interface: the interface alone; floating: the terminal over it. */ +export const State = {terminal: 'terminal', interface: 'interface', floating: 'floating'}; + +/** The state a page opens in. */ +export const initialState = interfaceExists => interfaceExists ? State.interface : State.terminal; + +const transitions = { + // An interface that appears while the terminal is in use leaves it open, over the interface. + [State.terminal]: {shown: State.floating}, + [State.interface]: {toggle: State.floating, open: State.floating, hidden: State.terminal}, + [State.floating]: {toggle: State.interface, close: State.interface, hidden: State.terminal}, +}; + +/** + * The state after an event: `shown` and `hidden` (the preview frame appears or disappears), `toggle` (the icon or the + * shortcut), `open` and `close`. An event that does not apply leaves the state unchanged. + */ +export const nextState = (state, event) => transitions[state]?.[event] ?? state; + +// --- Geometry -------------------------------------------------------------------------------------------------- + +export const minimumSize = {width: 320, height: 160}; +export const step = 16; +const clamp = (value, low, high) => Math.min(Math.max(value, low), Math.max(low, high)); + +/** The window fitted to the viewport: no larger than it (even below the minimum size) and entirely inside it. */ +export function clampRect(rect, viewport) { + const width = Math.round(Math.min(clamp(rect.width, minimumSize.width, viewport.width), viewport.width)); + const height = Math.round(Math.min(clamp(rect.height, minimumSize.height, viewport.height), viewport.height)); + return {x: Math.round(clamp(rect.x, 0, viewport.width - width)), y: Math.round(clamp(rect.y, 0, viewport.height - height)), width, height}; +} + +/** Where the window opens when the project has no remembered place: at the bottom of the viewport, clear of the icon. */ +export function defaultRect(viewport) { + const width = Math.min(760, viewport.width - 2 * step), height = Math.min(360, Math.round(viewport.height * 0.45)); + return clampRect({x: viewport.width - width - step, y: viewport.height - height - step, width, height}, viewport); +} + +const arrows = {ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1]}; + +/** The window after an arrow key on its title bar: moved by a step, or resized with Shift. Null for another key. */ +export function keyboardRect(rect, {key, shiftKey = false}, viewport) { + if (!Object.hasOwn(arrows, key)) return null; + const [dx, dy] = arrows[key].map(direction => direction * step); + return clampRect(shiftKey ? {...rect, width: rect.width + dx, height: rect.height + dy} : {...rect, x: rect.x + dx, y: rect.y + dy}, viewport); +} + +/** F9 alone: neither the line editor nor xterm.js uses it, and browsers leave it to the page. */ +export const isToggleKey = event => event.key === 'F9' && !(event.ctrlKey || event.altKey || event.metaKey || event.shiftKey); + +// --- Remembered place ------------------------------------------------------------------------------------------ + +/** The place of the window, kept in the project like the history: each project has its own. */ +export const placePath = '.webfront/developer/terminal-window.json'; + +/** The remembered rectangle of a file's text; null when it is not one. */ +export function parsePlace(text) { + try { + const {format, x, y, width, height} = JSON.parse(text); + const rect = {x, y, width, height}; + if (format !== 1 || !Object.values(rect).every(value => Number.isFinite(value) && Math.abs(value) < 1e6)) return null; + return rect.width > 0 && rect.height > 0 ? rect : null; + } catch { return null; } +} + +export const formatPlace = ({x, y, width, height}) => JSON.stringify({format: 1, x, y, width, height}) + '\n'; + +export async function readPlace(bridge) { + try { return parsePlace(decoder.decode(await readProject(bridge, placePath))); } + catch { return null; } +} + +/** + * Remembers the last place given, shortly after it stops changing; a failed write keeps the window usable. `saved()` + * resolves once the places given so far are written. + */ +export function placeStore(bridge, delay = 300) { + let timer = null, pending = null, writes = Promise.resolve(), written = null; + const flush = () => { + clearTimeout(timer); + timer = null; + if (!pending) return writes; + const text = formatPlace(pending); + pending = null; + if (text !== written) writes = writes + .then(() => publish(bridge, placePath, new Map([['output', encoder.encode(text)]]), {directory: false})) + .then(() => { written = text; }, () => {}); + return writes; + }; + return { + remember(rect) { + pending = rect; + clearTimeout(timer); + timer = setTimeout(flush, delay); + }, + saved: () => flush(), + }; +} + +// --- Page ------------------------------------------------------------------------------------------------------ + +// The WebFront swallow, shipped in the environment. +const logo = ''; + +const attribute = 'data-webfront-workspace'; +const floating = `:root:is([${attribute}=interface],[${attribute}=floating])`; +const styles = ` +:root[${attribute}],:root[${attribute}] body{height:100%} +:root[${attribute}] body{display:flex;flex-direction:column;overflow:hidden} +${floating} body>header{display:none} +.webfront-terminal-window{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;box-sizing:border-box;background:#141821} +${floating} .webfront-terminal-window{position:fixed;z-index:2147483646;border:1px solid #46536a;border-radius:8px;box-shadow:0 8px 32px #000a;resize:both;overflow:hidden;max-width:100vw;max-height:100vh} +:root[${attribute}=interface] .webfront-terminal-window{visibility:hidden} +.webfront-terminal-bar{display:none;flex:none;align-items:center;justify-content:space-between;padding:0 4px 0 12px;background:#202737;color:#e8edf4;font:13px system-ui;cursor:move;user-select:none;touch-action:none} +${floating} .webfront-terminal-bar{display:flex} +.webfront-terminal-bar:focus-visible,.webfront-terminal-close:focus-visible,.webfront-terminal-toggle:focus-visible{outline:2px solid #d7fa85;outline-offset:-2px} +.webfront-terminal-close{margin:0;padding:0;width:32px;height:32px;border:0;background:none;color:inherit;font:20px/1 system-ui;cursor:pointer} +.webfront-terminal-toggle{position:fixed;top:8px;right:8px;z-index:2147483647;margin:0;padding:0;width:44px;height:44px;display:grid;place-items:center;border:1px solid #46536a;border-radius:50%;background:#f6f7f2;box-shadow:0 2px 8px #0006;cursor:pointer;opacity:.9} +.webfront-terminal-toggle:hover,.webfront-terminal-toggle[aria-expanded=true]{opacity:1} +:root[${attribute}=terminal] .webfront-terminal-toggle{display:none} +`; + +const managed = new WeakSet(); +/** Whether a workspace already lays out this preview frame: a page has one, whatever the terminals mounted in it. */ +export const isManaged = frame => managed.has(frame); + +/** + * Lays the page out around the terminal's `element` and the preview `frame`, which starts hidden. Call it before the + * terminal opens in `element`, then attach({focus, fit}) with the functions that focus the terminal and fit it to `element`. + * The result gives the `state`, `interfaceExists` (the page opened on an existing interface, to load in the frame), + * toggle(), open({focus}) and close(), `button` and `panel`, and placeSaved(). + */ +export async function createWorkspace({bridge, element, frame}) { + managed.add(frame); + const page = element.ownerDocument, view = page.defaultView, root = page.documentElement; + const [interfaceExists, remembered] = await Promise.all([hasInterface(bridge), readPlace(bridge)]); + const store = placeStore(bridge); + const viewport = () => ({width: root.clientWidth, height: root.clientHeight}); + let state = initialState(interfaceExists); + let place = remembered; // as chosen; what is displayed is fitted to the viewport + let focusTerminal = () => {}, fitTerminal = () => {}; + + const style = page.createElement('style'); + style.textContent = styles; + page.head.append(style); + + const panel = page.createElement('section'); + panel.className = 'webfront-terminal-window'; + panel.id = 'webfront-terminal-window'; + panel.setAttribute('role', 'dialog'); + panel.setAttribute('aria-modal', 'false'); + panel.setAttribute('aria-label', 'WebFront terminal'); + const bar = page.createElement('div'); + bar.className = 'webfront-terminal-bar'; + bar.tabIndex = 0; + bar.setAttribute('role', 'group'); + bar.setAttribute('aria-label', 'Terminal window: drag it, or use the arrow keys to move it and Shift with the arrow keys to resize it'); + const title = page.createElement('span'); + title.textContent = 'Terminal'; + const closeButton = page.createElement('button'); + closeButton.type = 'button'; + closeButton.className = 'webfront-terminal-close'; + closeButton.setAttribute('aria-label', 'Hide the terminal'); + closeButton.title = 'Hide the terminal (F9)'; + closeButton.textContent = '×'; + bar.append(title, closeButton); + element.replaceWith(panel); + panel.append(bar, element); + Object.assign(element.style, {flex: '1 1 auto', height: 'auto', minHeight: '0', boxSizing: 'border-box'}); + Object.assign(frame.style, {position: 'fixed', inset: '0', width: '100%', height: '100%'}); + + const button = page.createElement('button'); + button.type = 'button'; + button.className = 'webfront-terminal-toggle'; + button.innerHTML = logo; + button.setAttribute('aria-controls', panel.id); + page.body.append(button); + + // The displayed rectangle; the chosen one is kept, so that a window enlarged again gives the terminal its place back. + const shown = () => clampRect(place ?? defaultRect(viewport()), viewport()); + function render() { + root.setAttribute(attribute, state); + const open = state === State.floating; + button.setAttribute('aria-expanded', String(open)); + button.setAttribute('aria-label', open ? 'Hide the WebFront terminal' : 'Show the WebFront terminal'); + button.title = `${open ? 'Hide' : 'Show'} the terminal (F9)`; + const rect = state === State.terminal ? null : shown(); + Object.assign(panel.style, rect ? {left: `${rect.x}px`, top: `${rect.y}px`, width: `${rect.width}px`, height: `${rect.height}px`} + : {left: '', top: '', width: '', height: ''}); + fitTerminal(); // its window may have changed size + } + function choose(rect) { + place = clampRect(rect, viewport()); + store.remember(place); + render(); + } + function apply(event, {focus = true} = {}) { + const before = state; + state = nextState(state, event); + if (state === before) return; + render(); + if (!focus) return; + if (state === State.interface) frame.focus(); // the keys go back to the interface + else focusTerminal(); + } + + button.addEventListener('click', () => apply('toggle')); + closeButton.addEventListener('click', () => apply('close')); + // The preview commands show the frame (and nothing else hides it): the layout follows it. + new view.MutationObserver(() => apply(frame.hidden ? 'hidden' : 'shown')).observe(frame, {attributes: true, attributeFilter: ['hidden']}); + + // The shortcut works wherever the focus is: in this page and in the interface, whose window changes at each load. + const onKey = event => { + if (!isToggleKey(event) || state === State.terminal) return; + event.preventDefault(); + event.stopPropagation(); + apply('toggle'); + }; + view.addEventListener('keydown', onKey, true); + const watchInterface = () => { + try { frame.contentWindow?.addEventListener('keydown', onKey, true); } + catch { /* a page of another origin keeps its keys */ } + }; + frame.addEventListener('load', watchInterface); + watchInterface(); + + // Moving: the pointer is captured, so that the interface under the window does not take the moves. + let grip = null; + bar.addEventListener('pointerdown', event => { + if (event.button !== 0 || event.target === closeButton) return; + const rect = shown(); + grip = {x: event.clientX - rect.x, y: event.clientY - rect.y}; + try { bar.setPointerCapture(event.pointerId); } + catch { /* a pointer that is already gone: the move ends with it */ } + event.preventDefault(); + bar.focus(); + }); + bar.addEventListener('pointermove', event => { + if (grip) choose({...shown(), x: event.clientX - grip.x, y: event.clientY - grip.y}); + }); + const release = () => { grip = null; }; + bar.addEventListener('pointerup', release); + bar.addEventListener('pointercancel', release); + bar.addEventListener('keydown', event => { + if (event.target !== bar) return; + const rect = keyboardRect(shown(), event, viewport()); + if (!rect) return; + event.preventDefault(); + choose(rect); + }); + // The corner handle (CSS resize) writes the size on the element: it becomes the chosen one. + new view.ResizeObserver(() => { + if (state !== State.floating) return; + const rect = shown(), width = panel.offsetWidth, height = panel.offsetHeight; + if (width && height && (width !== rect.width || height !== rect.height)) choose({...rect, width, height}); + }).observe(panel); + view.addEventListener('resize', render); + + render(); + return { + get state() { return state; }, + interfaceExists, button, panel, bar, + attach({focus, fit = () => {}}) { + focusTerminal = focus; + fitTerminal = fit; + if (state === State.interface) frame.focus(); else focus(); + }, + toggle: () => apply('toggle'), + open: options => apply('open', options), + close: () => apply('close'), + placeSaved: () => store.saved(), + }; +} diff --git a/js/developer/tools/bundle-inputs.json b/js/developer/tools/bundle-inputs.json index 68b15d58..26aa4271 100644 --- a/js/developer/tools/bundle-inputs.json +++ b/js/developer/tools/bundle-inputs.json @@ -22,6 +22,7 @@ "js/developer/environment/development.mjs", "js/developer/environment/testing.mjs", "js/developer/environment/terminal.mjs", + "js/developer/environment/workspace.mjs", "js/developer/environment/tarball.mjs", "js/developer/environment/commands.mjs", "js/developer/environment/compiler.mjs", diff --git a/js/developer/webfront.project.json b/js/developer/webfront.project.json index 9746d581..bd5ab9f4 100644 --- a/js/developer/webfront.project.json +++ b/js/developer/webfront.project.json @@ -30,6 +30,7 @@ "test/developer/specs/development-specs.mjs", "test/developer/specs/testing-specs.mjs", "test/developer/specs/timers-specs.mjs", + "test/developer/specs/workspace-specs.mjs", "test/developer/specs/distribution-specs.mjs" ] }, diff --git a/test/developer/specs/workspace-specs.mjs b/test/developer/specs/workspace-specs.mjs new file mode 100644 index 00000000..eeb7a3d3 --- /dev/null +++ b/test/developer/specs/workspace-specs.mjs @@ -0,0 +1,143 @@ +// Specs of the developer page's layout (workspace.mjs): what counts as an existing interface, the states of the display, +// and the place of the floating terminal window. The page itself is checked in test/web/developer-specs.mjs. +import {hasInterface, previewDirectory, State, initialState, nextState, clampRect, defaultRect, keyboardRect, minimumSize, step, + isToggleKey, parsePlace, formatPlace, readPlace, placeStore, placePath} from '../../../js/developer/environment/workspace.mjs'; +import {publish} from '../../../js/developer/environment/io.mjs'; +import {memoryBridge} from '../memory-bridge.mjs'; + +describe('The developer page layout', () => { + const encode = text => new TextEncoder().encode(text); + const page = text => new Map([['index.html', encode(text)], ['app.js', encode('')]]); + + describe('existing interface', () => { + it('is a published preview page, which wf create and wf build do not produce', async () => { + const {bridge, storage} = memoryBridge(); + expect(await hasInterface(bridge)).toBeFalse(); + // wf create writes sources, wf build publishes beside the preview. + storage.set('ui/main.tsx', encode('export {}')); + await publish(bridge, '.webfront/developer/build', page('built')); + expect(await hasInterface(bridge)).toBeFalse(); + await publish(bridge, previewDirectory, page('one')); + expect(await hasInterface(bridge)).toBeTrue(); + }); + + it('keeps the last successful publication after an interrupted or failed one', async () => { + const {bridge, storage, pending} = memoryBridge(); + await publish(bridge, previewDirectory, page('one')); + const interrupted = new AbortController(); + interrupted.abort(new Error('Interrupted')); + await expectAsync(publish(bridge, previewDirectory, page('two'), {signal: interrupted.signal})).toBeRejected(); + expect(pending()).toBe(0); + expect(await hasInterface(bridge)).toBeTrue(); + expect(new TextDecoder().decode(storage.get(`${previewDirectory}/index.html`))).toBe('one'); + }); + + it('is not a preview directory without its page, nor a project that cannot be listed', async () => { + const {bridge} = memoryBridge(new Map([[`${previewDirectory}/app.js`, encode('')]])); + expect(await hasInterface(bridge)).toBeFalse(); + expect(await hasInterface({cppFunction: () => async () => { throw new Error('bridge down'); }})).toBeFalse(); + }); + }); + + describe('states', () => { + it('open on the terminal alone without an interface, on the interface alone with one', () => { + expect(initialState(false)).toBe(State.terminal); + expect(initialState(true)).toBe(State.interface); + }); + + it('show the icon states only once an interface is displayed', () => { + for (const event of ['toggle', 'open', 'close', 'hidden']) expect(nextState(State.terminal, event)).toBe(State.terminal); + // The first preview appears while the terminal is in use: it stays open, over the interface. + expect(nextState(State.terminal, 'shown')).toBe(State.floating); + }); + + it('open and collapse the terminal over the interface', () => { + expect(nextState(State.interface, 'toggle')).toBe(State.floating); + expect(nextState(State.floating, 'toggle')).toBe(State.interface); + expect(nextState(State.interface, 'open')).toBe(State.floating); + expect(nextState(State.floating, 'open')).toBe(State.floating); + expect(nextState(State.floating, 'close')).toBe(State.interface); + expect(nextState(State.interface, 'close')).toBe(State.interface); + }); + + it('keep their state when wf dev reloads the preview, and return to the terminal without a preview', () => { + expect(nextState(State.interface, 'shown')).toBe(State.interface); + expect(nextState(State.floating, 'shown')).toBe(State.floating); + expect(nextState(State.interface, 'hidden')).toBe(State.terminal); + expect(nextState(State.floating, 'hidden')).toBe(State.terminal); + expect(nextState(State.floating, 'unknown')).toBe(State.floating); + }); + }); + + describe('window place', () => { + const viewport = {width: 1000, height: 700}; + const inside = (rect, view) => rect.x >= 0 && rect.y >= 0 && rect.x + rect.width <= view.width && rect.y + rect.height <= view.height; + + it('stays inside the viewport', () => { + expect(clampRect({x: 100, y: 50, width: 400, height: 300}, viewport)).toEqual({x: 100, y: 50, width: 400, height: 300}); + expect(clampRect({x: -40, y: -10, width: 400, height: 300}, viewport)).toEqual({x: 0, y: 0, width: 400, height: 300}); + expect(clampRect({x: 900, y: 650, width: 400, height: 300}, viewport)).toEqual({x: 600, y: 400, width: 400, height: 300}); + expect(clampRect({x: 10.4, y: 10.6, width: 400.2, height: 300}, viewport)).toEqual({x: 10, y: 11, width: 400, height: 300}); + }); + + it('has a minimum size, except in a window smaller than it', () => { + expect(clampRect({x: 0, y: 0, width: 10, height: 10}, viewport)).toEqual({x: 0, y: 0, ...minimumSize}); + expect(clampRect({x: 0, y: 0, width: 5000, height: 5000}, viewport)).toEqual({x: 0, y: 0, ...viewport}); + const small = {width: 200, height: 120}; + expect(clampRect({x: 50, y: 50, width: 400, height: 300}, small)).toEqual({x: 0, y: 0, ...small}); + }); + + it('opens inside viewports of every size', () => { + for (const view of [viewport, {width: 1920, height: 1080}, {width: 360, height: 240}, {width: 120, height: 80}]) + expect(inside(defaultRect(view), view)).withContext(JSON.stringify(view)).toBeTrue(); + }); + + it('moves with the arrow keys and resizes with Shift, inside the viewport', () => { + const rect = {x: 100, y: 100, width: 400, height: 300}; + expect(keyboardRect(rect, {key: 'ArrowLeft'}, viewport)).toEqual({...rect, x: 100 - step}); + expect(keyboardRect(rect, {key: 'ArrowDown'}, viewport)).toEqual({...rect, y: 100 + step}); + expect(keyboardRect(rect, {key: 'ArrowRight', shiftKey: true}, viewport)).toEqual({...rect, width: 400 + step}); + expect(keyboardRect(rect, {key: 'ArrowUp', shiftKey: true}, viewport)).toEqual({...rect, height: 300 - step}); + expect(keyboardRect({...rect, x: 4}, {key: 'ArrowLeft'}, viewport).x).toBe(0); + expect(keyboardRect({...rect, x: 600}, {key: 'ArrowRight'}, viewport).x).toBe(600); + expect(keyboardRect(rect, {key: 'a'}, viewport)).toBeNull(); + }); + + it('is toggled by F9 alone', () => { + expect(isToggleKey({key: 'F9'})).toBeTrue(); + expect(isToggleKey({key: 'F9', ctrlKey: true})).toBeFalse(); + expect(isToggleKey({key: 'F9', shiftKey: true})).toBeFalse(); + expect(isToggleKey({key: 'c', ctrlKey: true})).toBeFalse(); + }); + + it('is read from a well-formed file only', () => { + const rect = {x: 12, y: 34, width: 500, height: 280}; + expect(parsePlace(formatPlace(rect))).toEqual(rect); + for (const text of ['', '{broken', 'null', '[]', '{"format":2,"x":1,"y":1,"width":400,"height":300}', + '{"format":1,"x":"1","y":1,"width":400,"height":300}', '{"format":1,"x":1,"y":1,"width":0,"height":300}', + '{"format":1,"x":1e9,"y":1,"width":400,"height":300}', '{"format":1,"x":1,"y":1,"width":400}']) + expect(parsePlace(text)).withContext(text).toBeNull(); + }); + + it('is remembered in the project, the last one given', async () => { + const {bridge, storage} = memoryBridge(); + expect(await readPlace(bridge)).toBeNull(); + const store = placeStore(bridge, 60000); + store.remember({x: 1, y: 2, width: 400, height: 300}); + store.remember({x: 30, y: 40, width: 420, height: 310}); + expect(storage.has(placePath)).toBeFalse(); // a move writes once, when it ends + await store.saved(); + expect(await readPlace(bridge)).toEqual({x: 30, y: 40, width: 420, height: 310}); + // Another project has its own place. + expect(await readPlace(memoryBridge().bridge)).toBeNull(); + storage.set(placePath, encode('{broken')); + expect(await readPlace(bridge)).toBeNull(); + }); + + it('stays usable when the place cannot be written', async () => { + const store = placeStore({cppFunction: () => async () => { throw new Error('read-only project'); }}, 60000); + store.remember({x: 1, y: 2, width: 400, height: 300}); + await expectAsync(store.saved()).toBeResolved(); + }); + }); +}); From 31675c0fa50279d15003d386eb5c7725fe7541be Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Tue, 10 Nov 2026 23:21:20 +0100 Subject: [PATCH 02/11] Cover the page layout in a real browser: first launch, existing interface, floating terminal session (#539) --- test/web/CMakeLists.txt | 2 +- test/web/DeveloperTest.cpp | 3 +- test/web/developer-specs.mjs | 263 +++++++++++++++++++++++++++++++++++ 3 files changed, 266 insertions(+), 2 deletions(-) diff --git a/test/web/CMakeLists.txt b/test/web/CMakeLists.txt index 8c7ebc7c..a73358be 100644 --- a/test/web/CMakeLists.txt +++ b/test/web/CMakeLists.txt @@ -308,7 +308,7 @@ if(_browser_tests_available) # One long script (developer-specs.mjs) would run for two minutes on its own: it is cut into parts that start from their # own project and run in parallel (#435). `app` also generates the header that LifeEmbeddedBuild compiles. Each part # listens on a port the system picks, so none of them holds webfront_port_9002. - foreach(_part app scripts typescript jasmine terminal) + foreach(_part app scripts typescript jasmine terminal workspace) set(_name DeveloperBrowserIntegration) if(NOT _part STREQUAL "app") set(_name DeveloperBrowserIntegration-${_part}) diff --git a/test/web/DeveloperTest.cpp b/test/web/DeveloperTest.cpp index 4a5ce070..345f4b49 100644 --- a/test/web/DeveloperTest.cpp +++ b/test/web/DeveloperTest.cpp @@ -222,7 +222,8 @@ Mode parseMode(std::string_view argument) { mode.part = "app"; } else if (argument.starts_with("--part=")) { mode.part = std::string(argument.substr(7)); - if (mode.part != "app" && mode.part != "scripts" && mode.part != "typescript" && mode.part != "jasmine" && mode.part != "terminal") + if (mode.part != "app" && mode.part != "scripts" && mode.part != "typescript" && mode.part != "jasmine" && mode.part != "terminal" && + mode.part != "workspace") throw std::invalid_argument("Unknown part of the developer test: " + mode.part); } else { throw std::invalid_argument("Unknown smoke-test mode"); diff --git a/test/web/developer-specs.mjs b/test/web/developer-specs.mjs index a5e6d2ca..383b40ef 100644 --- a/test/web/developer-specs.mjs +++ b/test/web/developer-specs.mjs @@ -806,6 +806,269 @@ try { assert(exits[3] === 1, 'A result that cannot be sent must not end the session with 0'); if (part === 'jasmine') throw new Done('wf test passed'); } + if (wants('workspace')) { + await progress('page layout'); + // The layout of the page (#539): the terminal alone, then the interface over the whole window, with the terminal + // in a floating window behind an icon. + const until = async (predicate, message) => { + for (let attempt = 0; !(await predicate()); ++attempt) { + if (attempt === 400) throw new Error(message); + await delay(25); + } + }; + const layout = page => { + const view = page.defaultView, root = page.documentElement; + const box = selector => page.querySelector(selector).getBoundingClientRect(); + const style = selector => view.getComputedStyle(page.querySelector(selector)); + return { + state: () => root.getAttribute('data-webfront-workspace'), + button: () => page.querySelector('.webfront-terminal-toggle'), + panel: () => page.querySelector('.webfront-terminal-window'), + bar: () => page.querySelector('.webfront-terminal-bar'), + box, style, + viewport: () => ({width: root.clientWidth, height: root.clientHeight}), + inside: selector => { + const rect = box(selector); + return rect.left >= 0 && rect.top >= 0 && rect.right <= root.clientWidth + 0.5 && rect.bottom <= root.clientHeight + 0.5; + }, + fills: selector => { + const rect = box(selector); + return rect.left === 0 && rect.top === 0 && Math.abs(rect.width - root.clientWidth) < 1 && Math.abs(rect.height - root.clientHeight) < 1; + }, + }; + }; + const here = layout(document); + if (part === 'workspace') { + // First launch, in a project without an interface: the terminal alone, no icon, no empty preview. + assert(here.state() === 'terminal', `A project without an interface must open on the terminal: ${here.state()}`); + assert(here.style('.webfront-terminal-toggle').display === 'none', 'The icon must not be shown without an interface'); + assert(context.preview.hidden && here.style('.webfront-terminal-bar').display === 'none', 'Neither an empty preview nor a window bar must be shown'); + assert(Math.abs(here.box('.webfront-terminal-window').width - here.viewport().width) < 1 && here.style('header').display !== 'none', + 'The terminal must take the width of the window, under the status'); + } + await writeFile('layout/main.ts', "import {value} from './value'; document.getElementById('root').textContent = value;\n"); + await writeFile('layout/value.ts', "export const value: string = 'layout-one';\n"); + // wf create and wf build do not make an interface to show at the next launch; wf preview does. + await execute(['build', 'layout/main.ts'], context); + const listed = async directory => JSON.parse(new TextDecoder().decode(await call('list', directory))); + if (part === 'workspace') { + assert(here.state() === 'terminal' && !(await listed('.webfront/developer')).includes('preview/'), 'wf build must not publish a preview'); + } + // wf preview reads the lock, which the other parts get from wf install. + if (part === 'workspace') await writeFile('webfront-packages.lock.json', JSON.stringify({format: 1, roots: {}, packages: {}})); + await execute(['preview', 'layout/main.ts'], context); + await until(() => context.preview.contentDocument?.getElementById('root')?.textContent === 'layout-one', 'The preview did not mount'); + // The interface appears while the terminal is in use: it fills the window and the terminal stays open over it. + if (part === 'workspace') await until(() => here.state() === 'floating', `The first preview must leave the terminal open: ${here.state()}`); + assert(here.state() !== 'terminal' && here.fills('#preview') && here.style('.webfront-terminal-toggle').display !== 'none', + 'A displayed interface must fill the window, with the icon'); + + // Launching again: the bootstrap page of the same project, in a window of its own size. + const relaunched = document.createElement('iframe'); + relaunched.style.cssText = 'position:fixed;left:0;top:0;width:900px;height:600px;border:0;z-index:2147483647;background:#141821'; + relaunched.src = location.pathname; + document.body.append(relaunched); + await until(() => { + const text = relaunched.contentDocument?.getElementById('status')?.textContent ?? ''; + if (text.startsWith('Bootstrap failed:')) throw new Error(text); + return text.startsWith('Developer environment ready.'); + }, 'The relaunched page did not start'); + const again = layout(relaunched.contentDocument); + const page = relaunched.contentDocument, pagePreview = page.getElementById('preview'); + assert(again.state() === 'interface', `A project with an interface must open on it: ${again.state()}`); + await until(() => pagePreview.contentDocument?.getElementById('root')?.textContent === 'layout-one', 'The existing interface was not loaded'); + assert(again.fills('#preview') && again.style('header').display === 'none', 'The interface must fill the whole window'); + assert(again.style('.webfront-terminal-window').visibility === 'hidden', 'The terminal must not be visible'); + const button = again.button(), icon = again.box('.webfront-terminal-toggle'); + assert(button.tagName === 'BUTTON' && button.getAttribute('aria-expanded') === 'false' && /terminal/i.test(button.getAttribute('aria-label')) + && button.getAttribute('aria-controls') === again.panel().id, 'The icon must be a named button that controls the terminal window'); + assert(button.querySelector('svg') && icon.width >= 44 && icon.height >= 44 && icon.top <= 16 && again.viewport().width - icon.right <= 16, + `The icon must be a large enough target at the top right: ${JSON.stringify(icon)}`); + assert(page.elementFromPoint(icon.left + icon.width / 2, icon.top + icon.height / 2)?.closest('button') === button, 'The icon must stay over the interface'); + assert(page.activeElement === pagePreview, 'The keys must go to the interface while the terminal is collapsed'); + const session = page.querySelector('#terminal .xterm'); + assert(session, 'The terminal must be mounted while it is collapsed'); + const sessionText = () => page.querySelector('#terminal .xterm-rows')?.textContent ?? ''; + await until(() => sessionText().includes('>'), 'The collapsed terminal must have its prompt'); + const before = sessionText(); + + button.click(); + assert(again.state() === 'floating' && button.getAttribute('aria-expanded') === 'true', 'A click on the icon must open the terminal'); + const dialog = again.panel(); + assert(dialog.getAttribute('role') === 'dialog' && dialog.getAttribute('aria-modal') === 'false' && dialog.getAttribute('aria-label'), + 'The terminal window must be a named, non-modal dialog'); + assert(again.style('.webfront-terminal-window').visibility === 'visible' && again.inside('.webfront-terminal-window') && again.fills('#preview'), + 'The terminal window must float inside the window, over the full-size interface'); + assert(dialog.contains(page.activeElement), 'The opened terminal must take the keys'); + assert(page.querySelector('#terminal .xterm') === session && sessionText() === before, 'Opening must show the same session'); + // The interface stays in its frame, the terminal window in the page: the frame remains the only boundary. + assert(dialog.ownerDocument === page && !dialog.contains(pagePreview) && pagePreview.contentDocument.querySelector('.webfront-terminal-window, .webfront-terminal-toggle') === null, + 'The terminal window must not enter the application frame'); + + // Moving with the keyboard and the pointer stays inside the window. + const bar = again.bar(); + const key = (target, init) => target.dispatchEvent(new (target.ownerDocument ?? target.document).defaultView.KeyboardEvent('keydown', {bubbles: true, cancelable: true, ...init})); + const left = () => again.box('.webfront-terminal-window').left, top = () => again.box('.webfront-terminal-window').top; + const startLeft = left(); + bar.focus(); + key(bar, {key: 'ArrowLeft'}); + assert(left() === startLeft - 16, `An arrow key must move the terminal window: ${startLeft} -> ${left()}`); + for (let count = 0; count < 100; ++count) { key(bar, {key: 'ArrowLeft'}); key(bar, {key: 'ArrowUp'}); } + assert(left() === 0 && top() === 0 && again.inside('.webfront-terminal-window'), 'Keyboard moves must stop at the edges of the window'); + const startWidth = again.box('.webfront-terminal-window').width; + key(bar, {key: 'ArrowLeft', shiftKey: true}); + assert(again.box('.webfront-terminal-window').width === startWidth - 16, 'Shift with an arrow key must resize the terminal window'); + const pointer = (type, x, y) => bar.dispatchEvent(new page.defaultView.PointerEvent(type, {bubbles: true, cancelable: true, button: 0, pointerId: 1, clientX: x, clientY: y})); + pointer('pointerdown', 20, 10); + pointer('pointermove', 120, 110); + assert(left() === 100 && top() === 100, `Dragging the bar must move the terminal window: ${left()},${top()}`); + pointer('pointermove', 5000, 5000); + pointer('pointerup', 5000, 5000); + assert(again.inside('.webfront-terminal-window') && again.box('.webfront-terminal-window').right > again.viewport().width - 1, 'A drag must stay inside the window'); + pointer('pointermove', 0, 0); + assert(left() > 0, 'A released bar must not follow the pointer'); + // The place is remembered in the project. + const placePath = '.webfront/developer/terminal-window.json'; + const place = async () => { try { return JSON.parse(new TextDecoder().decode(await readFile(placePath))); } catch { return null; } }; + await until(async () => (await place())?.x === left(), 'The place of the terminal window must be remembered in the project'); + const remembered = await place(); + assert(remembered.format === 1 && remembered.width === again.box('.webfront-terminal-window').width, `The size must be remembered too: ${JSON.stringify(remembered)}`); + + // A smaller window keeps the icon and the terminal window; the remembered place comes back with the room. + const columns = () => Math.round(page.querySelector('#terminal .xterm-screen')?.getBoundingClientRect().width ?? 0); + const wideScreen = columns(); + // This window gets no rendering frames under the test (no requestAnimationFrame callback, hence no resize event + // and no ResizeObserver notification): the test sends the event the browser sends. + const resize = (width, height) => { + relaunched.style.width = `${width}px`; + relaunched.style.height = `${height}px`; + page.defaultView.dispatchEvent(new page.defaultView.Event('resize')); + }; + resize(280, 140); + assert(again.viewport().width === 280 && again.box('.webfront-terminal-window').right <= 280.5, `The terminal window must follow a smaller window: ${again.panel().style.cssText}`); + assert(again.inside('.webfront-terminal-window') && again.inside('.webfront-terminal-toggle'), 'A small window must keep the icon and the terminal window'); + await until(() => columns() < wideScreen, 'xterm.js must be fitted to a smaller terminal window'); + resize(900, 600); + await until(() => left() === remembered.x && top() === remembered.y, 'A window enlarged again must give the terminal window its place back'); + await until(() => columns() === wideScreen, 'xterm.js must be fitted to the terminal window again'); + + // The close button and the shortcut collapse and open it, wherever the focus is. + page.querySelector('.webfront-terminal-close').click(); + assert(again.state() === 'interface' && page.activeElement === pagePreview, 'Collapsing must give the keys back to the interface'); + assert(columns() === wideScreen, 'A collapsed terminal must keep its size'); + key(pagePreview.contentDocument.body, {key: 'F9'}); + assert(again.state() === 'floating', 'F9 in the interface must open the terminal'); + key(page.querySelector('#terminal .xterm-helper-textarea'), {key: 'F9'}); + assert(again.state() === 'interface', 'F9 in the terminal must collapse it'); + key(pagePreview.contentDocument.body, {key: 'F9', ctrlKey: true}); + assert(again.state() === 'interface', 'Another key combination must be left to the interface'); + + // wf dev with the terminal collapsed: the full-window interface reloads and shows the build diagnostics. + const devStop = new AbortController(); + let devOutput = ''; + await withTimers([750], async clock => { + const poll = async () => { + await until(() => clock.pending() > 0, 'Dev polling deadline was not armed'); + clock.fire(750); + }; + const shows = text => () => pagePreview.contentDocument?.getElementById('root')?.textContent === text; + const devResult = execute(['dev', 'layout/main.ts'], {...context, preview: pagePreview, signal: devStop.signal, + write: text => { devOutput += text; }}).then(() => null, error => error); + try { + await until(() => /Preview ready/.test(devOutput) && shows('layout-one')(), 'wf dev did not start'); + await writeFile('layout/value.ts', "export const value: string = 'layout-two';\n"); + await poll(); + await until(shows('layout-two'), 'wf dev must reload the full-window interface'); + assert(again.state() === 'interface' && again.fills('#preview'), 'A reload must leave the terminal collapsed'); + // The interface of a new document still gets the shortcut. + key(pagePreview.contentDocument.body, {key: 'F9'}); + assert(again.state() === 'floating', 'F9 must work in a reloaded interface'); + key(pagePreview.contentDocument.body, {key: 'F9'}); + await writeFile('layout/value.ts', 'export const value = ;\n'); + await poll(); + await until(() => pagePreview.contentDocument?.getElementById('webfront-build-diagnostics'), 'A failed build must show its diagnostic in the interface'); + assert(again.state() === 'interface' && shows('layout-two')() && /layout\/value.ts:1:/.test(pagePreview.contentDocument.getElementById('webfront-build-diagnostics').textContent), + 'The diagnostic must cover the last interface built, with the terminal collapsed'); + const overlay = pagePreview.contentDocument.getElementById('webfront-build-diagnostics').getBoundingClientRect(); + assert(page.elementFromPoint(icon.left + icon.width / 2, icon.top + icon.height / 2)?.closest('button') === button && overlay.width > 0, + 'The icon must stay over the diagnostic'); + } finally { devStop.abort(); } + assert((await devResult)?.exitCode === 130, 'Ctrl+C must stop dev with exit code 130'); + }); + // A failed build keeps the last interface published: the next launch still opens on it. + assert((await listed('.webfront/developer/preview')).includes('index.html'), 'A failed build must keep the published interface'); + relaunched.remove(); + + // The session behind the icon, with a terminal this test can type in: a page that mounts it with a preview frame. + const sessionFrame = document.createElement('iframe'); + sessionFrame.style.cssText = 'position:fixed;left:0;top:0;width:900px;height:600px;border:0;z-index:2147483647;background:#141821'; + sessionFrame.src = '/fixtures/session.html'; + document.body.append(sessionFrame); + await until(() => sessionFrame.contentWindow?.session, 'The session page did not load'); + const other = await sessionFrame.contentWindow.session; + const otherPage = sessionFrame.contentDocument, otherPreview = otherPage.createElement('iframe'); + otherPreview.id = 'preview'; + otherPreview.hidden = true; + otherPage.body.append(otherPreview); + const mounted = await other.runtime.mount({bridge: other.bridge, config, terminal: otherPage.getElementById('terminal'), preview: otherPreview, onExit: () => {}}); + const {terminal, editor, workspace} = mounted; + const there = layout(otherPage); + assert(workspace && there.state() === 'interface' && workspace.state === 'interface', `The mounted page must open on the interface: ${there.state()}`); + // The place remembered by the other page is the one of the project. + assert(Math.round(there.box('.webfront-terminal-window').left) === remembered.x, 'The remembered place must be the project\'s'); + // A second terminal in the page leaves its layout alone. + const second = otherPage.createElement('div'); + second.style.cssText = 'width:320px;height:120px'; + otherPage.body.append(second); + const plain = await other.runtime.mount({bridge: other.bridge, config, terminal: second, preview: otherPreview, onExit: () => {}}); + assert(!plain.workspace && otherPage.querySelectorAll('.webfront-terminal-toggle').length === 1, 'A page must have one layout'); + plain.terminal.dispose(); + second.remove(); + const rendered = () => new Promise(resolve => terminal.write('', resolve)); + const screen = () => { + const lines = []; + for (let index = 0; index < terminal.buffer.active.length; ++index) lines.push(terminal.buffer.active.getLine(index).translateToString(true)); + return lines.join('\n'); + }; + workspace.open(); + assert(there.state() === 'floating', 'The terminal must open'); + await until(() => terminal.cols > 20, 'The terminal must be fitted to its window'); + terminal.input('echo layout kept\r'); + await editor.whenIdle(); + terminal.input('echo par'); + await rendered(); + const size = [terminal.cols, terminal.rows]; + workspace.toggle(); + await delay(100); + assert(there.state() === 'interface' && terminal.cols === size[0] && terminal.rows === size[1], `Collapsing must not resize the terminal: ${terminal.cols}x${terminal.rows}`); + assert(editor.line === 'echo par', 'Collapsing must keep the line being typed'); + workspace.toggle(); + assert(otherPage.activeElement === terminal.textarea, 'Opening must give the keys to the terminal'); + terminal.input('tial\r'); + await editor.whenIdle(); + await rendered(); + assert(/^layout kept$/m.test(screen()) && /^partial$/m.test(screen()), `The session must keep its output: ${screen()}`); + assert(editor.history.slice(-2).join('|') === 'echo layout kept|echo partial', `The session must keep its history: ${editor.history.slice(-2)}`); + // A command keeps running while the terminal is collapsed and opened again. + const commandState = tag => webFront.cppFunction('test.command')(tag); + terminal.input('wait layout\r'); + await until(async () => (await commandState('layout')) === 'running', 'The command did not start'); + workspace.close(); + await delay(150); + assert(there.state() === 'interface' && (await commandState('layout')) === 'running' && editor.busy, 'Collapsing must not interrupt a running command'); + workspace.open(); + assert((await commandState('layout')) === 'running', 'Opening must not interrupt a running command'); + terminal.input('\x03'); + await editor.whenIdle(); + await rendered(); + await until(async () => (await commandState('layout')) === 'cancelled', 'Ctrl+C must still reach the command'); + assert(/waiting layout/.test(screen()) && /^layout kept$/m.test(screen()), + 'Ctrl+C must still reach the command, in the same session'); + await mounted.workspace.placeSaved(); + terminal.dispose(); + sessionFrame.remove(); + if (part === 'workspace') throw new Done('Page layout: terminal alone, full-window interface, floating terminal passed'); + } if (wants('terminal')) { // The completions below name a script and a file that the `scripts` part creates in a single-session run. if (part === 'terminal') { From 23400c4675f0431869bb89875c3f0ee6b9566b02 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Tue, 10 Nov 2026 23:21:20 +0100 Subject: [PATCH 03/11] Advance the developer environment sources to 0.9.1, refresh the bundle checksums and document the page layout (#539) The layout changes the environment archive and 0.9.0 is published. The release pin stays on 0.9.0. --- docs/CHANGELOG.md | 4 +++ docs/DEVELOPER_ENVIRONMENT.md | 35 +++++++++++++++++++++++++-- docs/PROJECT_STATUS.md | 4 ++- js/developer/environment/bundles.json | 7 +++--- js/developer/tools/distribution.json | 2 +- 5 files changed, 45 insertions(+), 7 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 5522daa6..298c3bd6 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -10,6 +10,10 @@ these entries stays in the GitHub releases and the Git history. ## Unreleased +### Changed + +- Open the developer page on the interface, over the whole window, once the project has a preview; the terminal moves to a floating, movable window behind an icon at the top right (F9), and keeps its session when collapsed. Environment sources 0.9.1, not published yet (#539, `docs/DEVELOPER_ENVIRONMENT.md`). + ## [0.9.0] - 2026-11-10 Last minor revision before 1.0, with the developer environment at the same number. It lays the groundwork for the diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index f660404f..8d3b1ac3 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -37,7 +37,8 @@ versions stay immutable. Environment **0.6.3** adds automation API v1 and the sh lease; version 0.6.2 predates that API. Environment **0.6.4** adds the project setup operations of the automation runner (`init`, `create`, `install`, `restore`, `embed`). Environment **0.6.6** adds the `call` operation, the terminal and `wf help` notice of automation and the starter's `AGENTS.md`. The release pin selects 0.6.6, published under the dedicated `developer-v0.6.6` tag and verified after deployment. The test bootstrap (`cmake/WebFrontBootstrap.cmake`) stays on the -published 0.6.3 and advances in a separate pull request. Publication and pin changes follow +published 0.6.3 and advances in a separate pull request. The sources advance to **0.9.1** (the page layout: full-window +interface and floating terminal, #539), which is not published yet; the release pin stays on the published 0.9.0. Publication and pin changes follow [PUBLISHING](../js/developer/tools/PUBLISHING.md). ## Minimal C++ application @@ -365,6 +366,36 @@ wf check terminated with `worker.terminate()` after the two-second grace period. The exit code is 130 (Ctrl+C) or 124 (time limit), and the terminal stays usable. +## The page: interface and floating terminal + +The page of `bootstrap("developer")` shows one thing at a time by default (environment 0.9.1, #539; the layout belongs to the +environment's `mount`, not to the embedded bootstrap page): + +- **No interface yet** (first launch, or a project that never ran `wf dev` or `wf preview`): the terminal alone, under the + status line. No icon and no empty preview are shown. +- **An interface exists**: the page opens on it, over the whole window, with the terminal collapsed. "Exists" means a + published preview, `.webfront/developer/preview/index.html`. `wf dev` and `wf preview` publish it; `wf create` and + `wf build` (which publishes under `build/`) do not. A publication replaces the directory in one step, so an interrupted + `wf dev` or a failed build leaves the last successful interface, which the next launch shows as it was built: run `wf dev` + to rebuild it. +- **The icon** with the WebFront swallow, at the top right over the interface, opens the terminal in a **floating window**; + the icon again, the window's close button or **F9** (in the terminal or in the interface) collapses it. Collapsing only + hides the terminal: the session, its scrollback, the line being typed and a running command (`wf dev`, `wf test`) are + kept, and the keys go back to the interface. The first preview of a session leaves the terminal open over the interface, + since it is in use. A notice of automation opens it, so that the notice is seen. +- **Moving and resizing**: drag the title bar, or focus it and use the arrow keys (Shift with an arrow key resizes); the + bottom-right corner resizes with the pointer. The window stays inside the browser window, shrinks with it and returns to + its place when there is room again; xterm.js is fitted to it. Its place and size are kept per project in + `.webfront/developer/terminal-window.json`. +- While the terminal is collapsed, `wf dev` keeps reloading the full-window interface, and a failed build still shows its + diagnostic over it. + +The icon is a button (`aria-expanded`, 44 px target) and the window a non-modal dialog. The interface stays in the preview +frame, as before: the layout adds nothing to the application's document except the F9 listener. This is a layout, not a +sandbox (see [limitations](#dependencies-storage-and-limitations)). An application that uses F9 itself does not receive it in +the developer page; it does in its embedded form. A page that mounts the terminal itself (`runtime.mount`) with a preview frame gets +the same layout; `workspace: false` keeps the page as it is. + ## The terminal and the application's commands The terminal of the environment (developer distribution 0.5.0, #308) is the only WebFront terminal; it is served @@ -705,7 +736,7 @@ WKWebView and all 14 Linux CEF/Xvfb cases with both GCC and Clang in The packed 0.3.0 version passes WKWebView and all 14 GCC CEF/Xvfb cases in [run 39490581423](https://github.com/ambroise-leclerc/WebFront/actions/runs/39490581423). For Linux, select CEF and Xvfb instead; the same developer tests use the selected test frontend. -`DeveloperBrowserIntegration` (the application part: starter, build, `wf dev`, Life preview, embedding) and `DeveloperBrowserIntegration-scripts`, `-typescript`, `-jasmine` and `-terminal` exercise, in parallel and each from its own project, the real WASM compiler, local registry, `wf test` under the locked jasmine-core (pass, fail, pending, asynchronous failures, pattern, time limit, Ctrl+C, non-interactive report to C++), build without navigation, incremental dev reload/error/recovery/Ctrl+C, the Life preview, C++ generation/animation and repeatable header generation. Its CTest fixtures then build that +`DeveloperBrowserIntegration` (the application part: starter, build, `wf dev`, Life preview, embedding) and `DeveloperBrowserIntegration-scripts`, `-typescript`, `-jasmine`, `-terminal` and `-workspace` (the page layout: first launch, launch on an existing interface, floating terminal and its session) exercise, in parallel and each from its own project, the real WASM compiler, local registry, `wf test` under the locked jasmine-core (pass, fail, pending, asynchronous failures, pattern, time limit, Ctrl+C, non-interactive report to C++), build without navigation, incremental dev reload/error/recovery/Ctrl+C, the Life preview, C++ generation/animation and repeatable header generation. Its CTest fixtures then build that **browser-generated** header and run `LifeEmbeddedIntegration` from an empty working directory with no developer callbacks. Deadline and grace-period regressions advance a scoped clock instead of sleeping for seconds; Worker startup, diff --git a/docs/PROJECT_STATUS.md b/docs/PROJECT_STATUS.md index d4824c4d..fc64e859 100644 --- a/docs/PROJECT_STATUS.md +++ b/docs/PROJECT_STATUS.md @@ -19,7 +19,9 @@ WebFront is a header-only C++23 HTTP/WebSocket core plus a standalone developer `install`, `restore`, `run`, `exec`, `check`, `test`, `build`, `dev`, `preview`, `embed`, `list` and `help`. The manifest and lock describe dependencies, entries, providers, scripts and permissions. TypeScript/TSX compilation uses esbuild-wasm; type checking uses the project's locked TypeScript. Application commands use - `webfront::Commands`. See the [developer reference](DEVELOPER_ENVIRONMENT.md). + `webfront::Commands`. From environment 0.9.1 (sources; the pin is still 0.9.0), a project that has a preview opens + on its interface over the whole window, with the terminal in a floating window behind an icon. See the + [developer reference](DEVELOPER_ENVIRONMENT.md). - **Distribution.** `wf embed` generates the application's compressed C++ provider. `NativeAppWithAssets` runs without project files, developer callbacks or tool cache. Native-engine deployment remains application work. The [README walkthrough](../README.md) diff --git a/js/developer/environment/bundles.json b/js/developer/environment/bundles.json index e2ed068e..133021dd 100644 --- a/js/developer/environment/bundles.json +++ b/js/developer/environment/bundles.json @@ -17,11 +17,12 @@ "js/developer/environment/packages.mjs": "37fe2a410e211264cfeaedbff3df50f7e62b02f8088130127d94f92081e2a5ad", "js/developer/environment/starter.mjs": "89ccab43be4455ed9598c54355b4bbe5adea1afd7a0ae5d755a14317e3ca39df", "js/developer/environment/paths.mjs": "3b6114df78eb193161c5c84499dda084cb7ff91c56a4496371c30295d00880e3", - "js/developer/environment/runtime.mjs": "19ea1924209915bbdb517212d5c2bc25cbb1b39ea3fde898b86efeab8c6ba220", + "js/developer/environment/runtime.mjs": "66588ff076db7837d7c859bc9b09f366091dd89582b06ca1da9cd42ed7946406", "js/developer/environment/automation.mjs": "79405c89ba7025c1774bc13c9b78d814a07592755dcde018c8659a8015c4b8ed", "js/developer/environment/development.mjs": "1125043016727111031a452fbebec358b9e78231f82fe91df7dea0fe8b22f015", "js/developer/environment/testing.mjs": "aeb584505fab5957b9c02e78536e12f7d7f3d12f8adb2e17f1a1a6e395e43f3c", "js/developer/environment/terminal.mjs": "7ffcf7ac6ef63c35cdf5ef70284b384525b13ba18422af069289e53b6c4f6be1", + "js/developer/environment/workspace.mjs": "77e012493924075132e613a24e5b6f3e7d6f41e3681fc9fa7ab0956284f1dce1", "js/developer/environment/tarball.mjs": "1c1e1aea067910e1fec74e85b4bf9fbefed9b38187a04d8d2764f0b9a96fca39", "js/developer/environment/commands.mjs": "8de20c01f02f33c0566f204fcf1ee2382a23344d2103581fe2914469ec570531", "js/developer/environment/compiler.mjs": "0158931132aa9b43b7bbbd01de6fa4fc34fce8c65515d593dd494930f7a1910f", @@ -39,11 +40,11 @@ "js/developer/environment/embed.mjs": "3e6bc10200939fa30d5f60a96f01eb33ddf3da87661390ad433a18366bf52547", "examples/life/ui/main.tsx": "7b1ff285d2a6b8f897ef12df872886e61ef4b24e2358a9423b76b38ab75c85d3", "examples/life/ui/style.css": "9bb55eb0f0a3287e5b7dc78af9d69608b87ff42c4d9c8a653bc83a52fe293c44", - "js/developer/tools/distribution.json": "a9314cb421c6113c0bb901bc57247e2373bf2670f65d1708923241940f6133db", + "js/developer/tools/distribution.json": "0de03c0bd22fdcfe87c686d6c1456d26eeb57b09b03d0d680bb81557906f31a0", "js/developer/tools/archive.mjs": "da63bb9d796ddfd24ed945b15c53f66a0400eb177886fd4f1c8fd10cafb5a91b", "js/developer/tools/distribution.mjs": "43dfdccc912693db46fd095fd78ae79325abab672d99f89fd569914ef3499cad", "js/developer/scripts/build.mjs": "def3c0ccecbc776b76e20571d015f9a1f23a267c0bd6c0c7a07a81ce9293a663", - "js/developer/webfront.project.json": "3c25620969d4cb3dcb7ed01ada2cd72f56f9e2660d67433ca2133e0be6211a9c", + "js/developer/webfront.project.json": "6f4f56783012a792ca8eb1ac8a1ca0be51e6fcc83d760545d65da67c8687dd61", "js/core/bootstrap/bootstrap.bundle.mjs": "536831257f0fc92e31911841750e1e59247f7c64e756b0fcb878efd9860a741f", "js/developer/environment/packages.bundle.mjs": "2d62f3fcdece8e898f15814d7e80fc3a27ea062f45514cf8e5c3ae32fd9d26c5", "include/webfront/system/DeveloperReleaseData.hpp": "98094418f18a0ce30f6334c94fb8a1ab2df6d9026a2203223aa11796b622b4ee" diff --git a/js/developer/tools/distribution.json b/js/developer/tools/distribution.json index 825b0d26..9d3e51b7 100644 --- a/js/developer/tools/distribution.json +++ b/js/developer/tools/distribution.json @@ -1,4 +1,4 @@ { - "version": "0.9.0", + "version": "0.9.1", "baseUrl": "https://dist.webfront.fr/" } From 6c1fdb3bb4b8ff5281a3bf38457ada3928128290 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Wed, 11 Nov 2026 06:29:54 +0100 Subject: [PATCH 04/11] Keep the terminal alone when a first build fails and always write the last place chosen (#539) Only a published preview loaded in the frame opens the interface states: the diagnostic of a failed first build no longer shows an empty frame with the icon. The place store compares with the last write inside its chain of writes, so a place chosen again while another one is being written replaces it. --- docs/DEVELOPER_ENVIRONMENT.md | 3 ++- js/developer/environment/bundles.json | 2 +- js/developer/environment/workspace.mjs | 24 ++++++++++++++++-------- test/developer/specs/workspace-specs.mjs | 13 +++++++++++++ test/web/developer-specs.mjs | 18 ++++++++++++++++++ 5 files changed, 50 insertions(+), 10 deletions(-) diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index 8d3b1ac3..7f681b3c 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -372,7 +372,8 @@ The page of `bootstrap("developer")` shows one thing at a time by default (envir environment's `mount`, not to the embedded bootstrap page): - **No interface yet** (first launch, or a project that never ran `wf dev` or `wf preview`): the terminal alone, under the - status line. No icon and no empty preview are shown. + status line. No icon and no empty preview are shown, also when the first build of `wf dev` fails: its diagnostic is in + the terminal. - **An interface exists**: the page opens on it, over the whole window, with the terminal collapsed. "Exists" means a published preview, `.webfront/developer/preview/index.html`. `wf dev` and `wf preview` publish it; `wf create` and `wf build` (which publishes under `build/`) do not. A publication replaces the directory in one step, so an interrupted diff --git a/js/developer/environment/bundles.json b/js/developer/environment/bundles.json index 133021dd..c5566838 100644 --- a/js/developer/environment/bundles.json +++ b/js/developer/environment/bundles.json @@ -22,7 +22,7 @@ "js/developer/environment/development.mjs": "1125043016727111031a452fbebec358b9e78231f82fe91df7dea0fe8b22f015", "js/developer/environment/testing.mjs": "aeb584505fab5957b9c02e78536e12f7d7f3d12f8adb2e17f1a1a6e395e43f3c", "js/developer/environment/terminal.mjs": "7ffcf7ac6ef63c35cdf5ef70284b384525b13ba18422af069289e53b6c4f6be1", - "js/developer/environment/workspace.mjs": "77e012493924075132e613a24e5b6f3e7d6f41e3681fc9fa7ab0956284f1dce1", + "js/developer/environment/workspace.mjs": "40cdcfdb044bd5b7d9fc5e6bbad5dd145e7e707a1b1998dca79b3069b9cbfc50", "js/developer/environment/tarball.mjs": "1c1e1aea067910e1fec74e85b4bf9fbefed9b38187a04d8d2764f0b9a96fca39", "js/developer/environment/commands.mjs": "8de20c01f02f33c0566f204fcf1ee2382a23344d2103581fe2914469ec570531", "js/developer/environment/compiler.mjs": "0158931132aa9b43b7bbbd01de6fa4fc34fce8c65515d593dd494930f7a1910f", diff --git a/js/developer/environment/workspace.mjs b/js/developer/environment/workspace.mjs index 102d729f..224261b7 100644 --- a/js/developer/environment/workspace.mjs +++ b/js/developer/environment/workspace.mjs @@ -34,8 +34,8 @@ const transitions = { }; /** - * The state after an event: `shown` and `hidden` (the preview frame appears or disappears), `toggle` (the icon or the - * shortcut), `open` and `close`. An event that does not apply leaves the state unchanged. + * The state after an event: `shown` (a published preview is loaded in the frame), `hidden` (the frame is hidden), `toggle` + * (the icon or the shortcut), `open` and `close`. An event that does not apply leaves the state unchanged. */ export const nextState = (state, event) => transitions[state]?.[event] ?? state; @@ -104,9 +104,13 @@ export function placeStore(bridge, delay = 300) { if (!pending) return writes; const text = formatPlace(pending); pending = null; - if (text !== written) writes = writes - .then(() => publish(bridge, placePath, new Map([['output', encoder.encode(text)]]), {directory: false})) - .then(() => { written = text; }, () => {}); + // Compared once the writes before this one are done: a place chosen again while another one is being written + // must still replace it. + writes = writes.then(async () => { + if (text === written) return; + await publish(bridge, placePath, new Map([['output', encoder.encode(text)]]), {directory: false}); + written = text; + }).catch(() => {}); return writes; }; return { @@ -144,7 +148,7 @@ ${floating} .webfront-terminal-bar{display:flex} .webfront-terminal-close{margin:0;padding:0;width:32px;height:32px;border:0;background:none;color:inherit;font:20px/1 system-ui;cursor:pointer} .webfront-terminal-toggle{position:fixed;top:8px;right:8px;z-index:2147483647;margin:0;padding:0;width:44px;height:44px;display:grid;place-items:center;border:1px solid #46536a;border-radius:50%;background:#f6f7f2;box-shadow:0 2px 8px #0006;cursor:pointer;opacity:.9} .webfront-terminal-toggle:hover,.webfront-terminal-toggle[aria-expanded=true]{opacity:1} -:root[${attribute}=terminal] .webfront-terminal-toggle{display:none} +:root[${attribute}=terminal] .webfront-terminal-toggle,:root[${attribute}=terminal] .webfront-interface{display:none} `; const managed = new WeakSet(); @@ -195,6 +199,7 @@ export async function createWorkspace({bridge, element, frame}) { panel.append(bar, element); Object.assign(element.style, {flex: '1 1 auto', height: 'auto', minHeight: '0', boxSizing: 'border-box'}); Object.assign(frame.style, {position: 'fixed', inset: '0', width: '100%', height: '100%'}); + frame.classList.add('webfront-interface'); const button = page.createElement('button'); button.type = 'button'; @@ -233,8 +238,11 @@ export async function createWorkspace({bridge, element, frame}) { button.addEventListener('click', () => apply('toggle')); closeButton.addEventListener('click', () => apply('close')); - // The preview commands show the frame (and nothing else hides it): the layout follows it. - new view.MutationObserver(() => apply(frame.hidden ? 'hidden' : 'shown')).observe(frame, {attributes: true, attributeFilter: ['hidden']}); + // Only a published preview loaded in the frame is an interface. wf dev also unhides the frame to show the diagnostic + // of a failed build: before any preview, the frame stays out of the page and the terminal, which prints the + // diagnostic too, keeps the window. + frame.addEventListener('webfront-preview-navigating', () => apply('shown')); + new view.MutationObserver(() => { if (frame.hidden) apply('hidden'); }).observe(frame, {attributes: true, attributeFilter: ['hidden']}); // The shortcut works wherever the focus is: in this page and in the interface, whose window changes at each load. const onKey = event => { diff --git a/test/developer/specs/workspace-specs.mjs b/test/developer/specs/workspace-specs.mjs index eeb7a3d3..c01cecc2 100644 --- a/test/developer/specs/workspace-specs.mjs +++ b/test/developer/specs/workspace-specs.mjs @@ -134,6 +134,19 @@ describe('The developer page layout', () => { expect(await readPlace(bridge)).toBeNull(); }); + it('keeps the last place chosen when it equals the one written before the write in progress', async () => { + const {bridge} = memoryBridge(); + const store = placeStore(bridge, 60000); + const first = {x: 1, y: 2, width: 400, height: 300}, second = {x: 50, y: 60, width: 400, height: 300}; + store.remember(first); + await store.saved(); + store.remember(second); + const writing = store.saved(); // not awaited: the first place is chosen again while this one is written + store.remember(first); + await Promise.all([writing, store.saved()]); + expect(await readPlace(bridge)).toEqual(first); + }); + it('stays usable when the place cannot be written', async () => { const store = placeStore({cppFunction: () => async () => { throw new Error('read-only project'); }}, 60000); store.remember({x: 1, y: 2, width: 400, height: 300}); diff --git a/test/web/developer-specs.mjs b/test/web/developer-specs.mjs index 383b40ef..54e66423 100644 --- a/test/web/developer-specs.mjs +++ b/test/web/developer-specs.mjs @@ -847,6 +847,24 @@ try { 'The terminal must take the width of the window, under the status'); } await writeFile('layout/main.ts', "import {value} from './value'; document.getElementById('root').textContent = value;\n"); + if (part === 'workspace') { + // A first build that fails shows its diagnostic in the terminal: no interface was published, so the page keeps + // the terminal alone, without the icon or an empty frame, also once wf dev is stopped. + await writeFile('layout/value.ts', 'export const value = ;\n'); + const failedStop = new AbortController(); + let failedOutput = ''; + const failedDev = execute(['dev', 'layout/main.ts'], {...context, signal: failedStop.signal, + write: text => { failedOutput += text; }}).then(() => null, error => error); + const alone = () => here.state() === 'terminal' && here.style('.webfront-terminal-toggle').display === 'none' + && here.style('#preview').display === 'none' && here.style('header').display !== 'none'; + try { + await until(() => /layout\/value.ts:1:/.test(failedOutput), 'The failed first build must be reported in the terminal'); + assert(alone(), `A failed first build must not show an empty interface: ${here.state()}`); + } finally { failedStop.abort(); } + assert((await failedDev)?.exitCode === 130 && alone(), 'Stopping wf dev after a failed first build must leave the terminal alone'); + assert(!(await call('list', '.webfront/developer').then(bytes => JSON.parse(new TextDecoder().decode(bytes)))).includes('preview/'), + 'A failed first build must not publish a preview'); + } await writeFile('layout/value.ts', "export const value: string = 'layout-one';\n"); // wf create and wf build do not make an interface to show at the next launch; wf preview does. await execute(['build', 'layout/main.ts'], context); From e1a0c3352ba6c4cf90da4107791f53f181e44692 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Wed, 11 Nov 2026 06:36:35 +0100 Subject: [PATCH 05/11] Handle F9 in the frames that the interface embeds (#539) Keys do not leave the document that has the focus: the shortcut is installed in the same-origin frames of the interface, at any depth, present or added later, and again after each of their loads. --- docs/DEVELOPER_ENVIRONMENT.md | 4 ++- js/developer/environment/bundles.json | 2 +- js/developer/environment/workspace.mjs | 35 +++++++++++++++++++++----- test/web/developer-specs.mjs | 27 ++++++++++++++++++++ 4 files changed, 60 insertions(+), 8 deletions(-) diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index 7f681b3c..f4664b6e 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -392,7 +392,9 @@ environment's `mount`, not to the embedded bootstrap page): diagnostic over it. The icon is a button (`aria-expanded`, 44 px target) and the window a non-modal dialog. The interface stays in the preview -frame, as before: the layout adds nothing to the application's document except the F9 listener. This is a layout, not a +frame, as before: the layout adds nothing to the application's documents except the F9 listener, installed in the interface +and in the same-origin frames it embeds (not in a frame of another origin, nor one inside a shadow tree: click the interface +or the icon first). This is a layout, not a sandbox (see [limitations](#dependencies-storage-and-limitations)). An application that uses F9 itself does not receive it in the developer page; it does in its embedded form. A page that mounts the terminal itself (`runtime.mount`) with a preview frame gets the same layout; `workspace: false` keeps the page as it is. diff --git a/js/developer/environment/bundles.json b/js/developer/environment/bundles.json index c5566838..0540d09c 100644 --- a/js/developer/environment/bundles.json +++ b/js/developer/environment/bundles.json @@ -22,7 +22,7 @@ "js/developer/environment/development.mjs": "1125043016727111031a452fbebec358b9e78231f82fe91df7dea0fe8b22f015", "js/developer/environment/testing.mjs": "aeb584505fab5957b9c02e78536e12f7d7f3d12f8adb2e17f1a1a6e395e43f3c", "js/developer/environment/terminal.mjs": "7ffcf7ac6ef63c35cdf5ef70284b384525b13ba18422af069289e53b6c4f6be1", - "js/developer/environment/workspace.mjs": "40cdcfdb044bd5b7d9fc5e6bbad5dd145e7e707a1b1998dca79b3069b9cbfc50", + "js/developer/environment/workspace.mjs": "7f17910385459fc269928c9a34a8f58e83ca218084a6c43d6c3d89154b3c9bf0", "js/developer/environment/tarball.mjs": "1c1e1aea067910e1fec74e85b4bf9fbefed9b38187a04d8d2764f0b9a96fca39", "js/developer/environment/commands.mjs": "8de20c01f02f33c0566f204fcf1ee2382a23344d2103581fe2914469ec570531", "js/developer/environment/compiler.mjs": "0158931132aa9b43b7bbbd01de6fa4fc34fce8c65515d593dd494930f7a1910f", diff --git a/js/developer/environment/workspace.mjs b/js/developer/environment/workspace.mjs index 224261b7..13467703 100644 --- a/js/developer/environment/workspace.mjs +++ b/js/developer/environment/workspace.mjs @@ -252,12 +252,35 @@ export async function createWorkspace({bridge, element, frame}) { apply('toggle'); }; view.addEventListener('keydown', onKey, true); - const watchInterface = () => { - try { frame.contentWindow?.addEventListener('keydown', onKey, true); } - catch { /* a page of another origin keeps its keys */ } - }; - frame.addEventListener('load', watchInterface); - watchInterface(); + // Keys do not leave the document that has the focus: the interface and the frames it embeds, present or added + // later, each get the listener, again after each of their loads. A document of another origin keeps its keys. + const observed = new WeakSet(), framed = new WeakSet(); + const isFrame = node => node.localName === 'iframe' || node.localName === 'frame'; + function watchFrame(element) { + if (!framed.has(element)) { + framed.add(element); + element.addEventListener('load', () => watchWindow(element.contentWindow)); + } + watchWindow(element.contentWindow); + } + function watchWindow(target) { + let content; + try { + target.addEventListener('keydown', onKey, true); + content = target.document; + } catch { return; } // no window yet, or another origin + if (observed.has(content)) return; + observed.add(content); + content.querySelectorAll('iframe,frame').forEach(watchFrame); + new target.MutationObserver(records => { + for (const {addedNodes} of records) for (const node of addedNodes) { + if (node.nodeType !== 1) continue; + if (isFrame(node)) watchFrame(node); + node.querySelectorAll('iframe,frame').forEach(watchFrame); + } + }).observe(content, {childList: true, subtree: true}); + } + watchFrame(frame); // Moving: the pointer is captured, so that the interface under the window does not take the moves. let grip = null; diff --git a/test/web/developer-specs.mjs b/test/web/developer-specs.mjs index 54e66423..04313b18 100644 --- a/test/web/developer-specs.mjs +++ b/test/web/developer-specs.mjs @@ -980,6 +980,33 @@ try { assert(again.state() === 'interface', 'F9 in the terminal must collapse it'); key(pagePreview.contentDocument.body, {key: 'F9', ctrlKey: true}); assert(again.state() === 'interface', 'Another key combination must be left to the interface'); + // The focus may be in a frame that the interface embeds, at any depth, added after its load: keys do not leave + // the document that has it. + const embed = async parent => { + const inner = parent.createElement('iframe'); + const loaded = new Promise(resolve => inner.addEventListener('load', resolve, {once: true})); + inner.srcdoc = ''; + parent.body.append(inner); + await loaded; + return inner; + }; + const inner = await embed(pagePreview.contentDocument); + const innermost = await embed(inner.contentDocument); + await delay(0); // the observers of added frames have run + inner.contentDocument.querySelector('input').focus(); + key(inner.contentDocument.querySelector('input'), {key: 'F9'}); + assert(again.state() === 'floating', 'F9 in a frame of the interface must open the terminal'); + key(innermost.contentDocument.querySelector('input'), {key: 'F9'}); + assert(again.state() === 'interface', 'F9 in a nested frame of the interface must collapse the terminal'); + // A frame that loads another document keeps the shortcut. + const reloaded = new Promise(resolve => inner.addEventListener('load', resolve, {once: true})); + inner.srcdoc = ''; + await reloaded; + key(inner.contentDocument.querySelector('button'), {key: 'F9'}); + assert(again.state() === 'floating', 'F9 must work in a frame of the interface that loaded another document'); + key(pagePreview.contentDocument.body, {key: 'F9'}); + assert(again.state() === 'interface', 'F9 in the interface must collapse the terminal again'); + inner.remove(); // wf dev with the terminal collapsed: the full-window interface reloads and shows the build diagnostics. const devStop = new AbortController(); From 991d9e9808c07a9036a6b94e4acde187e1a59e14 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Wed, 11 Nov 2026 08:33:11 +0100 Subject: [PATCH 06/11] Let the manifest name the terminal's shortcut, so that an application keeps F9 (#539) The developer page takes the shortcut before the interface does. A project whose application uses F9 names another one with developer.terminalShortcut (a function key, optionally after Ctrl, Alt, Shift or Meta); the page reads it when it opens and the icon names it. F9 stays the default. --- docs/CHANGELOG.md | 2 +- docs/DEVELOPER_ENVIRONMENT.md | 16 +++++--- js/developer/environment/bundles.json | 6 +-- js/developer/environment/manifest.mjs | 32 +++++++++++++++- js/developer/environment/packages.bundle.mjs | 22 +++++------ js/developer/environment/workspace.mjs | 40 ++++++++++++++++---- test/developer/specs/manifest-specs.mjs | 17 ++++++++- test/developer/specs/workspace-specs.mjs | 17 ++++++++- test/web/developer-specs.mjs | 16 ++++++++ 9 files changed, 136 insertions(+), 32 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 298c3bd6..ea708104 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -12,7 +12,7 @@ these entries stays in the GitHub releases and the Git history. ### Changed -- Open the developer page on the interface, over the whole window, once the project has a preview; the terminal moves to a floating, movable window behind an icon at the top right (F9), and keeps its session when collapsed. Environment sources 0.9.1, not published yet (#539, `docs/DEVELOPER_ENVIRONMENT.md`). +- Open the developer page on the interface, over the whole window, once the project has a preview; the terminal moves to a floating, movable window behind an icon at the top right, and keeps its session when collapsed. Its shortcut is F9, or the manifest's new optional `developer.terminalShortcut`. Environment sources 0.9.1, not published yet (#539, `docs/DEVELOPER_ENVIRONMENT.md`). ## [0.9.0] - 2026-11-10 diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index f4664b6e..67cae8d0 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -181,7 +181,8 @@ A project has one manifest, which every `wf` command reads: "entries": {"main": "ui/main.tsx"}, "providers": {"LifeUI": {"entry": "main", "output": "generated/LifeUI.hpp"}}, "test": {"specs": []}, - "permissions": {} + "permissions": {}, + "developer": {"terminalShortcut": "F9"} } ``` @@ -189,7 +190,8 @@ Only `format`, `name` and `version` are required. Validation is strict: an unkno newer than the environment reads, a path leaving the project, a non-HTTPS registry or origin and an unknown permission are errors printed in the terminal, never silently ignored. `scripts` and `permissions` are used by `wf run` and `wf exec` (below); `test.specs` lists the spec files of `wf test`. Permissions only frame -the operations of the `context` API of scripts; they are not a sandbox. +the operations of the `context` API of scripts; they are not a sandbox. `developer.terminalShortcut` (environment 0.9.1; +an earlier environment refuses the key) is the shortcut of the [terminal window](#the-page-interface-and-floating-terminal). - `wf init [name]` writes `webfront.project.json` at the project root (or in the application's manifest directory, below), the manifest every `wf` command reads; it never replaces an existing one. When a lock already exists (a project installed before @@ -388,15 +390,19 @@ environment's `mount`, not to the embedded bootstrap page): bottom-right corner resizes with the pointer. The window stays inside the browser window, shrinks with it and returns to its place when there is room again; xterm.js is fitted to it. Its place and size are kept per project in `.webfront/developer/terminal-window.json`. +- **The shortcut** is F9 by default. The developer page takes it before the interface does, so an application that uses + F9 itself names another one in its manifest, and receives F9 as it does in its embedded form: + `"developer": {"terminalShortcut": "Ctrl+Shift+F9"}`. A shortcut is a function key, F1 to F12, optionally after `Ctrl`, + `Alt`, `Shift` or `Meta`, joined by `+`; anything else is a manifest error. The page reads it when it opens: relaunch + the application after changing it. The icon's tooltip names the shortcut in use. - While the terminal is collapsed, `wf dev` keeps reloading the full-window interface, and a failed build still shows its diagnostic over it. The icon is a button (`aria-expanded`, 44 px target) and the window a non-modal dialog. The interface stays in the preview -frame, as before: the layout adds nothing to the application's documents except the F9 listener, installed in the interface +frame, as before: the layout adds nothing to the application's documents except the shortcut's listener, installed in the interface and in the same-origin frames it embeds (not in a frame of another origin, nor one inside a shadow tree: click the interface or the icon first). This is a layout, not a -sandbox (see [limitations](#dependencies-storage-and-limitations)). An application that uses F9 itself does not receive it in -the developer page; it does in its embedded form. A page that mounts the terminal itself (`runtime.mount`) with a preview frame gets +sandbox (see [limitations](#dependencies-storage-and-limitations)). A page that mounts the terminal itself (`runtime.mount`) with a preview frame gets the same layout; `workspace: false` keeps the page as it is. ## The terminal and the application's commands diff --git a/js/developer/environment/bundles.json b/js/developer/environment/bundles.json index 0540d09c..2d62be0a 100644 --- a/js/developer/environment/bundles.json +++ b/js/developer/environment/bundles.json @@ -1,6 +1,6 @@ { "LICENSE": "0b96b3ed27eb64ba777eaa049093d0047c7f9a4e690b6e68b52fde2844226ccd", - "js/developer/environment/manifest.mjs": "8a655810fd7bd380d861adad9a7870bb677fd530483cf9113ca240e03facdce5", + "js/developer/environment/manifest.mjs": "98203e18e4c85b806d03db9fe52d619cc6d8d5e8acf267daeb6944c2b7956806", "js/developer/environment/project.mjs": "280cced29e41bc48d5d9d69934186ababfdbbc9dc32ed9517e17af4f19d3bd73", "js/developer/environment/installer.mjs": "1159404b151dc8c580d9a155a9ec0dfa3fcb6a8e073d8586d29b329ce91b741b", "js/developer/environment/restore.mjs": "cdd22eebd55d68bd705685cd5ee3059e228a35053eaad116ab99c4c05b908098", @@ -22,7 +22,7 @@ "js/developer/environment/development.mjs": "1125043016727111031a452fbebec358b9e78231f82fe91df7dea0fe8b22f015", "js/developer/environment/testing.mjs": "aeb584505fab5957b9c02e78536e12f7d7f3d12f8adb2e17f1a1a6e395e43f3c", "js/developer/environment/terminal.mjs": "7ffcf7ac6ef63c35cdf5ef70284b384525b13ba18422af069289e53b6c4f6be1", - "js/developer/environment/workspace.mjs": "7f17910385459fc269928c9a34a8f58e83ca218084a6c43d6c3d89154b3c9bf0", + "js/developer/environment/workspace.mjs": "0c7cadd37af3397b73c37b54daa01709b196e27dc8a83f519774b6c5f422e06a", "js/developer/environment/tarball.mjs": "1c1e1aea067910e1fec74e85b4bf9fbefed9b38187a04d8d2764f0b9a96fca39", "js/developer/environment/commands.mjs": "8de20c01f02f33c0566f204fcf1ee2382a23344d2103581fe2914469ec570531", "js/developer/environment/compiler.mjs": "0158931132aa9b43b7bbbd01de6fa4fc34fce8c65515d593dd494930f7a1910f", @@ -46,6 +46,6 @@ "js/developer/scripts/build.mjs": "def3c0ccecbc776b76e20571d015f9a1f23a267c0bd6c0c7a07a81ce9293a663", "js/developer/webfront.project.json": "6f4f56783012a792ca8eb1ac8a1ca0be51e6fcc83d760545d65da67c8687dd61", "js/core/bootstrap/bootstrap.bundle.mjs": "536831257f0fc92e31911841750e1e59247f7c64e756b0fcb878efd9860a741f", - "js/developer/environment/packages.bundle.mjs": "2d62f3fcdece8e898f15814d7e80fc3a27ea062f45514cf8e5c3ae32fd9d26c5", + "js/developer/environment/packages.bundle.mjs": "c9d5b0c3516b5c14e0583aa12b6f7993dd8b4290997b6281bfaacdfbcd98b9d4", "include/webfront/system/DeveloperReleaseData.hpp": "98094418f18a0ce30f6334c94fb8a1ab2df6d9026a2203223aa11796b622b4ee" } diff --git a/js/developer/environment/manifest.mjs b/js/developer/environment/manifest.mjs index f59662f4..c3a8c570 100644 --- a/js/developer/environment/manifest.mjs +++ b/js/developer/environment/manifest.mjs @@ -33,7 +33,7 @@ const exactVersion = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/; const rangeShape = /^[0-9A-Za-z.+\-^~<>=*| ]{1,128}$/; const label = /^[A-Za-z0-9][A-Za-z0-9:_.-]{0,63}$/; const identifier = /^[A-Za-z_][A-Za-z0-9_]*$/; -const keys = ['format', 'name', 'version', 'dependencies', 'registry', 'scripts', 'entries', 'providers', 'test', 'permissions']; +const keys = ['format', 'name', 'version', 'dependencies', 'registry', 'scripts', 'entries', 'providers', 'test', 'permissions', 'developer']; const permissionKeys = ['files', 'publish', 'fetch']; const fail = message => { throw new Error(`${manifestPath}: ${message}`); }; @@ -136,6 +136,35 @@ function checkPermissions(value) { return permissions; } +const shortcutModifiers = {Ctrl: 'ctrlKey', Alt: 'altKey', Shift: 'shiftKey', Meta: 'metaKey'}; + +/** The shortcut of the terminal window when the manifest names none. */ +export const defaultTerminalShortcut = 'F9'; + +/** + * A shortcut written as "F9" or "Ctrl+Shift+F10": a function key, F1 to F12, after any of Ctrl, Alt, Shift and Meta, each + * at most once. Gives the key and the modifiers as a keyboard event has them; null when the text is not a shortcut. + */ +export function parseShortcut(text) { + if (typeof text !== 'string') return null; + const parts = text.split('+'), key = parts.pop(); + if (!/^F(?:[1-9]|1[0-2])$/.test(key) || new Set(parts).size !== parts.length) return null; + const shortcut = {key, ctrlKey: false, altKey: false, shiftKey: false, metaKey: false}; + for (const part of parts) { + if (!Object.hasOwn(shortcutModifiers, part)) return null; + shortcut[shortcutModifiers[part]] = true; + } + return shortcut; +} + +function checkDeveloper(value) { + const developer = requireObject(value, 'developer'); + onlyKeys(developer, ['terminalShortcut'], 'developer'); + if (developer.terminalShortcut !== undefined && !parseShortcut(developer.terminalShortcut)) + fail('developer.terminalShortcut must be a function key, F1 to F12, optionally after Ctrl, Alt, Shift or Meta (for instance "Ctrl+Shift+F9")'); + return developer; +} + function checkIdentity(manifest) { if (typeof manifest.name !== 'string' || !npmName.test(manifest.name)) fail('name must be a lower-case npm package name'); if (typeof manifest.version !== 'string' || !exactVersion.test(manifest.version)) fail('version must be a semantic version'); @@ -164,6 +193,7 @@ export function validateManifest(manifest) { ...(manifest.scripts === undefined ? {} : {scripts: checkScripts(manifest.scripts)}), ...(manifest.test === undefined ? {} : {test: checkTest(manifest.test)}), ...(manifest.permissions === undefined ? {} : {permissions: checkPermissions(manifest.permissions)}), + ...(manifest.developer === undefined ? {} : {developer: checkDeveloper(manifest.developer)}), }; } diff --git a/js/developer/environment/packages.bundle.mjs b/js/developer/environment/packages.bundle.mjs index 772e9b5e..0c488a57 100644 --- a/js/developer/environment/packages.bundle.mjs +++ b/js/developer/environment/packages.bundle.mjs @@ -1,16 +1,16 @@ -var _n=Object.create;var gt=Object.defineProperty;var Vn=Object.getOwnPropertyDescriptor;var Xn=Object.getOwnPropertyNames;var Bn=Object.getPrototypeOf,Hn=Object.prototype.hasOwnProperty;var w=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}};var Yn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Xn(t))!Hn.call(e,s)&&s!==r&>(e,s,{get:()=>t[s],enumerable:!(n=Vn(t,s))||n.enumerable});return e};var F=(e,t,r)=>(r=e!=null?_n(Bn(e)):{},Yn(t||!e||!e.__esModule?gt(r,"default",{value:e,enumerable:!0}):r,e));var V=w((ya,Ot)=>{"use strict";var ts="2.0.0",rs=Number.MAX_SAFE_INTEGER||9007199254740991,ns=16,ss=250,os=["major","premajor","minor","preminor","patch","prepatch","prerelease"];Ot.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:ns,MAX_SAFE_BUILD_LENGTH:ss,MAX_SAFE_INTEGER:rs,RELEASE_TYPES:os,SEMVER_SPEC_VERSION:ts,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var X=w((xa,vt)=>{"use strict";var is=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};vt.exports=is});var z=w((j,It)=>{"use strict";var{MAX_SAFE_COMPONENT_LENGTH:Te,MAX_SAFE_BUILD_LENGTH:cs,MAX_LENGTH:as}=V(),ls=X();j=It.exports={};var us=j.re=[],fs=j.safeRe=[],p=j.src=[],ps=j.safeSrc=[],h=j.t={},hs=0,je="[a-zA-Z0-9-]",ds=[["\\s",1],["\\d",as],[je,cs]],ms=e=>{for(let[t,r]of ds)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e},E=(e,t,r)=>{let n=ms(t),s=hs++;ls(e,s,t),h[e]=s,p[s]=t,ps[s]=n,us[s]=new RegExp(t,r?"g":void 0),fs[s]=new RegExp(n,r?"g":void 0)};E("NUMERICIDENTIFIER","0|[1-9]\\d*");E("NUMERICIDENTIFIERLOOSE","\\d+");E("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${je}*`);E("MAINVERSION",`(${p[h.NUMERICIDENTIFIER]})\\.(${p[h.NUMERICIDENTIFIER]})\\.(${p[h.NUMERICIDENTIFIER]})`);E("MAINVERSIONLOOSE",`(${p[h.NUMERICIDENTIFIERLOOSE]})\\.(${p[h.NUMERICIDENTIFIERLOOSE]})\\.(${p[h.NUMERICIDENTIFIERLOOSE]})`);E("PRERELEASEIDENTIFIER",`(?:${p[h.NONNUMERICIDENTIFIER]}|${p[h.NUMERICIDENTIFIER]})`);E("PRERELEASEIDENTIFIERLOOSE",`(?:${p[h.NONNUMERICIDENTIFIER]}|${p[h.NUMERICIDENTIFIERLOOSE]})`);E("PRERELEASE",`(?:-(${p[h.PRERELEASEIDENTIFIER]}(?:\\.${p[h.PRERELEASEIDENTIFIER]})*))`);E("PRERELEASELOOSE",`(?:-?(${p[h.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${p[h.PRERELEASEIDENTIFIERLOOSE]})*))`);E("BUILDIDENTIFIER",`${je}+`);E("BUILD",`(?:\\+(${p[h.BUILDIDENTIFIER]}(?:\\.${p[h.BUILDIDENTIFIER]})*))`);E("FULLPLAIN",`v?${p[h.MAINVERSION]}${p[h.PRERELEASE]}?${p[h.BUILD]}?`);E("FULL",`^${p[h.FULLPLAIN]}$`);E("LOOSEPLAIN",`[v=\\s]*${p[h.MAINVERSIONLOOSE]}${p[h.PRERELEASELOOSE]}?${p[h.BUILD]}?`);E("LOOSE",`^${p[h.LOOSEPLAIN]}$`);E("GTLT","((?:<|>)?=?)");E("XRANGEIDENTIFIERLOOSE",`${p[h.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);E("XRANGEIDENTIFIER",`${p[h.NUMERICIDENTIFIER]}|x|X|\\*`);E("XRANGEPLAIN",`[v=\\s]*(${p[h.XRANGEIDENTIFIER]})(?:\\.(${p[h.XRANGEIDENTIFIER]})(?:\\.(${p[h.XRANGEIDENTIFIER]})(?:${p[h.PRERELEASE]})?${p[h.BUILD]}?)?)?`);E("XRANGEPLAINLOOSE",`[v=\\s]*(${p[h.XRANGEIDENTIFIERLOOSE]})(?:\\.(${p[h.XRANGEIDENTIFIERLOOSE]})(?:\\.(${p[h.XRANGEIDENTIFIERLOOSE]})(?:${p[h.PRERELEASELOOSE]})?${p[h.BUILD]}?)?)?`);E("XRANGE",`^${p[h.GTLT]}\\s*${p[h.XRANGEPLAIN]}$`);E("XRANGELOOSE",`^${p[h.GTLT]}\\s*${p[h.XRANGEPLAINLOOSE]}$`);E("COERCEPLAIN",`(^|[^\\d])(\\d{1,${Te}})(?:\\.(\\d{1,${Te}}))?(?:\\.(\\d{1,${Te}}))?`);E("COERCE",`${p[h.COERCEPLAIN]}(?:$|[^\\d])`);E("COERCEFULL",p[h.COERCEPLAIN]+`(?:${p[h.PRERELEASE]})?(?:${p[h.BUILD]})?(?:$|[^\\d])`);E("COERCERTL",p[h.COERCE],!0);E("COERCERTLFULL",p[h.COERCEFULL],!0);E("LONETILDE","(?:~>?)");E("TILDETRIM",`(\\s*)${p[h.LONETILDE]}\\s+`,!0);j.tildeTrimReplace="$1~";E("TILDE",`^${p[h.LONETILDE]}${p[h.XRANGEPLAIN]}$`);E("TILDELOOSE",`^${p[h.LONETILDE]}${p[h.XRANGEPLAINLOOSE]}$`);E("LONECARET","(?:\\^)");E("CARETTRIM",`(\\s*)${p[h.LONECARET]}\\s+`,!0);j.caretTrimReplace="$1^";E("CARET",`^${p[h.LONECARET]}${p[h.XRANGEPLAIN]}$`);E("CARETLOOSE",`^${p[h.LONECARET]}${p[h.XRANGEPLAINLOOSE]}$`);E("COMPARATORLOOSE",`^${p[h.GTLT]}\\s*(${p[h.LOOSEPLAIN]})$|^$`);E("COMPARATOR",`^${p[h.GTLT]}\\s*(${p[h.FULLPLAIN]})$|^$`);E("COMPARATORTRIM",`(\\s*)${p[h.GTLT]}\\s*(${p[h.LOOSEPLAIN]}|${p[h.XRANGEPLAIN]})`,!0);j.comparatorTrimReplace="$1$2$3";E("HYPHENRANGE",`^\\s*(${p[h.XRANGEPLAIN]})\\s+-\\s+(${p[h.XRANGEPLAIN]})\\s*$`);E("HYPHENRANGELOOSE",`^\\s*(${p[h.XRANGEPLAINLOOSE]})\\s+-\\s+(${p[h.XRANGEPLAINLOOSE]})\\s*$`);E("STAR","(<|>)?=?\\s*\\*");E("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");E("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var ce=w((Ra,Nt)=>{"use strict";var ws=Object.freeze({loose:!0}),Es=Object.freeze({}),gs=e=>e?typeof e!="object"?ws:e:Es;Nt.exports=gs});var Pe=w((ba,Lt)=>{"use strict";var kt=/^[0-9]+$/,St=(e,t)=>{if(typeof e=="number"&&typeof t=="number")return e===t?0:eSt(t,e);Lt.exports={compareIdentifiers:St,rcompareIdentifiers:$s}});var b=w((Oa,Tt)=>{"use strict";var ae=X(),{MAX_LENGTH:At,MAX_SAFE_INTEGER:le}=V(),{safeRe:ue,t:fe}=z(),ys=ce(),{compareIdentifiers:qe}=Pe(),Ce=class e{constructor(t,r){if(r=ys(r),t instanceof e){if(t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>At)throw new TypeError(`version is longer than ${At} characters`);ae("SemVer",t,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let n=t.trim().match(r.loose?ue[fe.LOOSE]:ue[fe.FULL]);if(!n)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>le||this.major<0)throw new TypeError("Invalid major version");if(this.minor>le||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>le||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(s=>{if(/^[0-9]+$/.test(s)){let o=+s;if(o>=0&&ot.major?1:this.minort.minor?1:this.patcht.patch?1:0}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let n=this.prerelease[r],s=t.prerelease[r];if(ae("prerelease compare",r,n,s),n===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(n===void 0)return-1;if(n===s)continue;return qe(n,s)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let n=this.build[r],s=t.build[r];if(ae("build compare",r,n,s),n===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(n===void 0)return-1;if(n===s)continue;return qe(n,s)}while(++r)}inc(t,r,n){if(t.startsWith("pre")){if(!r&&n===!1)throw new Error("invalid increment argument: identifier is empty");if(r){let s=`-${r}`.match(this.options.loose?ue[fe.PRERELEASELOOSE]:ue[fe.PRERELEASE]);if(!s||s[1]!==r)throw new Error(`invalid identifier: ${r}`)}}switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r,n);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r,n);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r,n),this.inc("pre",r,n);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",r,n),this.inc("pre",r,n);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{let s=Number(n)?1:0;if(this.prerelease.length===0)this.prerelease=[s];else{let o=this.prerelease.length;for(;--o>=0;)typeof this.prerelease[o]=="number"&&(this.prerelease[o]++,o=-2);if(o===-1){if(r===this.prerelease.join(".")&&n===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(s)}}if(r){let o=[r,s];n===!1&&(o=[r]),qe(this.prerelease[0],r)===0?isNaN(this.prerelease[1])&&(this.prerelease=o):this.prerelease=o}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};Tt.exports=Ce});var q=w((va,Pt)=>{"use strict";var jt=b(),xs=(e,t,r=!1)=>{if(e instanceof jt)return e;try{return new jt(e,t)}catch(n){if(!r)return null;throw n}};Pt.exports=xs});var Ct=w((Ia,qt)=>{"use strict";var Rs=q(),bs=(e,t)=>{let r=Rs(e,t);return r?r.version:null};qt.exports=bs});var Ut=w((Na,Dt)=>{"use strict";var Os=q(),vs=(e,t)=>{let r=Os(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null};Dt.exports=vs});var Gt=w((ka,zt)=>{"use strict";var Ft=b(),Is=(e,t,r,n,s)=>{typeof r=="string"&&(s=n,n=r,r=void 0);try{return new Ft(e instanceof Ft?e.version:e,r).inc(t,n,s).version}catch{return null}};zt.exports=Is});var _t=w((Sa,Wt)=>{"use strict";var Mt=q(),Ns=(e,t)=>{let r=Mt(e,null,!0),n=Mt(t,null,!0),s=r.compare(n);if(s===0)return null;let o=s>0,i=o?r:n,a=o?n:r,c=!!i.prerelease.length;if(!!a.prerelease.length&&!c){if(!a.patch&&!a.minor)return"major";if(a.compareMain(i)===0)return a.minor&&!a.patch?"minor":"patch"}let u=c?"pre":"";return r.major!==n.major?u+"major":r.minor!==n.minor?u+"minor":r.patch!==n.patch?u+"patch":"prerelease"};Wt.exports=Ns});var Xt=w((La,Vt)=>{"use strict";var ks=b(),Ss=(e,t)=>new ks(e,t).major;Vt.exports=Ss});var Ht=w((Aa,Bt)=>{"use strict";var Ls=b(),As=(e,t)=>new Ls(e,t).minor;Bt.exports=As});var Jt=w((Ta,Yt)=>{"use strict";var Ts=b(),js=(e,t)=>new Ts(e,t).patch;Yt.exports=js});var Kt=w((ja,Zt)=>{"use strict";var Ps=q(),qs=(e,t)=>{let r=Ps(e,t);return r&&r.prerelease.length?r.prerelease:null};Zt.exports=qs});var S=w((Pa,er)=>{"use strict";var Qt=b(),Cs=(e,t,r)=>new Qt(e,r).compare(new Qt(t,r));er.exports=Cs});var rr=w((qa,tr)=>{"use strict";var Ds=S(),Us=(e,t,r)=>Ds(t,e,r);tr.exports=Us});var sr=w((Ca,nr)=>{"use strict";var Fs=S(),zs=(e,t)=>Fs(e,t,!0);nr.exports=zs});var pe=w((Da,ir)=>{"use strict";var or=b(),Gs=(e,t,r)=>{let n=new or(e,r),s=new or(t,r);return n.compare(s)||n.compareBuild(s)};ir.exports=Gs});var ar=w((Ua,cr)=>{"use strict";var Ms=pe(),Ws=(e,t)=>e.sort((r,n)=>Ms(r,n,t));cr.exports=Ws});var ur=w((Fa,lr)=>{"use strict";var _s=pe(),Vs=(e,t)=>e.sort((r,n)=>_s(n,r,t));lr.exports=Vs});var B=w((za,fr)=>{"use strict";var Xs=S(),Bs=(e,t,r)=>Xs(e,t,r)>0;fr.exports=Bs});var he=w((Ga,pr)=>{"use strict";var Hs=S(),Ys=(e,t,r)=>Hs(e,t,r)<0;pr.exports=Ys});var De=w((Ma,hr)=>{"use strict";var Js=S(),Zs=(e,t,r)=>Js(e,t,r)===0;hr.exports=Zs});var Ue=w((Wa,dr)=>{"use strict";var Ks=S(),Qs=(e,t,r)=>Ks(e,t,r)!==0;dr.exports=Qs});var de=w((_a,mr)=>{"use strict";var eo=S(),to=(e,t,r)=>eo(e,t,r)>=0;mr.exports=to});var me=w((Va,wr)=>{"use strict";var ro=S(),no=(e,t,r)=>ro(e,t,r)<=0;wr.exports=no});var Fe=w((Xa,Er)=>{"use strict";var so=De(),oo=Ue(),io=B(),co=de(),ao=he(),lo=me(),uo=(e,t,r,n)=>{switch(t){case"===":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e===r;case"!==":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e!==r;case"":case"=":case"==":return so(e,r,n);case"!=":return oo(e,r,n);case">":return io(e,r,n);case">=":return co(e,r,n);case"<":return ao(e,r,n);case"<=":return lo(e,r,n);default:throw new TypeError(`Invalid operator: ${t}`)}};Er.exports=uo});var $r=w((Ba,gr)=>{"use strict";var fo=b(),po=q(),{safeRe:we,t:Ee}=z(),ho=(e,t)=>{if(e instanceof fo)return e;if(typeof e=="number"&&(e=String(e)),typeof e!="string")return null;t=t||{};let r=null;if(!t.rtl)r=e.match(t.includePrerelease?we[Ee.COERCEFULL]:we[Ee.COERCE]);else{let c=t.includePrerelease?we[Ee.COERCERTLFULL]:we[Ee.COERCERTL],l;for(;(l=c.exec(e))&&(!r||r.index+r[0].length!==e.length);)(!r||l.index+l[0].length!==r.index+r[0].length)&&(r=l),c.lastIndex=l.index+l[1].length+l[2].length;c.lastIndex=-1}if(r===null)return null;let n=r[2],s=r[3]||"0",o=r[4]||"0",i=t.includePrerelease&&r[5]?`-${r[5]}`:"",a=t.includePrerelease&&r[6]?`+${r[6]}`:"";return po(`${n}.${s}.${o}${i}${a}`,t)};gr.exports=ho});var xr=w((Ha,yr)=>{"use strict";var ze=class{constructor(){this.max=1e3,this.map=new Map}get(t){let r=this.map.get(t);if(r!==void 0)return this.map.delete(t),this.map.set(t,r),r}delete(t){return this.map.delete(t)}set(t,r){if(!this.delete(t)&&r!==void 0){if(this.map.size>=this.max){let s=this.map.keys().next().value;this.delete(s)}this.map.set(t,r)}return this}};yr.exports=ze});var L=w((Ya,vr)=>{"use strict";var mo=/\s+/g,Ge=class e{constructor(t,r){if(r=Eo(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof Me)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(mo," "),this.set=this.raw.split("||").map(n=>this.parseRange(n.trim())).filter(n=>n.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let n=this.set[0];if(this.set=this.set.filter(s=>!br(s[0])),this.set.length===0)this.set=[n];else if(this.set.length>1){for(let s of this.set)if(s.length===1&&Oo(s[0])){this.set=[s];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let t=0;t0&&(this.formatted+="||");let r=this.set[t];for(let n=0;n0&&(this.formatted+=" "),this.formatted+=r[n].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(t){let n=((this.options.includePrerelease&&Ro)|(this.options.loose&&bo))+":"+t,s=Rr.get(n);if(s)return s;let o=this.options.loose,i=o?v[O.HYPHENRANGELOOSE]:v[O.HYPHENRANGE];t=t.replace(i,Po(this.options.includePrerelease)),g("hyphen replace",t),t=t.replace(v[O.COMPARATORTRIM],$o),g("comparator trim",t),t=t.replace(v[O.TILDETRIM],yo),g("tilde trim",t),t=t.replace(v[O.CARETTRIM],xo),g("caret trim",t);let a=t.split(" ").map(f=>vo(f,this.options)).join(" ").split(/\s+/).map(f=>jo(f,this.options));o&&(a=a.filter(f=>(g("loose invalid filter",f,this.options),!!f.match(v[O.COMPARATORLOOSE])))),g("range list",a);let c=new Map,l=a.map(f=>new Me(f,this.options));for(let f of l){if(br(f))return[f];c.set(f.value,f)}c.size>1&&c.has("")&&c.delete("");let u=[...c.values()];return Rr.set(n,u),u}intersects(t,r){if(!(t instanceof e))throw new TypeError("a Range is required");return this.set.some(n=>Or(n,r)&&t.set.some(s=>Or(s,r)&&n.every(o=>s.every(i=>o.intersects(i,r)))))}test(t){if(!t)return!1;if(typeof t=="string")try{t=new go(t,this.options)}catch{return!1}for(let r=0;re.value==="<0.0.0-0",Oo=e=>e.value==="",Or=(e,t)=>{let r=!0,n=e.slice(),s=n.pop();for(;r&&n.length;)r=n.every(o=>s.intersects(o,t)),s=n.pop();return r},vo=(e,t)=>(e=e.replace(v[O.BUILD],""),g("comp",e,t),e=ko(e,t),g("caret",e),e=Io(e,t),g("tildes",e),e=Lo(e,t),g("xrange",e),e=To(e,t),g("stars",e),e),I=e=>!e||e.toLowerCase()==="x"||e==="*",Io=(e,t)=>e.trim().split(/\s+/).map(r=>No(r,t)).join(" "),No=(e,t)=>{let r=t.loose?v[O.TILDELOOSE]:v[O.TILDE];return e.replace(r,(n,s,o,i,a)=>{g("tilde",e,n,s,o,i,a);let c;return I(s)?c="":I(o)?c=`>=${s}.0.0 <${+s+1}.0.0-0`:I(i)?c=`>=${s}.${o}.0 <${s}.${+o+1}.0-0`:a?(g("replaceTilde pr",a),c=`>=${s}.${o}.${i}-${a} <${s}.${+o+1}.0-0`):c=`>=${s}.${o}.${i} <${s}.${+o+1}.0-0`,g("tilde return",c),c})},ko=(e,t)=>e.trim().split(/\s+/).map(r=>So(r,t)).join(" "),So=(e,t)=>{g("caret",e,t);let r=t.loose?v[O.CARETLOOSE]:v[O.CARET],n=t.includePrerelease?"-0":"";return e.replace(r,(s,o,i,a,c)=>{g("caret",e,s,o,i,a,c);let l;return I(o)?l="":I(i)?l=`>=${o}.0.0${n} <${+o+1}.0.0-0`:I(a)?o==="0"?l=`>=${o}.${i}.0${n} <${o}.${+i+1}.0-0`:l=`>=${o}.${i}.0${n} <${+o+1}.0.0-0`:c?(g("replaceCaret pr",c),o==="0"?i==="0"?l=`>=${o}.${i}.${a}-${c} <${o}.${i}.${+a+1}-0`:l=`>=${o}.${i}.${a}-${c} <${o}.${+i+1}.0-0`:l=`>=${o}.${i}.${a}-${c} <${+o+1}.0.0-0`):(g("no pr"),o==="0"?i==="0"?l=`>=${o}.${i}.${a}${n} <${o}.${i}.${+a+1}-0`:l=`>=${o}.${i}.${a}${n} <${o}.${+i+1}.0-0`:l=`>=${o}.${i}.${a} <${+o+1}.0.0-0`),g("caret return",l),l})},Lo=(e,t)=>(g("replaceXRanges",e,t),e.split(/\s+/).map(r=>Ao(r,t)).join(" ")),Ao=(e,t)=>{e=e.trim();let r=t.loose?v[O.XRANGELOOSE]:v[O.XRANGE];return e.replace(r,(n,s,o,i,a,c)=>{g("xRange",e,n,s,o,i,a,c);let l=I(o),u=l||I(i),f=u||I(a),m=f;return s==="="&&m&&(s=""),c=t.includePrerelease?"-0":"",l?s===">"||s==="<"?n="<0.0.0-0":n="*":s&&m?(u&&(i=0),a=0,s===">"?(s=">=",u?(o=+o+1,i=0,a=0):(i=+i+1,a=0)):s==="<="&&(s="<",u?o=+o+1:i=+i+1),s==="<"&&(c="-0"),n=`${s+o}.${i}.${a}${c}`):u?n=`>=${o}.0.0${c} <${+o+1}.0.0-0`:f&&(n=`>=${o}.${i}.0${c} <${o}.${+i+1}.0-0`),g("xRange return",n),n})},To=(e,t)=>(g("replaceStars",e,t),e.trim().replace(v[O.STAR],"")),jo=(e,t)=>(g("replaceGTE0",e,t),e.trim().replace(v[t.includePrerelease?O.GTE0PRE:O.GTE0],"")),Po=e=>(t,r,n,s,o,i,a,c,l,u,f,m)=>(I(n)?r="":I(s)?r=`>=${n}.0.0${e?"-0":""}`:I(o)?r=`>=${n}.${s}.0${e?"-0":""}`:i?r=`>=${r}`:r=`>=${r}${e?"-0":""}`,I(l)?c="":I(u)?c=`<${+l+1}.0.0-0`:I(f)?c=`<${l}.${+u+1}.0-0`:m?c=`<=${l}.${u}.${f}-${m}`:e?c=`<${l}.${u}.${+f+1}-0`:c=`<=${c}`,`${r} ${c}`.trim()),qo=(e,t,r)=>{for(let n=0;n0){let s=e[n].semver;if(s.major===t.major&&s.minor===t.minor&&s.patch===t.patch)return!0}return!1}return!0}});var H=w((Ja,Ar)=>{"use strict";var Y=Symbol("SemVer ANY"),Ve=class e{static get ANY(){return Y}constructor(t,r){if(r=Ir(r),t instanceof e){if(t.loose===!!r.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(" "),_e("comparator",t,r),this.options=r,this.loose=!!r.loose,this.parse(t),this.semver===Y?this.value="":this.value=this.operator+this.semver.version,_e("comp",this)}parse(t){let r=this.options.loose?Nr[kr.COMPARATORLOOSE]:Nr[kr.COMPARATOR],n=t.match(r);if(!n)throw new TypeError(`Invalid comparator: ${t}`);this.operator=n[1]!==void 0?n[1]:"",this.operator==="="&&(this.operator=""),n[2]?this.semver=new Sr(n[2],this.options.loose):this.semver=Y}toString(){return this.value}test(t){if(_e("Comparator.test",t,this.options.loose),this.semver===Y||t===Y)return!0;if(typeof t=="string")try{t=new Sr(t,this.options)}catch{return!1}return We(t,this.operator,this.semver,this.options)}intersects(t,r){if(!(t instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new Lr(t.value,r).test(this.value):t.operator===""?t.value===""?!0:new Lr(this.value,r).test(t.semver):(r=Ir(r),r.includePrerelease&&(this.value==="<0.0.0-0"||t.value==="<0.0.0-0")||!r.includePrerelease&&(this.value.startsWith("<0.0.0")||t.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&t.operator.startsWith(">")||this.operator.startsWith("<")&&t.operator.startsWith("<")||this.semver.version===t.semver.version&&this.operator.includes("=")&&t.operator.includes("=")||We(this.semver,"<",t.semver,r)&&this.operator.startsWith(">")&&t.operator.startsWith("<")||We(this.semver,">",t.semver,r)&&this.operator.startsWith("<")&&t.operator.startsWith(">")))}};Ar.exports=Ve;var Ir=ce(),{safeRe:Nr,t:kr}=z(),We=Fe(),_e=X(),Sr=b(),Lr=L()});var J=w((Za,Tr)=>{"use strict";var Co=L(),Do=(e,t,r)=>{try{t=new Co(t,r)}catch{return!1}return t.test(e)};Tr.exports=Do});var Pr=w((Ka,jr)=>{"use strict";var Uo=L(),Fo=(e,t)=>new Uo(e,t).set.map(r=>r.map(n=>n.value).join(" ").trim().split(" "));jr.exports=Fo});var Cr=w((Qa,qr)=>{"use strict";var zo=b(),Go=L(),Mo=(e,t,r)=>{let n=null,s=null,o=null;try{o=new Go(t,r)}catch{return null}return e.forEach(i=>{o.test(i)&&(!n||s.compare(i)===-1)&&(n=i,s=new zo(n,r))}),n};qr.exports=Mo});var Ur=w((el,Dr)=>{"use strict";var Wo=b(),_o=L(),Vo=(e,t,r)=>{let n=null,s=null,o=null;try{o=new _o(t,r)}catch{return null}return e.forEach(i=>{o.test(i)&&(!n||s.compare(i)===1)&&(n=i,s=new Wo(n,r))}),n};Dr.exports=Vo});var Gr=w((tl,zr)=>{"use strict";var Xe=b(),Xo=L(),Fr=B(),Bo=(e,t)=>{e=new Xo(e,t);let r=new Xe("0.0.0");if(e.test(r)||(r=new Xe("0.0.0-0"),e.test(r)))return r;r=null;for(let n=0;n{let a=new Xe(i.semver.version);switch(i.operator){case">":a.prerelease.length===0?a.patch++:a.prerelease.push(0),a.raw=a.format();case"":case">=":(!o||Fr(a,o))&&(o=a);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${i.operator}`)}}),o&&(!r||Fr(r,o))&&(r=o)}return r&&e.test(r)?r:null};zr.exports=Bo});var Wr=w((rl,Mr)=>{"use strict";var Ho=L(),Yo=(e,t)=>{try{return new Ho(e,t).range||"*"}catch{return null}};Mr.exports=Yo});var ge=w((nl,Br)=>{"use strict";var Jo=b(),Xr=H(),{ANY:Zo}=Xr,Ko=L(),Qo=J(),_r=B(),Vr=he(),ei=me(),ti=de(),ri=(e,t,r,n)=>{e=new Jo(e,n),t=new Ko(t,n);let s,o,i,a,c;switch(r){case">":s=_r,o=ei,i=Vr,a=">",c=">=";break;case"<":s=Vr,o=ti,i=_r,a="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(Qo(e,t,n))return!1;for(let l=0;l{d.semver===Zo&&(d=new Xr(">=0.0.0")),f=f||d,m=m||d,s(d.semver,f.semver,n)?f=d:i(d.semver,m.semver,n)&&(m=d)}),f.operator===a||f.operator===c||(!m.operator||m.operator===a)&&o(e,m.semver))return!1;if(m.operator===c&&i(e,m.semver))return!1}return!0};Br.exports=ri});var Yr=w((sl,Hr)=>{"use strict";var ni=ge(),si=(e,t,r)=>ni(e,t,">",r);Hr.exports=si});var Zr=w((ol,Jr)=>{"use strict";var oi=ge(),ii=(e,t,r)=>oi(e,t,"<",r);Jr.exports=ii});var en=w((il,Qr)=>{"use strict";var Kr=L(),ci=(e,t,r)=>(e=new Kr(e,r),t=new Kr(t,r),e.intersects(t,r));Qr.exports=ci});var rn=w((cl,tn)=>{"use strict";var ai=J(),li=S();tn.exports=(e,t,r)=>{let n=[],s=null,o=null,i=e.sort((u,f)=>li(u,f,r));for(let u of i)ai(u,t,r)?(o=u,s||(s=u)):(o&&n.push([s,o]),o=null,s=null);s&&n.push([s,null]);let a=[];for(let[u,f]of n)u===f?a.push(u):!f&&u===i[0]?a.push("*"):f?u===i[0]?a.push(`<=${f}`):a.push(`${u} - ${f}`):a.push(`>=${u}`);let c=a.join(" || "),l=typeof t.raw=="string"?t.raw:String(t);return c.length{"use strict";var nn=L(),He=H(),{ANY:Be}=He,Z=J(),Ye=S(),ui=(e,t,r={})=>{if(e===t)return!0;e=new nn(e,r),t=new nn(t,r);let n=!1;e:for(let s of e.set){for(let o of t.set){let i=pi(s,o,r);if(n=n||i!==null,i)continue e}if(n)return!1}return!0},fi=[new He(">=0.0.0-0")],sn=[new He(">=0.0.0")],pi=(e,t,r)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===Be){if(t.length===1&&t[0].semver===Be)return!0;r.includePrerelease?e=fi:e=sn}if(t.length===1&&t[0].semver===Be){if(r.includePrerelease)return!0;t=sn}let n=new Set,s,o;for(let d of e)d.operator===">"||d.operator===">="?s=on(s,d,r):d.operator==="<"||d.operator==="<="?o=cn(o,d,r):n.add(d.semver);if(n.size>1)return null;let i;if(s&&o){if(i=Ye(s.semver,o.semver,r),i>0)return null;if(i===0&&(s.operator!==">="||o.operator!=="<="))return null}for(let d of n){if(s&&!Z(d,String(s),r)||o&&!Z(d,String(o),r))return null;for(let T of t)if(!Z(d,String(T),r))return!1;return!0}let a,c,l,u,f=o&&!r.includePrerelease&&o.semver.prerelease.length?o.semver:!1,m=s&&!r.includePrerelease&&s.semver.prerelease.length?s.semver:!1;f&&f.prerelease.length===1&&o.operator==="<"&&f.prerelease[0]===0&&(f=!1);for(let d of t){if(u=u||d.operator===">"||d.operator===">=",l=l||d.operator==="<"||d.operator==="<=",s){if(m&&d.semver.prerelease&&d.semver.prerelease.length&&d.semver.major===m.major&&d.semver.minor===m.minor&&d.semver.patch===m.patch&&(m=!1),d.operator===">"||d.operator===">="){if(a=on(s,d,r),a===d&&a!==s)return!1}else if(s.operator===">="&&!Z(s.semver,String(d),r))return!1}if(o){if(f&&d.semver.prerelease&&d.semver.prerelease.length&&d.semver.major===f.major&&d.semver.minor===f.minor&&d.semver.patch===f.patch&&(f=!1),d.operator==="<"||d.operator==="<="){if(c=cn(o,d,r),c===d&&c!==o)return!1}else if(o.operator==="<="&&!Z(o.semver,String(d),r))return!1}if(!d.operator&&(o||s)&&i!==0)return!1}return!(s&&l&&!o&&i!==0||o&&u&&!s&&i!==0||m||f)},on=(e,t,r)=>{if(!e)return t;let n=Ye(e.semver,t.semver,r);return n>0?e:n<0||t.operator===">"&&e.operator===">="?t:e},cn=(e,t,r)=>{if(!e)return t;let n=Ye(e.semver,t.semver,r);return n<0?e:n>0||t.operator==="<"&&e.operator==="<="?t:e};an.exports=ui});var C=w((ll,pn)=>{"use strict";var Je=z(),un=V(),hi=b(),fn=Pe(),di=q(),mi=Ct(),wi=Ut(),Ei=Gt(),gi=_t(),$i=Xt(),yi=Ht(),xi=Jt(),Ri=Kt(),bi=S(),Oi=rr(),vi=sr(),Ii=pe(),Ni=ar(),ki=ur(),Si=B(),Li=he(),Ai=De(),Ti=Ue(),ji=de(),Pi=me(),qi=Fe(),Ci=$r(),Di=H(),Ui=L(),Fi=J(),zi=Pr(),Gi=Cr(),Mi=Ur(),Wi=Gr(),_i=Wr(),Vi=ge(),Xi=Yr(),Bi=Zr(),Hi=en(),Yi=rn(),Ji=ln();pn.exports={parse:di,valid:mi,clean:wi,inc:Ei,diff:gi,major:$i,minor:yi,patch:xi,prerelease:Ri,compare:bi,rcompare:Oi,compareLoose:vi,compareBuild:Ii,sort:Ni,rsort:ki,gt:Si,lt:Li,eq:Ai,neq:Ti,gte:ji,lte:Pi,cmp:qi,coerce:Ci,Comparator:Di,Range:Ui,satisfies:Fi,toComparators:zi,maxSatisfying:Gi,minSatisfying:Mi,minVersion:Wi,validRange:_i,outside:Vi,gtr:Xi,ltr:Bi,intersects:Hi,simplifyRange:Yi,subset:Ji,SemVer:hi,re:Je.re,src:Je.src,tokens:Je.t,SEMVER_SPEC_VERSION:un.SEMVER_SPEC_VERSION,RELEASE_TYPES:un.RELEASE_TYPES,compareIdentifiers:fn.compareIdentifiers,rcompareIdentifiers:fn.rcompareIdentifiers}});var Ae=new TextDecoder;function ie(e){let t=e.indexOf("@",e.startsWith("@")?1:0);return t<0?{name:e,version:""}:{name:e.slice(0,t),version:e.slice(t+1)}}async function yt(e,t){let r=String(t??"").split(/\s+/).filter(o=>o.startsWith("sha512-")).map(o=>o.split("?")[0]);if(r.length===0)throw new Error("The package has no SHA-512 integrity");if(!globalThis.crypto?.subtle)throw new Error("Integrity checks need a secure context (https or localhost)");let n=new Uint8Array(await crypto.subtle.digest("SHA-512",e)),s="sha512-"+btoa(Array.from(n,o=>String.fromCharCode(o)).join(""));if(!r.includes(s))throw new Error(`Integrity check failed: expected ${r[0]}, got ${s}`);return s}async function xt(e,t=268435456){let r=new Blob([e]).stream().pipeThrough(new DecompressionStream("gzip")).getReader(),n=[],s=0;for(let o=await r.read();!o.done;o=await r.read()){if(s+=o.value.length,s>t)throw await r.cancel(),new Error(`The tarball unpacks to more than ${t} bytes`);n.push(o.value)}return new Uint8Array(await new Blob(n).arrayBuffer())}function _(e,t,r){let n=e.subarray(t,t+r),s=n.indexOf(0);return Ae.decode(s<0?n:n.subarray(0,s))}function Rt(e,t,r){if(e[t]&128)return e.subarray(t+1,t+r).reduce((s,o)=>s*256+o,e[t]&127);let n=_(e,t,r).trim();if(!/^[0-7]*$/.test(n))throw new Error("Corrupt tar header");return n===""?0:parseInt(n,8)}function Jn(e){let t=0;for(let r=0;r<512;++r)t+=r>=148&&r<156?32:e[r];if(Rt(e,148,8)!==t)throw new Error("Corrupt tar header checksum")}function Zn(e){let t={},r=0;for(;r0)||r+s>e.length)throw new Error("Corrupt pax header");let o=Ae.decode(e.subarray(n+1,r+s-1)),i=o.indexOf("=");t[o.slice(0,i)]=o.slice(i+1),r+=s}return t}function Kn(e,t){let r=e.subarray(t,t+512);Jn(r);let n=Rt(r,124,12),s=t+512;if(s+n>e.length)throw new Error("Truncated tar archive");return{header:r,type:r[156]===0?"0":String.fromCharCode(r[156]),data:e.subarray(s,s+n),next:s+Math.ceil(n/512)*512}}function Qn(e,t){return t+512>e.length||e.subarray(t,t+512).every(r=>r===0)}function es(e){let t=_(e,0,100),r=_(e,257,5)==="ustar"?_(e,345,155):"";return r?`${r}/${t}`:t}var $t={x:(e,t)=>({...e,pax:Zn(t).path}),L:(e,t)=>({...e,long:_(t,0,t.length)}),g:e=>e};function bt(e){let t=[],r={};for(let n=0;!Qn(e,n);){let{header:s,type:o,data:i,next:a}=Kn(e,n);if(n=a,Object.hasOwn($t,o)){r=$t[o](r,i);continue}(o==="0"||o==="7")&&t.push({path:r.pax??r.long??es(s),bytes:i}),r={}}return t}var xe=F(C(),1);var R=(e,t,...r)=>e.cppFunction(`webfront.developer.${t}`)(...r);async function G(e,t){let r=[],n=0;for(;;){let s=await R(e,"read",t,n);if(r.push(s),n+=s.length,s.length<262144)break;if(n>256*1024*1024)throw new Error("Project file is too large")}return new Uint8Array(await new Blob(r).arrayBuffer())}async function K(e,{id:t,path:r,bytes:n},s){for(let o=0;o{}),a}}async function Zi(e,t){let r=[],n=0;for(;;){let{done:s,value:o}=await e.read();if(s)return r;if(n+=o.length,n>t)throw new Error("Compressed download exceeds its byte limit");r.push(o)}}async function Ki(e,t){try{return await Zi(e,t)}catch(r){throw await e.cancel().catch(()=>{}),r}finally{e.releaseLock()}}async function hn(e,t=64*1024*1024){if(!e.ok)throw new Error(`Download: HTTP ${e.status}`);if(Number(e.headers.get("content-length"))>t)throw new Error("Compressed download exceeds its byte limit");return new Uint8Array(await new Blob(await Ki(e.body.getReader(),t)).arrayBuffer())}var M=".webfront/developer/packages",Qi=/[\\\0:*?"<>|]/,ec=e=>e.split("/").some(t=>!t||t==="."||t==="..");function Ze(e){return typeof e!="string"||!e||Qi.test(e)?!0:ec(e)}function A(e){if(Ze(e))throw new Error(`Unsafe package path: ${e}`);return e}var tc=new TextDecoder,rc=["preinstall","install","postinstall"];async function dn(e){let t=new Map,r;for(let n of bt(await xt(e))){let s=n.path.indexOf("/"),o=n.path.slice(0,s);if(s<1||o==="."||o===".."||(r??(r=o))!==o)throw new Error("Invalid npm tarball root");let i=A(n.path.slice(s+1));if(t.has(i))throw new Error(`Duplicate package path: ${i}`);t.set(i,n.bytes)}return t}var nc=e=>rc.some(t=>e.scripts?.[t]),sc=e=>e.has("binding.gyp")||[...e.keys()].some(t=>t.endsWith(".node"));function oc(e,t){return nc(e)||e.gypfile?!0:sc(t)}function mn(e,t,r){let n=JSON.parse(tc.decode(e.get("package.json")));if(n.name!==t||n.version!==r)throw new Error("npm archive identity mismatch");if(oc(n,e))throw new Error(`${t} needs an unsupported install script or native module`);return n}function W(e){return!e||typeof e!="object"?!1:!Array.isArray(e)}var Ke="webfront.project.json",Qe="webfront-packages.lock.json",x=Ke,N=Qe;function ic(e){if(e===void 0||e==="")return"";if(typeof e!="string"||e.endsWith("/")||Ze(e)||e===".webfront"||e.startsWith(".webfront/"))throw new Error(`Unsafe manifest directory: ${e}`);return e}function xl(e){let t=ic(e);x=t?`${t}/${Ke}`:Ke,N=t?`${t}/${Qe}`:Qe}var ee=1,et=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/,cc=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,ac=/^[0-9A-Za-z.+\-^~<>=*| ]{1,128}$/,wn=/^[A-Za-z0-9][A-Za-z0-9:_.-]{0,63}$/,tt=/^[A-Za-z_][A-Za-z0-9_]*$/,En=["format","name","version","dependencies","registry","scripts","entries","providers","test","permissions"],lc=["files","publish","fetch"],y=e=>{throw new Error(`${x}: ${e}`)};function P(e,t){return W(e)||y(`${t} must be an object`),e}function rt(e,t,r){for(let n of Object.keys(e))t.includes(n)||y(`unknown key "${n}" in ${r}`)}function $e(e,t){typeof e!="string"&&y(`${t} must be a project path`);try{return A(e)}catch{return y(`${t} is not a safe project-relative path: ${e}`)}}function gn(e,t){return(!Array.isArray(e)||e.length>256)&&y(`${t} must be an array of at most 256 paths`),e.map((r,n)=>$e(r,`${t}[${n}]`))}function uc(e){let t=P(e,"dependencies");for(let[r,n]of Object.entries(t))et.test(r)||y(`invalid npm package name "${r}"`),(typeof n!="string"||!ac.test(n)||n!==n.trim())&&y(`invalid version range for "${r}"`);return t}var nt=e=>e.startsWith("/")&&!e.startsWith("//")&&!e.includes("\\");function fc(e){if(typeof e!="string"&&y("registry must be a URL"),nt(e))return e;let t;try{t=new URL(e)}catch{return y("registry must be an https URL or an absolute path")}return t.protocol!=="https:"&&y("registry must use https"),e}function pc(e){let t=P(e,"scripts");for(let[r,n]of Object.entries(t))(!wn.test(r)||typeof n!="string"||!n||n.length>1024)&&y(`invalid script "${r}"`);return t}function hc(e){let t=P(e,"entries");for(let[r,n]of Object.entries(t))wn.test(r)||y(`invalid entry name "${r}"`),$e(n,`entries.${r}`);return t}function dc(e,t){let r=P(e,"providers");for(let[n,s]of Object.entries(r))tt.test(n)||y(`invalid provider name "${n}"`),P(s,`providers.${n}`),rt(s,["entry","output"],`providers.${n}`),typeof s.entry!="string"&&y(`providers.${n}.entry must name an entry or a path`),Object.hasOwn(t,s.entry)||$e(s.entry,`providers.${n}.entry`),$e(s.output,`providers.${n}.output`).endsWith(".hpp")||y(`providers.${n}.output must be a .hpp file`);return r}function mc(e){let t=P(e,"test");return rt(t,["specs"],"test"),t.specs!==void 0&&gn(t.specs,"test.specs"),t}function wc(e,t){let r;try{r=new URL(e)}catch{return y(`${t} must be an https origin`)}return(r.protocol!=="https:"||r.origin!==e)&&y(`${t} must be an https origin without a path`),e}function Ec(e){let t=P(e,"permissions");for(let r of Object.keys(t))lc.includes(r)||y(`unknown permission "${r}"`);for(let r of["files","publish"])t[r]!==void 0&&gn(t[r],`permissions.${r}`);return t.fetch!==void 0&&((!Array.isArray(t.fetch)||t.fetch.length>64)&&y("permissions.fetch must be an array of origins"),t.fetch.forEach((r,n)=>wc(r,`permissions.fetch[${n}]`))),t}function gc(e){(typeof e.name!="string"||!et.test(e.name))&&y("name must be a lower-case npm package name"),(typeof e.version!="string"||!cc.test(e.version))&&y("version must be a semantic version")}function $c(e){e.format!==ee&&(Number.isInteger(e.format)&&e.format>ee&&y(`format ${e.format} is not supported by this environment (it reads format ${ee}); update the environment`),y(`format must be ${ee}`))}function te(e){P(e,"the manifest"),$c(e),rt(e,En,"the manifest"),gc(e);let t=e.entries===void 0?{}:hc(e.entries);return{...e,dependencies:e.dependencies===void 0?{}:uc(e.dependencies),entries:t,providers:e.providers===void 0?{}:dc(e.providers,t),...e.registry===void 0?{}:{registry:fc(e.registry)},...e.scripts===void 0?{}:{scripts:pc(e.scripts)},...e.test===void 0?{}:{test:mc(e.test)},...e.permissions===void 0?{}:{permissions:Ec(e.permissions)}}}function st(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch{return y("not valid JSON")}return{source:t,manifest:te(t)}}function Rl(e){return st(e).manifest}function ot(e){let t={};for(let r of En)e[r]!==void 0&&(t[r]=e[r]);return JSON.stringify(t,null,2)+` -`}function $n(e){return{format:ee,name:e,version:"0.1.0",dependencies:{}}}function yn(e){let r=(String(e??"").split("/").filter(Boolean).pop()??"").toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^[^a-z0-9]+/,"").replace(/-+$/,"");return et.test(r)?r:"webfront-app"}async function ye(e){let t=JSON.stringify(Object.entries(e).sort(([n],[s])=>ns?1:0)),r=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return[...new Uint8Array(r)].map(n=>n.toString(16).padStart(2,"0")).join("")}var it=e=>/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/.test(e),Re=(e,t)=>`${e.replace("/","+")}@${t}`,ct=(e,t,r)=>`${Re(e,t)}-${r.slice(7).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}`;async function yc(e,t,{fetchImpl:r,signal:n}){let s=await r(new URL(e.replace("/","%2f"),t),{signal:n});if(!s.ok)throw new Error(`Registry metadata for ${e}: HTTP ${s.status}`);return s.json()}function xc(e,t){let r=e["dist-tags"]?.[t];return r||(xe.default.valid(t)?t:xe.default.maxSatisfying(Object.keys(e.versions??{}),t))}function Rc(e,t,r){let n=r||"latest",s=xc(e,n),o=e.versions?.[s];if(!o||!xe.default.valid(s))throw new Error(`Cannot resolve ${t}@${n}`);return{version:s,manifest:o}}async function bc(e,t,r,{fetchImpl:n,signal:s}){let o=new URL(t.dist?.tarball,r);if(o.protocol!=="https:"&&o.origin!==r.origin)throw new Error("Package tarballs must use HTTPS or the registry origin");let i=await n(o,{signal:s});if(!i.ok)throw new Error(`Package download for ${e}: HTTP ${i.status}`);let a=await hn(i);return{bytes:a,integrity:await yt(a,t.dist.integrity)}}function at(e){let t=new URL(e,globalThis.location?.href),r=t.origin===globalThis.location?.origin;if(e.startsWith("/")?!nt(e)||!r:t.protocol!=="https:"&&!r)throw new Error(`The npm registry must use HTTPS or the application origin: ${e}`);return t.pathname.endsWith("/")||(t.pathname+="/"),t}async function D(e,t,{registry:r,fetchImpl:n=fetch,signal:s}){if(!it(e))throw new Error(`Unsupported npm package name: ${e}`);let o=at(r),i={fetchImpl:n,signal:s},{version:a,manifest:c}=Rc(await yc(e,o,i),e,t),{bytes:l,integrity:u}=await bc(e,c,o,i),f=await dn(l),m=mn(f,e,a);return{id:Re(e,a),key:ct(e,a,u),manifest:m,integrity:u,files:f}}var be=F(C(),1);function Oc(e,t,r){let n=e?.roots?.[t];return n?.requested===r&&e.packages[n.id]?e.packages[n.id]:be.default.validRange(r)?Object.values(e?.packages??{}).filter(o=>o.name===t&&be.default.satisfies(o.version,r)).sort((o,i)=>be.default.rcompare(o.version,i.version))[0]??null:null}function xn({registry:e="https://registry.npmjs.org/",fetchImpl:t=fetch,signal:r,download:n=D,previous:s}){let o=new Map;return async(i,a)=>{let c=`${i}@${a}`;if(o.has(c))return o.get(c);let l=Oc(s,i,a),u=await n(i,l?.version??a,{registry:e,fetchImpl:t,signal:r});if(l&&u.integrity!==l.integrity)throw new Error(`${u.id} no longer matches the integrity recorded in the lock`);return o.set(c,u),u}}var Rn=F(C(),1),bn=(e,t,r)=>new Error(`${e.name}@${e.version} requires peer ${t}@${r}; install a compatible root explicitly`);function vc(e,t,r){if(e.manifest.peerDependenciesMeta?.[t]?.optional)return null;throw bn(e,t,r)}function Ic(e,[t,r],{nodes:n,roots:s}){let o=s[t]?.id??e.dependencies[t];if(!o)return vc(e,t,r);if(!Rn.default.satisfies(n[o].version,r))throw bn(e,t,r);return o}function Nc(e,t){for(let r of Object.entries(e.manifest.peerDependencies??{})){let n=Ic(e,r,t);n&&(e.dependencies[r[0]]=n)}}function On(e,t){for(let r of Object.values(e))Nc(r,{nodes:e,roots:t})}var vn=F(C(),1);function kc(e,t){return!it(t.name)||!vn.default.valid(t.version)?!1:e===Re(t.name,t.version)}function Sc(e){return e.integrity?.startsWith("sha512-")?e.key===ct(e.name,e.version,e.integrity):!1}function Lc(e,t,r){if(!kc(t,r)||!Sc(r))throw new Error("Invalid locked package");for(let n of r.files)A(n);if(Object.values(r.dependencies).some(n=>!e.packages[n]))throw new Error("Dangling locked dependency")}function Ac(e){return e?.format!==1?!1:!!e.roots&&!!e.packages}function lt(e){if(!Ac(e))throw new Error("Unsupported package lock");if(Object.keys(e.packages).length>512)throw new Error("The package lock exceeds 512 packages");for(let[t,r]of Object.entries(e.packages))Lc(e,t,r);if(Object.values(e.roots).some(t=>!e.packages[t.id]))throw new Error("Dangling locked root");return e}function Tc(e,t,r){if(Object.keys(e.nodes).length>=512)throw new Error("Dependency graph exceeds 512 packages");for(let n of r.files.values())e.total+=n.length;if(e.total>256*1024*1024)throw new Error("Dependency graph exceeds 256 MiB");e.nodes[r.id]={name:t,version:r.manifest.version,integrity:r.integrity,key:r.key,manifest:r.manifest,files:[...r.files.keys()].sort(),dependencies:{}},e.downloads.set(r.id,r.files)}async function jc(e,t){let r={};for(let n of e){let{name:s,version:o}=ie(n);r[s]={requested:o||"latest",id:await t(s,o||"latest")}}return r}async function In(e,t={}){let r=xn(t),n={nodes:{},downloads:new Map,total:0},s=async(i,a)=>{t.signal?.throwIfAborted();let c=await r(i,a);if(n.nodes[c.id])return c.id;Tc(n,i,c);for(let[l,u]of Object.entries(c.manifest.dependencies??{}).sort())n.nodes[c.id].dependencies[l]=await s(l,u);return c.id},o=await jc(e,s);return On(n.nodes,o),{lock:{format:1,registry:t.registry??"https://registry.npmjs.org/",roots:o,packages:n.nodes},downloads:n.downloads}}var ut=F(C(),1);var Pc=new TextDecoder,qc=new TextEncoder,Oe="No webfront.project.json: run wf init",ve="The lock does not match the dependencies of webfront.project.json; run wf install --update to resolve them again";async function Nn(e,t){try{return await G(e,t)}catch(r){if(r.message.includes("Cannot read project file:"))return null;throw r}}function Cc(e,t,r){return t?r===t.requested?!0:ut.default.validRange(r)!==null&&ut.default.satisfies(e.packages[t.id].version,r):!1}function Dc(e,t){let r=Object.keys(t);return r.length===Object.keys(e.roots).length&&r.every(n=>Cc(e,e.roots[n],t[n]))}function Uc(e,t,r){return e?t?t.manifestDigest===void 0?Dc(t,e.dependencies)?"legacy":"desynchronized":t.manifestDigest===r?"consistent":"desynchronized":"unlocked":"no-manifest"}async function re(e){let t=await R(e,"state",`${x} -${N}`),r=await Nn(e,x),n=await Nn(e,N),{source:s,manifest:o}=r?st(r):{source:null,manifest:null},i=n?lt(JSON.parse(Pc.decode(n))):null,a=o?await ye(o.dependencies):null;return{manifest:o,source:s,lock:i,token:t,status:Uc(o,i,a),digest:a}}var Sn=e=>e.status==="desynchronized"?`Warning: ${ve}.\r -`:"";async function Ln(e,t,r,{signal:n}={}){let s=[];try{for(let[o,i]of t){n?.throwIfAborted();let a=await R(e,"begin",o,!1);s.push(a),await K(e,{id:a,path:"output",bytes:i},n)}n?.throwIfAborted(),await R(e,"commitGroup",s.join(` +var Vn=Object.create;var gt=Object.defineProperty;var Xn=Object.getOwnPropertyDescriptor;var Bn=Object.getOwnPropertyNames;var Hn=Object.getPrototypeOf,Kn=Object.prototype.hasOwnProperty;var w=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}};var Yn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Bn(t))!Kn.call(e,s)&&s!==r&>(e,s,{get:()=>t[s],enumerable:!(n=Xn(t,s))||n.enumerable});return e};var F=(e,t,r)=>(r=e!=null?Vn(Hn(e)):{},Yn(t||!e||!e.__esModule?gt(r,"default",{value:e,enumerable:!0}):r,e));var V=w((ba,Ot)=>{"use strict";var rs="2.0.0",ns=Number.MAX_SAFE_INTEGER||9007199254740991,ss=16,os=250,is=["major","premajor","minor","preminor","patch","prepatch","prerelease"];Ot.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:ss,MAX_SAFE_BUILD_LENGTH:os,MAX_SAFE_INTEGER:ns,RELEASE_TYPES:is,SEMVER_SPEC_VERSION:rs,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var X=w((Oa,vt)=>{"use strict";var cs=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};vt.exports=cs});var z=w((j,It)=>{"use strict";var{MAX_SAFE_COMPONENT_LENGTH:je,MAX_SAFE_BUILD_LENGTH:as,MAX_LENGTH:ls}=V(),us=X();j=It.exports={};var fs=j.re=[],ps=j.safeRe=[],p=j.src=[],hs=j.safeSrc=[],h=j.t={},ds=0,Pe="[a-zA-Z0-9-]",ms=[["\\s",1],["\\d",ls],[Pe,as]],ws=e=>{for(let[t,r]of ms)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e},E=(e,t,r)=>{let n=ws(t),s=ds++;us(e,s,t),h[e]=s,p[s]=t,hs[s]=n,fs[s]=new RegExp(t,r?"g":void 0),ps[s]=new RegExp(n,r?"g":void 0)};E("NUMERICIDENTIFIER","0|[1-9]\\d*");E("NUMERICIDENTIFIERLOOSE","\\d+");E("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${Pe}*`);E("MAINVERSION",`(${p[h.NUMERICIDENTIFIER]})\\.(${p[h.NUMERICIDENTIFIER]})\\.(${p[h.NUMERICIDENTIFIER]})`);E("MAINVERSIONLOOSE",`(${p[h.NUMERICIDENTIFIERLOOSE]})\\.(${p[h.NUMERICIDENTIFIERLOOSE]})\\.(${p[h.NUMERICIDENTIFIERLOOSE]})`);E("PRERELEASEIDENTIFIER",`(?:${p[h.NONNUMERICIDENTIFIER]}|${p[h.NUMERICIDENTIFIER]})`);E("PRERELEASEIDENTIFIERLOOSE",`(?:${p[h.NONNUMERICIDENTIFIER]}|${p[h.NUMERICIDENTIFIERLOOSE]})`);E("PRERELEASE",`(?:-(${p[h.PRERELEASEIDENTIFIER]}(?:\\.${p[h.PRERELEASEIDENTIFIER]})*))`);E("PRERELEASELOOSE",`(?:-?(${p[h.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${p[h.PRERELEASEIDENTIFIERLOOSE]})*))`);E("BUILDIDENTIFIER",`${Pe}+`);E("BUILD",`(?:\\+(${p[h.BUILDIDENTIFIER]}(?:\\.${p[h.BUILDIDENTIFIER]})*))`);E("FULLPLAIN",`v?${p[h.MAINVERSION]}${p[h.PRERELEASE]}?${p[h.BUILD]}?`);E("FULL",`^${p[h.FULLPLAIN]}$`);E("LOOSEPLAIN",`[v=\\s]*${p[h.MAINVERSIONLOOSE]}${p[h.PRERELEASELOOSE]}?${p[h.BUILD]}?`);E("LOOSE",`^${p[h.LOOSEPLAIN]}$`);E("GTLT","((?:<|>)?=?)");E("XRANGEIDENTIFIERLOOSE",`${p[h.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);E("XRANGEIDENTIFIER",`${p[h.NUMERICIDENTIFIER]}|x|X|\\*`);E("XRANGEPLAIN",`[v=\\s]*(${p[h.XRANGEIDENTIFIER]})(?:\\.(${p[h.XRANGEIDENTIFIER]})(?:\\.(${p[h.XRANGEIDENTIFIER]})(?:${p[h.PRERELEASE]})?${p[h.BUILD]}?)?)?`);E("XRANGEPLAINLOOSE",`[v=\\s]*(${p[h.XRANGEIDENTIFIERLOOSE]})(?:\\.(${p[h.XRANGEIDENTIFIERLOOSE]})(?:\\.(${p[h.XRANGEIDENTIFIERLOOSE]})(?:${p[h.PRERELEASELOOSE]})?${p[h.BUILD]}?)?)?`);E("XRANGE",`^${p[h.GTLT]}\\s*${p[h.XRANGEPLAIN]}$`);E("XRANGELOOSE",`^${p[h.GTLT]}\\s*${p[h.XRANGEPLAINLOOSE]}$`);E("COERCEPLAIN",`(^|[^\\d])(\\d{1,${je}})(?:\\.(\\d{1,${je}}))?(?:\\.(\\d{1,${je}}))?`);E("COERCE",`${p[h.COERCEPLAIN]}(?:$|[^\\d])`);E("COERCEFULL",p[h.COERCEPLAIN]+`(?:${p[h.PRERELEASE]})?(?:${p[h.BUILD]})?(?:$|[^\\d])`);E("COERCERTL",p[h.COERCE],!0);E("COERCERTLFULL",p[h.COERCEFULL],!0);E("LONETILDE","(?:~>?)");E("TILDETRIM",`(\\s*)${p[h.LONETILDE]}\\s+`,!0);j.tildeTrimReplace="$1~";E("TILDE",`^${p[h.LONETILDE]}${p[h.XRANGEPLAIN]}$`);E("TILDELOOSE",`^${p[h.LONETILDE]}${p[h.XRANGEPLAINLOOSE]}$`);E("LONECARET","(?:\\^)");E("CARETTRIM",`(\\s*)${p[h.LONECARET]}\\s+`,!0);j.caretTrimReplace="$1^";E("CARET",`^${p[h.LONECARET]}${p[h.XRANGEPLAIN]}$`);E("CARETLOOSE",`^${p[h.LONECARET]}${p[h.XRANGEPLAINLOOSE]}$`);E("COMPARATORLOOSE",`^${p[h.GTLT]}\\s*(${p[h.LOOSEPLAIN]})$|^$`);E("COMPARATOR",`^${p[h.GTLT]}\\s*(${p[h.FULLPLAIN]})$|^$`);E("COMPARATORTRIM",`(\\s*)${p[h.GTLT]}\\s*(${p[h.LOOSEPLAIN]}|${p[h.XRANGEPLAIN]})`,!0);j.comparatorTrimReplace="$1$2$3";E("HYPHENRANGE",`^\\s*(${p[h.XRANGEPLAIN]})\\s+-\\s+(${p[h.XRANGEPLAIN]})\\s*$`);E("HYPHENRANGELOOSE",`^\\s*(${p[h.XRANGEPLAINLOOSE]})\\s+-\\s+(${p[h.XRANGEPLAINLOOSE]})\\s*$`);E("STAR","(<|>)?=?\\s*\\*");E("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");E("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var ce=w((va,St)=>{"use strict";var Es=Object.freeze({loose:!0}),gs=Object.freeze({}),$s=e=>e?typeof e!="object"?Es:e:gs;St.exports=$s});var qe=w((Ia,Lt)=>{"use strict";var kt=/^[0-9]+$/,Nt=(e,t)=>{if(typeof e=="number"&&typeof t=="number")return e===t?0:eNt(t,e);Lt.exports={compareIdentifiers:Nt,rcompareIdentifiers:ys}});var b=w((Sa,Tt)=>{"use strict";var ae=X(),{MAX_LENGTH:At,MAX_SAFE_INTEGER:le}=V(),{safeRe:ue,t:fe}=z(),xs=ce(),{compareIdentifiers:Ce}=qe(),De=class e{constructor(t,r){if(r=xs(r),t instanceof e){if(t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>At)throw new TypeError(`version is longer than ${At} characters`);ae("SemVer",t,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let n=t.trim().match(r.loose?ue[fe.LOOSE]:ue[fe.FULL]);if(!n)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>le||this.major<0)throw new TypeError("Invalid major version");if(this.minor>le||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>le||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(s=>{if(/^[0-9]+$/.test(s)){let o=+s;if(o>=0&&ot.major?1:this.minort.minor?1:this.patcht.patch?1:0}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let n=this.prerelease[r],s=t.prerelease[r];if(ae("prerelease compare",r,n,s),n===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(n===void 0)return-1;if(n===s)continue;return Ce(n,s)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let n=this.build[r],s=t.build[r];if(ae("build compare",r,n,s),n===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(n===void 0)return-1;if(n===s)continue;return Ce(n,s)}while(++r)}inc(t,r,n){if(t.startsWith("pre")){if(!r&&n===!1)throw new Error("invalid increment argument: identifier is empty");if(r){let s=`-${r}`.match(this.options.loose?ue[fe.PRERELEASELOOSE]:ue[fe.PRERELEASE]);if(!s||s[1]!==r)throw new Error(`invalid identifier: ${r}`)}}switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r,n);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r,n);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r,n),this.inc("pre",r,n);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",r,n),this.inc("pre",r,n);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{let s=Number(n)?1:0;if(this.prerelease.length===0)this.prerelease=[s];else{let o=this.prerelease.length;for(;--o>=0;)typeof this.prerelease[o]=="number"&&(this.prerelease[o]++,o=-2);if(o===-1){if(r===this.prerelease.join(".")&&n===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(s)}}if(r){let o=[r,s];n===!1&&(o=[r]),Ce(this.prerelease[0],r)===0?isNaN(this.prerelease[1])&&(this.prerelease=o):this.prerelease=o}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};Tt.exports=De});var q=w((ka,Pt)=>{"use strict";var jt=b(),Rs=(e,t,r=!1)=>{if(e instanceof jt)return e;try{return new jt(e,t)}catch(n){if(!r)return null;throw n}};Pt.exports=Rs});var Ct=w((Na,qt)=>{"use strict";var bs=q(),Os=(e,t)=>{let r=bs(e,t);return r?r.version:null};qt.exports=Os});var Ut=w((La,Dt)=>{"use strict";var vs=q(),Is=(e,t)=>{let r=vs(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null};Dt.exports=Is});var Gt=w((Aa,zt)=>{"use strict";var Ft=b(),Ss=(e,t,r,n,s)=>{typeof r=="string"&&(s=n,n=r,r=void 0);try{return new Ft(e instanceof Ft?e.version:e,r).inc(t,n,s).version}catch{return null}};zt.exports=Ss});var _t=w((Ta,Wt)=>{"use strict";var Mt=q(),ks=(e,t)=>{let r=Mt(e,null,!0),n=Mt(t,null,!0),s=r.compare(n);if(s===0)return null;let o=s>0,i=o?r:n,a=o?n:r,c=!!i.prerelease.length;if(!!a.prerelease.length&&!c){if(!a.patch&&!a.minor)return"major";if(a.compareMain(i)===0)return a.minor&&!a.patch?"minor":"patch"}let u=c?"pre":"";return r.major!==n.major?u+"major":r.minor!==n.minor?u+"minor":r.patch!==n.patch?u+"patch":"prerelease"};Wt.exports=ks});var Xt=w((ja,Vt)=>{"use strict";var Ns=b(),Ls=(e,t)=>new Ns(e,t).major;Vt.exports=Ls});var Ht=w((Pa,Bt)=>{"use strict";var As=b(),Ts=(e,t)=>new As(e,t).minor;Bt.exports=Ts});var Yt=w((qa,Kt)=>{"use strict";var js=b(),Ps=(e,t)=>new js(e,t).patch;Kt.exports=Ps});var Zt=w((Ca,Jt)=>{"use strict";var qs=q(),Cs=(e,t)=>{let r=qs(e,t);return r&&r.prerelease.length?r.prerelease:null};Jt.exports=Cs});var N=w((Da,er)=>{"use strict";var Qt=b(),Ds=(e,t,r)=>new Qt(e,r).compare(new Qt(t,r));er.exports=Ds});var rr=w((Ua,tr)=>{"use strict";var Us=N(),Fs=(e,t,r)=>Us(t,e,r);tr.exports=Fs});var sr=w((Fa,nr)=>{"use strict";var zs=N(),Gs=(e,t)=>zs(e,t,!0);nr.exports=Gs});var pe=w((za,ir)=>{"use strict";var or=b(),Ms=(e,t,r)=>{let n=new or(e,r),s=new or(t,r);return n.compare(s)||n.compareBuild(s)};ir.exports=Ms});var ar=w((Ga,cr)=>{"use strict";var Ws=pe(),_s=(e,t)=>e.sort((r,n)=>Ws(r,n,t));cr.exports=_s});var ur=w((Ma,lr)=>{"use strict";var Vs=pe(),Xs=(e,t)=>e.sort((r,n)=>Vs(n,r,t));lr.exports=Xs});var B=w((Wa,fr)=>{"use strict";var Bs=N(),Hs=(e,t,r)=>Bs(e,t,r)>0;fr.exports=Hs});var he=w((_a,pr)=>{"use strict";var Ks=N(),Ys=(e,t,r)=>Ks(e,t,r)<0;pr.exports=Ys});var Ue=w((Va,hr)=>{"use strict";var Js=N(),Zs=(e,t,r)=>Js(e,t,r)===0;hr.exports=Zs});var Fe=w((Xa,dr)=>{"use strict";var Qs=N(),eo=(e,t,r)=>Qs(e,t,r)!==0;dr.exports=eo});var de=w((Ba,mr)=>{"use strict";var to=N(),ro=(e,t,r)=>to(e,t,r)>=0;mr.exports=ro});var me=w((Ha,wr)=>{"use strict";var no=N(),so=(e,t,r)=>no(e,t,r)<=0;wr.exports=so});var ze=w((Ka,Er)=>{"use strict";var oo=Ue(),io=Fe(),co=B(),ao=de(),lo=he(),uo=me(),fo=(e,t,r,n)=>{switch(t){case"===":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e===r;case"!==":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e!==r;case"":case"=":case"==":return oo(e,r,n);case"!=":return io(e,r,n);case">":return co(e,r,n);case">=":return ao(e,r,n);case"<":return lo(e,r,n);case"<=":return uo(e,r,n);default:throw new TypeError(`Invalid operator: ${t}`)}};Er.exports=fo});var $r=w((Ya,gr)=>{"use strict";var po=b(),ho=q(),{safeRe:we,t:Ee}=z(),mo=(e,t)=>{if(e instanceof po)return e;if(typeof e=="number"&&(e=String(e)),typeof e!="string")return null;t=t||{};let r=null;if(!t.rtl)r=e.match(t.includePrerelease?we[Ee.COERCEFULL]:we[Ee.COERCE]);else{let c=t.includePrerelease?we[Ee.COERCERTLFULL]:we[Ee.COERCERTL],l;for(;(l=c.exec(e))&&(!r||r.index+r[0].length!==e.length);)(!r||l.index+l[0].length!==r.index+r[0].length)&&(r=l),c.lastIndex=l.index+l[1].length+l[2].length;c.lastIndex=-1}if(r===null)return null;let n=r[2],s=r[3]||"0",o=r[4]||"0",i=t.includePrerelease&&r[5]?`-${r[5]}`:"",a=t.includePrerelease&&r[6]?`+${r[6]}`:"";return ho(`${n}.${s}.${o}${i}${a}`,t)};gr.exports=mo});var xr=w((Ja,yr)=>{"use strict";var Ge=class{constructor(){this.max=1e3,this.map=new Map}get(t){let r=this.map.get(t);if(r!==void 0)return this.map.delete(t),this.map.set(t,r),r}delete(t){return this.map.delete(t)}set(t,r){if(!this.delete(t)&&r!==void 0){if(this.map.size>=this.max){let s=this.map.keys().next().value;this.delete(s)}this.map.set(t,r)}return this}};yr.exports=Ge});var L=w((Za,vr)=>{"use strict";var wo=/\s+/g,Me=class e{constructor(t,r){if(r=go(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof We)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(wo," "),this.set=this.raw.split("||").map(n=>this.parseRange(n.trim())).filter(n=>n.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let n=this.set[0];if(this.set=this.set.filter(s=>!br(s[0])),this.set.length===0)this.set=[n];else if(this.set.length>1){for(let s of this.set)if(s.length===1&&vo(s[0])){this.set=[s];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let t=0;t0&&(this.formatted+="||");let r=this.set[t];for(let n=0;n0&&(this.formatted+=" "),this.formatted+=r[n].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(t){let n=((this.options.includePrerelease&&bo)|(this.options.loose&&Oo))+":"+t,s=Rr.get(n);if(s)return s;let o=this.options.loose,i=o?v[O.HYPHENRANGELOOSE]:v[O.HYPHENRANGE];t=t.replace(i,qo(this.options.includePrerelease)),g("hyphen replace",t),t=t.replace(v[O.COMPARATORTRIM],yo),g("comparator trim",t),t=t.replace(v[O.TILDETRIM],xo),g("tilde trim",t),t=t.replace(v[O.CARETTRIM],Ro),g("caret trim",t);let a=t.split(" ").map(f=>Io(f,this.options)).join(" ").split(/\s+/).map(f=>Po(f,this.options));o&&(a=a.filter(f=>(g("loose invalid filter",f,this.options),!!f.match(v[O.COMPARATORLOOSE])))),g("range list",a);let c=new Map,l=a.map(f=>new We(f,this.options));for(let f of l){if(br(f))return[f];c.set(f.value,f)}c.size>1&&c.has("")&&c.delete("");let u=[...c.values()];return Rr.set(n,u),u}intersects(t,r){if(!(t instanceof e))throw new TypeError("a Range is required");return this.set.some(n=>Or(n,r)&&t.set.some(s=>Or(s,r)&&n.every(o=>s.every(i=>o.intersects(i,r)))))}test(t){if(!t)return!1;if(typeof t=="string")try{t=new $o(t,this.options)}catch{return!1}for(let r=0;re.value==="<0.0.0-0",vo=e=>e.value==="",Or=(e,t)=>{let r=!0,n=e.slice(),s=n.pop();for(;r&&n.length;)r=n.every(o=>s.intersects(o,t)),s=n.pop();return r},Io=(e,t)=>(e=e.replace(v[O.BUILD],""),g("comp",e,t),e=No(e,t),g("caret",e),e=So(e,t),g("tildes",e),e=Ao(e,t),g("xrange",e),e=jo(e,t),g("stars",e),e),I=e=>!e||e.toLowerCase()==="x"||e==="*",So=(e,t)=>e.trim().split(/\s+/).map(r=>ko(r,t)).join(" "),ko=(e,t)=>{let r=t.loose?v[O.TILDELOOSE]:v[O.TILDE];return e.replace(r,(n,s,o,i,a)=>{g("tilde",e,n,s,o,i,a);let c;return I(s)?c="":I(o)?c=`>=${s}.0.0 <${+s+1}.0.0-0`:I(i)?c=`>=${s}.${o}.0 <${s}.${+o+1}.0-0`:a?(g("replaceTilde pr",a),c=`>=${s}.${o}.${i}-${a} <${s}.${+o+1}.0-0`):c=`>=${s}.${o}.${i} <${s}.${+o+1}.0-0`,g("tilde return",c),c})},No=(e,t)=>e.trim().split(/\s+/).map(r=>Lo(r,t)).join(" "),Lo=(e,t)=>{g("caret",e,t);let r=t.loose?v[O.CARETLOOSE]:v[O.CARET],n=t.includePrerelease?"-0":"";return e.replace(r,(s,o,i,a,c)=>{g("caret",e,s,o,i,a,c);let l;return I(o)?l="":I(i)?l=`>=${o}.0.0${n} <${+o+1}.0.0-0`:I(a)?o==="0"?l=`>=${o}.${i}.0${n} <${o}.${+i+1}.0-0`:l=`>=${o}.${i}.0${n} <${+o+1}.0.0-0`:c?(g("replaceCaret pr",c),o==="0"?i==="0"?l=`>=${o}.${i}.${a}-${c} <${o}.${i}.${+a+1}-0`:l=`>=${o}.${i}.${a}-${c} <${o}.${+i+1}.0-0`:l=`>=${o}.${i}.${a}-${c} <${+o+1}.0.0-0`):(g("no pr"),o==="0"?i==="0"?l=`>=${o}.${i}.${a}${n} <${o}.${i}.${+a+1}-0`:l=`>=${o}.${i}.${a}${n} <${o}.${+i+1}.0-0`:l=`>=${o}.${i}.${a} <${+o+1}.0.0-0`),g("caret return",l),l})},Ao=(e,t)=>(g("replaceXRanges",e,t),e.split(/\s+/).map(r=>To(r,t)).join(" ")),To=(e,t)=>{e=e.trim();let r=t.loose?v[O.XRANGELOOSE]:v[O.XRANGE];return e.replace(r,(n,s,o,i,a,c)=>{g("xRange",e,n,s,o,i,a,c);let l=I(o),u=l||I(i),f=u||I(a),m=f;return s==="="&&m&&(s=""),c=t.includePrerelease?"-0":"",l?s===">"||s==="<"?n="<0.0.0-0":n="*":s&&m?(u&&(i=0),a=0,s===">"?(s=">=",u?(o=+o+1,i=0,a=0):(i=+i+1,a=0)):s==="<="&&(s="<",u?o=+o+1:i=+i+1),s==="<"&&(c="-0"),n=`${s+o}.${i}.${a}${c}`):u?n=`>=${o}.0.0${c} <${+o+1}.0.0-0`:f&&(n=`>=${o}.${i}.0${c} <${o}.${+i+1}.0-0`),g("xRange return",n),n})},jo=(e,t)=>(g("replaceStars",e,t),e.trim().replace(v[O.STAR],"")),Po=(e,t)=>(g("replaceGTE0",e,t),e.trim().replace(v[t.includePrerelease?O.GTE0PRE:O.GTE0],"")),qo=e=>(t,r,n,s,o,i,a,c,l,u,f,m)=>(I(n)?r="":I(s)?r=`>=${n}.0.0${e?"-0":""}`:I(o)?r=`>=${n}.${s}.0${e?"-0":""}`:i?r=`>=${r}`:r=`>=${r}${e?"-0":""}`,I(l)?c="":I(u)?c=`<${+l+1}.0.0-0`:I(f)?c=`<${l}.${+u+1}.0-0`:m?c=`<=${l}.${u}.${f}-${m}`:e?c=`<${l}.${u}.${+f+1}-0`:c=`<=${c}`,`${r} ${c}`.trim()),Co=(e,t,r)=>{for(let n=0;n0){let s=e[n].semver;if(s.major===t.major&&s.minor===t.minor&&s.patch===t.patch)return!0}return!1}return!0}});var H=w((Qa,Ar)=>{"use strict";var K=Symbol("SemVer ANY"),Xe=class e{static get ANY(){return K}constructor(t,r){if(r=Ir(r),t instanceof e){if(t.loose===!!r.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(" "),Ve("comparator",t,r),this.options=r,this.loose=!!r.loose,this.parse(t),this.semver===K?this.value="":this.value=this.operator+this.semver.version,Ve("comp",this)}parse(t){let r=this.options.loose?Sr[kr.COMPARATORLOOSE]:Sr[kr.COMPARATOR],n=t.match(r);if(!n)throw new TypeError(`Invalid comparator: ${t}`);this.operator=n[1]!==void 0?n[1]:"",this.operator==="="&&(this.operator=""),n[2]?this.semver=new Nr(n[2],this.options.loose):this.semver=K}toString(){return this.value}test(t){if(Ve("Comparator.test",t,this.options.loose),this.semver===K||t===K)return!0;if(typeof t=="string")try{t=new Nr(t,this.options)}catch{return!1}return _e(t,this.operator,this.semver,this.options)}intersects(t,r){if(!(t instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new Lr(t.value,r).test(this.value):t.operator===""?t.value===""?!0:new Lr(this.value,r).test(t.semver):(r=Ir(r),r.includePrerelease&&(this.value==="<0.0.0-0"||t.value==="<0.0.0-0")||!r.includePrerelease&&(this.value.startsWith("<0.0.0")||t.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&t.operator.startsWith(">")||this.operator.startsWith("<")&&t.operator.startsWith("<")||this.semver.version===t.semver.version&&this.operator.includes("=")&&t.operator.includes("=")||_e(this.semver,"<",t.semver,r)&&this.operator.startsWith(">")&&t.operator.startsWith("<")||_e(this.semver,">",t.semver,r)&&this.operator.startsWith("<")&&t.operator.startsWith(">")))}};Ar.exports=Xe;var Ir=ce(),{safeRe:Sr,t:kr}=z(),_e=ze(),Ve=X(),Nr=b(),Lr=L()});var Y=w((el,Tr)=>{"use strict";var Do=L(),Uo=(e,t,r)=>{try{t=new Do(t,r)}catch{return!1}return t.test(e)};Tr.exports=Uo});var Pr=w((tl,jr)=>{"use strict";var Fo=L(),zo=(e,t)=>new Fo(e,t).set.map(r=>r.map(n=>n.value).join(" ").trim().split(" "));jr.exports=zo});var Cr=w((rl,qr)=>{"use strict";var Go=b(),Mo=L(),Wo=(e,t,r)=>{let n=null,s=null,o=null;try{o=new Mo(t,r)}catch{return null}return e.forEach(i=>{o.test(i)&&(!n||s.compare(i)===-1)&&(n=i,s=new Go(n,r))}),n};qr.exports=Wo});var Ur=w((nl,Dr)=>{"use strict";var _o=b(),Vo=L(),Xo=(e,t,r)=>{let n=null,s=null,o=null;try{o=new Vo(t,r)}catch{return null}return e.forEach(i=>{o.test(i)&&(!n||s.compare(i)===1)&&(n=i,s=new _o(n,r))}),n};Dr.exports=Xo});var Gr=w((sl,zr)=>{"use strict";var Be=b(),Bo=L(),Fr=B(),Ho=(e,t)=>{e=new Bo(e,t);let r=new Be("0.0.0");if(e.test(r)||(r=new Be("0.0.0-0"),e.test(r)))return r;r=null;for(let n=0;n{let a=new Be(i.semver.version);switch(i.operator){case">":a.prerelease.length===0?a.patch++:a.prerelease.push(0),a.raw=a.format();case"":case">=":(!o||Fr(a,o))&&(o=a);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${i.operator}`)}}),o&&(!r||Fr(r,o))&&(r=o)}return r&&e.test(r)?r:null};zr.exports=Ho});var Wr=w((ol,Mr)=>{"use strict";var Ko=L(),Yo=(e,t)=>{try{return new Ko(e,t).range||"*"}catch{return null}};Mr.exports=Yo});var ge=w((il,Br)=>{"use strict";var Jo=b(),Xr=H(),{ANY:Zo}=Xr,Qo=L(),ei=Y(),_r=B(),Vr=he(),ti=me(),ri=de(),ni=(e,t,r,n)=>{e=new Jo(e,n),t=new Qo(t,n);let s,o,i,a,c;switch(r){case">":s=_r,o=ti,i=Vr,a=">",c=">=";break;case"<":s=Vr,o=ri,i=_r,a="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(ei(e,t,n))return!1;for(let l=0;l{d.semver===Zo&&(d=new Xr(">=0.0.0")),f=f||d,m=m||d,s(d.semver,f.semver,n)?f=d:i(d.semver,m.semver,n)&&(m=d)}),f.operator===a||f.operator===c||(!m.operator||m.operator===a)&&o(e,m.semver))return!1;if(m.operator===c&&i(e,m.semver))return!1}return!0};Br.exports=ni});var Kr=w((cl,Hr)=>{"use strict";var si=ge(),oi=(e,t,r)=>si(e,t,">",r);Hr.exports=oi});var Jr=w((al,Yr)=>{"use strict";var ii=ge(),ci=(e,t,r)=>ii(e,t,"<",r);Yr.exports=ci});var en=w((ll,Qr)=>{"use strict";var Zr=L(),ai=(e,t,r)=>(e=new Zr(e,r),t=new Zr(t,r),e.intersects(t,r));Qr.exports=ai});var rn=w((ul,tn)=>{"use strict";var li=Y(),ui=N();tn.exports=(e,t,r)=>{let n=[],s=null,o=null,i=e.sort((u,f)=>ui(u,f,r));for(let u of i)li(u,t,r)?(o=u,s||(s=u)):(o&&n.push([s,o]),o=null,s=null);s&&n.push([s,null]);let a=[];for(let[u,f]of n)u===f?a.push(u):!f&&u===i[0]?a.push("*"):f?u===i[0]?a.push(`<=${f}`):a.push(`${u} - ${f}`):a.push(`>=${u}`);let c=a.join(" || "),l=typeof t.raw=="string"?t.raw:String(t);return c.length{"use strict";var nn=L(),Ke=H(),{ANY:He}=Ke,J=Y(),Ye=N(),fi=(e,t,r={})=>{if(e===t)return!0;e=new nn(e,r),t=new nn(t,r);let n=!1;e:for(let s of e.set){for(let o of t.set){let i=hi(s,o,r);if(n=n||i!==null,i)continue e}if(n)return!1}return!0},pi=[new Ke(">=0.0.0-0")],sn=[new Ke(">=0.0.0")],hi=(e,t,r)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===He){if(t.length===1&&t[0].semver===He)return!0;r.includePrerelease?e=pi:e=sn}if(t.length===1&&t[0].semver===He){if(r.includePrerelease)return!0;t=sn}let n=new Set,s,o;for(let d of e)d.operator===">"||d.operator===">="?s=on(s,d,r):d.operator==="<"||d.operator==="<="?o=cn(o,d,r):n.add(d.semver);if(n.size>1)return null;let i;if(s&&o){if(i=Ye(s.semver,o.semver,r),i>0)return null;if(i===0&&(s.operator!==">="||o.operator!=="<="))return null}for(let d of n){if(s&&!J(d,String(s),r)||o&&!J(d,String(o),r))return null;for(let T of t)if(!J(d,String(T),r))return!1;return!0}let a,c,l,u,f=o&&!r.includePrerelease&&o.semver.prerelease.length?o.semver:!1,m=s&&!r.includePrerelease&&s.semver.prerelease.length?s.semver:!1;f&&f.prerelease.length===1&&o.operator==="<"&&f.prerelease[0]===0&&(f=!1);for(let d of t){if(u=u||d.operator===">"||d.operator===">=",l=l||d.operator==="<"||d.operator==="<=",s){if(m&&d.semver.prerelease&&d.semver.prerelease.length&&d.semver.major===m.major&&d.semver.minor===m.minor&&d.semver.patch===m.patch&&(m=!1),d.operator===">"||d.operator===">="){if(a=on(s,d,r),a===d&&a!==s)return!1}else if(s.operator===">="&&!J(s.semver,String(d),r))return!1}if(o){if(f&&d.semver.prerelease&&d.semver.prerelease.length&&d.semver.major===f.major&&d.semver.minor===f.minor&&d.semver.patch===f.patch&&(f=!1),d.operator==="<"||d.operator==="<="){if(c=cn(o,d,r),c===d&&c!==o)return!1}else if(o.operator==="<="&&!J(o.semver,String(d),r))return!1}if(!d.operator&&(o||s)&&i!==0)return!1}return!(s&&l&&!o&&i!==0||o&&u&&!s&&i!==0||m||f)},on=(e,t,r)=>{if(!e)return t;let n=Ye(e.semver,t.semver,r);return n>0?e:n<0||t.operator===">"&&e.operator===">="?t:e},cn=(e,t,r)=>{if(!e)return t;let n=Ye(e.semver,t.semver,r);return n<0?e:n>0||t.operator==="<"&&e.operator==="<="?t:e};an.exports=fi});var C=w((pl,pn)=>{"use strict";var Je=z(),un=V(),di=b(),fn=qe(),mi=q(),wi=Ct(),Ei=Ut(),gi=Gt(),$i=_t(),yi=Xt(),xi=Ht(),Ri=Yt(),bi=Zt(),Oi=N(),vi=rr(),Ii=sr(),Si=pe(),ki=ar(),Ni=ur(),Li=B(),Ai=he(),Ti=Ue(),ji=Fe(),Pi=de(),qi=me(),Ci=ze(),Di=$r(),Ui=H(),Fi=L(),zi=Y(),Gi=Pr(),Mi=Cr(),Wi=Ur(),_i=Gr(),Vi=Wr(),Xi=ge(),Bi=Kr(),Hi=Jr(),Ki=en(),Yi=rn(),Ji=ln();pn.exports={parse:mi,valid:wi,clean:Ei,inc:gi,diff:$i,major:yi,minor:xi,patch:Ri,prerelease:bi,compare:Oi,rcompare:vi,compareLoose:Ii,compareBuild:Si,sort:ki,rsort:Ni,gt:Li,lt:Ai,eq:Ti,neq:ji,gte:Pi,lte:qi,cmp:Ci,coerce:Di,Comparator:Ui,Range:Fi,satisfies:zi,toComparators:Gi,maxSatisfying:Mi,minSatisfying:Wi,minVersion:_i,validRange:Vi,outside:Xi,gtr:Bi,ltr:Hi,intersects:Ki,simplifyRange:Yi,subset:Ji,SemVer:di,re:Je.re,src:Je.src,tokens:Je.t,SEMVER_SPEC_VERSION:un.SEMVER_SPEC_VERSION,RELEASE_TYPES:un.RELEASE_TYPES,compareIdentifiers:fn.compareIdentifiers,rcompareIdentifiers:fn.rcompareIdentifiers}});var Te=new TextDecoder;function ie(e){let t=e.indexOf("@",e.startsWith("@")?1:0);return t<0?{name:e,version:""}:{name:e.slice(0,t),version:e.slice(t+1)}}async function yt(e,t){let r=String(t??"").split(/\s+/).filter(o=>o.startsWith("sha512-")).map(o=>o.split("?")[0]);if(r.length===0)throw new Error("The package has no SHA-512 integrity");if(!globalThis.crypto?.subtle)throw new Error("Integrity checks need a secure context (https or localhost)");let n=new Uint8Array(await crypto.subtle.digest("SHA-512",e)),s="sha512-"+btoa(Array.from(n,o=>String.fromCharCode(o)).join(""));if(!r.includes(s))throw new Error(`Integrity check failed: expected ${r[0]}, got ${s}`);return s}async function xt(e,t=268435456){let r=new Blob([e]).stream().pipeThrough(new DecompressionStream("gzip")).getReader(),n=[],s=0;for(let o=await r.read();!o.done;o=await r.read()){if(s+=o.value.length,s>t)throw await r.cancel(),new Error(`The tarball unpacks to more than ${t} bytes`);n.push(o.value)}return new Uint8Array(await new Blob(n).arrayBuffer())}function _(e,t,r){let n=e.subarray(t,t+r),s=n.indexOf(0);return Te.decode(s<0?n:n.subarray(0,s))}function Rt(e,t,r){if(e[t]&128)return e.subarray(t+1,t+r).reduce((s,o)=>s*256+o,e[t]&127);let n=_(e,t,r).trim();if(!/^[0-7]*$/.test(n))throw new Error("Corrupt tar header");return n===""?0:parseInt(n,8)}function Jn(e){let t=0;for(let r=0;r<512;++r)t+=r>=148&&r<156?32:e[r];if(Rt(e,148,8)!==t)throw new Error("Corrupt tar header checksum")}function Zn(e){let t={},r=0;for(;r0)||r+s>e.length)throw new Error("Corrupt pax header");let o=Te.decode(e.subarray(n+1,r+s-1)),i=o.indexOf("=");t[o.slice(0,i)]=o.slice(i+1),r+=s}return t}function Qn(e,t){let r=e.subarray(t,t+512);Jn(r);let n=Rt(r,124,12),s=t+512;if(s+n>e.length)throw new Error("Truncated tar archive");return{header:r,type:r[156]===0?"0":String.fromCharCode(r[156]),data:e.subarray(s,s+n),next:s+Math.ceil(n/512)*512}}function es(e,t){return t+512>e.length||e.subarray(t,t+512).every(r=>r===0)}function ts(e){let t=_(e,0,100),r=_(e,257,5)==="ustar"?_(e,345,155):"";return r?`${r}/${t}`:t}var $t={x:(e,t)=>({...e,pax:Zn(t).path}),L:(e,t)=>({...e,long:_(t,0,t.length)}),g:e=>e};function bt(e){let t=[],r={};for(let n=0;!es(e,n);){let{header:s,type:o,data:i,next:a}=Qn(e,n);if(n=a,Object.hasOwn($t,o)){r=$t[o](r,i);continue}(o==="0"||o==="7")&&t.push({path:r.pax??r.long??ts(s),bytes:i}),r={}}return t}var Re=F(C(),1);var R=(e,t,...r)=>e.cppFunction(`webfront.developer.${t}`)(...r);async function G(e,t){let r=[],n=0;for(;;){let s=await R(e,"read",t,n);if(r.push(s),n+=s.length,s.length<262144)break;if(n>256*1024*1024)throw new Error("Project file is too large")}return new Uint8Array(await new Blob(r).arrayBuffer())}async function Z(e,{id:t,path:r,bytes:n},s){for(let o=0;o{}),a}}async function Zi(e,t){let r=[],n=0;for(;;){let{done:s,value:o}=await e.read();if(s)return r;if(n+=o.length,n>t)throw new Error("Compressed download exceeds its byte limit");r.push(o)}}async function Qi(e,t){try{return await Zi(e,t)}catch(r){throw await e.cancel().catch(()=>{}),r}finally{e.releaseLock()}}async function hn(e,t=64*1024*1024){if(!e.ok)throw new Error(`Download: HTTP ${e.status}`);if(Number(e.headers.get("content-length"))>t)throw new Error("Compressed download exceeds its byte limit");return new Uint8Array(await new Blob(await Qi(e.body.getReader(),t)).arrayBuffer())}var M=".webfront/developer/packages",ec=/[\\\0:*?"<>|]/,tc=e=>e.split("/").some(t=>!t||t==="."||t==="..");function Ze(e){return typeof e!="string"||!e||ec.test(e)?!0:tc(e)}function A(e){if(Ze(e))throw new Error(`Unsafe package path: ${e}`);return e}var rc=new TextDecoder,nc=["preinstall","install","postinstall"];async function dn(e){let t=new Map,r;for(let n of bt(await xt(e))){let s=n.path.indexOf("/"),o=n.path.slice(0,s);if(s<1||o==="."||o===".."||(r??(r=o))!==o)throw new Error("Invalid npm tarball root");let i=A(n.path.slice(s+1));if(t.has(i))throw new Error(`Duplicate package path: ${i}`);t.set(i,n.bytes)}return t}var sc=e=>nc.some(t=>e.scripts?.[t]),oc=e=>e.has("binding.gyp")||[...e.keys()].some(t=>t.endsWith(".node"));function ic(e,t){return sc(e)||e.gypfile?!0:oc(t)}function mn(e,t,r){let n=JSON.parse(rc.decode(e.get("package.json")));if(n.name!==t||n.version!==r)throw new Error("npm archive identity mismatch");if(ic(n,e))throw new Error(`${t} needs an unsupported install script or native module`);return n}function W(e){return!e||typeof e!="object"?!1:!Array.isArray(e)}var Qe="webfront.project.json",et="webfront-packages.lock.json",x=Qe,S=et;function cc(e){if(e===void 0||e==="")return"";if(typeof e!="string"||e.endsWith("/")||Ze(e)||e===".webfront"||e.startsWith(".webfront/"))throw new Error(`Unsafe manifest directory: ${e}`);return e}function Ol(e){let t=cc(e);x=t?`${t}/${Qe}`:Qe,S=t?`${t}/${et}`:et}var ee=1,tt=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/,ac=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,lc=/^[0-9A-Za-z.+\-^~<>=*| ]{1,128}$/,En=/^[A-Za-z0-9][A-Za-z0-9:_.-]{0,63}$/,rt=/^[A-Za-z_][A-Za-z0-9_]*$/,gn=["format","name","version","dependencies","registry","scripts","entries","providers","test","permissions","developer"],uc=["files","publish","fetch"],$=e=>{throw new Error(`${x}: ${e}`)};function P(e,t){return W(e)||$(`${t} must be an object`),e}function ye(e,t,r){for(let n of Object.keys(e))t.includes(n)||$(`unknown key "${n}" in ${r}`)}function $e(e,t){typeof e!="string"&&$(`${t} must be a project path`);try{return A(e)}catch{return $(`${t} is not a safe project-relative path: ${e}`)}}function $n(e,t){return(!Array.isArray(e)||e.length>256)&&$(`${t} must be an array of at most 256 paths`),e.map((r,n)=>$e(r,`${t}[${n}]`))}function fc(e){let t=P(e,"dependencies");for(let[r,n]of Object.entries(t))tt.test(r)||$(`invalid npm package name "${r}"`),(typeof n!="string"||!lc.test(n)||n!==n.trim())&&$(`invalid version range for "${r}"`);return t}var nt=e=>e.startsWith("/")&&!e.startsWith("//")&&!e.includes("\\");function pc(e){if(typeof e!="string"&&$("registry must be a URL"),nt(e))return e;let t;try{t=new URL(e)}catch{return $("registry must be an https URL or an absolute path")}return t.protocol!=="https:"&&$("registry must use https"),e}function hc(e){let t=P(e,"scripts");for(let[r,n]of Object.entries(t))(!En.test(r)||typeof n!="string"||!n||n.length>1024)&&$(`invalid script "${r}"`);return t}function dc(e){let t=P(e,"entries");for(let[r,n]of Object.entries(t))En.test(r)||$(`invalid entry name "${r}"`),$e(n,`entries.${r}`);return t}function mc(e,t){let r=P(e,"providers");for(let[n,s]of Object.entries(r))rt.test(n)||$(`invalid provider name "${n}"`),P(s,`providers.${n}`),ye(s,["entry","output"],`providers.${n}`),typeof s.entry!="string"&&$(`providers.${n}.entry must name an entry or a path`),Object.hasOwn(t,s.entry)||$e(s.entry,`providers.${n}.entry`),$e(s.output,`providers.${n}.output`).endsWith(".hpp")||$(`providers.${n}.output must be a .hpp file`);return r}function wc(e){let t=P(e,"test");return ye(t,["specs"],"test"),t.specs!==void 0&&$n(t.specs,"test.specs"),t}function Ec(e,t){let r;try{r=new URL(e)}catch{return $(`${t} must be an https origin`)}return(r.protocol!=="https:"||r.origin!==e)&&$(`${t} must be an https origin without a path`),e}function gc(e){let t=P(e,"permissions");for(let r of Object.keys(t))uc.includes(r)||$(`unknown permission "${r}"`);for(let r of["files","publish"])t[r]!==void 0&&$n(t[r],`permissions.${r}`);return t.fetch!==void 0&&((!Array.isArray(t.fetch)||t.fetch.length>64)&&$("permissions.fetch must be an array of origins"),t.fetch.forEach((r,n)=>Ec(r,`permissions.fetch[${n}]`))),t}var wn={Ctrl:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"},vl="F9";function $c(e){if(typeof e!="string")return null;let t=e.split("+"),r=t.pop();if(!/^F(?:[1-9]|1[0-2])$/.test(r)||new Set(t).size!==t.length)return null;let n={key:r,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1};for(let s of t){if(!Object.hasOwn(wn,s))return null;n[wn[s]]=!0}return n}function yc(e){let t=P(e,"developer");return ye(t,["terminalShortcut"],"developer"),t.terminalShortcut!==void 0&&!$c(t.terminalShortcut)&&$('developer.terminalShortcut must be a function key, F1 to F12, optionally after Ctrl, Alt, Shift or Meta (for instance "Ctrl+Shift+F9")'),t}function xc(e){(typeof e.name!="string"||!tt.test(e.name))&&$("name must be a lower-case npm package name"),(typeof e.version!="string"||!ac.test(e.version))&&$("version must be a semantic version")}function Rc(e){e.format!==ee&&(Number.isInteger(e.format)&&e.format>ee&&$(`format ${e.format} is not supported by this environment (it reads format ${ee}); update the environment`),$(`format must be ${ee}`))}function te(e){P(e,"the manifest"),Rc(e),ye(e,gn,"the manifest"),xc(e);let t=e.entries===void 0?{}:dc(e.entries);return{...e,dependencies:e.dependencies===void 0?{}:fc(e.dependencies),entries:t,providers:e.providers===void 0?{}:mc(e.providers,t),...e.registry===void 0?{}:{registry:pc(e.registry)},...e.scripts===void 0?{}:{scripts:hc(e.scripts)},...e.test===void 0?{}:{test:wc(e.test)},...e.permissions===void 0?{}:{permissions:gc(e.permissions)},...e.developer===void 0?{}:{developer:yc(e.developer)}}}function st(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch{return $("not valid JSON")}return{source:t,manifest:te(t)}}function Il(e){return st(e).manifest}function ot(e){let t={};for(let r of gn)e[r]!==void 0&&(t[r]=e[r]);return JSON.stringify(t,null,2)+` +`}function yn(e){return{format:ee,name:e,version:"0.1.0",dependencies:{}}}function xn(e){let r=(String(e??"").split("/").filter(Boolean).pop()??"").toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^[^a-z0-9]+/,"").replace(/-+$/,"");return tt.test(r)?r:"webfront-app"}async function xe(e){let t=JSON.stringify(Object.entries(e).sort(([n],[s])=>ns?1:0)),r=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return[...new Uint8Array(r)].map(n=>n.toString(16).padStart(2,"0")).join("")}var it=e=>/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/.test(e),be=(e,t)=>`${e.replace("/","+")}@${t}`,ct=(e,t,r)=>`${be(e,t)}-${r.slice(7).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}`;async function bc(e,t,{fetchImpl:r,signal:n}){let s=await r(new URL(e.replace("/","%2f"),t),{signal:n});if(!s.ok)throw new Error(`Registry metadata for ${e}: HTTP ${s.status}`);return s.json()}function Oc(e,t){let r=e["dist-tags"]?.[t];return r||(Re.default.valid(t)?t:Re.default.maxSatisfying(Object.keys(e.versions??{}),t))}function vc(e,t,r){let n=r||"latest",s=Oc(e,n),o=e.versions?.[s];if(!o||!Re.default.valid(s))throw new Error(`Cannot resolve ${t}@${n}`);return{version:s,manifest:o}}async function Ic(e,t,r,{fetchImpl:n,signal:s}){let o=new URL(t.dist?.tarball,r);if(o.protocol!=="https:"&&o.origin!==r.origin)throw new Error("Package tarballs must use HTTPS or the registry origin");let i=await n(o,{signal:s});if(!i.ok)throw new Error(`Package download for ${e}: HTTP ${i.status}`);let a=await hn(i);return{bytes:a,integrity:await yt(a,t.dist.integrity)}}function at(e){let t=new URL(e,globalThis.location?.href),r=t.origin===globalThis.location?.origin;if(e.startsWith("/")?!nt(e)||!r:t.protocol!=="https:"&&!r)throw new Error(`The npm registry must use HTTPS or the application origin: ${e}`);return t.pathname.endsWith("/")||(t.pathname+="/"),t}async function D(e,t,{registry:r,fetchImpl:n=fetch,signal:s}){if(!it(e))throw new Error(`Unsupported npm package name: ${e}`);let o=at(r),i={fetchImpl:n,signal:s},{version:a,manifest:c}=vc(await bc(e,o,i),e,t),{bytes:l,integrity:u}=await Ic(e,c,o,i),f=await dn(l),m=mn(f,e,a);return{id:be(e,a),key:ct(e,a,u),manifest:m,integrity:u,files:f}}var Oe=F(C(),1);function Sc(e,t,r){let n=e?.roots?.[t];return n?.requested===r&&e.packages[n.id]?e.packages[n.id]:Oe.default.validRange(r)?Object.values(e?.packages??{}).filter(o=>o.name===t&&Oe.default.satisfies(o.version,r)).sort((o,i)=>Oe.default.rcompare(o.version,i.version))[0]??null:null}function Rn({registry:e="https://registry.npmjs.org/",fetchImpl:t=fetch,signal:r,download:n=D,previous:s}){let o=new Map;return async(i,a)=>{let c=`${i}@${a}`;if(o.has(c))return o.get(c);let l=Sc(s,i,a),u=await n(i,l?.version??a,{registry:e,fetchImpl:t,signal:r});if(l&&u.integrity!==l.integrity)throw new Error(`${u.id} no longer matches the integrity recorded in the lock`);return o.set(c,u),u}}var bn=F(C(),1),On=(e,t,r)=>new Error(`${e.name}@${e.version} requires peer ${t}@${r}; install a compatible root explicitly`);function kc(e,t,r){if(e.manifest.peerDependenciesMeta?.[t]?.optional)return null;throw On(e,t,r)}function Nc(e,[t,r],{nodes:n,roots:s}){let o=s[t]?.id??e.dependencies[t];if(!o)return kc(e,t,r);if(!bn.default.satisfies(n[o].version,r))throw On(e,t,r);return o}function Lc(e,t){for(let r of Object.entries(e.manifest.peerDependencies??{})){let n=Nc(e,r,t);n&&(e.dependencies[r[0]]=n)}}function vn(e,t){for(let r of Object.values(e))Lc(r,{nodes:e,roots:t})}var In=F(C(),1);function Ac(e,t){return!it(t.name)||!In.default.valid(t.version)?!1:e===be(t.name,t.version)}function Tc(e){return e.integrity?.startsWith("sha512-")?e.key===ct(e.name,e.version,e.integrity):!1}function jc(e,t,r){if(!Ac(t,r)||!Tc(r))throw new Error("Invalid locked package");for(let n of r.files)A(n);if(Object.values(r.dependencies).some(n=>!e.packages[n]))throw new Error("Dangling locked dependency")}function Pc(e){return e?.format!==1?!1:!!e.roots&&!!e.packages}function lt(e){if(!Pc(e))throw new Error("Unsupported package lock");if(Object.keys(e.packages).length>512)throw new Error("The package lock exceeds 512 packages");for(let[t,r]of Object.entries(e.packages))jc(e,t,r);if(Object.values(e.roots).some(t=>!e.packages[t.id]))throw new Error("Dangling locked root");return e}function qc(e,t,r){if(Object.keys(e.nodes).length>=512)throw new Error("Dependency graph exceeds 512 packages");for(let n of r.files.values())e.total+=n.length;if(e.total>256*1024*1024)throw new Error("Dependency graph exceeds 256 MiB");e.nodes[r.id]={name:t,version:r.manifest.version,integrity:r.integrity,key:r.key,manifest:r.manifest,files:[...r.files.keys()].sort(),dependencies:{}},e.downloads.set(r.id,r.files)}async function Cc(e,t){let r={};for(let n of e){let{name:s,version:o}=ie(n);r[s]={requested:o||"latest",id:await t(s,o||"latest")}}return r}async function Sn(e,t={}){let r=Rn(t),n={nodes:{},downloads:new Map,total:0},s=async(i,a)=>{t.signal?.throwIfAborted();let c=await r(i,a);if(n.nodes[c.id])return c.id;qc(n,i,c);for(let[l,u]of Object.entries(c.manifest.dependencies??{}).sort())n.nodes[c.id].dependencies[l]=await s(l,u);return c.id},o=await Cc(e,s);return vn(n.nodes,o),{lock:{format:1,registry:t.registry??"https://registry.npmjs.org/",roots:o,packages:n.nodes},downloads:n.downloads}}var ut=F(C(),1);var Dc=new TextDecoder,Uc=new TextEncoder,ve="No webfront.project.json: run wf init",Ie="The lock does not match the dependencies of webfront.project.json; run wf install --update to resolve them again";async function kn(e,t){try{return await G(e,t)}catch(r){if(r.message.includes("Cannot read project file:"))return null;throw r}}function Fc(e,t,r){return t?r===t.requested?!0:ut.default.validRange(r)!==null&&ut.default.satisfies(e.packages[t.id].version,r):!1}function zc(e,t){let r=Object.keys(t);return r.length===Object.keys(e.roots).length&&r.every(n=>Fc(e,e.roots[n],t[n]))}function Gc(e,t,r){return e?t?t.manifestDigest===void 0?zc(t,e.dependencies)?"legacy":"desynchronized":t.manifestDigest===r?"consistent":"desynchronized":"unlocked":"no-manifest"}async function re(e){let t=await R(e,"state",`${x} +${S}`),r=await kn(e,x),n=await kn(e,S),{source:s,manifest:o}=r?st(r):{source:null,manifest:null},i=n?lt(JSON.parse(Dc.decode(n))):null,a=o?await xe(o.dependencies):null;return{manifest:o,source:s,lock:i,token:t,status:Gc(o,i,a),digest:a}}var Ln=e=>e.status==="desynchronized"?`Warning: ${Ie}.\r +`:"";async function An(e,t,r,{signal:n}={}){let s=[];try{for(let[o,i]of t){n?.throwIfAborted();let a=await R(e,"begin",o,!1);s.push(a),await Z(e,{id:a,path:"output",bytes:i},n)}n?.throwIfAborted(),await R(e,"commitGroup",s.join(` `),`${x} -${N}`,r.token)}catch(o){for(let i of s)await R(e,"abort",i).catch(()=>{});throw o}}function kn(e,t,r){let n=e?.entries??{};if(t!==void 0)return Object.hasOwn(n,t)?n[t]:t;if(Object.hasOwn(n,"main"))return n.main;let s=Object.keys(n);if(s.length===1)return n[s[0]];throw new Error(`Usage: ${r} (declare entries.main in ${x} to omit the entry)`)}function Vl(e,[t,r,n,...s]){if(t&&Object.hasOwn(e?.providers??{},t)&&r===void 0){let i=e.providers[t];return{entry:kn(e,i.entry),output:i.output,className:t}}if(!t||r!=="--output"||s.length||!n?.endsWith(".hpp"))throw new Error("wf embed requires or --output ");let o=n.split("/").pop().slice(0,-4);if(!tt.test(o))throw new Error(`wf embed: ${o} is not a C++ class name; name the output .hpp`);return{entry:kn(e,t),output:n,className:o}}var Ie=e=>qc.encode(e);var mt=F(C(),1);var An=e=>`${M}/${e.key}`,Tn=e=>`${M}/${e.key}.json`,zc=new TextEncoder,Gc=new TextDecoder,jn=e=>e.message.includes("Cannot read project file:");async function Pn(e){return[...new Uint8Array(await crypto.subtle.digest("SHA-256",e))].map(r=>r.toString(16).padStart(2,"0")).join("")}async function Ne(e,t,r,{signal:n}={}){let s={};for(let i of[...r.keys()].sort())s[i]=await Pn(r.get(i));await Q(e,An(t),r,{signal:n});let o=JSON.stringify({format:1,integrity:t.integrity,files:s},null,2)+` -`;await Q(e,Tn(t),new Map([["output",zc.encode(o)]]),{directory:!1,signal:n})}async function Mc(e,t){let r;try{r=await G(e,Tn(t))}catch(n){if(jn(n))return null;throw n}try{return JSON.parse(Gc.decode(r))}catch{return{}}}var Wc=(e,t)=>Object.keys(e.files).sort().join(` +${S}`,r.token)}catch(o){for(let i of s)await R(e,"abort",i).catch(()=>{});throw o}}function Nn(e,t,r){let n=e?.entries??{};if(t!==void 0)return Object.hasOwn(n,t)?n[t]:t;if(Object.hasOwn(n,"main"))return n.main;let s=Object.keys(n);if(s.length===1)return n[s[0]];throw new Error(`Usage: ${r} (declare entries.main in ${x} to omit the entry)`)}function Kl(e,[t,r,n,...s]){if(t&&Object.hasOwn(e?.providers??{},t)&&r===void 0){let i=e.providers[t];return{entry:Nn(e,i.entry),output:i.output,className:t}}if(!t||r!=="--output"||s.length||!n?.endsWith(".hpp"))throw new Error("wf embed requires or --output ");let o=n.split("/").pop().slice(0,-4);if(!rt.test(o))throw new Error(`wf embed: ${o} is not a C++ class name; name the output .hpp`);return{entry:Nn(e,t),output:n,className:o}}var Se=e=>Uc.encode(e);var mt=F(C(),1);var Tn=e=>`${M}/${e.key}`,jn=e=>`${M}/${e.key}.json`,Wc=new TextEncoder,_c=new TextDecoder,Pn=e=>e.message.includes("Cannot read project file:");async function qn(e){return[...new Uint8Array(await crypto.subtle.digest("SHA-256",e))].map(r=>r.toString(16).padStart(2,"0")).join("")}async function ke(e,t,r,{signal:n}={}){let s={};for(let i of[...r.keys()].sort())s[i]=await qn(r.get(i));await Q(e,Tn(t),r,{signal:n});let o=JSON.stringify({format:1,integrity:t.integrity,files:s},null,2)+` +`;await Q(e,jn(t),new Map([["output",Wc.encode(o)]]),{directory:!1,signal:n})}async function Vc(e,t){let r;try{r=await G(e,jn(t))}catch(n){if(Pn(n))return null;throw n}try{return JSON.parse(_c.decode(r))}catch{return{}}}var Xc=(e,t)=>Object.keys(e.files).sort().join(` `)===[...t.files].sort().join(` -`);async function _c(e,t,r){let n=[],s=0;for(;;){let o;try{o=await R(e,"read",t,s)}catch(i){if(jn(i))return null;throw i}if(s+=o.length,s>r)return null;if(n.push(o),o.length<262144)return new Uint8Array(await new Blob(n).arrayBuffer())}}async function ft(e,t,{signal:r,limit:n=1/0}={}){let s=await Mc(e,t);if(!s)return{state:"missing",size:0};if(s.integrity!==t.integrity||!W(s.files)||!Wc(s,t))return{state:"corrupted",size:0};let o=0;for(let i of t.files){r?.throwIfAborted();let a=await _c(e,`${An(t)}/${i}`,n-o);if(!a||await Pn(a)!==s.files[i])return{state:"corrupted",size:0};o+=a.length}return{state:"valid",size:o}}var Zl=async(e,t,r)=>(await ft(e,t,r)).state;var Vc="https://registry.npmjs.org/";function Xc({registry:e,registryExplicit:t}={},r){return t&&e?{url:e,source:"application option"}:r?.registry?{url:r.registry,source:x}:{url:e||Vc,source:"default"}}function pt(e,t){let r=Xc(e,t);return at(r.url),r}var ht=({url:e,source:t})=>`Registry: ${e} (${t})`,Bc=256*1024*1024,Hc=e=>[...e.values()].reduce((t,r)=>t+r.length,0),Yc=e=>new Error(`The locked packages exceed ${e/(1024*1024)} MiB unpacked`);async function Jc(e,t,{signal:r,limit:n}){let s=[],o=0;for(let[i,a]of Object.entries(t.packages)){r?.throwIfAborted();let c=await ft(e,a,{signal:r,limit:n-o});o+=c.size,s.push({id:i,node:a,state:c.state})}return{states:s,size:o}}async function dt(e,t,{registry:r,offline:n=!1,signal:s,progress:o=()=>{},fetchImpl:i=fetch,limit:a=Bc}){let{states:c,size:l}=await Jc(e,t,{signal:s,limit:a}),u=l,f={verified:c.filter(({state:m})=>m==="valid").length,restored:0,problems:[]};for(let{id:m,node:d,state:T}of c.filter(({state:k})=>k!=="valid")){if(n){f.problems.push(`${m} (${T})`);continue}o(`Restoring ${m}${T==="corrupted"?" (corrupted in the cache)":""}`);let k=await D(d.name,d.version,{registry:r,fetchImpl:i,signal:s});if(k.integrity!==d.integrity)throw new Error(`${m} no longer matches the integrity recorded in the lock`);if(u+=Hc(k.files),u>a)throw Yc(a);await Ne(e,d,k.files,{signal:s}),f.restored++}if(f.problems.length)throw new Error(`The cache does not match ${N}; missing or corrupted, nothing downloaded:\r +`);async function Bc(e,t,r){let n=[],s=0;for(;;){let o;try{o=await R(e,"read",t,s)}catch(i){if(Pn(i))return null;throw i}if(s+=o.length,s>r)return null;if(n.push(o),o.length<262144)return new Uint8Array(await new Blob(n).arrayBuffer())}}async function ft(e,t,{signal:r,limit:n=1/0}={}){let s=await Vc(e,t);if(!s)return{state:"missing",size:0};if(s.integrity!==t.integrity||!W(s.files)||!Xc(s,t))return{state:"corrupted",size:0};let o=0;for(let i of t.files){r?.throwIfAborted();let a=await Bc(e,`${Tn(t)}/${i}`,n-o);if(!a||await qn(a)!==s.files[i])return{state:"corrupted",size:0};o+=a.length}return{state:"valid",size:o}}var tu=async(e,t,r)=>(await ft(e,t,r)).state;var Hc="https://registry.npmjs.org/";function Kc({registry:e,registryExplicit:t}={},r){return t&&e?{url:e,source:"application option"}:r?.registry?{url:r.registry,source:x}:{url:e||Hc,source:"default"}}function pt(e,t){let r=Kc(e,t);return at(r.url),r}var ht=({url:e,source:t})=>`Registry: ${e} (${t})`,Yc=256*1024*1024,Jc=e=>[...e.values()].reduce((t,r)=>t+r.length,0),Zc=e=>new Error(`The locked packages exceed ${e/(1024*1024)} MiB unpacked`);async function Qc(e,t,{signal:r,limit:n}){let s=[],o=0;for(let[i,a]of Object.entries(t.packages)){r?.throwIfAborted();let c=await ft(e,a,{signal:r,limit:n-o});o+=c.size,s.push({id:i,node:a,state:c.state})}return{states:s,size:o}}async function dt(e,t,{registry:r,offline:n=!1,signal:s,progress:o=()=>{},fetchImpl:i=fetch,limit:a=Yc}){let{states:c,size:l}=await Qc(e,t,{signal:s,limit:a}),u=l,f={verified:c.filter(({state:m})=>m==="valid").length,restored:0,problems:[]};for(let{id:m,node:d,state:T}of c.filter(({state:k})=>k!=="valid")){if(n){f.problems.push(`${m} (${T})`);continue}o(`Restoring ${m}${T==="corrupted"?" (corrupted in the cache)":""}`);let k=await D(d.name,d.version,{registry:r,fetchImpl:i,signal:s});if(k.integrity!==d.integrity)throw new Error(`${m} no longer matches the integrity recorded in the lock`);if(u+=Jc(k.files),u>a)throw Zc(a);await ke(e,d,k.files,{signal:s}),f.restored++}if(f.problems.length)throw new Error(`The cache does not match ${S}; missing or corrupted, nothing downloaded:\r ${f.problems.join(`\r `)}\r -Run wf restore to download them.`);return f}function Zc(e){let t=e.includes("--offline");if(e.some(r=>r!=="--offline"))throw new Error("Usage: wf restore [--offline]");return{offline:t}}async function nu(e,t,{registry:r,registryExplicit:n,signal:s,progress:o=()=>{},fetchImpl:i=fetch}={}){let{offline:a}=Zc(t),c=await re(e);if(!c.manifest)throw new Error(Oe);if(!c.lock)throw new Error(`No ${N}: run wf install to resolve the dependencies`);let l=a?null:pt({registry:r,registryExplicit:n},c.manifest);o(a?"Offline: no registry is contacted":ht(l));let u=await dt(e,c.lock,{registry:l?.url,offline:a,signal:s,progress:o,fetchImpl:i}),f=Object.keys(c.lock.packages).length,m=a?`Cache verified offline: ${f} packages match ${N}.`:`Restored ${u.restored} of ${f} packages (${u.verified} already in the cache). Lock: ${N}`;return{...u,registry:l,text:Sn(c)+m}}var Dn=e=>{let{name:t,version:r}=ie(e);return[t,r||void 0]};function Kc(e,t){let{version:r}=e.packages[t.id];return!(mt.default.valid(t.requested)!==null)&&t.requested!=="latest"&&mt.default.validRange(t.requested)!==null?t.requested:`^${r}`}async function pu(e,[t,...r],{signal:n}={}){if(r.length)throw new Error("Usage: wf init [name]");let{lock:s}=await re(e),o=$n(t??yn(""));s&&(o.dependencies=Object.fromEntries(Object.entries(s.roots).map(([a,c])=>[a,Kc(s,c)]))),te(o),await Q(e,x,new Map([["output",Ie(ot(o))]]),{directory:!1,replace:!1,signal:n});let i=s?` with the ${Object.keys(o.dependencies).length} dependencies of ${N}`:"";return`Created ${x}${i}. Add libraries with wf install .`}function Qc(e,t){let r={...e.manifest.dependencies},n=new Set;for(let s of t){let[o,i]=Dn(s);r[o]=i??"latest",i&&i!=="latest"&&n.add(o)}return te({...e.source,dependencies:r}),{dependencies:r,explicit:n}}function ea(e,t){let r={...e.source,dependencies:t};return te(r),r}function ta({dependencies:e,explicit:t},r,n){let s={...e};for(let o of n){let i=Dn(o)[0];t.has(i)||(s[i]=`^${r.packages[r.roots[i].id].version}`)}return s}async function ra(e,t,r){let n=Object.entries(e).map(([i,a])=>`${i}@${a}`),{lock:s,downloads:o}=await In(n,{registry:r.registry,signal:r.signal,fetchImpl:r.fetchImpl,previous:t,download:async(...i)=>(r.progress(`Resolving ${i[0]}@${i[1]}`),D(...i))});return{lock:s,downloads:o}}async function na(e,t,r,{signal:n,progress:s}){for(let[o,i]of r)s(`Storing ${o}`),await Ne(e,t.packages[o],i,{signal:n})}function sa(e){let t=e.includes("--update"),r=e.filter(n=>n!=="--update");if(r.some(n=>n.startsWith("-")))throw new Error("Usage: wf install [--update] [[@range] ...]");return{update:t,specs:r}}async function qn(e,t,{manifest:r,lock:n},s){let o=new Map([[N,Ie(JSON.stringify(n,null,2)+` -`)]]);r&&o.set(x,Ie(ot(r))),await Ln(e,o,t,s)}var Cn=async(e,t)=>({format:e.format,manifestDigest:await ye(t),...e});async function hu(e,t,{registry:r,registryExplicit:n,signal:s,progress:o=()=>{},fetchImpl:i=fetch}){let{update:a,specs:c}=sa(t),l=await re(e);if(!l.manifest)throw new Error(Oe);let u=pt({registry:r,registryExplicit:n},l.manifest),f={registry:u.url,signal:s,fetchImpl:i,progress:o};if(c.length&&a)throw new Error("Usage: wf install --update does not take packages");if(c.length&&l.status==="desynchronized")throw new Error(ve);if(!c.length&&!a&&l.status==="desynchronized")throw new Error(ve);o(ht(u));let m=l.status==="consistent"||l.status==="legacy";if(!c.length&&!a&&m){let{restored:U}=await dt(e,l.lock,f);if(l.status==="consistent")return{lock:l.lock,restored:U,registry:u};let oe=await Cn(l.lock,l.manifest.dependencies);return await qn(e,l,{manifest:null,lock:oe},{signal:s}),{lock:oe,restored:U,registry:u}}let d=Qc(l,c),T=m&&!a?l.lock:void 0,k=await ra(d.dependencies,T,f),Le=ta(d,k.lock,c);await na(e,k.lock,k.downloads,{signal:s,progress:o});let se=await Cn(k.lock,Le),$=c.length?ea(l,Le):null;return await qn(e,l,{manifest:$,lock:se},{signal:s}),{lock:se,restored:0,registry:u}}var oa=()=>[x,N,".webfront"],ne=(e,t)=>e===t||e.startsWith(t+"/");function wt(e){try{return A(e)}catch{throw new Error(`Not a project-relative path: ${e}`)}}var ke=(e,t,r)=>new Error(`Permission denied: ${e} ${t} is not granted by permissions.${r} in ${x}`);function Un(e,t){let r=wt(t);if(![...e?.files??[],...e?.publish??[]].some(s=>ne(r,s)))throw ke("reading",t,"files");return r}function Fn(e,t){let r=t===""||t==="."?"":wt(t),n=[...e?.files??[],...e?.publish??[]];if(r&&n.some(o=>ne(r,o)))return{path:r,keep:()=>!0};let s=o=>n.some(i=>ne(o,i)||i.startsWith(o+"/"));if(!n.some(o=>r===""||o.startsWith(r+"/")))throw ke("listing",r||"the project root","files");return{path:r,keep:o=>s(r?`${r}/${o.replace(/\/$/,"")}`:o.replace(/\/$/,""))}}function zn(e,t){let r=wt(t);if(oa().some(n=>ne(r,n)))throw new Error(`Permission denied: ${t} is managed by wf and never written by a script`);if(!(e?.publish??[]).some(n=>ne(r,n)))throw ke("writing",t,"publish");return r}function Eu(e,t,r){let n=new URL(t,r);if(!(e?.fetch??[]).includes(n.origin))throw ke("fetching",n.origin,"fetch");return n}var ia=2e3,Mn=600,Se=[1,3600],Gn=4,Et=class extends Error{constructor(t,r){super(t),this.exitCode=r}},bu=(e,t=1/0,r=Date.now())=>Math.min(r+e*1e3,t),Ou=(e,t=Date.now())=>Math.max(0,(e-t)/1e3);function vu(e,t){let r=Mn,n=e;if(n[0]==="--timeout"){if(r=Number(n[1]),!Number.isInteger(r)||rSe[1])throw new Error(`--timeout expects whole seconds from ${Se[0]} to ${Se[1]}`);n=n.slice(2)}if(!n.length||n[0].startsWith("-"))throw new Error(`Usage: ${t}`);return{timeout:r,target:n[0],args:n.slice(1)}}function Iu(e,t,r,n,s=0){let o=e?.scripts??{};if(!Object.hasOwn(o,t)){let c=Object.keys(o).sort().join(", ")||"none";throw new Error(`No script "${t}" in ${x} (scripts: ${c})`)}let[i,...a]=n(o[t]);if(i==="wf"){if(s>=Gn)throw new Error(`Scripts call wf more than ${Gn} levels deep`);return{kind:"wf",argv:[...a,...r]}}return{kind:"module",entry:{namespace:"project",path:A(i)},args:[...a,...r]}}function Wn(e,t){if(e?.roots&&Object.hasOwn(e.roots,t)){let{id:n}=e.roots[t];return[n,e.packages[n]]}let r=Object.entries(e?.packages??{}).filter(([,n])=>n.name===t);if(r.length>1)throw new Error(`${t} is locked at several versions; install it as a root to choose one`);return r[0]??null}function ca(e,t){let r=t.webfront?.bin;if(typeof r=="string")return{[t.name.split("/").pop()]:r};if(r&&typeof r=="object"&&!Array.isArray(r))return r;throw t.bin?new Error(`${e} only declares an npm "bin" (a Node.js program); wf exec runs only "webfront.bin" entries`):new Error(`${e} has no WebFront executable entry ("webfront.bin" in its package.json)`)}function Nu(e,t){let r=t.indexOf(":",t.startsWith("@")?t.indexOf("/"):0),[n,s]=r<0?[t,void 0]:[t.slice(0,r),t.slice(r+1)],o=Wn(e,n);if(!o)throw new Error(`${n} is not installed: run wf install ${n}`);let[i,a]=o,c=ca(i,a.manifest),l=Object.keys(c),u=s??(l.length===1?l[0]:void 0);if(!u||!Object.hasOwn(c,u))throw new Error(`${i} has the WebFront entries ${l.join(", ")||"none"}: run wf exec ${n}:`);let f=String(c[u]).replace(/^\.\//,"");if(!a.files.includes(A(f)))throw new Error(`${i}: webfront.bin entry ${u} names a missing file ${f}`);return{id:i,name:u,entry:{namespace:"npm",path:`${i}/${f}`}}}var aa=new TextDecoder;function ku({bridge:e,permissions:t,lock:r}){let n=new AbortController,s=[],o=new Set;async function i(c,l){let u=zn(t,c);if(!(l instanceof Uint8Array))throw new TypeError("context.project.write expects a string or a Uint8Array");let f={path:u,state:"staging"};s.push(f);let m=null;try{m=await R(e,"begin",u,!1),await K(e,{id:m,path:"output",bytes:l},n.signal),n.signal.throwIfAborted(),f.state="committing",await R(e,"commit",m),f.state="applied"}catch(d){let T=n.signal.aborted&&f.state!=="committing";throw f.state=T?"abandoned":"failed",m!==null&&await R(e,"abort",m).catch(()=>{}),d}}let a={read:c=>G(e,Un(t,c)),list:async(c="")=>{let{path:l,keep:u}=Fn(t,c);return JSON.parse(aa.decode(await R(e,"list",l))).filter(u)},write:i,resolve:c=>{let l=Wn(r,c)?.[1];return l?{name:l.name,version:l.version,integrity:l.integrity}:null}};return{publications:s,async handle({operation:c,args:l}){if(n.signal.aborted)throw new Error("The script was stopped");if(!Object.hasOwn(a,c))throw new Error(`Unknown context operation: ${c}`);let u=a[c](...l);o.add(u);try{return await u}finally{o.delete(u)}},async finish(){for(let c of s)(c.state==="staging"||c.state==="committing")&&(c.unawaited=!0);for(;o.size;)await Promise.allSettled([...o]);await this.stop()},async stop(){n.abort(new Error("The script was stopped")),await Promise.allSettled([...o])}}}function Su({createWorker:e,host:t,message:r,signal:n,timeout:s=Mn,grace:o=ia,write:i}){return new Promise(a=>{let c=e(),l=[],u=null,f=!1,m=()=>u==="timeout"?124:130,d=$=>{f||(f=!0,c.terminate(),l.forEach(clearTimeout),n?.removeEventListener("abort",k),a({reason:u??"exit",...$}))},T=$=>{u||f||(u=$,c.postMessage({type:"abort"}),l.push(setTimeout(()=>d({code:m(),forced:o}),o)))},k=()=>T("interrupted"),se={console:$=>i(String($.text).replace(/\r?\n/g,`\r +Run wf restore to download them.`);return f}function ea(e){let t=e.includes("--offline");if(e.some(r=>r!=="--offline"))throw new Error("Usage: wf restore [--offline]");return{offline:t}}async function cu(e,t,{registry:r,registryExplicit:n,signal:s,progress:o=()=>{},fetchImpl:i=fetch}={}){let{offline:a}=ea(t),c=await re(e);if(!c.manifest)throw new Error(ve);if(!c.lock)throw new Error(`No ${S}: run wf install to resolve the dependencies`);let l=a?null:pt({registry:r,registryExplicit:n},c.manifest);o(a?"Offline: no registry is contacted":ht(l));let u=await dt(e,c.lock,{registry:l?.url,offline:a,signal:s,progress:o,fetchImpl:i}),f=Object.keys(c.lock.packages).length,m=a?`Cache verified offline: ${f} packages match ${S}.`:`Restored ${u.restored} of ${f} packages (${u.verified} already in the cache). Lock: ${S}`;return{...u,registry:l,text:Ln(c)+m}}var Un=e=>{let{name:t,version:r}=ie(e);return[t,r||void 0]};function ta(e,t){let{version:r}=e.packages[t.id];return!(mt.default.valid(t.requested)!==null)&&t.requested!=="latest"&&mt.default.validRange(t.requested)!==null?t.requested:`^${r}`}async function wu(e,[t,...r],{signal:n}={}){if(r.length)throw new Error("Usage: wf init [name]");let{lock:s}=await re(e),o=yn(t??xn(""));s&&(o.dependencies=Object.fromEntries(Object.entries(s.roots).map(([a,c])=>[a,ta(s,c)]))),te(o),await Q(e,x,new Map([["output",Se(ot(o))]]),{directory:!1,replace:!1,signal:n});let i=s?` with the ${Object.keys(o.dependencies).length} dependencies of ${S}`:"";return`Created ${x}${i}. Add libraries with wf install .`}function ra(e,t){let r={...e.manifest.dependencies},n=new Set;for(let s of t){let[o,i]=Un(s);r[o]=i??"latest",i&&i!=="latest"&&n.add(o)}return te({...e.source,dependencies:r}),{dependencies:r,explicit:n}}function na(e,t){let r={...e.source,dependencies:t};return te(r),r}function sa({dependencies:e,explicit:t},r,n){let s={...e};for(let o of n){let i=Un(o)[0];t.has(i)||(s[i]=`^${r.packages[r.roots[i].id].version}`)}return s}async function oa(e,t,r){let n=Object.entries(e).map(([i,a])=>`${i}@${a}`),{lock:s,downloads:o}=await Sn(n,{registry:r.registry,signal:r.signal,fetchImpl:r.fetchImpl,previous:t,download:async(...i)=>(r.progress(`Resolving ${i[0]}@${i[1]}`),D(...i))});return{lock:s,downloads:o}}async function ia(e,t,r,{signal:n,progress:s}){for(let[o,i]of r)s(`Storing ${o}`),await ke(e,t.packages[o],i,{signal:n})}function ca(e){let t=e.includes("--update"),r=e.filter(n=>n!=="--update");if(r.some(n=>n.startsWith("-")))throw new Error("Usage: wf install [--update] [[@range] ...]");return{update:t,specs:r}}async function Cn(e,t,{manifest:r,lock:n},s){let o=new Map([[S,Se(JSON.stringify(n,null,2)+` +`)]]);r&&o.set(x,Se(ot(r))),await An(e,o,t,s)}var Dn=async(e,t)=>({format:e.format,manifestDigest:await xe(t),...e});async function Eu(e,t,{registry:r,registryExplicit:n,signal:s,progress:o=()=>{},fetchImpl:i=fetch}){let{update:a,specs:c}=ca(t),l=await re(e);if(!l.manifest)throw new Error(ve);let u=pt({registry:r,registryExplicit:n},l.manifest),f={registry:u.url,signal:s,fetchImpl:i,progress:o};if(c.length&&a)throw new Error("Usage: wf install --update does not take packages");if(c.length&&l.status==="desynchronized")throw new Error(Ie);if(!c.length&&!a&&l.status==="desynchronized")throw new Error(Ie);o(ht(u));let m=l.status==="consistent"||l.status==="legacy";if(!c.length&&!a&&m){let{restored:U}=await dt(e,l.lock,f);if(l.status==="consistent")return{lock:l.lock,restored:U,registry:u};let oe=await Dn(l.lock,l.manifest.dependencies);return await Cn(e,l,{manifest:null,lock:oe},{signal:s}),{lock:oe,restored:U,registry:u}}let d=ra(l,c),T=m&&!a?l.lock:void 0,k=await oa(d.dependencies,T,f),Ae=sa(d,k.lock,c);await ia(e,k.lock,k.downloads,{signal:s,progress:o});let se=await Dn(k.lock,Ae),y=c.length?na(l,Ae):null;return await Cn(e,l,{manifest:y,lock:se},{signal:s}),{lock:se,restored:0,registry:u}}var aa=()=>[x,S,".webfront"],ne=(e,t)=>e===t||e.startsWith(t+"/");function wt(e){try{return A(e)}catch{throw new Error(`Not a project-relative path: ${e}`)}}var Ne=(e,t,r)=>new Error(`Permission denied: ${e} ${t} is not granted by permissions.${r} in ${x}`);function Fn(e,t){let r=wt(t);if(![...e?.files??[],...e?.publish??[]].some(s=>ne(r,s)))throw Ne("reading",t,"files");return r}function zn(e,t){let r=t===""||t==="."?"":wt(t),n=[...e?.files??[],...e?.publish??[]];if(r&&n.some(o=>ne(r,o)))return{path:r,keep:()=>!0};let s=o=>n.some(i=>ne(o,i)||i.startsWith(o+"/"));if(!n.some(o=>r===""||o.startsWith(r+"/")))throw Ne("listing",r||"the project root","files");return{path:r,keep:o=>s(r?`${r}/${o.replace(/\/$/,"")}`:o.replace(/\/$/,""))}}function Gn(e,t){let r=wt(t);if(aa().some(n=>ne(r,n)))throw new Error(`Permission denied: ${t} is managed by wf and never written by a script`);if(!(e?.publish??[]).some(n=>ne(r,n)))throw Ne("writing",t,"publish");return r}function xu(e,t,r){let n=new URL(t,r);if(!(e?.fetch??[]).includes(n.origin))throw Ne("fetching",n.origin,"fetch");return n}var la=2e3,Wn=600,Le=[1,3600],Mn=4,Et=class extends Error{constructor(t,r){super(t),this.exitCode=r}},Su=(e,t=1/0,r=Date.now())=>Math.min(r+e*1e3,t),ku=(e,t=Date.now())=>Math.max(0,(e-t)/1e3);function Nu(e,t){let r=Wn,n=e;if(n[0]==="--timeout"){if(r=Number(n[1]),!Number.isInteger(r)||rLe[1])throw new Error(`--timeout expects whole seconds from ${Le[0]} to ${Le[1]}`);n=n.slice(2)}if(!n.length||n[0].startsWith("-"))throw new Error(`Usage: ${t}`);return{timeout:r,target:n[0],args:n.slice(1)}}function Lu(e,t,r,n,s=0){let o=e?.scripts??{};if(!Object.hasOwn(o,t)){let c=Object.keys(o).sort().join(", ")||"none";throw new Error(`No script "${t}" in ${x} (scripts: ${c})`)}let[i,...a]=n(o[t]);if(i==="wf"){if(s>=Mn)throw new Error(`Scripts call wf more than ${Mn} levels deep`);return{kind:"wf",argv:[...a,...r]}}return{kind:"module",entry:{namespace:"project",path:A(i)},args:[...a,...r]}}function _n(e,t){if(e?.roots&&Object.hasOwn(e.roots,t)){let{id:n}=e.roots[t];return[n,e.packages[n]]}let r=Object.entries(e?.packages??{}).filter(([,n])=>n.name===t);if(r.length>1)throw new Error(`${t} is locked at several versions; install it as a root to choose one`);return r[0]??null}function ua(e,t){let r=t.webfront?.bin;if(typeof r=="string")return{[t.name.split("/").pop()]:r};if(r&&typeof r=="object"&&!Array.isArray(r))return r;throw t.bin?new Error(`${e} only declares an npm "bin" (a Node.js program); wf exec runs only "webfront.bin" entries`):new Error(`${e} has no WebFront executable entry ("webfront.bin" in its package.json)`)}function Au(e,t){let r=t.indexOf(":",t.startsWith("@")?t.indexOf("/"):0),[n,s]=r<0?[t,void 0]:[t.slice(0,r),t.slice(r+1)],o=_n(e,n);if(!o)throw new Error(`${n} is not installed: run wf install ${n}`);let[i,a]=o,c=ua(i,a.manifest),l=Object.keys(c),u=s??(l.length===1?l[0]:void 0);if(!u||!Object.hasOwn(c,u))throw new Error(`${i} has the WebFront entries ${l.join(", ")||"none"}: run wf exec ${n}:`);let f=String(c[u]).replace(/^\.\//,"");if(!a.files.includes(A(f)))throw new Error(`${i}: webfront.bin entry ${u} names a missing file ${f}`);return{id:i,name:u,entry:{namespace:"npm",path:`${i}/${f}`}}}var fa=new TextDecoder;function Tu({bridge:e,permissions:t,lock:r}){let n=new AbortController,s=[],o=new Set;async function i(c,l){let u=Gn(t,c);if(!(l instanceof Uint8Array))throw new TypeError("context.project.write expects a string or a Uint8Array");let f={path:u,state:"staging"};s.push(f);let m=null;try{m=await R(e,"begin",u,!1),await Z(e,{id:m,path:"output",bytes:l},n.signal),n.signal.throwIfAborted(),f.state="committing",await R(e,"commit",m),f.state="applied"}catch(d){let T=n.signal.aborted&&f.state!=="committing";throw f.state=T?"abandoned":"failed",m!==null&&await R(e,"abort",m).catch(()=>{}),d}}let a={read:c=>G(e,Fn(t,c)),list:async(c="")=>{let{path:l,keep:u}=zn(t,c);return JSON.parse(fa.decode(await R(e,"list",l))).filter(u)},write:i,resolve:c=>{let l=_n(r,c)?.[1];return l?{name:l.name,version:l.version,integrity:l.integrity}:null}};return{publications:s,async handle({operation:c,args:l}){if(n.signal.aborted)throw new Error("The script was stopped");if(!Object.hasOwn(a,c))throw new Error(`Unknown context operation: ${c}`);let u=a[c](...l);o.add(u);try{return await u}finally{o.delete(u)}},async finish(){for(let c of s)(c.state==="staging"||c.state==="committing")&&(c.unawaited=!0);for(;o.size;)await Promise.allSettled([...o]);await this.stop()},async stop(){n.abort(new Error("The script was stopped")),await Promise.allSettled([...o])}}}function ju({createWorker:e,host:t,message:r,signal:n,timeout:s=Wn,grace:o=la,write:i}){return new Promise(a=>{let c=e(),l=[],u=null,f=!1,m=()=>u==="timeout"?124:130,d=y=>{f||(f=!0,c.terminate(),l.forEach(clearTimeout),n?.removeEventListener("abort",k),a({reason:u??"exit",...y}))},T=y=>{u||f||(u=y,c.postMessage({type:"abort"}),l.push(setTimeout(()=>d({code:m(),forced:o}),o)))},k=()=>T("interrupted"),se={console:y=>i(String(y.text).replace(/\r?\n/g,`\r `)+`\r -`,$.stream),exit:$=>d({code:u&&$.code===0?m():$.code,...Array.isArray($.diagnostics)?{diagnostics:$.diagnostics}:{}}),error:$=>d({code:u?m():1,error:$.error}),call:async $=>{let U;try{U={value:await t.handle($)}}catch(oe){U={error:oe.message}}f||c.postMessage({type:"reply",id:$.id,...U})}};c.onmessage=({data:$})=>se[$?.type]?.($),c.onerror=$=>{$.preventDefault?.(),d({code:1,error:$.message||"The script Worker failed"})},n?.addEventListener("abort",k,{once:!0}),l.push(setTimeout(()=>T("timeout"),s*1e3)),c.postMessage({type:"run",...r}),n?.aborted&&k()})}function la(e,t){let r=t?e:e.filter(o=>o.unawaited),n=o=>r.filter(i=>i.state===o).map(({path:i})=>i),s=[];return t&&n("applied").length&&s.push(`Applied before the stop: ${n("applied").join(", ")}`),n("abandoned").length&&s.push(`Abandoned, unchanged: ${n("abandoned").join(", ")}`),n("failed").length&&s.push(`Failed, unchanged: ${n("failed").join(", ")}`),s}function Lu(e,t,r){let n={interrupted:"stopped by Ctrl+C",timeout:"stopped at its time limit"}[t.reason],s=la(r,n!==void 0);if(t.code===0&&!n&&!s.length)return`${e} completed.`;let o=t.forced?` (terminated after the ${t.forced/1e3} s grace period)`:"",i=t.code===0&&!n?1:t.code,a=n?`${n}${o}`:t.code===0?"ended without applying all its writes":`exited with code ${t.code}`;throw new Et([t.error,`${e} ${a}`,...s].filter(Boolean).join(`\r -`),i)}var Uu=new TextDecoder,pa=["",".tsx",".ts",".jsx",".js",".mjs",".cjs",".json",".css","/index.tsx","/index.ts","/index.js"],Fu=new Map(Object.entries({mjs:"js",cjs:"js",js:"js",jsx:"jsx",ts:"ts",tsx:"tsx",css:"css",json:"json"}));async function ha(e,t,r){try{return await e(t,r)}catch(n){if(t!=="project")throw n;return}}function da(e,t,r,n){let s=new Map,o=(c,l)=>{let u=n?.packages?.[c];if(u)return s.has(c)||s.set(c,new Set(u.files)),s.get(c).has(l)?t(`${M}/${u.key}/${l}`):void 0},i=async(c,l)=>{if(c==="project")return t(l);let u=l.indexOf("/"),[f,m]=[l.slice(0,u),l.slice(u+1)];return e?e[f]?.get(m):o(f,m)};return{read:i,find:async(c,l)=>{for(let u of pa){let f=await ha(i,c,l+u);if(f!==void 0)return r.set(`${c}:${l+u}`,f),{path:l+u,namespace:c}}throw new Error(`Cannot resolve ${l}`)}}}var ma=new Set(["assert","async_hooks","buffer","child_process","cluster","console","constants","crypto","dgram","diagnostics_channel","dns","domain","events","fs","http","http2","https","inspector","module","net","os","path","perf_hooks","process","punycode","querystring","readline","repl","stream","string_decoder","sys","timers","tls","trace_events","tty","url","util","v8","vm","wasi","worker_threads","zlib"]),wa=/^(?:node:|[a-z_][a-z0-9_]*(?:\/|$))/;function Ea(e){if(e.startsWith("node:"))return e.slice(5).split("/")[0];let t=e.split("/")[0];return ma.has(t)?t:null}export{Et as ScriptExit,Zl as cacheState,Eu as checkFetch,ic as checkManifestDirectory,Un as checkRead,zn as checkWrite,da as createFinder,Vc as defaultRegistry,Mn as defaultTimeout,ye as dependenciesDigest,ht as describeRegistry,ve as desynchronized,D as downloadPackage,Xc as effectiveRegistry,Vl as embedTarget,cc as exactVersion,Nu as execTarget,ia as gracePeriod,tt as identifier,pu as initProject,ft as inspectCache,hu as install,Fn as listable,re as loadProject,Qe as lockFileName,N as lockPath,Wn as lockedPackage,Dc as locksDependencies,Ke as manifestFileName,ee as manifestFormat,yn as manifestName,x as manifestPath,$n as newManifest,Oe as noManifest,Ea as nodeBuiltin,wa as nodeImport,et as npmName,An as packageDirectory,M as packageRoot,Rl as parseManifest,vu as parseRunOptions,Ln as publishTogether,st as readManifest,Tn as recordPath,kn as resolveEntry,In as resolvePackages,nu as restore,dt as restorePackages,bu as runDeadline,Lu as runResult,Su as runWorker,A as safePackagePath,nt as sameOriginPath,Iu as scriptCommand,ku as scriptHost,Ou as secondsLeft,ot as serializeManifest,xl as setManifestDirectory,Ne as storePackage,Sn as syncNotice,Ie as textBytes,Se as timeoutBounds,Bc as unpackedLimit,pt as usableRegistry,lt as validateLock,te as validateManifest}; +`,y.stream),exit:y=>d({code:u&&y.code===0?m():y.code,...Array.isArray(y.diagnostics)?{diagnostics:y.diagnostics}:{}}),error:y=>d({code:u?m():1,error:y.error}),call:async y=>{let U;try{U={value:await t.handle(y)}}catch(oe){U={error:oe.message}}f||c.postMessage({type:"reply",id:y.id,...U})}};c.onmessage=({data:y})=>se[y?.type]?.(y),c.onerror=y=>{y.preventDefault?.(),d({code:1,error:y.message||"The script Worker failed"})},n?.addEventListener("abort",k,{once:!0}),l.push(setTimeout(()=>T("timeout"),s*1e3)),c.postMessage({type:"run",...r}),n?.aborted&&k()})}function pa(e,t){let r=t?e:e.filter(o=>o.unawaited),n=o=>r.filter(i=>i.state===o).map(({path:i})=>i),s=[];return t&&n("applied").length&&s.push(`Applied before the stop: ${n("applied").join(", ")}`),n("abandoned").length&&s.push(`Abandoned, unchanged: ${n("abandoned").join(", ")}`),n("failed").length&&s.push(`Failed, unchanged: ${n("failed").join(", ")}`),s}function Pu(e,t,r){let n={interrupted:"stopped by Ctrl+C",timeout:"stopped at its time limit"}[t.reason],s=pa(r,n!==void 0);if(t.code===0&&!n&&!s.length)return`${e} completed.`;let o=t.forced?` (terminated after the ${t.forced/1e3} s grace period)`:"",i=t.code===0&&!n?1:t.code,a=n?`${n}${o}`:t.code===0?"ended without applying all its writes":`exited with code ${t.code}`;throw new Et([t.error,`${e} ${a}`,...s].filter(Boolean).join(`\r +`),i)}var Mu=new TextDecoder,ma=["",".tsx",".ts",".jsx",".js",".mjs",".cjs",".json",".css","/index.tsx","/index.ts","/index.js"],Wu=new Map(Object.entries({mjs:"js",cjs:"js",js:"js",jsx:"jsx",ts:"ts",tsx:"tsx",css:"css",json:"json"}));async function wa(e,t,r){try{return await e(t,r)}catch(n){if(t!=="project")throw n;return}}function Ea(e,t,r,n){let s=new Map,o=(c,l)=>{let u=n?.packages?.[c];if(u)return s.has(c)||s.set(c,new Set(u.files)),s.get(c).has(l)?t(`${M}/${u.key}/${l}`):void 0},i=async(c,l)=>{if(c==="project")return t(l);let u=l.indexOf("/"),[f,m]=[l.slice(0,u),l.slice(u+1)];return e?e[f]?.get(m):o(f,m)};return{read:i,find:async(c,l)=>{for(let u of ma){let f=await wa(i,c,l+u);if(f!==void 0)return r.set(`${c}:${l+u}`,f),{path:l+u,namespace:c}}throw new Error(`Cannot resolve ${l}`)}}}var ga=new Set(["assert","async_hooks","buffer","child_process","cluster","console","constants","crypto","dgram","diagnostics_channel","dns","domain","events","fs","http","http2","https","inspector","module","net","os","path","perf_hooks","process","punycode","querystring","readline","repl","stream","string_decoder","sys","timers","tls","trace_events","tty","url","util","v8","vm","wasi","worker_threads","zlib"]),$a=/^(?:node:|[a-z_][a-z0-9_]*(?:\/|$))/;function ya(e){if(e.startsWith("node:"))return e.slice(5).split("/")[0];let t=e.split("/")[0];return ga.has(t)?t:null}export{Et as ScriptExit,tu as cacheState,xu as checkFetch,cc as checkManifestDirectory,Fn as checkRead,Gn as checkWrite,Ea as createFinder,Hc as defaultRegistry,vl as defaultTerminalShortcut,Wn as defaultTimeout,xe as dependenciesDigest,ht as describeRegistry,Ie as desynchronized,D as downloadPackage,Kc as effectiveRegistry,Kl as embedTarget,ac as exactVersion,Au as execTarget,la as gracePeriod,rt as identifier,wu as initProject,ft as inspectCache,Eu as install,zn as listable,re as loadProject,et as lockFileName,S as lockPath,_n as lockedPackage,zc as locksDependencies,Qe as manifestFileName,ee as manifestFormat,xn as manifestName,x as manifestPath,yn as newManifest,ve as noManifest,ya as nodeBuiltin,$a as nodeImport,tt as npmName,Tn as packageDirectory,M as packageRoot,Il as parseManifest,Nu as parseRunOptions,$c as parseShortcut,An as publishTogether,st as readManifest,jn as recordPath,Nn as resolveEntry,Sn as resolvePackages,cu as restore,dt as restorePackages,Su as runDeadline,Pu as runResult,ju as runWorker,A as safePackagePath,nt as sameOriginPath,Lu as scriptCommand,Tu as scriptHost,ku as secondsLeft,ot as serializeManifest,Ol as setManifestDirectory,ke as storePackage,Ln as syncNotice,Se as textBytes,Le as timeoutBounds,Yc as unpackedLimit,pt as usableRegistry,lt as validateLock,te as validateManifest}; diff --git a/js/developer/environment/workspace.mjs b/js/developer/environment/workspace.mjs index 13467703..0a87ecc9 100644 --- a/js/developer/environment/workspace.mjs +++ b/js/developer/environment/workspace.mjs @@ -3,6 +3,8 @@ // once in its window and never moves in the document afterwards: collapsing only hides it, so the session, a running // command, the line being typed and the scrollback are kept. The interface stays in the preview frame. import {call, readProject, publish} from './io.mjs'; +import {loadProject} from './project.mjs'; +import {parseShortcut, defaultTerminalShortcut} from './manifest.mjs'; const encoder = new TextEncoder(); const decoder = new TextDecoder(); @@ -67,8 +69,28 @@ export function keyboardRect(rect, {key, shiftKey = false}, viewport) { return clampRect(shiftKey ? {...rect, width: rect.width + dx, height: rect.height + dy} : {...rect, x: rect.x + dx, y: rect.y + dy}, viewport); } -/** F9 alone: neither the line editor nor xterm.js uses it, and browsers leave it to the page. */ -export const isToggleKey = event => event.key === 'F9' && !(event.ctrlKey || event.altKey || event.metaKey || event.shiftKey); +/** + * F9 alone by default: neither the line editor nor xterm.js uses it, and browsers leave it to the page. The page takes the + * shortcut before the interface does, so an application that uses F9 itself names another one in its manifest. + */ +export const defaultShortcut = parseShortcut(defaultTerminalShortcut); + +/** Whether a key event is the shortcut: its key with exactly its modifiers. */ +export const isToggleKey = (event, shortcut = defaultShortcut) => event.key === shortcut.key + && ['ctrlKey', 'altKey', 'shiftKey', 'metaKey'].every(modifier => Boolean(event[modifier]) === shortcut[modifier]); + +/** The shortcut as the manifest writes it ("Ctrl+Shift+F9"), for the labels. */ +export const shortcutText = shortcut => [shortcut.ctrlKey && 'Ctrl', shortcut.altKey && 'Alt', shortcut.shiftKey && 'Shift', + shortcut.metaKey && 'Meta', shortcut.key].filter(Boolean).join('+'); + +/** + * The project's shortcut, `developer.terminalShortcut` of its manifest, read when the page opens. Without a manifest or + * that key, and with a manifest that is not valid (the commands report it), the default one. + */ +export async function readShortcut(bridge) { + try { return parseShortcut((await loadProject(bridge)).manifest?.developer?.terminalShortcut) ?? defaultShortcut; } + catch { return defaultShortcut; } +} // --- Remembered place ------------------------------------------------------------------------------------------ @@ -159,12 +181,13 @@ export const isManaged = frame => managed.has(frame); * Lays the page out around the terminal's `element` and the preview `frame`, which starts hidden. Call it before the * terminal opens in `element`, then attach({focus, fit}) with the functions that focus the terminal and fit it to `element`. * The result gives the `state`, `interfaceExists` (the page opened on an existing interface, to load in the frame), - * toggle(), open({focus}) and close(), `button` and `panel`, and placeSaved(). + * toggle(), open({focus}) and close(), `button` and `panel`, the `shortcut` in use ("F9") and placeSaved(). */ export async function createWorkspace({bridge, element, frame}) { managed.add(frame); const page = element.ownerDocument, view = page.defaultView, root = page.documentElement; - const [interfaceExists, remembered] = await Promise.all([hasInterface(bridge), readPlace(bridge)]); + const [interfaceExists, remembered, shortcut] = await Promise.all([hasInterface(bridge), readPlace(bridge), readShortcut(bridge)]); + const keys = shortcutText(shortcut); const store = placeStore(bridge); const viewport = () => ({width: root.clientWidth, height: root.clientHeight}); let state = initialState(interfaceExists); @@ -192,7 +215,7 @@ export async function createWorkspace({bridge, element, frame}) { closeButton.type = 'button'; closeButton.className = 'webfront-terminal-close'; closeButton.setAttribute('aria-label', 'Hide the terminal'); - closeButton.title = 'Hide the terminal (F9)'; + closeButton.title = `Hide the terminal (${keys})`; closeButton.textContent = '×'; bar.append(title, closeButton); element.replaceWith(panel); @@ -206,6 +229,7 @@ export async function createWorkspace({bridge, element, frame}) { button.className = 'webfront-terminal-toggle'; button.innerHTML = logo; button.setAttribute('aria-controls', panel.id); + button.setAttribute('aria-keyshortcuts', keys.replace('Ctrl', 'Control')); page.body.append(button); // The displayed rectangle; the chosen one is kept, so that a window enlarged again gives the terminal its place back. @@ -215,7 +239,7 @@ export async function createWorkspace({bridge, element, frame}) { const open = state === State.floating; button.setAttribute('aria-expanded', String(open)); button.setAttribute('aria-label', open ? 'Hide the WebFront terminal' : 'Show the WebFront terminal'); - button.title = `${open ? 'Hide' : 'Show'} the terminal (F9)`; + button.title = `${open ? 'Hide' : 'Show'} the terminal (${keys})`; const rect = state === State.terminal ? null : shown(); Object.assign(panel.style, rect ? {left: `${rect.x}px`, top: `${rect.y}px`, width: `${rect.width}px`, height: `${rect.height}px`} : {left: '', top: '', width: '', height: ''}); @@ -246,7 +270,7 @@ export async function createWorkspace({bridge, element, frame}) { // The shortcut works wherever the focus is: in this page and in the interface, whose window changes at each load. const onKey = event => { - if (!isToggleKey(event) || state === State.terminal) return; + if (!isToggleKey(event, shortcut) || state === State.terminal) return; event.preventDefault(); event.stopPropagation(); apply('toggle'); @@ -317,7 +341,7 @@ export async function createWorkspace({bridge, element, frame}) { render(); return { get state() { return state; }, - interfaceExists, button, panel, bar, + interfaceExists, button, panel, bar, shortcut: keys, attach({focus, fit = () => {}}) { focusTerminal = focus; fitTerminal = fit; diff --git a/test/developer/specs/manifest-specs.mjs b/test/developer/specs/manifest-specs.mjs index 621b57db..79410902 100644 --- a/test/developer/specs/manifest-specs.mjs +++ b/test/developer/specs/manifest-specs.mjs @@ -1,5 +1,5 @@ // Specs of the project manifest, its agreement with the lock and the joint publication of both. -import {validateManifest, parseManifest, serializeManifest, manifestName, dependenciesDigest} from '../../../js/developer/environment/manifest.mjs'; +import {validateManifest, parseManifest, serializeManifest, manifestName, dependenciesDigest, parseShortcut} from '../../../js/developer/environment/manifest.mjs'; import {install, initProject, loadProject, syncNotice, resolveEntry, embedTarget, lockPath, manifestPath, setManifestDirectory, checkWrite} from '../../../js/developer/environment/packages.bundle.mjs'; import {compress} from '../../../js/developer/environment/embed.mjs'; import {tar} from '../../../js/developer/tools/archive.mjs'; @@ -19,7 +19,8 @@ describe('The project manifest', () => { const full = {...minimal, dependencies: {react: '^19.0.0', '@scope/lib': '>=1.2.0 <2', tool: 'latest'}, registry: 'https://registry.test/', scripts: {build: 'wf embed main'}, entries: {main: 'ui/main.tsx'}, providers: {AppUI: {entry: 'main', output: 'generated/AppUI.hpp'}}, test: {specs: ['spec/a.mjs']}, - permissions: {files: ['ui'], publish: ['generated'], fetch: ['https://registry.npmjs.org']}}; + permissions: {files: ['ui'], publish: ['generated'], fetch: ['https://registry.npmjs.org']}, + developer: {terminalShortcut: 'Ctrl+Shift+F9'}}; const text = serializeManifest(validateManifest(full)); expect(JSON.parse(text)).toEqual(full); expect(serializeManifest(parseManifest(encode(text)))).toBe(text); @@ -50,12 +51,24 @@ describe('The project manifest', () => { [{...minimal, permissions: {files: ['a/../../b']}}, /safe project-relative path/], [{...minimal, permissions: {fetch: ['http://plain.test']}}, /https origin/], [{...minimal, permissions: {fetch: ['https://registry.test/path']}}, /without a path/], + [{...minimal, developer: {terminalShortcut: 'Ctrl+C'}}, /developer\.terminalShortcut must be a function key/], + [{...minimal, developer: {terminalShortcut: 9}}, /developer\.terminalShortcut must be a function key/], + [{...minimal, developer: {shortcut: 'F9'}}, /unknown key "shortcut" in developer/], + [{...minimal, developer: 'F9'}, /developer must be an object/], [[], /must be an object/], ]; for (const [value, message] of cases) throws(() => validateManifest(value), message); throws(() => parseManifest(encode('{')), /not valid JSON/); }); + it('a terminal shortcut is a function key with any of the four modifiers', () => { + expect(parseShortcut('F9')).toEqual({key: 'F9', ctrlKey: false, altKey: false, shiftKey: false, metaKey: false}); + expect(parseShortcut('Shift+Ctrl+F12')).toEqual({key: 'F12', ctrlKey: true, altKey: false, shiftKey: true, metaKey: false}); + expect(parseShortcut('Alt+Meta+F1')).toEqual({key: 'F1', ctrlKey: false, altKey: true, shiftKey: false, metaKey: true}); + for (const text of ['', 'F0', 'F13', 'f9', 'Ctrl+', 'Ctrl+C', 'ctrl+F9', 'Ctrl+Ctrl+F9', 'Ctrl+F9+Shift', 'F9 ', 'hasOwnProperty+F9', undefined, 9]) + expect(parseShortcut(text)).toBeNull(); + }); + it('the dependency digest ignores key order and changes with any range', async () => { const first = await dependenciesDigest({a: '^1.0.0', b: '2.0.0'}); expect(first).toBe(await dependenciesDigest({b: '2.0.0', a: '^1.0.0'})); diff --git a/test/developer/specs/workspace-specs.mjs b/test/developer/specs/workspace-specs.mjs index c01cecc2..e04970b6 100644 --- a/test/developer/specs/workspace-specs.mjs +++ b/test/developer/specs/workspace-specs.mjs @@ -1,7 +1,7 @@ // Specs of the developer page's layout (workspace.mjs): what counts as an existing interface, the states of the display, // and the place of the floating terminal window. The page itself is checked in test/web/developer-specs.mjs. import {hasInterface, previewDirectory, State, initialState, nextState, clampRect, defaultRect, keyboardRect, minimumSize, step, - isToggleKey, parsePlace, formatPlace, readPlace, placeStore, placePath} from '../../../js/developer/environment/workspace.mjs'; + isToggleKey, defaultShortcut, shortcutText, readShortcut, parsePlace, formatPlace, readPlace, placeStore, placePath} from '../../../js/developer/environment/workspace.mjs'; import {publish} from '../../../js/developer/environment/io.mjs'; import {memoryBridge} from '../memory-bridge.mjs'; @@ -110,6 +110,21 @@ describe('The developer page layout', () => { expect(isToggleKey({key: 'c', ctrlKey: true})).toBeFalse(); }); + it('is toggled by the shortcut of the project\'s manifest instead, which leaves F9 to the application', async () => { + const manifest = developer => encode(JSON.stringify({format: 1, name: 'app', version: '0.1.0', ...developer})); + const {bridge} = memoryBridge(new Map([['webfront.project.json', manifest({developer: {terminalShortcut: 'Ctrl+Shift+F9'}})]])); + const shortcut = await readShortcut(bridge); + expect(shortcutText(shortcut)).toBe('Ctrl+Shift+F9'); + expect(isToggleKey({key: 'F9'}, shortcut)).toBeFalse(); + expect(isToggleKey({key: 'F9', ctrlKey: true}, shortcut)).toBeFalse(); + expect(isToggleKey({key: 'F9', ctrlKey: true, shiftKey: true, altKey: true}, shortcut)).toBeFalse(); + expect(isToggleKey({key: 'F9', ctrlKey: true, shiftKey: true}, shortcut)).toBeTrue(); + // No manifest, no key, or a manifest that is not valid: F9. + for (const files of [[], [['webfront.project.json', manifest({})]], [['webfront.project.json', manifest({developer: {terminalShortcut: 'Ctrl+C'}})]]]) + expect(shortcutText(await readShortcut(memoryBridge(new Map(files)).bridge))).toBe('F9'); + expect(shortcutText(defaultShortcut)).toBe('F9'); + }); + it('is read from a well-formed file only', () => { const rect = {x: 12, y: 34, width: 500, height: 280}; expect(parsePlace(formatPlace(rect))).toEqual(rect); diff --git a/test/web/developer-specs.mjs b/test/web/developer-specs.mjs index 04313b18..8aca3f79 100644 --- a/test/web/developer-specs.mjs +++ b/test/web/developer-specs.mjs @@ -1055,10 +1055,26 @@ try { otherPreview.id = 'preview'; otherPreview.hidden = true; otherPage.body.append(otherPreview); + // An application that uses F9 names another shortcut in its manifest: this page reads it when it opens. + const plainManifest = new TextDecoder().decode(await readFile('webfront.project.json')); + await writeFile('webfront.project.json', JSON.stringify({...JSON.parse(plainManifest), developer: {terminalShortcut: 'Ctrl+Shift+F9'}})); const mounted = await other.runtime.mount({bridge: other.bridge, config, terminal: otherPage.getElementById('terminal'), preview: otherPreview, onExit: () => {}}); + await writeFile('webfront.project.json', plainManifest); const {terminal, editor, workspace} = mounted; const there = layout(otherPage); assert(workspace && there.state() === 'interface' && workspace.state === 'interface', `The mounted page must open on the interface: ${there.state()}`); + await until(() => otherPreview.contentDocument?.getElementById('root'), 'The mounted page must load the interface'); + const received = []; + otherPreview.contentDocument.addEventListener('keydown', event => received.push(event.key)); + const untouched = key(otherPreview.contentDocument.body, {key: 'F9'}); + assert(untouched && received.join() === 'F9' && there.state() === 'interface', `F9 must reach an application whose project names another shortcut: ${received}, ${there.state()}`); + const taken = key(otherPreview.contentDocument.body, {key: 'F9', ctrlKey: true, shiftKey: true}); + assert(!taken && received.join() === 'F9' && there.state() === 'floating', `The project's shortcut must open the terminal: ${there.state()}`); + key(otherPage.querySelector('#terminal .xterm-helper-textarea'), {key: 'F9', ctrlKey: true, shiftKey: true}); + assert(there.state() === 'interface', 'The project\'s shortcut must collapse the terminal'); + const toggleButton = otherPage.querySelector('.webfront-terminal-toggle'); + assert(workspace.shortcut === 'Ctrl+Shift+F9' && /Ctrl\+Shift\+F9/.test(toggleButton.title) && toggleButton.getAttribute('aria-keyshortcuts') === 'Control+Shift+F9', + `The icon must name the project's shortcut: ${toggleButton.title}`); // The place remembered by the other page is the one of the project. assert(Math.round(there.box('.webfront-terminal-window').left) === remembered.x, 'The remembered place must be the project\'s'); // A second terminal in the page leaves its layout alone. From 9e121dd2a65165fc59c20ec377aa0c5f7f2a7989 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Wed, 11 Nov 2026 08:42:50 +0100 Subject: [PATCH 07/11] Wait for the interface to finish loading before typing the project's shortcut in it (#539) --- test/web/developer-specs.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/web/developer-specs.mjs b/test/web/developer-specs.mjs index 8aca3f79..310137c4 100644 --- a/test/web/developer-specs.mjs +++ b/test/web/developer-specs.mjs @@ -1063,7 +1063,9 @@ try { const {terminal, editor, workspace} = mounted; const there = layout(otherPage); assert(workspace && there.state() === 'interface' && workspace.state === 'interface', `The mounted page must open on the interface: ${there.state()}`); - await until(() => otherPreview.contentDocument?.getElementById('root'), 'The mounted page must load the interface'); + // The page installs the shortcut in the interface once its document is loaded. + await until(() => otherPreview.contentDocument?.getElementById('root') && otherPreview.contentDocument.readyState === 'complete', + 'The mounted page must load the interface'); const received = []; otherPreview.contentDocument.addEventListener('keydown', event => received.push(event.key)); const untouched = key(otherPreview.contentDocument.body, {key: 'F9'}); From 714413464f14ef85766c025c3daaa81bb9c38010 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Wed, 11 Nov 2026 09:12:53 +0100 Subject: [PATCH 08/11] Replace the round icon with a tab on the window's edge that shows the session's state (#539) The tab hugs the right edge, in the greens of the logo. Its mark tells what the collapsed terminal does: nothing, a running command or a build, wf dev watching, or a failed build. wf dev reports its state on the preview frame. --- docs/CHANGELOG.md | 2 +- docs/DEVELOPER_ENVIRONMENT.md | 15 +++-- docs/PROJECT_STATUS.md | 2 +- js/developer/environment/bundles.json | 6 +- js/developer/environment/development.mjs | 8 ++- js/developer/environment/runtime.mjs | 6 +- js/developer/environment/workspace.mjs | 72 +++++++++++++++++++----- test/developer/specs/workspace-specs.mjs | 14 ++++- test/web/developer-specs.mjs | 15 ++++- 9 files changed, 109 insertions(+), 31 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ea708104..d8a943e1 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -12,7 +12,7 @@ these entries stays in the GitHub releases and the Git history. ### Changed -- Open the developer page on the interface, over the whole window, once the project has a preview; the terminal moves to a floating, movable window behind an icon at the top right, and keeps its session when collapsed. Its shortcut is F9, or the manifest's new optional `developer.terminalShortcut`. Environment sources 0.9.1, not published yet (#539, `docs/DEVELOPER_ENVIRONMENT.md`). +- Open the developer page on the interface, over the whole window, once the project has a preview; the terminal moves to a floating, movable window behind a tab on the right edge that shows the session's state, and keeps its session when collapsed. Its shortcut is F9, or the manifest's new optional `developer.terminalShortcut`. Environment sources 0.9.1, not published yet (#539, `docs/DEVELOPER_ENVIRONMENT.md`). ## [0.9.0] - 2026-11-10 diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index 67cae8d0..abe5db6d 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -374,15 +374,15 @@ The page of `bootstrap("developer")` shows one thing at a time by default (envir environment's `mount`, not to the embedded bootstrap page): - **No interface yet** (first launch, or a project that never ran `wf dev` or `wf preview`): the terminal alone, under the - status line. No icon and no empty preview are shown, also when the first build of `wf dev` fails: its diagnostic is in + status line. No tab and no empty preview are shown, also when the first build of `wf dev` fails: its diagnostic is in the terminal. - **An interface exists**: the page opens on it, over the whole window, with the terminal collapsed. "Exists" means a published preview, `.webfront/developer/preview/index.html`. `wf dev` and `wf preview` publish it; `wf create` and `wf build` (which publishes under `build/`) do not. A publication replaces the directory in one step, so an interrupted `wf dev` or a failed build leaves the last successful interface, which the next launch shows as it was built: run `wf dev` to rebuild it. -- **The icon** with the WebFront swallow, at the top right over the interface, opens the terminal in a **floating window**; - the icon again, the window's close button or **F9** (in the terminal or in the interface) collapses it. Collapsing only +- **The tab** with the WebFront swallow, against the right edge of the window over the interface, opens the terminal in a + **floating window**; the tab again, the window's close button or **F9** (in the terminal or in the interface) collapses it. Collapsing only hides the terminal: the session, its scrollback, the line being typed and a running command (`wf dev`, `wf test`) are kept, and the keys go back to the interface. The first preview of a session leaves the terminal open over the interface, since it is in use. A notice of automation opens it, so that the notice is seen. @@ -390,18 +390,21 @@ environment's `mount`, not to the embedded bootstrap page): bottom-right corner resizes with the pointer. The window stays inside the browser window, shrinks with it and returns to its place when there is room again; xterm.js is fitted to it. Its place and size are kept per project in `.webfront/developer/terminal-window.json`. +- **The tab shows the session's state**, so that a collapsed terminal still tells what it does: three bars when nothing + runs, a ring while a command runs or `wf dev` builds, a full dot when `wf dev` has built the interface and watches its + inputs, an amber diamond when the last build failed. The tab's name and tooltip say it in words. - **The shortcut** is F9 by default. The developer page takes it before the interface does, so an application that uses F9 itself names another one in its manifest, and receives F9 as it does in its embedded form: `"developer": {"terminalShortcut": "Ctrl+Shift+F9"}`. A shortcut is a function key, F1 to F12, optionally after `Ctrl`, `Alt`, `Shift` or `Meta`, joined by `+`; anything else is a manifest error. The page reads it when it opens: relaunch - the application after changing it. The icon's tooltip names the shortcut in use. + the application after changing it. The tab's tooltip names the shortcut in use. - While the terminal is collapsed, `wf dev` keeps reloading the full-window interface, and a failed build still shows its diagnostic over it. -The icon is a button (`aria-expanded`, 44 px target) and the window a non-modal dialog. The interface stays in the preview +The tab is a button (`aria-expanded`, 44 px target) and the window a non-modal dialog. The interface stays in the preview frame, as before: the layout adds nothing to the application's documents except the shortcut's listener, installed in the interface and in the same-origin frames it embeds (not in a frame of another origin, nor one inside a shadow tree: click the interface -or the icon first). This is a layout, not a +or the tab first). This is a layout, not a sandbox (see [limitations](#dependencies-storage-and-limitations)). A page that mounts the terminal itself (`runtime.mount`) with a preview frame gets the same layout; `workspace: false` keeps the page as it is. diff --git a/docs/PROJECT_STATUS.md b/docs/PROJECT_STATUS.md index fc64e859..f5431a92 100644 --- a/docs/PROJECT_STATUS.md +++ b/docs/PROJECT_STATUS.md @@ -20,7 +20,7 @@ WebFront is a header-only C++23 HTTP/WebSocket core plus a standalone developer dependencies, entries, providers, scripts and permissions. TypeScript/TSX compilation uses esbuild-wasm; type checking uses the project's locked TypeScript. Application commands use `webfront::Commands`. From environment 0.9.1 (sources; the pin is still 0.9.0), a project that has a preview opens - on its interface over the whole window, with the terminal in a floating window behind an icon. See the + on its interface over the whole window, with the terminal in a floating window behind a tab on the window's edge. See the [developer reference](DEVELOPER_ENVIRONMENT.md). - **Distribution.** `wf embed` generates the application's compressed C++ provider. `NativeAppWithAssets` runs without project files, developer callbacks or tool cache. diff --git a/js/developer/environment/bundles.json b/js/developer/environment/bundles.json index 2d62be0a..1b84ed83 100644 --- a/js/developer/environment/bundles.json +++ b/js/developer/environment/bundles.json @@ -17,12 +17,12 @@ "js/developer/environment/packages.mjs": "37fe2a410e211264cfeaedbff3df50f7e62b02f8088130127d94f92081e2a5ad", "js/developer/environment/starter.mjs": "89ccab43be4455ed9598c54355b4bbe5adea1afd7a0ae5d755a14317e3ca39df", "js/developer/environment/paths.mjs": "3b6114df78eb193161c5c84499dda084cb7ff91c56a4496371c30295d00880e3", - "js/developer/environment/runtime.mjs": "66588ff076db7837d7c859bc9b09f366091dd89582b06ca1da9cd42ed7946406", + "js/developer/environment/runtime.mjs": "15daf498e0cee6697962e4e8decaea7e169d8c228d86d3436aa72b72403ada03", "js/developer/environment/automation.mjs": "79405c89ba7025c1774bc13c9b78d814a07592755dcde018c8659a8015c4b8ed", - "js/developer/environment/development.mjs": "1125043016727111031a452fbebec358b9e78231f82fe91df7dea0fe8b22f015", + "js/developer/environment/development.mjs": "39feb6bb507270228bf8de065c26d9d5e3fad3ade48bfe429458ca273d36ad3a", "js/developer/environment/testing.mjs": "aeb584505fab5957b9c02e78536e12f7d7f3d12f8adb2e17f1a1a6e395e43f3c", "js/developer/environment/terminal.mjs": "7ffcf7ac6ef63c35cdf5ef70284b384525b13ba18422af069289e53b6c4f6be1", - "js/developer/environment/workspace.mjs": "0c7cadd37af3397b73c37b54daa01709b196e27dc8a83f519774b6c5f422e06a", + "js/developer/environment/workspace.mjs": "0b628295dc133ab2c34cb48f3c8f361e7bf5071ad027828bccf7d7198c0a2e6f", "js/developer/environment/tarball.mjs": "1c1e1aea067910e1fec74e85b4bf9fbefed9b38187a04d8d2764f0b9a96fca39", "js/developer/environment/commands.mjs": "8de20c01f02f33c0566f204fcf1ee2382a23344d2103581fe2914469ec570531", "js/developer/environment/compiler.mjs": "0158931132aa9b43b7bbbd01de6fa4fc34fce8c65515d593dd494930f7a1910f", diff --git a/js/developer/environment/development.mjs b/js/developer/environment/development.mjs index ed6fa7e4..220ea537 100644 --- a/js/developer/environment/development.mjs +++ b/js/developer/environment/development.mjs @@ -195,9 +195,12 @@ export async function dev(args, {bridge, signal, preview: frame, write = () => { let diagnostic = ''; const loaded = () => previewDiagnostics(frame, diagnostic); frame?.addEventListener('load', loaded); + // The page shows where the loop is (workspace.mjs): building, ready, failed, then stopped. + const report = state => frame?.dispatchEvent?.(new CustomEvent('webfront-dev-status', {detail: {state}})); try { for (;;) { active.throwIfAborted(); + report('building'); const configReads = new Map(), budget = {bytes: 0}; try { await withBuild(async () => { @@ -219,12 +222,14 @@ export async function dev(args, {bridge, signal, preview: frame, write = () => { showPreview(frame); // A successful build can drop dependencies that are no longer imported. observed = new Map(session.observed); + report('ready'); write(syncNotice(project) + 'Preview ready. Watching inputs (Ctrl+C to stop).\n'); }); } catch (error) { if (active.aborted) throw stopped(); if (error?.code === 'busy') { await waitForPoll(active); continue; } diagnostic = diagnosticsText(error); + report('failed'); write(diagnostic + '\n'); previewDiagnostics(frame, diagnostic); if (session?.observed.size) observed = new Map(session.observed); @@ -238,7 +243,7 @@ export async function dev(args, {bridge, signal, preview: frame, write = () => { if (active.aborted) throw stopped(); // A temporarily unreadable file or a bound violation cannot publish or reload anything. const text = diagnosticsText(error); - if (diagnostic !== text) { diagnostic = text; write(text + '\n'); previewDiagnostics(frame, text); } + if (diagnostic !== text) { diagnostic = text; report('failed'); write(text + '\n'); previewDiagnostics(frame, text); } } } } @@ -254,5 +259,6 @@ export async function dev(args, {bridge, signal, preview: frame, write = () => { bridge.socket?.removeEventListener('close', disconnected); frame?.removeEventListener('load', loaded); previewDiagnostics(frame, ''); + report('stopped'); } } diff --git a/js/developer/environment/runtime.mjs b/js/developer/environment/runtime.mjs index 6a85e886..2f52be17 100644 --- a/js/developer/environment/runtime.mjs +++ b/js/developer/environment/runtime.mjs @@ -576,7 +576,11 @@ export async function mount({bridge, config, terminal: element, preview, onExit, const context = {bridge, config, preview, cppCommands, onExit}; const editor = new LineEditor({write, columns: () => terminal.cols, rows: () => terminal.rows, prompt: '> ', history, remember: line => rememberLine(bridge, line), - run: (line, signal) => runLine(line, {...context, editor, signal, write: text => editor.write(text)}), + run: async (line, signal) => { + workspace?.command(true); // the tab shows that a command runs, also while the terminal is collapsed + try { return await runLine(line, {...context, editor, signal, write: text => editor.write(text)}); } + finally { workspace?.command(false); } + }, complete: line => complete(line, context)}); terminal.onResize(() => editor.resized()); // An element without a size is not laid out: fitting to it would shrink the terminal and reflow its lines. diff --git a/js/developer/environment/workspace.mjs b/js/developer/environment/workspace.mjs index 0a87ecc9..a7124a19 100644 --- a/js/developer/environment/workspace.mjs +++ b/js/developer/environment/workspace.mjs @@ -1,5 +1,5 @@ // The layout of the developer page: the terminal alone while the project has no interface, then the interface over the -// whole window with the terminal in a floating, movable window that an icon opens and collapses. The terminal is mounted +// whole window with the terminal in a floating, movable window that a tab on the right edge opens and collapses. The terminal is mounted // once in its window and never moves in the document afterwards: collapsing only hides it, so the session, a running // command, the line being typed and the scrollback are kept. The interface stays in the preview frame. import {call, readProject, publish} from './io.mjs'; @@ -92,6 +92,23 @@ export async function readShortcut(bridge) { catch { return defaultShortcut; } } +// --- Status ---------------------------------------------------------------------------------------------------- + +/** + * What the tab shows of the session behind it: `idle`, `running` (a command), or where wf dev is: `building`, `ready` + * (the interface is built and its inputs are watched) and `failed` (the last build). + */ +export const Status = {idle: 'idle', running: 'running', building: 'building', ready: 'ready', failed: 'failed'}; +const devStates = [Status.building, Status.ready, Status.failed]; + +/** The status of a session: the state wf dev reports while it runs (anything else means it does not), else whether a command runs. */ +export const tabStatus = ({command = false, dev = null} = {}) => devStates.includes(dev) ? dev : command ? Status.running : Status.idle; + +const statusTexts = {[Status.idle]: '', [Status.running]: 'a command is running', [Status.building]: 'wf dev is building', + [Status.ready]: 'wf dev is watching', [Status.failed]: 'the last build failed'}; +/** The status in words, for the tab's name; empty when nothing runs. */ +export const statusText = status => Object.hasOwn(statusTexts, status) ? statusTexts[status] : ''; + // --- Remembered place ------------------------------------------------------------------------------------------ /** The place of the window, kept in the project like the history: each project has its own. */ @@ -147,13 +164,12 @@ export function placeStore(bridge, delay = 300) { // --- Page ------------------------------------------------------------------------------------------------------ -// The WebFront swallow, shipped in the environment. -const logo = ''; +// The WebFront swallow, shipped in the environment, in the colours of the tab. +const logo = ''; const attribute = 'data-webfront-workspace'; const floating = `:root:is([${attribute}=interface],[${attribute}=floating])`; @@ -166,10 +182,23 @@ ${floating} .webfront-terminal-window{position:fixed;z-index:2147483646;border:1 :root[${attribute}=interface] .webfront-terminal-window{visibility:hidden} .webfront-terminal-bar{display:none;flex:none;align-items:center;justify-content:space-between;padding:0 4px 0 12px;background:#202737;color:#e8edf4;font:13px system-ui;cursor:move;user-select:none;touch-action:none} ${floating} .webfront-terminal-bar{display:flex} -.webfront-terminal-bar:focus-visible,.webfront-terminal-close:focus-visible,.webfront-terminal-toggle:focus-visible{outline:2px solid #d7fa85;outline-offset:-2px} +.webfront-terminal-bar:focus-visible,.webfront-terminal-close:focus-visible{outline:2px solid #d7fa85;outline-offset:-2px} .webfront-terminal-close{margin:0;padding:0;width:32px;height:32px;border:0;background:none;color:inherit;font:20px/1 system-ui;cursor:pointer} -.webfront-terminal-toggle{position:fixed;top:8px;right:8px;z-index:2147483647;margin:0;padding:0;width:44px;height:44px;display:grid;place-items:center;border:1px solid #46536a;border-radius:50%;background:#f6f7f2;box-shadow:0 2px 8px #0006;cursor:pointer;opacity:.9} -.webfront-terminal-toggle:hover,.webfront-terminal-toggle[aria-expanded=true]{opacity:1} +.webfront-terminal-toggle{position:fixed;top:max(0px,min(64px,100vh - 88px));right:0;z-index:2147483647;margin:0;padding:0;width:44px;height:88px;max-height:100vh;display:flex;justify-content:flex-end;border:0;background:none;cursor:pointer} +.webfront-terminal-tab{box-sizing:border-box;width:30px;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;border-radius:12px 0 0 12px;background:#203b30;color:#f6f7f2;--webfront-accent:#d7fa85;box-shadow:0 2px 8px #0006;opacity:.92} +.webfront-terminal-toggle:hover .webfront-terminal-tab,.webfront-terminal-toggle:focus-visible .webfront-terminal-tab{opacity:1} +.webfront-terminal-toggle:focus-visible{outline:none} +.webfront-terminal-toggle:focus-visible .webfront-terminal-tab{outline:2px solid #d7fa85;outline-offset:2px} +.webfront-terminal-toggle[aria-expanded=true] .webfront-terminal-tab{background:#d7fa85;color:#203b30;--webfront-accent:#203b30;opacity:1} +.webfront-terminal-toggle[aria-expanded=true]:focus-visible .webfront-terminal-tab{outline-color:#203b30} +.webfront-terminal-status{box-sizing:border-box;width:10px;height:10px;color:var(--webfront-accent)} +[data-status=idle] .webfront-terminal-status{height:2px;border-radius:1px;background:currentColor;box-shadow:0 -5px,0 5px} +:is([data-status=running],[data-status=building]) .webfront-terminal-status{border:2px solid;border-radius:50%;animation:webfront-terminal-working 1.2s ease-in-out infinite alternate} +[data-status=ready] .webfront-terminal-status{border-radius:50%;background:currentColor} +[data-status=failed] .webfront-terminal-status{width:9px;height:9px;background:#ffbd2e;transform:rotate(45deg)} +[data-status=failed][aria-expanded=true] .webfront-terminal-status{background:#8a3d00} +@keyframes webfront-terminal-working{to{opacity:.35}} +@media (prefers-reduced-motion:reduce){.webfront-terminal-status{animation:none!important}} :root[${attribute}=terminal] .webfront-terminal-toggle,:root[${attribute}=terminal] .webfront-interface{display:none} `; @@ -181,7 +210,7 @@ export const isManaged = frame => managed.has(frame); * Lays the page out around the terminal's `element` and the preview `frame`, which starts hidden. Call it before the * terminal opens in `element`, then attach({focus, fit}) with the functions that focus the terminal and fit it to `element`. * The result gives the `state`, `interfaceExists` (the page opened on an existing interface, to load in the frame), - * toggle(), open({focus}) and close(), `button` and `panel`, the `shortcut` in use ("F9") and placeSaved(). + * the `status` shown on the tab and command(running) to say that a command runs, toggle(), open({focus}) and close(), `button` and `panel`, the `shortcut` in use ("F9") and placeSaved(). */ export async function createWorkspace({bridge, element, frame}) { managed.add(frame); @@ -193,6 +222,7 @@ export async function createWorkspace({bridge, element, frame}) { let state = initialState(interfaceExists); let place = remembered; // as chosen; what is displayed is fitted to the viewport let focusTerminal = () => {}, fitTerminal = () => {}; + const session = {command: false, dev: null}; const style = page.createElement('style'); style.textContent = styles; @@ -227,7 +257,7 @@ export async function createWorkspace({bridge, element, frame}) { const button = page.createElement('button'); button.type = 'button'; button.className = 'webfront-terminal-toggle'; - button.innerHTML = logo; + button.innerHTML = `${logo}`; button.setAttribute('aria-controls', panel.id); button.setAttribute('aria-keyshortcuts', keys.replace('Ctrl', 'Control')); page.body.append(button); @@ -238,8 +268,10 @@ export async function createWorkspace({bridge, element, frame}) { root.setAttribute(attribute, state); const open = state === State.floating; button.setAttribute('aria-expanded', String(open)); - button.setAttribute('aria-label', open ? 'Hide the WebFront terminal' : 'Show the WebFront terminal'); - button.title = `${open ? 'Hide' : 'Show'} the terminal (${keys})`; + const status = tabStatus(session), words = statusText(status); + button.dataset.status = status; + button.setAttribute('aria-label', `${open ? 'Hide' : 'Show'} the WebFront terminal${words && `: ${words}`}`); + button.title = `${open ? 'Hide' : 'Show'} the terminal (${keys})${words && `: ${words}`}`; const rect = state === State.terminal ? null : shown(); Object.assign(panel.style, rect ? {left: `${rect.x}px`, top: `${rect.y}px`, width: `${rect.width}px`, height: `${rect.height}px`} : {left: '', top: '', width: '', height: ''}); @@ -266,6 +298,10 @@ export async function createWorkspace({bridge, element, frame}) { // of a failed build: before any preview, the frame stays out of the page and the terminal, which prints the // diagnostic too, keeps the window. frame.addEventListener('webfront-preview-navigating', () => apply('shown')); + frame.addEventListener('webfront-dev-status', event => { + session.dev = event.detail?.state ?? null; + render(); + }); new view.MutationObserver(() => { if (frame.hidden) apply('hidden'); }).observe(frame, {attributes: true, attributeFilter: ['hidden']}); // The shortcut works wherever the focus is: in this page and in the interface, whose window changes at each load. @@ -341,6 +377,12 @@ export async function createWorkspace({bridge, element, frame}) { render(); return { get state() { return state; }, + get status() { return tabStatus(session); }, + /** Tells whether a command runs in the terminal. */ + command(running) { + session.command = Boolean(running); + render(); + }, interfaceExists, button, panel, bar, shortcut: keys, attach({focus, fit = () => {}}) { focusTerminal = focus; diff --git a/test/developer/specs/workspace-specs.mjs b/test/developer/specs/workspace-specs.mjs index e04970b6..d7ef2ab6 100644 --- a/test/developer/specs/workspace-specs.mjs +++ b/test/developer/specs/workspace-specs.mjs @@ -1,7 +1,7 @@ // Specs of the developer page's layout (workspace.mjs): what counts as an existing interface, the states of the display, // and the place of the floating terminal window. The page itself is checked in test/web/developer-specs.mjs. import {hasInterface, previewDirectory, State, initialState, nextState, clampRect, defaultRect, keyboardRect, minimumSize, step, - isToggleKey, defaultShortcut, shortcutText, readShortcut, parsePlace, formatPlace, readPlace, placeStore, placePath} from '../../../js/developer/environment/workspace.mjs'; + isToggleKey, Status, tabStatus, statusText, defaultShortcut, shortcutText, readShortcut, parsePlace, formatPlace, readPlace, placeStore, placePath} from '../../../js/developer/environment/workspace.mjs'; import {publish} from '../../../js/developer/environment/io.mjs'; import {memoryBridge} from '../memory-bridge.mjs'; @@ -103,6 +103,18 @@ describe('The developer page layout', () => { expect(keyboardRect(rect, {key: 'a'}, viewport)).toBeNull(); }); + it('shows on its tab where wf dev is, else whether a command runs', () => { + expect(tabStatus()).toBe(Status.idle); + expect(tabStatus({command: true})).toBe(Status.running); + for (const dev of [Status.building, Status.ready, Status.failed]) expect(tabStatus({command: true, dev})).toBe(dev); + // wf dev stopped, or a state this page does not know: the command decides. + expect(tabStatus({command: true, dev: 'stopped'})).toBe(Status.running); + expect(tabStatus({command: false, dev: 'toString'})).toBe(Status.idle); + expect(statusText(Status.idle)).toBe(''); + for (const status of [Status.running, Status.building, Status.ready, Status.failed]) expect(statusText(status)).not.toBe(''); + expect(new Set(Object.values(Status).map(statusText)).size).toBe(5); + }); + it('is toggled by F9 alone', () => { expect(isToggleKey({key: 'F9'})).toBeTrue(); expect(isToggleKey({key: 'F9', ctrlKey: true})).toBeFalse(); diff --git a/test/web/developer-specs.mjs b/test/web/developer-specs.mjs index 310137c4..700a9eb5 100644 --- a/test/web/developer-specs.mjs +++ b/test/web/developer-specs.mjs @@ -900,8 +900,11 @@ try { const button = again.button(), icon = again.box('.webfront-terminal-toggle'); assert(button.tagName === 'BUTTON' && button.getAttribute('aria-expanded') === 'false' && /terminal/i.test(button.getAttribute('aria-label')) && button.getAttribute('aria-controls') === again.panel().id, 'The icon must be a named button that controls the terminal window'); - assert(button.querySelector('svg') && icon.width >= 44 && icon.height >= 44 && icon.top <= 16 && again.viewport().width - icon.right <= 16, - `The icon must be a large enough target at the top right: ${JSON.stringify(icon)}`); + const tab = again.box('.webfront-terminal-tab'); + assert(button.querySelector('svg') && icon.width >= 44 && icon.height >= 44 && icon.top <= 96 && Math.round(icon.right) === again.viewport().width + && Math.round(tab.right) === again.viewport().width && tab.width < icon.width, + `The icon must be a large enough target against the right edge: ${JSON.stringify(icon)}`); + assert(button.dataset.status === 'idle' && again.style('.webfront-terminal-status').height === '2px', `The tab must show that nothing runs: ${button.dataset.status}`); assert(page.elementFromPoint(icon.left + icon.width / 2, icon.top + icon.height / 2)?.closest('button') === button, 'The icon must stay over the interface'); assert(page.activeElement === pagePreview, 'The keys must go to the interface while the terminal is collapsed'); const session = page.querySelector('#terminal .xterm'); @@ -1025,6 +1028,8 @@ try { await poll(); await until(shows('layout-two'), 'wf dev must reload the full-window interface'); assert(again.state() === 'interface' && again.fills('#preview'), 'A reload must leave the terminal collapsed'); + await until(() => button.dataset.status === 'ready', `The tab must show that wf dev watches: ${button.dataset.status}`); + assert(/wf dev is watching/.test(button.getAttribute('aria-label')), 'The tab must name the state of wf dev'); // The interface of a new document still gets the shortcut. key(pagePreview.contentDocument.body, {key: 'F9'}); assert(again.state() === 'floating', 'F9 must work in a reloaded interface'); @@ -1032,6 +1037,8 @@ try { await writeFile('layout/value.ts', 'export const value = ;\n'); await poll(); await until(() => pagePreview.contentDocument?.getElementById('webfront-build-diagnostics'), 'A failed build must show its diagnostic in the interface'); + assert(button.dataset.status === 'failed' && /the last build failed/.test(button.getAttribute('aria-label')) && again.style('.webfront-terminal-status').transform !== 'none', + `The tab must show a failed build while the terminal is collapsed: ${button.dataset.status}`); assert(again.state() === 'interface' && shows('layout-two')() && /layout\/value.ts:1:/.test(pagePreview.contentDocument.getElementById('webfront-build-diagnostics').textContent), 'The diagnostic must cover the last interface built, with the terminal collapsed'); const overlay = pagePreview.contentDocument.getElementById('webfront-build-diagnostics').getBoundingClientRect(); @@ -1040,6 +1047,7 @@ try { } finally { devStop.abort(); } assert((await devResult)?.exitCode === 130, 'Ctrl+C must stop dev with exit code 130'); }); + assert(button.dataset.status === 'idle', `The tab must show that wf dev stopped: ${button.dataset.status}`); // A failed build keeps the last interface published: the next launch still opens on it. assert((await listed('.webfront/developer/preview')).includes('index.html'), 'A failed build must keep the published interface'); relaunched.remove(); @@ -1119,12 +1127,15 @@ try { workspace.close(); await delay(150); assert(there.state() === 'interface' && (await commandState('layout')) === 'running' && editor.busy, 'Collapsing must not interrupt a running command'); + assert(toggleButton.dataset.status === 'running' && workspace.status === 'running' && /a command is running/.test(toggleButton.getAttribute('aria-label')), + `The tab must show a running command while the terminal is collapsed: ${toggleButton.dataset.status}`); workspace.open(); assert((await commandState('layout')) === 'running', 'Opening must not interrupt a running command'); terminal.input('\x03'); await editor.whenIdle(); await rendered(); await until(async () => (await commandState('layout')) === 'cancelled', 'Ctrl+C must still reach the command'); + assert(toggleButton.dataset.status === 'idle', `The tab must show that the command ended: ${toggleButton.dataset.status}`); assert(/waiting layout/.test(screen()) && /^layout kept$/m.test(screen()), 'Ctrl+C must still reach the command, in the same session'); await mounted.workspace.placeSaved(); From 564db1b12fc763d59f8b2145b656a391220725bb Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Wed, 11 Nov 2026 09:47:35 +0100 Subject: [PATCH 09/11] Take the terminal's shortcut before the application's own listeners (#539) The listener was installed in the interface at its load, after the application's scripts: a capture listener of the application on its window got the shortcut first. The page of a preview now announces its window before its scripts run, so the developer page's listener is the first of that window, and it stops the other listeners of the same window too. --- docs/DEVELOPER_ENVIRONMENT.md | 9 +++++++-- js/developer/environment/bundles.json | 8 ++++---- js/developer/environment/development.mjs | 12 +++++++++++- js/developer/environment/embed.mjs | 5 +++-- js/developer/environment/runtime.mjs | 3 ++- js/developer/environment/workspace.mjs | 6 +++++- test/developer/specs/development-specs.mjs | 14 +++++++++++++- test/web/developer-specs.mjs | 11 ++++++++++- 8 files changed, 55 insertions(+), 13 deletions(-) diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index abe5db6d..902b0478 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -393,7 +393,12 @@ environment's `mount`, not to the embedded bootstrap page): - **The tab shows the session's state**, so that a collapsed terminal still tells what it does: three bars when nothing runs, a ring while a command runs or `wf dev` builds, a full dot when `wf dev` has built the interface and watches its inputs, an amber diamond when the last build failed. The tab's name and tooltip say it in words. -- **The shortcut** is F9 by default. The developer page takes it before the interface does, so an application that uses +- **The shortcut** is F9 by default. The developer page takes it before the interface does: the page of a preview + announces its window before its scripts run (one inline script, absent from `wf build` and from an embedded + application), so the page's listener is the first of that window and no listener of the application sees the shortcut. + A frame that the application embeds is covered once the page has seen it, after any listener its own document installs + while loading; so is a preview published by an environment before 0.9.1, until `wf dev` or `wf preview` rebuilds it. + An application that uses F9 itself names another one in its manifest, and receives F9 as it does in its embedded form: `"developer": {"terminalShortcut": "Ctrl+Shift+F9"}`. A shortcut is a function key, F1 to F12, optionally after `Ctrl`, `Alt`, `Shift` or `Meta`, joined by `+`; anything else is a manifest error. The page reads it when it opens: relaunch @@ -402,7 +407,7 @@ environment's `mount`, not to the embedded bootstrap page): diagnostic over it. The tab is a button (`aria-expanded`, 44 px target) and the window a non-modal dialog. The interface stays in the preview -frame, as before: the layout adds nothing to the application's documents except the shortcut's listener, installed in the interface +frame, as before: the layout adds nothing to the application's documents except the shortcut's listener and the preview page's announcement, installed in the interface and in the same-origin frames it embeds (not in a frame of another origin, nor one inside a shadow tree: click the interface or the tab first). This is a layout, not a sandbox (see [limitations](#dependencies-storage-and-limitations)). A page that mounts the terminal itself (`runtime.mount`) with a preview frame gets diff --git a/js/developer/environment/bundles.json b/js/developer/environment/bundles.json index 1b84ed83..3852dcc2 100644 --- a/js/developer/environment/bundles.json +++ b/js/developer/environment/bundles.json @@ -17,12 +17,12 @@ "js/developer/environment/packages.mjs": "37fe2a410e211264cfeaedbff3df50f7e62b02f8088130127d94f92081e2a5ad", "js/developer/environment/starter.mjs": "89ccab43be4455ed9598c54355b4bbe5adea1afd7a0ae5d755a14317e3ca39df", "js/developer/environment/paths.mjs": "3b6114df78eb193161c5c84499dda084cb7ff91c56a4496371c30295d00880e3", - "js/developer/environment/runtime.mjs": "15daf498e0cee6697962e4e8decaea7e169d8c228d86d3436aa72b72403ada03", + "js/developer/environment/runtime.mjs": "5ce088084c84874e143e7e3f5e4d55d7151064f01c0137071343880dfa4acd4d", "js/developer/environment/automation.mjs": "79405c89ba7025c1774bc13c9b78d814a07592755dcde018c8659a8015c4b8ed", - "js/developer/environment/development.mjs": "39feb6bb507270228bf8de065c26d9d5e3fad3ade48bfe429458ca273d36ad3a", + "js/developer/environment/development.mjs": "168a2619c4d74544eed2b2ae1121e87c3afc776dc6140a3c7d1ba1d0d6168cd8", "js/developer/environment/testing.mjs": "aeb584505fab5957b9c02e78536e12f7d7f3d12f8adb2e17f1a1a6e395e43f3c", "js/developer/environment/terminal.mjs": "7ffcf7ac6ef63c35cdf5ef70284b384525b13ba18422af069289e53b6c4f6be1", - "js/developer/environment/workspace.mjs": "0b628295dc133ab2c34cb48f3c8f361e7bf5071ad027828bccf7d7198c0a2e6f", + "js/developer/environment/workspace.mjs": "f3b1f7c58bb9973ea438a1d1ef8fd2154de31ba79e84536c5d5d9ec8c1ce2da4", "js/developer/environment/tarball.mjs": "1c1e1aea067910e1fec74e85b4bf9fbefed9b38187a04d8d2764f0b9a96fca39", "js/developer/environment/commands.mjs": "8de20c01f02f33c0566f204fcf1ee2382a23344d2103581fe2914469ec570531", "js/developer/environment/compiler.mjs": "0158931132aa9b43b7bbbd01de6fa4fc34fce8c65515d593dd494930f7a1910f", @@ -37,7 +37,7 @@ "js/developer/environment/pins.mjs": "df07f6f01edaf86a1052d0e76f6c6745cb6e7a3309bbd256ac720ee8adc85297", "js/developer/environment/peers.mjs": "e1d999892138682fc0134ef1f4d4b19b9a9ad8d7fb16e37fc9c6c684bd853896", "js/developer/environment/resolve.mjs": "8b96b850af215be51f5cb85cc9c69e057afa04dfb8a57e572620c07059c17fa3", - "js/developer/environment/embed.mjs": "3e6bc10200939fa30d5f60a96f01eb33ddf3da87661390ad433a18366bf52547", + "js/developer/environment/embed.mjs": "3d3b5036c34c23a1fa0512c1eea42f26d5f30e054545b61fe83a5c378b74e09e", "examples/life/ui/main.tsx": "7b1ff285d2a6b8f897ef12df872886e61ef4b24e2358a9423b76b38ab75c85d3", "examples/life/ui/style.css": "9bb55eb0f0a3287e5b7dc78af9d69608b87ff42c4d9c8a653bc83a52fe293c44", "js/developer/tools/distribution.json": "0de03c0bd22fdcfe87c686d6c1456d26eeb57b09b03d0d680bb81557906f31a0", diff --git a/js/developer/environment/development.mjs b/js/developer/environment/development.mjs index 220ea537..cd0435f3 100644 --- a/js/developer/environment/development.mjs +++ b/js/developer/environment/development.mjs @@ -108,6 +108,16 @@ export function previewDiagnostics(frame, text) { document.body.append(overlay); } +/** + * The one addition to the page of a preview, absent from a build and from an embedded application: before any script of + * the application runs, the page tells the frame that shows it that it has a new window, so that the developer page + * takes the terminal's shortcut before the application's listeners (workspace.mjs). It does nothing outside that frame. + */ +export const previewHook = ""; + +/** The page of a published preview. */ +export const previewPage = files => applicationPage(files, previewHook); + let revision = 0; export function showPreview(frame, directory = 'preview') { if (!frame) throw new Error('No preview frame is available'); @@ -214,7 +224,7 @@ export async function dev(args, {bridge, signal, preview: frame, write = () => { const entry = resolveEntry(project.manifest, args[0], 'wf dev '); if (!session || session.closed) session = compilerSession(bridge, active); const files = await session.rebuild({entry, lock: project.lock ?? {format: 1, roots: {}, packages: {}}}); - files.set('index.html', applicationPage(files)); + files.set('index.html', previewPage(files)); await publish(bridge, '.webfront/developer/preview', files, {signal: active}); // Once commit succeeds, display its publication even if Ctrl+C arrived while awaiting it. diagnostic = ''; diff --git a/js/developer/environment/embed.mjs b/js/developer/environment/embed.mjs index 88ce1f76..f46ffb61 100644 --- a/js/developer/environment/embed.mjs +++ b/js/developer/environment/embed.mjs @@ -62,8 +62,9 @@ ${declarations.join('\n')} `; } -export function applicationPage(files) { +/** The page of an application built into `files`; `head` is markup put before its stylesheet and its scripts. */ +export function applicationPage(files, head = '') { const encode = new TextEncoder(); const stylesheet = files.has('app.css') ? '' : ''; - return encode.encode(`\nWebFront application${stylesheet}
\n`); + return encode.encode(`\nWebFront application${head}${stylesheet}
\n`); } diff --git a/js/developer/environment/runtime.mjs b/js/developer/environment/runtime.mjs index 2f52be17..54e0171a 100644 --- a/js/developer/environment/runtime.mjs +++ b/js/developer/environment/runtime.mjs @@ -12,7 +12,7 @@ import {install, initProject} from './installer.mjs'; import {restore, describeRegistry} from './restore.mjs'; import {loadProject, syncNotice, resolveEntry, embedTarget, lockPath, packageRoot, noManifest} from './project.mjs'; import {parseRunOptions, scriptCommand, execTarget, scriptHost, runWorker, runResult, runDeadline, secondsLeft} from './scripts.mjs'; -import {build, dev, showPreview} from './development.mjs'; +import {build, dev, showPreview, previewPage} from './development.mjs'; import {parseTestOptions, specFiles, jasmineCore, runnerFiles, runInFrame, reportResult, fitResult, stoppedRun, abortable, testDirectory} from './testing.mjs'; import {generateProvider, applicationPage} from './embed.mjs'; import {typescriptPackage, parseCheckOptions, checkHost} from './typecheck.mjs'; @@ -126,6 +126,7 @@ async function preview(args, {bridge, signal, preview: frame}) { const project = await loadProject(bridge); const entry = resolveEntry(project.manifest, args[0], 'wf preview '); const result = await compile(bridge, entry, signal); + result.files.set('index.html', previewPage(result.files)); await publish(bridge, '.webfront/developer/preview', result.files, {signal}); showPreview(frame); return syncNotice(project) + 'Preview ready.'; diff --git a/js/developer/environment/workspace.mjs b/js/developer/environment/workspace.mjs index a7124a19..2f216f16 100644 --- a/js/developer/environment/workspace.mjs +++ b/js/developer/environment/workspace.mjs @@ -305,10 +305,11 @@ export async function createWorkspace({bridge, element, frame}) { new view.MutationObserver(() => { if (frame.hidden) apply('hidden'); }).observe(frame, {attributes: true, attributeFilter: ['hidden']}); // The shortcut works wherever the focus is: in this page and in the interface, whose window changes at each load. + // The listener is the first of its window (below), so the application's ones never see the shortcut. const onKey = event => { if (!isToggleKey(event, shortcut) || state === State.terminal) return; event.preventDefault(); - event.stopPropagation(); + event.stopImmediatePropagation(); apply('toggle'); }; view.addEventListener('keydown', onKey, true); @@ -341,6 +342,9 @@ export async function createWorkspace({bridge, element, frame}) { }).observe(content, {childList: true, subtree: true}); } watchFrame(frame); + // A published preview announces its new window before its scripts run (development.mjs, previewHook): the listener + // is installed ahead of the application's. A frame that the application embeds gets it once it is seen here. + frame.addEventListener('webfront-preview-window', () => watchWindow(frame.contentWindow)); // Moving: the pointer is captured, so that the interface under the window does not take the moves. let grip = null; diff --git a/test/developer/specs/development-specs.mjs b/test/developer/specs/development-specs.mjs index a4c8613c..e9827bed 100644 --- a/test/developer/specs/development-specs.mjs +++ b/test/developer/specs/development-specs.mjs @@ -1,6 +1,7 @@ // Specs of wf dev's host side, which supplement the real-WASM browser regression in test/web/developer-specs.mjs. import {bundleContext} from '../../../js/developer/environment/bundler.mjs'; -import {observedRead, inputsChanged, compilerSession, waitForPoll, buildEntries, diagnosticsText, dev} from '../../../js/developer/environment/development.mjs'; +import {observedRead, inputsChanged, compilerSession, waitForPoll, buildEntries, diagnosticsText, dev, previewPage, previewHook} from '../../../js/developer/environment/development.mjs'; +import {applicationPage} from '../../../js/developer/environment/embed.mjs'; import {memoryBridge} from '../memory-bridge.mjs'; import {rejects, throws, esbuild} from '../support.mjs'; @@ -90,6 +91,17 @@ describe('wf dev', () => { } finally { session.close(); } }); + it('only the page of a preview announces its window, before the application\'s scripts', () => { + const decode = bytes => new TextDecoder().decode(bytes); + const files = new Map([['app.js', encode('')], ['app.css', encode('')]]); + const page = decode(previewPage(files)); + expect(page.indexOf(previewHook)).toBeGreaterThan(0); + expect(page.indexOf(previewHook)).toBeLessThan(page.indexOf('