Eilen Shin 81de0761ed
feat: improve file attachments and add Office artifact previews (#8009)
* feat(frontend): improve file attachment recovery and artifact presentation

* feat(extensions): add Office artifact previews with search and navigation

* fix: preserve public viewers and HTTP Office previews

* fix: address file preview and upload review findings

* fix: use typed upload errors and linear bookmark allocation

* fix(office-preview): isolate parsing and bound preview resources

* fix(ci): install Office preview fixture dependencies for E2E

* fix(ci): provision matching Playwright browsers before E2E tests

* fix(ci): isolate Python libraries and include Office documentation

* test(frontend): wait for download status to finish rendering
2026-11-12 20:30:17 +08:00

30 lines
2.4 KiB
JavaScript

// Preserve upstream license texts for the locked production dependency tree,
// including libraries already embedded in ExcelJS's browser distribution.
import { readdir, readFile, writeFile } from "node:fs/promises";
const lock = JSON.parse(await readFile("package-lock.json", "utf8"));
// Indent quoted upstream text so README underlines cannot resemble merge markers.
// Only insignificant trailing whitespace is removed from license notices.
const quoteNotice = body => body.trim().split(/\r?\n/).map(line => line.trimEnd() ? ` ${line.trimEnd()}` : "").join("\n");
let output = `# Third-party notices\n\nOffice preview is independently implemented for DeerFlow. Asset-System was\nreviewed as a UX reference; its source code and assets are not included.\n\nThe browser bundle uses ExcelJS, docx-preview, JSZip and @jvmr/pptx-to-html.\nThe following notices cover the locked production dependency tree, including\ntransitive packages embedded in prebuilt browser distributions. JSZip is used\nunder its MIT license option. Node-only dependency notices are included\nconservatively; their inclusion does not imply that their code ships to browsers.\n\nGenerated by \`node notices.mjs\` from \`package-lock.json\` and installed packages.\n\n`;
for (const [directory, entry] of Object.entries(lock.packages).sort(([a], [b]) => a.localeCompare(b))) {
if (!directory || entry.dev) continue;
const pkg = JSON.parse(await readFile(`${directory}/package.json`, "utf8"));
const files = (await readdir(directory)).filter(name => /^(licen[sc]e|copying|notice)([.-]|$)/i.test(name));
output += `## ${pkg.name} ${pkg.version}\n\nLicense: ${pkg.license ?? entry.license ?? "see upstream notice"}.\n\n`;
for (const name of files.sort()) {
let body;
try { body = await readFile(`${directory}/${name}`, "utf8"); } catch { continue; }
output += `### ${name}\n\n${quoteNotice(body)}\n\n`;
}
if (!files.length) {
// Several older npm packages put their copyright and permission grant
// in README instead of shipping a separate LICENSE file.
const readme = (await readdir(directory)).find(name => /^readme([.-]|$)/i.test(name));
if (!readme) throw new Error(`Missing license notice: ${directory}`);
const body = await readFile(`${directory}/${readme}`, "utf8");
output += `### ${readme} (upstream notice)\n\n${quoteNotice(body)}\n\n`;
}
}
await writeFile("THIRD_PARTY_NOTICES.md", output.trimEnd() + "\n", "utf8");