Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
015af91
refactor(layout): share one coordinate rounding helper with core
hyamero Nov 13, 2026
286096f
fix(cli): keep serve running when a request path is not a valid URL
hyamero Nov 13, 2026
a831b50
fix(cli): accept the port-less Host header that clients send when ser…
hyamero Nov 13, 2026
6cfd1e7
fix(viewer): keep the export menu open when an item is pressed in Safari
hyamero Nov 13, 2026
4cfe20c
fix(viewer): forget a pan's target when another camera move cuts it s…
hyamero Nov 13, 2026
f23cdc4
fix(cli): pick up saves made during serve's first layout, and rebuild…
hyamero Nov 13, 2026
bb5a4fc
fix(cli): stop warning of a slow layout for workflow, lifecycle and s…
hyamero Nov 13, 2026
6c914fb
fix(cli): have serve say when a large diagram is being laid out
hyamero Nov 13, 2026
0109ea9
perf(layout): skip routes nowhere near a label when placing it
hyamero Nov 13, 2026
db15abf
fix(cli): skip serve rebuilds when the watched file's content has not…
hyamero Nov 13, 2026
2bd5dd7
fix(viewer): centre a search result that was off screen instead of pa…
hyamero Nov 13, 2026
4eb13db
fix(layout): keep a repeated unanswered call in the activation bar it…
hyamero Nov 13, 2026
d922e4a
fix(viewer): keep a route to what lies between its ends, not loops ba…
hyamero Nov 13, 2026
e3cd0fb
fix(layout): end a sequence message on the bar it meets left of a nes…
hyamero Nov 13, 2026
5e4d2bd
fix(cli): report serve's port and folder failures as plain errors, no…
hyamero Nov 13, 2026
3a9fb1b
fix(viewer): refit the presentation once full screen has resized the …
hyamero Nov 13, 2026
8c6d3b1
docs(site): reserve the walkthrough's runway in CSS so a hash or a re…
hyamero Nov 13, 2026
c56e6b9
fix(layout): size an empty group's frame to hold its title
hyamero Nov 13, 2026
8b14924
fix(cli): reject an empty or non-numeric --port instead of serving on…
hyamero Nov 13, 2026
6d64bd6
fix(cli): refuse to overwrite the input when -o names it in a differe…
hyamero Nov 13, 2026
0a9b2db
fix(viewer): leave ⌘/Ctrl/Alt key combinations on the canvas to the b…
hyamero Nov 13, 2026
9fe50ca
fix(layout): keep edge labels off a group title wider than 160px
hyamero Nov 13, 2026
869e418
fix(core): budget a row label against its value as rendered, so padde…
hyamero Nov 13, 2026
ede1b2b
fix(viewer): show a card's link in the inspector when the card has no…
hyamero Nov 13, 2026
7996a31
docs(site): leave what is already on screen alone when the reveals ta…
hyamero Nov 13, 2026
4958249
docs(site): light the edge when its JSON lines are pointed at in a li…
hyamero Nov 13, 2026
b346cb6
docs(site): fetch the search index again after a failed load
hyamero Nov 13, 2026
fb1aa82
docs(site): start the embedded viewer's flow only once it is on screen
hyamero Nov 13, 2026
847f9d4
docs(site): keep the gallery's kind filter in step with the address
hyamero Nov 13, 2026
df4f48f
docs(site): place the docs sheet's section bar when the sheet opens
hyamero Nov 13, 2026
e6b7c7b
docs(site): describe Play in the try bar only while it runs over the …
hyamero Nov 13, 2026
dd0a670
docs(site): drop the embedded viewer's header icon on a phone, where …
hyamero Nov 13, 2026
aebe977
fix(layout): keep a corner that ELK returns as two points in one place
hyamero Nov 13, 2026
b24f950
fix(schema): suggest an evidence note, not a card row, for a self-loo…
hyamero Nov 13, 2026
ab45d00
fix(schema): offer to phase the source of a phase-order edge only whe…
hyamero Nov 13, 2026
1409af3
refactor(schema): read a phase-order edge's phase from phaseViolation…
hyamero Nov 13, 2026
5a085cb
perf(layout): skip a label retry that repeats the first layout, and c…
hyamero Nov 13, 2026
f031a18
fix(viewer): track the edges in flight per diagram, not once for the …
hyamero Nov 13, 2026
eed249e
fix(schema): give an out-of-range number a numeric fix instead of a t…
hyamero Nov 13, 2026
ce27aed
fix(schema): stop suggesting a move for unknown keys named like Objec…
hyamero Nov 13, 2026
ea0f727
fix(schema): warn about an empty card footer, which draws a blank band
hyamero Nov 13, 2026
620ae90
test(cli): resolve the built CLI with fileURLToPath so smoke and e2e …
hyamero Nov 13, 2026
d48ca3f
test(cli): cover serve skipping a rebuild when a save changes nothing
hyamero Nov 13, 2026
af069b5
refactor(viewer): look up a viewer's cards and dot grid within that v…
hyamero Nov 13, 2026
14ddd16
docs(layout): say why a large diagram wraps without the width gate
hyamero Nov 13, 2026
247060f
docs(site): keep the docs search's keys after a press on its panel, a…
hyamero Nov 13, 2026
f4cf9e2
docs(site): fit the embedded viewer's still to the stage's 936px, its…
hyamero Nov 13, 2026
1e11833
docs(site): drop a phone gap rule that restates the embedded viewer's…
hyamero Nov 13, 2026
84d123b
docs(site): write "An architecture diagram" in the example pages' des…
hyamero Nov 13, 2026
ff328a3
docs(site): list a schema field once in the search when folded card p…
hyamero Nov 13, 2026
2b0d0d3
docs(site): name the package, the repo and the schema URL in one module
hyamero Nov 13, 2026
56fee9d
docs(site): light the innermost group when linked figure frames nest
hyamero Nov 13, 2026
c598db1
docs(site): count the gallery's kinds with the filter's own match
hyamero Nov 13, 2026
2434469
docs(site): take the landing's and the quick start's request from the…
hyamero Nov 13, 2026
901476d
docs(site): remove the unused Still, Note, three icons and their CSS
hyamero Nov 13, 2026
fc0c1dd
docs(site): fit stills and live scenes to their box with one hook
hyamero Nov 13, 2026
d1203c4
docs(site): let git diff's own failure cover a commit missing from th…
hyamero Nov 13, 2026
7ac0baf
perf(viewer): build flow geometry once per scene, and the flow only w…
hyamero Nov 13, 2026
a51bc9f
fix(layout): keep lane routes off cards and off the port runs that fa…
hyamero Nov 14, 2026
0e4a103
docs(site): arrive at a #hash at once, so a glide can't be cut short …
hyamero Nov 14, 2026
4db9845
fix(layout): keep edge labels inside the diagram's bounds
hyamero Nov 14, 2026
e158248
fix(layout): size stage bands round group frames, clear of the stage …
hyamero Nov 14, 2026
c931def
fix(layout): keep lane routes off the lanes' edges
hyamero Nov 14, 2026
5b8492b
docs(site): test the search's schema fields without the generated dat…
hyamero Nov 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/cli/e2e/offline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { execFileSync } from 'node:child_process';
import { mkdtempSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { pathToFileURL } from 'node:url';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { expect, test } from '@playwright/test';
import { groupedPlatform } from '@stackmap/core/samples';

test('a delivered file renders from file:// with no network', async ({ page }) => {
const dir = mkdtempSync(join(tmpdir(), 'stackmap-e2e-'));
const input = join(dir, 'platform.json');
writeFileSync(input, JSON.stringify(groupedPlatform));
execFileSync('node', [new URL('../dist/cli.js', import.meta.url).pathname, 'deliver', input]);
execFileSync('node', [fileURLToPath(new URL('../dist/cli.js', import.meta.url)), 'deliver', input]);

const requests: string[] = [];
await page.route('**/*', (route) => {
Expand All @@ -29,6 +29,6 @@ test('a delivered file renders from file:// with no network', async ({ page }) =
});

test('the bare template says no diagram is embedded', async ({ page }) => {
await page.goto(pathToFileURL(new URL('../dist/viewer.html', import.meta.url).pathname).href);
await page.goto(new URL('../dist/viewer.html', import.meta.url).href);
await expect(page.getByRole('status')).toHaveText(/No diagram embedded/);
});
3 changes: 2 additions & 1 deletion packages/cli/e2e/serve.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { spawn, type ChildProcess } from 'node:child_process';
import { mkdtempSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { expect, test } from '@playwright/test';
import { commerceApi } from '@stackmap/core/samples';

Expand All @@ -15,7 +16,7 @@ async function start(initial: unknown, port = '0') {
file = join(mkdtempSync(join(tmpdir(), 'stackmap-live-')), 'd.json');
write(initial);
}
proc = spawn('node', [new URL('../dist/cli.js', import.meta.url).pathname, 'serve', file, '--port', port]);
proc = spawn('node', [fileURLToPath(new URL('../dist/cli.js', import.meta.url)), 'serve', file, '--port', port]);
url = await new Promise<string>((resolve, reject) => {
proc.stdout!.on('data', (b: Buffer) => {
const m = /serving (http:\/\/127\.0\.0\.1:\d+)/.exec(b.toString());
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/scripts/smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { createHash } from 'node:crypto';
import { mkdtempSync, readFileSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { GALLERY } from '../../core/src/samples/gallery.ts';
import { commerceApi, groupedPlatform } from '../../core/src/samples/index.ts';

const cli = new URL('../dist/cli.js', import.meta.url).pathname;
// Not `.pathname`: it keeps percent-escapes, so a checkout path with a space would not resolve.
const cli = fileURLToPath(new URL('../dist/cli.js', import.meta.url));
const dir = mkdtempSync(join(tmpdir(), 'stackmap-smoke-'));
const run = (...args) => execFileSync('node', [cli, ...args], { encoding: 'utf8' });
const check = (ok, msg) => {
Expand Down
11 changes: 5 additions & 6 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { readFileSync } from 'node:fs';
import { parseArgs } from 'node:util';
import { deliverCommand, validateCommand, type CommandResult } from './commands';
import { deliverCommand, failure, validateCommand, type CommandResult } from './commands';
import { openInBrowser } from './open';
import { serve } from './serve';
import { styleFor } from './style';
Expand Down Expand Up @@ -81,18 +81,17 @@ async function run(argv: string[]): Promise<CommandResult> {
return signed(command, await deliverCommand(file, { template, out: values.out, style, open, progress }));
}

const port = values.port === undefined ? 4400 : Number(values.port);
if (!Number.isInteger(port) || port < 0 || port > 65535) return usage(`--port must be 0-65535, got "${values.port}"`);
// Digits only: Number('') and Number(' ') are 0, which would silently mean "any free port".
const port = values.port === undefined ? 4400 : /^\d+$/.test(values.port) ? Number(values.port) : NaN;
if (!(port >= 0 && port <= 65535)) return usage(`--port must be 0-65535, got "${values.port}"`);
const server = await serve(file, { template, port, log: (line) => process.stderr.write(`${line}\n`) });
process.stdout.write(sign(command, `serving ${style.path(server.url)} · watching ${file} · Ctrl-C to stop\n`));
await new Promise<void>((resolve) => process.once('SIGINT', resolve));
await server.close();
return { code: 0, stdout: '', stderr: '' };
}

const result = await run(process.argv.slice(2)).catch(
(e: unknown): CommandResult => ({ code: 2, stdout: '', stderr: `stackmap: internal error: ${(e as Error).message}\n` }),
);
const result = await run(process.argv.slice(2)).catch(failure);
process.stdout.write(result.stdout);
process.stderr.write(result.stderr);
process.exitCode = result.code;
11 changes: 7 additions & 4 deletions packages/cli/src/commands.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createHash } from 'node:crypto';
import { realpathSync } from 'node:fs';
import { extname, resolve } from 'node:path';
import { isLaneKind } from '@stackmap/core';
import { isLarge, layoutDiagram } from '@stackmap/layout';
import { validateDiagram, type Diagnostic, type ValidationResult } from '@stackmap/schema';
import { embedDiagram } from './embed';
Expand Down Expand Up @@ -36,15 +37,16 @@ export function validateFile(path: string): ValidationResult {
}

// Exit 1 means "the diagram has errors" to the agent loop, so every other failure must be exit 2.
const failure = (e: unknown): CommandResult => ({
export const failure = (e: unknown): CommandResult => ({
code: 2,
stdout: '',
stderr: `stackmap: ${e instanceof CliError ? '' : 'internal error: '}${(e as Error).message}\n`,
});

const real = (p: string) => {
try {
return realpathSync(p);
// .native also resolves the name to its case on disk: on macOS and Windows `D.JSON` can be `d.json`.
return realpathSync.native(p);
} catch {
return resolve(p);
}
Expand All @@ -70,9 +72,10 @@ export async function buildHtml(
): Promise<ValidationResult & { html?: string }> {
const result = validateFile(path);
if (!result.ok || !result.diagram) return result;
const { nodes, edges } = result.diagram;
const { kind, nodes, edges } = result.diagram;
// The result only prints once the layout is done; without this a big diagram looks hung for minutes.
if (progress && isLarge(result.diagram))
// Lane and sequence kinds have their own layouts, which take a second at their largest.
if (progress && !isLaneKind(kind) && kind !== 'sequence' && isLarge(result.diagram))
progress(`laying out ${nodes.length} nodes and ${edges.length} connections; a diagram this size can take a while`);
return { ...result, html: embedDiagram(template, await layoutDiagram(result.diagram)) };
}
Expand Down
81 changes: 59 additions & 22 deletions packages/cli/src/serve.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createHash } from 'node:crypto';
import { watch, type FSWatcher } from 'node:fs';
import { readFileSync, watch, type FSWatcher } from 'node:fs';
import { createServer, type ServerResponse } from 'node:http';
import type { AddressInfo } from 'node:net';
import { basename, dirname } from 'node:path';
Expand Down Expand Up @@ -41,6 +41,13 @@ const diagnostic = (code: string, message: string, fix: string, path: string): D
allowedFixes: [fix],
});

/** DNS rebinding: a foreign page resolving its own name to 127.0.0.1 would send its own Host. */
export function isLocalHost(host: string | undefined, port: number): boolean {
// Clients leave the port out of Host when it is http's default.
const suffixes = port === 80 ? [':80', ''] : [`:${port}`];
return suffixes.some((s) => host === `127.0.0.1${s}` || host === `localhost${s}`);
}

function listen(server: ReturnType<typeof createServer>, port: number): Promise<number> {
return new Promise((resolve, reject) => {
const tryPort = (p: number, left: number) => {
Expand Down Expand Up @@ -93,9 +100,19 @@ export async function serve(path: string, { template, port = 4400, log = () => {
};

let built = false;
// What the last build read: the watcher also reports saves that change nothing, and a write from just before it started.
let source = '';
const fingerprint = () => {
try {
return createHash('sha256').update(readFileSync(path)).digest('hex');
} catch {
return '';
}
};
const rebuild = async () => {
source = fingerprint();
try {
const result = await buildHtml(path, template);
const result = await buildHtml(path, template, log);
publish({ ok: result.ok, diagnostics: result.diagnostics }, result.html);
} catch (e) {
const unreadable = e instanceof CliError;
Expand All @@ -110,21 +127,54 @@ export async function serve(path: string, { template, port = 4400, log = () => {
}
};

await rebuild();
// One rebuild waits behind the running one however many saves arrive: only the latest content matters.
let queued = false;
let running = Promise.resolve();
const schedule = () => {
if (queued) return;
queued = true;
running = running
.then(() => {
queued = false;
if (fingerprint() !== source) return rebuild();
})
.catch((e: unknown) => log(`✗ rebuild failed: ${(e as Error).message}`));
};

// Editors save by writing a temp file and renaming it over the original, so watch the directory.
// Watching starts before the first build, so a save during that layout is not lost.
let timer: NodeJS.Timeout | undefined;
let watcher: FSWatcher;
try {
watcher = watch(dirname(path), (_event, name) => {
if (name !== null && name !== basename(path)) return;
clearTimeout(timer);
timer = setTimeout(schedule, DEBOUNCE_MS);
});
} catch (e) {
throw new CliError(`cannot watch ${dirname(path)}: ${(e as NodeJS.ErrnoException).code ?? (e as Error).message}`);
}
// e.g. the directory was deleted (EPERM on Windows): report it instead of crashing the server.
watcher.on('error', (e) =>
publish({ ok: false, diagnostics: [diagnostic('io/watch-failed', `stopped watching: ${e.message}`, 'restart stackmap serve', path)] }),
);

running = rebuild();
await running;

let bound = 0;
const server = createServer((req, res) => {
// DNS rebinding: a foreign page resolving its own name to 127.0.0.1 would send its own Host.
if (req.headers.host !== `127.0.0.1:${bound}` && req.headers.host !== `localhost:${bound}`) {
if (!isLocalHost(req.headers.host, bound)) {
res.writeHead(403, { 'content-type': 'text/plain' });
return void res.end('forbidden host');
}
const url = new URL(req.url ?? '/', 'http://localhost');
// Not `new URL`: it throws on a path like `//`, and any page in the user's browser can send one.
const pathname = (req.url ?? '/').split('?', 1)[0];
const read = req.method === 'GET' || req.method === 'HEAD';
if (read && url.pathname === '/') {
if (read && pathname === '/') {
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-store' });
res.end(req.method === 'HEAD' ? undefined : page);
} else if (req.method === 'GET' && url.pathname === '/events') {
} else if (req.method === 'GET' && pathname === '/events') {
res.writeHead(200, { 'content-type': 'text/event-stream', 'cache-control': 'no-store', connection: 'keep-alive' });
res.write('retry: 1000\n\n');
send(res, 'diagnostics', JSON.stringify(state));
Expand All @@ -136,23 +186,10 @@ export async function serve(path: string, { template, port = 4400, log = () => {
}
});

// Editors save by writing a temp file and renaming it over the original, so watch the directory.
let timer: NodeJS.Timeout | undefined;
let running = Promise.resolve();
const watcher: FSWatcher = watch(dirname(path), (_event, name) => {
if (name !== null && name !== basename(path)) return;
clearTimeout(timer);
timer = setTimeout(() => {
running = running.then(rebuild).catch((e: unknown) => log(`✗ rebuild failed: ${(e as Error).message}`));
}, DEBOUNCE_MS);
});
// e.g. the directory was deleted (EPERM on Windows): report it instead of crashing the server.
watcher.on('error', (e) =>
publish({ ok: false, diagnostics: [diagnostic('io/watch-failed', `stopped watching: ${e.message}`, 'restart stackmap serve', path)] }),
);
const keepAlive = setInterval(() => clients.forEach((res) => res.write(': ping\n\n')), 15_000);

bound = await listen(server, port).catch((e) => {
clearTimeout(timer);
watcher.close();
clearInterval(keepAlive);
throw e;
Expand Down
25 changes: 24 additions & 1 deletion packages/cli/test/commands.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createHash } from 'node:crypto';
import { chmodSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { beforeEach, describe, expect, it } from 'vitest';
Expand Down Expand Up @@ -89,6 +89,19 @@ describe('deliver', () => {
expect(lines).toEqual(['laying out 61 nodes and 60 connections; a diagram this size can take a while']);
}, 30_000);

it('gives no slow-layout notice for kinds that never reach the slow layout', async () => {
const lines: string[] = [];
const nodes = Array.from({ length: 61 }, (_, i) => ({ id: `n${i}`, type: 'service', lane: 'a', card: { title: `n${i}` } }));
const edges = nodes.slice(1).map((n, i) => ({ id: `e${i}`, from: `n${i}`, to: n.id }));
const workflow = { kind: 'workflow', title: 'Steps', lanes: [{ id: 'a', label: 'A' }], nodes, edges };
const sequence = { kind: 'sequence', title: 'Calls', nodes: nodes.map(({ lane: _lane, ...n }) => n), edges };
for (const [name, d] of Object.entries({ workflow, sequence })) {
const r = await deliverCommand(file(`${name}.json`, d), { template: TEMPLATE, progress: (l) => lines.push(l) });
expect(r.code).toBe(0);
}
expect(lines).toEqual([]);
});

it('opens nothing when validation fails', async () => {
let opened = false;
const r = await deliverCommand(file('broken.json', broken), { template: TEMPLATE, open: async () => ((opened = true), null) });
Expand Down Expand Up @@ -147,6 +160,16 @@ describe('deliver', () => {
expect(JSON.parse(readFileSync(json, 'utf8'))).toEqual(commerceApi);
});

it('refuses an output that names its input in another case, where the filesystem ignores case', async () => {
const json = file('case.json', commerceApi);
const upper = join(dir, 'CASE.JSON');
if (!existsSync(upper)) return; // a case-sensitive filesystem: that is a different file
const r = await deliverCommand(json, { template: TEMPLATE, out: upper });
expect(r.code).toBe(2);
expect(r.stderr).toMatch(/^stackmap: refusing to overwrite the input/);
expect(JSON.parse(readFileSync(json, 'utf8'))).toEqual(commerceApi);
});

it('reports an unexpected failure as an internal error with exit 2, never a stack trace', async () => {
const r = await deliverCommand(file('d.json', commerceApi), { template: '<html>no data block</html>' });
expect(r.code).toBe(2);
Expand Down
51 changes: 51 additions & 0 deletions packages/cli/test/serve-queue.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { mkdtempSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { afterEach, expect, it, vi } from 'vitest';
import { buildHtml } from '../src/commands';
import { serve, type ServeHandle } from '../src/serve';

vi.mock('../src/commands', () => ({ buildHtml: vi.fn() }));
const build = vi.mocked(buildHtml);
const built = (title: string) => ({ ok: true, diagnostics: [], html: `<title>${title}</title><body></body>` });
const pause = (ms: number) => new Promise((r) => setTimeout(r, ms));

let server: ServeHandle | undefined;
afterEach(async () => {
await server?.close();
server = undefined;
});

it('runs one rebuild for all the saves that arrive during a slow one', async () => {
const file = join(mkdtempSync(join(tmpdir(), 'stackmap-queue-')), 'd.json');
writeFileSync(file, '1');
build.mockResolvedValueOnce(built('first'));
server = await serve(file, { template: '<body></body>', port: 0 });
build.mockClear();

let release!: () => void;
build.mockImplementationOnce(() => new Promise((resolve) => (release = () => resolve(built('slow')))));
build.mockResolvedValue(built('latest'));
// Each save lands after the previous one's debounce, while the slow build is still running.
for (const content of ['2', '3', '4']) {
writeFileSync(file, content);
await pause(300);
}
release();
await expect.poll(async () => (await fetch(server!.url)).text(), { timeout: 4000 }).toContain('<title>latest</title>');
await pause(300);
expect(build).toHaveBeenCalledTimes(2);
});

it('does not rebuild for a save that leaves the content as it was built', async () => {
const file = join(mkdtempSync(join(tmpdir(), 'stackmap-queue-')), 'd.json');
writeFileSync(file, '1');
build.mockResolvedValue(built('first'));
server = await serve(file, { template: '<body></body>', port: 0 });
build.mockClear();
writeFileSync(file, '1');
await pause(400);
expect(build).not.toHaveBeenCalled();
writeFileSync(file, '2');
await expect.poll(() => build.mock.calls.length, { timeout: 4000 }).toBe(1);
});
Loading
Loading