mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 20:45:33 -08:00
Add Notebook tabs and a CodeMirror editor, rename Notepad to Notebook, add Back to Questions
AI Assisted
This commit is contained in:
1 parent
2075d235d8
commit
d4adb53a3a
55 files changed
+4017
-9231
No files matched your search
@@ -81,18 +81,46 @@ const SHOTS = {
|
||||
// The git board draws itself from a real repository, so this shot runs in
|
||||
// its own git sample project; the post only hands the board back to you.
|
||||
git: { workflow: "git", posts: ["git"], repo: true },
|
||||
// The Notepad dialog over the plan question, with a few lines of Markdown
|
||||
// typed into it. The store is the scratch folder's, never the real one.
|
||||
// The Notebook dialog over the plan question, with two named tabs: Call notes
|
||||
// (a heading, bullets and bold, shown live) and Ideas, with the first one
|
||||
// open. The store is the scratch folder's, never the real one.
|
||||
notepad: {
|
||||
workflow: "plan",
|
||||
posts: ["question"],
|
||||
open: async (page) => {
|
||||
await page.click("#btn-notepad");
|
||||
await page.waitForSelector("#notepad-modal[open]", { timeout: 10000 });
|
||||
await page.waitForFunction(() => !document.querySelector("#notepad-modal textarea").readOnly, null, { timeout: 10000 });
|
||||
await page.locator("#notepad-modal textarea").fill(
|
||||
"# Before the call\n\n- Ask about **paging**: cursor or offset?\n- Who signs in to the API?\n- Check the `/tasks` limit with the team\n"
|
||||
const editor = page.locator("#notepad-editor .cm-content");
|
||||
const newTab = async (name) => {
|
||||
await page.click((await page.locator("#notepad-empty").isVisible()) ? "#notepad-empty-new" : "#notepad-tab-new");
|
||||
await page.fill("#notepad-name", name);
|
||||
await page.keyboard.press("Enter");
|
||||
await page.waitForFunction(
|
||||
(n) => [...document.querySelectorAll("#notepad-tabs .notepad-tab")].some((b) => b.textContent === n && b.getAttribute("aria-selected") === "true"),
|
||||
name,
|
||||
{ timeout: 10000 },
|
||||
);
|
||||
await editor.click();
|
||||
};
|
||||
// The second theme's run finds the first one's tabs, kept in the same store.
|
||||
await page.waitForFunction(
|
||||
() => document.querySelector("#notepad-tabs .notepad-tab") || !document.getElementById("notepad-empty").hidden,
|
||||
null,
|
||||
{ timeout: 10000 },
|
||||
);
|
||||
if (!(await page.locator("#notepad-tabs .notepad-tab").count())) {
|
||||
// The list marker is typed once: the editor carries a list on at Enter.
|
||||
await newTab("Call notes");
|
||||
await page.keyboard.type(
|
||||
"# Before the call\n\n- Ask about **paging**: cursor or offset?\nWho signs in to the API?\nCheck the `/tasks` limit with the team\n\n"
|
||||
);
|
||||
await newTab("Ideas");
|
||||
await page.keyboard.type("Retry policy for the export job.\nWhat should the page size cap be?");
|
||||
}
|
||||
await sleep(1000);
|
||||
await page.locator("#notepad-tabs .notepad-tab", { hasText: /^Call notes$/ }).click();
|
||||
await page.locator("#notepad-editor .cm-h1").waitFor({ timeout: 10000 });
|
||||
await page.locator("#notepad-editor .cm-line").last().click();
|
||||
await sleep(1800);
|
||||
},
|
||||
},
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -669,6 +669,30 @@ test("Download offers a Markdown file with the doc's title, blocks and marks", a
|
||||
assert.equal(Buffer.concat(chunks).toString("utf8"), "# What we've agreed\n\nRuns nightly.\n\n> **Assumed for now, still open.**\n\nOutput is CSV.");
|
||||
});
|
||||
|
||||
// What a person sees break: a long document has no way home but the first
|
||||
// tab, or its header scrolls away with the text.
|
||||
test("a document's header stays on screen and its Back to Questions button returns to the questions", async (t) => {
|
||||
const blocks = Array.from({ length: 60 }, (_, i) => ({ id: "b" + i, state: "settled", md: `Paragraph ${i}. ` + "More words. ".repeat(40) }));
|
||||
const s = await openSession(await suite.browser(), {
|
||||
t,
|
||||
workflow: "plan",
|
||||
payload: {
|
||||
items: [{ id: "q1", kind: "text", title: "A question", body: "Say something." }],
|
||||
docs: [{ id: "map", title: "What we've agreed", blocks }],
|
||||
},
|
||||
});
|
||||
await s.page.locator("#views").getByRole("button", { name: /What we've agreed/ }).click();
|
||||
const back = s.page.getByRole("button", { name: "Back to Questions" });
|
||||
await back.waitFor();
|
||||
await s.page.evaluate(() => { document.getElementById("main").scrollTop = 4000; });
|
||||
const box = await back.boundingBox();
|
||||
const main = await s.page.locator("#main").boundingBox();
|
||||
assert.ok(box && box.y >= main.y - 1 && box.y < main.y + 80, "the header row is still at the top of the pane after scrolling");
|
||||
await back.click();
|
||||
await s.page.getByText("Say something.").waitFor();
|
||||
assert.equal(await s.page.getByRole("button", { name: "Back to Questions" }).count(), 0, "the questions view has no Back button");
|
||||
});
|
||||
|
||||
// What a person sees break: the brief button turns up where no playbook
|
||||
// answers it, or sends a different range than the one picked.
|
||||
test("a pathfinder session offers Write a brief, and the picked range reaches the agent", async (t) => {
|
||||
|
||||
@@ -1,50 +1,93 @@
|
||||
// Page tests for the Notepad: the top bar icon on every screen, the styled
|
||||
// editor, autosave and what survives a reload or a restart, one notepad per
|
||||
// folder, the page's content-security policy with the editor open, hostile
|
||||
// Markdown, typing speed on a long note, the editor's two layers lining up,
|
||||
// both themes, and the pictures: adding, deleting, the preview and the cap.
|
||||
// Page tests for the Notebook: the top bar icon on every screen, the tabs (made
|
||||
// by naming them, renamed, reordered, deleted after two confirms), the live
|
||||
// Markdown editor, autosave per tab and what survives a reload or a restart,
|
||||
// one notepad per folder, the page's content-security policy with the editor
|
||||
// open, hostile Markdown, typing speed on a long note, both themes, and the
|
||||
// pictures: adding, deleting, the preview and the cap.
|
||||
// Run with:
|
||||
// node --test scripts/test-web-console-page-notepad.mjs
|
||||
//
|
||||
// Each test drives the real console in a real Chrome or Edge through
|
||||
// scripts/page-test-helpers.mjs: one browser for the file, a fresh console
|
||||
// session per test. Notes land in the file's throwaway NOTEPADS_DIR.
|
||||
//
|
||||
// The editor lives in the open shadow root of `.notepad-cm-host`: Playwright's
|
||||
// CSS locators pierce it, `page.evaluate` code reaches in through `shadowRoot`,
|
||||
// and the text is read from the editor's own state (`docText`), since lines
|
||||
// the cursor is not on draw without their Markdown marks.
|
||||
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { pageSuite, openSession, drawn } from "./page-test-helpers.mjs";
|
||||
import { backdate, cli, until } from "./web-console-test-helpers.mjs";
|
||||
import { JPEG, backdate, cli, until } from "./web-console-test-helpers.mjs";
|
||||
import {
|
||||
LEGACY_TAB_ID,
|
||||
NOTEPAD_MAX_IMAGES,
|
||||
NOTE_MAX_BYTES,
|
||||
addImage,
|
||||
addImage as addImageTo,
|
||||
createTab,
|
||||
defaultTabId,
|
||||
deleteTab,
|
||||
listTabs,
|
||||
notepadFolder,
|
||||
notepadKey,
|
||||
readNotepad,
|
||||
removeImage,
|
||||
saveNote,
|
||||
removeImage as removeImageFrom,
|
||||
saveNote as saveNoteTo,
|
||||
} from "../src/web-console/notepads.mjs";
|
||||
import { NOT_LOADED, SAVE_DEBOUNCE_MS, errorSentence } from "../src/web-console/public/notepad.js";
|
||||
|
||||
const suite = pageSuite(test);
|
||||
|
||||
// The store calls here name the tab they use: the last one, with Notes made
|
||||
// first when the notepad has none.
|
||||
const openTab = (folder) => defaultTabId(folder) ?? createTab(folder, "Notes").id;
|
||||
const saveNote = (folder, text) => saveNoteTo(folder, openTab(folder), text);
|
||||
const addImage = (folder, buf) => addImageTo(folder, openTab(folder), buf);
|
||||
const removeImage = (folder, id) => removeImageFrom(folder, openTab(folder), id);
|
||||
|
||||
// A plan session on the person's turn.
|
||||
const PLAN_QUESTION = {
|
||||
items: [{ id: "q1", kind: "text", title: "What to call it", body: "A short name for the export." }],
|
||||
agent: { status: "waiting" },
|
||||
};
|
||||
|
||||
const input = (s) => s.page.locator("#notepad-editor .overtype-input");
|
||||
// The editor's editable surface (the locator pierces the shadow root).
|
||||
const input = (s) => s.page.locator("#notepad-editor .cm-content");
|
||||
|
||||
// The editor's whole text.
|
||||
const docText = (s) =>
|
||||
s.page.evaluate(async () => {
|
||||
const { EditorView } = await import("/vendor/codemirror.esm.js");
|
||||
const content = document.querySelector(".notepad-cm-host").shadowRoot.querySelector(".cm-content");
|
||||
return EditorView.findFromDOM(content).state.doc.toString();
|
||||
});
|
||||
|
||||
// Replaces the text the way typing does: through the editor, so autosave runs.
|
||||
const setDoc = (s, text) =>
|
||||
s.page.evaluate(async (t) => {
|
||||
const { EditorView } = await import("/vendor/codemirror.esm.js");
|
||||
const content = document.querySelector(".notepad-cm-host").shadowRoot.querySelector(".cm-content");
|
||||
const view = EditorView.findFromDOM(content);
|
||||
view.dispatch({ changes: { from: 0, to: view.state.doc.length, insert: t }, selection: { anchor: t.length } });
|
||||
}, text);
|
||||
|
||||
// Opens the notepad and, unless told the note cannot load, waits until it has:
|
||||
// the editor is read-only until then.
|
||||
async function openNotepad(s, { loads = true } = {}) {
|
||||
// the editor is read-only until then. A notepad with no tab gets Notes first,
|
||||
// unless `tabs: false`, since an empty one shows the empty state instead.
|
||||
async function openNotepad(s, { loads = true, tabs = true } = {}) {
|
||||
if (tabs && !listTabs(s.project).tabs.length) createTab(s.project, "Notes");
|
||||
await s.page.click("#btn-notepad");
|
||||
await s.page.locator("#notepad-modal[open]").waitFor();
|
||||
await input(s).waitFor();
|
||||
if (loads) await s.page.waitForFunction(() => !document.querySelector("#notepad-editor .overtype-input").readOnly);
|
||||
if (tabs) await input(s).waitFor();
|
||||
if (loads && tabs) {
|
||||
await s.page.waitForFunction(() => {
|
||||
const c = document.querySelector(".notepad-cm-host")?.shadowRoot?.querySelector(".cm-content");
|
||||
return Boolean(c) && c.getAttribute("aria-readonly") !== "true";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function closeNotepad(s) {
|
||||
@@ -55,19 +98,39 @@ async function closeNotepad(s) {
|
||||
// The editor's text once the page has read the note in: opening reads it from
|
||||
// the server, so the first value can still be the empty editor.
|
||||
async function shows(s, text) {
|
||||
await s.page.waitForFunction((want) => document.querySelector("#notepad-editor .overtype-input").value === want, text, { timeout: 5000 });
|
||||
return input(s).inputValue();
|
||||
await until(async () => (await docText(s)) === text, 5000);
|
||||
return docText(s);
|
||||
}
|
||||
|
||||
// The note on disk for the session's folder, as the store reads it.
|
||||
// Types as a person does, into the end of the text.
|
||||
async function typeInto(s, text) {
|
||||
await input(s).click();
|
||||
await s.page.keyboard.press("Control+End");
|
||||
await s.page.keyboard.type(text);
|
||||
}
|
||||
|
||||
// The note on disk for the session's folder (its last tab), as the store reads it.
|
||||
const onDisk = (s) => readNotepad(s.project).text;
|
||||
|
||||
// Records content-security violations from now on; the getter lists them.
|
||||
async function watchViolations(s) {
|
||||
await s.context.addInitScript(() => {
|
||||
window.__violations = [];
|
||||
document.addEventListener("securitypolicyviolation", (e) =>
|
||||
window.__violations.push(`${e.violatedDirective} ${e.blockedURI} ${e.sourceFile}:${e.lineNumber} ${e.sample}`),
|
||||
);
|
||||
});
|
||||
await s.page.reload({ waitUntil: "domcontentloaded" });
|
||||
await drawn(s.page);
|
||||
return () => s.page.evaluate(() => window.__violations);
|
||||
}
|
||||
|
||||
async function iconUsable(s, where) {
|
||||
const btn = s.page.locator("#btn-notepad");
|
||||
assert.ok(await btn.isVisible(), `the icon shows on ${where}`);
|
||||
assert.ok(await btn.isEnabled(), `the icon is usable on ${where}`);
|
||||
assert.equal(await btn.getAttribute("aria-label"), "Notepad");
|
||||
assert.equal(await btn.getAttribute("title"), "Notepad");
|
||||
assert.equal(await btn.getAttribute("aria-label"), "Notebook");
|
||||
assert.equal(await btn.getAttribute("title"), "Notebook");
|
||||
}
|
||||
|
||||
test("the notepad icon shows on the dashboard, a skill session and a finished screen", async (t) => {
|
||||
@@ -93,14 +156,19 @@ test("the notepad icon shows on the dashboard, a skill session and a finished sc
|
||||
test("typing Markdown styles it in place, saves within two seconds, and survives close, reload and a restart", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await openNotepad(s);
|
||||
assert.equal(await input(s).getAttribute("aria-label"), "Notepad text");
|
||||
await input(s).focus();
|
||||
await s.page.keyboard.type("# Shopping list\n\nSome **bold** text");
|
||||
assert.equal(await input(s).getAttribute("aria-label"), "Notebook text");
|
||||
await typeInto(s, "# Shopping list\n\nSome **bold** text");
|
||||
const typedAt = Date.now();
|
||||
// Styled in place: the preview layer under the textarea holds a heading.
|
||||
await s.page.locator("#notepad-editor .overtype-preview h1").waitFor();
|
||||
assert.match(await s.page.locator("#notepad-editor .overtype-preview h1").innerText(), /Shopping list/);
|
||||
assert.equal(await s.page.locator("#notepad-editor .overtype-preview strong").count(), 1);
|
||||
// Styled in place: the heading line is drawn large, the bold run bold.
|
||||
await s.page.locator("#notepad-editor .cm-h1").waitFor();
|
||||
assert.match(await s.page.locator("#notepad-editor .cm-h1").innerText(), /Shopping list/);
|
||||
const sizes = await s.page.evaluate(() => {
|
||||
const root = document.querySelector(".notepad-cm-host").shadowRoot;
|
||||
const px = (el) => parseFloat(getComputedStyle(el).fontSize);
|
||||
return { heading: px(root.querySelector(".cm-h1")), body: px(root.querySelector(".cm-content")) };
|
||||
});
|
||||
assert.ok(sizes.heading > sizes.body * 1.4, `the heading is larger than the text (${sizes.heading}px against ${sizes.body}px)`);
|
||||
assert.equal(await s.page.locator("#notepad-editor .cm-strong").count(), 1);
|
||||
|
||||
await until(() => onDisk(s) === "# Shopping list\n\nSome **bold** text", 4000);
|
||||
assert.ok(Date.now() - typedAt < 2000, `saved ${Date.now() - typedAt} ms after the last key`);
|
||||
@@ -135,11 +203,11 @@ test("two sessions in two folders keep two separate notepads", async (t) => {
|
||||
const a = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
const b = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await openNotepad(a);
|
||||
await input(a).fill("Folder A's note");
|
||||
await setDoc(a, "Folder A's note");
|
||||
await until(() => onDisk(a) === "Folder A's note", 4000);
|
||||
await openNotepad(b);
|
||||
assert.equal(await input(b).inputValue(), "", "the second folder starts empty");
|
||||
await input(b).fill("Folder B's note");
|
||||
assert.equal(await docText(b), "", "the second folder starts empty");
|
||||
await setDoc(b, "Folder B's note");
|
||||
await until(() => onDisk(b) === "Folder B's note", 4000);
|
||||
assert.equal(onDisk(a), "Folder A's note");
|
||||
// Reopening each shows its own.
|
||||
@@ -154,46 +222,42 @@ test("the editor breaks no content-security rule, and hostile Markdown runs noth
|
||||
s.page.on("console", (m) => {
|
||||
if (m.type() === "error") consoleErrors.push(m.text());
|
||||
});
|
||||
await s.context.addInitScript(() => {
|
||||
window.__violations = [];
|
||||
document.addEventListener("securitypolicyviolation", (e) =>
|
||||
window.__violations.push(`${e.violatedDirective} ${e.blockedURI} ${e.sourceFile}:${e.lineNumber} ${e.sample}`),
|
||||
);
|
||||
});
|
||||
await s.page.reload({ waitUntil: "domcontentloaded" });
|
||||
await drawn(s.page);
|
||||
const violations = await watchViolations(s);
|
||||
await openNotepad(s);
|
||||
await input(s).focus();
|
||||
await s.page.keyboard.type(
|
||||
await typeInto(
|
||||
s,
|
||||
"# Title\n\n- a list with `code` and [a link](https://example.com)\n> quoted\n\n" +
|
||||
'<img src=x onerror="window.__pwned = 1">\n<script>window.__pwned2 = 1</script>\n' +
|
||||
'<a href="javascript:window.__pwned3 = 1">click</a>\n',
|
||||
);
|
||||
await until(() => onDisk(s).includes("__pwned3"), 4000);
|
||||
await s.page.waitForTimeout(300);
|
||||
const result = await s.page.evaluate(() => ({
|
||||
violations: window.__violations,
|
||||
pwned: [window.__pwned, window.__pwned2, window.__pwned3],
|
||||
imgs: document.querySelectorAll("#notepad-editor .overtype-preview img").length,
|
||||
scripts: document.querySelectorAll("#notepad-editor script").length,
|
||||
styleTag: Boolean(document.querySelector("style.overtype-styles")),
|
||||
}));
|
||||
assert.deepEqual(result.violations, [], "no content-security violations with the notepad open");
|
||||
const result = await s.page.evaluate(() => {
|
||||
const root = document.querySelector(".notepad-cm-host").shadowRoot;
|
||||
return {
|
||||
pwned: [window.__pwned, window.__pwned2, window.__pwned3],
|
||||
// CodeMirror's own empty spacer images (aria-hidden) beside widgets are not typed HTML.
|
||||
imgs: root.querySelectorAll("img:not(.cm-widgetBuffer)").length,
|
||||
scripts: root.querySelectorAll("script").length,
|
||||
styleTags: root.querySelectorAll("style").length + document.querySelectorAll("style").length,
|
||||
};
|
||||
});
|
||||
assert.deepEqual(await violations(), [], "no content-security violations with the notepad open");
|
||||
assert.deepEqual(result.pwned, [undefined, undefined, undefined], "nothing typed ran");
|
||||
assert.equal(result.imgs, 0, "typed HTML stays text");
|
||||
assert.equal(result.scripts, 0);
|
||||
assert.equal(result.styleTag, false, "OverType injected no <style>");
|
||||
assert.equal(result.styleTags, 0, "the editor added no <style> element");
|
||||
assert.deepEqual(consoleErrors.filter((e) => /Content.Security.Policy|Refused to/i.test(e)), []);
|
||||
// The heading is styled from the stylesheet the page ships.
|
||||
const h1 = await s.page.locator("#notepad-editor .overtype-preview h1").evaluate((el) => getComputedStyle(el).fontWeight);
|
||||
const h1 = await s.page.locator("#notepad-editor .cm-h1").evaluate((el) => getComputedStyle(el).fontWeight);
|
||||
assert.ok(Number(h1) >= 600 || h1 === "bold", `the heading is bold (${h1})`);
|
||||
});
|
||||
|
||||
// The editor redraws only the lines that changed (patchPreview in
|
||||
// screens/notepad.js): about 90 ms a key at 200 KB on a quiet machine, against
|
||||
// about 310 ms when every key redrew the whole note. The bar is higher than
|
||||
// that because `npm test` runs every test file at once, which alone adds 50 ms
|
||||
// or more; it still catches a slide back toward whole-note redraws.
|
||||
// The editor redraws only the lines in view, so a key costs the same at 200 KB
|
||||
// as at 2 KB: about 25 ms on a quiet machine (OverType, which it replaced,
|
||||
// took about 95). The bar is higher than that because `npm test` runs every
|
||||
// test file at once, which alone adds 50 ms or more; it still catches a slide
|
||||
// back toward whole-note redraws.
|
||||
const KEY_BUDGET_MS = 200;
|
||||
|
||||
test("typing into a 200 KB note keeps input-to-paint under the key budget on average", async (t) => {
|
||||
@@ -201,7 +265,9 @@ test("typing into a 200 KB note keeps input-to-paint under the key budget on ave
|
||||
const block = "## Heading\n\nSome **bold** text with `code` and a [link](https://example.com).\n\n- an item\n- another\n\n";
|
||||
saveNote(s.project, block.repeat(Math.ceil((200 * 1024) / block.length)));
|
||||
await openNotepad(s);
|
||||
await s.page.waitForFunction(() => document.querySelector("#notepad-editor .overtype-input").value.length > 200000);
|
||||
await until(async () => (await docText(s)).length > 200000, 5000);
|
||||
await input(s).click();
|
||||
await s.page.keyboard.press("Control+End");
|
||||
await s.page.evaluate(() => {
|
||||
window.__lags = [];
|
||||
window.addEventListener(
|
||||
@@ -212,9 +278,6 @@ test("typing into a 200 KB note keeps input-to-paint under the key budget on ave
|
||||
},
|
||||
{ capture: true },
|
||||
);
|
||||
const ta = document.querySelector("#notepad-editor .overtype-input");
|
||||
ta.focus();
|
||||
ta.setSelectionRange(ta.value.length, ta.value.length);
|
||||
});
|
||||
// `npm test` runs every test file at once, and a round that lands in another
|
||||
// file's busiest moment measures the machine rather than the editor: the
|
||||
@@ -233,45 +296,11 @@ test("typing into a 200 KB note keeps input-to-paint under the key budget on ave
|
||||
assert.ok(best < KEY_BUDGET_MS, `average input-to-paint ${averages.map((a) => a.toFixed(1)).join(", ")} ms`);
|
||||
});
|
||||
|
||||
test("the textarea and the styled layer line up, line for line", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await openNotepad(s);
|
||||
await input(s).fill(
|
||||
"# A heading\n## A smaller one\nPlain text with **bold**, *em* and `code`.\n> a quote\n- a list item\n\n" +
|
||||
"A long line that wraps: " + "word ".repeat(80) + "\nThe last line",
|
||||
);
|
||||
const m = await s.page.evaluate(() => {
|
||||
const ta = document.querySelector("#notepad-editor .overtype-input");
|
||||
const pv = document.querySelector("#notepad-editor .overtype-preview");
|
||||
const cs = (el) => getComputedStyle(el);
|
||||
const lineHeight = parseFloat(cs(ta).lineHeight);
|
||||
const lines = [...pv.children];
|
||||
const top0 = lines[0].getBoundingClientRect().top;
|
||||
return {
|
||||
lineHeight,
|
||||
count: lines.length,
|
||||
offsets: lines.map((el) => (el.getBoundingClientRect().top - top0) / lineHeight),
|
||||
heights: [ta.scrollHeight, pv.scrollHeight],
|
||||
fonts: [ta, pv, pv.querySelector("h1"), pv.querySelector("h2"), pv.querySelector("strong"), pv.querySelector("code")].map(
|
||||
(el) => `${cs(el).fontFamily} ${cs(el).fontSize}`,
|
||||
),
|
||||
padding: [cs(ta).paddingTop, cs(pv).paddingTop, cs(ta).paddingLeft, cs(pv).paddingLeft],
|
||||
};
|
||||
});
|
||||
assert.equal(m.count, 8, "one preview line per text line");
|
||||
for (const [i, offset] of m.offsets.entries()) {
|
||||
assert.ok(Math.abs(offset - Math.round(offset)) < 0.05, `line ${i + 1} sits on the grid (${offset})`);
|
||||
}
|
||||
assert.ok(Math.abs(m.heights[0] - m.heights[1]) <= 1, `same height: ${m.heights.join(" vs ")}`);
|
||||
assert.equal(new Set(m.fonts).size, 1, `one font and size everywhere: ${[...new Set(m.fonts)].join(" | ")}`);
|
||||
assert.equal(m.padding[0], m.padding[1]);
|
||||
assert.equal(m.padding[2], m.padding[3]);
|
||||
});
|
||||
|
||||
test("the editor follows the console's light and dark themes", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await openNotepad(s);
|
||||
await input(s).fill("# Heading\n\nText");
|
||||
await setDoc(s, "# Heading\n\nText");
|
||||
await s.page.locator("#notepad-editor .cm-h1").waitFor();
|
||||
const colours = (theme) =>
|
||||
s.page.evaluate((th) => {
|
||||
document.documentElement.setAttribute("data-theme", th);
|
||||
@@ -284,16 +313,16 @@ test("the editor follows the console's light and dark themes", async (t) => {
|
||||
el.remove();
|
||||
return out;
|
||||
};
|
||||
const ta = document.querySelector("#notepad-editor .overtype-input");
|
||||
const pv = document.querySelector("#notepad-editor .overtype-preview");
|
||||
const shadow = document.querySelector(".notepad-cm-host").shadowRoot;
|
||||
const content = shadow.querySelector(".cm-content");
|
||||
return {
|
||||
ink: probe(root.getPropertyValue("--ink")),
|
||||
accent: probe(root.getPropertyValue("--accent")),
|
||||
panel: probe(root.getPropertyValue("--panel"), "backgroundColor"),
|
||||
text: getComputedStyle(pv).color,
|
||||
heading: getComputedStyle(pv.querySelector("h1")).color,
|
||||
caret: getComputedStyle(ta).caretColor,
|
||||
background: getComputedStyle(document.querySelector("#notepad-editor .overtype-wrapper")).backgroundColor,
|
||||
text: getComputedStyle(content).color,
|
||||
heading: getComputedStyle(shadow.querySelector(".cm-h1")).color,
|
||||
caret: getComputedStyle(content).caretColor,
|
||||
background: getComputedStyle(shadow.querySelector(".cm-editor")).backgroundColor,
|
||||
};
|
||||
}, theme);
|
||||
const light = await colours("light");
|
||||
@@ -308,84 +337,42 @@ test("the editor follows the console's light and dark themes", async (t) => {
|
||||
assert.notEqual(light.background, dark.background);
|
||||
});
|
||||
|
||||
test("after edits anywhere, the styled layer matches a full redraw", async (t) => {
|
||||
test("headings grow, bullets draw, and marks come back on the line the cursor is on", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
const block = "## Heading\n\nSome **bold** and a [link](https://example.com).\n\n- an item\n- another\n1. first\n2. second\n\n```js\nconst x = 1;\n```\n> quote\n";
|
||||
saveNote(s.project, block.repeat(40));
|
||||
saveNote(s.project, "# Big\n\n## Smaller\n\n- one\n- two\n\nplain\n");
|
||||
await openNotepad(s);
|
||||
await s.page.waitForFunction(() => document.querySelector("#notepad-editor .overtype-input").value.length > 1000);
|
||||
// The layer on the page against one drawn from scratch from the same text.
|
||||
const matches = () =>
|
||||
s.page.evaluate(async () => {
|
||||
const { withoutStyleAttrs } = await import("/notepad.js");
|
||||
const ta = document.querySelector("#notepad-editor .overtype-input");
|
||||
const pv = document.querySelector("#notepad-editor .overtype-preview");
|
||||
const parser = ta.closest(".overtype-wrapper")._instance.constructor.MarkdownParser;
|
||||
const fresh = document.createElement("div");
|
||||
fresh.className = "overtype-preview";
|
||||
// Parsed into an inert template, so nothing in it reaches the page.
|
||||
const tpl = document.createElement("template");
|
||||
tpl.innerHTML = withoutStyleAttrs(parser.parse(ta.value, -1, false, undefined, false));
|
||||
fresh.append(tpl.content);
|
||||
// OverType shades code fences in pairs, in order, after drawing
|
||||
// (_applyCodeBlockBackgrounds): the fresh copy gets the same, so a stale
|
||||
// mark left on the page shows as a difference.
|
||||
const fences = fresh.querySelectorAll(".code-fence");
|
||||
for (let i = 0; i < fences.length - 1; i += 2) {
|
||||
for (const f of [fences[i], fences[i + 1]]) {
|
||||
f.parentElement.classList.add("code-block-line");
|
||||
f.style.display = "block";
|
||||
}
|
||||
}
|
||||
// An emptied style or class attribute looks exactly like none.
|
||||
const plain = (html) => html.replace(/ (style|class)=""/g, "");
|
||||
return plain(pv.innerHTML) === plain(fresh.innerHTML);
|
||||
await until(async () => (await docText(s)).startsWith("# Big"), 5000);
|
||||
const lines = () =>
|
||||
s.page.evaluate(() => {
|
||||
const root = document.querySelector(".notepad-cm-host").shadowRoot;
|
||||
return [...root.querySelectorAll(".cm-line")].map((l) => ({ text: l.textContent, size: parseFloat(getComputedStyle(l).fontSize) }));
|
||||
});
|
||||
const at = (pos) =>
|
||||
s.page.evaluate((p) => {
|
||||
const ta = document.querySelector("#notepad-editor .overtype-input");
|
||||
const i = p < 0 ? ta.value.length + p : p;
|
||||
ta.focus();
|
||||
ta.setSelectionRange(i, i);
|
||||
}, pos);
|
||||
await at(0);
|
||||
await s.page.keyboard.type("# A new first line\n");
|
||||
assert.ok(await matches(), "typing at the top");
|
||||
await at(600);
|
||||
await s.page.keyboard.type("\n- a list item added in the middle\n[another link](https://example.org) ");
|
||||
assert.ok(await matches(), "typing in the middle, adding a link before others");
|
||||
await at(900);
|
||||
for (let i = 0; i < 30; i++) await s.page.keyboard.press("Backspace");
|
||||
assert.ok(await matches(), "deleting across lines");
|
||||
await at(-5);
|
||||
await s.page.keyboard.type("\n```\nopen fence at the end");
|
||||
assert.ok(await matches(), "an unclosed fence at the end");
|
||||
await s.page.keyboard.press("Control+a");
|
||||
await s.page.keyboard.press("Backspace");
|
||||
assert.ok(await matches(), "clearing it all");
|
||||
await s.page.keyboard.type("# Back again");
|
||||
assert.ok(await matches(), "typing into the empty note");
|
||||
// Four fences, two shaded blocks; deleting the first fence leaves three, and
|
||||
// the last one, kept from the drawing before, is no longer paired.
|
||||
// Ending on the last fence, so its line is the one kept unchanged.
|
||||
await s.page.keyboard.type("\n```\ncode\n```\ntext\n```\nmore\n```");
|
||||
assert.ok(await matches(), "two fenced blocks");
|
||||
const firstFence = await s.page.evaluate(() => document.querySelector("#notepad-editor .overtype-input").value.indexOf("```"));
|
||||
await at(firstFence + 4);
|
||||
for (let i = 0; i < 4; i++) await s.page.keyboard.press("Backspace");
|
||||
assert.ok(await matches(), "the first fence deleted, unpairing the last");
|
||||
// The cursor starts on line 1 (the "# Big" heading): its mark shows, the
|
||||
// second heading's does not.
|
||||
let seen = await lines();
|
||||
assert.equal(seen[0].text, "# Big");
|
||||
assert.equal(seen[2].text, "Smaller", "off the cursor line the mark is hidden");
|
||||
assert.ok(seen[0].size > seen[2].size && seen[2].size > seen[7].size, `heading sizes step down: ${seen.map((l) => l.size).join(", ")}`);
|
||||
assert.ok(seen[4].text.startsWith("•") || !seen[4].text.startsWith("-"), `a bullet is drawn, not a hyphen: "${seen[4].text}"`);
|
||||
// Click the second heading: its mark comes back.
|
||||
await s.page.locator("#notepad-editor .cm-h2").click();
|
||||
seen = await lines();
|
||||
assert.equal(seen[2].text, "## Smaller");
|
||||
assert.equal(seen[0].text, "Big");
|
||||
});
|
||||
|
||||
test("a note that cannot be read leaves the editor read-only, and nothing typed reaches the stored note", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
saveNote(s.project, "The real note");
|
||||
await s.page.route("**/notepad", (route) => (route.request().method() === "GET" ? route.abort() : route.continue()));
|
||||
await openNotepad(s, { loads: false });
|
||||
await s.page.click("#btn-notepad");
|
||||
await s.page.locator("#notepad-modal[open]").waitFor();
|
||||
await input(s).waitFor();
|
||||
await s.page.waitForFunction((want) => document.getElementById("notepad-status").textContent === want, NOT_LOADED);
|
||||
assert.equal(await input(s).evaluate((el) => el.readOnly), true);
|
||||
await input(s).focus();
|
||||
assert.equal(await input(s).getAttribute("aria-readonly"), "true");
|
||||
await input(s).click();
|
||||
await s.page.keyboard.type("typed into the empty editor");
|
||||
assert.equal(await input(s).inputValue(), "", "nothing could be typed");
|
||||
assert.equal(await docText(s), "", "nothing could be typed");
|
||||
await s.page.waitForTimeout(SAVE_DEBOUNCE_MS + 400);
|
||||
assert.equal(onDisk(s), "The real note");
|
||||
// Once it can be read, reopening loads it and the editor opens up.
|
||||
@@ -401,22 +388,445 @@ test("a note too long to save keeps its text when the notepad is closed and open
|
||||
await openNotepad(s);
|
||||
await shows(s, "Saved earlier");
|
||||
const long = "x".repeat(NOTE_MAX_BYTES) + " and some more";
|
||||
await input(s).fill(long);
|
||||
await setDoc(s, long);
|
||||
await s.page.waitForFunction(() => document.getElementById("notepad-status").textContent.startsWith("Too long to save"));
|
||||
await closeNotepad(s);
|
||||
await openNotepad(s);
|
||||
await s.page.waitForTimeout(300);
|
||||
assert.equal((await input(s).inputValue()).length, long.length, "the long text is still in the editor");
|
||||
assert.equal((await docText(s)).length, long.length, "the long text is still in the editor");
|
||||
assert.equal(onDisk(s), "Saved earlier", "and nothing over the cap was saved");
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------------ tabs */
|
||||
|
||||
const tabButtons = (s) => s.page.locator("#notepad-tabs .notepad-tab");
|
||||
const tabNamed = (s, name) => s.page.locator("#notepad-tabs .notepad-tab", { hasText: new RegExp(`^${name}$`) });
|
||||
const tabNames = (s) => tabButtons(s).evaluateAll((bs) => bs.map((b) => b.textContent));
|
||||
const selectedName = (s) => s.page.locator('#notepad-tabs .notepad-tab[aria-selected="true"]').evaluateAll((bs) => bs.map((b) => b.textContent));
|
||||
const status = (s) => s.page.locator("#notepad-status").textContent();
|
||||
const idOf = (s, name) => listTabs(s.project).tabs.find((tab) => tab.name === name)?.id;
|
||||
const nameError = (s) => s.page.locator("#notepad-name-error").textContent();
|
||||
|
||||
// Makes a tab through the page: the button, the name form, Enter.
|
||||
async function newTab(s, name, shown = name) {
|
||||
await s.page.click("#notepad-tab-new");
|
||||
await s.page.locator("#notepad-name-form:not([hidden])").waitFor();
|
||||
await s.page.fill("#notepad-name", name);
|
||||
await s.page.keyboard.press("Enter");
|
||||
await s.page.waitForFunction((n) => [...document.querySelectorAll("#notepad-tabs .notepad-tab")].some((b) => b.textContent === n && b.getAttribute("aria-selected") === "true"), shown);
|
||||
await s.page.waitForFunction(() => document.getElementById("notepad-name-form").hidden);
|
||||
}
|
||||
|
||||
// A notepad in its first shape: meta.json v1, note.md and images/ at the top.
|
||||
const U1 = "11111111-1111-4111-8111-111111111111";
|
||||
const U2 = "22222222-2222-4222-8222-222222222222";
|
||||
function legacyNotepad(folder, note) {
|
||||
const dir = notepadFolder(folder);
|
||||
fs.mkdirSync(path.join(dir, "images"), { recursive: true });
|
||||
fs.writeFileSync(path.join(dir, "meta.json"), JSON.stringify({ v: 1, folder: path.resolve(folder), created: "2026-01-01T00:00:00.000Z" }));
|
||||
fs.writeFileSync(path.join(dir, "note.md"), note);
|
||||
for (const id of [U1, U2]) fs.writeFileSync(path.join(dir, "images", id + ".jpg"), JPEG);
|
||||
fs.writeFileSync(path.join(dir, "images", U1 + ".thumb.jpg"), JPEG);
|
||||
return dir;
|
||||
}
|
||||
|
||||
test("an old notepad opens as one tab, Notes, with its text and pictures, and reading it writes nothing", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
const dir = legacyNotepad(s.project, "old note\n");
|
||||
const before = fs.readdirSync(dir).sort();
|
||||
await openNotepad(s, { tabs: false });
|
||||
await input(s).waitFor();
|
||||
await s.page.waitForFunction(() => document.querySelectorAll("#notepad-strip > li").length === 2);
|
||||
assert.deepEqual(await tabNames(s), ["Notes"]);
|
||||
assert.deepEqual(await selectedName(s), ["Notes"]);
|
||||
assert.equal(await shows(s, "old note\n"), "old note\n");
|
||||
assert.equal(await s.page.locator("#notepad-empty").isHidden(), true);
|
||||
assert.deepEqual(fs.readdirSync(dir).sort(), before, "opening it moved and wrote nothing");
|
||||
// The first edit moves it into the Notes tab.
|
||||
await typeInto(s, "more");
|
||||
await until(() => fs.existsSync(path.join(dir, "tabs.json")), 4000);
|
||||
await until(() => readNotepad(s.project, LEGACY_TAB_ID).text === "old note\nmore", 4000);
|
||||
assert.equal(fs.existsSync(path.join(dir, "note.md")), false, "the top-level note moved into the tab");
|
||||
assert.equal(readNotepad(s.project, LEGACY_TAB_ID).images.length, 2, "and so did the pictures");
|
||||
});
|
||||
|
||||
test("New tab asks for a name, refuses a bad or duplicate one, and Escape backs out", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
const violations = await watchViolations(s);
|
||||
await openNotepad(s);
|
||||
await s.page.click("#notepad-tab-new");
|
||||
await s.page.locator("#notepad-name-form:not([hidden])").waitFor();
|
||||
assert.equal(await s.page.locator("#notepad-name-label").textContent(), "Name this tab");
|
||||
assert.equal(await s.page.evaluate(() => document.activeElement.id), "notepad-name", "the field has the focus");
|
||||
assert.equal(await s.page.inputValue("#notepad-name"), "");
|
||||
|
||||
await s.page.keyboard.press("Enter");
|
||||
assert.equal(await nameError(s), "Give the tab a name.");
|
||||
await s.page.fill("#notepad-name", " ");
|
||||
await s.page.click("#notepad-name-save");
|
||||
assert.equal(await nameError(s), "Give the tab a name.");
|
||||
await s.page.fill("#notepad-name", "x".repeat(41));
|
||||
await s.page.keyboard.press("Enter");
|
||||
assert.match(await nameError(s), /40 characters or fewer/);
|
||||
await s.page.fill("#notepad-name", "nOtEs");
|
||||
await s.page.keyboard.press("Enter");
|
||||
assert.equal(await nameError(s), errorSentence("duplicate-name"));
|
||||
assert.deepEqual(await tabNames(s), ["Notes"], "nothing was made");
|
||||
assert.equal(listTabs(s.project).tabs.length, 1);
|
||||
|
||||
// Escape closes the form, not the Notebook, and gives the focus back.
|
||||
await s.page.keyboard.press("Escape");
|
||||
await s.page.waitForFunction(() => document.getElementById("notepad-name-form").hidden);
|
||||
assert.equal(await s.page.evaluate(() => document.getElementById("notepad-modal").open), true);
|
||||
assert.equal(await s.page.evaluate(() => document.activeElement.id), "notepad-tab-new");
|
||||
// Cancel does the same.
|
||||
await s.page.click("#notepad-tab-new");
|
||||
await s.page.click("#notepad-name-cancel");
|
||||
await s.page.waitForFunction(() => document.getElementById("notepad-name-form").hidden);
|
||||
|
||||
await newTab(s, " Big ideas ", "Big ideas");
|
||||
assert.deepEqual(await tabNames(s), ["Notes", "Big ideas"]);
|
||||
assert.deepEqual(await selectedName(s), ["Big ideas"]);
|
||||
assert.equal(await docText(s), "", "the new tab starts empty");
|
||||
assert.equal(await input(s).getAttribute("aria-readonly"), null, "and can be typed in");
|
||||
assert.deepEqual(listTabs(s.project).tabs.map((tab) => tab.name), ["Notes", "Big ideas"]);
|
||||
assert.deepEqual(await violations(), []);
|
||||
});
|
||||
|
||||
test("each tab keeps its own text and pictures, and switching never saves into the wrong tab", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
const violations = await watchViolations(s);
|
||||
await openNotepad(s);
|
||||
await typeInto(s, "notes text");
|
||||
await newTab(s, "Ideas");
|
||||
const notes = idOf(s, "Notes");
|
||||
const ideas = idOf(s, "Ideas");
|
||||
await until(() => readNotepad(s.project, notes).text === "notes text", 4000);
|
||||
await typeInto(s, "ideas text");
|
||||
// Switch at once, before the debounce: the text still goes to Ideas.
|
||||
await tabNamed(s, "Notes").click();
|
||||
assert.equal(await shows(s, "notes text"), "notes text");
|
||||
assert.equal(readNotepad(s.project, ideas).text, "ideas text", "typed just before the switch, saved into its own tab");
|
||||
assert.equal(readNotepad(s.project, notes).text, "notes text", "and not into the other");
|
||||
|
||||
await typeInto(s, " (edited)");
|
||||
await tabNamed(s, "Ideas").click();
|
||||
assert.equal(await shows(s, "ideas text"), "ideas text");
|
||||
assert.equal(readNotepad(s.project, notes).text, "notes text (edited)");
|
||||
assert.equal(await selectedName(s).then((n) => n.join()), "Ideas");
|
||||
|
||||
// A picture added to Ideas is not in Notes.
|
||||
const png = await s.page.evaluate(async () => {
|
||||
const c = document.createElement("canvas");
|
||||
c.width = c.height = 40;
|
||||
c.getContext("2d").fillRect(0, 0, 40, 40);
|
||||
const blob = await new Promise((r) => c.toBlob(r, "image/png"));
|
||||
let bin = "";
|
||||
for (const b of new Uint8Array(await blob.arrayBuffer())) bin += String.fromCharCode(b);
|
||||
return btoa(bin);
|
||||
});
|
||||
await s.page.setInputFiles("#notepad-file", { name: "p.png", mimeType: "image/png", buffer: Buffer.from(png, "base64") });
|
||||
await until(() => readNotepad(s.project, ideas).images.length === 1, 5000);
|
||||
await s.page.waitForFunction(() => document.querySelectorAll("#notepad-strip > li.is-ready").length === 1);
|
||||
assert.equal(readNotepad(s.project, notes).images.length, 0);
|
||||
await tabNamed(s, "Notes").click();
|
||||
await s.page.waitForFunction(() => document.querySelectorAll("#notepad-strip > li").length === 0);
|
||||
await tabNamed(s, "Ideas").click();
|
||||
await s.page.waitForFunction(() => document.querySelectorAll("#notepad-strip > li.is-ready").length === 1);
|
||||
const src = await s.page.locator("#notepad-strip img").getAttribute("src");
|
||||
assert.match(src, new RegExp(`^/notepad/images/${ideas}/`), "the picture's address names its tab");
|
||||
|
||||
// A save that cannot reach the server keeps you on the tab, with why.
|
||||
await s.page.route("**/notepad/text*", (route) => route.abort());
|
||||
await typeInto(s, " unsaved");
|
||||
await tabNamed(s, "Notes").click();
|
||||
await s.page.waitForFunction((want) => document.getElementById("notepad-status").textContent.includes(want), "Not saved yet, so staying on this tab.");
|
||||
assert.deepEqual(await selectedName(s), ["Ideas"], "still on the tab with the unsaved text");
|
||||
assert.equal(await docText(s), "ideas text unsaved");
|
||||
await s.page.unroute("**/notepad/text*");
|
||||
await until(() => readNotepad(s.project, ideas).text === "ideas text unsaved", 40000);
|
||||
await tabNamed(s, "Notes").click();
|
||||
assert.equal(await shows(s, "notes text (edited)"), "notes text (edited)");
|
||||
|
||||
// The last tab is remembered across a reload.
|
||||
await tabNamed(s, "Ideas").click();
|
||||
await until(() => listTabs(s.project).last === ideas, 4000);
|
||||
await s.page.reload({ waitUntil: "domcontentloaded" });
|
||||
await drawn(s.page);
|
||||
await openNotepad(s);
|
||||
assert.deepEqual(await selectedName(s), ["Ideas"]);
|
||||
assert.equal(await shows(s, "ideas text unsaved"), "ideas text unsaved");
|
||||
assert.deepEqual(await violations(), []);
|
||||
});
|
||||
|
||||
test("Rename opens the same form with the name selected; F2 and double-click work too", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await openNotepad(s);
|
||||
await newTab(s, "Ideas");
|
||||
const ideas = idOf(s, "Ideas");
|
||||
|
||||
await s.page.click("#notepad-tab-rename");
|
||||
await s.page.locator("#notepad-name-form:not([hidden])").waitFor();
|
||||
assert.equal(await s.page.locator("#notepad-name-label").textContent(), "Rename this tab");
|
||||
assert.equal(await s.page.inputValue("#notepad-name"), "Ideas");
|
||||
assert.equal(await s.page.evaluate(() => document.getElementById("notepad-name").selectionEnd - document.getElementById("notepad-name").selectionStart), 5, "the name is selected");
|
||||
// Its own name is not a duplicate; another tab's is.
|
||||
await s.page.keyboard.press("Enter");
|
||||
await s.page.waitForFunction(() => document.getElementById("notepad-name-form").hidden);
|
||||
await s.page.click("#notepad-tab-rename");
|
||||
await s.page.fill("#notepad-name", "notes");
|
||||
await s.page.keyboard.press("Enter");
|
||||
assert.equal(await nameError(s), errorSentence("duplicate-name"));
|
||||
await s.page.fill("#notepad-name", "Plans");
|
||||
await s.page.keyboard.press("Enter");
|
||||
await s.page.waitForFunction(() => document.getElementById("notepad-name-form").hidden);
|
||||
assert.deepEqual(await tabNames(s), ["Notes", "Plans"]);
|
||||
assert.equal(listTabs(s.project).tabs.find((tab) => tab.id === ideas).name, "Plans");
|
||||
assert.equal(await s.page.evaluate(() => document.activeElement.textContent), "Plans", "the focus is back on the tab");
|
||||
|
||||
// F2 on a focused tab, and a double-click.
|
||||
await tabNamed(s, "Plans").focus();
|
||||
await s.page.keyboard.press("F2");
|
||||
await s.page.locator("#notepad-name-form:not([hidden])").waitFor();
|
||||
assert.equal(await s.page.inputValue("#notepad-name"), "Plans");
|
||||
await s.page.keyboard.press("Escape");
|
||||
await tabNamed(s, "Notes").dblclick();
|
||||
await s.page.locator("#notepad-name-form:not([hidden])").waitFor();
|
||||
assert.equal(await s.page.inputValue("#notepad-name"), "Notes");
|
||||
assert.deepEqual(await selectedName(s), ["Notes"], "double-click picked the tab it renames");
|
||||
});
|
||||
|
||||
// A drag the way the browser sends one: the events, in order, with one shared
|
||||
// DataTransfer, so the page's handlers see what a person's drag would.
|
||||
const drag = (s, from, to, { kind = "tab" } = {}) =>
|
||||
s.page.evaluate(
|
||||
({ from, to, kind }) => {
|
||||
const tabs = [...document.querySelectorAll("#notepad-tabs .notepad-tab")];
|
||||
const source = tabs.find((b) => b.textContent === from);
|
||||
const target = tabs.find((b) => b.textContent === to);
|
||||
const dt = new DataTransfer();
|
||||
if (kind === "text") dt.setData("text/plain", "dragged text");
|
||||
const fire = (el, type) => el.dispatchEvent(new DragEvent(type, { dataTransfer: dt, bubbles: true, cancelable: true }));
|
||||
if (kind === "tab") fire(source, "dragstart");
|
||||
fire(target, "dragover");
|
||||
const marked = target.classList.contains("is-drop-before");
|
||||
fire(target, "drop");
|
||||
if (kind === "tab") fire(source, "dragend");
|
||||
return marked;
|
||||
},
|
||||
{ from, to, kind },
|
||||
);
|
||||
|
||||
test("tabs reorder by drag and by keyboard, and the order is kept", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await openNotepad(s);
|
||||
for (const name of ["Ideas", "Plans", "Done"]) await newTab(s, name);
|
||||
assert.deepEqual(await tabNames(s), ["Notes", "Ideas", "Plans", "Done"]);
|
||||
const order = () => listTabs(s.project).tabs.map((tab) => tab.name);
|
||||
|
||||
// Keyboard: Alt+Left and Alt+Right on a focused tab, focus stays on it.
|
||||
await tabNamed(s, "Done").focus();
|
||||
await s.page.keyboard.press("Alt+ArrowLeft");
|
||||
await until(() => order().join() === "Notes,Ideas,Done,Plans", 4000);
|
||||
assert.deepEqual(await tabNames(s), ["Notes", "Ideas", "Done", "Plans"]);
|
||||
assert.equal(await s.page.evaluate(() => document.activeElement.textContent), "Done");
|
||||
assert.equal(await status(s), "Moved Done to position 3 of 4", "the move is announced");
|
||||
await s.page.keyboard.press("Alt+ArrowLeft");
|
||||
await s.page.keyboard.press("Alt+ArrowLeft");
|
||||
await s.page.keyboard.press("Alt+ArrowLeft");
|
||||
await until(() => order().join() === "Done,Notes,Ideas,Plans", 4000);
|
||||
assert.equal(await status(s), "Moved Done to position 1 of 4", "and it stops at the first place");
|
||||
// Plain arrows move the focus without moving the tab.
|
||||
await s.page.keyboard.press("ArrowRight");
|
||||
assert.equal(await s.page.evaluate(() => document.activeElement.textContent), "Notes");
|
||||
assert.equal(order().join(), "Done,Notes,Ideas,Plans");
|
||||
|
||||
// The visible buttons act on the current tab.
|
||||
await tabNamed(s, "Plans").click();
|
||||
await s.page.click("#notepad-tab-left");
|
||||
await until(() => order().join() === "Done,Notes,Plans,Ideas", 4000);
|
||||
await s.page.click("#notepad-tab-right");
|
||||
await until(() => order().join() === "Done,Notes,Ideas,Plans", 4000);
|
||||
assert.equal(await s.page.locator("#notepad-tab-right").isDisabled(), true, "the last tab cannot move right");
|
||||
|
||||
// Drag: the target shows a mark, the dragged tab lands just before it.
|
||||
assert.equal(await drag(s, "Plans", "Done"), true, "the target is marked while dragged over");
|
||||
await until(() => order().join() === "Plans,Done,Notes,Ideas", 4000);
|
||||
assert.deepEqual(await tabNames(s), ["Plans", "Done", "Notes", "Ideas"]);
|
||||
assert.equal(await s.page.locator("#notepad-tabs .is-drop-before").count(), 0, "the mark is gone after the drop");
|
||||
|
||||
// Text dragged over a tab does nothing.
|
||||
const posted = [];
|
||||
s.page.on("request", (r) => r.url().includes("/notepad/tab/order") && posted.push(r.url()));
|
||||
assert.equal(await drag(s, "Plans", "Ideas", { kind: "text" }), false);
|
||||
await s.page.waitForTimeout(300);
|
||||
assert.equal(order().join(), "Plans,Done,Notes,Ideas");
|
||||
assert.equal(posted.length, 0);
|
||||
|
||||
// Reopened, the order stands.
|
||||
await s.page.reload({ waitUntil: "domcontentloaded" });
|
||||
await drawn(s.page);
|
||||
await openNotepad(s);
|
||||
assert.deepEqual(await tabNames(s), ["Plans", "Done", "Notes", "Ideas"]);
|
||||
});
|
||||
|
||||
test("Delete asks twice, Escape backs out of either, and only the second confirm removes the tab and its folder", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
const violations = await watchViolations(s);
|
||||
await openNotepad(s);
|
||||
await typeInto(s, "keep me");
|
||||
await newTab(s, "Ideas");
|
||||
await typeInto(s, "doomed text");
|
||||
const ideas = idOf(s, "Ideas");
|
||||
const folder = path.join(notepadFolder(s.project), "tabs", ideas);
|
||||
await until(() => readNotepad(s.project, ideas).text === "doomed text", 4000);
|
||||
addImageTo(s.project, ideas, JPEG);
|
||||
addImageTo(s.project, ideas, JPEG);
|
||||
await tabNamed(s, "Notes").click();
|
||||
await tabNamed(s, "Ideas").click();
|
||||
await s.page.waitForFunction(() => document.querySelectorAll("#notepad-strip > li").length === 2);
|
||||
|
||||
const panel = s.page.locator("#notepad-delete");
|
||||
const text = () => s.page.locator("#notepad-delete-text").textContent();
|
||||
await s.page.click("#notepad-tab-delete");
|
||||
await panel.waitFor({ state: "visible" });
|
||||
assert.equal(await text(), "This deletes the tab Ideas, its text and its 2 pictures. This cannot be undone.");
|
||||
assert.equal(await s.page.evaluate(() => document.activeElement.textContent), "Keep tab", "Keep tab has the focus");
|
||||
assert.equal(await s.page.locator("#notepad-delete-go").textContent(), "Delete tab…");
|
||||
// Keep tab: nothing happens.
|
||||
await s.page.click("#notepad-delete-keep");
|
||||
await panel.waitFor({ state: "hidden" });
|
||||
assert.equal(fs.existsSync(folder), true);
|
||||
assert.equal(await s.page.evaluate(() => document.activeElement.textContent), "Ideas");
|
||||
|
||||
// Step one then Escape: nothing deleted, and the Notebook stays open.
|
||||
await s.page.click("#notepad-tab-delete");
|
||||
await s.page.click("#notepad-delete-go");
|
||||
assert.equal(await text(), "Really delete Ideas for good?");
|
||||
assert.equal(await s.page.locator("#notepad-delete-go").textContent(), "Yes, delete it");
|
||||
assert.equal(await s.page.evaluate(() => document.activeElement.textContent), "Keep tab", "Keep tab has the focus on the second step too");
|
||||
await s.page.keyboard.press("Escape");
|
||||
await panel.waitFor({ state: "hidden" });
|
||||
assert.equal(await s.page.evaluate(() => document.getElementById("notepad-modal").open), true);
|
||||
assert.equal(fs.existsSync(folder), true);
|
||||
// Escape at the first step too.
|
||||
await s.page.click("#notepad-tab-delete");
|
||||
await s.page.keyboard.press("Escape");
|
||||
await panel.waitFor({ state: "hidden" });
|
||||
assert.equal(fs.existsSync(folder), true);
|
||||
|
||||
// Both confirms: gone, with its folder, and the neighbour is shown.
|
||||
await s.page.click("#notepad-tab-delete");
|
||||
await s.page.click("#notepad-delete-go");
|
||||
await s.page.click("#notepad-delete-go");
|
||||
await until(() => !fs.existsSync(folder), 4000);
|
||||
await s.page.waitForFunction(() => document.querySelectorAll("#notepad-tabs .notepad-tab").length === 1);
|
||||
assert.deepEqual(await selectedName(s), ["Notes"]);
|
||||
assert.equal(await shows(s, "keep me"), "keep me");
|
||||
assert.equal(listTabs(s.project).last, idOf(s, "Notes"), "the neighbour became the last tab");
|
||||
|
||||
// Delete the last tab: the empty state, with the focus on its button.
|
||||
await s.page.click("#notepad-tab-delete");
|
||||
await s.page.click("#notepad-delete-go");
|
||||
await s.page.click("#notepad-delete-go");
|
||||
await s.page.locator("#notepad-empty").waitFor({ state: "visible" });
|
||||
assert.equal(await s.page.locator("#notepad-body").isHidden(), true, "the editor and pictures are hidden");
|
||||
assert.equal(await s.page.locator("#notepad-empty").innerText().then((x) => x.startsWith("No tabs yet. Make one to start writing.")), true);
|
||||
assert.equal(await s.page.evaluate(() => document.activeElement.id), "notepad-empty-new");
|
||||
assert.equal(listTabs(s.project).tabs.length, 0);
|
||||
// Reopened, still empty; a new tab from the empty state works.
|
||||
await closeNotepad(s);
|
||||
await openNotepad(s, { tabs: false });
|
||||
await s.page.locator("#notepad-empty").waitFor({ state: "visible" });
|
||||
await s.page.click("#notepad-empty-new");
|
||||
await s.page.fill("#notepad-name", "Fresh");
|
||||
await s.page.keyboard.press("Enter");
|
||||
await s.page.locator("#notepad-body").waitFor({ state: "visible" });
|
||||
assert.deepEqual(await tabNames(s), ["Fresh"]);
|
||||
assert.deepEqual(await violations(), []);
|
||||
});
|
||||
|
||||
test("text typed into a tab that is then deleted is never saved, and a tab deleted elsewhere leaves the bar with why", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await openNotepad(s);
|
||||
await newTab(s, "Ideas");
|
||||
const ideas = idOf(s, "Ideas");
|
||||
const saves = [];
|
||||
s.page.on("request", (r) => r.url().includes("/notepad/text") && saves.push(r.url()));
|
||||
await typeInto(s, "typed then deleted");
|
||||
await s.page.click("#notepad-tab-delete");
|
||||
await s.page.click("#notepad-delete-go");
|
||||
await s.page.click("#notepad-delete-go");
|
||||
await s.page.waitForFunction(() => document.querySelectorAll("#notepad-tabs .notepad-tab").length === 1);
|
||||
await s.page.waitForTimeout(SAVE_DEBOUNCE_MS + 500);
|
||||
assert.equal(saves.filter((u) => u.includes("tab=" + ideas)).length, 0, "no save was sent for the deleted tab");
|
||||
assert.equal(fs.existsSync(path.join(notepadFolder(s.project), "tabs", ideas)), false);
|
||||
|
||||
// Deleted from another page: picking it says so and shows what is left.
|
||||
await newTab(s, "Elsewhere");
|
||||
const elsewhere = idOf(s, "Elsewhere");
|
||||
await tabNamed(s, "Notes").click();
|
||||
deleteTab(s.project, elsewhere);
|
||||
await tabNamed(s, "Elsewhere").click();
|
||||
await s.page.waitForFunction((want) => document.getElementById("notepad-status").textContent.includes(want), errorSentence("no-such-tab"));
|
||||
assert.deepEqual(await tabNames(s), ["Notes"]);
|
||||
});
|
||||
|
||||
test("a name form or delete question open on one tab closes when another tab is picked", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await openNotepad(s);
|
||||
await newTab(s, "Ideas");
|
||||
const notes = idOf(s, "Notes");
|
||||
|
||||
// Rename opened on Ideas, then Notes picked: the form goes, and Notes keeps its name.
|
||||
await s.page.click("#notepad-tab-rename");
|
||||
await s.page.locator("#notepad-name-form:not([hidden])").waitFor();
|
||||
await tabNamed(s, "Notes").click();
|
||||
await s.page.waitForFunction(() => document.getElementById("notepad-name-form").hidden);
|
||||
await until(async () => (await selectedName(s)).join() === "Notes", 4000);
|
||||
assert.equal(listTabs(s.project).tabs.find((tab) => tab.id === notes).name, "Notes");
|
||||
|
||||
// Delete opened (and moved on to its second step) on Notes, then Ideas picked: the question goes.
|
||||
await s.page.click("#notepad-tab-delete");
|
||||
await s.page.click("#notepad-delete-go");
|
||||
assert.equal(await s.page.locator("#notepad-delete-text").textContent(), "Really delete Notes for good?");
|
||||
await tabNamed(s, "Ideas").click();
|
||||
await s.page.locator("#notepad-delete").waitFor({ state: "hidden" });
|
||||
await until(async () => (await selectedName(s)).join() === "Ideas", 4000);
|
||||
assert.deepEqual(await tabNames(s), ["Notes", "Ideas"], "nothing was deleted");
|
||||
// Asking again starts at the first step, naming the tab now open.
|
||||
await s.page.click("#notepad-tab-delete");
|
||||
assert.match(await s.page.locator("#notepad-delete-text").textContent(), /^This deletes the tab Ideas,/);
|
||||
});
|
||||
|
||||
test("when the tab after a delete cannot be loaded, the deleted text is not left on screen", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await openNotepad(s);
|
||||
await typeInto(s, "notes text");
|
||||
await newTab(s, "Ideas");
|
||||
await typeInto(s, "doomed text");
|
||||
const ideas = idOf(s, "Ideas");
|
||||
await until(() => readNotepad(s.project, ideas).text === "doomed text", 4000);
|
||||
// The neighbour's read fails, as if the connection dropped right after the delete.
|
||||
await s.page.route("**/notepad?tab=*", (route) => route.abort());
|
||||
await s.page.click("#notepad-tab-delete");
|
||||
await s.page.click("#notepad-delete-go");
|
||||
await s.page.click("#notepad-delete-go");
|
||||
await s.page.waitForFunction(() => document.querySelectorAll("#notepad-tabs .notepad-tab").length === 1);
|
||||
await s.page.waitForFunction(() => document.getElementById("notepad-status").textContent.length > 0);
|
||||
assert.equal(await docText(s), "", "the deleted tab's text is gone from the editor");
|
||||
assert.equal(await input(s).getAttribute("aria-readonly"), "true", "and the editor does not take typing it would never save");
|
||||
await s.page.unroute("**/notepad?tab=*");
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------ pictures */
|
||||
|
||||
|
||||
// The stored pictures for the session's folder, and whether each of a
|
||||
// picture's two files is on disk.
|
||||
const stored = (s) => readNotepad(s.project).images;
|
||||
const filesOf = (s, id) => {
|
||||
const dir = path.join(notepadFolder(s.project), "images");
|
||||
const dir = path.join(notepadFolder(s.project), "tabs", openTab(s.project), "images");
|
||||
return [fs.existsSync(path.join(dir, id + ".jpg")), fs.existsSync(path.join(dir, id + ".thumb.jpg"))];
|
||||
};
|
||||
|
||||
@@ -464,11 +874,11 @@ const sendPicture = (s, kind, colour) =>
|
||||
const blob = await new Promise((resolve) => c.toBlob(resolve, "image/png"));
|
||||
const dt = new DataTransfer();
|
||||
dt.items.add(new File([blob], "pasted.png", { type: "image/png" }));
|
||||
const ta = document.querySelector("#notepad-editor .overtype-input");
|
||||
if (kind === "paste") return !ta.dispatchEvent(new ClipboardEvent("paste", { clipboardData: dt, bubbles: true, cancelable: true }));
|
||||
ta.dispatchEvent(new DragEvent("dragover", { dataTransfer: dt, bubbles: true, cancelable: true }));
|
||||
const ta = document.querySelector(".notepad-cm-host").shadowRoot.querySelector(".cm-content");
|
||||
if (kind === "paste") return !ta.dispatchEvent(new ClipboardEvent("paste", { clipboardData: dt, bubbles: true, cancelable: true, composed: true }));
|
||||
ta.dispatchEvent(new DragEvent("dragover", { dataTransfer: dt, bubbles: true, cancelable: true, composed: true }));
|
||||
const lit = document.getElementById("notepad-modal").classList.contains("is-drop");
|
||||
ta.dispatchEvent(new DragEvent("drop", { dataTransfer: dt, bubbles: true, cancelable: true }));
|
||||
ta.dispatchEvent(new DragEvent("drop", { dataTransfer: dt, bubbles: true, cancelable: true, composed: true }));
|
||||
return lit;
|
||||
},
|
||||
{ kind, fill: colour },
|
||||
@@ -488,10 +898,10 @@ test("Add image, paste and drop each add a thumbnail whose files are on disk and
|
||||
await until(() => stored(s).length === 3 && filesOf(s, stored(s)[2].id).every(Boolean), 5000);
|
||||
await readyCount(s, 3);
|
||||
assert.equal(await s.page.locator("#notepad-modal.is-drop").count(), 0, "the highlight is gone after the drop");
|
||||
assert.equal(await input(s).inputValue(), "", "no picture landed in the text");
|
||||
assert.equal(await docText(s), "", "no picture landed in the text");
|
||||
|
||||
const alts = await s.page.locator("#notepad-strip img").evaluateAll((imgs) => imgs.map((i) => i.alt));
|
||||
assert.deepEqual(alts, ["Notepad image 1", "Notepad image 2", "Notepad image 3"]);
|
||||
assert.deepEqual(alts, ["Notebook image 1", "Notebook image 2", "Notebook image 3"]);
|
||||
const xs = await s.page.locator("#notepad-strip .notepad-thumb-delete").evaluateAll((b) => b.map((x) => x.getAttribute("aria-label")));
|
||||
assert.deepEqual(xs, ["Delete image 1", "Delete image 2", "Delete image 3"]);
|
||||
|
||||
@@ -506,7 +916,7 @@ test("Add image, paste and drop each add a thumbnail whose files are on disk and
|
||||
return imgs.length === 3 && imgs.every((i) => new URL(i.src).pathname.startsWith("/notepad/images/"));
|
||||
});
|
||||
const srcs = await s.page.locator("#notepad-strip img").evaluateAll((imgs) => imgs.map((i) => new URL(i.src).pathname));
|
||||
assert.deepEqual(srcs, ids.map((id) => `/notepad/images/${id}.thumb.jpg`));
|
||||
assert.deepEqual(srcs, ids.map((id) => `/notepad/images/${openTab(s.project)}/${id}.thumb.jpg`));
|
||||
await s.page.waitForFunction(() => [...document.querySelectorAll("#notepad-strip img")].every((i) => i.complete && i.naturalWidth > 0));
|
||||
});
|
||||
|
||||
@@ -515,7 +925,7 @@ test("a pasted text snippet still lands in the editor", async (t) => {
|
||||
await s.context.grantPermissions(["clipboard-read", "clipboard-write"], { origin: new URL(s.url).origin });
|
||||
await openNotepad(s);
|
||||
await s.page.evaluate(() => navigator.clipboard.writeText("a pasted snippet"));
|
||||
await input(s).focus();
|
||||
await input(s).click();
|
||||
await s.page.keyboard.press("Control+V");
|
||||
await shows(s, "a pasted snippet");
|
||||
await until(() => onDisk(s) === "a pasted snippet", 4000);
|
||||
@@ -546,10 +956,10 @@ test("the X asks first: Keep keeps the picture, Delete removes both its files",
|
||||
await until(() => !filesOf(s, first).some(Boolean), 4000);
|
||||
await s.page.waitForFunction(() => document.querySelectorAll("#notepad-strip > li").length === 1);
|
||||
assert.deepEqual(stored(s).map((img) => img.id), [second]);
|
||||
assert.equal(await s.page.locator("#notepad-strip img").getAttribute("alt"), "Notepad image 1");
|
||||
assert.equal(await s.page.locator("#notepad-strip img").getAttribute("alt"), "Notebook image 1");
|
||||
});
|
||||
|
||||
test("the preview opens at the clicked picture, steps and wraps, and Esc closes it before the Notepad", async (t) => {
|
||||
test("the preview opens at the clicked picture, steps and wraps, and Esc closes it before the Notebook", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await openNotepad(s);
|
||||
for (const colour of ["#c33", "#3c3", "#33c"]) await addViaButton(s, colour);
|
||||
@@ -580,7 +990,7 @@ test("the preview opens at the clicked picture, steps and wraps, and Esc closes
|
||||
|
||||
await s.page.keyboard.press("Escape");
|
||||
await s.page.waitForFunction(() => !document.getElementById("notepad-preview").open);
|
||||
assert.equal(await s.page.evaluate(() => document.getElementById("notepad-modal").open), true, "the Notepad stays open");
|
||||
assert.equal(await s.page.evaluate(() => document.getElementById("notepad-modal").open), true, "the Notebook stays open");
|
||||
assert.equal(
|
||||
await s.page.evaluate(() => document.activeElement.closest("li") === document.querySelector("#notepad-strip li:nth-child(2)")),
|
||||
true,
|
||||
@@ -693,11 +1103,11 @@ test("User Preferences, Cleanup offers a month-old notepad by its folder and rem
|
||||
await s.page.click("#btn-looks");
|
||||
await s.page.click("#cleanup-scan");
|
||||
const list = s.page.locator("#cleanup-list");
|
||||
const row = list.locator(".cleanup-row").filter({ hasText: "Notepad for" });
|
||||
const row = list.locator(".cleanup-row").filter({ hasText: "Notebook for" });
|
||||
await row.waitFor();
|
||||
assert.equal(await row.count(), 1, "one item for the whole notepad");
|
||||
assert.equal((await row.locator("span").first().innerText()).trim(), "Notepad for " + path.resolve(s.project));
|
||||
assert.ok((await list.locator(".cleanup-summary").innerText()).includes("1 old notepad"), "the summary counts it as a notepad");
|
||||
assert.equal((await row.locator("span").first().innerText()).trim(), "Notebook for " + path.resolve(s.project));
|
||||
assert.ok((await list.locator(".cleanup-summary").innerText()).includes("1 old notebook"), "the summary counts it as a notepad");
|
||||
assert.equal(await list.locator(".cleanup-row").filter({ hasText: "notepads/" }).count(), 0, "the notepads folder is no stray");
|
||||
assert.equal(fs.existsSync(notepadFolder(s.project)), true, "a scan only looks");
|
||||
|
||||
@@ -746,9 +1156,9 @@ test("Help's Getting around panel describes the notepad", async (t) => {
|
||||
await s.page.locator("#help-modal").waitFor();
|
||||
await s.page.click("#help-tab-around");
|
||||
const panel = s.page.locator("#help-panel-around");
|
||||
await panel.getByRole("heading", { name: "Your notepad" }).waitFor();
|
||||
await panel.getByRole("heading", { name: "Your notebook" }).waitFor();
|
||||
const text = await panel.innerText();
|
||||
for (const words of ["Notepad", "never sent to Plan2Code", "last save wins", "Cleanup"]) {
|
||||
for (const words of ["Notebook", "never sent to Plan2Code", "last save wins", "Cleanup"]) {
|
||||
assert.ok(text.includes(words), `the panel mentions ${words}`);
|
||||
}
|
||||
});
|
||||
@@ -186,7 +186,8 @@ test("shape: no page module sets a style attribute from script", () => {
|
||||
const ROUTE_ORDER = [
|
||||
"/health", "/s/", "/", "SERVABLE", "/overview", "/handoff", "/version", "/state", "/events", "/draft",
|
||||
"/looks", "/looks", "/subagents", "/pr-host", "/models", "/models", "/cleanup", "/upload",
|
||||
"/notepad", "/notepad/text", "/notepad/image", "/notepad/thumb", "/notepad/image/delete", "/notepad/images/",
|
||||
"/notepad", "/notepad/text", "/notepad/image", "/notepad/thumb", "/notepad/image/delete", "/notepad/tab",
|
||||
"/notepad/tab/rename", "/notepad/tab/delete", "/notepad/tab/order", "/notepad/tab/last", "/notepad/images/",
|
||||
"/attachments/", "/shots/", "/uploads/", "/submit", "/chat", "/chat/decision", "/workspace",
|
||||
"WORKSPACE_EDITS", "/workspace/scope", "/workspace/browse", "/cancel", "/ping", "/bye",
|
||||
];
|
||||
|
||||
@@ -0,0 +1,703 @@
|
||||
{
|
||||
"name": "cm-build",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "cm-build",
|
||||
"dependencies": {
|
||||
"@codemirror/commands": "6.11.1",
|
||||
"@codemirror/lang-markdown": "6.5.2",
|
||||
"@codemirror/language": "6.13.1",
|
||||
"@codemirror/state": "6.7.6",
|
||||
"@codemirror/view": "6.43.15",
|
||||
"esbuild": "0.28.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/autocomplete": {
|
||||
"version": "6.20.4",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.20.4.tgz",
|
||||
"integrity": "sha512-yF8RhOf2SXlg00+qtupzLhrglcas61boqaONiNcbPIebHCpJocpqTBA6dyrtUrQO47hqyTdeob/3XnYilT7TaQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/language": "^6.0.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.17.0",
|
||||
"@lezer/common": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/commands": {
|
||||
"version": "6.11.1",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.11.1.tgz",
|
||||
"integrity": "sha512-O/4hG3SC1YwcmQ0d2UVNDs+AsaNWd1iHVxbTeEBuqH+6bExAiPK3iS/BvpY6rZGURALv4ZD3sIgcCmRvw3ehBg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/language": "^6.0.0",
|
||||
"@codemirror/state": "^6.7.0",
|
||||
"@codemirror/view": "^6.27.0",
|
||||
"@lezer/common": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/lang-css": {
|
||||
"version": "6.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/lang-css/-/lang-css-6.3.1.tgz",
|
||||
"integrity": "sha512-kr5fwBGiGtmz6l0LSJIbno9QrifNMUusivHbnA1H6Dmqy4HZFte3UAICix1VuKo0lMPKQr2rqB+0BkKi/S3Ejg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.0.0",
|
||||
"@codemirror/language": "^6.0.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@lezer/common": "^1.0.2",
|
||||
"@lezer/css": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/lang-html": {
|
||||
"version": "6.4.12",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/lang-html/-/lang-html-6.4.12.tgz",
|
||||
"integrity": "sha512-pw2ReWKUqSkbvh76RAT4NYxiogRu+PWkR2ukAwO9uOgrm8uipkzjtKKtNpyeAQwHOqxEeSvAXZ6vr3AfyB9y/w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.0.0",
|
||||
"@codemirror/lang-css": "^6.0.0",
|
||||
"@codemirror/lang-javascript": "^6.0.0",
|
||||
"@codemirror/language": "^6.4.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.17.0",
|
||||
"@lezer/common": "^1.0.0",
|
||||
"@lezer/css": "^1.1.0",
|
||||
"@lezer/html": "^1.3.12"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/lang-javascript": {
|
||||
"version": "6.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.2.5.tgz",
|
||||
"integrity": "sha512-zD4e5mS+50htS7F+TYjBPsiIFGanfVqg4HyUz6WNFikgOPf2BgKlx+TQedI1w6n/IqRBVBbBWmGFdLB/7uxO4A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.0.0",
|
||||
"@codemirror/language": "^6.6.0",
|
||||
"@codemirror/lint": "^6.0.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.17.0",
|
||||
"@lezer/common": "^1.0.0",
|
||||
"@lezer/javascript": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/lang-markdown": {
|
||||
"version": "6.5.2",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/lang-markdown/-/lang-markdown-6.5.2.tgz",
|
||||
"integrity": "sha512-AwBOdkWYuA//WcM0xO5PfHPUcmz/O2i5o0Nsg1U69SII/loCJlFI1Romd9xp2HYb1kYJRGZotyqRghuHH5n8Kw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.7.1",
|
||||
"@codemirror/lang-html": "^6.0.0",
|
||||
"@codemirror/language": "^6.3.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.0.0",
|
||||
"@lezer/common": "^1.2.1",
|
||||
"@lezer/markdown": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/language": {
|
||||
"version": "6.13.1",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.13.1.tgz",
|
||||
"integrity": "sha512-zfvU2r3TyylQLMj/te+5CnQ0rSqZi8B1oTCBbQkagcLW4Xc6imab6qN+pEJhsuNOLaJqiRyBXp9UhWA1DhVvDw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/streamparser": "^6.0.0",
|
||||
"@codemirror/view": "^6.23.0",
|
||||
"@lezer/common": "^1.5.0",
|
||||
"@lezer/highlight": "^1.0.0",
|
||||
"@lezer/lr": "^1.0.0",
|
||||
"style-mod": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/lint": {
|
||||
"version": "6.9.7",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.9.7.tgz",
|
||||
"integrity": "sha512-28/+iWLYxKxsvGYhSYL7zaCZqLz5+FFFDq9tVsvGv9kv8RY4fFAchJ5WX9M3YrrRlTIsECjsXPqeNgnSmNP2dg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.42.0",
|
||||
"crelt": "^1.0.5"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/state": {
|
||||
"version": "6.7.6",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.7.6.tgz",
|
||||
"integrity": "sha512-kAz+AncRtKuIknedxT1bq4XwXv4UowhbkHU1myPrtVb/jZtImWuV5BXzv5vK6i3kYACsdiZiQKFQQ5Mq7elW8w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@marijn/find-cluster-break": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/streamparser": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/streamparser/-/streamparser-6.0.0.tgz",
|
||||
"integrity": "sha512-JTFPF6xrfjt0mnfGPgzcLiMwYmvIyNaoizp8BYzv8FE8KrT6GBGDZ190rtt+O7Wke3gG/MFHyiY9YGNeimof4w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@codemirror/view": {
|
||||
"version": "6.43.15",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.43.15.tgz",
|
||||
"integrity": "sha512-HHsfpqFeHyXLs983pSRe38Xajs0vFWZQ2BuX0m7Ki8w3jZ5iD8cuR3lBz2/5/X53Dhf32SBHKh6rtSTB6tKeGw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.7.0",
|
||||
"crelt": "^1.0.6",
|
||||
"style-mod": "^4.1.0",
|
||||
"w3c-keyname": "^2.2.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/aix-ppc64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz",
|
||||
"integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"aix"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-arm": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz",
|
||||
"integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-arm64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz",
|
||||
"integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-x64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz",
|
||||
"integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/darwin-arm64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz",
|
||||
"integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/darwin-x64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz",
|
||||
"integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/freebsd-arm64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz",
|
||||
"integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/freebsd-x64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz",
|
||||
"integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-arm": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz",
|
||||
"integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-arm64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz",
|
||||
"integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-ia32": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz",
|
||||
"integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-loong64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz",
|
||||
"integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==",
|
||||
"cpu": [
|
||||
"loong64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-mips64el": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz",
|
||||
"integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==",
|
||||
"cpu": [
|
||||
"mips64el"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-ppc64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz",
|
||||
"integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-riscv64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz",
|
||||
"integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-s390x": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz",
|
||||
"integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-x64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz",
|
||||
"integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/netbsd-arm64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz",
|
||||
"integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"netbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/netbsd-x64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz",
|
||||
"integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"netbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/openbsd-arm64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz",
|
||||
"integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/openbsd-x64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz",
|
||||
"integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/openharmony-arm64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz",
|
||||
"integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openharmony"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/sunos-x64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz",
|
||||
"integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"sunos"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-arm64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz",
|
||||
"integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-ia32": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz",
|
||||
"integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-x64": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz",
|
||||
"integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/common": {
|
||||
"version": "1.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.3.tgz",
|
||||
"integrity": "sha512-H0iErY4e43LpXbYDyBci5W4v/RwTgGV3YzYOlJPiGZ8RY8w51kVE+xLn1tg3Z6UmSfyETvtsUK3r7YsgDQEI7Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@lezer/css": {
|
||||
"version": "1.3.9",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.3.9.tgz",
|
||||
"integrity": "sha512-ZmzgvTOBdJWGIsY/ItAfN7UW8DV802oZG+jeG6E508SwEzz5YhuAajptpWPICvIyqYAD2+VjMdOS40GgGkyEOQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.2.0",
|
||||
"@lezer/highlight": "^1.0.0",
|
||||
"@lezer/lr": "^1.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/highlight": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.5.tgz",
|
||||
"integrity": "sha512-O1GMVKgtf5YspFaRzpmqkVgMtIk2HG9uMAbH6wdAIdNh3TVzCsch/+cRi+6l2//UGDKe6NB9BW3cvuR5ezMQ0w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/html": {
|
||||
"version": "1.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/html/-/html-1.3.13.tgz",
|
||||
"integrity": "sha512-oI7n6NJml729m7pjm9lvLvmXbdoMoi2f+1pwSDJkl9d68zGr7a9Btz8NdHTGQZtW2DA25ybeuv/SyDb9D5tseg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.2.0",
|
||||
"@lezer/highlight": "^1.0.0",
|
||||
"@lezer/lr": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/javascript": {
|
||||
"version": "1.5.6",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.6.tgz",
|
||||
"integrity": "sha512-sEvOqpl4vJQca0NugSQK02vQPbc5KrvoojnYGoqqFgFO0MtcYhwGiHKVEB+LuXYJnfyXo4QPA8ztbrEa4Fw5NA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.2.0",
|
||||
"@lezer/highlight": "^1.1.3",
|
||||
"@lezer/lr": "^1.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/lr": {
|
||||
"version": "1.4.11",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.11.tgz",
|
||||
"integrity": "sha512-UwgZcl1R66H2hDzBrA7kWyYmX6s8p5TQ+e/t7CuvgCtBEPxbEPaHYHu+pJBvTvDotEJpuQkJjbXuHiw5Cixxgw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/markdown": {
|
||||
"version": "1.8.1",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/markdown/-/markdown-1.8.1.tgz",
|
||||
"integrity": "sha512-M5YmEcKWO4mJ45Y1hECwqyu8cLv25EiXOK554PVOvDOWOP0olwelHHQUWr9sjF+d1bENVhy0nfJ8E57XZUTiXg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.5.0",
|
||||
"@lezer/highlight": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@marijn/find-cluster-break": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.4.tgz",
|
||||
"integrity": "sha512-Wy0V7+SGUjnF9/TkiM1hKVDPj7jKXduPNboMVtHTA8dySMURWqfg/JZ9E2Sq8JgSJmkl7k7Qe9FLeMSrSraWmQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/crelt": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.7.tgz",
|
||||
"integrity": "sha512-aK6BbWfhf4U/wCcLHKPJl/xa6VkVstRaPywWtMKGwuOLc/wZTyQYuoxgvZnNsBvv7Kg3YTBQYYBCggcviQczuA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/esbuild": {
|
||||
"version": "0.28.2",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz",
|
||||
"integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"esbuild": "bin/esbuild"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@esbuild/aix-ppc64": "0.28.2",
|
||||
"@esbuild/android-arm": "0.28.2",
|
||||
"@esbuild/android-arm64": "0.28.2",
|
||||
"@esbuild/android-x64": "0.28.2",
|
||||
"@esbuild/darwin-arm64": "0.28.2",
|
||||
"@esbuild/darwin-x64": "0.28.2",
|
||||
"@esbuild/freebsd-arm64": "0.28.2",
|
||||
"@esbuild/freebsd-x64": "0.28.2",
|
||||
"@esbuild/linux-arm": "0.28.2",
|
||||
"@esbuild/linux-arm64": "0.28.2",
|
||||
"@esbuild/linux-ia32": "0.28.2",
|
||||
"@esbuild/linux-loong64": "0.28.2",
|
||||
"@esbuild/linux-mips64el": "0.28.2",
|
||||
"@esbuild/linux-ppc64": "0.28.2",
|
||||
"@esbuild/linux-riscv64": "0.28.2",
|
||||
"@esbuild/linux-s390x": "0.28.2",
|
||||
"@esbuild/linux-x64": "0.28.2",
|
||||
"@esbuild/netbsd-arm64": "0.28.2",
|
||||
"@esbuild/netbsd-x64": "0.28.2",
|
||||
"@esbuild/openbsd-arm64": "0.28.2",
|
||||
"@esbuild/openbsd-x64": "0.28.2",
|
||||
"@esbuild/openharmony-arm64": "0.28.2",
|
||||
"@esbuild/sunos-x64": "0.28.2",
|
||||
"@esbuild/win32-arm64": "0.28.2",
|
||||
"@esbuild/win32-ia32": "0.28.2",
|
||||
"@esbuild/win32-x64": "0.28.2"
|
||||
}
|
||||
},
|
||||
"node_modules/style-mod": {
|
||||
"version": "4.1.4",
|
||||
"resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.4.tgz",
|
||||
"integrity": "sha512-XXWIQt633/EpAFx8aZDOTjBzrCaGmhvEQlQo6MVPfa2OzO2cWo+4hV9h+6UkHYlXGfy+ODXKUdP7Pthmcu5ATw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/w3c-keyname": {
|
||||
"version": "2.2.8",
|
||||
"resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",
|
||||
"integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==",
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env node
|
||||
// Builds the one vendored CodeMirror file the Notebook's live-preview editor
|
||||
// imports. Dev-only: lives in scripts/ so it never ships inside a skill.
|
||||
//
|
||||
// node scripts/vendor-codemirror.mjs rebuild from the lock file
|
||||
// node scripts/vendor-codemirror.mjs --update-lock after changing a version below
|
||||
//
|
||||
// The console has no dependencies and no build step for users, so CodeMirror 6
|
||||
// is bundled once, here, into src/web-console/public/vendor/codemirror.esm.js
|
||||
// (Markdown only, minified, one ES module). The packages and esbuild are
|
||||
// installed into a throwaway folder under the OS temp directory, never into
|
||||
// the repo. Only the six packages below are named; everything they pull in
|
||||
// (@lezer/*, style-mod, w3c-keyname, crelt) is pinned by
|
||||
// scripts/vendor-codemirror-lock.json, installed with npm ci, so the same
|
||||
// lock gives the same bytes. Needs Node 18+, npm and network access.
|
||||
|
||||
import { spawnSync } from "node:child_process";
|
||||
import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const ROOT = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
||||
const OUT = path.join(ROOT, "src", "web-console", "public", "vendor", "codemirror.esm.js");
|
||||
const LOCK = path.join(ROOT, "scripts", "vendor-codemirror-lock.json");
|
||||
|
||||
export const VERSIONS = Object.freeze({
|
||||
esbuild: "0.28.2",
|
||||
"@codemirror/state": "6.7.6",
|
||||
"@codemirror/view": "6.43.15",
|
||||
"@codemirror/language": "6.13.1",
|
||||
"@codemirror/commands": "6.11.1",
|
||||
"@codemirror/lang-markdown": "6.5.2",
|
||||
});
|
||||
|
||||
export const HEADER =
|
||||
"/* CodeMirror 6 (state, view, language, commands, lang-markdown), MIT licence, (c) Marijn Haverbeke and others.\n" +
|
||||
" * https://codemirror.net/ . Bundled by scripts/vendor-codemirror.mjs; do not edit by hand.\n" +
|
||||
" * Versions: " +
|
||||
Object.entries(VERSIONS)
|
||||
.filter(([name]) => name !== "esbuild")
|
||||
.map(([name, version]) => name + " " + version)
|
||||
.join(", ") +
|
||||
" */\n";
|
||||
|
||||
// What the page may import: exactly what notepad-editor.js uses, since an
|
||||
// entry export is never tree-shaken. indentWithTab is left out on purpose: it
|
||||
// would trap the Tab key and keyboard users could not leave the editor.
|
||||
export const ENTRY = `export { Compartment, EditorState } from "@codemirror/state";
|
||||
export { Decoration, EditorView, ViewPlugin, WidgetType, keymap } from "@codemirror/view";
|
||||
export { markdown, markdownLanguage } from "@codemirror/lang-markdown";
|
||||
export { syntaxTree } from "@codemirror/language";
|
||||
export { defaultKeymap, history, historyKeymap, redo } from "@codemirror/commands";
|
||||
`;
|
||||
|
||||
// npm is a .cmd file on Windows, which only a shell can start; node never needs one
|
||||
// (its path may hold spaces).
|
||||
function run(cmd, args, cwd) {
|
||||
const res = spawnSync(cmd, args, { cwd, encoding: "utf8", shell: process.platform === "win32" && cmd === "npm" });
|
||||
if (res.status !== 0) {
|
||||
process.stderr.write((res.stdout || "") + (res.stderr || ""));
|
||||
throw new Error(`${cmd} ${args.join(" ")} failed (${res.status})`);
|
||||
}
|
||||
return res.stdout;
|
||||
}
|
||||
|
||||
export function build({ updateLock = false } = {}) {
|
||||
const work = fs.mkdtempSync(path.join(os.tmpdir(), "plan2code-codemirror-"));
|
||||
try {
|
||||
fs.writeFileSync(path.join(work, "package.json"), JSON.stringify({ name: "cm-build", private: true, type: "module", dependencies: VERSIONS }));
|
||||
if (updateLock || !fs.existsSync(LOCK)) {
|
||||
run("npm", ["install", "--no-audit", "--no-fund", "--ignore-scripts", "--package-lock-only"], work);
|
||||
fs.copyFileSync(path.join(work, "package-lock.json"), LOCK);
|
||||
} else {
|
||||
fs.copyFileSync(LOCK, path.join(work, "package-lock.json"));
|
||||
}
|
||||
run("npm", ["ci", "--no-audit", "--no-fund", "--ignore-scripts"], work);
|
||||
fs.writeFileSync(path.join(work, "entry.js"), ENTRY);
|
||||
const esbuild = path.join(work, "node_modules", "esbuild", "bin", "esbuild");
|
||||
run(process.execPath, [esbuild, "entry.js", "--bundle", "--format=esm", "--minify", "--target=es2022", "--legal-comments=none", "--outfile=out.js"], work);
|
||||
const body = fs.readFileSync(path.join(work, "out.js"), "utf8");
|
||||
fs.mkdirSync(path.dirname(OUT), { recursive: true });
|
||||
fs.writeFileSync(OUT, HEADER + body);
|
||||
} finally {
|
||||
fs.rmSync(work, { recursive: true, force: true });
|
||||
}
|
||||
const bytes = fs.readFileSync(OUT);
|
||||
return { file: path.relative(ROOT, OUT), bytes: bytes.length, sha256: crypto.createHash("sha256").update(bytes).digest("hex") };
|
||||
}
|
||||
|
||||
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
console.log(JSON.stringify(build({ updateLock: process.argv.includes("--update-lock") }), null, 2));
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
// Captures the CSS the vendored OverType would inject, as a real stylesheet.
|
||||
// Dev-only: lives in scripts/ so it never ships inside a skill.
|
||||
//
|
||||
// node scripts/vendor-overtype.mjs
|
||||
//
|
||||
// The console's content-security policy (`style-src 'self'`) blocks the
|
||||
// <style> OverType adds to the page, so the notepad sets
|
||||
// `OverType.stylesInjected = true` and ships the same rules in
|
||||
// src/web-console/public/styles/notepad.css instead. This script loads
|
||||
// public/vendor/overtype.esm.js in a blank page, calls
|
||||
// `OverType.injectStyles(true)` and writes what landed in
|
||||
// `style.overtype-styles` between the header and the end marker below. The
|
||||
// notepad's own rules, after the marker, are kept as they are. Run it again
|
||||
// after upgrading the vendored file.
|
||||
//
|
||||
// Needs playwright-core (a root devDependency) and a local Chrome or Edge,
|
||||
// launched through scripts/browser.mjs.
|
||||
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { launchBrowser } from "./browser.mjs";
|
||||
|
||||
const ROOT = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
||||
const PUBLIC = path.join(ROOT, "src", "web-console", "public");
|
||||
const VENDOR = path.join(PUBLIC, "vendor", "overtype.esm.js");
|
||||
const OUT = path.join(PUBLIC, "styles", "notepad.css");
|
||||
|
||||
export const HEADER = "/* OverType 2.6.1 generated CSS: regenerate with node scripts/vendor-overtype.mjs */";
|
||||
export const END_MARKER = "/* end OverType */";
|
||||
|
||||
// A made-up origin served from here, so the module loads as it does on the
|
||||
// page: as a module, from a URL, with nothing else around it.
|
||||
const ORIGIN = "http://overtype.invalid";
|
||||
|
||||
async function capture() {
|
||||
const browser = await launchBrowser();
|
||||
try {
|
||||
const page = await browser.newPage();
|
||||
await page.route(`${ORIGIN}/**`, (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
if (url.pathname === "/overtype.esm.js") {
|
||||
return route.fulfill({ contentType: "text/javascript", body: fs.readFileSync(VENDOR) });
|
||||
}
|
||||
return route.fulfill({ contentType: "text/html", body: "<!doctype html><title>OverType CSS</title>" });
|
||||
});
|
||||
await page.goto(`${ORIGIN}/`);
|
||||
return await page.evaluate(async (src) => {
|
||||
const { OverType } = await import(src);
|
||||
OverType.injectStyles(true);
|
||||
const style = document.querySelector("style.overtype-styles");
|
||||
return style ? style.textContent : null;
|
||||
}, `${ORIGIN}/overtype.esm.js`);
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
}
|
||||
|
||||
// The generated block, then whatever followed the marker before (the
|
||||
// notepad's own rules), or nothing on a first run. A stylesheet with rules but
|
||||
// no marker is refused: rewriting it would delete them.
|
||||
export function assemble(css, existing) {
|
||||
const at = existing.indexOf(END_MARKER);
|
||||
if (at === -1 && existing.trim()) {
|
||||
throw new Error(`notepad.css has no "${END_MARKER}" marker, so its own rules cannot be told apart: put the marker back, then run this again.`);
|
||||
}
|
||||
const own = at === -1 ? "" : existing.slice(at + END_MARKER.length);
|
||||
const body = css.trim().split("\n").map((line) => line.replace(/\s+$/, "")).join("\n");
|
||||
return `${HEADER}\n${body}\n${END_MARKER}${own || "\n"}`;
|
||||
}
|
||||
|
||||
const css = await capture().catch((e) => {
|
||||
console.error(e.browserProblem ? e.message : `Could not capture OverType's CSS: ${e.message}`);
|
||||
process.exit(1);
|
||||
});
|
||||
if (!css) {
|
||||
console.error("OverType injected no style.overtype-styles element.");
|
||||
process.exit(1);
|
||||
}
|
||||
const existing = fs.existsSync(OUT) ? fs.readFileSync(OUT, "utf8") : "";
|
||||
let out;
|
||||
try {
|
||||
out = assemble(css, existing);
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
process.exit(1);
|
||||
}
|
||||
fs.writeFileSync(OUT, out);
|
||||
console.log(`Wrote ${path.relative(ROOT, OUT)} (${css.length} characters of OverType CSS).`);
|
||||
Reference in new issue
Block a user