@niscorp/cli 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dev.ts","../src/routes.ts","../src/shell-site.ts","../src/site.ts","../src/stylesheet.ts","../src/commands.ts","../src/cli.ts"],"names":["join","pad","why","existsSync","resolve","sep","statSync","readFileSync","writeFileSync","require","createRequire","dirname","spawnSync","rmSync","httpServer","url"],"mappings":";;;;;;;;;;;;;AA0BA,IAAM,SAAA,GAAY,CAAC,KAAA,KACjB,KAAA,KAAU,IAAA,IAAQ,OAAO,KAAA,KAAU,QAAA,IAAY,OAAO,OAAA,CAAQ,GAAA,CAAI,KAAA,EAAO,cAAc,CAAA,KAAM,UAAA;AAG/F,IAAM,MAAA,GAAS,OAAO,IAAA,KAAmC;AACvD,EAAA,IAAI,KAAA;AACJ,EAAA,IAAI;AACF,IAAA,KAAA,GAAQ,cAAc,IAAA,CAAK,IAAA,EAAM,cAAc,CAAC,CAAA,CAAE,QAAQ,MAAM,CAAA;AAAA,EAClE,CAAA,CAAA,MAAQ;AACN,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kDAAA,EAAqD,IAAI,CAAA,EAAA,CAAI,CAAA;AAAA,EAC/E;AACA,EAAA,MAAM,MAAA,GAAkB,MAAM,OAAO,aAAA,CAAc,KAAK,CAAA,CAAE,IAAA,CAAA;AAC1D,EAAA,IAAI,CAAC,UAAU,MAAM,CAAA,QAAS,IAAI,KAAA,CAAM,CAAA,MAAA,EAAS,KAAK,CAAA,aAAA,CAAe,CAAA;AACrE,EAAA,OAAO,MAAA;AACT,CAAA;AAGA,IAAM,UAAA,GAAa,OAAO,UAAA,KAAyC;AACjE,EAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,MAAM,OAAO,oBAAoB,CAAA;AACrD,EAAA,OAAO,OAAA,CAAQ;AAAA,IACb,KAAA,EAAO,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W;AACzB,IAAA,MAAM,OAAA,CAAQ,EAAE,GAAG,OAAA,EAAS,QAAQ,IAAA,CAAK,QAAA,CAAS,SAAS,CAAA,EAAG,CAAA;AAC9D,IAAA,OAAO,CAAA;AAAA,EACT;AACA,EAAA,IAAI,YAAY,OAAA,EAAS;AACvB,IAAA,OAAA,CAAQ,MAAM,KAAA,CAAM,OAAO,CAAA,EAAG,KAAK,CAAA,GAAI,CAAA;AAAA,EACzC;AACA,EAAA,IAAI,OAAA,KAAY,UAAU,OAAA,CAAQ,MAAM,WAAW,OAAO,CAAA,EAAG,UAAU,CAAA,GAAI,CAAA;AAC3E,EAAA,OAAA,CAAQ,IAAI,KAAK,CAAA;AACjB,EAAA,OAAO,YAAY,MAAA,IAAa,OAAA,KAAY,MAAA,IAAU,OAAA,KAAY,WAAW,CAAA,GAAI,CAAA;AACnF,CAAA;AAEA,IAAA,EAAK,CAAE,IAAA;AAAA;AAAA;AAAA,EAGL,CAAC,IAAA,KAAS,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAA;AAAA,EAC3B,CAAC,KAAA,KAAmB;AAClB,IAAA,OAAA,CAAQ,KAAA,CAAM,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,UAAU,KAAK,CAAA;AAC5D,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF,CAAA","file":"cli.js","sourcesContent":["import { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { configFileOf, isProject, isShellProject, loadProject } from './project';\n\n// ═══════════════════════════════════════════════════════════════\n// `nisc dev` — the app's own vite, started from here.\n//\n// An app with its own shell is a vite app and nothing more. An app behind moss\n// also needs its server inside that dev process, and that is moss's plugin\n// (`@niscorp/moss/vite`): added here, fed from the app's nisc.config.ts — the\n// same boot and the same drawing `nisc build` and `nisc start` use, loaded\n// through vite so an edit is a fresh boot. The app's vite.config.ts stays what\n// it is: its framework's plugin, its aliases.\n// ═══════════════════════════════════════════════════════════════\n\n// What is used of the app's vite — described here rather than imported, since\n// the vite is the app's and its types are the app's too.\ntype DevServer = {\n listen: () => Promise<unknown>;\n printUrls: () => void;\n resolvedUrls: { local: string[] } | null;\n close: () => Promise<void>;\n};\ntype ViteApi = { createServer: (config: { root: string; server?: { port: number }; plugins: unknown[] }) => Promise<DevServer> };\n\nconst isViteApi = (value: unknown): value is ViteApi =>\n value !== null && typeof value === 'object' && typeof Reflect.get(value, 'createServer') === 'function';\n\n// The app's vite — the command carries none of its own.\nconst viteOf = async (root: string): Promise<ViteApi> => {\n let entry: string;\n try {\n entry = createRequire(join(root, 'package.json')).resolve('vite');\n } catch {\n throw new Error(`nisc: this app has no vite installed (looked from ${root}).`);\n }\n const loaded: unknown = await import(pathToFileURL(entry).href);\n if (!isViteApi(loaded)) throw new Error(`nisc: ${entry} is not vite.`);\n return loaded;\n};\n\n// moss's dev plugin, fed from the config as vite loads it.\nconst mossPlugin = async (configFile: string): Promise<unknown> => {\n const { mossDev } = await import('@niscorp/moss/vite');\n return mossDev({\n label: 'nisc',\n app: async (load) => {\n const loaded = await load(`/${configFile}`);\n const project: unknown = Reflect.get(loaded, 'project');\n if (!isProject(project) || isShellProject(project)) throw new Error(`nisc: ${configFile} no longer describes an app behind moss.`);\n const booted = await project.boot();\n const signIn = project.dev?.signIn;\n return {\n server: booted.server,\n ...(booted.close !== undefined ? { close: booted.close } : {}),\n draw: project.draw,\n ...(project.htmlAttributes !== undefined ? { htmlAttributes: project.htmlAttributes } : {}),\n ...(project.site !== undefined ? { site: project.site } : {}),\n ...(project.tokenKey !== undefined ? { tokenKey: project.tokenKey } : {}),\n ...(signIn !== undefined ? { signIn: (who: string) => signIn(booted.server, who) } : {}),\n };\n },\n });\n};\n\nexport const devServer = async (options: { root: string; port?: number }): Promise<{ url: string; close: () => Promise<void> }> => {\n const project = await loadProject(options.root);\n const configFile = configFileOf(options.root);\n const vite = await viteOf(options.root);\n const server = await vite.createServer({\n root: options.root,\n ...(options.port !== undefined ? { server: { port: options.port } } : {}),\n plugins: isShellProject(project) || configFile === undefined ? [] : [await mossPlugin(configFile)],\n });\n await server.listen();\n server.printUrls();\n const url = server.resolvedUrls?.local[0] ?? `http://localhost:${options.port ?? 5173}/`;\n return { url, close: () => server.close() };\n};\n","// ═══════════════════════════════════════════════════════════════\n// The paths an app has, where each one's file goes, and the table a build\n// prints. Pure: no server, no disk — the command hands these what it found.\n// ═══════════════════════════════════════════════════════════════\n\n// What a build learned about one path (moss's `ExportedDocument`, without the\n// markup).\nexport type RouteReport = {\n path: string;\n // the page the path led to; absent: the app's own shell\n page?: string;\n drawn: boolean;\n // something on it can still happen — it wants a server behind it\n live: boolean;\n why: readonly string[];\n // reads whose answers are in the markup as they were when it was drawn\n drawnWith: readonly string[];\n settled: boolean;\n // what the screen's head held, and the actions that said it — absent when\n // the screen has no head and the document's is the template's own\n head?: { elements: readonly unknown[]; actions: readonly string[] };\n};\n\n// `/`, and every page whose path names no parameter. A parameterised page has\n// as many paths as there are rows; those are the app's to list.\nexport const defaultPaths = (pages: readonly { name: string; path: string }[]): string[] => [\n '/',\n ...pages\n .map((page) => page.path)\n .filter((path) => !path.split('/').some((segment) => segment.startsWith(':')))\n .sort(),\n];\n\n// Where a path's file goes under the output directory: `/` is index.html, and\n// every other path is a folder with an index.html in it — what every static\n// host serves for that path without being told to.\nexport const fileOf = (path: string): string => {\n const segments = path.split('?')[0]?.split('/').filter((segment) => segment !== '') ?? [];\n if (segments.some((segment) => segment === '..' || segment === '.')) throw new Error(`nisc: \"${path}\" is not a path a file can be written for.`);\n return [...segments, 'index.html'].join('/');\n};\n\nconst pad = (text: string, width: number): string => text + ' '.repeat(Math.max(0, width - text.length));\n\n// The table. One row per path: whether a file is the whole of it, or a server\n// has to stand behind it — and, in the build's own words, why.\nexport const routeTable = (routes: readonly RouteReport[]): string => {\n // Said only by an app that has a head somewhere: then a path without one is\n // going out under the template's, and that may not be what was meant.\n const says = (route: RouteReport): boolean => (route.head?.elements.length ?? 0) > 0;\n const headed = routes.some(says);\n const rows = routes.map((route) => {\n const mark = !route.drawn ? '✗' : route.live ? '●' : '○';\n const what = route.page === undefined ? 'the app' : `page ${route.page}`;\n const served = !route.drawn ? 'not drawn' : route.live ? 'server' : 'file';\n const notes = [\n ...(route.drawn ? route.why : ['it could not be drawn — it goes out as the undrawn template']),\n ...(route.drawn && !route.settled ? ['it was still loading when the wait ran out — drawn with what it had'] : []),\n ...(route.drawnWith.length > 0 ? [`drawn with ${route.drawnWith.join(', ')} — as it answered at build`] : []),\n ];\n const head = headed && route.drawn ? [says(route) ? `head: its own, said by ${route.head?.actions.join(', ') || 'the shell’s chrome'}` : 'head: the template’s own'] : [];\n return { mark, path: route.path, what, served, notes, head };\n });\n const widths = {\n path: Math.max(5, ...rows.map((row) => row.path.length)),\n what: Math.max(4, ...rows.map((row) => row.what.length)),\n served: Math.max(9, ...rows.map((row) => row.served.length)),\n };\n const lines = [` ${pad('Route', widths.path + 2)}${pad('What', widths.what + 2)}${pad('Served as', widths.served + 2)}Because`];\n for (const row of rows) {\n const head = `${row.mark} ${pad(row.path, widths.path + 2)}${pad(row.what, widths.what + 2)}${pad(row.served, widths.served + 2)}`;\n const [first, ...rest] = [...(row.notes.length > 0 ? row.notes : ['nothing on it can still happen']), ...row.head];\n lines.push(`${head}${first ?? ''}`);\n for (const note of rest) lines.push(`${' '.repeat(head.length)}${note}`);\n }\n lines.push('');\n lines.push('○ file drawn once, for nobody in particular; nothing on it can still happen');\n lines.push('● server something on it can still happen; it wants moss behind it');\n return lines.join('\\n');\n};\n","import { spawnSync } from 'node:child_process';\nimport { existsSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { dirname, extname, join, resolve, sep } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { shellSettled, shellView } from '@niscorp/nova';\nimport type { Shell } from '@niscorp/nova';\nimport { headOf, placeHead } from '@niscorp/nova/document';\nimport type { ScreenHead } from '@niscorp/nova/document';\nimport { livenessOf } from '@niscorp/nova/reflect';\nimport type { NiscShellProject } from './project';\n\n// ═══════════════════════════════════════════════════════════════\n// AN APP WITH ITS OWN SHELL, DRAWN AHEAD OF TIME.\n//\n// The shell lives in the page. A build runs the app's own boot where there is\n// no browser, waits for the screen to be whole, and has the app's adapter draw\n// it to markup; the page's boot then picks that markup up and from there the\n// app is what it always was. No server holds a shell at any point.\n//\n// A file is a claim — \"this is the page\" — so a build does not write one it has\n// not checked. Per path, and each one FAILS the build:\n//\n// drawn the app booted and its screen drew to markup that is not empty\n// whole nothing was still loading when it was drawn\n// same twice a second boot draws the same markup, byte for byte, and says\n// the same head — or the page's own boot would not match what\n// the file says\n// adopted inside a DOM, a third boot picks the markup up and the\n// adapter complains about nothing\n//\n// And one that holds by construction: the boot is handed a path and nothing\n// else, so a file is only ever the screen as nobody in particular sees it.\n//\n// What a build cannot fail on, it reports: what the screen opened with (those\n// answers are in the markup as they were at build), what it can still call, and\n// what it waits on.\n//\n// THE HEAD OF EACH FILE IS ITS SCREEN'S OWN. A page's <head> is a node in a\n// layout (nova's `nova:head`, holding the elements a head holds). It is read\n// off the same shell the markup was drawn from and written into the template's\n// <head>; a path whose screen has none goes out with the template's. A head\n// that holds what it may not — something that runs, or styles — FAILS the\n// build like any other check. With a `site` in the config, each path is given\n// its own canonical address.\n// ═══════════════════════════════════════════════════════════════\n\nconst DEFAULT_BUILD_WAIT_MS = 5000;\nexport const DEFAULT_ROOT = '<div id=\"root\"></div>';\n\nexport type ShellRouteReport = {\n path: string;\n // the whole document; the template as it is when the screen could not be drawn\n html: string;\n // every check that did not hold — empty is a file that may be written\n problems: readonly string[];\n // the actions on the first screen\n actions: readonly string[];\n // endpoints answered while the screen opened: their answers are in the markup\n // as they were when it was drawn\n opensWith: readonly string[];\n // endpoints the first screen can still call once it is in the page\n callsLater: readonly string[];\n // channels the first screen waits on\n listens: readonly string[];\n // what the first screen's head held, and the actions that said it — absent\n // when the screen has no head and the file's is the template's own\n head?: ScreenHead;\n};\n\nconst escapeAttribute = (value: string): string => value.replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;');\n\n// The screen, in the app's own index.html: inside the empty root, with whatever\n// the kit would have put on <html>.\nexport const placeScreen = (template: string, screen: string, attributes: Record<string, string> = {}, root = DEFAULT_ROOT): string => {\n const written = Object.entries(attributes)\n .map(([name, value]) => ` ${name}=\"${escapeAttribute(value)}\"`)\n .join('');\n return (\n template\n // functions, both, so nothing in the screen is read as a replacement pattern\n .replace(root, () => root.replace('></div>', () => `>${screen}</div>`))\n .replace(/<html([^>]*)>/, (whole, existing: string) => (written === '' ? whole : `<html${existing}${written}>`))\n );\n};\n\n// What the first screen is made of, read off the definitions of what is mounted.\nconst factsOf = (shell: Shell): Pick<ShellRouteReport, 'actions' | 'opensWith' | 'callsLater' | 'listens'> => {\n const [actions, opensWith, callsLater, listens] = [new Set<string>(), new Set<string>(), new Set<string>(), new Set<string>()];\n for (const canvas of Object.values(shell.getState().canvases)) {\n for (const instance of canvas.stack) {\n const definition = shell.getRuntime(instance.id)?.definition;\n if (definition === undefined) continue;\n actions.add(definition.id);\n const liveness = livenessOf(definition);\n for (const channel of liveness.listens) listens.add(channel);\n for (const endpoint of liveness.endpoints) {\n const label = `${definition.id}.${endpoint.name}${endpoint.kind === 'fn' ? ' (a function)' : endpoint.url !== undefined ? ` (${endpoint.url})` : ''}`;\n if (endpoint.onOpen) opensWith.add(label);\n if (endpoint.later) callsLater.add(label);\n }\n }\n }\n const sorted = (set: Set<string>): string[] => [...set].sort();\n return { actions: sorted(actions), opensWith: sorted(opensWith), callsLater: sorted(callsLater), listens: sorted(listens) };\n};\n\ntype Drawn = { screen: string; whole: boolean; attributes: Record<string, string>; head: ScreenHead | undefined; facts: ReturnType<typeof factsOf> };\n\n// A drawn screen as the document it goes out in: the screen in the root, and\n// what it says about itself in the head.\nconst documentOf = (project: NiscShellProject, template: string, path: string, drawn: Drawn): string =>\n placeHead(placeScreen(template, drawn.screen, drawn.attributes), drawn.head?.elements, { ...(project.site !== undefined ? { site: project.site } : {}), path });\n\n// One boot, one draw, and the app let go again.\nconst drawOnce = async (project: NiscShellProject, path: string): Promise<Drawn> => {\n const booted = await project.shell({ path });\n try {\n const whole = await shellSettled(booted.shell, { waitMs: project.waitMs ?? DEFAULT_BUILD_WAIT_MS });\n const screen = await project.draw(booted.shell);\n return { screen, whole, attributes: project.htmlAttributes?.(booted.shell) ?? {}, head: headOf(shellView(booted.shell).api), facts: factsOf(booted.shell) };\n } finally {\n await booted.close?.();\n }\n};\n\nconst said = (error: unknown): string => (error instanceof Error ? error.message : String(error));\n\n// ── adopted ──\n//\n// The one check that needs a browser's world. A DOM has to exist BEFORE the\n// app's modules load (an adapter decides what it is running in when it is\n// imported), so it runs in a process of its own: ./adopt stands a DOM up, loads\n// the same config, and for each path puts the markup in a root and makes the\n// app's own `adopt` call over a fresh boot.\n\ntype Adoption = { path: string; complaints: string[] };\n\nconst isAdoption = (value: unknown): value is Adoption =>\n value !== null &&\n typeof value === 'object' &&\n typeof Reflect.get(value, 'path') === 'string' &&\n Array.isArray(Reflect.get(value, 'complaints'));\n\nconst adoptAll = (root: string, pages: readonly { path: string; screen: string }[]): Adoption[] => {\n if (pages.length === 0) return [];\n const here = dirname(fileURLToPath(import.meta.url));\n // built: beside this file. From source (the package's own tests): in dist.\n const entry = [join(here, 'adopt.js'), join(here, '..', 'dist', 'adopt.js')].find((candidate) => existsSync(candidate));\n if (entry === undefined) throw new Error('nisc: the adoption check is not built (packages/cli/dist/adopt.js).');\n const scratch = mkdtempSync(join(tmpdir(), 'nisc-adopt-'));\n try {\n const [asked, answered] = [join(scratch, 'pages.json'), join(scratch, 'adopted.json')];\n writeFileSync(asked, JSON.stringify(pages));\n const result = spawnSync(process.execPath, [entry, root, asked, answered], { cwd: root, stdio: ['ignore', 'ignore', 'pipe'], encoding: 'utf8' });\n if (!existsSync(answered)) {\n const why = result.stderr.trim().split('\\n').slice(-6).join('\\n');\n return pages.map((page) => ({ path: page.path, complaints: [`the adoption check could not run${why === '' ? '' : ` — ${why}`}`] }));\n }\n const parsed: unknown = JSON.parse(readFileSync(answered, 'utf8'));\n return Array.isArray(parsed) ? parsed.filter(isAdoption) : [];\n } finally {\n rmSync(scratch, { recursive: true, force: true });\n }\n};\n\n// Every path, checked.\nexport const surveyShell = async (root: string, project: NiscShellProject, template: string): Promise<ShellRouteReport[]> => {\n if (!template.includes(DEFAULT_ROOT)) {\n throw new Error(`nisc: the built index.html has no empty root (${DEFAULT_ROOT}) — that is where a screen goes.`);\n }\n const paths = project.paths === undefined ? ['/'] : await project.paths();\n const none = { actions: [], opensWith: [], callsLater: [], listens: [] };\n\n const first: { path: string; drawn?: Drawn; problems: string[] }[] = [];\n for (const path of paths) {\n const problems: string[] = [];\n let drawn: Drawn | undefined;\n try {\n drawn = await drawOnce(project, path);\n if (drawn.screen.trim() === '') problems.push('drawn: it drew to nothing');\n if (!drawn.whole) problems.push(`whole: it was still loading after ${project.waitMs ?? DEFAULT_BUILD_WAIT_MS}ms`);\n for (const why of drawn.head?.refused ?? []) problems.push(`head: ${why}`);\n const again = await drawOnce(project, path);\n if (again.screen !== drawn.screen) problems.push(`same twice: a second boot drew different markup${differenceOf(drawn.screen, again.screen)}`);\n const [head, headAgain] = [JSON.stringify(drawn.head ?? null), JSON.stringify(again.head ?? null)];\n if (headAgain !== head) problems.push(`same twice: a second boot said a different head${differenceOf(head, headAgain)}`);\n } catch (error) {\n problems.push(`drawn: ${said(error)}`);\n }\n first.push({ path, ...(drawn !== undefined ? { drawn } : {}), problems });\n }\n\n // only what is worth adopting: a screen that drew, whole\n const adoptable = first.flatMap((route) => (route.drawn !== undefined && route.drawn.whole && route.drawn.screen.trim() !== '' ? [{ path: route.path, screen: route.drawn.screen }] : []));\n const adoptions = new Map(adoptAll(root, adoptable).map((adoption) => [adoption.path, adoption.complaints]));\n\n return first.map((route) => {\n const asked = adoptable.some((page) => page.path === route.path);\n const complaints = asked ? (adoptions.get(route.path) ?? ['the adoption check said nothing about it']) : [];\n const problems = [...route.problems, ...complaints.map((complaint) => `adopted: ${complaint}`)];\n return {\n path: route.path,\n html: route.drawn === undefined ? template : documentOf(project, template, route.path, route.drawn),\n problems,\n ...(route.drawn?.facts ?? none),\n ...(route.drawn?.head !== undefined ? { head: route.drawn.head } : {}),\n };\n });\n};\n\n// Where two draws part, in a few words — enough to find it.\nconst differenceOf = (a: string, b: string): string => {\n let at = 0;\n while (at < a.length && at < b.length && a[at] === b[at]) at += 1;\n const around = (text: string): string => JSON.stringify(text.slice(Math.max(0, at - 30), at + 50));\n return ` — at character ${at}: ${around(a)} then ${around(b)}`;\n};\n\nconst pad = (text: string, width: number): string => text + ' '.repeat(Math.max(0, width - text.length));\n\nexport const shellRouteTable = (routes: readonly ShellRouteReport[]): string => {\n const width = Math.max(5, ...routes.map((route) => route.path.length)) + 2;\n const lines = [` ${pad('Route', width)}First screen`];\n const indent = ' '.repeat(width + 2);\n // Said only by an app that has a head somewhere: then a path without one is\n // going out under the template's, and that may not be what was meant.\n const says = (route: ShellRouteReport): boolean => (route.head?.elements.length ?? 0) > 0;\n const headed = routes.some(says);\n const headNote = (route: ShellRouteReport): string =>\n says(route) ? `head: its own, said by ${route.head?.actions.join(', ') || 'the shell’s chrome'}` : 'head: the template’s own';\n for (const route of routes) {\n const ok = route.problems.length === 0;\n const notes = ok\n ? [\n `drawn · whole · same twice · adopted${route.actions.length > 0 ? ` (${route.actions.join(', ')})` : ''}`,\n ...(route.opensWith.length > 0 ? [`opened with ${route.opensWith.join(', ')} — in the file as answered at build`] : []),\n ...(route.callsLater.length > 0 ? [`can still call ${route.callsLater.join(', ')}`] : []),\n ...(route.listens.length > 0 ? [`waits on ${route.listens.join(', ')}`] : []),\n ...(headed ? [headNote(route)] : []),\n ]\n : route.problems;\n const [head, ...rest] = notes;\n lines.push(`${ok ? '○' : '✗'} ${pad(route.path, width)}${head ?? ''}`);\n for (const note of rest) lines.push(`${indent}${note}`);\n }\n lines.push('');\n lines.push('○ a file: the first screen, drawn for nobody in particular; the page’s own shell picks it up');\n lines.push('✗ not written: a check did not hold');\n return lines.join('\\n');\n};\n\n// ── served ──\n//\n// The same draw, per request: the first answer to a path is its screen, and\n// everything else in the built folder is a file. No checks here — a build made\n// them; a screen that will not draw goes out as the template, and the page's\n// own boot paints it as it did before any of this existed.\n//\n// What a browser may keep of all this, and how it travels, is not said here:\n// `start` puts that around this handler (./site), as it does around moss's.\n\nconst TYPES: Record<string, string> = {\n '.html': 'text/html; charset=utf-8',\n '.js': 'text/javascript; charset=utf-8',\n '.mjs': 'text/javascript; charset=utf-8',\n '.css': 'text/css; charset=utf-8',\n '.json': 'application/json; charset=utf-8',\n '.svg': 'image/svg+xml',\n '.png': 'image/png',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.webp': 'image/webp',\n '.ico': 'image/x-icon',\n '.woff2': 'font/woff2',\n '.woff': 'font/woff',\n '.wasm': 'application/wasm',\n '.data': 'application/octet-stream',\n '.map': 'application/json; charset=utf-8',\n '.txt': 'text/plain; charset=utf-8',\n};\n\nexport const shellSite = (project: NiscShellProject, dist: string): ((request: Request) => Promise<Response>) => {\n const base = resolve(dist);\n return async (request) => {\n const path = decodeURIComponent(new URL(request.url).pathname);\n if (path !== '/' && path !== '/index.html') {\n const file = resolve(base, `.${path}`);\n const stats = file === base || file.startsWith(base + sep) ? statSync(file, { throwIfNoEntry: false }) : undefined;\n if (stats?.isFile() === true) {\n // How big it is and when it last changed — what `start` needs to say\n // what a browser may keep, and to answer \"has it changed?\" (./site).\n return new Response(readFileSync(file), {\n headers: { 'content-type': TYPES[extname(file)] ?? 'application/octet-stream', 'content-length': String(stats.size), 'last-modified': stats.mtime.toUTCString() },\n });\n }\n // a name with an extension that is not there is a missing file, not a page\n if (extname(path) !== '') return new Response('not found', { status: 404 });\n }\n const template = readFileSync(join(base, 'index.html'), 'utf8');\n const headers = { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-cache' };\n try {\n const at = path === '/index.html' ? '/' : path;\n return new Response(documentOf(project, template, at, await drawOnce(project, at)), { headers });\n } catch (error) {\n console.error(`[nisc] \"${path}\" could not be drawn — serving it undrawn:`, error);\n return new Response(template, { headers });\n }\n };\n};\n","import { constants, createBrotliCompress, createGzip } from 'node:zlib';\nimport type { BrotliCompress, Gzip } from 'node:zlib';\n\n// ═══════════════════════════════════════════════════════════════\n// WHAT `nisc start` PUTS AROUND AN APP — either kind.\n//\n// `start` hands a listener one handler: an app with its own shell's\n// (./shell-site), or the moss server's. This wraps that handler, so the two\n// things below are said once, here, for both — and nothing inside moss or the\n// shell's own handler knows them.\n//\n// WHAT A BROWSER MAY KEEP (`withCaching`). What the bundler writes under\n// assets/ is named by its content: it is kept for a year and never asked\n// about again. Every other file is asked about each time, and answered 304\n// when it has not changed. An answer that already says for itself — every\n// drawn document does (who may keep a page follows from who asked) — is left\n// exactly as it is.\n//\n// HOW IT TRAVELS (`withCompression`). Text a browser reads goes out\n// compressed, brotli or gzip by what was asked for, a piece at a time as the\n// handler produces it — an answer that streams still streams.\n//\n// The app server's own paths (`except`: moss's /api, /catalog, …) are passed\n// through untouched: what they answer is theirs to say.\n// ═══════════════════════════════════════════════════════════════\n\n// A handler as a listener calls it: the request, and whatever else the listener\n// hands over (the Node request and response, for moss) — passed on as given.\nexport type SiteHandler<Rest extends readonly unknown[] = []> = (request: Request, ...rest: Rest) => Response | Promise<Response>;\n\nexport type SiteOptions = {\n // Paths whose answers are not the site's: left exactly as the handler made them.\n except?: RegExp;\n};\n\n// what the bundler writes is named by its content\nconst KEPT_PATHS = /^\\/assets\\//;\nconst KEPT_FOREVER = 'public, max-age=31536000, immutable';\n\nexport const withCaching =\n <Rest extends readonly unknown[]>(handler: SiteHandler<Rest>, options: SiteOptions = {}): SiteHandler<Rest> =>\n async (request, ...rest) => {\n const response = await handler(request, ...rest);\n if ((request.method !== 'GET' && request.method !== 'HEAD') || response.status !== 200) return response;\n const path = new URL(request.url).pathname;\n if (options.except?.test(path) === true) return response;\n if (response.headers.has('cache-control')) return response;\n\n const headers = new Headers(response.headers);\n if (KEPT_PATHS.test(path)) {\n headers.set('cache-control', KEPT_FOREVER);\n return new Response(response.body, { status: 200, headers });\n }\n headers.set('cache-control', 'no-cache');\n const [since, modified] = [request.headers.get('if-modified-since'), headers.get('last-modified')];\n if (since !== null && modified !== null && Date.parse(since) >= Date.parse(modified)) {\n await response.body?.cancel();\n headers.delete('content-length');\n return new Response(null, { status: 304, headers });\n }\n return new Response(response.body, { status: 200, headers });\n };\n\n// Text a browser reads — and nothing that is a conversation (an event stream).\nconst COMPRESSIBLE = /^(text\\/(?!event-stream)|application\\/(json|javascript|xml|manifest\\+json|wasm)|image\\/svg\\+xml)/i;\n// under this, the headers cost more than the saving\nconst SMALL_BYTES = 1024;\n// fast enough to do per answer, and already smaller than gzip's best\nconst BROTLI_QUALITY = 5;\n\ntype Encoding = 'br' | 'gzip';\n\n// What the asker takes, best first. `q=0` is a refusal.\nconst encodingFor = (header: string | null): Encoding | undefined => {\n const offered = new Map<string, number>();\n for (const part of (header ?? '').toLowerCase().split(',')) {\n const [name = '', ...parameters] = part.split(';').map((piece) => piece.trim());\n const weight = parameters.find((parameter) => parameter.startsWith('q='));\n if (name !== '') offered.set(name, weight === undefined ? 1 : Number(weight.slice(2)));\n }\n if ((offered.get('br') ?? 0) > 0) return 'br';\n if ((offered.get('gzip') ?? 0) > 0) return 'gzip';\n return undefined;\n};\n\n// Flushed after every piece written: what goes in comes out, compressed, before\n// the next piece is asked for. That is what keeps a streamed answer streaming.\nconst compressorFor = (encoding: Encoding): BrotliCompress | Gzip =>\n encoding === 'br'\n ? createBrotliCompress({ flush: constants.BROTLI_OPERATION_FLUSH, params: { [constants.BROTLI_PARAM_QUALITY]: BROTLI_QUALITY } })\n : createGzip({ flush: constants.Z_SYNC_FLUSH });\n\n// A body, compressed as it is read. `whole` is handed all of it once it has\n// gone out complete — never for a body that was cut short.\nconst compressedBody = (source: ReadableStream<Uint8Array>, encoding: Encoding, whole?: (bytes: Buffer<ArrayBuffer>) => void): ReadableStream<Uint8Array> => {\n const reader = source.getReader();\n const compressor = compressorFor(encoding);\n const pieces: Buffer[] = [];\n // whoever was reading has stopped: nothing more may be handed to them\n let isLetGo = false;\n let finished: () => void = () => undefined;\n const ended = new Promise<void>((done) => {\n finished = done;\n });\n return new ReadableStream<Uint8Array>({\n start: (controller) => {\n compressor.on('data', (piece: Buffer) => {\n if (isLetGo) return;\n if (whole !== undefined) pieces.push(piece);\n controller.enqueue(piece);\n });\n compressor.on('end', () => {\n if (!isLetGo) {\n whole?.(Buffer.concat(pieces));\n controller.close();\n }\n finished();\n });\n compressor.on('error', (error) => {\n if (!isLetGo) controller.error(error);\n finished();\n });\n },\n pull: async () => {\n // a source that fails takes the compressor with it; the failure is the reader's to hear\n const { done, value } = await reader.read().catch((error: unknown) => {\n compressor.destroy();\n throw error;\n });\n if (done) {\n compressor.end();\n return ended;\n }\n return new Promise<void>((taken) => {\n compressor.write(value, () => taken());\n });\n },\n cancel: async (reason) => {\n isLetGo = true;\n compressor.destroy();\n await reader.cancel(reason);\n },\n });\n};\n\nexport const withCompression = <Rest extends readonly unknown[]>(handler: SiteHandler<Rest>, options: SiteOptions = {}): SiteHandler<Rest> => {\n // An answer that says it will never change is compressed once: what it came\n // to is remembered, by what was asked for and how. Bounded by what the built\n // folder holds under assets/.\n const remembered = new Map<string, Buffer<ArrayBuffer>>();\n return async (request, ...rest) => {\n const response = await handler(request, ...rest);\n if (request.method !== 'GET' || response.status !== 200 || response.body === null) return response;\n const path = new URL(request.url).pathname;\n if (options.except?.test(path) === true) return response;\n if (!COMPRESSIBLE.test(response.headers.get('content-type') ?? '')) return response;\n if (response.headers.has('content-encoding') || /no-transform/i.test(response.headers.get('cache-control') ?? '')) return response;\n\n // From here the answer depends on what was asked for, compressed or not —\n // whatever keeps a copy has to be told.\n const headers = new Headers(response.headers);\n const varies = (headers.get('vary') ?? '').toLowerCase().split(',').map((name) => name.trim());\n if (!varies.includes('accept-encoding')) headers.append('vary', 'Accept-Encoding');\n\n const encoding = encodingFor(request.headers.get('accept-encoding'));\n const length = headers.get('content-length');\n if (encoding === undefined || (length !== null && Number(length) < SMALL_BYTES)) return new Response(response.body, { status: 200, headers });\n\n headers.set('content-encoding', encoding);\n headers.delete('content-length');\n // the bytes are no longer those bytes\n const etag = headers.get('etag');\n if (etag !== null && !etag.startsWith('W/')) headers.set('etag', `W/${etag}`);\n\n if (!/\\bimmutable\\b/i.test(headers.get('cache-control') ?? '')) return new Response(compressedBody(response.body, encoding), { status: 200, headers });\n const key = `${encoding} ${path} ${headers.get('last-modified') ?? ''}`;\n const known = remembered.get(key);\n if (known === undefined) return new Response(compressedBody(response.body, encoding, (bytes) => remembered.set(key, bytes)), { status: 200, headers });\n await response.body.cancel();\n headers.set('content-length', String(known.length));\n return new Response(known, { status: 200, headers });\n };\n};\n\n// Both, in the order they apply: said what may be kept, then compressed.\nexport const siteHandler = <Rest extends readonly unknown[]>(handler: SiteHandler<Rest>, options: SiteOptions = {}): SiteHandler<Rest> =>\n withCompression(withCaching(handler, options), options);\n","import { existsSync, readFileSync, statSync, writeFileSync } from 'node:fs';\nimport { join, resolve, sep } from 'node:path';\n\n// ═══════════════════════════════════════════════════════════════\n// THE STYLESHEET GOES IN THE PAGE.\n//\n// A drawn page arrives as markup, and a browser paints none of it until it has\n// the stylesheet. As a file of its own that is a second round trip before the\n// first paint. So once the bundler is done, the page it wrote (`index.html`,\n// the template every drawn page is made from) has each stylesheet it links\n// written into it as a <style>, and one response paints the page.\n//\n// It is done ONCE, to the file in the built folder — every reader of that file\n// (`build`, `export`, `start`, moss's document) then hands out the same head\n// without knowing any of this. The stylesheet's own file stays where it is.\n//\n// A link is left as it is, and the build says so, when moving the stylesheet\n// could change what it means: a link that says more than where the file is (a\n// `media`, a `title`), a file that is not in the built folder, a stylesheet\n// that names another file relative to itself.\n// ═══════════════════════════════════════════════════════════════\n\n// What became of each stylesheet link the page had.\nexport type StylesheetReport = {\n // now in the page: where it was linked from, and how much text that is\n inPage: readonly { href: string; bytes: number }[];\n // left as a file, and why\n left: readonly { href: string; why: string }[];\n};\n\nexport type StylesheetRewrite = StylesheetReport & { html: string };\n\nconst attributesOf = (tag: string): Record<string, string> => {\n const found: Record<string, string> = {};\n // past `<link`\n for (const match of tag.slice(5).matchAll(/([^\\s\"'<>/=]+)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s\"'=<>`]+)))?/g)) {\n const name = match[1];\n if (name !== undefined) found[name.toLowerCase()] = match[2] ?? match[3] ?? match[4] ?? '';\n }\n return found;\n};\n\n// what a link may say and still be only \"this stylesheet, from here\"\nconst PLAIN = new Set(['rel', 'href', 'crossorigin']);\n\n// A url() that points at the same thing from a page at any path: an absolute\n// path, a full address, a data: or blob: URI, a fragment.\nconst isPortableUrl = (url: string): boolean => url === '' || /^(\\/|data:|blob:|https?:|#)/i.test(url);\n\n// Why a stylesheet cannot move into a page — nothing, when it can.\nconst whyStylesheetStays = (css: string): string | undefined => {\n if (/@import\\b/i.test(css)) return 'it imports another stylesheet';\n for (const match of css.matchAll(/url\\(\\s*(?:\"([^\"]*)\"|'([^']*)'|([^)]*?))\\s*\\)/gi)) {\n const url = (match[1] ?? match[2] ?? match[3] ?? '').trim();\n if (!isPortableUrl(url)) return `it names a file relative to itself (${url})`;\n }\n return undefined;\n};\n\n// The page, with every stylesheet it links by a plain local path written into\n// it. `read` answers a stylesheet's text by its href, or nothing when the built\n// folder has no such file. Pure: a second pass over its own output changes\n// nothing.\nexport const stylesheetInPage = (html: string, read: (href: string) => string | undefined): StylesheetRewrite => {\n const inPage: { href: string; bytes: number }[] = [];\n const left: { href: string; why: string }[] = [];\n const rewritten = html.replace(/<link\\b[^>]*>/gi, (tag) => {\n const attributes = attributesOf(tag);\n if ((attributes['rel'] ?? '').toLowerCase() !== 'stylesheet') return tag;\n const href = attributes['href'] ?? '';\n const stays = (why: string): string => {\n left.push({ href, why });\n return tag;\n };\n const extra = Object.keys(attributes).filter((name) => !PLAIN.has(name));\n if (extra.length > 0) return stays(`its link says more than where it is (${extra.join(', ')})`);\n if (!href.startsWith('/') || href.startsWith('//') || /[?#]/.test(href)) return stays('it is not a path into the built folder');\n const css = read(href);\n if (css === undefined) return stays('it is not in the built folder');\n const why = whyStylesheetStays(css);\n if (why !== undefined) return stays(why);\n inPage.push({ href, bytes: Buffer.byteLength(css) });\n // A <style> ends at the first `</style`, whatever CSS thinks it is inside.\n // `\\/` is the same character to CSS, and not that to the HTML parser.\n return `<style>${css.replace(/<\\/(style)/gi, '<\\\\/$1')}</style>`;\n });\n return { html: rewritten, inPage, left };\n};\n\n// The same, over the built folder: its index.html rewritten where it stands.\n// Nothing to do (no page, no stylesheet link) is nothing done.\nexport const writeStylesheetIntoPage = (dist: string): StylesheetReport => {\n const page = join(dist, 'index.html');\n if (!existsSync(page)) return { inPage: [], left: [] };\n const base = resolve(dist);\n const read = (href: string): string | undefined => {\n const file = resolve(base, `.${href}`);\n return file.startsWith(base + sep) && existsSync(file) && statSync(file).isFile() ? readFileSync(file, 'utf8') : undefined;\n };\n const html = readFileSync(page, 'utf8');\n const rewrite = stylesheetInPage(html, read);\n if (rewrite.html !== html) writeFileSync(page, rewrite.html);\n return { inPage: rewrite.inPage, left: rewrite.left };\n};\n","import { spawn, spawnSync } from 'node:child_process';\nimport { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport type { AddressInfo } from 'node:net';\nimport { dirname, join, resolve } from 'node:path';\nimport { serve } from '@hono/node-server';\nimport type { ExportedDocument } from '@niscorp/moss';\nimport { devServer } from './dev';\nimport { isShellProject, loadProject } from './project';\nimport type { NiscMossProject, NiscProject, NiscShellProject } from './project';\nimport { defaultPaths, fileOf, routeTable } from './routes';\nimport { shellRouteTable, shellSite, surveyShell } from './shell-site';\nimport type { ShellRouteReport } from './shell-site';\nimport { siteHandler } from './site';\nimport { writeStylesheetIntoPage } from './stylesheet';\n\n// ═══════════════════════════════════════════════════════════════\n// What `nisc` does. Each command is the app's own machinery, run in order:\n//\n// dev the app's own vite, with the app server inside it when it has one\n// build bundle the terminal and write its stylesheet into its page, then\n// draw every path once and say how each is served — a file, or a server\n// export build, then write every path as a file: the whole site as a folder\n// start serve the built terminal from the app's own process, pages drawn —\n// compressed, and with what a browser may keep said (./site)\n// check the app's check suite\n// migrate apply the tables' pending migrations, if the app's entries fit what\n// they leave\n//\n// Nothing here knows an app. How it boots and how a screen is drawn come from\n// its nisc.config.ts. An app behind moss hands over its server, and which paths\n// exist and what each needs come from that (`server.pages`, `exportDocuments`).\n// An app with its own shell hands over its boot, and every path is drawn from\n// that and checked (./shell-site). Moss is loaded only for the first kind — an\n// app without it does not have it installed.\n// ═══════════════════════════════════════════════════════════════\n\nexport type CommandOptions = {\n // the app's root (where nisc.config.ts is)\n root: string;\n // export: where the files go (default `out`), relative to the root\n out?: string;\n // export: write the site even though some path wants a server behind it\n allowLive?: boolean;\n // start: the port (default $PORT, then 8787)\n port?: number;\n // build/export: skip the bundler (the terminal is already built)\n skipBundle?: boolean;\n // migrate: do all of it, then roll it back\n dryRun?: boolean;\n print?: (line: string) => void;\n};\n\nconst say = (options: CommandOptions): ((line: string) => void) => options.print ?? ((line) => console.log(line));\n\n// A tool the APP has installed, found from the app's own root — the command\n// carries no bundler and no test runner of its own.\nconst toolOf = (root: string, name: string, bin: string): string => {\n const require = createRequire(join(root, 'package.json'));\n let manifestPath: string;\n try {\n manifestPath = require.resolve(`${name}/package.json`);\n } catch {\n throw new Error(`nisc: this app has no ${name} installed (looked from ${root}).`);\n }\n const manifest: unknown = JSON.parse(readFileSync(manifestPath, 'utf8'));\n const bins: unknown = manifest !== null && typeof manifest === 'object' ? Reflect.get(manifest, 'bin') : undefined;\n const relative: unknown = typeof bins === 'string' ? bins : bins !== null && typeof bins === 'object' ? Reflect.get(bins, bin) : undefined;\n if (typeof relative !== 'string') throw new Error(`nisc: ${name} ships no \"${bin}\" command.`);\n return join(dirname(manifestPath), relative);\n};\n\nconst distOf = (root: string, project: NiscProject): string => resolve(root, project.dist ?? 'dist');\n\n// The app's own vite, and then the one thing done to what it wrote: the page's\n// stylesheet goes into the page (./stylesheet). A terminal that is already built\n// (`skipBundle`) is taken as it is.\nconst bundle = (options: CommandOptions, project: NiscProject): void => {\n const result = spawnSync(process.execPath, [toolOf(options.root, 'vite', 'vite'), 'build'], { cwd: options.root, stdio: 'inherit' });\n if (result.status !== 0) throw new Error('nisc: the bundler failed — nothing was drawn.');\n if (project.stylesheet === 'file') return;\n const print = say(options);\n const { inPage, left } = writeStylesheetIntoPage(distOf(options.root, project));\n if (inPage.length + left.length > 0) print('');\n for (const sheet of inPage) print(`nisc: ${sheet.href} is in the page (${(sheet.bytes / 1024).toFixed(1)} kB) — one response paints it`);\n for (const sheet of left) print(`nisc: ${sheet.href} stays a file — ${sheet.why}`);\n if (inPage.length > 0) print(\" A Content-Security-Policy that forbids inline styles would refuse it: `stylesheet: 'file'` in nisc.config.ts keeps it a file.\");\n};\n\n// `start` tells browsers to keep what is under /assets/ for a year — right for\n// what the bundler writes there, named by its content. The bundler also copies\n// the app's public/ as it is, so a file of the app's own under public/assets/\n// would be kept just as long, under a name that says nothing about its content.\nconst warnOfOwnAssets = (options: CommandOptions): void => {\n if (!existsSync(join(options.root, 'public', 'assets'))) return;\n say(options)('nisc: public/assets/ holds files of your own. `nisc start` has browsers keep everything under /assets/ for a year, so a change to one of them will not be seen under the same name — keep them elsewhere in public/.');\n};\n\n// index.html says where the page lives, once — and every path is written from\n// it. With more than one path and no `site`, each file would name that one\n// address as its own, which tells a search engine they are all copies of it.\nconst warnOfOneAddress = (options: CommandOptions, project: NiscProject, template: string, paths: number): void => {\n if (project.site !== undefined || paths < 2 || !/<link\\b[^>]*\\brel\\s*=\\s*[\"']?canonical\\b/i.test(template)) return;\n say(options)('');\n say(options)(`nisc: index.html names one canonical address and this app has ${paths} paths — every file would say it lives there.`);\n say(options)(' `site: \"https://…\"` in nisc.config.ts gives each path its own.');\n};\n\n// Stand the app up, draw every path once for nobody, let the app go.\nconst templateOf =(options: CommandOptions, project: NiscProject): string => {\n const template = join(distOf(options.root, project), 'index.html');\n if (!existsSync(template)) throw new Error(`nisc: no built terminal at ${template} — run \\`nisc build\\`.`);\n return readFileSync(template, 'utf8');\n};\n\nconst survey = async (options: CommandOptions, project: NiscMossProject): Promise<ExportedDocument[]> => {\n const template = templateOf(options, project);\n const { exportDocuments } = await import('@niscorp/moss');\n const booted = await project.boot();\n try {\n const paths = project.paths === undefined ? defaultPaths(booted.server.pages) : await project.paths(booted.server);\n return await exportDocuments({\n server: booted.server,\n template,\n draw: project.draw,\n ...(project.htmlAttributes !== undefined ? { htmlAttributes: project.htmlAttributes } : {}),\n ...(project.site !== undefined ? { site: project.site } : {}),\n ...(project.tokenKey !== undefined ? { tokenKey: project.tokenKey } : {}),\n paths,\n });\n } finally {\n await booted.close?.();\n }\n};\n\n// What a build found, either way round: every path, and whether the build holds.\nexport type BuildResult =\n | { kind: 'moss'; ok: boolean; routes: ExportedDocument[] }\n | { kind: 'shell'; ok: boolean; routes: ShellRouteReport[] };\n\nconst buildShell = async (options: CommandOptions, project: NiscShellProject): Promise<BuildResult> => {\n const template = templateOf(options, project);\n const routes = await surveyShell(options.root, project, template);\n say(options)('');\n say(options)(shellRouteTable(routes));\n warnOfOneAddress(options, project, template, routes.length);\n return { kind: 'shell', ok: routes.every((route) => route.problems.length === 0), routes };\n};\n\nexport const build = async (options: CommandOptions): Promise<BuildResult> => {\n const project = await loadProject(options.root);\n if (options.skipBundle !== true) bundle(options, project);\n warnOfOwnAssets(options);\n if (isShellProject(project)) return buildShell(options, project);\n const routes = await survey(options, project);\n say(options)('');\n say(options)(routeTable(routes));\n warnOfOneAddress(options, project, templateOf(options, project), routes.length);\n return { kind: 'moss', ok: routes.every((route) => route.drawn), routes };\n};\n\nconst write = (options: CommandOptions, project: NiscProject, out: string, routes: readonly { path: string; html: string }[]): void => {\n rmSync(out, { recursive: true, force: true });\n cpSync(distOf(options.root, project), out, { recursive: true });\n for (const route of routes) {\n const file = join(out, fileOf(route.path));\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(file, route.html);\n }\n say(options)('');\n say(options)(`nisc: ${routes.length} paths written to ${out}`);\n};\n\n// The whole site as a folder. A path that wants a server behind it is not\n// something a folder can be — so unless the caller says a server will stand\n// beside the files (`allowLive`), nothing is written and the table says why.\n//\n// An app with its own shell has no such path: the shell is in the page, so a\n// folder is all of it. What stops ITS files is a check that did not hold.\nexport const exportSite = async (options: CommandOptions): Promise<{ written: boolean; result: BuildResult; out: string }> => {\n const project = await loadProject(options.root);\n const result = await build(options);\n const out = resolve(options.root, options.out ?? 'out');\n if (result.kind === 'shell') {\n if (!result.ok) {\n const failed = result.routes.filter((route) => route.problems.length > 0);\n say(options)('');\n say(options)(`nisc: ${failed.length} of ${result.routes.length} paths did not hold (${failed.map((route) => route.path).join(', ')}). Nothing was written.`);\n return { written: false, result, out };\n }\n write(options, project, out, result.routes);\n return { written: true, result, out };\n }\n const routes = result.routes;\n const live = routes.filter((route) => route.live || !route.drawn);\n if (live.length > 0 && options.allowLive !== true) {\n say(options)('');\n say(options)(`nisc: ${live.length} of ${routes.length} paths cannot be a file alone (${live.map((route) => route.path).join(', ')}).`);\n say(options)(' Nothing was written. With a server beside the files they still work: `nisc export --allow-live`.');\n return { written: false, result, out };\n }\n write(options, project, out, routes);\n return { written: true, result, out };\n};\n\nconst listening = async (httpServer: ReturnType<typeof serve>, options: CommandOptions): Promise<string> => {\n await new Promise<void>((up) => httpServer.once('listening', () => up()));\n const address = httpServer.address();\n const port = address !== null && typeof address === 'object' ? (address satisfies AddressInfo).port : options.port;\n return `http://localhost:${port}`;\n};\n\nexport const start = async (options: CommandOptions): Promise<{ url: string; close: () => Promise<void> }> => {\n const project = await loadProject(options.root);\n const dist = distOf(options.root, project);\n if (!existsSync(join(dist, 'index.html'))) throw new Error(`nisc: no built terminal in ${dist} — run \\`nisc build\\`.`);\n const port = options.port ?? Number(process.env['PORT'] ?? 8787);\n if (isShellProject(project)) {\n // no server shell, no socket: each path's first answer is its screen, drawn\n // from a boot of the app's own, and the page's shell takes it from there\n const httpServer = serve({ fetch: siteHandler(shellSite(project, dist)), port });\n const url = await listening(httpServer, options);\n say(options)(`nisc: serving ${url} — the built app, each path’s first screen drawn; the shell is the page’s own`);\n return { url, close: async () => void httpServer.close() };\n }\n const { attachSocket, mountSite, MOSS_PATHS } = await import('@niscorp/moss/node');\n const booted = await project.boot();\n await project.routes?.(booted.server);\n mountSite(booted.server, {\n dist,\n draw: project.draw,\n ...(project.htmlAttributes !== undefined ? { htmlAttributes: project.htmlAttributes } : {}),\n ...(project.site !== undefined ? { site: project.site } : {}),\n ...(project.tokenKey !== undefined ? { tokenKey: project.tokenKey } : {}),\n });\n // what the app server answers itself is its own to say; the rest is the site\n const httpServer = serve({ fetch: siteHandler(booted.server.fetch, { except: MOSS_PATHS }), port });\n attachSocket(httpServer, booted.server.socket);\n const url = await listening(httpServer, options);\n say(options)(`nisc: serving ${url} — the built terminal, its pages drawn; the socket at /socket`);\n return {\n url,\n close: async () => {\n httpServer.close();\n await booted.close?.();\n },\n };\n};\n\n// The tables, moved — by moss (`migrateTables`), which refuses a run that would\n// leave an entry of the manifest not fitting. A refusal is thrown with its\n// reasons, and nothing was applied. What a run that lands took away is said.\nexport const migrate = async (options: CommandOptions): Promise<void> => {\n const project = await loadProject(options.root);\n if (isShellProject(project) || project.app === undefined || project.runtime === undefined) {\n throw new Error('nisc: `nisc migrate` needs `app` and `runtime` in nisc.config.ts — the manifest, and the environment it runs on.');\n }\n const { migrateTables } = await import('@niscorp/moss');\n const print = say(options);\n const isDryRun = options.dryRun === true;\n const runtime = await project.runtime();\n try {\n const report = await migrateTables(runtime, project.app, isDryRun ? { dryRun: true } : {});\n if (report.applied.length === 0) print('nisc: nothing to migrate');\n else print(isDryRun ? `nisc: would apply ${report.applied.length} — rolled back, nothing changed` : `nisc: applied ${report.applied.length}`);\n for (const migration of report.applied) print(` ${migration.ref} ${migration.description}`);\n if (report.removed.length > 0) print(`nisc: this run removes ${report.removed.join(', ')}`);\n if (report.retyped.length > 0) print(`nisc: this run changes the type of ${report.retyped.join(', ')}`);\n if (report.alreadyBroken.length > 0) print('nisc: not fitting before this run either, and seeded as they are — said, not refused:');\n for (const entry of report.alreadyBroken) print(` ${entry}`);\n } finally {\n await runtime.close?.();\n }\n};\n\n// The two that hand over to a tool of the app's own and stay out of the way.\nconst handOver = (options: CommandOptions, tool: string, args: readonly string[]): Promise<number> =>\n new Promise((done) => {\n const child = spawn(process.execPath, [tool, ...args], { cwd: options.root, stdio: 'inherit' });\n child.once('exit', (code) => done(code ?? 1));\n });\n\nexport const dev = (options: CommandOptions): Promise<{ url: string; close: () => Promise<void> }> =>\n devServer({ root: options.root, ...(options.port !== undefined ? { port: options.port } : {}) });\n\nexport const check = async (options: CommandOptions): Promise<number> => {\n const project = await loadProject(options.root);\n return handOver(options, toolOf(options.root, 'tsx', 'tsx'), [project.checks ?? 'src/dev/all-checks.ts']);\n};\n","import { resolve } from 'node:path';\nimport { build, check, dev, exportSite, migrate, start } from './commands';\nimport type { CommandOptions } from './commands';\n\n// ═══════════════════════════════════════════════════════════════\n// nisc — the command line. It parses, and hands over to ./commands.\n// ═══════════════════════════════════════════════════════════════\n\nconst USAGE = `nisc — the command for a nisc application\n\n nisc dev the app's dev server — its vite, with the app server inside\n nisc build bundle the app, draw every path, and check what was drawn\n nisc export build, then write every path as a file (the site as a folder)\n nisc start serve the built app, each path's first screen drawn\n nisc check the app's check suite\n nisc migrate apply the tables' pending migrations, if the app's entries fit the result\n\n --root <dir> the app's root (default: here) — where nisc.config.ts is\n --out <dir> export: where the files go (default: out)\n --allow-live export: write even though some path wants a server behind it\n --port <n> dev, start: the port (start: $PORT, then 8787)\n --skip-bundle build, export: the terminal is already built\n --check migrate: do all of it, then roll it back\n\nAn app says in nisc.config.ts how it boots and how one of its screens is drawn.\nBehind moss (boot + draw): which paths exist and what each needs is read off the\nserver. With its own shell (shell + draw + adopt): every path is drawn from the\napp's own boot, and a file is written only if the page's boot picks it up clean.`;\n\nconst valueAfter = (args: readonly string[], flag: string): string | undefined => {\n const at = args.indexOf(flag);\n return at < 0 ? undefined : args[at + 1];\n};\n\nconst main = async (): Promise<number> => {\n const [command, ...args] = process.argv.slice(2);\n const port = valueAfter(args, '--port');\n const out = valueAfter(args, '--out');\n const options: CommandOptions = {\n root: resolve(valueAfter(args, '--root') ?? process.cwd()),\n ...(out !== undefined ? { out } : {}),\n ...(port !== undefined ? { port: Number(port) } : {}),\n allowLive: args.includes('--allow-live'),\n skipBundle: args.includes('--skip-bundle'),\n };\n\n if (command === 'dev' || command === 'start') {\n const served = command === 'dev' ? await dev(options) : await start(options);\n const stop = (): void => {\n void served.close().finally(() => process.exit(0));\n };\n process.on('SIGINT', stop);\n process.on('SIGTERM', stop);\n // stays up until it is told to stop\n return new Promise<number>(() => undefined);\n }\n if (command === 'check') return check(options);\n if (command === 'migrate') {\n await migrate({ ...options, dryRun: args.includes('--check') });\n return 0;\n }\n if (command === 'build') {\n return (await build(options)).ok ? 0 : 1;\n }\n if (command === 'export') return (await exportSite(options)).written ? 0 : 1;\n console.log(USAGE);\n return command === undefined || command === 'help' || command === '--help' ? 0 : 1;\n};\n\nmain().then(\n // An app's own handles (a database, a timer) must not keep a finished command\n // open: a command that is done says so and leaves.\n (code) => process.exit(code),\n (error: unknown) => {\n console.error(error instanceof Error ? error.message : error);\n process.exit(1);\n },\n);\n"]}
1
+ {"version":3,"sources":["../src/dev.ts","../src/routes.ts","../src/shell-site.ts","../src/site.ts","../src/stylesheet.ts","../src/commands.ts","../src/cli.ts"],"names":["dev","join","pad","why","existsSync","resolve","sep","statSync","readFileSync","writeFileSync","require","createRequire","dirname","spawnSync","rmSync","httpServer","url"],"mappings":";;;;;;;;;;;;;AA2BA,IAAM,SAAA,GAAY,CAAC,KAAA,KACjB,KAAA,KAAU,IA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CAAM,OAAO,CAAA;AAC7C,EAAA,IAAI,YAAY,SAAA,EAAW;AACzB,IAAA,MAAM,OAAA,CAAQ,EAAE,GAAG,OAAA,EAAS,QAAQ,IAAA,CAAK,QAAA,CAAS,SAAS,CAAA,EAAG,CAAA;AAC9D,IAAA,OAAO,CAAA;AAAA,EACT;AACA,EAAA,IAAI,YAAY,OAAA,EAAS;AACvB,IAAA,OAAA,CAAQ,MAAM,KAAA,CAAM,OAAO,CAAA,EAAG,KAAK,CAAA,GAAI,CAAA;AAAA,EACzC;AACA,EAAA,IAAI,OAAA,KAAY,UAAU,OAAA,CAAQ,MAAM,WAAW,OAAO,CAAA,EAAG,UAAU,CAAA,GAAI,CAAA;AAC3E,EAAA,OAAA,CAAQ,IAAI,KAAK,CAAA;AACjB,EAAA,OAAO,YAAY,MAAA,IAAa,OAAA,KAAY,MAAA,IAAU,OAAA,KAAY,WAAW,CAAA,GAAI,CAAA;AACnF,CAAA;AAEA,IAAA,EAAK,CAAE,IAAA;AAAA;AAAA;AAAA,EAGL,CAAC,IAAA,KAAS,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAA;AAAA,EAC3B,CAAC,KAAA,KAAmB;AAClB,IAAA,OAAA,CAAQ,KAAA,CAAM,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,UAAU,KAAK,CAAA;AAC5D,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF,CAAA","file":"cli.js","sourcesContent":["import { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { configFileOf, isProject, isShellProject, loadProject } from './project';\nimport type { NiscMossProject } from './project';\n\n// ═══════════════════════════════════════════════════════════════\n// `nisc dev` — the app's own vite, started from here.\n//\n// An app with its own shell is a vite app and nothing more. An app behind moss\n// also needs its server inside that dev process, and that is moss's plugin\n// (`@niscorp/moss/vite`): added here, fed from the app's nisc.config.ts — the\n// same boot and the same drawing `nisc build` and `nisc start` use, loaded\n// through vite so an edit is a fresh boot. The app's vite.config.ts stays what\n// it is: its framework's plugin, its aliases.\n// ═══════════════════════════════════════════════════════════════\n\n// What is used of the app's vite — described here rather than imported, since\n// the vite is the app's and its types are the app's too.\ntype DevServer = {\n listen: () => Promise<unknown>;\n printUrls: () => void;\n resolvedUrls: { local: string[] } | null;\n close: () => Promise<void>;\n};\ntype ViteApi = { createServer: (config: { root: string; server?: { port: number }; plugins: unknown[] }) => Promise<DevServer> };\n\nconst isViteApi = (value: unknown): value is ViteApi =>\n value !== null && typeof value === 'object' && typeof Reflect.get(value, 'createServer') === 'function';\n\n// The app's vite — the command carries none of its own.\nconst viteOf = async (root: string): Promise<ViteApi> => {\n let entry: string;\n try {\n entry = createRequire(join(root, 'package.json')).resolve('vite');\n } catch {\n throw new Error(`nisc: this app has no vite installed (looked from ${root}).`);\n }\n const loaded: unknown = await import(pathToFileURL(entry).href);\n if (!isViteApi(loaded)) throw new Error(`nisc: ${entry} is not vite.`);\n return loaded;\n};\n\n// What of the config's `dev` block the plugin is told when it is made. Read\n// once, when the command starts: changing one takes a restart of `nisc dev`.\nexport const devPluginOptionsOf = (dev: NiscMossProject['dev']): { watch?: RegExp; owned?: RegExp; signInFromNetwork?: boolean } => ({\n ...(dev?.watch !== undefined ? { watch: dev.watch } : {}),\n ...(dev?.owned !== undefined ? { owned: dev.owned } : {}),\n ...(dev?.signInFromNetwork !== undefined ? { signInFromNetwork: dev.signInFromNetwork } : {}),\n});\n\n// moss's dev plugin, fed from the config as vite loads it.\nconst mossPlugin = async (configFile: string, dev: NiscMossProject['dev']): Promise<unknown> => {\n const { mossDev } = await import('@niscorp/moss/vite');\n return mossDev({\n label: 'nisc',\n ...devPluginOptionsOf(dev),\n app: async (load) => {\n const loaded = await load(`/${configFile}`);\n const project: unknown = Reflect.get(loaded, 'project');\n if (!isProject(project) || isShellProject(project)) throw new Error(`nisc: ${configFile} no longer describes an app behind moss.`);\n const booted = await project.boot();\n const signIn = project.dev?.signIn;\n return {\n server: booted.server,\n ...(booted.close !== undefined ? { close: booted.close } : {}),\n draw: project.draw,\n ...(project.htmlAttributes !== undefined ? { htmlAttributes: project.htmlAttributes } : {}),\n ...(project.site !== undefined ? { site: project.site } : {}),\n ...(project.tokenKey !== undefined ? { tokenKey: project.tokenKey } : {}),\n ...(signIn !== undefined ? { signIn: (who: string) => signIn(booted.server, who) } : {}),\n };\n },\n });\n};\n\nexport const devServer = async (options: { root: string; port?: number }): Promise<{ url: string; close: () => Promise<void> }> => {\n const project = await loadProject(options.root);\n const configFile = configFileOf(options.root);\n const vite = await viteOf(options.root);\n const server = await vite.createServer({\n root: options.root,\n ...(options.port !== undefined ? { server: { port: options.port } } : {}),\n plugins: isShellProject(project) || configFile === undefined ? [] : [await mossPlugin(configFile, project.dev)],\n });\n await server.listen();\n server.printUrls();\n const url = server.resolvedUrls?.local[0] ?? `http://localhost:${options.port ?? 5173}/`;\n return { url, close: () => server.close() };\n};\n","// ═══════════════════════════════════════════════════════════════\n// The paths an app has, where each one's file goes, and the table a build\n// prints. Pure: no server, no disk — the command hands these what it found.\n// ═══════════════════════════════════════════════════════════════\n\n// What a build learned about one path (moss's `ExportedDocument`, without the\n// markup).\nexport type RouteReport = {\n path: string;\n // the page the path led to; absent: the app's own shell\n page?: string;\n drawn: boolean;\n // something on it can still happen — it wants a server behind it\n live: boolean;\n why: readonly string[];\n // reads whose answers are in the markup as they were when it was drawn\n drawnWith: readonly string[];\n settled: boolean;\n // what the screen's head held, and the actions that said it — absent when\n // the screen has no head and the document's is the template's own\n head?: { elements: readonly unknown[]; actions: readonly string[] };\n};\n\n// `/`, and every page whose path names no parameter. A parameterised page has\n// as many paths as there are rows; those are the app's to list.\nexport const defaultPaths = (pages: readonly { name: string; path: string }[]): string[] => [\n '/',\n ...pages\n .map((page) => page.path)\n .filter((path) => !path.split('/').some((segment) => segment.startsWith(':')))\n .sort(),\n];\n\n// Where a path's file goes under the output directory: `/` is index.html, and\n// every other path is a folder with an index.html in it — what every static\n// host serves for that path without being told to.\nexport const fileOf = (path: string): string => {\n const segments = path.split('?')[0]?.split('/').filter((segment) => segment !== '') ?? [];\n if (segments.some((segment) => segment === '..' || segment === '.')) throw new Error(`nisc: \"${path}\" is not a path a file can be written for.`);\n return [...segments, 'index.html'].join('/');\n};\n\nconst pad = (text: string, width: number): string => text + ' '.repeat(Math.max(0, width - text.length));\n\n// The table. One row per path: whether a file is the whole of it, or a server\n// has to stand behind it — and, in the build's own words, why.\nexport const routeTable = (routes: readonly RouteReport[]): string => {\n // Said only by an app that has a head somewhere: then a path without one is\n // going out under the template's, and that may not be what was meant.\n const says = (route: RouteReport): boolean => (route.head?.elements.length ?? 0) > 0;\n const headed = routes.some(says);\n const rows = routes.map((route) => {\n const mark = !route.drawn ? '✗' : route.live ? '●' : '○';\n const what = route.page === undefined ? 'the app' : `page ${route.page}`;\n const served = !route.drawn ? 'not drawn' : route.live ? 'server' : 'file';\n const notes = [\n ...(route.drawn ? route.why : ['it could not be drawn — it goes out as the undrawn template']),\n ...(route.drawn && !route.settled ? ['it was still loading when the wait ran out — drawn with what it had'] : []),\n ...(route.drawnWith.length > 0 ? [`drawn with ${route.drawnWith.join(', ')} — as it answered at build`] : []),\n ];\n const head = headed && route.drawn ? [says(route) ? `head: its own, said by ${route.head?.actions.join(', ') || 'the shell’s chrome'}` : 'head: the template’s own'] : [];\n return { mark, path: route.path, what, served, notes, head };\n });\n const widths = {\n path: Math.max(5, ...rows.map((row) => row.path.length)),\n what: Math.max(4, ...rows.map((row) => row.what.length)),\n served: Math.max(9, ...rows.map((row) => row.served.length)),\n };\n const lines = [` ${pad('Route', widths.path + 2)}${pad('What', widths.what + 2)}${pad('Served as', widths.served + 2)}Because`];\n for (const row of rows) {\n const head = `${row.mark} ${pad(row.path, widths.path + 2)}${pad(row.what, widths.what + 2)}${pad(row.served, widths.served + 2)}`;\n const [first, ...rest] = [...(row.notes.length > 0 ? row.notes : ['nothing on it can still happen']), ...row.head];\n lines.push(`${head}${first ?? ''}`);\n for (const note of rest) lines.push(`${' '.repeat(head.length)}${note}`);\n }\n lines.push('');\n lines.push('○ file drawn once, for nobody in particular; nothing on it can still happen');\n lines.push('● server something on it can still happen; it wants moss behind it');\n return lines.join('\\n');\n};\n","import { spawnSync } from 'node:child_process';\nimport { existsSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { dirname, extname, join, resolve, sep } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { shellSettled, shellView } from '@niscorp/nova';\nimport type { Shell } from '@niscorp/nova';\nimport { headOf, placeHead } from '@niscorp/nova/document';\nimport type { ScreenHead } from '@niscorp/nova/document';\nimport { livenessOf } from '@niscorp/nova/reflect';\nimport type { NiscShellProject } from './project';\n\n// ═══════════════════════════════════════════════════════════════\n// AN APP WITH ITS OWN SHELL, DRAWN AHEAD OF TIME.\n//\n// The shell lives in the page. A build runs the app's own boot where there is\n// no browser, waits for the screen to be whole, and has the app's adapter draw\n// it to markup; the page's boot then picks that markup up and from there the\n// app is what it always was. No server holds a shell at any point.\n//\n// A file is a claim — \"this is the page\" — so a build does not write one it has\n// not checked. Per path, and each one FAILS the build:\n//\n// drawn the app booted and its screen drew to markup that is not empty\n// whole nothing was still loading when it was drawn\n// same twice a second boot draws the same markup, byte for byte, and says\n// the same head — or the page's own boot would not match what\n// the file says\n// adopted inside a DOM, a third boot picks the markup up and the\n// adapter complains about nothing\n//\n// And one that holds by construction: the boot is handed a path and nothing\n// else, so a file is only ever the screen as nobody in particular sees it.\n//\n// What a build cannot fail on, it reports: what the screen opened with (those\n// answers are in the markup as they were at build), what it can still call, and\n// what it waits on.\n//\n// THE HEAD OF EACH FILE IS ITS SCREEN'S OWN. A page's <head> is a node in a\n// layout (nova's `nova:head`, holding the elements a head holds). It is read\n// off the same shell the markup was drawn from and written into the template's\n// <head>; a path whose screen has none goes out with the template's. A head\n// that holds what it may not — something that runs, or styles — FAILS the\n// build like any other check. With a `site` in the config, each path is given\n// its own canonical address.\n// ═══════════════════════════════════════════════════════════════\n\nconst DEFAULT_BUILD_WAIT_MS = 5000;\nexport const DEFAULT_ROOT = '<div id=\"root\"></div>';\n\nexport type ShellRouteReport = {\n path: string;\n // the whole document; the template as it is when the screen could not be drawn\n html: string;\n // every check that did not hold — empty is a file that may be written\n problems: readonly string[];\n // the actions on the first screen\n actions: readonly string[];\n // endpoints answered while the screen opened: their answers are in the markup\n // as they were when it was drawn\n opensWith: readonly string[];\n // endpoints the first screen can still call once it is in the page\n callsLater: readonly string[];\n // channels the first screen waits on\n listens: readonly string[];\n // what the first screen's head held, and the actions that said it — absent\n // when the screen has no head and the file's is the template's own\n head?: ScreenHead;\n};\n\nconst escapeAttribute = (value: string): string => value.replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;');\n\n// The screen, in the app's own index.html: inside the empty root, with whatever\n// the kit would have put on <html>.\nexport const placeScreen = (template: string, screen: string, attributes: Record<string, string> = {}, root = DEFAULT_ROOT): string => {\n const written = Object.entries(attributes)\n .map(([name, value]) => ` ${name}=\"${escapeAttribute(value)}\"`)\n .join('');\n return (\n template\n // functions, both, so nothing in the screen is read as a replacement pattern\n .replace(root, () => root.replace('></div>', () => `>${screen}</div>`))\n .replace(/<html([^>]*)>/, (whole, existing: string) => (written === '' ? whole : `<html${existing}${written}>`))\n );\n};\n\n// What the first screen is made of, read off the definitions of what is mounted.\nconst factsOf = (shell: Shell): Pick<ShellRouteReport, 'actions' | 'opensWith' | 'callsLater' | 'listens'> => {\n const [actions, opensWith, callsLater, listens] = [new Set<string>(), new Set<string>(), new Set<string>(), new Set<string>()];\n for (const canvas of Object.values(shell.getState().canvases)) {\n for (const instance of canvas.stack) {\n const definition = shell.getRuntime(instance.id)?.definition;\n if (definition === undefined) continue;\n actions.add(definition.id);\n const liveness = livenessOf(definition);\n for (const channel of liveness.listens) listens.add(channel);\n for (const endpoint of liveness.endpoints) {\n const label = `${definition.id}.${endpoint.name}${endpoint.kind === 'fn' ? ' (a function)' : endpoint.url !== undefined ? ` (${endpoint.url})` : ''}`;\n if (endpoint.onOpen) opensWith.add(label);\n if (endpoint.later) callsLater.add(label);\n }\n }\n }\n const sorted = (set: Set<string>): string[] => [...set].sort();\n return { actions: sorted(actions), opensWith: sorted(opensWith), callsLater: sorted(callsLater), listens: sorted(listens) };\n};\n\ntype Drawn = { screen: string; whole: boolean; attributes: Record<string, string>; head: ScreenHead | undefined; facts: ReturnType<typeof factsOf> };\n\n// A drawn screen as the document it goes out in: the screen in the root, and\n// what it says about itself in the head.\nconst documentOf = (project: NiscShellProject, template: string, path: string, drawn: Drawn): string =>\n placeHead(placeScreen(template, drawn.screen, drawn.attributes), drawn.head?.elements, { ...(project.site !== undefined ? { site: project.site } : {}), path });\n\n// One boot, one draw, and the app let go again.\nconst drawOnce = async (project: NiscShellProject, path: string): Promise<Drawn> => {\n const booted = await project.shell({ path });\n try {\n const whole = await shellSettled(booted.shell, { waitMs: project.waitMs ?? DEFAULT_BUILD_WAIT_MS });\n const screen = await project.draw(booted.shell);\n return { screen, whole, attributes: project.htmlAttributes?.(booted.shell) ?? {}, head: headOf(shellView(booted.shell).api), facts: factsOf(booted.shell) };\n } finally {\n await booted.close?.();\n }\n};\n\nconst said = (error: unknown): string => (error instanceof Error ? error.message : String(error));\n\n// ── adopted ──\n//\n// The one check that needs a browser's world. A DOM has to exist BEFORE the\n// app's modules load (an adapter decides what it is running in when it is\n// imported), so it runs in a process of its own: ./adopt stands a DOM up, loads\n// the same config, and for each path puts the markup in a root and makes the\n// app's own `adopt` call over a fresh boot.\n\ntype Adoption = { path: string; complaints: string[] };\n\nconst isAdoption = (value: unknown): value is Adoption =>\n value !== null &&\n typeof value === 'object' &&\n typeof Reflect.get(value, 'path') === 'string' &&\n Array.isArray(Reflect.get(value, 'complaints'));\n\nconst adoptAll = (root: string, pages: readonly { path: string; screen: string }[]): Adoption[] => {\n if (pages.length === 0) return [];\n const here = dirname(fileURLToPath(import.meta.url));\n // built: beside this file. From source (the package's own tests): in dist.\n const entry = [join(here, 'adopt.js'), join(here, '..', 'dist', 'adopt.js')].find((candidate) => existsSync(candidate));\n if (entry === undefined) throw new Error('nisc: the adoption check is not built (packages/cli/dist/adopt.js).');\n const scratch = mkdtempSync(join(tmpdir(), 'nisc-adopt-'));\n try {\n const [asked, answered] = [join(scratch, 'pages.json'), join(scratch, 'adopted.json')];\n writeFileSync(asked, JSON.stringify(pages));\n const result = spawnSync(process.execPath, [entry, root, asked, answered], { cwd: root, stdio: ['ignore', 'ignore', 'pipe'], encoding: 'utf8' });\n if (!existsSync(answered)) {\n const why = result.stderr.trim().split('\\n').slice(-6).join('\\n');\n return pages.map((page) => ({ path: page.path, complaints: [`the adoption check could not run${why === '' ? '' : ` — ${why}`}`] }));\n }\n const parsed: unknown = JSON.parse(readFileSync(answered, 'utf8'));\n return Array.isArray(parsed) ? parsed.filter(isAdoption) : [];\n } finally {\n rmSync(scratch, { recursive: true, force: true });\n }\n};\n\n// Every path, checked.\nexport const surveyShell = async (root: string, project: NiscShellProject, template: string): Promise<ShellRouteReport[]> => {\n if (!template.includes(DEFAULT_ROOT)) {\n throw new Error(`nisc: the built index.html has no empty root (${DEFAULT_ROOT}) — that is where a screen goes.`);\n }\n const paths = project.paths === undefined ? ['/'] : await project.paths();\n const none = { actions: [], opensWith: [], callsLater: [], listens: [] };\n\n const first: { path: string; drawn?: Drawn; problems: string[] }[] = [];\n for (const path of paths) {\n const problems: string[] = [];\n let drawn: Drawn | undefined;\n try {\n drawn = await drawOnce(project, path);\n if (drawn.screen.trim() === '') problems.push('drawn: it drew to nothing');\n if (!drawn.whole) problems.push(`whole: it was still loading after ${project.waitMs ?? DEFAULT_BUILD_WAIT_MS}ms`);\n for (const why of drawn.head?.refused ?? []) problems.push(`head: ${why}`);\n const again = await drawOnce(project, path);\n if (again.screen !== drawn.screen) problems.push(`same twice: a second boot drew different markup${differenceOf(drawn.screen, again.screen)}`);\n const [head, headAgain] = [JSON.stringify(drawn.head ?? null), JSON.stringify(again.head ?? null)];\n if (headAgain !== head) problems.push(`same twice: a second boot said a different head${differenceOf(head, headAgain)}`);\n } catch (error) {\n problems.push(`drawn: ${said(error)}`);\n }\n first.push({ path, ...(drawn !== undefined ? { drawn } : {}), problems });\n }\n\n // only what is worth adopting: a screen that drew, whole\n const adoptable = first.flatMap((route) => (route.drawn !== undefined && route.drawn.whole && route.drawn.screen.trim() !== '' ? [{ path: route.path, screen: route.drawn.screen }] : []));\n const adoptions = new Map(adoptAll(root, adoptable).map((adoption) => [adoption.path, adoption.complaints]));\n\n return first.map((route) => {\n const asked = adoptable.some((page) => page.path === route.path);\n const complaints = asked ? (adoptions.get(route.path) ?? ['the adoption check said nothing about it']) : [];\n const problems = [...route.problems, ...complaints.map((complaint) => `adopted: ${complaint}`)];\n return {\n path: route.path,\n html: route.drawn === undefined ? template : documentOf(project, template, route.path, route.drawn),\n problems,\n ...(route.drawn?.facts ?? none),\n ...(route.drawn?.head !== undefined ? { head: route.drawn.head } : {}),\n };\n });\n};\n\n// Where two draws part, in a few words — enough to find it.\nconst differenceOf = (a: string, b: string): string => {\n let at = 0;\n while (at < a.length && at < b.length && a[at] === b[at]) at += 1;\n const around = (text: string): string => JSON.stringify(text.slice(Math.max(0, at - 30), at + 50));\n return ` — at character ${at}: ${around(a)} then ${around(b)}`;\n};\n\nconst pad = (text: string, width: number): string => text + ' '.repeat(Math.max(0, width - text.length));\n\nexport const shellRouteTable = (routes: readonly ShellRouteReport[]): string => {\n const width = Math.max(5, ...routes.map((route) => route.path.length)) + 2;\n const lines = [` ${pad('Route', width)}First screen`];\n const indent = ' '.repeat(width + 2);\n // Said only by an app that has a head somewhere: then a path without one is\n // going out under the template's, and that may not be what was meant.\n const says = (route: ShellRouteReport): boolean => (route.head?.elements.length ?? 0) > 0;\n const headed = routes.some(says);\n const headNote = (route: ShellRouteReport): string =>\n says(route) ? `head: its own, said by ${route.head?.actions.join(', ') || 'the shell’s chrome'}` : 'head: the template’s own';\n for (const route of routes) {\n const ok = route.problems.length === 0;\n const notes = ok\n ? [\n `drawn · whole · same twice · adopted${route.actions.length > 0 ? ` (${route.actions.join(', ')})` : ''}`,\n ...(route.opensWith.length > 0 ? [`opened with ${route.opensWith.join(', ')} — in the file as answered at build`] : []),\n ...(route.callsLater.length > 0 ? [`can still call ${route.callsLater.join(', ')}`] : []),\n ...(route.listens.length > 0 ? [`waits on ${route.listens.join(', ')}`] : []),\n ...(headed ? [headNote(route)] : []),\n ]\n : route.problems;\n const [head, ...rest] = notes;\n lines.push(`${ok ? '○' : '✗'} ${pad(route.path, width)}${head ?? ''}`);\n for (const note of rest) lines.push(`${indent}${note}`);\n }\n lines.push('');\n lines.push('○ a file: the first screen, drawn for nobody in particular; the page’s own shell picks it up');\n lines.push('✗ not written: a check did not hold');\n return lines.join('\\n');\n};\n\n// ── served ──\n//\n// The same draw, per request: the first answer to a path is its screen, and\n// everything else in the built folder is a file. No checks here — a build made\n// them; a screen that will not draw goes out as the template, and the page's\n// own boot paints it as it did before any of this existed.\n//\n// What a browser may keep of all this, and how it travels, is not said here:\n// `start` puts that around this handler (./site), as it does around moss's.\n\nconst TYPES: Record<string, string> = {\n '.html': 'text/html; charset=utf-8',\n '.js': 'text/javascript; charset=utf-8',\n '.mjs': 'text/javascript; charset=utf-8',\n '.css': 'text/css; charset=utf-8',\n '.json': 'application/json; charset=utf-8',\n '.svg': 'image/svg+xml',\n '.png': 'image/png',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.webp': 'image/webp',\n '.ico': 'image/x-icon',\n '.woff2': 'font/woff2',\n '.woff': 'font/woff',\n '.wasm': 'application/wasm',\n '.data': 'application/octet-stream',\n '.map': 'application/json; charset=utf-8',\n '.txt': 'text/plain; charset=utf-8',\n};\n\nexport const shellSite = (project: NiscShellProject, dist: string): ((request: Request) => Promise<Response>) => {\n const base = resolve(dist);\n return async (request) => {\n const path = decodeURIComponent(new URL(request.url).pathname);\n if (path !== '/' && path !== '/index.html') {\n const file = resolve(base, `.${path}`);\n const stats = file === base || file.startsWith(base + sep) ? statSync(file, { throwIfNoEntry: false }) : undefined;\n if (stats?.isFile() === true) {\n // How big it is and when it last changed — what `start` needs to say\n // what a browser may keep, and to answer \"has it changed?\" (./site).\n return new Response(readFileSync(file), {\n headers: { 'content-type': TYPES[extname(file)] ?? 'application/octet-stream', 'content-length': String(stats.size), 'last-modified': stats.mtime.toUTCString() },\n });\n }\n // a name with an extension that is not there is a missing file, not a page\n if (extname(path) !== '') return new Response('not found', { status: 404 });\n }\n const template = readFileSync(join(base, 'index.html'), 'utf8');\n const headers = { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-cache' };\n try {\n const at = path === '/index.html' ? '/' : path;\n return new Response(documentOf(project, template, at, await drawOnce(project, at)), { headers });\n } catch (error) {\n console.error(`[nisc] \"${path}\" could not be drawn — serving it undrawn:`, error);\n return new Response(template, { headers });\n }\n };\n};\n","import { constants, createBrotliCompress, createGzip } from 'node:zlib';\nimport type { BrotliCompress, Gzip } from 'node:zlib';\n\n// ═══════════════════════════════════════════════════════════════\n// WHAT `nisc start` PUTS AROUND AN APP — either kind.\n//\n// `start` hands a listener one handler: an app with its own shell's\n// (./shell-site), or the moss server's. This wraps that handler, so the two\n// things below are said once, here, for both — and nothing inside moss or the\n// shell's own handler knows them.\n//\n// WHAT A BROWSER MAY KEEP (`withCaching`). What the bundler writes under\n// assets/ is named by its content: it is kept for a year and never asked\n// about again. Every other file is asked about each time, and answered 304\n// when it has not changed. An answer that already says for itself — every\n// drawn document does (who may keep a page follows from who asked) — is left\n// exactly as it is.\n//\n// HOW IT TRAVELS (`withCompression`). Text a browser reads goes out\n// compressed, brotli or gzip by what was asked for, a piece at a time as the\n// handler produces it — an answer that streams still streams.\n//\n// The app server's own paths (`except`: moss's /api, /catalog, …) are passed\n// through untouched: what they answer is theirs to say.\n// ═══════════════════════════════════════════════════════════════\n\n// A handler as a listener calls it: the request, and whatever else the listener\n// hands over (the Node request and response, for moss) — passed on as given.\nexport type SiteHandler<Rest extends readonly unknown[] = []> = (request: Request, ...rest: Rest) => Response | Promise<Response>;\n\nexport type SiteOptions = {\n // Paths whose answers are not the site's: left exactly as the handler made them.\n except?: RegExp;\n};\n\n// what the bundler writes is named by its content\nconst KEPT_PATHS = /^\\/assets\\//;\nconst KEPT_FOREVER = 'public, max-age=31536000, immutable';\n\nexport const withCaching =\n <Rest extends readonly unknown[]>(handler: SiteHandler<Rest>, options: SiteOptions = {}): SiteHandler<Rest> =>\n async (request, ...rest) => {\n const response = await handler(request, ...rest);\n if ((request.method !== 'GET' && request.method !== 'HEAD') || response.status !== 200) return response;\n const path = new URL(request.url).pathname;\n if (options.except?.test(path) === true) return response;\n if (response.headers.has('cache-control')) return response;\n\n const headers = new Headers(response.headers);\n if (KEPT_PATHS.test(path)) {\n headers.set('cache-control', KEPT_FOREVER);\n return new Response(response.body, { status: 200, headers });\n }\n headers.set('cache-control', 'no-cache');\n const [since, modified] = [request.headers.get('if-modified-since'), headers.get('last-modified')];\n if (since !== null && modified !== null && Date.parse(since) >= Date.parse(modified)) {\n await response.body?.cancel();\n headers.delete('content-length');\n return new Response(null, { status: 304, headers });\n }\n return new Response(response.body, { status: 200, headers });\n };\n\n// Text a browser reads — and nothing that is a conversation (an event stream).\nconst COMPRESSIBLE = /^(text\\/(?!event-stream)|application\\/(json|javascript|xml|manifest\\+json|wasm)|image\\/svg\\+xml)/i;\n// under this, the headers cost more than the saving\nconst SMALL_BYTES = 1024;\n// fast enough to do per answer, and already smaller than gzip's best\nconst BROTLI_QUALITY = 5;\n\ntype Encoding = 'br' | 'gzip';\n\n// What the asker takes, best first. `q=0` is a refusal.\nconst encodingFor = (header: string | null): Encoding | undefined => {\n const offered = new Map<string, number>();\n for (const part of (header ?? '').toLowerCase().split(',')) {\n const [name = '', ...parameters] = part.split(';').map((piece) => piece.trim());\n const weight = parameters.find((parameter) => parameter.startsWith('q='));\n if (name !== '') offered.set(name, weight === undefined ? 1 : Number(weight.slice(2)));\n }\n if ((offered.get('br') ?? 0) > 0) return 'br';\n if ((offered.get('gzip') ?? 0) > 0) return 'gzip';\n return undefined;\n};\n\n// Flushed after every piece written: what goes in comes out, compressed, before\n// the next piece is asked for. That is what keeps a streamed answer streaming.\nconst compressorFor = (encoding: Encoding): BrotliCompress | Gzip =>\n encoding === 'br'\n ? createBrotliCompress({ flush: constants.BROTLI_OPERATION_FLUSH, params: { [constants.BROTLI_PARAM_QUALITY]: BROTLI_QUALITY } })\n : createGzip({ flush: constants.Z_SYNC_FLUSH });\n\n// A body, compressed as it is read. `whole` is handed all of it once it has\n// gone out complete — never for a body that was cut short.\nconst compressedBody = (source: ReadableStream<Uint8Array>, encoding: Encoding, whole?: (bytes: Buffer<ArrayBuffer>) => void): ReadableStream<Uint8Array> => {\n const reader = source.getReader();\n const compressor = compressorFor(encoding);\n const pieces: Buffer[] = [];\n // whoever was reading has stopped: nothing more may be handed to them\n let isLetGo = false;\n let finished: () => void = () => undefined;\n const ended = new Promise<void>((done) => {\n finished = done;\n });\n return new ReadableStream<Uint8Array>({\n start: (controller) => {\n compressor.on('data', (piece: Buffer) => {\n if (isLetGo) return;\n if (whole !== undefined) pieces.push(piece);\n controller.enqueue(piece);\n });\n compressor.on('end', () => {\n if (!isLetGo) {\n whole?.(Buffer.concat(pieces));\n controller.close();\n }\n finished();\n });\n compressor.on('error', (error) => {\n if (!isLetGo) controller.error(error);\n finished();\n });\n },\n pull: async () => {\n // a source that fails takes the compressor with it; the failure is the reader's to hear\n const { done, value } = await reader.read().catch((error: unknown) => {\n compressor.destroy();\n throw error;\n });\n if (done) {\n compressor.end();\n return ended;\n }\n return new Promise<void>((taken) => {\n compressor.write(value, () => taken());\n });\n },\n cancel: async (reason) => {\n isLetGo = true;\n compressor.destroy();\n await reader.cancel(reason);\n },\n });\n};\n\nexport const withCompression = <Rest extends readonly unknown[]>(handler: SiteHandler<Rest>, options: SiteOptions = {}): SiteHandler<Rest> => {\n // An answer that says it will never change is compressed once: what it came\n // to is remembered, by what was asked for and how. Bounded by what the built\n // folder holds under assets/.\n const remembered = new Map<string, Buffer<ArrayBuffer>>();\n return async (request, ...rest) => {\n const response = await handler(request, ...rest);\n if (request.method !== 'GET' || response.status !== 200 || response.body === null) return response;\n const path = new URL(request.url).pathname;\n if (options.except?.test(path) === true) return response;\n if (!COMPRESSIBLE.test(response.headers.get('content-type') ?? '')) return response;\n if (response.headers.has('content-encoding') || /no-transform/i.test(response.headers.get('cache-control') ?? '')) return response;\n\n // From here the answer depends on what was asked for, compressed or not —\n // whatever keeps a copy has to be told.\n const headers = new Headers(response.headers);\n const varies = (headers.get('vary') ?? '').toLowerCase().split(',').map((name) => name.trim());\n if (!varies.includes('accept-encoding')) headers.append('vary', 'Accept-Encoding');\n\n const encoding = encodingFor(request.headers.get('accept-encoding'));\n const length = headers.get('content-length');\n if (encoding === undefined || (length !== null && Number(length) < SMALL_BYTES)) return new Response(response.body, { status: 200, headers });\n\n headers.set('content-encoding', encoding);\n headers.delete('content-length');\n // the bytes are no longer those bytes\n const etag = headers.get('etag');\n if (etag !== null && !etag.startsWith('W/')) headers.set('etag', `W/${etag}`);\n\n if (!/\\bimmutable\\b/i.test(headers.get('cache-control') ?? '')) return new Response(compressedBody(response.body, encoding), { status: 200, headers });\n const key = `${encoding} ${path} ${headers.get('last-modified') ?? ''}`;\n const known = remembered.get(key);\n if (known === undefined) return new Response(compressedBody(response.body, encoding, (bytes) => remembered.set(key, bytes)), { status: 200, headers });\n await response.body.cancel();\n headers.set('content-length', String(known.length));\n return new Response(known, { status: 200, headers });\n };\n};\n\n// Both, in the order they apply: said what may be kept, then compressed.\nexport const siteHandler = <Rest extends readonly unknown[]>(handler: SiteHandler<Rest>, options: SiteOptions = {}): SiteHandler<Rest> =>\n withCompression(withCaching(handler, options), options);\n","import { existsSync, readFileSync, statSync, writeFileSync } from 'node:fs';\nimport { join, resolve, sep } from 'node:path';\n\n// ═══════════════════════════════════════════════════════════════\n// THE STYLESHEET GOES IN THE PAGE.\n//\n// A drawn page arrives as markup, and a browser paints none of it until it has\n// the stylesheet. As a file of its own that is a second round trip before the\n// first paint. So once the bundler is done, the page it wrote (`index.html`,\n// the template every drawn page is made from) has each stylesheet it links\n// written into it as a <style>, and one response paints the page.\n//\n// It is done ONCE, to the file in the built folder — every reader of that file\n// (`build`, `export`, `start`, moss's document) then hands out the same head\n// without knowing any of this. The stylesheet's own file stays where it is.\n//\n// A link is left as it is, and the build says so, when moving the stylesheet\n// could change what it means: a link that says more than where the file is (a\n// `media`, a `title`), a file that is not in the built folder, a stylesheet\n// that names another file relative to itself.\n// ═══════════════════════════════════════════════════════════════\n\n// What became of each stylesheet link the page had.\nexport type StylesheetReport = {\n // now in the page: where it was linked from, and how much text that is\n inPage: readonly { href: string; bytes: number }[];\n // left as a file, and why\n left: readonly { href: string; why: string }[];\n};\n\nexport type StylesheetRewrite = StylesheetReport & { html: string };\n\nconst attributesOf = (tag: string): Record<string, string> => {\n const found: Record<string, string> = {};\n // past `<link`\n for (const match of tag.slice(5).matchAll(/([^\\s\"'<>/=]+)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s\"'=<>`]+)))?/g)) {\n const name = match[1];\n if (name !== undefined) found[name.toLowerCase()] = match[2] ?? match[3] ?? match[4] ?? '';\n }\n return found;\n};\n\n// what a link may say and still be only \"this stylesheet, from here\"\nconst PLAIN = new Set(['rel', 'href', 'crossorigin']);\n\n// A url() that points at the same thing from a page at any path: an absolute\n// path, a full address, a data: or blob: URI, a fragment.\nconst isPortableUrl = (url: string): boolean => url === '' || /^(\\/|data:|blob:|https?:|#)/i.test(url);\n\n// Why a stylesheet cannot move into a page — nothing, when it can.\nconst whyStylesheetStays = (css: string): string | undefined => {\n if (/@import\\b/i.test(css)) return 'it imports another stylesheet';\n for (const match of css.matchAll(/url\\(\\s*(?:\"([^\"]*)\"|'([^']*)'|([^)]*?))\\s*\\)/gi)) {\n const url = (match[1] ?? match[2] ?? match[3] ?? '').trim();\n if (!isPortableUrl(url)) return `it names a file relative to itself (${url})`;\n }\n return undefined;\n};\n\n// The page, with every stylesheet it links by a plain local path written into\n// it. `read` answers a stylesheet's text by its href, or nothing when the built\n// folder has no such file. Pure: a second pass over its own output changes\n// nothing.\nexport const stylesheetInPage = (html: string, read: (href: string) => string | undefined): StylesheetRewrite => {\n const inPage: { href: string; bytes: number }[] = [];\n const left: { href: string; why: string }[] = [];\n const rewritten = html.replace(/<link\\b[^>]*>/gi, (tag) => {\n const attributes = attributesOf(tag);\n if ((attributes['rel'] ?? '').toLowerCase() !== 'stylesheet') return tag;\n const href = attributes['href'] ?? '';\n const stays = (why: string): string => {\n left.push({ href, why });\n return tag;\n };\n const extra = Object.keys(attributes).filter((name) => !PLAIN.has(name));\n if (extra.length > 0) return stays(`its link says more than where it is (${extra.join(', ')})`);\n if (!href.startsWith('/') || href.startsWith('//') || /[?#]/.test(href)) return stays('it is not a path into the built folder');\n const css = read(href);\n if (css === undefined) return stays('it is not in the built folder');\n const why = whyStylesheetStays(css);\n if (why !== undefined) return stays(why);\n inPage.push({ href, bytes: Buffer.byteLength(css) });\n // A <style> ends at the first `</style`, whatever CSS thinks it is inside.\n // `\\/` is the same character to CSS, and not that to the HTML parser.\n return `<style>${css.replace(/<\\/(style)/gi, '<\\\\/$1')}</style>`;\n });\n return { html: rewritten, inPage, left };\n};\n\n// The same, over the built folder: its index.html rewritten where it stands.\n// Nothing to do (no page, no stylesheet link) is nothing done.\nexport const writeStylesheetIntoPage = (dist: string): StylesheetReport => {\n const page = join(dist, 'index.html');\n if (!existsSync(page)) return { inPage: [], left: [] };\n const base = resolve(dist);\n const read = (href: string): string | undefined => {\n const file = resolve(base, `.${href}`);\n return file.startsWith(base + sep) && existsSync(file) && statSync(file).isFile() ? readFileSync(file, 'utf8') : undefined;\n };\n const html = readFileSync(page, 'utf8');\n const rewrite = stylesheetInPage(html, read);\n if (rewrite.html !== html) writeFileSync(page, rewrite.html);\n return { inPage: rewrite.inPage, left: rewrite.left };\n};\n","import { spawn, spawnSync } from 'node:child_process';\nimport { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport type { AddressInfo } from 'node:net';\nimport { dirname, join, resolve } from 'node:path';\nimport { serve } from '@hono/node-server';\nimport type { ExportedDocument } from '@niscorp/moss';\nimport { devServer } from './dev';\nimport { isShellProject, loadProject } from './project';\nimport type { NiscMossProject, NiscProject, NiscShellProject } from './project';\nimport { defaultPaths, fileOf, routeTable } from './routes';\nimport { shellRouteTable, shellSite, surveyShell } from './shell-site';\nimport type { ShellRouteReport } from './shell-site';\nimport { siteHandler } from './site';\nimport { writeStylesheetIntoPage } from './stylesheet';\n\n// ═══════════════════════════════════════════════════════════════\n// What `nisc` does. Each command is the app's own machinery, run in order:\n//\n// dev the app's own vite, with the app server inside it when it has one\n// build bundle the terminal and write its stylesheet into its page, then\n// draw every path once and say how each is served — a file, or a server\n// export build, then write every path as a file: the whole site as a folder\n// start serve the built terminal from the app's own process, pages drawn —\n// compressed, and with what a browser may keep said (./site)\n// check the app's check suite\n// migrate apply the tables' pending migrations, if the app's entries fit what\n// they leave\n//\n// Nothing here knows an app. How it boots and how a screen is drawn come from\n// its nisc.config.ts. An app behind moss hands over its server, and which paths\n// exist and what each needs come from that (`server.pages`, `exportDocuments`).\n// An app with its own shell hands over its boot, and every path is drawn from\n// that and checked (./shell-site). Moss is loaded only for the first kind — an\n// app without it does not have it installed.\n// ═══════════════════════════════════════════════════════════════\n\nexport type CommandOptions = {\n // the app's root (where nisc.config.ts is)\n root: string;\n // export: where the files go (default `out`), relative to the root\n out?: string;\n // export: write the site even though some path wants a server behind it\n allowLive?: boolean;\n // start: the port (default $PORT, then 8787)\n port?: number;\n // build/export: skip the bundler (the terminal is already built)\n skipBundle?: boolean;\n // migrate: do all of it, then roll it back\n dryRun?: boolean;\n print?: (line: string) => void;\n};\n\nconst say = (options: CommandOptions): ((line: string) => void) => options.print ?? ((line) => console.log(line));\n\n// A tool the APP has installed, found from the app's own root — the command\n// carries no bundler and no test runner of its own.\nconst toolOf = (root: string, name: string, bin: string): string => {\n const require = createRequire(join(root, 'package.json'));\n let manifestPath: string;\n try {\n manifestPath = require.resolve(`${name}/package.json`);\n } catch {\n throw new Error(`nisc: this app has no ${name} installed (looked from ${root}).`);\n }\n const manifest: unknown = JSON.parse(readFileSync(manifestPath, 'utf8'));\n const bins: unknown = manifest !== null && typeof manifest === 'object' ? Reflect.get(manifest, 'bin') : undefined;\n const relative: unknown = typeof bins === 'string' ? bins : bins !== null && typeof bins === 'object' ? Reflect.get(bins, bin) : undefined;\n if (typeof relative !== 'string') throw new Error(`nisc: ${name} ships no \"${bin}\" command.`);\n return join(dirname(manifestPath), relative);\n};\n\nconst distOf = (root: string, project: NiscProject): string => resolve(root, project.dist ?? 'dist');\n\n// The app's own vite, and then the one thing done to what it wrote: the page's\n// stylesheet goes into the page (./stylesheet). A terminal that is already built\n// (`skipBundle`) is taken as it is.\nconst bundle = (options: CommandOptions, project: NiscProject): void => {\n const result = spawnSync(process.execPath, [toolOf(options.root, 'vite', 'vite'), 'build'], { cwd: options.root, stdio: 'inherit' });\n if (result.status !== 0) throw new Error('nisc: the bundler failed — nothing was drawn.');\n if (project.stylesheet === 'file') return;\n const print = say(options);\n const { inPage, left } = writeStylesheetIntoPage(distOf(options.root, project));\n if (inPage.length + left.length > 0) print('');\n for (const sheet of inPage) print(`nisc: ${sheet.href} is in the page (${(sheet.bytes / 1024).toFixed(1)} kB) — one response paints it`);\n for (const sheet of left) print(`nisc: ${sheet.href} stays a file — ${sheet.why}`);\n if (inPage.length > 0) print(\" A Content-Security-Policy that forbids inline styles would refuse it: `stylesheet: 'file'` in nisc.config.ts keeps it a file.\");\n};\n\n// `start` tells browsers to keep what is under /assets/ for a year — right for\n// what the bundler writes there, named by its content. The bundler also copies\n// the app's public/ as it is, so a file of the app's own under public/assets/\n// would be kept just as long, under a name that says nothing about its content.\nconst warnOfOwnAssets = (options: CommandOptions): void => {\n if (!existsSync(join(options.root, 'public', 'assets'))) return;\n say(options)('nisc: public/assets/ holds files of your own. `nisc start` has browsers keep everything under /assets/ for a year, so a change to one of them will not be seen under the same name — keep them elsewhere in public/.');\n};\n\n// index.html says where the page lives, once — and every path is written from\n// it. With more than one path and no `site`, each file would name that one\n// address as its own, which tells a search engine they are all copies of it.\nconst warnOfOneAddress = (options: CommandOptions, project: NiscProject, template: string, paths: number): void => {\n if (project.site !== undefined || paths < 2 || !/<link\\b[^>]*\\brel\\s*=\\s*[\"']?canonical\\b/i.test(template)) return;\n say(options)('');\n say(options)(`nisc: index.html names one canonical address and this app has ${paths} paths — every file would say it lives there.`);\n say(options)(' `site: \"https://…\"` in nisc.config.ts gives each path its own.');\n};\n\n// Stand the app up, draw every path once for nobody, let the app go.\nconst templateOf =(options: CommandOptions, project: NiscProject): string => {\n const template = join(distOf(options.root, project), 'index.html');\n if (!existsSync(template)) throw new Error(`nisc: no built terminal at ${template} — run \\`nisc build\\`.`);\n return readFileSync(template, 'utf8');\n};\n\nconst survey = async (options: CommandOptions, project: NiscMossProject): Promise<ExportedDocument[]> => {\n const template = templateOf(options, project);\n const { exportDocuments } = await import('@niscorp/moss');\n const booted = await project.boot();\n try {\n const paths = project.paths === undefined ? defaultPaths(booted.server.pages) : await project.paths(booted.server);\n return await exportDocuments({\n server: booted.server,\n template,\n draw: project.draw,\n ...(project.htmlAttributes !== undefined ? { htmlAttributes: project.htmlAttributes } : {}),\n ...(project.site !== undefined ? { site: project.site } : {}),\n ...(project.tokenKey !== undefined ? { tokenKey: project.tokenKey } : {}),\n paths,\n });\n } finally {\n await booted.close?.();\n }\n};\n\n// What a build found, either way round: every path, and whether the build holds.\nexport type BuildResult =\n | { kind: 'moss'; ok: boolean; routes: ExportedDocument[] }\n | { kind: 'shell'; ok: boolean; routes: ShellRouteReport[] };\n\nconst buildShell = async (options: CommandOptions, project: NiscShellProject): Promise<BuildResult> => {\n const template = templateOf(options, project);\n const routes = await surveyShell(options.root, project, template);\n say(options)('');\n say(options)(shellRouteTable(routes));\n warnOfOneAddress(options, project, template, routes.length);\n return { kind: 'shell', ok: routes.every((route) => route.problems.length === 0), routes };\n};\n\nexport const build = async (options: CommandOptions): Promise<BuildResult> => {\n const project = await loadProject(options.root);\n if (options.skipBundle !== true) bundle(options, project);\n warnOfOwnAssets(options);\n if (isShellProject(project)) return buildShell(options, project);\n const routes = await survey(options, project);\n say(options)('');\n say(options)(routeTable(routes));\n warnOfOneAddress(options, project, templateOf(options, project), routes.length);\n return { kind: 'moss', ok: routes.every((route) => route.drawn), routes };\n};\n\nconst write = (options: CommandOptions, project: NiscProject, out: string, routes: readonly { path: string; html: string }[]): void => {\n rmSync(out, { recursive: true, force: true });\n cpSync(distOf(options.root, project), out, { recursive: true });\n for (const route of routes) {\n const file = join(out, fileOf(route.path));\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(file, route.html);\n }\n say(options)('');\n say(options)(`nisc: ${routes.length} paths written to ${out}`);\n};\n\n// The whole site as a folder. A path that wants a server behind it is not\n// something a folder can be — so unless the caller says a server will stand\n// beside the files (`allowLive`), nothing is written and the table says why.\n//\n// An app with its own shell has no such path: the shell is in the page, so a\n// folder is all of it. What stops ITS files is a check that did not hold.\nexport const exportSite = async (options: CommandOptions): Promise<{ written: boolean; result: BuildResult; out: string }> => {\n const project = await loadProject(options.root);\n const result = await build(options);\n const out = resolve(options.root, options.out ?? 'out');\n if (result.kind === 'shell') {\n if (!result.ok) {\n const failed = result.routes.filter((route) => route.problems.length > 0);\n say(options)('');\n say(options)(`nisc: ${failed.length} of ${result.routes.length} paths did not hold (${failed.map((route) => route.path).join(', ')}). Nothing was written.`);\n return { written: false, result, out };\n }\n write(options, project, out, result.routes);\n return { written: true, result, out };\n }\n const routes = result.routes;\n const live = routes.filter((route) => route.live || !route.drawn);\n if (live.length > 0 && options.allowLive !== true) {\n say(options)('');\n say(options)(`nisc: ${live.length} of ${routes.length} paths cannot be a file alone (${live.map((route) => route.path).join(', ')}).`);\n say(options)(' Nothing was written. With a server beside the files they still work: `nisc export --allow-live`.');\n return { written: false, result, out };\n }\n write(options, project, out, routes);\n return { written: true, result, out };\n};\n\nconst listening = async (httpServer: ReturnType<typeof serve>, options: CommandOptions): Promise<string> => {\n await new Promise<void>((up) => httpServer.once('listening', () => up()));\n const address = httpServer.address();\n const port = address !== null && typeof address === 'object' ? (address satisfies AddressInfo).port : options.port;\n return `http://localhost:${port}`;\n};\n\nexport const start = async (options: CommandOptions): Promise<{ url: string; close: () => Promise<void> }> => {\n const project = await loadProject(options.root);\n const dist = distOf(options.root, project);\n if (!existsSync(join(dist, 'index.html'))) throw new Error(`nisc: no built terminal in ${dist} — run \\`nisc build\\`.`);\n const port = options.port ?? Number(process.env['PORT'] ?? 8787);\n if (isShellProject(project)) {\n // no server shell, no socket: each path's first answer is its screen, drawn\n // from a boot of the app's own, and the page's shell takes it from there\n const httpServer = serve({ fetch: siteHandler(shellSite(project, dist)), port });\n const url = await listening(httpServer, options);\n say(options)(`nisc: serving ${url} — the built app, each path’s first screen drawn; the shell is the page’s own`);\n return { url, close: async () => void httpServer.close() };\n }\n const { attachSocket, mountSite, MOSS_PATHS } = await import('@niscorp/moss/node');\n const booted = await project.boot();\n await project.routes?.(booted.server);\n mountSite(booted.server, {\n dist,\n draw: project.draw,\n ...(project.htmlAttributes !== undefined ? { htmlAttributes: project.htmlAttributes } : {}),\n ...(project.site !== undefined ? { site: project.site } : {}),\n ...(project.tokenKey !== undefined ? { tokenKey: project.tokenKey } : {}),\n });\n // what the app server answers itself is its own to say; the rest is the site\n const httpServer = serve({ fetch: siteHandler(booted.server.fetch, { except: MOSS_PATHS }), port });\n attachSocket(httpServer, booted.server.socket);\n const url = await listening(httpServer, options);\n say(options)(`nisc: serving ${url} — the built terminal, its pages drawn; the socket at /socket`);\n return {\n url,\n close: async () => {\n httpServer.close();\n await booted.close?.();\n },\n };\n};\n\n// The tables, moved — by moss (`migrateTables`), which refuses a run that would\n// leave an entry of the manifest not fitting. A refusal is thrown with its\n// reasons, and nothing was applied. What a run that lands took away is said.\nexport const migrate = async (options: CommandOptions): Promise<void> => {\n const project = await loadProject(options.root);\n if (isShellProject(project) || project.app === undefined || project.runtime === undefined) {\n throw new Error('nisc: `nisc migrate` needs `app` and `runtime` in nisc.config.ts — the manifest, and the environment it runs on.');\n }\n const { migrateTables } = await import('@niscorp/moss');\n const print = say(options);\n const isDryRun = options.dryRun === true;\n const runtime = await project.runtime();\n try {\n const report = await migrateTables(runtime, project.app, isDryRun ? { dryRun: true } : {});\n if (report.applied.length === 0) print('nisc: nothing to migrate');\n else print(isDryRun ? `nisc: would apply ${report.applied.length} — rolled back, nothing changed` : `nisc: applied ${report.applied.length}`);\n for (const migration of report.applied) print(` ${migration.ref} ${migration.description}`);\n if (report.removed.length > 0) print(`nisc: this run removes ${report.removed.join(', ')}`);\n if (report.retyped.length > 0) print(`nisc: this run changes the type of ${report.retyped.join(', ')}`);\n if (report.alreadyBroken.length > 0) print('nisc: not fitting before this run either, and seeded as they are — said, not refused:');\n for (const entry of report.alreadyBroken) print(` ${entry}`);\n } finally {\n await runtime.close?.();\n }\n};\n\n// The two that hand over to a tool of the app's own and stay out of the way.\nconst handOver = (options: CommandOptions, tool: string, args: readonly string[]): Promise<number> =>\n new Promise((done) => {\n const child = spawn(process.execPath, [tool, ...args], { cwd: options.root, stdio: 'inherit' });\n child.once('exit', (code) => done(code ?? 1));\n });\n\nexport const dev = (options: CommandOptions): Promise<{ url: string; close: () => Promise<void> }> =>\n devServer({ root: options.root, ...(options.port !== undefined ? { port: options.port } : {}) });\n\nexport const check = async (options: CommandOptions): Promise<number> => {\n const project = await loadProject(options.root);\n return handOver(options, toolOf(options.root, 'tsx', 'tsx'), [project.checks ?? 'src/dev/all-checks.ts']);\n};\n","import { resolve } from 'node:path';\nimport { build, check, dev, exportSite, migrate, start } from './commands';\nimport type { CommandOptions } from './commands';\n\n// ═══════════════════════════════════════════════════════════════\n// nisc — the command line. It parses, and hands over to ./commands.\n// ═══════════════════════════════════════════════════════════════\n\nconst USAGE = `nisc — the command for a nisc application\n\n nisc dev the app's dev server — its vite, with the app server inside\n nisc build bundle the app, draw every path, and check what was drawn\n nisc export build, then write every path as a file (the site as a folder)\n nisc start serve the built app, each path's first screen drawn\n nisc check the app's check suite\n nisc migrate apply the tables' pending migrations, if the app's entries fit the result\n\n --root <dir> the app's root (default: here) — where nisc.config.ts is\n --out <dir> export: where the files go (default: out)\n --allow-live export: write even though some path wants a server behind it\n --port <n> dev, start: the port (start: $PORT, then 8787)\n --skip-bundle build, export: the terminal is already built\n --check migrate: do all of it, then roll it back\n\nAn app says in nisc.config.ts how it boots and how one of its screens is drawn.\nBehind moss (boot + draw): which paths exist and what each needs is read off the\nserver. With its own shell (shell + draw + adopt): every path is drawn from the\napp's own boot, and a file is written only if the page's boot picks it up clean.`;\n\nconst valueAfter = (args: readonly string[], flag: string): string | undefined => {\n const at = args.indexOf(flag);\n return at < 0 ? undefined : args[at + 1];\n};\n\nconst main = async (): Promise<number> => {\n const [command, ...args] = process.argv.slice(2);\n const port = valueAfter(args, '--port');\n const out = valueAfter(args, '--out');\n const options: CommandOptions = {\n root: resolve(valueAfter(args, '--root') ?? process.cwd()),\n ...(out !== undefined ? { out } : {}),\n ...(port !== undefined ? { port: Number(port) } : {}),\n allowLive: args.includes('--allow-live'),\n skipBundle: args.includes('--skip-bundle'),\n };\n\n if (command === 'dev' || command === 'start') {\n const served = command === 'dev' ? await dev(options) : await start(options);\n const stop = (): void => {\n void served.close().finally(() => process.exit(0));\n };\n process.on('SIGINT', stop);\n process.on('SIGTERM', stop);\n // stays up until it is told to stop\n return new Promise<number>(() => undefined);\n }\n if (command === 'check') return check(options);\n if (command === 'migrate') {\n await migrate({ ...options, dryRun: args.includes('--check') });\n return 0;\n }\n if (command === 'build') {\n return (await build(options)).ok ? 0 : 1;\n }\n if (command === 'export') return (await exportSite(options)).written ? 0 : 1;\n console.log(USAGE);\n return command === undefined || command === 'help' || command === '--help' ? 0 : 1;\n};\n\nmain().then(\n // An app's own handles (a database, a timer) must not keep a finished command\n // open: a command that is done says so and leaves.\n (code) => process.exit(code),\n (error: unknown) => {\n console.error(error instanceof Error ? error.message : error);\n process.exit(1);\n },\n);\n"]}
package/dist/index.d.cts CHANGED
@@ -24,6 +24,9 @@ type NiscMossProject = Common & {
24
24
  }>;
25
25
  dev?: {
26
26
  signIn?: (server: MossServer, who: string) => string | null | Promise<string | null>;
27
+ signInFromNetwork?: boolean;
28
+ watch?: RegExp;
29
+ owned?: RegExp;
27
30
  };
28
31
  };
29
32
  type NiscShellProject = Common & {
package/dist/index.d.ts CHANGED
@@ -24,6 +24,9 @@ type NiscMossProject = Common & {
24
24
  }>;
25
25
  dev?: {
26
26
  signIn?: (server: MossServer, who: string) => string | null | Promise<string | null>;
27
+ signInFromNetwork?: boolean;
28
+ watch?: RegExp;
29
+ owned?: RegExp;
27
30
  };
28
31
  };
29
32
  type NiscShellProject = Common & {
@@ -0,0 +1,3 @@
1
+ export { configFileOf, isProject, isShellProject, loadProject } from './chunk-I2SDNSH5.js';
2
+ //# sourceMappingURL=project-CH37UEL7.js.map
3
+ //# sourceMappingURL=project-CH37UEL7.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"project-UVB6UCJU.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"project-CH37UEL7.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@niscorp/cli",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "nisc — the command for a nisc application: dev, build, export, start. One config file says how the app boots and how its pages are drawn; the command does the rest.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -39,8 +39,8 @@
39
39
  "node": ">=22.12"
40
40
  },
41
41
  "peerDependencies": {
42
- "@niscorp/moss": "^0.4.0",
43
- "@niscorp/nova": "^0.3.0"
42
+ "@niscorp/nova": "^0.3.0",
43
+ "@niscorp/moss": "^0.5.0"
44
44
  },
45
45
  "peerDependenciesMeta": {
46
46
  "@niscorp/moss": {
@@ -58,8 +58,8 @@
58
58
  "tsup": "^8.5.1",
59
59
  "typescript": "^6.0.2",
60
60
  "vitest": "^4.1.2",
61
- "@niscorp/nova": "^0.3.0",
62
- "@niscorp/moss": "^0.4.0"
61
+ "@niscorp/moss": "^0.5.0",
62
+ "@niscorp/nova": "^0.3.0"
63
63
  },
64
64
  "scripts": {
65
65
  "build": "tsup",
@@ -1,3 +0,0 @@
1
- export { configFileOf, isProject, isShellProject, loadProject } from './chunk-6BXG4AD5.js';
2
- //# sourceMappingURL=project-UVB6UCJU.js.map
3
- //# sourceMappingURL=project-UVB6UCJU.js.map