@bangerpage/cli 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/NOTICE +16 -0
- package/README.md +17 -2
- package/dist/args.d.ts +8 -0
- package/dist/bin.js +943 -0
- package/dist/bin.js.map +7 -0
- package/dist/browser.d.ts +14 -0
- package/dist/capture.d.ts +49 -0
- package/dist/commands/check.d.ts +9 -0
- package/dist/commands/export.d.ts +1 -0
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/preview.d.ts +1 -0
- package/dist/commands/skill.d.ts +11 -0
- package/dist/commands/snap.d.ts +1 -0
- package/dist/commands/theme.d.ts +1 -0
- package/dist/core-package.d.ts +9 -0
- package/dist/errors.d.ts +11 -0
- package/dist/export/pdf.d.ts +19 -0
- package/dist/html-transform.d.ts +41 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +383 -0
- package/dist/index.js.map +7 -0
- package/dist/server.d.ts +13 -0
- package/dist/skill/SKILL.md +55 -0
- package/dist/skill/meta.json +4 -0
- package/dist/skill/reference/components.md +380 -0
- package/dist/skill/reference/patterns.md +377 -0
- package/dist/skill/reference/themes.md +263 -0
- package/dist/skill/templates/starter.html +20 -0
- package/dist/update-check.d.ts +17 -0
- package/package.json +58 -3
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/bin.ts", "../src/browser.ts", "../src/args.ts", "../src/errors.ts", "../src/capture.ts", "../src/core-package.ts", "../src/html-transform.ts", "../src/server.ts", "../src/commands/check.ts", "../src/export/pdf.ts", "../src/commands/export.ts", "../src/commands/init.ts", "../src/commands/preview.ts", "../src/commands/skill.ts", "../src/commands/snap.ts", "../src/commands/theme.ts", "../src/update-check.ts"],
|
|
4
|
+
"sourcesContent": ["import { readFileSync, realpathSync } from \"node:fs\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { BrowserNotFoundError, installHint } from \"./browser.js\";\nimport { runCheck } from \"./commands/check.js\";\nimport { runExport } from \"./commands/export.js\";\nimport { runInit } from \"./commands/init.js\";\nimport { runPreview } from \"./commands/preview.js\";\nimport { runSkill } from \"./commands/skill.js\";\nimport { runSnap } from \"./commands/snap.js\";\nimport { runTheme } from \"./commands/theme.js\";\nimport { CliError } from \"./errors.js\";\nimport { checkForUpdate } from \"./update-check.js\";\n\nexport const USAGE = `usage: banger <command> [options]\n\ncommands:\n init [dir] [--force] start a deck: write index.html from the starter\n preview [file] [--port N] preview with live reload\n snap [file] [--stop N] [--step M|last] [--steps last|all] [--out path] [--out-dir dir] [--scale 1|2]\n render states as 1920x1080 PNGs\n check [file] [--json] render every stop and list the problems the runtime finds;\n exits 1 when there is any\n export [file] --pdf [--out path] [--steps last|all]\n write a PDF, one page per stop\n theme init [file] [--from <preset>] [--force]\n write a theme.json from a bundled preset\n theme apply <theme.json> <deck.html>\n embed the theme in a deck, idempotently\n skill install [--project | --dir <path>] [--force]\n copy the agent skill to ~/.claude/skills/banger\n (--project: ./.claude/skills/banger)\n\n [file] defaults to index.html in the working directory.\n\n In a terminal, banger checks npm for a newer release once a day and prints a notice.\n Set BANGER_NO_UPDATE_CHECK=1 to turn it off; it is also off when CI is set.\n\noptions:\n --help show this help\n --version show the version\n`;\n\nconst COMMANDS = new Set([\"init\", \"preview\", \"snap\", \"check\", \"export\", \"theme\", \"skill\"]);\n\nfunction version(): string {\n const manifest = fileURLToPath(new URL(\"../package.json\", import.meta.url));\n return JSON.parse(readFileSync(manifest, \"utf8\")).version as string;\n}\n\nasync function dispatch(argv: string[]): Promise<number> {\n const [command, ...rest] = argv;\n if (command === undefined) throw new CliError(2, `missing command\\n${USAGE}`);\n if (command === \"--help\" || command === \"-h\" || command === \"help\") {\n process.stdout.write(USAGE);\n return 0;\n }\n if (command === \"--version\" || command === \"-v\") {\n process.stdout.write(`${version()}\\n`);\n return 0;\n }\n if (COMMANDS.has(command)) void checkForUpdate({ current: version() });\n switch (command) {\n case \"init\":\n return runInit(rest);\n case \"preview\":\n return runPreview(rest);\n case \"snap\":\n return runSnap(rest);\n case \"check\":\n return runCheck(rest);\n case \"export\":\n return runExport(rest);\n case \"theme\":\n return runTheme(rest);\n case \"skill\":\n return runSkill(rest);\n default:\n throw new CliError(2, `unknown command: ${command}\\n${USAGE}`);\n }\n}\n\nexport async function main(argv: string[]): Promise<number> {\n try {\n return await dispatch(argv);\n } catch (error) {\n if (error instanceof BrowserNotFoundError) {\n process.stderr.write(`banger: ${error.message}; ${installHint()}\\n`);\n return 2;\n }\n if (error instanceof CliError) {\n process.stderr.write(`banger: ${error.message}\\n`);\n return error.exitCode;\n }\n process.stderr.write(`${error instanceof Error ? (error.stack ?? error.message) : String(error)}\\n`);\n return 1;\n }\n}\n\nconst entry = process.argv[1];\nif (entry && import.meta.url === pathToFileURL(realpathSync(entry)).href) {\n process.exitCode = await main(process.argv.slice(2));\n}\n", "import { createRequire } from \"node:module\";\nimport { chromium, type Browser } from \"playwright-core\";\n\nexport class BrowserNotFoundError extends Error {\n constructor() {\n super(\"no browser found (tried Google Chrome and the bundled Chromium)\");\n this.name = \"BrowserNotFoundError\";\n }\n}\n\nexport interface BrowserLaunchers {\n chrome: () => Promise<Browser>;\n chromium: () => Promise<Browser>;\n}\n\nexport function installHint(): string {\n const { version } = createRequire(import.meta.url)(\"playwright-core/package.json\") as { version: string };\n return `install a browser with: npx playwright-core@${version} install chromium`;\n}\n\n/** Tries Google Chrome first, then Chromium; throws `BrowserNotFoundError` when neither starts. */\nexport async function launchBrowser(opts: { headless?: boolean; launchers?: BrowserLaunchers } = {}): Promise<Browser> {\n const headless = opts.headless ?? true;\n const launchers: BrowserLaunchers = opts.launchers ?? {\n chrome: () => chromium.launch({ channel: \"chrome\", headless }),\n chromium: () => chromium.launch({ headless }),\n };\n for (const launch of [launchers.chrome, launchers.chromium]) {\n try {\n return await launch();\n } catch {\n // fall through to the next launcher\n }\n }\n throw new BrowserNotFoundError();\n}\n", "import { parseArgs, type ParseArgsConfig } from \"node:util\";\nimport { CliError } from \"./errors.js\";\n\n/** `util.parseArgs` in strict mode; its errors are usage errors (exit code 2). */\nexport function parseArgsStrict<const T extends NonNullable<ParseArgsConfig[\"options\"]>>(argv: string[], options: T) {\n try {\n return parseArgs({ args: argv, options, allowPositionals: true, strict: true });\n } catch (error) {\n throw new CliError(2, (error as Error).message);\n }\n}\n\n/** The deck file from the positionals; with none, `index.html` in the working directory. */\nexport function deckFile(positionals: string[], usage: string): string {\n if (positionals.length > 1) throw new CliError(2, usage);\n return positionals[0] ?? \"index.html\";\n}\n", "import { existsSync, readFileSync, statSync } from \"node:fs\";\n\n/**\n * Failure of a CLI operation.\n * `exitCode` 1 is a problem with the deck's content (failed components, unembeddable assets);\n * 2 is a problem with usage or the environment (bad option, missing file, no browser, port in use).\n */\nexport class CliError extends Error {\n constructor(\n readonly exitCode: 1 | 2,\n message: string,\n ) {\n super(message);\n this.name = \"CliError\";\n }\n}\n\n/** Reads a deck file as UTF-8; a missing file is `CliError(2)`. */\nexport function readInput(file: string): string {\n if (!existsSync(file) || !statSync(file).isFile()) throw new CliError(2, `file not found: ${file}`);\n return readFileSync(file, \"utf8\");\n}\n", "import { readdir, rm } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport type { Page } from \"playwright-core\";\nimport { BrowserNotFoundError, installHint, launchBrowser, type BrowserLaunchers } from \"./browser.js\";\nimport { CORE_PACKAGE, coreVersion, type ReadyReport, type StopInfo } from \"./core-package.js\";\nimport { CliError, readInput } from \"./errors.js\";\nimport { runtimeVersionWarning } from \"./html-transform.js\";\nimport { startServer } from \"./server.js\";\n\n/** Which states of each stop to capture: `\"last\"` is the fully revealed state only, `\"all\"` every step. */\nexport type StepSelection = \"last\" | \"all\";\n\nexport interface StopRef {\n stop: number;\n step: number;\n}\n\nexport interface CaptureSession {\n page: Page;\n path: StopInfo[];\n title: string;\n /** Moves to `ref` and waits until everything in that state has rendered. Call sequentially. */\n goto(ref: StopRef): Promise<ReadyReport>;\n}\n\nexport interface CaptureOptions {\n scale?: 1 | 2;\n launchers?: BrowserLaunchers;\n runtimeVersionCheck?: boolean;\n runtimeTimeoutMs?: number;\n onWarning?: (message: string) => void;\n}\n\nexport const RUNTIME_LOAD_TIMEOUT_MS = 15000;\nexport const STOP_FILE_PATTERN = /^stop-\\d{3}-step-\\d{3}\\.png$/;\n\nconst pad = (n: number) => String(n).padStart(3, \"0\");\n\nexport function stopFileName(stop: number, step: number): string {\n return `stop-${pad(stop)}-step-${pad(step)}.png`;\n}\n\nexport function expandStates(\n path: ReadonlyArray<{ steps: number }>,\n sel: StepSelection,\n only?: StopRef,\n): StopRef[] {\n if (only) return [only];\n return path.flatMap((stop, index) =>\n sel === \"last\"\n ? [{ stop: index, step: stop.steps }]\n : Array.from({ length: stop.steps + 1 }, (_, step) => ({ stop: index, step })),\n );\n}\n\n/** Deletes only `stop-NNN-step-MMM.png` files directly in `dir`; returns the deleted names. */\nexport async function clearStopFiles(dir: string): Promise<string[]> {\n let entries;\n try {\n entries = await readdir(dir, { withFileTypes: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return [];\n throw error;\n }\n const removed: string[] = [];\n for (const entry of entries) {\n if (entry.isFile() && STOP_FILE_PATTERN.test(entry.name)) {\n await rm(join(dir, entry.name));\n removed.push(entry.name);\n }\n }\n return removed;\n}\n\nexport const defaultOnWarning = (message: string) => {\n process.stderr.write(`warning: ${message}\\n`);\n};\n\n/** Screenshots the current state (call `session.goto` first). The 1920x1080 stage is the whole page, so the clip is the full viewport by default. */\nexport async function captureState(\n session: CaptureSession,\n ref: StopRef,\n clip = { x: 0, y: 0, width: 1920, height: 1080 },\n): Promise<Buffer> {\n return session.page.screenshot({ type: \"png\", clip });\n}\n\n/**\n * Opens the deck in export mode and runs `fn` against it. Server, browser and page are always closed.\n * Warnings (runtime version mismatch, font fallbacks) go through `onWarning`, once per distinct message.\n */\nexport async function withCapture<T>(\n file: string,\n opts: CaptureOptions,\n fn: (session: CaptureSession) => Promise<T>,\n): Promise<T> {\n const seen = new Set<string>();\n const sink = opts.onWarning ?? defaultOnWarning;\n const warn = (message: string) => {\n if (seen.has(message)) return;\n seen.add(message);\n sink(message);\n };\n\n const html = readInput(file);\n if (opts.runtimeVersionCheck !== false) {\n const versionWarning = runtimeVersionWarning(html, CORE_PACKAGE, coreVersion());\n if (versionWarning) warn(versionWarning.message);\n }\n\n const server = await startServer({ file, watch: false, port: 0 });\n try {\n const browser = await launchBrowser({ launchers: opts.launchers }).catch((error) => {\n if (error instanceof BrowserNotFoundError) throw new CliError(2, `${error.message}; ${installHint()}`);\n throw error;\n });\n try {\n const scale = opts.scale ?? 1;\n const context = await browser.newContext({ viewport: { width: 1920, height: 1080 }, deviceScaleFactor: scale });\n const page = await context.newPage();\n const failedRequests: string[] = [];\n page.on(\"requestfailed\", (request) => failedRequests.push(request.url()));\n page.on(\"response\", (response) => {\n if (response.status() >= 400) failedRequests.push(`${response.url()} (${response.status()})`);\n });\n\n await page.goto(server.urlFor(\"mode=export#stop=0&step=last\"), { waitUntil: \"commit\" });\n const timeoutMs = opts.runtimeTimeoutMs ?? RUNTIME_LOAD_TIMEOUT_MS;\n const loaded = await page.evaluate(\n (ms) =>\n Promise.race([\n customElements.whenDefined(\"bang-root\").then(() => true),\n new Promise<boolean>((resolveTimeout) => setTimeout(() => resolveTimeout(false), ms)),\n ]),\n timeoutMs,\n );\n if (!loaded) {\n const detail = failedRequests.length > 0 ? ` Failed requests: ${failedRequests.join(\", \")}.` : \"\";\n throw new CliError(\n 1,\n `the runtime script did not load (bang-root was not defined within ${timeoutMs}ms).${detail} Check the <script type=\"module\" src> URL of the runtime.`,\n );\n }\n await page\n .waitForFunction(\n () => typeof (document.querySelector(\"bang-root\") as { getPath?: unknown } | null)?.getPath === \"function\",\n undefined,\n { timeout: timeoutMs },\n )\n .catch(() => {\n throw new CliError(1, \"the deck has no <bang-root> element; wrap the slides in <bang-root>.\");\n });\n\n const path = await page.evaluate(\n () => (document.querySelector(\"bang-root\") as unknown as { getPath(): StopInfo[] }).getPath(),\n );\n const session: CaptureSession = {\n page,\n path,\n title: await page.title(),\n async goto(ref) {\n const report = await page.evaluate(async ({ stop, step }) => {\n const root = document.querySelector(\"bang-root\") as unknown as {\n goto(stop: number, step: number): Promise<void>;\n ready(): Promise<ReadyReport>;\n };\n await root.goto(stop, step);\n return root.ready();\n }, ref);\n for (const message of report.warnings) warn(message);\n return report;\n },\n };\n return await fn(session);\n } finally {\n await browser.close();\n }\n } finally {\n await server.close();\n }\n}\n\nexport function formatReadyFailure(failure: { tag: string; selector: string; reason: string }): string {\n return `ready failed: ${failure.tag} ${failure.selector}: ${failure.reason}`;\n}\n", "import { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nexport const CORE_PACKAGE = \"@bangerpage/core\";\nexport const CDN_HOSTS = [\"cdn.jsdelivr.net/npm\", \"unpkg.com\"];\n\nexport type { ReadyFailure, ReadyReport, StopInfo } from \"@bangerpage/core\";\nexport { PRESET_NAMES, isPresetName, parseThemeJson, presetTheme, resolveTheme, serializeTheme } from \"@bangerpage/core/theme\";\nexport type { PresetName } from \"@bangerpage/core/theme\";\nexport type { ThemeDefinition } from \"@bangerpage/core\";\n\nfunction corePackageDir(): string {\n return dirname(fileURLToPath(import.meta.resolve(`${CORE_PACKAGE}/package.json`)));\n}\n\nexport function coreDistDir(): string {\n return join(corePackageDir(), \"dist\");\n}\n\nexport function coreManifestPath(): string {\n return join(corePackageDir(), \"custom-elements.json\");\n}\n\nexport function coreVersion(): string {\n return JSON.parse(readFileSync(join(corePackageDir(), \"package.json\"), \"utf8\")).version as string;\n}\n", "import { parse, type DefaultTreeAdapterMap } from \"parse5\";\nimport { CDN_HOSTS } from \"./core-package.js\";\n\ntype Element = DefaultTreeAdapterMap[\"element\"];\ntype ParentNode = DefaultTreeAdapterMap[\"parentNode\"];\n\nexport interface RuntimeScriptRef {\n src: string;\n version: string | null;\n line: number;\n element: { start: number; end: number };\n srcAttr: { start: number; end: number };\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nexport function runtimeUrlPattern(corePackage: string): RegExp {\n const hosts = CDN_HOSTS.map(escapeRegExp).join(\"|\");\n return new RegExp(`^https?://(${hosts})/${escapeRegExp(corePackage)}(@[^/]+)?/dist/index\\\\.js$`);\n}\n\ninterface ModuleScript {\n src: string;\n line: number;\n element: { start: number; end: number };\n srcAttr: { start: number; end: number };\n}\n\nfunction moduleScripts(html: string): ModuleScript[] {\n const found: ModuleScript[] = [];\n const visit = (node: ParentNode) => {\n for (const child of node.childNodes) {\n if (!(\"tagName\" in child)) continue;\n const element = child as Element;\n const loc = element.sourceCodeLocation;\n if (element.tagName === \"script\" && loc) {\n const attr = (name: string) => element.attrs.find((a) => a.name === name)?.value;\n const src = attr(\"src\");\n const srcLoc = loc.attrs?.src;\n if (attr(\"type\") === \"module\" && src !== undefined && srcLoc) {\n found.push({\n src,\n line: loc.startLine,\n element: { start: loc.startOffset, end: loc.endOffset },\n srcAttr: { start: srcLoc.startOffset, end: srcLoc.endOffset },\n });\n }\n }\n visit(element);\n if (element.tagName === \"template\") visit((element as unknown as { content: ParentNode }).content);\n }\n };\n visit(parse(html, { sourceCodeLocationInfo: true }));\n return found;\n}\n\n/** The first `<script type=\"module\" src>` that points at the core runtime on a known CDN. */\nexport function findRuntimeScript(html: string, corePackage: string): RuntimeScriptRef | null {\n const pattern = runtimeUrlPattern(corePackage);\n for (const script of moduleScripts(html)) {\n const match = pattern.exec(script.src);\n if (match) return { ...script, version: match[2] ? match[2].slice(1) : null };\n }\n return null;\n}\n\n/**\n * Describes how the deck's runtime script differs from the local core the CLI renders with.\n * Returns null when they agree or the deck does not load the runtime.\n */\nexport function runtimeVersionWarning(\n html: string,\n corePackage: string,\n localVersion: string,\n): { message: string; line: number } | null {\n const ref = findRuntimeScript(html, corePackage);\n if (ref) {\n if (ref.version === null) {\n return { message: `the runtime URL has no version; pin it to ${corePackage}@${localVersion}`, line: ref.line };\n }\n if (ref.version !== localVersion) {\n return {\n message: `the deck loads ${corePackage}@${ref.version} but this CLI uses ${corePackage}@${localVersion}; the published deck will run ${ref.version}`,\n line: ref.line,\n };\n }\n return null;\n }\n const other = moduleScripts(html).find((script) => script.src.includes(corePackage));\n if (other) {\n return {\n message: `runtime script ${other.src} is not a recognized CDN URL and is not replaced with the local core`,\n line: other.line,\n };\n }\n return null;\n}\n\n/** Replaces only the `src` value of the runtime script; other bytes stay untouched. */\nexport function rewriteRuntimeScript(html: string, corePackage: string, newSrc: string): string {\n const ref = findRuntimeScript(html, corePackage);\n if (!ref) return html;\n const attrText = html.slice(ref.srcAttr.start, ref.srcAttr.end);\n const valueStart = attrText.indexOf(ref.src);\n if (valueStart < 0) return html;\n const start = ref.srcAttr.start + valueStart;\n return html.slice(0, start) + newSrc + html.slice(start + ref.src.length);\n}\n\n/** Inserts `snippet` just before `</body>`, or at the end when there is none. */\nexport function injectBeforeBodyEnd(html: string, snippet: string): string {\n const index = html.toLowerCase().lastIndexOf(\"</body>\");\n if (index < 0) return html + snippet;\n return html.slice(0, index) + snippet + html.slice(index);\n}\n\nexport interface ThemeApplyResult {\n html: string;\n extraBlocks: number;\n}\n\nexport interface ThemeApplyError {\n error: \"unclosed-theme\" | \"foreign-children\";\n}\n\nfunction findFirstElement(node: ParentNode, tagName: string): Element | null {\n for (const child of node.childNodes) {\n if (!(\"tagName\" in child)) continue;\n const element = child as Element;\n if (element.tagName === tagName) return element;\n const inner = findFirstElement(element, tagName);\n if (inner) return inner;\n }\n return null;\n}\n\nfunction lineIndent(html: string, offset: number): string {\n let start = offset;\n while (start > 0 && (html[start - 1] === \" \" || html[start - 1] === \"\\t\")) start--;\n if (start === 0 || html[start - 1] === \"\\n\" || html[start - 1] === \"\\r\") return html.slice(start, offset);\n return \"\";\n}\n\nfunction hasOnlyJsonScript(block: Element): boolean {\n let scripts = 0;\n for (const child of block.childNodes) {\n if (child.nodeName === \"#text\") {\n if ((child as { value: string }).value.trim() !== \"\") return false;\n } else if (!(\"tagName\" in child)) {\n return false;\n } else if (\n ++scripts > 1 ||\n child.tagName !== \"script\" ||\n !child.attrs.some((a) => a.name === \"type\" && a.value === \"application/json\")\n ) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Embeds `json` as the first `<bang-theme>` block directly inside the first `<bang-root>` and sets\n * `theme=\"custom\"`. Only the block and the `theme` attribute are rewritten; other bytes stay untouched.\n * Returns null when the deck has no `<bang-root>`.\n */\nexport function applyThemeBlock(html: string, json: string): ThemeApplyResult | ThemeApplyError | null {\n const root = findFirstElement(parse(html, { sourceCodeLocationInfo: true }), \"bang-root\");\n const rootLoc = root?.sourceCodeLocation;\n if (!root || !rootLoc?.startTag) return null;\n const blocks = root.childNodes.filter((child): child is Element => \"tagName\" in child && child.tagName === \"bang-theme\");\n const eol = html.includes(\"\\r\\n\") ? \"\\r\\n\" : \"\\n\";\n const makeBlock = (indent: string) =>\n [\n \"<bang-theme>\",\n `${indent} <script type=\"application/json\">`,\n ...json.split(\"\\n\").map((line) => `${indent} ${line}`),\n `${indent} </script>`,\n `${indent}</bang-theme>`,\n ].join(eol);\n\n const edits: { start: number; end: number; text: string }[] = [];\n const first = blocks[0];\n if (first) {\n const loc = first.sourceCodeLocation;\n if (!loc?.endTag) return { error: \"unclosed-theme\" };\n if (!hasOnlyJsonScript(first)) return { error: \"foreign-children\" };\n edits.push({ start: loc.startOffset, end: loc.endOffset, text: makeBlock(lineIndent(html, loc.startOffset)) });\n } else {\n const at = rootLoc.startTag.endOffset;\n const indent = `${lineIndent(html, rootLoc.startOffset)} `;\n edits.push({ start: at, end: at, text: `${eol}${indent}${makeBlock(indent)}` });\n }\n const attr = root.attrs.find((a) => a.name === \"theme\");\n if (!attr) {\n const at = rootLoc.startOffset + 1 + \"bang-root\".length;\n edits.push({ start: at, end: at, text: ' theme=\"custom\"' });\n } else if (attr.value !== \"custom\") {\n const attrLoc = rootLoc.attrs?.theme;\n if (attrLoc) edits.push({ start: attrLoc.startOffset, end: attrLoc.endOffset, text: 'theme=\"custom\"' });\n }\n let out = html;\n for (const edit of edits.sort((a, b) => b.start - a.start)) out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);\n return { html: out, extraBlocks: Math.max(0, blocks.length - 1) };\n}\n", "import { createReadStream, existsSync, readFileSync, statSync, watch, type FSWatcher } from \"node:fs\";\nimport { createServer, type ServerResponse } from \"node:http\";\nimport type { AddressInfo } from \"node:net\";\nimport { basename, dirname, extname, join, normalize, resolve, sep } from \"node:path\";\nimport { CORE_PACKAGE, coreDistDir } from \"./core-package.js\";\nimport { CliError, readInput } from \"./errors.js\";\nimport { injectBeforeBodyEnd, rewriteRuntimeScript } from \"./html-transform.js\";\n\nexport interface DeckServer {\n url: string;\n urlFor(query?: string): string;\n close(): Promise<void>;\n}\n\nconst CONTENT_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 \".map\": \"application/json; charset=utf-8\",\n \".svg\": \"image/svg+xml\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".gif\": \"image/gif\",\n \".webp\": \"image/webp\",\n \".avif\": \"image/avif\",\n \".woff2\": \"font/woff2\",\n \".txt\": \"text/plain; charset=utf-8\",\n};\n\nexport function contentType(file: string): string {\n return CONTENT_TYPES[extname(file).toLowerCase()] ?? \"application/octet-stream\";\n}\n\n/** Resolves a URL path under `root`; null when it escapes `root` or contains a NUL. */\nexport function resolveWithin(root: string, urlPath: string): string | null {\n let decoded: string;\n try {\n decoded = decodeURIComponent(urlPath);\n } catch {\n return null;\n }\n if (decoded.includes(\"\\0\")) return null;\n const base = resolve(root);\n const full = normalize(join(base, decoded));\n return full === base || full.startsWith(base + sep) ? full : null;\n}\n\nconst RELOAD_SNIPPET = `<script>new EventSource(\"/__banger/events\").addEventListener(\"reload\",()=>location.reload())</script>`;\nconst EVENTS_PATH = \"/__banger/events\";\nconst CORE_PREFIX = \"/__banger/core/\";\n\nexport async function startServer(opts: { file: string; watch: boolean; port?: number }): Promise<DeckServer> {\n readInput(opts.file);\n const file = resolve(opts.file);\n const root = dirname(file);\n const served = new Set<string>();\n const clients = new Set<ServerResponse>();\n\n const send = (res: ServerResponse, status: number, body: string, type = \"text/plain; charset=utf-8\") => {\n res.writeHead(status, { \"content-type\": type, \"cache-control\": \"no-store\" });\n res.end(body);\n };\n\n const server = createServer((req, res) => {\n if (req.method !== \"GET\" && req.method !== \"HEAD\") return send(res, 405, \"method not allowed\");\n const urlPath = (req.url ?? \"/\").split(\"?\")[0] ?? \"/\";\n\n if (urlPath === EVENTS_PATH && opts.watch) {\n res.writeHead(200, { \"content-type\": \"text/event-stream\", \"cache-control\": \"no-store\", connection: \"keep-alive\" });\n res.write(\": connected\\n\\n\");\n clients.add(res);\n req.on(\"close\", () => clients.delete(res));\n return;\n }\n\n const isCore = urlPath.startsWith(CORE_PREFIX);\n const target = isCore\n ? resolveWithin(coreDistDir(), urlPath.slice(CORE_PREFIX.length))\n : resolveWithin(root, urlPath === \"/\" ? basename(file) : urlPath);\n if (!target || !existsSync(target) || !statSync(target).isFile()) return send(res, 404, \"not found\");\n\n if (!isCore) served.add(target);\n const type = contentType(target);\n if (!isCore && extname(target).toLowerCase() === \".html\") {\n let html = rewriteRuntimeScript(readFileSync(target, \"utf8\"), CORE_PACKAGE, `${CORE_PREFIX}index.js`);\n if (opts.watch) html = injectBeforeBodyEnd(html, RELOAD_SNIPPET);\n return send(res, 200, req.method === \"HEAD\" ? \"\" : html, type);\n }\n res.writeHead(200, { \"content-type\": type, \"cache-control\": \"no-store\" });\n if (req.method === \"HEAD\") return res.end();\n createReadStream(target).pipe(res);\n });\n\n await new Promise<void>((resolveListen, rejectListen) => {\n server.once(\"error\", (error: NodeJS.ErrnoException) => {\n rejectListen(\n error.code === \"EADDRINUSE\"\n ? new CliError(2, `port ${opts.port} is already in use`)\n : new CliError(2, `cannot start the server: ${error.message}`),\n );\n });\n server.listen(opts.port ?? 0, \"127.0.0.1\", resolveListen);\n });\n\n let watcher: FSWatcher | undefined;\n let timer: ReturnType<typeof setTimeout> | undefined;\n if (opts.watch) {\n watcher = watch(root, { recursive: true }, (_event, name) => {\n if (!name || !served.has(join(root, name.toString()))) return;\n clearTimeout(timer);\n timer = setTimeout(() => {\n for (const client of clients) client.write(\"event: reload\\ndata: {}\\n\\n\");\n }, 100);\n });\n }\n\n const origin = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;\n const entry = `${origin}/${encodeURIComponent(basename(file))}`;\n return {\n url: entry,\n urlFor: (query) => (query ? `${entry}?${query}` : entry),\n close: async () => {\n clearTimeout(timer);\n watcher?.close();\n for (const client of clients) client.end();\n server.closeAllConnections();\n await new Promise<void>((resolveClose) => server.close(() => resolveClose()));\n },\n };\n}\n", "import { deckFile, parseArgsStrict } from \"../args.js\";\nimport { expandStates, formatReadyFailure, withCapture } from \"../capture.js\";\n\nconst USAGE = \"usage: banger check [file] [--json]\";\n\nexport interface CheckResult {\n ok: boolean;\n stops: number;\n warnings: string[];\n failed: string[];\n}\n\n/** Renders every stop at its last step without taking pictures and collects what the runtime reports. */\nexport async function checkDeck(file: string): Promise<CheckResult> {\n const warnings: string[] = [];\n const failed = new Set<string>();\n const stops = await withCapture(file, { onWarning: (message) => warnings.push(message) }, async (session) => {\n for (const ref of expandStates(session.path, \"last\")) {\n const report = await session.goto(ref);\n for (const failure of report.failed) failed.add(formatReadyFailure(failure));\n }\n return session.path.length;\n });\n return { ok: warnings.length === 0 && failed.size === 0, stops, warnings, failed: [...failed] };\n}\n\nexport async function runCheck(argv: string[]): Promise<number> {\n if (argv.includes(\"--help\")) {\n process.stdout.write(`${USAGE}\\n`);\n return 0;\n }\n const { values, positionals } = parseArgsStrict(argv, { json: { type: \"boolean\" } });\n const result = await checkDeck(deckFile(positionals, USAGE));\n if (values.json) {\n process.stdout.write(`${JSON.stringify(result, null, 2)}\\n`);\n } else {\n for (const line of result.failed) process.stdout.write(`${line}\\n`);\n for (const line of result.warnings) process.stdout.write(`warning: ${line}\\n`);\n const problems = result.failed.length + result.warnings.length;\n process.stdout.write(\n problems === 0 ? `ok: ${result.stops} stops, no problems\\n` : `${problems} problem${problems === 1 ? \"\" : \"s\"} in ${result.stops} stops\\n`,\n );\n }\n return result.ok ? 0 : 1;\n}\n", "import { mkdir, writeFile } from \"node:fs/promises\";\nimport { basename, dirname, extname, resolve } from \"node:path\";\nimport { PDFDocument } from \"@cantoo/pdf-lib\";\nimport type { BrowserLaunchers } from \"../browser.js\";\nimport { expandStates, formatReadyFailure, withCapture, type StepSelection } from \"../capture.js\";\nimport type { ReadyFailure } from \"../core-package.js\";\nimport { CliError } from \"../errors.js\";\n\n/**\n * Writes the deck as a PDF with one 1920x1080 CSS px page per state; text stays vector.\n *\n * @param file Path to the deck HTML.\n * @param opts.out Output path (default: next to the input, same name with `.pdf`).\n * @param opts.steps `\"last\"` (default) writes one page per stop; `\"all\"` one page per step.\n * @param opts.onWarning Receives warnings (font fallbacks, runtime version mismatch); defaults to stderr.\n * @returns The absolute path of the written PDF.\n * @throws CliError with `exitCode` 1 when a component fails to render (nothing is written),\n * the runtime script did not load, or the deck has no `<bang-root>`; 2 when the file is missing or no browser is available.\n */\nexport async function exportPdf(\n file: string,\n opts: { out?: string; steps?: StepSelection; launchers?: BrowserLaunchers; onWarning?: (message: string) => void } = {},\n): Promise<string> {\n const out = resolve(opts.out ?? resolve(dirname(file), `${basename(file, extname(file))}.pdf`));\n const failures = new Map<string, ReadyFailure>();\n const pages: Buffer[] = [];\n const title = await withCapture(\n file,\n { launchers: opts.launchers, onWarning: opts.onWarning },\n async (session) => {\n for (const ref of expandStates(session.path, opts.steps ?? \"last\")) {\n const report = await session.goto(ref);\n for (const failure of report.failed) failures.set(formatReadyFailure(failure), failure);\n pages.push(\n await session.page.pdf({ width: \"1920px\", height: \"1080px\", printBackground: true, pageRanges: \"1\" }),\n );\n }\n return session.title;\n },\n );\n if (failures.size > 0) {\n throw new CliError(1, `export failed; nothing was written\\n${[...failures.keys()].join(\"\\n\")}`);\n }\n const merged = await PDFDocument.create();\n for (const page of pages) {\n const doc = await PDFDocument.load(page);\n for (const copied of await merged.copyPages(doc, doc.getPageIndices())) merged.addPage(copied);\n }\n merged.setTitle(title);\n await mkdir(dirname(out), { recursive: true });\n await writeFile(out, await merged.save());\n return out;\n}\n", "import { deckFile, parseArgsStrict } from \"../args.js\";\nimport { CliError } from \"../errors.js\";\nimport { exportPdf } from \"../export/pdf.js\";\nimport type { StepSelection } from \"../capture.js\";\n\nconst USAGE = \"usage: banger export [file] --pdf [--out path] [--steps last|all]\";\n\nexport async function runExport(argv: string[]): Promise<number> {\n if (argv.includes(\"--help\")) {\n process.stdout.write(`${USAGE}\\n`);\n return 0;\n }\n const { values, positionals } = parseArgsStrict(argv, {\n pdf: { type: \"boolean\" },\n out: { type: \"string\" },\n steps: { type: \"string\" },\n });\n const file = deckFile(positionals, USAGE);\n if (!values.pdf) throw new CliError(2, `choose exactly one export format\\n${USAGE}`);\n if (values.steps !== undefined && values.steps !== \"last\" && values.steps !== \"all\") {\n throw new CliError(2, `invalid --steps: ${values.steps} (expected last or all)`);\n }\n const out = await exportPdf(file, { out: values.out, steps: values.steps as StepSelection | undefined });\n process.stdout.write(`${out}\\n`);\n return 0;\n}\n", "import { copyFileSync, existsSync, mkdirSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { parseArgsStrict } from \"../args.js\";\nimport { CliError } from \"../errors.js\";\n\nconst USAGE = \"usage: banger init [dir] [--force]\";\n\n/** Writes `<dir>/index.html` from `starter`. Returns the written path. */\nexport function initDeck(opts: { starter: string; dir: string; force?: boolean }): string {\n const target = join(opts.dir, \"index.html\");\n if (existsSync(target) && !opts.force) throw new CliError(2, `${target} already exists; pass --force to overwrite`);\n if (!existsSync(opts.starter)) throw new CliError(2, `the bundled starter is missing: ${opts.starter}`);\n mkdirSync(opts.dir, { recursive: true });\n copyFileSync(opts.starter, target);\n return target;\n}\n\nexport function runInit(argv: string[]): number {\n const { values, positionals } = parseArgsStrict(argv, { force: { type: \"boolean\" } });\n if (positionals.length > 1) throw new CliError(2, USAGE);\n // bin.js is bundled into dist/, and the build copies the skill (with its starter) to dist/skill.\n const starter = fileURLToPath(new URL(\"./skill/templates/starter.html\", import.meta.url));\n const target = initDeck({ starter, dir: resolve(positionals[0] ?? \".\"), force: values.force });\n process.stdout.write(`${target}\\n`);\n return 0;\n}\n", "import { deckFile, parseArgsStrict } from \"../args.js\";\nimport { CORE_PACKAGE, coreVersion } from \"../core-package.js\";\nimport { CliError, readInput } from \"../errors.js\";\nimport { runtimeVersionWarning } from \"../html-transform.js\";\nimport { startServer } from \"../server.js\";\n\nconst USAGE = \"usage: banger preview [file] [--port N]\";\n\nexport async function runPreview(argv: string[]): Promise<number> {\n if (argv.includes(\"--help\")) {\n process.stdout.write(`${USAGE}\\n`);\n return 0;\n }\n const { values, positionals } = parseArgsStrict(argv, { port: { type: \"string\" } });\n const file = deckFile(positionals, USAGE);\n const port = values.port === undefined ? 4321 : Number(values.port);\n if (!Number.isInteger(port) || port < 0 || port > 65535) throw new CliError(2, `invalid --port: ${values.port}`);\n\n const warning = runtimeVersionWarning(readInput(file), CORE_PACKAGE, coreVersion());\n if (warning) process.stderr.write(`warning: ${warning.message}\\n`);\n\n // Listen before printing the URL: a caller may send SIGINT as soon as it reads it.\n const stopped = new Promise<void>((resolveStop) => process.once(\"SIGINT\", resolveStop));\n const server = await startServer({ file, watch: true, port });\n process.stdout.write(`${server.url}\\n`);\n await stopped;\n await server.close();\n return 0;\n}\n", "import { cpSync, existsSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { parseArgsStrict } from \"../args.js\";\nimport { CliError } from \"../errors.js\";\n\nconst USAGE = \"usage: banger skill install [--project | --dir <path>] [--force]\";\n/** Marks a directory written by `banger skill install`, so a later install may replace it. Holds the CLI version. */\nexport const MARKER = \".banger-skill\";\n\nexport interface InstallSkillOptions {\n source: string;\n dest: string;\n version: string;\n force?: boolean;\n}\n\n/** Copies the bundled skill to `dest`. Returns whether an earlier install was replaced. */\nexport function installSkill(opts: InstallSkillOptions): \"installed\" | \"updated\" {\n if (!existsSync(join(opts.source, \"SKILL.md\"))) throw new CliError(2, `the bundled skill is missing: ${opts.source}`);\n let outcome: \"installed\" | \"updated\" = \"installed\";\n if (existsSync(opts.dest)) {\n if (!existsSync(join(opts.dest, MARKER)) && !opts.force) {\n throw new CliError(2, `${opts.dest} already exists and was not written by banger; pass --force to replace it`);\n }\n rmSync(opts.dest, { recursive: true, force: true });\n outcome = \"updated\";\n }\n cpSync(opts.source, opts.dest, { recursive: true });\n writeFileSync(join(opts.dest, MARKER), `${opts.version}\\n`);\n return outcome;\n}\n\nfunction bundledSkill(): string {\n // bin.js is bundled into dist/, and the build copies the skill to dist/skill.\n return fileURLToPath(new URL(\"./skill\", import.meta.url));\n}\n\nfunction cliVersion(): string {\n const manifest = fileURLToPath(new URL(\"../package.json\", import.meta.url));\n return (JSON.parse(readFileSync(manifest, \"utf8\")) as { version: string }).version;\n}\n\nexport function runSkill(argv: string[]): number {\n const [sub, ...rest] = argv;\n if (sub !== \"install\") throw new CliError(2, USAGE);\n const { values, positionals } = parseArgsStrict(rest, {\n project: { type: \"boolean\" },\n dir: { type: \"string\" },\n force: { type: \"boolean\" },\n });\n if (positionals.length > 0 || (values.project && values.dir !== undefined)) throw new CliError(2, USAGE);\n const dest = values.dir !== undefined\n ? resolve(values.dir)\n : values.project\n ? resolve(\".claude\", \"skills\", \"banger\")\n : join(homedir(), \".claude\", \"skills\", \"banger\");\n const outcome = installSkill({ source: bundledSkill(), dest, version: cliVersion(), force: values.force });\n process.stdout.write(`${outcome}: ${dest}\\n`);\n return 0;\n}\n", "import { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { deckFile, parseArgsStrict } from \"../args.js\";\nimport { captureState, clearStopFiles, expandStates, formatReadyFailure, stopFileName, withCapture } from \"../capture.js\";\nimport { CliError } from \"../errors.js\";\n\nconst USAGE = \"usage: banger snap [file] [--stop N] [--step M|last] [--steps last|all] [--out path] [--out-dir dir] [--scale 1|2]\";\n\nfunction parseCount(name: string, value: string): number {\n if (!/^\\d+$/.test(value)) throw new CliError(2, `invalid --${name}: ${value}`);\n return Number(value);\n}\n\nexport async function runSnap(argv: string[]): Promise<number> {\n if (argv.includes(\"--help\")) {\n process.stdout.write(`${USAGE}\\n`);\n return 0;\n }\n const { values, positionals } = parseArgsStrict(argv, {\n stop: { type: \"string\" },\n step: { type: \"string\" },\n steps: { type: \"string\" },\n out: { type: \"string\" },\n \"out-dir\": { type: \"string\" },\n scale: { type: \"string\" },\n });\n const file = deckFile(positionals, USAGE);\n if (values.scale !== undefined && values.scale !== \"1\" && values.scale !== \"2\") {\n throw new CliError(2, `invalid --scale: ${values.scale} (expected 1 or 2)`);\n }\n const scale = values.scale === \"2\" ? 2 : 1;\n if (values.stop === undefined && values.step !== undefined) throw new CliError(2, \"--step requires --stop\");\n if (values.steps !== undefined && values.steps !== \"last\" && values.steps !== \"all\") {\n throw new CliError(2, `invalid --steps: ${values.steps} (expected last or all)`);\n }\n if (values.steps !== undefined && values.stop !== undefined) throw new CliError(2, \"--steps cannot be used with --stop\");\n const selection = values.steps === \"all\" ? \"all\" : \"last\";\n if (values.stop === undefined && values.out !== undefined) throw new CliError(2, \"--out requires --stop; use --out-dir\");\n const stop = values.stop === undefined ? undefined : parseCount(\"stop\", values.stop);\n const stepArg = values.step === undefined || values.step === \"last\" ? \"last\" : parseCount(\"step\", values.step);\n const outDir = values[\"out-dir\"] ?? \"snap\";\n\n const failures = new Set<string>();\n await withCapture(file, { scale }, async (session) => {\n let only;\n if (stop !== undefined) {\n const info = session.path[stop];\n if (!info) throw new CliError(2, `--stop ${stop} is out of range (the deck has ${session.path.length} stops)`);\n const step = stepArg === \"last\" ? info.steps : stepArg;\n if (step > info.steps) throw new CliError(2, `--step ${step} is out of range (stop ${stop} has ${info.steps} steps)`);\n only = { stop, step };\n }\n const states = expandStates(session.path, selection, only);\n const single = only !== undefined;\n if (!single) await clearStopFiles(outDir);\n for (const ref of states) {\n const report = await session.goto(ref);\n for (const failure of report.failed) failures.add(formatReadyFailure(failure));\n const png = await captureState(session, ref);\n const target = (single && values.out) || join(outDir, stopFileName(ref.stop, ref.step));\n await mkdir(dirname(target), { recursive: true });\n await writeFile(target, png);\n }\n return undefined;\n });\n for (const line of failures) process.stderr.write(`${line}\\n`);\n return failures.size > 0 ? 1 : 0;\n}\n", "import { existsSync, writeFileSync } from \"node:fs\";\nimport { parseArgsStrict } from \"../args.js\";\nimport { PRESET_NAMES, isPresetName, parseThemeJson, presetTheme, resolveTheme, serializeTheme } from \"../core-package.js\";\nimport { CliError, readInput } from \"../errors.js\";\nimport { applyThemeBlock } from \"../html-transform.js\";\n\nconst USAGE = `usage: banger theme init [file] [--from <preset>] [--force]\n banger theme apply <theme.json> <deck.html>`;\n\nfunction runThemeInit(argv: string[]): number {\n const { values, positionals } = parseArgsStrict(argv, { from: { type: \"string\" }, force: { type: \"boolean\" } });\n if (positionals.length > 1) throw new CliError(2, USAGE);\n const file = positionals[0] ?? \"theme.json\";\n const name = values.from ?? \"signal\";\n if (!isPresetName(name)) throw new CliError(2, `unknown preset: ${name} (choose one of: ${PRESET_NAMES.join(\", \")})`);\n if (existsSync(file) && !values.force) throw new CliError(2, `${file} already exists; pass --force to overwrite`);\n try {\n writeFileSync(file, `${serializeTheme(presetTheme(name))}\\n`);\n } catch (error) {\n throw new CliError(2, `cannot write ${file}: ${(error as NodeJS.ErrnoException).code ?? \"error\"}`);\n }\n process.stdout.write(`${file}\\n`);\n return 0;\n}\n\nfunction runThemeApply(argv: string[]): number {\n const { positionals } = parseArgsStrict(argv, {});\n if (positionals.length !== 2) throw new CliError(2, USAGE);\n const [themeFile, deckFile] = positionals as [string, string];\n const parsed = parseThemeJson(readInput(themeFile));\n if (!parsed.definition) {\n throw new CliError(1, `${themeFile}: ${(parsed.warnings[0] ?? \"theme: invalid theme\").replace(/^theme: /, \"\")}`);\n }\n for (const message of [...parsed.warnings, ...resolveTheme(parsed.definition).warnings]) {\n process.stderr.write(`warning: ${message}\\n`);\n }\n const html = readInput(deckFile);\n const result = applyThemeBlock(html, serializeTheme(parsed.definition));\n if (result === null) throw new CliError(1, `${deckFile}: no <bang-root> element to apply the theme to`);\n if (\"error\" in result) {\n throw new CliError(\n 1,\n result.error === \"unclosed-theme\"\n ? `${deckFile}: <bang-theme> has no closing tag; fix it before applying`\n : `${deckFile}: <bang-theme> has children other than the JSON script; remove them before applying`,\n );\n }\n if (result.extraBlocks > 0) {\n process.stderr.write(\n `warning: ${deckFile} has ${result.extraBlocks} more <bang-theme> elements; the runtime uses only the first\\n`,\n );\n }\n if (result.html !== html) {\n writeFileSync(deckFile, result.html);\n process.stdout.write(`applied: ${deckFile}\\n`);\n } else {\n process.stdout.write(`unchanged: ${deckFile}\\n`);\n }\n return 0;\n}\n\nexport async function runTheme(argv: string[]): Promise<number> {\n const [sub, ...rest] = argv;\n if (sub === undefined) throw new CliError(2, USAGE);\n if (sub === \"--help\" || sub === \"-h\" || rest.includes(\"--help\")) {\n process.stdout.write(`${USAGE}\\n`);\n return 0;\n }\n if (sub === \"init\") return runThemeInit(rest);\n if (sub === \"apply\") return runThemeApply(rest);\n throw new CliError(2, `unknown theme subcommand: ${sub}\\n${USAGE}`);\n}\n", "import { mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\n\nconst PACKAGE = \"@bangerpage/cli\";\nconst LATEST_URL = \"https://registry.npmjs.org/@bangerpage%2fcli/latest\";\nconst INTERVAL_MS = 24 * 60 * 60 * 1000;\nconst TIMEOUT_MS = 2000;\n\ninterface Cache {\n checkedAt: number;\n latest: string;\n}\n\nexport interface UpdateCheckOptions {\n current: string;\n env?: NodeJS.ProcessEnv;\n isTTY?: boolean;\n now?: number;\n cacheFile?: string;\n fetchLatest?: () => Promise<string | undefined>;\n write?: (text: string) => void;\n}\n\nexport function updateCacheFile(env: NodeJS.ProcessEnv = process.env): string {\n return join(env.XDG_CACHE_HOME || join(homedir(), \".cache\"), \"banger\", \"update-check.json\");\n}\n\nfunction enabled(env: NodeJS.ProcessEnv, isTTY: boolean): boolean {\n return isTTY && !env.CI && !env.BANGER_NO_UPDATE_CHECK && !env.NO_UPDATE_NOTIFIER;\n}\n\nfunction parse(version: string): [number, number, number] | undefined {\n const match = /^(\\d+)\\.(\\d+)\\.(\\d+)$/.exec(version);\n return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : undefined;\n}\n\n/** True when `latest` is a release (no prerelease tag) newer than `current`. */\nexport function isNewer(latest: string, current: string): boolean {\n const a = parse(latest);\n const b = parse(current);\n if (!a || !b) return false;\n for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return a[i] > b[i];\n return false;\n}\n\nfunction readCache(file: string): Cache | undefined {\n try {\n const data = JSON.parse(readFileSync(file, \"utf8\")) as Partial<Cache>;\n return typeof data.checkedAt === \"number\" && typeof data.latest === \"string\"\n ? { checkedAt: data.checkedAt, latest: data.latest }\n : undefined;\n } catch {\n return undefined;\n }\n}\n\nasync function fetchFromRegistry(): Promise<string | undefined> {\n const response = await fetch(LATEST_URL, { signal: AbortSignal.timeout(TIMEOUT_MS) });\n if (!response.ok) return undefined;\n const body = (await response.json()) as { version?: unknown };\n return typeof body.version === \"string\" ? body.version : undefined;\n}\n\n/**\n * Prints a notice when the last check found a newer release, and refreshes the check at most once a day.\n * The notice uses the cached result so a command never waits on the network; failures are ignored.\n */\nexport function checkForUpdate(opts: UpdateCheckOptions): Promise<void> {\n const env = opts.env ?? process.env;\n if (!enabled(env, opts.isTTY ?? process.stderr.isTTY === true)) return Promise.resolve();\n const file = opts.cacheFile ?? updateCacheFile(env);\n const now = opts.now ?? Date.now();\n const write = opts.write ?? ((text: string) => process.stderr.write(text));\n const cache = readCache(file);\n if (cache && isNewer(cache.latest, opts.current)) {\n write(`banger: ${cache.latest} is available (you have ${opts.current}). Update with: npm install -g ${PACKAGE}@latest\\n`);\n }\n if (cache && now - cache.checkedAt < INTERVAL_MS) return Promise.resolve();\n return (opts.fetchLatest ?? fetchFromRegistry)()\n .then((latest) => {\n if (!latest) return;\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(file, `${JSON.stringify({ checkedAt: now, latest } satisfies Cache)}\\n`);\n })\n .catch(() => undefined);\n}\n"],
|
|
5
|
+
"mappings": ";;;AAAA,SAAS,gBAAAA,eAAc,oBAAoB;AAC3C,SAAS,iBAAAC,gBAAe,qBAAqB;;;ACD7C,SAAS,qBAAqB;AAC9B,SAAS,gBAA8B;AAEhC,IAAM,uBAAN,cAAmC,MAAM;AAAA,EAC9C,cAAc;AACZ,UAAM,iEAAiE;AACvE,SAAK,OAAO;AAAA,EACd;AACF;AAOO,SAAS,cAAsB;AACpC,QAAM,EAAE,SAAAC,SAAQ,IAAI,cAAc,YAAY,GAAG,EAAE,8BAA8B;AACjF,SAAO,+CAA+CA,QAAO;AAC/D;AAGA,eAAsB,cAAc,OAA6D,CAAC,GAAqB;AACrH,QAAM,WAAW,KAAK,YAAY;AAClC,QAAM,YAA8B,KAAK,aAAa;AAAA,IACpD,QAAQ,MAAM,SAAS,OAAO,EAAE,SAAS,UAAU,SAAS,CAAC;AAAA,IAC7D,UAAU,MAAM,SAAS,OAAO,EAAE,SAAS,CAAC;AAAA,EAC9C;AACA,aAAW,UAAU,CAAC,UAAU,QAAQ,UAAU,QAAQ,GAAG;AAC3D,QAAI;AACF,aAAO,MA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AO,MAAM,WAAW,MAAM,OAAO;AAAA,CAAI;AACjD,aAAO,MAAM;AAAA,IACf;AACA,YAAQ,OAAO,MAAM,GAAG,iBAAiB,QAAS,MAAM,SAAS,MAAM,UAAW,OAAO,KAAK,CAAC;AAAA,CAAI;AACnG,WAAO;AAAA,EACT;AACF;AAEA,IAAM,QAAQ,QAAQ,KAAK,CAAC;AAC5B,IAAI,SAAS,YAAY,QAAQ,cAAc,aAAa,KAAK,CAAC,EAAE,MAAM;AACxE,UAAQ,WAAW,MAAM,KAAK,QAAQ,KAAK,MAAM,CAAC,CAAC;AACrD;",
|
|
6
|
+
"names": ["readFileSync", "fileURLToPath", "version", "join", "readFileSync", "readFileSync", "existsSync", "readFileSync", "statSync", "dirname", "join", "join", "dirname", "existsSync", "statSync", "readFileSync", "entry", "entry", "join", "basename", "dirname", "extname", "resolve", "resolve", "dirname", "basename", "extname", "USAGE", "existsSync", "join", "resolve", "fileURLToPath", "USAGE", "join", "existsSync", "fileURLToPath", "resolve", "USAGE", "existsSync", "readFileSync", "join", "resolve", "fileURLToPath", "USAGE", "existsSync", "join", "fileURLToPath", "readFileSync", "resolve", "mkdir", "writeFile", "dirname", "join", "USAGE", "join", "mkdir", "dirname", "writeFile", "existsSync", "writeFileSync", "USAGE", "existsSync", "writeFileSync", "deckFile", "mkdirSync", "readFileSync", "writeFileSync", "homedir", "dirname", "join", "parse", "version", "USAGE", "fileURLToPath", "readFileSync"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Browser } from "playwright-core";
|
|
2
|
+
export declare class BrowserNotFoundError extends Error {
|
|
3
|
+
constructor();
|
|
4
|
+
}
|
|
5
|
+
export interface BrowserLaunchers {
|
|
6
|
+
chrome: () => Promise<Browser>;
|
|
7
|
+
chromium: () => Promise<Browser>;
|
|
8
|
+
}
|
|
9
|
+
export declare function installHint(): string;
|
|
10
|
+
/** Tries Google Chrome first, then Chromium; throws `BrowserNotFoundError` when neither starts. */
|
|
11
|
+
export declare function launchBrowser(opts?: {
|
|
12
|
+
headless?: boolean;
|
|
13
|
+
launchers?: BrowserLaunchers;
|
|
14
|
+
}): Promise<Browser>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Page } from "playwright-core";
|
|
2
|
+
import { type BrowserLaunchers } from "./browser.js";
|
|
3
|
+
import { type ReadyReport, type StopInfo } from "./core-package.js";
|
|
4
|
+
/** Which states of each stop to capture: `"last"` is the fully revealed state only, `"all"` every step. */
|
|
5
|
+
export type StepSelection = "last" | "all";
|
|
6
|
+
export interface StopRef {
|
|
7
|
+
stop: number;
|
|
8
|
+
step: number;
|
|
9
|
+
}
|
|
10
|
+
export interface CaptureSession {
|
|
11
|
+
page: Page;
|
|
12
|
+
path: StopInfo[];
|
|
13
|
+
title: string;
|
|
14
|
+
/** Moves to `ref` and waits until everything in that state has rendered. Call sequentially. */
|
|
15
|
+
goto(ref: StopRef): Promise<ReadyReport>;
|
|
16
|
+
}
|
|
17
|
+
export interface CaptureOptions {
|
|
18
|
+
scale?: 1 | 2;
|
|
19
|
+
launchers?: BrowserLaunchers;
|
|
20
|
+
runtimeVersionCheck?: boolean;
|
|
21
|
+
runtimeTimeoutMs?: number;
|
|
22
|
+
onWarning?: (message: string) => void;
|
|
23
|
+
}
|
|
24
|
+
export declare const RUNTIME_LOAD_TIMEOUT_MS = 15000;
|
|
25
|
+
export declare const STOP_FILE_PATTERN: RegExp;
|
|
26
|
+
export declare function stopFileName(stop: number, step: number): string;
|
|
27
|
+
export declare function expandStates(path: ReadonlyArray<{
|
|
28
|
+
steps: number;
|
|
29
|
+
}>, sel: StepSelection, only?: StopRef): StopRef[];
|
|
30
|
+
/** Deletes only `stop-NNN-step-MMM.png` files directly in `dir`; returns the deleted names. */
|
|
31
|
+
export declare function clearStopFiles(dir: string): Promise<string[]>;
|
|
32
|
+
export declare const defaultOnWarning: (message: string) => void;
|
|
33
|
+
/** Screenshots the current state (call `session.goto` first). The 1920x1080 stage is the whole page, so the clip is the full viewport by default. */
|
|
34
|
+
export declare function captureState(session: CaptureSession, ref: StopRef, clip?: {
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
}): Promise<Buffer>;
|
|
40
|
+
/**
|
|
41
|
+
* Opens the deck in export mode and runs `fn` against it. Server, browser and page are always closed.
|
|
42
|
+
* Warnings (runtime version mismatch, font fallbacks) go through `onWarning`, once per distinct message.
|
|
43
|
+
*/
|
|
44
|
+
export declare function withCapture<T>(file: string, opts: CaptureOptions, fn: (session: CaptureSession) => Promise<T>): Promise<T>;
|
|
45
|
+
export declare function formatReadyFailure(failure: {
|
|
46
|
+
tag: string;
|
|
47
|
+
selector: string;
|
|
48
|
+
reason: string;
|
|
49
|
+
}): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface CheckResult {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
stops: number;
|
|
4
|
+
warnings: string[];
|
|
5
|
+
failed: string[];
|
|
6
|
+
}
|
|
7
|
+
/** Renders every stop at its last step without taking pictures and collects what the runtime reports. */
|
|
8
|
+
export declare function checkDeck(file: string): Promise<CheckResult>;
|
|
9
|
+
export declare function runCheck(argv: string[]): Promise<number>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runExport(argv: string[]): Promise<number>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runPreview(argv: string[]): Promise<number>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Marks a directory written by `banger skill install`, so a later install may replace it. Holds the CLI version. */
|
|
2
|
+
export declare const MARKER = ".banger-skill";
|
|
3
|
+
export interface InstallSkillOptions {
|
|
4
|
+
source: string;
|
|
5
|
+
dest: string;
|
|
6
|
+
version: string;
|
|
7
|
+
force?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** Copies the bundled skill to `dest`. Returns whether an earlier install was replaced. */
|
|
10
|
+
export declare function installSkill(opts: InstallSkillOptions): "installed" | "updated";
|
|
11
|
+
export declare function runSkill(argv: string[]): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runSnap(argv: string[]): Promise<number>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runTheme(argv: string[]): Promise<number>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const CORE_PACKAGE = "@bangerpage/core";
|
|
2
|
+
export declare const CDN_HOSTS: string[];
|
|
3
|
+
export type { ReadyFailure, ReadyReport, StopInfo } from "@bangerpage/core";
|
|
4
|
+
export { PRESET_NAMES, isPresetName, parseThemeJson, presetTheme, resolveTheme, serializeTheme } from "@bangerpage/core/theme";
|
|
5
|
+
export type { PresetName } from "@bangerpage/core/theme";
|
|
6
|
+
export type { ThemeDefinition } from "@bangerpage/core";
|
|
7
|
+
export declare function coreDistDir(): string;
|
|
8
|
+
export declare function coreManifestPath(): string;
|
|
9
|
+
export declare function coreVersion(): string;
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Failure of a CLI operation.
|
|
3
|
+
* `exitCode` 1 is a problem with the deck's content (failed components, unembeddable assets);
|
|
4
|
+
* 2 is a problem with usage or the environment (bad option, missing file, no browser, port in use).
|
|
5
|
+
*/
|
|
6
|
+
export declare class CliError extends Error {
|
|
7
|
+
readonly exitCode: 1 | 2;
|
|
8
|
+
constructor(exitCode: 1 | 2, message: string);
|
|
9
|
+
}
|
|
10
|
+
/** Reads a deck file as UTF-8; a missing file is `CliError(2)`. */
|
|
11
|
+
export declare function readInput(file: string): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BrowserLaunchers } from "../browser.js";
|
|
2
|
+
import { type StepSelection } from "../capture.js";
|
|
3
|
+
/**
|
|
4
|
+
* Writes the deck as a PDF with one 1920x1080 CSS px page per state; text stays vector.
|
|
5
|
+
*
|
|
6
|
+
* @param file Path to the deck HTML.
|
|
7
|
+
* @param opts.out Output path (default: next to the input, same name with `.pdf`).
|
|
8
|
+
* @param opts.steps `"last"` (default) writes one page per stop; `"all"` one page per step.
|
|
9
|
+
* @param opts.onWarning Receives warnings (font fallbacks, runtime version mismatch); defaults to stderr.
|
|
10
|
+
* @returns The absolute path of the written PDF.
|
|
11
|
+
* @throws CliError with `exitCode` 1 when a component fails to render (nothing is written),
|
|
12
|
+
* the runtime script did not load, or the deck has no `<bang-root>`; 2 when the file is missing or no browser is available.
|
|
13
|
+
*/
|
|
14
|
+
export declare function exportPdf(file: string, opts?: {
|
|
15
|
+
out?: string;
|
|
16
|
+
steps?: StepSelection;
|
|
17
|
+
launchers?: BrowserLaunchers;
|
|
18
|
+
onWarning?: (message: string) => void;
|
|
19
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface RuntimeScriptRef {
|
|
2
|
+
src: string;
|
|
3
|
+
version: string | null;
|
|
4
|
+
line: number;
|
|
5
|
+
element: {
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
8
|
+
};
|
|
9
|
+
srcAttr: {
|
|
10
|
+
start: number;
|
|
11
|
+
end: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function runtimeUrlPattern(corePackage: string): RegExp;
|
|
15
|
+
/** The first `<script type="module" src>` that points at the core runtime on a known CDN. */
|
|
16
|
+
export declare function findRuntimeScript(html: string, corePackage: string): RuntimeScriptRef | null;
|
|
17
|
+
/**
|
|
18
|
+
* Describes how the deck's runtime script differs from the local core the CLI renders with.
|
|
19
|
+
* Returns null when they agree or the deck does not load the runtime.
|
|
20
|
+
*/
|
|
21
|
+
export declare function runtimeVersionWarning(html: string, corePackage: string, localVersion: string): {
|
|
22
|
+
message: string;
|
|
23
|
+
line: number;
|
|
24
|
+
} | null;
|
|
25
|
+
/** Replaces only the `src` value of the runtime script; other bytes stay untouched. */
|
|
26
|
+
export declare function rewriteRuntimeScript(html: string, corePackage: string, newSrc: string): string;
|
|
27
|
+
/** Inserts `snippet` just before `</body>`, or at the end when there is none. */
|
|
28
|
+
export declare function injectBeforeBodyEnd(html: string, snippet: string): string;
|
|
29
|
+
export interface ThemeApplyResult {
|
|
30
|
+
html: string;
|
|
31
|
+
extraBlocks: number;
|
|
32
|
+
}
|
|
33
|
+
export interface ThemeApplyError {
|
|
34
|
+
error: "unclosed-theme" | "foreign-children";
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Embeds `json` as the first `<bang-theme>` block directly inside the first `<bang-root>` and sets
|
|
38
|
+
* `theme="custom"`. Only the block and the `theme` attribute are rewritten; other bytes stay untouched.
|
|
39
|
+
* Returns null when the deck has no `<bang-root>`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function applyThemeBlock(html: string, json: string): ThemeApplyResult | ThemeApplyError | null;
|
package/dist/index.d.ts
ADDED