diff --git a/external_plugins/invoice-maker/.zcode-plugin/plugin.json b/external_plugins/invoice-maker/.zcode-plugin/plugin.json new file mode 100644 index 00000000..2ef7c415 --- /dev/null +++ b/external_plugins/invoice-maker/.zcode-plugin/plugin.json @@ -0,0 +1,57 @@ +{ + "name": "invoice-maker", + "version": "0.1.0", + "description": "Turn a sheet of line items (.xlsx/.csv) into numbered PDF invoices: rows are grouped by invoice number or client, amounts, tax and totals are calculated, and bad numbers or missing clients are flagged. Fix any cell in the panel, preview the invoice and export one PDF per invoice plus an Excel/CSV ledger. Runs locally; no API keys.", + "description_i18n": { + "en": "Turn a sheet of line items (.xlsx/.csv) into numbered PDF invoices: rows are grouped by invoice number or client, amounts, tax and totals are calculated, and bad numbers or missing clients are flagged. Fix any cell in the panel, preview the invoice and export one PDF per invoice plus an Excel/CSV ledger. Runs locally; no API keys.", + "zh-CN": "把一张明细表(.xlsx/.csv)批量做成带编号的 PDF 发票:按发票号或客户自动分组,计算金额、税额和合计,标出数字错误、缺少客户等问题。在面板里直接改单元格、预览发票,导出每张一个 PDF,另附 Excel/CSV 开票台账。在本地运行,无需 API 密钥。" + }, + "author": { + "name": "Penova", + "url": "https://github.com/ppppp2005-p" + }, + "license": "MIT", + "keywords": [ + "invoice", + "billing", + "pdf", + "freelancer", + "tax", + "ledger", + "发票", + "账单", + "开票", + "报价", + "自由职业" + ], + "skills": "skills", + "mcpServers": { + "invoice-maker": { + "type": "stdio", + "command": "node", + "args": [ + "${ZCODE_PLUGIN_ROOT}/dist/server.mjs" + ], + "cwd": "${ZCODE_PROJECT_DIR}", + "timeoutMs": 900000, + "env": { + "ZCODE_WORKSPACE_ROOT": "${ZCODE_PROJECT_DIR}" + } + } + }, + "ui": { + "surfaces": [ + { + "id": "editor", + "title": { + "zh-CN": "批量开发票", + "en-US": "Invoice Maker" + }, + "icon": "receipt", + "server": "invoice-maker", + "resourceUri": "ui://invoice-maker/panel.html", + "availability": "session" + } + ] + } +} diff --git a/external_plugins/invoice-maker/LICENSE b/external_plugins/invoice-maker/LICENSE new file mode 100644 index 00000000..67e98093 --- /dev/null +++ b/external_plugins/invoice-maker/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Penova + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/external_plugins/invoice-maker/README.md b/external_plugins/invoice-maker/README.md new file mode 100644 index 00000000..a5d4999a --- /dev/null +++ b/external_plugins/invoice-maker/README.md @@ -0,0 +1,52 @@ +# Invoice Maker + +Turn a sheet of line items (.xlsx/.csv) into numbered PDF invoices: rows are grouped by invoice number or client, amounts, tax and totals are calculated, and bad numbers or missing clients are flagged. Fix any cell in the panel, preview the invoice and export one PDF per invoice plus an Excel/CSV ledger. Runs locally; no API keys. + +## Features + +- **Input**: one row per line item. Chinese or English column names (发票号 / invoice no., 客户 / client, 地址 / address, 项目 / item, 数量 / qty, 单价 / price, 税率 / tax) are matched automatically; prices like `¥26,000` or `$320.00` and quantities like `一` are understood. +- **Grouping and numbering**: rows with the same invoice number form one invoice; rows without a number are grouped by client and numbered from your prefix and first number (e.g. INV-0001). +- **Checks**: non-numeric quantities and prices, tax rates outside 0–100, missing clients, one invoice number used for two clients, missing addresses and invoices that will not fit on one page. +- **PDF**: your business name and details, client block, item table, subtotal, tax and total, payment due date and notes; Chinese, English or bilingual labels; A4 or Letter; accent colour. Chinese text uses a font already on your computer. +- **Ledger**: invoices.xlsx (summary and lines), invoices.csv and an HTML list. +- **Panel**: pick input files, adjust settings, see problems, edit any cell in the table, preview the result and export — all in the ZCode side panel. Edits are saved in `invoice-maker/.project.json` and kept until you re-open the inputs. + +## Usage + +Ask the agent in ZCode Desktop: + +- "Make invoices from billing/invoices-2026-11.xlsx with 6% tax, our company name Penova Labs, due in 30 days" +- "Change the support hours for Northwind to 5 and switch the invoices to USD in English" +- "Export the invoices as PDFs and the ledger" + +## Tools + +| Tool | Purpose | +|---|---| +| `invoice_open` | Read the line-item sheet, group rows into invoices and check them. Opens the panel | +| `invoice_edit` | Change settings, edit cells by row, add or remove rows | +| `invoice_status` | Show the current rows, issues and summary | +| `invoice_export` | Write one PDF per invoice, all-invoices.pdf, invoices.xlsx/.csv and an HTML list | + +Output goes to `invoice-maker//` in the workspace. + +## Scope (v0.1) + +- One currency per project; tax is a percentage per line (no compound or withholding taxes). +- One page per invoice (about 20 lines). Not an official tax invoice (e.g. China fapiao or EU e-invoice formats); nothing is sent by email. +- Old .xls files: save as .xlsx first. + +## Privacy, network and files + +- **Everything runs locally.** No network, no uploads, no API keys or accounts. +- Reads only the files you choose. Writes only the `invoice-maker/` folder in the workspace. No hooks. + +## Build and test (developers) + +- Source: `ui-plugins/invoice-maker/`. +- Build: `pnpm install --frozen-lockfile && pnpm build`, then add `dist/local-marketplace` as a local source. +- Tests: `pnpm --filter @penova/plugin-invoice-maker test` and `test:e2e` (needs Chrome; sample files in `test/samples/`). + +## Third-party components and licenses + +MIT licensed (author: Penova). Bundled: pdf-lib (MIT), fontkit (MIT), ExcelJS (MIT), MCP SDK and ext-apps (MIT), zod (MIT); the full list is in `dist/THIRD_PARTY_NOTICES.txt`. diff --git a/external_plugins/invoice-maker/README_CN.md b/external_plugins/invoice-maker/README_CN.md new file mode 100644 index 00000000..61edd87e --- /dev/null +++ b/external_plugins/invoice-maker/README_CN.md @@ -0,0 +1,52 @@ +# 批量开发票 + +把一张明细表(.xlsx/.csv)批量做成带编号的 PDF 发票:按发票号或客户自动分组,计算金额、税额和合计,标出数字错误、缺少客户等问题。在面板里直接改单元格、预览发票,导出每张一个 PDF,另附 Excel/CSV 开票台账。在本地运行,无需 API 密钥。 + +## 功能 + +- **输入**:每行一个收费项目。自动识别中英文列名(发票号、客户、地址、项目、数量、单价、税率),能读懂 `¥26,000`、`$320.00` 这样的金额和“一”这样的数量。 +- **分组与编号**:发票号相同的行合成一张发票;没有发票号的按客户分组,并按前缀和起始编号自动编号(如 INV-0001)。 +- **检查**:数量或单价不是数字、税率不在 0–100、缺少客户、同一发票号对应两个客户、缺少地址、行数太多放不下一页。 +- **PDF**:开票方名称和信息、客户信息、项目表、小计、税额、合计、付款期限和备注;中文、英文或双语;A4 或 Letter;可选主题色。中文使用电脑上已有的字体。 +- **台账**:invoices.xlsx(汇总表和明细表)、invoices.csv 和 HTML 清单。 +- **面板**:在 ZCode 侧栏里选择输入文件、调整设置、查看问题、直接修改表格里的任意单元格、预览成品并导出。修改保存在 `invoice-maker/<项目>.project.json`,重新打开输入文件前一直保留。 + +## 使用方法 + +在 ZCode 桌面端对助手说: + +- “用 账单/invoices-2026-11.xlsx 开发票,税率 6%,开票方 Penova Labs,30 天内付款” +- “把 Northwind 的支持工时改成 5 小时,发票改成美元、英文” +- “导出 PDF 发票和开票台账” + +## 工具 + +| 工具 | 作用 | +|---|---| +| `invoice_open` | 读取明细表,分组成发票并检查,并打开面板 | +| `invoice_edit` | 修改设置、按行修改单元格、新增或删除行 | +| `invoice_status` | 查看当前数据、问题和汇总 | +| `invoice_export` | 导出每张发票的 PDF、合并的 all-invoices.pdf、invoices.xlsx/.csv 和 HTML 清单 | + +导出文件写到工作区的 `invoice-maker/<项目>/` 文件夹。 + +## 范围(v0.1) + +- 每个项目一种币种;税额按每行税率计算(不含复合税、代扣税)。 +- 每张发票一页(约 20 行)。不是官方税务发票(如增值税发票、欧盟电子发票),也不会通过邮件发送。 +- 旧版 .xls 请先另存为 .xlsx。 + +## 隐私、网络与文件 + +- **全部在本地运行。** 不联网、不上传,不需要 API 密钥或账号。 +- 只读取你选择的文件,只写入工作区的 `invoice-maker/` 文件夹。没有 Hook。 + +## 构建与测试(开发者) + +- 源码:`ui-plugins/invoice-maker/`。 +- 构建:`pnpm install --frozen-lockfile && pnpm build`,然后把 `dist/local-marketplace` 添加为本地来源。 +- 测试:`pnpm --filter @penova/plugin-invoice-maker test` 和 `test:e2e`(需要 Chrome;样例文件在 `test/samples/`)。 + +## 第三方组件与许可证 + +MIT 许可(作者:Penova)。打包的组件:pdf-lib (MIT), fontkit (MIT), ExcelJS (MIT)、MCP SDK 与 ext-apps(MIT)、zod(MIT);完整列表见 `dist/THIRD_PARTY_NOTICES.txt`。 diff --git a/external_plugins/invoice-maker/skills/invoice-maker/SKILL.md b/external_plugins/invoice-maker/skills/invoice-maker/SKILL.md new file mode 100644 index 00000000..b9d839ae --- /dev/null +++ b/external_plugins/invoice-maker/skills/invoice-maker/SKILL.md @@ -0,0 +1,15 @@ +--- +name: invoice-maker +description: 把一张明细表(.xlsx/.csv)批量做成带编号的 PDF 发票:按发票号或客户自动分组,计算金额、税额和合计,标出数字错误、缺少客户等问题。在面板里直接改单元格、预览发票,导出每张一个 PDF,另附 Excel/CSV 开票台账。在本地运行,无需 API 密钥。 用户提到“开发票 / 批量出账单 / invoice / 账单 PDF / 给客户开票”时使用。 +--- + +# 批量开发票 + +1. `invoice_open(inputs, settings?, project?)`:读取明细表,分组成发票并检查。inputs 是工作区相对路径。 + - 结果里有汇总、问题列表(错误 / 提醒)和前几行数据,每行有编号 `#n`。 + - 设置里先填开票方名称(seller)、默认税率(taxRate)、币种(currency);用户没说的就问一句或用默认值。 +2. 向用户简要说明结果,先说错误和需要确认的地方,不要逐行念。 +3. 用户要改时调用 `invoice_edit(project, settings?, set?: [{row, values}], add?, remove?)`。 + - 改金额:`set: [{row: 3, values: {qty: 5}}]`;改币种语言:`settings: {currency: "USD", lang: "en"}`。 +4. `invoice_export(project, formats?)`:导出每张发票的 PDF、合并的 all-invoices.pdf、invoices.xlsx/.csv 和 HTML 清单。把文件路径告诉用户。 +5. 有错误(error)时 PDF 不能导出,先告诉用户哪一行有问题并帮他改好。 diff --git a/marketplace.json b/marketplace.json index 32e8c8ef..4f4be6c2 100644 --- a/marketplace.json +++ b/marketplace.json @@ -1673,6 +1673,55 @@ "把上一个 Hi3D 任务生成的模型按角色拆分成部件" ] } + }, + { + "name": "invoice-maker", + "componentTypes": [ + "ui" + ], + "source": "./external_plugins/invoice-maker", + "displayName": "Invoice Maker", + "displayName_i18n": { + "en": "Invoice Maker", + "zh-CN": "批量开发票" + }, + "description": "Turn a sheet of line items (.xlsx/.csv) into numbered PDF invoices: rows are grouped by invoice number or client, amounts, tax and totals are calculated, and bad numbers or missing clients are flagged. Fix any cell in the panel, preview the invoice and export one PDF per invoice plus an Excel/CSV ledger. Runs locally; no API keys.", + "description_i18n": { + "en": "Turn a sheet of line items (.xlsx/.csv) into numbered PDF invoices: rows are grouped by invoice number or client, amounts, tax and totals are calculated, and bad numbers or missing clients are flagged. Fix any cell in the panel, preview the invoice and export one PDF per invoice plus an Excel/CSV ledger. Runs locally; no API keys.", + "zh-CN": "把一张明细表(.xlsx/.csv)批量做成带编号的 PDF 发票:按发票号或客户自动分组,计算金额、税额和合计,标出数字错误、缺少客户等问题。在面板里直接改单元格、预览发票,导出每张一个 PDF,另附 Excel/CSV 开票台账。在本地运行,无需 API 密钥。" + }, + "version": "0.1.0", + "author": { + "name": "Penova", + "url": "https://github.com/ppppp2005-p" + }, + "license": "MIT", + "category": "productivity", + "keywords": [ + "invoice", + "billing", + "pdf", + "freelancer", + "tax", + "ledger", + "发票", + "账单", + "开票", + "报价", + "自由职业" + ], + "examplePrompts": [ + "Make invoices from billing/invoices-2026-11.xlsx with 6% tax, our company name Penova Labs, due in 30 days", + "Change the support hours for Northwind to 5 and switch the invoices to USD in English", + "Export the invoices as PDFs and the ledger" + ], + "examplePrompts_i18n": { + "zh-CN": [ + "用 账单/invoices-2026-11.xlsx 开发票,税率 6%,开票方 Penova Labs,30 天内付款", + "把 Northwind 的支持工时改成 5 小时,发票改成美元、英文", + "导出 PDF 发票和开票台账" + ] + } } ] } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 14b35f76..1fed5f8d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -89,6 +89,46 @@ importers: ui-plugins/gridcraft: {} + ui-plugins/invoice-maker: + dependencies: + '@modelcontextprotocol/sdk': + specifier: 1.29.0 + version: 1.29.0(zod@4.6.5) + exceljs: + specifier: 4.4.0 + version: 4.4.0 + fontkit: + specifier: 2.0.4 + version: 2.0.4 + pdf-lib: + specifier: 1.17.1 + version: 1.17.1 + zod: + specifier: ^4.6.5 + version: 4.6.5 + devDependencies: + '@modelcontextprotocol/core': + specifier: 2.0.0 + version: 2.0.0 + '@modelcontextprotocol/ext-apps': + specifier: 2.0.0 + version: 2.0.0(@modelcontextprotocol/client@2.2.0)(@modelcontextprotocol/core@2.0.0)(@modelcontextprotocol/server@2.0.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(zod@4.6.5) + '@types/node': + specifier: 25.5.0 + version: 25.5.0 + esbuild: + specifier: ^0.25.12 + version: 0.25.12 + playwright-core: + specifier: 1.59.1 + version: 1.59.1 + typescript: + specifier: 6.0.2 + version: 6.0.2 + vitest: + specifier: 4.1.4 + version: 4.1.4(@opentelemetry/api@1.9.1)(@types/node@25.5.0)(msw@2.13.3(@types/node@25.5.0)(typescript@6.0.2))(vite@8.3.1(@types/node@25.5.0)(esbuild@0.25.12)(jiti@2.6.1)(tsx@4.21.0)(yaml@2.9.0)) + ui-plugins/jupyter-notebook: dependencies: '@modelcontextprotocol/sdk': @@ -745,6 +785,12 @@ packages: resolution: {integrity: sha512-nULYsQxkWHnbmHvcs+efMkJ4/9TtvNyFeLyHdeGxW0zHs6P+jYVqcRff9A6Vq9w9JXeDRnRh2VKvTtS19GW2qA==} engines: {node: '>=10'} + '@fast-csv/format@4.3.5': + resolution: {integrity: sha512-8iRn6QF3I8Ak78lNAa+Gdl5MJJBM5vRHivFtMRUWINdevNo00K7OXxS2PshawLKTejVwieIlPmK5YlLu6w4u8A==} + + '@fast-csv/parse@4.3.6': + resolution: {integrity: sha512-uRsLYksqpbDmWaSmzvJcuApSEe38+6NQZBUsuAyMZKqHxH0g1wcJgsKUvN3WC8tewaqFjBMMGrkHmC+T7k8LvA==} + '@floating-ui/core@1.7.5': resolution: {integrity: sha512-1Ih4WTWyw0+lKyFMcBHGbb5U5FtuHJuujoyyr5zTaWS5EYMeT6Jb2AuDeftsCsEuchO+mM2ij5+q9crhydzLhQ==} @@ -1362,6 +1408,12 @@ packages: cpu: [x64] os: [win32] + '@pdf-lib/standard-fonts@1.0.0': + resolution: {integrity: sha512-hU30BK9IUN/su0Mn9VdlVKsWBS6GyhVfqjwl1FjZN4TxP6cCw0jP2w7V3Hf5uX7M0AZJ16vey9yE0ny7Sa59ZA==} + + '@pdf-lib/upng@1.0.1': + resolution: {integrity: sha512-dQK2FUMQtowVP00mtIksrlZhdFXQZPC+taih1q4CvPZ5vqdxR/LKBaFg0oAfzd1GlHZXXSPdQfzQnt+ViGvEIQ==} + '@radix-ui/primitive@1.0.0': resolution: {integrity: sha512-3e7rn8FDMin4CgeL7Z/49smCA3rFYY3Ha2rUQ7HRWFadS5iCRw08ZgVT1LaNTCNqgvrUiyczLflrVrF0SRQtNA==} @@ -1875,6 +1927,9 @@ packages: '@types/geojson@7946.0.16': resolution: {integrity: sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==} + '@types/node@14.18.63': + resolution: {integrity: sha512-fAtCfv4jJg+ExtXhvCkCqUKZ+4ok/JQk01qDKhL5BDDoS3AxKXhV5/MAVUZyQnSEd2GT92fkgZl0pz0Q0AzcIQ==} + '@types/node@22.20.4': resolution: {integrity: sha512-zJRE40jpHtKqE/C4fgHrAKQLJuSpzEnP9ff9Y7YtoR3Wd2pwqzlekDeEuUQXjRd+QCYnVnNwuJYmhdk9XV8gvA==} @@ -2018,36 +2073,109 @@ packages: resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} engines: {node: '>= 8'} + archiver-utils@2.1.0: + resolution: {integrity: sha512-bEL/yUb/fNNiNTuUz979Z0Yg5L+LzLxGJz8x79lYmR54fmTIb6ob/hNQgkQnIUDWIFjZVQwl9Xs356I6BAMHfw==} + engines: {node: '>= 6'} + + archiver-utils@3.0.4: + resolution: {integrity: sha512-KVgf4XQVrTjhyWmx6cte4RxonPLR9onExufI1jhvw/MQ4BB6IsZD5gT8Lq+u/+pRkWna/6JoHpiQioaqFP5Rzw==} + engines: {node: '>= 10'} + + archiver@5.3.2: + resolution: {integrity: sha512-+25nxyyznAXF7Nef3y0EbBeqmGZgeN/BxHX29Rs39djAfaFalmQ89SE6CWyDCHzGL0yt/ycBtNOmGTW0FyGWNw==} + engines: {node: '>= 10'} + aria-hidden@1.2.6: resolution: {integrity: sha512-ik3ZgC9dY/lYVVM++OISsaYDeg1tb0VtP5uL3ouh1koGOaUMDPpbFIei4JkFimWUFPn90sbMNMXQAIVOlnYKJA==} engines: {node: '>=10'} + array-buffer-byte-length@1.0.2: + resolution: {integrity: sha512-LHE+8BuR7RYGDKvnrmcuSq3tDcKv9OFEXQt/HpbZhY7V6h0zlUXutnAD82GiFx9rdieCMjkvtcsPqBwgUl1Iiw==} + engines: {node: '>= 0.4'} + + arraybuffer.prototype.slice@1.0.4: + resolution: {integrity: sha512-BNoCY6SXXPQ7gF2opIP4GBE+Xw7U+pHMYKuzjgCN3GwiaIR09UUeKfheyIry77QtrCBlC0KK0q5/TER/tYh3PQ==} + engines: {node: '>= 0.4'} + assertion-error@2.0.1: resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} engines: {node: '>=12'} + async-function@1.0.0: + resolution: {integrity: sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA==} + engines: {node: '>= 0.4'} + + async@3.2.6: + resolution: {integrity: sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==} + + available-typed-arrays@1.0.7: + resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==} + engines: {node: '>= 0.4'} + + balanced-match@1.0.2: + resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} + base64-arraybuffer@1.0.2: resolution: {integrity: sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==} engines: {node: '>= 0.6.0'} + base64-js@1.5.1: + resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + + big-integer@1.6.52: + resolution: {integrity: sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg==} + engines: {node: '>=0.6'} + binary-extensions@2.3.0: resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} engines: {node: '>=8'} + binary@0.3.0: + resolution: {integrity: sha512-D4H1y5KYwpJgK8wk1Cue5LLPgmwHKYSChkbspQg5JtVuR5ulGckxfR62H3AE9UDkdMC8yyXlqYihuz3Aqg2XZg==} + bind-event-listener@3.0.0: resolution: {integrity: sha512-PJvH288AWQhKs2v9zyfYdPzlPqf5bXbGMmhmUIY9x4dAUGIWgomO771oBQNwJnMQSnUIXhKu6sgzpBRXTlvb8Q==} + bl@4.1.0: + resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} + + bluebird@3.4.7: + resolution: {integrity: sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA==} + body-parser@2.2.2: resolution: {integrity: sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==} engines: {node: '>=18'} + brace-expansion@1.1.22: + resolution: {integrity: sha512-CKLDTuSsN0+r1ThM0WkzzBI7dnPI6xEGfa/JnVYIK9JNBA1N1NyPwXVHor//NKD/y3sDxp764sZdLhFK7pH8XQ==} + + brace-expansion@2.1.8: + resolution: {integrity: sha512-BnlDzDYQoplTsZSvPi86CNzmbcb07X8ufR8fk1zivaiEJlXJkiq1MQyDCVmlWcsWbj6aWXqHnrwwevbrm/Saig==} + braces@3.0.3: resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} engines: {node: '>=8'} + brotli@1.3.3: + resolution: {integrity: sha512-oTKjJdShmDuGW94SyyaoQvAjf30dZaHnjJ8uAF+u2/vGJkJbJPJAT1gDiOJP5v1Zb6f9KEyW/1HpuaWIXtGHPg==} + browser-fs-access@0.29.1: resolution: {integrity: sha512-LSvVX5e21LRrXqVMhqtAwj5xPgDb+fXAIH80NsnCQ9xuZPs2xWsOREi24RKgZa1XOiQRbcmVrv87+ulOKsgjxw==} + buffer-crc32@0.2.13: + resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==} + + buffer-indexof-polyfill@1.0.2: + resolution: {integrity: sha512-I7wzHwA3t1/lwXQh+A5PbNvJxgfo5r3xulgpYDB5zckTu/Z9oUK9biouBKQUjEqzaz3HnAT6TYoovmE+GqSf7A==} + engines: {node: '>=0.10'} + + buffer@5.7.1: + resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} + + buffers@0.1.1: + resolution: {integrity: sha512-9q/rDEGSb/Qsvv2qvzIzdluL5k7AaJOTrw23z9reQthrbF7is4CtlT0DXyO1oei2DCp4uojjzQ7igaSHp1kAEQ==} + engines: {node: '>=0.2.0'} + bun@1.3.11: resolution: {integrity: sha512-AvXWYFO6j/ZQ7bhGm4X6eilq2JHsDVC90ZM32k2B7/srhC2gs3Sdki1QTbwrdRCo8o7eT+167vcB1yzOvPdbjA==} cpu: [arm64, x64] @@ -2062,6 +2190,10 @@ packages: resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==} engines: {node: '>= 0.4'} + call-bind@1.0.9: + resolution: {integrity: sha512-a/hy+pNsFUTR+Iz8TCJvXudKVLAnz/DyeSUo10I5yvFDQJBFU2s9uqQpoSrJlroHUKoKqzg+epxyP9lqFdzfBQ==} + engines: {node: '>= 0.4'} + call-bound@1.0.4: resolution: {integrity: sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==} engines: {node: '>= 0.4'} @@ -2080,6 +2212,9 @@ packages: resolution: {integrity: sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==} engines: {node: '>=18'} + chainsaw@0.1.0: + resolution: {integrity: sha512-75kWfWt6MEKNC8xYXIdRpDehRYY/tNSgwKaJq+dbbDcxORuVrrQ+SEHoWsniVn9XPYfP4gmdWIeDk/4YNp1rNQ==} + chevrotain-allstar@0.3.1: resolution: {integrity: sha512-b7g+y9A0v4mxCW1qUhf3BSVPg+/NvGErk/dOkrDaHA0nQIQGAtrOjlX//9OQtRlSCy+x9rfB5N8yC71lH1nvMw==} peerDependencies: @@ -2109,6 +2244,10 @@ packages: resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} engines: {node: '>=12'} + clone@2.1.2: + resolution: {integrity: sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==} + engines: {node: '>=0.8'} + clsx@1.1.1: resolution: {integrity: sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA==} engines: {node: '>=6'} @@ -2136,6 +2275,13 @@ packages: resolution: {integrity: sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==} engines: {node: '>= 12'} + compress-commons@4.1.2: + resolution: {integrity: sha512-D3uMHtGc/fcO1Gt1/L7i1e33VOvD4A9hfQLP+6ewd+BvG/gQ84Yh4oftEhAdjSMgBgwGL+jsppT7JYNpo6MHHg==} + engines: {node: '>= 10'} + + concat-map@0.0.1: + resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} + confbox@0.1.8: resolution: {integrity: sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==} @@ -2182,6 +2328,15 @@ packages: resolution: {integrity: sha512-kucVIjOmMc1f0tv53BJ/5WIX+MGLcKuoBhnGqQrgKJNqLByb/sVMWfW/Aw6hw0jgcqjJ2pi9E5y32zOIpaUlsA==} engines: {node: '>=0.8'} + crc-32@1.2.2: + resolution: {integrity: sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==} + engines: {node: '>=0.8'} + hasBin: true + + crc32-stream@4.0.3: + resolution: {integrity: sha512-NT7w2JVU7DFroFdYkeq8cywxrgjPHWkdX1wjpRQXPX5Asews3tA+Ght6lddQO5Mkumffp3X7GEqku3epj2toIw==} + engines: {node: '>= 10'} + crelt@1.0.7: resolution: {integrity: sha512-aK6BbWfhf4U/wCcLHKPJl/xa6VkVstRaPywWtMKGwuOLc/wZTyQYuoxgvZnNsBvv7Kg3YTBQYYBCggcviQczuA==} @@ -2369,6 +2524,18 @@ packages: dagre-d3-es@7.0.14: resolution: {integrity: sha512-P4rFMVq9ESWqmOgK+dlXvOtLwYg0i7u0HBGJER0LZDJT2VHIPAMZ/riPxqJceWMStH5+E61QxFra9kIS3AqdMg==} + data-view-buffer@1.0.2: + resolution: {integrity: sha512-EmKO5V3OLXh1rtK2wgXRansaK1/mtVdTUEiEI0W8RkvgT05kfxaH29PliLnpLP73yYO6142Q72QNa8Wx/A5CqQ==} + engines: {node: '>= 0.4'} + + data-view-byte-length@1.0.2: + resolution: {integrity: sha512-tuhGbE6CfTM9+5ANGf+oQb72Ky/0+s3xKUpHvShfiz2RxMFgFPjsXuRLBVMtvMs15awe45SRb83D6wH4ew6wlQ==} + engines: {node: '>= 0.4'} + + data-view-byte-offset@1.0.1: + resolution: {integrity: sha512-BS8PfmtDGnrgYdOonGZQdLZslWIeCGFP9tpan0hi1Co2Zr2NKADsvGYA8XxuG/4UWgJ6Cjtv+YJnB6MM69QGlQ==} + engines: {node: '>= 0.4'} + dayjs@1.11.20: resolution: {integrity: sha512-YbwwqR/uYpeoP4pu043q+LTDLFBLApUP6VxRihdfNTqu4ubqMlGDLd6ErXhEgsyvY0K6nCs7nggYumAN+9uEuQ==} @@ -2381,6 +2548,14 @@ packages: supports-color: optional: true + define-data-property@1.1.4: + resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==} + engines: {node: '>= 0.4'} + + define-properties@1.2.1: + resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} + engines: {node: '>= 0.4'} + defu@6.1.7: resolution: {integrity: sha512-7z22QmUWiQ/2d0KkdYmANbRUVABpZ9SNYyH5vx6PZ+nE5bcC0l7uFvEfHlyld/HcGBFTL536ClDt3DEcSlEJAQ==} @@ -2401,6 +2576,9 @@ packages: detect-node-es@1.1.0: resolution: {integrity: sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ==} + dfa@1.2.0: + resolution: {integrity: sha512-ED3jP8saaweFTjeGX8HQPjeC1YYyZs98jGNZx6IiBvxW7JG5v492kamAQB3m2wop07CvU/RQmzcKr6bgcC5D/Q==} + diff@8.0.4: resolution: {integrity: sha512-DPi0FmjiSU5EvQV0++GFDOJ9ASQUVFh5kD+OzOnYdi7n3Wpm9hWWGfB/O2blfHcMVTL5WkQXSnRiK9makhrcnw==} engines: {node: '>=0.3.1'} @@ -2412,6 +2590,9 @@ packages: resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} engines: {node: '>= 0.4'} + duplexer2@0.1.4: + resolution: {integrity: sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==} + ee-first@1.1.1: resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} @@ -2422,10 +2603,21 @@ packages: resolution: {integrity: sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==} engines: {node: '>= 0.8'} + end-of-stream@1.4.5: + resolution: {integrity: sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==} + entities@7.0.1: resolution: {integrity: sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==} engines: {node: '>=0.12'} + es-abstract-get@1.0.0: + resolution: {integrity: sha512-6PMWXpdhshVvFp+FoWYs1EvG1Nj0tvk0dZM+XcK0xMEM1czRVcP6ohqPWHy6qPagSpC8j4+p89WXlT+xXJs/fg==} + engines: {node: '>= 0.4'} + + es-abstract@1.24.2: + resolution: {integrity: sha512-2FpH9Q5i2RRwyEP1AylXe6nYLR5OhaJTZwmlcP0dL/+JCbgg7yyEo/sEK6HeGZRf3dFpWwThaRHVApXSkW3xeg==} + engines: {node: '>= 0.4'} + es-define-property@1.0.1: resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==} engines: {node: '>= 0.4'} @@ -2441,6 +2633,18 @@ packages: resolution: {integrity: sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==} engines: {node: '>= 0.4'} + es-object-atoms@1.1.2: + resolution: {integrity: sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==} + engines: {node: '>= 0.4'} + + es-set-tostringtag@2.1.0: + resolution: {integrity: sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==} + engines: {node: '>= 0.4'} + + es-to-primitive@1.3.4: + resolution: {integrity: sha512-yPDz7wqpg1/mmHLmS3tcfTfbw5f1eryXvyghYBffGdERwe+mV7ZcWzTR8LR17Kvqt3qfPurjlonmnq3MKXIOXw==} + engines: {node: '>= 0.4'} + es-toolkit@1.46.1: resolution: {integrity: sha512-5eNtXOs3tbfxXOj04tjjseeWkRWaoCjdEI+96DgwzZoe6c9juL49pXlzAFTI72aWC9Y8p7168g6XIKjh7k6pyQ==} @@ -2475,10 +2679,6 @@ packages: resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==} engines: {node: '>= 0.6'} - eventsource-parser@3.1.0: - resolution: {integrity: sha512-kJezFj9YFAMLeORyi7aCLxLbD5/qWMQnoMVlVPyHIll7lgRJCc3JVln9Vgl9nwQi0YkMnhdGTMNn7CkRRAptMg==} - engines: {node: '>=18.0.0'} - eventsource-parser@3.1.1: resolution: {integrity: sha512-EKN1vKAMcZ8MlYMpaNuxN6R9yakzH6uajHcHVTqWJzvu5pWw9DyhbP35HH8MVBQ+dZjAfDxk+A8NiR9KWaXiyQ==} engines: {node: '>=18.0.0'} @@ -2487,6 +2687,10 @@ packages: resolution: {integrity: sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==} engines: {node: '>=18.0.0'} + exceljs@4.4.0: + resolution: {integrity: sha512-XctvKaEMaj1Ii9oDOqbW/6e1gXknSY4g/aLCDicOXqBE4M0nRWkUu0PTp++UPNzoFY12BNHMfs/VadKIS6llvg==} + engines: {node: '>=8.3.0'} + expect-type@1.4.0: resolution: {integrity: sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==} engines: {node: '>=12.0.0'} @@ -2504,6 +2708,10 @@ packages: resolution: {integrity: sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==} engines: {node: '>= 18'} + fast-csv@4.3.6: + resolution: {integrity: sha512-2RNSpuwwsJGP0frGsOmTb9oUF+VkFSM4SyLTDgwf2ciHWTarN0lQTC+F2f/t5J9QjW+c65VFIAAu85GsvMIusw==} + engines: {node: '>=10.0.0'} + fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} @@ -2536,9 +2744,16 @@ packages: font-family-papandreou@0.2.0-patch2: resolution: {integrity: sha512-l/YiRdBSH/eWv6OF3sLGkwErL+n0MqCICi9mppTZBOCL5vixWGDqCYvRcuxB2h7RGCTzaTKOHT2caHvCXQPRlw==} + fontkit@2.0.4: + resolution: {integrity: sha512-syetQadaUEDNdxdugga9CpEYVaQIxOwk7GlwZWWZ19//qW4zE5bknOKeMBDYAASwnpaSHKJITRLMF9m1fp3s6g==} + fontoxpath@3.34.0: resolution: {integrity: sha512-7FgBQRohn4WR/2eVdYqZtKBFZkJNaiP4kGdfqS6bAg465og05ixGA2OgfMdxsO1mnX67+64JX/8JKclVqS+bzA==} + for-each@0.3.5: + resolution: {integrity: sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==} + engines: {node: '>= 0.4'} + forwarded@0.2.0: resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==} engines: {node: '>= 0.6'} @@ -2551,14 +2766,32 @@ packages: resolution: {integrity: sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==} engines: {node: '>= 0.8'} + fs-constants@1.0.0: + resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} + + fs.realpath@1.0.0: + resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} + fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} os: [darwin] + fstream@1.0.12: + resolution: {integrity: sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==} + engines: {node: '>=0.6'} + deprecated: This package is no longer supported. + function-bind@1.1.2: resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} + function.prototype.name@1.2.0: + resolution: {integrity: sha512-jObKIik1P2QjPHP5nz5BaOtUlfgS0fWo8IUByNXkM+o+02sJOi94em77GwJKQSJ3gfPHdgzLNrHc1uokV4P/ew==} + engines: {node: '>= 0.4'} + + functions-have-names@1.2.3: + resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==} + fuzzy@0.1.3: resolution: {integrity: sha512-/gZffu4ykarLrCiP3Ygsa86UAo1E5vEVlvTrpkKywXSbP9Xhln3oSp9QSV57gEq3JFFpGJ4GZ+5zdEp3FcUh4w==} engines: {node: '>= 0.6.0'} @@ -2566,6 +2799,10 @@ packages: fzstd@0.1.1: resolution: {integrity: sha512-dkuVSOKKwh3eas5VkJy1AW1vFpet8TA/fGmVA5krThl8YcOVE/8ZIoEA1+U1vEn5ckxxhLirSdY837azmbaNHA==} + generator-function@2.0.1: + resolution: {integrity: sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g==} + engines: {node: '>= 0.4'} + get-caller-file@2.0.5: resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} engines: {node: 6.* || 8.* || >= 10.*} @@ -2582,6 +2819,10 @@ packages: resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==} engines: {node: '>= 0.4'} + get-symbol-description@1.1.0: + resolution: {integrity: sha512-w9UMqWwJxHNOvoNzSJ2oPF5wvYcvP7jUvYzhp67yEhTi17ZDBBC1z9pTdGuzjD+EFIqLSYRweZjqfiPzQ06Ebg==} + engines: {node: '>= 0.4'} + get-tsconfig@4.13.7: resolution: {integrity: sha512-7tN6rFgBlMgpBML5j8typ92BKFi2sFQvIdpAqLA2beia5avZDrMs0FLZiM5etShWq5irVyGcGMEA1jcDaK7A/Q==} @@ -2589,6 +2830,14 @@ packages: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} + glob@7.2.3: + resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} + deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me + + globalthis@1.0.4: + resolution: {integrity: sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==} + engines: {node: '>= 0.4'} + glur@1.1.2: resolution: {integrity: sha512-l+8esYHTKOx2G/Aao4lEQ0bnHWg4fWtJbVoZZT9Knxi01pB8C80BR85nONLFwkkQoFRCmXY+BUcGZN3yZ2QsRA==} @@ -2596,6 +2845,9 @@ packages: resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==} engines: {node: '>= 0.4'} + graceful-fs@4.2.12: + resolution: {integrity: sha512-iuyGF2E4oafQfPsRrG2wtY2ILupMhvtdrhzrxB+0VcjsPpSPttpfYdjnGFGsTi5MaJFjI1jOKHPQ6UTbTj9TAw==} + graphql@16.13.2: resolution: {integrity: sha512-5bJ+nf/UCpAjHM8i06fl7eLyVC9iuNAjm9qzkiu2ZGhM0VscSvS6WDPfAwkdkBuoXGM9FJSbKl6wylMwP9Ktig==} engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0} @@ -2603,14 +2855,33 @@ packages: hachure-fill@0.5.2: resolution: {integrity: sha512-3GKBOn+m2LX9iq+JC1064cSFprJY4jL1jCXTcpnfER5HYE2l/4EfWSGzkPa/ZDBmYI0ZOEj5VHV/eKnPGkHuOg==} + has-bigints@1.1.0: + resolution: {integrity: sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==} + engines: {node: '>= 0.4'} + + has-property-descriptors@1.0.2: + resolution: {integrity: sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==} + + has-proto@1.2.0: + resolution: {integrity: sha512-KIL7eQPfHQRC8+XluaIw7BHUwwqL19bQn4hzNgdr+1wXoU0KKj6rufu47lhY7KbJR2C6T6+PfyN0Ea7wkSS+qQ==} + engines: {node: '>= 0.4'} + has-symbols@1.1.0: resolution: {integrity: sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==} engines: {node: '>= 0.4'} + has-tostringtag@1.0.2: + resolution: {integrity: sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==} + engines: {node: '>= 0.4'} + hasown@2.0.2: resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} engines: {node: '>= 0.4'} + hasown@2.0.4: + resolution: {integrity: sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==} + engines: {node: '>= 0.4'} + headers-polyfill@4.0.3: resolution: {integrity: sha512-IScLbePpkvO846sIwOtOTDjutRMWdXdJmXdMvk6gCBHxFO8d+QKOQedyZSxFTTFYRSmlgSTDtXqqq4pcenBXLQ==} @@ -2637,6 +2908,9 @@ packages: resolution: {integrity: sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==} engines: {node: '>=0.10.0'} + ieee754@1.2.1: + resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} + image-blob-reduce@3.0.1: resolution: {integrity: sha512-/VmmWgIryG/wcn4TVrV7cC4mlfUC/oyiKIfSg5eVM3Ten/c1c34RJhMYKCWTnoSMHSqXLt3tsrBR4Q2HInvN+Q==} @@ -2654,9 +2928,17 @@ packages: immutable@4.3.9: resolution: {integrity: sha512-ObHy4YN7ycwZOUCLI1/6svfyAFu7vL8RhAvVu/bh/RZW9EPlOyDaQ9jDQWCtdqzaXUjgXZCW1migtHE7YI7UGQ==} + inflight@1.0.6: + resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} + deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. + inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} + internal-slot@1.1.0: + resolution: {integrity: sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw==} + engines: {node: '>= 0.4'} + internmap@1.0.1: resolution: {integrity: sha512-lDB5YccMydFBtasVtxnZ3MRBHuaoE8GKsppq+EchKL2U4nK/DmEpPHNH8MZe5HkMtpSiTSOZwfN0tzYjO/lJEw==} @@ -2675,25 +2957,77 @@ packages: resolution: {integrity: sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==} engines: {node: '>= 0.10'} + is-array-buffer@3.0.5: + resolution: {integrity: sha512-DDfANUiiG2wC1qawP66qlTugJeL5HyzMpfr8lLK+jMQirGzNod0B12cFB/9q838Ru27sBwfw78/rdoU7RERz6A==} + engines: {node: '>= 0.4'} + + is-async-function@2.1.1: + resolution: {integrity: sha512-9dgM/cZBnNvjzaMYHVoxxfPj2QXt22Ev7SuuPrs+xav0ukGB0S6d4ydZdEiM48kLx5kDV+QBPrpVnFyefL8kkQ==} + engines: {node: '>= 0.4'} + + is-bigint@1.1.0: + resolution: {integrity: sha512-n4ZT37wG78iz03xPRKJrHTdZbe3IicyucEtdRsV5yglwc3GyUfbAfpSeD0FJ41NbUNSt5wbhqfp1fS+BgnvDFQ==} + engines: {node: '>= 0.4'} + is-binary-path@2.1.0: resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} engines: {node: '>=8'} + is-boolean-object@1.2.2: + resolution: {integrity: sha512-wa56o2/ElJMYqjCjGkXri7it5FbebW5usLw/nPmCMs5DeZ7eziSYZhSmPRn0txqeW4LnAmQQU7FgqLpsEFKM4A==} + engines: {node: '>= 0.4'} + + is-callable@1.2.7: + resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} + engines: {node: '>= 0.4'} + + is-data-view@1.0.2: + resolution: {integrity: sha512-RKtWF8pGmS87i2D6gqQu/l7EYRlVdfzemCJN/P3UOs//x1QE7mfhvzHIApBTRf7axvT6DMGwSwBXYCT0nfB9xw==} + engines: {node: '>= 0.4'} + + is-date-object@1.1.0: + resolution: {integrity: sha512-PwwhEakHVKTdRNVOw+/Gyh0+MzlCl4R6qKvkhuvLtPMggI1WAHt9sOwZxQLSGpUaDnrdyDsomoRgNnCfKNSXXg==} + engines: {node: '>= 0.4'} + + is-document.all@1.0.0: + resolution: {integrity: sha512-+XSoyS05OdBbhFuELhgTCpFNHkpBOJqtsZfUFFpe5QTw+9Sjbh8zitxhQkYAo6wV7e1Vb8cAPvpCk9jGam/82g==} + engines: {node: '>= 0.4'} + is-extglob@2.1.1: resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} engines: {node: '>=0.10.0'} + is-finalizationregistry@1.1.1: + resolution: {integrity: sha512-1pC6N8qWJbWoPtEjgcL2xyhQOP491EQjeUo3qTKcmV8YSDDJrOepfG8pcC7h/QgnQHYSv0mJ3Z/ZWxmatVrysg==} + engines: {node: '>= 0.4'} + is-fullwidth-code-point@3.0.0: resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} engines: {node: '>=8'} + is-generator-function@1.1.2: + resolution: {integrity: sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA==} + engines: {node: '>= 0.4'} + is-glob@4.0.3: resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} engines: {node: '>=0.10.0'} + is-map@2.0.3: + resolution: {integrity: sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw==} + engines: {node: '>= 0.4'} + + is-negative-zero@2.0.3: + resolution: {integrity: sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw==} + engines: {node: '>= 0.4'} + is-node-process@1.2.0: resolution: {integrity: sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw==} + is-number-object@1.1.1: + resolution: {integrity: sha512-lZhclumE1G6VYD8VHe35wFaIif+CTy5SJIi5+3y4psDgWu4wPDoBhF8NxUOinEc7pHgiTsT6MaBb92rKhhD+Xw==} + engines: {node: '>= 0.4'} + is-number@7.0.0: resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} engines: {node: '>=0.12.0'} @@ -2701,9 +3035,48 @@ packages: is-promise@4.0.0: resolution: {integrity: sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==} + is-regex@1.2.1: + resolution: {integrity: sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==} + engines: {node: '>= 0.4'} + + is-set@2.0.3: + resolution: {integrity: sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg==} + engines: {node: '>= 0.4'} + + is-shared-array-buffer@1.0.4: + resolution: {integrity: sha512-ISWac8drv4ZGfwKl5slpHG9OwPNty4jOWPRIhBpxOoD+hqITiwuipOQ2bNthAzwA3B4fIjO4Nln74N0S9byq8A==} + engines: {node: '>= 0.4'} + + is-string@1.1.1: + resolution: {integrity: sha512-BtEeSsoaQjlSPBemMQIrY1MY0uM6vnS1g5fmufYOtnxLGUZM2178PKbhsk7Ffv58IX+ZtcvoGwccYsh0PglkAA==} + engines: {node: '>= 0.4'} + + is-symbol@1.1.1: + resolution: {integrity: sha512-9gGx6GTtCQM73BgmHQXfDmLtfjjTUDSyoxTCbp5WtoixAhfgsDirWIcVQ/IHpvI5Vgd5i/J5F7B9cN/WlVbC/w==} + engines: {node: '>= 0.4'} + + is-typed-array@1.1.15: + resolution: {integrity: sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==} + engines: {node: '>= 0.4'} + + is-weakmap@2.0.2: + resolution: {integrity: sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==} + engines: {node: '>= 0.4'} + + is-weakref@1.1.1: + resolution: {integrity: sha512-6i9mGWSlqzNMEqpCp93KwRS1uUOodk2OJ6b+sq7ZPDSy2WuI5NFIxp/254TytR8ftefexkWn5xNiHUNpPOfSew==} + engines: {node: '>= 0.4'} + + is-weakset@2.0.4: + resolution: {integrity: sha512-mfcwb6IzQyOKTs84CQMrOwW4gQcaTOAWJ0zzJCl2WSPDrWk/OzDaImWFH3djXhb24g4eudZfLRozAvPGw4d9hQ==} + engines: {node: '>= 0.4'} + isarray@1.0.0: resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} + isarray@2.0.5: + resolution: {integrity: sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==} + isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} @@ -2714,9 +3087,6 @@ packages: jose@6.2.12: resolution: {integrity: sha512-9NiFmJEex0sy2Dk58j2UGBSHgUs2ypF9eZSu4L6vjOX3Dp96Sw1F3uL+H+D1sx02jZZdzUT0HgvCy59CuvXcWw==} - jose@6.2.2: - resolution: {integrity: sha512-d7kPDd34KO/YnzaDOlikGpOurfF0ByC2sEV4cANCtdqLlTfBlw2p14O/5d/zv40gJPbIQxfES3nSx1/oYNyuZQ==} - jotai-scope@0.7.2: resolution: {integrity: sha512-Gwed97f3dDObrO43++2lRcgOqw4O2sdr4JCjP/7eHK1oPACDJ7xKHGScpJX9XaflU+KBHXF+VhwECnzcaQiShg==} peerDependencies: @@ -2775,6 +3145,10 @@ packages: layout-base@2.0.1: resolution: {integrity: sha512-dp3s92+uNI1hWIpPGH3jK2kxE2lMjdXdr+DH8ynZHpd6PUlH6x6cbuXnoMmiNumznqaNO31xu9e79F0uuZ0JFg==} + lazystream@1.0.1: + resolution: {integrity: sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==} + engines: {node: '>= 0.6.3'} + lie@3.3.0: resolution: {integrity: sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==} @@ -2855,6 +3229,9 @@ packages: lines-and-columns@1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} + listenercount@1.0.1: + resolution: {integrity: sha512-3mk/Zag0+IJxeDrxSgaDPy4zZ3w05PRZeJNnlWhzFz5OkX49J4krc+A8X2d2M69vGMBEX0uyl8M+W+8gH+kBqQ==} + lodash-es@4.17.21: resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==} @@ -2864,9 +3241,49 @@ packages: lodash.debounce@4.0.8: resolution: {integrity: sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==} + lodash.defaults@4.2.0: + resolution: {integrity: sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==} + + lodash.difference@4.5.0: + resolution: {integrity: sha512-dS2j+W26TQ7taQBGN8Lbbq04ssV3emRw4NY58WErlTO29pIqS0HmoT5aJ9+TUQ1N3G+JOZSji4eugsWwGp9yPA==} + + lodash.escaperegexp@4.1.2: + resolution: {integrity: sha512-TM9YBvyC84ZxE3rgfefxUWiQKLilstD6k7PTGt6wfbtXF8ixIJLOL3VYyV/z+ZiPLsVxAsKAFVwWlWeb2Y8Yyw==} + + lodash.flatten@4.4.0: + resolution: {integrity: sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g==} + + lodash.groupby@4.6.0: + resolution: {integrity: sha512-5dcWxm23+VAoz+awKmBaiBvzox8+RqMgFhi7UvX9DHZr2HdxHXM/Wrf8cfKpsW37RNrvtPn6hSwNqurSILbmJw==} + + lodash.isboolean@3.0.3: + resolution: {integrity: sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==} + + lodash.isequal@4.5.0: + resolution: {integrity: sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==} + deprecated: This package is deprecated. Use require('node:util').isDeepStrictEqual instead. + + lodash.isfunction@3.0.9: + resolution: {integrity: sha512-AirXNj15uRIMMPihnkInB4i3NHeb4iBtNg9WRWuK2o31S+ePwwNmDPaTL3o7dTJ+VXNZim7rFs4rxN4YU1oUJw==} + + lodash.isnil@4.0.0: + resolution: {integrity: sha512-up2Mzq3545mwVnMhTDMdfoG1OurpA/s5t88JmQX809eH3C8491iu2sfKhTfhQtKY78oPNhiaHJUpT/dUDAAtng==} + + lodash.isplainobject@4.0.6: + resolution: {integrity: sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==} + + lodash.isundefined@3.0.1: + resolution: {integrity: sha512-MXB1is3s899/cD8jheYYE2V9qTHwKvt+npCwpD+1Sxm3Q3cECXCiYHjeHWXNwr6Q0SOBPrYUDxendrO6goVTEA==} + lodash.throttle@4.1.1: resolution: {integrity: sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==} + lodash.union@4.6.0: + resolution: {integrity: sha512-c4pB2CdGrGdjMKYLA+XiRDO7Y0PRQbm/Gzg8qMj+QH+pFVAoTp5sBpO0odL3FjoPCGjK96p6qsP+yQoiLoOBcw==} + + lodash.uniq@4.5.0: + resolution: {integrity: sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==} + magic-string@0.30.21: resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==} @@ -2906,6 +3323,20 @@ packages: resolution: {integrity: sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==} engines: {node: '>=18'} + minimatch@3.1.5: + resolution: {integrity: sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==} + + minimatch@5.1.9: + resolution: {integrity: sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==} + engines: {node: '>=10'} + + minimist@1.2.8: + resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} + + mkdirp@0.5.6: + resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==} + hasBin: true + mlly@1.8.2: resolution: {integrity: sha512-d+ObxMQFmbt10sretNDytwt85VrbkhhUA/JBGm1MPaWJ65Cl4wOgLaB1NYvJSZ0Ef03MMEU/0xpPMXUIQ29UfA==} @@ -2974,6 +3405,14 @@ packages: resolution: {integrity: sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==} engines: {node: '>= 0.4'} + object-keys@1.1.1: + resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==} + engines: {node: '>= 0.4'} + + object.assign@4.1.7: + resolution: {integrity: sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw==} + engines: {node: '>= 0.4'} + obug@2.2.1: resolution: {integrity: sha512-XrsrhT5sybtKI6wakr2SPOlGZWWYbUXZ7a0jT8/QOeAPau+1X/bSegNe5YR75oJmEZQbKningirmGOEJCIk61Q==} engines: {node: '>=12.20.0'} @@ -3001,6 +3440,10 @@ packages: outvariant@1.4.3: resolution: {integrity: sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA==} + own-keys@1.0.2: + resolution: {integrity: sha512-19YVAg7T+WTrxggPukVq7DjTv6+PJ867TmhCvBsYwmbFCsZd344rq2Ld1p0wo8f8Qrrhgp82c6FJRqdXWtSEhg==} + engines: {node: '>= 0.4'} + oxfmt@0.41.0: resolution: {integrity: sha512-sKLdJZdQ3bw6x9qKiT7+eID4MNEXlDHf5ZacfIircrq6Qwjk0L6t2/JQlZZrVHTXJawK3KaMuBoJnEJPcqCEdg==} engines: {node: ^20.19.0 || >=22.12.0} @@ -3019,6 +3462,9 @@ packages: package-manager-detector@1.6.0: resolution: {integrity: sha512-61A5ThoTiDG/C8s8UMZwSorAGwMJ0ERVGj2OjoW5pAalsNOg15+iQiPzrLJ4jhZ1HJzmC2PIHT2oEiH3R5fzNA==} + pako@0.2.9: + resolution: {integrity: sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA==} + pako@1.0.11: resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==} @@ -3035,6 +3481,10 @@ packages: path-data-parser@0.1.0: resolution: {integrity: sha512-NOnmBpt5Y2RWbuv0LMzsayp3lVylAHLPUTut412ZA3l+C4uw4ZVkQbjShYCQ8TCpUMdPapr4YjUqLYD6v68j+w==} + path-is-absolute@1.0.1: + resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} + engines: {node: '>=0.10.0'} + path-key@3.1.1: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} @@ -3048,6 +3498,9 @@ packages: pathe@2.0.3: resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} + pdf-lib@1.17.1: + resolution: {integrity: sha512-V/mpyJAoTsN4cnP31vc0wfNA1+p20evqqnap0KLoRUN0Yk/p3wN52DOEsL4oBFcLdb76hlpKPtzJIgo67j/XLw==} + pdfjs-dist@6.3.289: resolution: {integrity: sha512-ZHjSVpDa3D6izMq8/04lvkhkATUmL9px6ChPaXc1k6nU2Mrhlg1/7F0bdUqCwUjw3NsPTfPZsMDUU6ZIcRaeQw==} engines: {node: '>=22.13.0 || >=24'} @@ -3068,10 +3521,6 @@ packages: resolution: {integrity: sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==} engines: {node: '>=8.6'} - picomatch@4.0.4: - resolution: {integrity: sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==} - engines: {node: '>=12'} - picomatch@4.0.7: resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==} engines: {node: '>=12'} @@ -3110,6 +3559,10 @@ packages: points-on-path@0.2.1: resolution: {integrity: sha512-25ClnWWuw7JbWZcgqY/gJ4FQWadKxGWk+3kR/7kD0tCaDtPPMj7oHu2ToLaVhfpnHrZzYby2w6tUA0eOIuUg8g==} + possible-typed-array-names@1.1.0: + resolution: {integrity: sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==} + engines: {node: '>= 0.4'} + postcss@8.5.28: resolution: {integrity: sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A==} engines: {node: ^10 || ^12 || >=14} @@ -3193,13 +3646,28 @@ packages: readable-stream@2.3.8: resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==} + readable-stream@3.6.2: + resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} + engines: {node: '>= 6'} + + readdir-glob@1.1.3: + resolution: {integrity: sha512-v05I2k7xN8zXvPD9N+z/uhXPaj0sUFCe2rcWZIpBsqxfP7xXFQ0tipAd/wjj1YxWyWtUS5IDJpOG82JKt2EAVA==} + readdirp@3.6.0: resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} engines: {node: '>=8.10.0'} + reflect.getprototypeof@1.0.10: + resolution: {integrity: sha512-00o4I+DVrefhv+nX0ulyi3biSHCPDe+yLv5o/p6d/UVlirijB8E16FtfwSAi4g3tcqrQ4lRAqQSoFEZJehYEcw==} + engines: {node: '>= 0.4'} + regenerator-runtime@0.13.11: resolution: {integrity: sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==} + regexp.prototype.flags@1.5.4: + resolution: {integrity: sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA==} + engines: {node: '>= 0.4'} + reka-ui@2.10.4: resolution: {integrity: sha512-kbS5GAbkHkYj0EVKAg5ZPEPndhBjeUFSa1Aq5m5ftQwyHnB1v5tw8X6fcwfKH/ry3StPXblMWM1DW82MVS71cw==} peerDependencies: @@ -3216,6 +3684,9 @@ packages: resolve-pkg-maps@1.0.0: resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} + restructure@3.0.2: + resolution: {integrity: sha512-gSfoiOEA0VPE6Tukkrr7I0RBdE0s7H1eFCDBk05l1KIQT1UIKNc5JZy6jdyW6eYH3aR3g5b3PuL77rq0hvwtAw==} + rettime@0.11.7: resolution: {integrity: sha512-DoAm1WjR1eH7z8sHPtvvUMIZh4/CSKkGCz6CxPqOrEAnOGtOuHSnSE9OC+razqxKuf4ub7pAYyl/vZV0vGs5tg==} @@ -3223,6 +3694,11 @@ packages: resolution: {integrity: sha512-9aZLIrhRaD97sgVhtJOW6ckOEh6/GnvQtdVNfdZ6s67+3/XwLS9lBcQYzEEhYVeUowN7pRzMLsyGhK2i/xvWbw==} engines: {node: '>= 0.8.15'} + rimraf@2.7.1: + resolution: {integrity: sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==} + deprecated: Rimraf versions prior to v4 are no longer supported + hasBin: true + robust-predicates@3.0.3: resolution: {integrity: sha512-NS3levdsRIUOmiJ8FZWCP7LG3QpJyrs/TE0Zpf1yvZu8cAJJ6QMW92H1c7kWpdIHo8RvmLxN/o2JXTKHp74lUA==} @@ -3244,9 +3720,21 @@ packages: rw@1.3.3: resolution: {integrity: sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ==} + safe-array-concat@1.1.4: + resolution: {integrity: sha512-wtZlHyOje6OZTGqAoaDKxFkgRtkF9CnHAVnCHKfuj200wAgL+bSJhdsCD2l0Qx/2ekEXjPWcyKkfGb5CPboslg==} + engines: {node: '>=0.4'} + safe-buffer@5.1.2: resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} + safe-push-apply@1.0.0: + resolution: {integrity: sha512-iKE9w/Z7xCzUMIZqdBsp6pEQvwuEebH4vdpjcDWnyzaI6yl6O9FHvVpmGelvEHNsoY6wGblkxR6Zty/h00WiSA==} + engines: {node: '>= 0.4'} + + safe-regex-test@1.1.0: + resolution: {integrity: sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==} + engines: {node: '>= 0.4'} + safer-buffer@2.1.2: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} @@ -3255,6 +3743,10 @@ packages: engines: {node: '>=12.0.0'} hasBin: true + saxes@5.0.1: + resolution: {integrity: sha512-5LBh1Tls8c9xgGjw3QrMwETmTMVk0oFgvrFSvWx62llR2hcEInrKNZ2GZCCuuy2lvWrdl5jhbpeqc5hRYKFOcw==} + engines: {node: '>=10'} + scheduler@0.27.0: resolution: {integrity: sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==} @@ -3266,6 +3758,18 @@ packages: resolution: {integrity: sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==} engines: {node: '>= 18'} + set-function-length@1.2.2: + resolution: {integrity: sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==} + engines: {node: '>= 0.4'} + + set-function-name@2.0.2: + resolution: {integrity: sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==} + engines: {node: '>= 0.4'} + + set-proto@1.0.0: + resolution: {integrity: sha512-RJRdvCo6IAnPdsvP/7m6bsQqNnn1FCBX5ZNtFL98MmFF/4xAIJTIg1YbHW5DC2W5SKZanrC6i4HsJqlajw/dZw==} + engines: {node: '>= 0.4'} + setimmediate@1.0.5: resolution: {integrity: sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==} @@ -3329,6 +3833,10 @@ packages: std-env@4.2.0: resolution: {integrity: sha512-oCUKSupKTHX53EyjDtuZQ64pjLJ6yYCtpmEw0goYxtjG9KpbRe8KAsl2tBUGU9DyMcJ0RwJ8GqJAFzMXcXW1Rw==} + stop-iteration-iterator@1.1.0: + resolution: {integrity: sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==} + engines: {node: '>= 0.4'} + strict-event-emitter@0.5.1: resolution: {integrity: sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==} @@ -3336,6 +3844,18 @@ packages: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} + string.prototype.trim@1.2.11: + resolution: {integrity: sha512-PwvK7BU+CMTJGYQCTZb5RWXIML92lftJLhQz1tBzgKiqGxJaMlBAa48POXaNAC2s4y8jr3EFqrkF9+44neS46w==} + engines: {node: '>= 0.4'} + + string.prototype.trimend@1.0.10: + resolution: {integrity: sha512-2+3aDAOmPTmuFwjDnmJG2ctEkQKVki7vOSqaxkv42Mowj1V6PnvuwFCRrR5lChUux1TBskPjfkeTOhqczDMxTw==} + engines: {node: '>= 0.4'} + + string.prototype.trimstart@1.0.8: + resolution: {integrity: sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==} + engines: {node: '>= 0.4'} + string_decoder@1.1.1: resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==} @@ -3370,6 +3890,10 @@ packages: resolution: {integrity: sha512-yEFYrVhod+hdNyx7g5Bnkkb0G6si8HJurOoOEgC8B/O0uXLHlaey/65KRv6cuWBNhBgHKAROVpc7QyYqE5gFng==} engines: {node: '>=20'} + tar-stream@2.2.0: + resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==} + engines: {node: '>=6'} + text-segmentation@1.0.3: resolution: {integrity: sha512-iOiPUo/BGnZ6+54OsWxZidGCsdU8YbE4PSpdPinp7DeMtUJNJBoJ/ouUSTJjHkh1KntHaltHl/gDs2FC4i5+Nw==} @@ -3380,21 +3904,16 @@ packages: thenify@3.3.1: resolution: {integrity: sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==} + tiny-inflate@1.0.3: + resolution: {integrity: sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==} + tinybench@2.9.0: resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==} - tinyexec@1.1.1: - resolution: {integrity: sha512-VKS/ZaQhhkKFMANmAOhhXVoIfBXblQxGX1myCQ2faQrfmobMftXeJPcZGp0gS07ocvGJWDLZGyOZDadDBqYIJg==} - engines: {node: '>=18'} - tinyexec@1.3.1: resolution: {integrity: sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==} engines: {node: '>=18'} - tinyglobby@0.2.16: - resolution: {integrity: sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==} - engines: {node: '>=12.0.0'} - tinyglobby@0.2.17: resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} engines: {node: '>=12.0.0'} @@ -3414,6 +3933,10 @@ packages: resolution: {integrity: sha512-+Zg3vWhRUv8B1maGSTFdev9mjoo8Etn2Ayfs4cnjlD3CsGkxXX4QyW3j2WJ0wdjYcYmy7Lx2RDsZMhgCWafKIw==} hasBin: true + tmp@0.2.7: + resolution: {integrity: sha512-e0votIpp4Uo2AJYSzVHV6xCcawuiez3DzqDAbrTc3YxBkplN6e+dM13ZeIcZnDg/QpSuU2zfZ3rzwY8ukEnaXw==} + engines: {node: '>=14.14'} + to-regex-range@5.0.1: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} @@ -3426,13 +3949,20 @@ packages: resolution: {integrity: sha512-LktZQb3IeoUWB9lqR5EWTHgW/VTITCXg4D21M+lvybRVdylLrRMnqaIONLVb5mav8vM19m44HIcGq4qASeu2Qw==} engines: {node: '>=16'} - ts-dedent@2.2.0: + traverse@0.3.10: + resolution: {integrity: sha512-pd6fq5qmiFuPA3TpdqBCqJXlOrSdCSt0l9IZDg83Vbf4x3m/X18prEwMMVM5LXp9vGL9NxjeiDGBrTasqyngXQ==} + engines: {node: '>= 0.4'} + + ts-dedent@2.2.0: resolution: {integrity: sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==} engines: {node: '>=6.10'} ts-interface-checker@0.1.13: resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} + tslib@1.14.1: + resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} + tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} @@ -3455,6 +3985,26 @@ packages: resolution: {integrity: sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==} engines: {node: '>= 0.6'} + typed-array-buffer@1.0.3: + resolution: {integrity: sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw==} + engines: {node: '>= 0.4'} + + typed-array-byte-length@1.0.3: + resolution: {integrity: sha512-BaXgOuIxz8n8pIq3e7Atg/7s+DpiYrxn4vdot3w9KbnBhcRQq6o3xemQdIfynqSeXeDrF32x+WvfzmOjPiY9lg==} + engines: {node: '>= 0.4'} + + typed-array-byte-offset@1.0.5: + resolution: {integrity: sha512-0FHJvLPqZ7KJzp17O13jfsAjsqazgrxBu2zEK95PmUz8lv2+GjRuxUInCr2Rk9Dms3ihN21zJ929ZO43yJ95QQ==} + engines: {node: '>= 0.4'} + + typed-array-length@1.0.8: + resolution: {integrity: sha512-phPGCwqr2+Qo0fwniCE8e4pKnGu/yFb5nD5Y8bf0EEeiI5GklnACYA9GFy/DrAeRrKHXvHn+1SUsOWgJp6RO+g==} + engines: {node: '>= 0.4'} + + typedarray.prototype.slice@1.0.6: + resolution: {integrity: sha512-r+7YvGfM5TkTiDQ5EqWi/Z4L4KP3jUI+YCmTtWg1tmTHUw6xladLJqzR2heMaHBIM0TTFLZmn/EkIaEHYs/bIA==} + engines: {node: '>= 0.4'} + typescript@6.0.2: resolution: {integrity: sha512-bGdAIrZ0wiGDo5l8c++HWtbaNCWTS4UTv7RaTH/ThVIgjkveJt83m74bBHMJkuCbslY8ixgLBVZJIOiQlQTjfQ==} engines: {node: '>=14.17'} @@ -3463,6 +4013,10 @@ packages: ufo@1.6.3: resolution: {integrity: sha512-yDJTmhydvl5lJzBmy/hyOAA0d+aqCBuwl818haVdYCRrWV84o7YyeVm4QlVHStqNrrJSTb6jKuFAVqAFsr+K3Q==} + unbox-primitive@1.1.0: + resolution: {integrity: sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==} + engines: {node: '>= 0.4'} + undici-types@6.21.0: resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==} @@ -3473,6 +4027,12 @@ packages: resolution: {integrity: sha512-/y4/bH9YNU5hi9NIrpOuvGXFcxrj3CMrV+/AYpowAYTpHn8gX/XPFjNy766FPoYY0miQhdW977JFWKGNhBdwyQ==} engines: {node: '>=22.19.0'} + unicode-properties@1.4.1: + resolution: {integrity: sha512-CLjCCLQ6UuMxWnbIylkisbRj31qxHPAurvena/0iwSVbQ2G1VY5/HjV0IRabOEbDHlzZlRdCrD4NhB0JtU40Pg==} + + unicode-trie@2.0.0: + resolution: {integrity: sha512-x7bc76x0bm4prf1VLg79uhAzKw8DVboClSN5VxJuQ+LKDOVEW9CdH+VY7SP+vX7xCYQqzzgQpFqz15zeLvAtZQ==} + unifont@0.7.5: resolution: {integrity: sha512-ULe/Cs+ZIsq+dcFofNkhqielCrUJnb5mr+Yc4EBM2VlL+6OZR6+cjtI2mT1bJvRBrVncqHAbLURxmPLcCXzWMg==} @@ -3483,6 +4043,9 @@ packages: until-async@3.0.2: resolution: {integrity: sha512-IiSk4HlzAMqTUseHHe3VhIGyuFmN90zMTpD3Z3y8jeQbzLIq500MVM7Jq2vUAnTKAFPJrqwkzr6PoTcPhGcOiw==} + unzipper@0.10.14: + resolution: {integrity: sha512-ti4wZj+0bQTiX2KmKWuwj7lhV+2n//uXEotUmGuQqrbVZSEGFMbI68+c6JCQ8aAmUWYvtHEz2A8K6wXvueR/6g==} + use-callback-ref@1.3.3: resolution: {integrity: sha512-jQL3lRnocaFtu3V00JToYz/4QkNWswxijDaCVNZRiRTO3HQDLsdu1ZtmIUvV4yPp+rvWm5j0y0TG/S61cuijTg==} engines: {node: '>=10'} @@ -3518,6 +4081,11 @@ packages: resolution: {integrity: sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==} hasBin: true + uuid@8.3.2: + resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} + deprecated: uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028). + hasBin: true + vary@1.1.2: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} @@ -3654,6 +4222,22 @@ packages: webworkify@1.5.0: resolution: {integrity: sha512-AMcUeyXAhbACL8S2hqqdqOLqvJ8ylmIbNwUIqQujRSouf4+eUFaXbG6F1Rbu+srlJMmxQWsiU7mOJi0nMBfM1g==} + which-boxed-primitive@1.1.1: + resolution: {integrity: sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==} + engines: {node: '>= 0.4'} + + which-builtin-type@1.2.1: + resolution: {integrity: sha512-6iBczoX+kDQ7a3+YJBnh3T+KZRxM/iYNPXicqk66/Qfm1b93iu+yOImkg0zHbj5LNOcNv1TEADiZ0xa34B4q6Q==} + engines: {node: '>= 0.4'} + + which-collection@1.0.2: + resolution: {integrity: sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==} + engines: {node: '>= 0.4'} + + which-typed-array@1.1.24: + resolution: {integrity: sha512-wk4Mf4pR5mRP7eYuuTBCIQ9d0ud2Fv2jRLQpfgnRjbOxAFHmjKFValgTpitVKzJJS8ajnYQV2Du1SZ8j6b/EUQ==} + engines: {node: '>= 0.4'} + which@2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} engines: {node: '>= 8'} @@ -3690,6 +4274,9 @@ packages: utf-8-validate: optional: true + xmlchars@2.2.0: + resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==} + xspattern@3.1.0: resolution: {integrity: sha512-rxtOX8ORJizRqswIdZ72G3thKrHd0Q+TvyUCMByc5VdjDz1nkuZKfPXM3xGdrGi0fwEy+DDJN7DqtAZ06Re4bA==} @@ -3714,6 +4301,10 @@ packages: resolution: {integrity: sha512-U/PBtDf35ff0D8X8D0jfdzHYEPFxAI7jJlxZXwCSez5M3190m+QobIfh+sWDWSHMCWWJN2AWamkegn6vr6YBTw==} engines: {node: '>=18'} + zip-stream@4.1.1: + resolution: {integrity: sha512-9qv4rlDiopXg4E69k+vMHjNN63YFMe9sZMrdlvKnCjlCRWeCBswPPMPUfx+ipsAWq1LXHe70RcbaHdJJpS6hyQ==} + engines: {node: '>= 10'} + zod-to-json-schema@3.25.2: resolution: {integrity: sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==} peerDependencies: @@ -3742,7 +4333,7 @@ snapshots: '@antfu/install-pkg@1.1.0': dependencies: package-manager-detector: 1.6.0 - tinyexec: 1.1.1 + tinyexec: 1.3.1 '@atlaskit/pragmatic-drag-and-drop-hitbox@1.2.0': dependencies: @@ -4105,6 +4696,25 @@ snapshots: '@excalidraw/random-username@1.1.0': {} + '@fast-csv/format@4.3.5': + dependencies: + '@types/node': 14.18.63 + lodash.escaperegexp: 4.1.2 + lodash.isboolean: 3.0.3 + lodash.isequal: 4.5.0 + lodash.isfunction: 3.0.9 + lodash.isnil: 4.0.0 + + '@fast-csv/parse@4.3.6': + dependencies: + '@types/node': 14.18.63 + lodash.escaperegexp: 4.1.2 + lodash.groupby: 4.6.0 + lodash.isfunction: 3.0.9 + lodash.isnil: 4.0.0 + lodash.isundefined: 3.0.1 + lodash.uniq: 4.5.0 + '@floating-ui/core@1.7.5': dependencies: '@floating-ui/utils': 0.2.11 @@ -4285,11 +4895,11 @@ snapshots: cors: 2.8.6 cross-spawn: 7.0.6 eventsource: 3.0.7 - eventsource-parser: 3.1.0 + eventsource-parser: 3.1.1 express: 5.2.1 express-rate-limit: 8.3.2(express@5.2.1) hono: 4.12.12 - jose: 6.2.2 + jose: 6.2.12 json-schema-typed: 8.0.2 pkce-challenge: 5.0.1 raw-body: 3.0.2 @@ -4631,6 +5241,14 @@ snapshots: '@oxlint/binding-win32-x64-msvc@1.57.0': optional: true + '@pdf-lib/standard-fonts@1.0.0': + dependencies: + pako: 1.0.11 + + '@pdf-lib/upng@1.0.1': + dependencies: + pako: 1.0.11 + '@radix-ui/primitive@1.0.0': dependencies: '@babel/runtime': 7.29.7 @@ -5108,6 +5726,8 @@ snapshots: '@types/geojson@7946.0.16': {} + '@types/node@14.18.63': {} + '@types/node@22.20.4': dependencies: undici-types: 6.21.0 @@ -5288,19 +5908,97 @@ snapshots: normalize-path: 3.0.0 picomatch: 2.3.2 + archiver-utils@2.1.0: + dependencies: + glob: 7.2.3 + graceful-fs: 4.2.12 + lazystream: 1.0.1 + lodash.defaults: 4.2.0 + lodash.difference: 4.5.0 + lodash.flatten: 4.4.0 + lodash.isplainobject: 4.0.6 + lodash.union: 4.6.0 + normalize-path: 3.0.0 + readable-stream: 2.3.8 + + archiver-utils@3.0.4: + dependencies: + glob: 7.2.3 + graceful-fs: 4.2.12 + lazystream: 1.0.1 + lodash.defaults: 4.2.0 + lodash.difference: 4.5.0 + lodash.flatten: 4.4.0 + lodash.isplainobject: 4.0.6 + lodash.union: 4.6.0 + normalize-path: 3.0.0 + readable-stream: 3.6.2 + + archiver@5.3.2: + dependencies: + archiver-utils: 2.1.0 + async: 3.2.6 + buffer-crc32: 0.2.13 + readable-stream: 3.6.2 + readdir-glob: 1.1.3 + tar-stream: 2.2.0 + zip-stream: 4.1.1 + aria-hidden@1.2.6: dependencies: tslib: 2.8.1 + array-buffer-byte-length@1.0.2: + dependencies: + call-bound: 1.0.4 + is-array-buffer: 3.0.5 + + arraybuffer.prototype.slice@1.0.4: + dependencies: + array-buffer-byte-length: 1.0.2 + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + is-array-buffer: 3.0.5 + assertion-error@2.0.1: {} + async-function@1.0.0: {} + + async@3.2.6: {} + + available-typed-arrays@1.0.7: + dependencies: + possible-typed-array-names: 1.1.0 + + balanced-match@1.0.2: {} + base64-arraybuffer@1.0.2: optional: true + base64-js@1.5.1: {} + + big-integer@1.6.52: {} + binary-extensions@2.3.0: {} + binary@0.3.0: + dependencies: + buffers: 0.1.1 + chainsaw: 0.1.0 + bind-event-listener@3.0.0: {} + bl@4.1.0: + dependencies: + buffer: 5.7.1 + inherits: 2.0.4 + readable-stream: 3.6.2 + + bluebird@3.4.7: {} + body-parser@2.2.2: dependencies: bytes: 3.1.2 @@ -5315,12 +6013,36 @@ snapshots: transitivePeerDependencies: - supports-color + brace-expansion@1.1.22: + dependencies: + balanced-match: 1.0.2 + concat-map: 0.0.1 + + brace-expansion@2.1.8: + dependencies: + balanced-match: 1.0.2 + braces@3.0.3: dependencies: fill-range: 7.1.1 + brotli@1.3.3: + dependencies: + base64-js: 1.5.1 + browser-fs-access@0.29.1: {} + buffer-crc32@0.2.13: {} + + buffer-indexof-polyfill@1.0.2: {} + + buffer@5.7.1: + dependencies: + base64-js: 1.5.1 + ieee754: 1.2.1 + + buffers@0.1.1: {} + bun@1.3.11: optionalDependencies: '@oven/bun-darwin-aarch64': 1.3.11 @@ -5343,6 +6065,13 @@ snapshots: es-errors: 1.3.0 function-bind: 1.1.2 + call-bind@1.0.9: + dependencies: + call-bind-apply-helpers: 1.0.2 + es-define-property: 1.0.1 + get-intrinsic: 1.3.0 + set-function-length: 1.2.2 + call-bound@1.0.4: dependencies: call-bind-apply-helpers: 1.0.2 @@ -5368,6 +6097,10 @@ snapshots: chai@6.2.2: {} + chainsaw@0.1.0: + dependencies: + traverse: 0.3.10 + chevrotain-allstar@0.3.1(chevrotain@11.0.3): dependencies: chevrotain: 11.0.3 @@ -5417,6 +6150,8 @@ snapshots: wrap-ansi: 7.0.0 optional: true + clone@2.1.2: {} + clsx@1.1.1: {} color-convert@2.0.1: @@ -5435,6 +6170,15 @@ snapshots: commander@8.3.0: {} + compress-commons@4.1.2: + dependencies: + buffer-crc32: 0.2.13 + crc32-stream: 4.0.3 + normalize-path: 3.0.0 + readable-stream: 3.6.2 + + concat-map@0.0.1: {} + confbox@0.1.8: {} content-disposition@1.1.0: {} @@ -5470,6 +6214,13 @@ snapshots: crc-32@0.3.0: {} + crc-32@1.2.2: {} + + crc32-stream@4.0.3: + dependencies: + crc-32: 1.2.2 + readable-stream: 3.6.2 + crelt@1.0.7: {} cross-env@7.0.3: @@ -5682,12 +6433,42 @@ snapshots: d3: 7.9.0 lodash-es: 4.18.1 + data-view-buffer@1.0.2: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + is-data-view: 1.0.2 + + data-view-byte-length@1.0.2: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + is-data-view: 1.0.2 + + data-view-byte-offset@1.0.1: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + is-data-view: 1.0.2 + dayjs@1.11.20: {} debug@4.4.3: dependencies: ms: 2.1.3 + define-data-property@1.1.4: + dependencies: + es-define-property: 1.0.1 + es-errors: 1.3.0 + gopd: 1.2.0 + + define-properties@1.2.1: + dependencies: + define-data-property: 1.1.4 + has-property-descriptors: 1.0.2 + object-keys: 1.1.1 + defu@6.1.7: {} delaunator@5.1.0: @@ -5702,6 +6483,8 @@ snapshots: detect-node-es@1.1.0: {} + dfa@1.2.0: {} + diff@8.0.4: {} dompurify@3.3.3: @@ -5714,6 +6497,10 @@ snapshots: es-errors: 1.3.0 gopd: 1.2.0 + duplexer2@0.1.4: + dependencies: + readable-stream: 2.3.8 + ee-first@1.1.1: {} emoji-regex@8.0.0: @@ -5721,8 +6508,76 @@ snapshots: encodeurl@2.0.0: {} + end-of-stream@1.4.5: + dependencies: + once: 1.4.0 + entities@7.0.1: {} + es-abstract-get@1.0.0: + dependencies: + es-errors: 1.3.0 + es-object-atoms: 1.1.2 + is-callable: 1.2.7 + object-inspect: 1.13.4 + + es-abstract@1.24.2: + dependencies: + array-buffer-byte-length: 1.0.2 + arraybuffer.prototype.slice: 1.0.4 + available-typed-arrays: 1.0.7 + call-bind: 1.0.9 + call-bound: 1.0.4 + data-view-buffer: 1.0.2 + data-view-byte-length: 1.0.2 + data-view-byte-offset: 1.0.1 + es-define-property: 1.0.1 + es-errors: 1.3.0 + es-object-atoms: 1.1.1 + es-set-tostringtag: 2.1.0 + es-to-primitive: 1.3.4 + function.prototype.name: 1.2.0 + get-intrinsic: 1.3.0 + get-proto: 1.0.1 + get-symbol-description: 1.1.0 + globalthis: 1.0.4 + gopd: 1.2.0 + has-property-descriptors: 1.0.2 + has-proto: 1.2.0 + has-symbols: 1.1.0 + hasown: 2.0.2 + internal-slot: 1.1.0 + is-array-buffer: 3.0.5 + is-callable: 1.2.7 + is-data-view: 1.0.2 + is-negative-zero: 2.0.3 + is-regex: 1.2.1 + is-set: 2.0.3 + is-shared-array-buffer: 1.0.4 + is-string: 1.1.1 + is-typed-array: 1.1.15 + is-weakref: 1.1.1 + math-intrinsics: 1.1.0 + object-inspect: 1.13.4 + object-keys: 1.1.1 + object.assign: 4.1.7 + own-keys: 1.0.2 + regexp.prototype.flags: 1.5.4 + safe-array-concat: 1.1.4 + safe-push-apply: 1.0.0 + safe-regex-test: 1.1.0 + set-proto: 1.0.0 + stop-iteration-iterator: 1.1.0 + string.prototype.trim: 1.2.11 + string.prototype.trimend: 1.0.10 + string.prototype.trimstart: 1.0.8 + typed-array-buffer: 1.0.3 + typed-array-byte-length: 1.0.3 + typed-array-byte-offset: 1.0.5 + typed-array-length: 1.0.8 + unbox-primitive: 1.1.0 + which-typed-array: 1.1.24 + es-define-property@1.0.1: {} es-errors@1.3.0: {} @@ -5733,6 +6588,26 @@ snapshots: dependencies: es-errors: 1.3.0 + es-object-atoms@1.1.2: + dependencies: + es-errors: 1.3.0 + + es-set-tostringtag@2.1.0: + dependencies: + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + has-tostringtag: 1.0.2 + hasown: 2.0.2 + + es-to-primitive@1.3.4: + dependencies: + es-abstract-get: 1.0.0 + es-define-property: 1.0.1 + es-errors: 1.3.0 + is-callable: 1.2.7 + is-date-object: 1.1.0 + is-symbol: 1.1.1 + es-toolkit@1.46.1: {} es6-promise-pool@2.5.0: {} @@ -5809,13 +6684,23 @@ snapshots: etag@1.8.1: {} - eventsource-parser@3.1.0: {} - eventsource-parser@3.1.1: {} eventsource@3.0.7: dependencies: - eventsource-parser: 3.1.0 + eventsource-parser: 3.1.1 + + exceljs@4.4.0: + dependencies: + archiver: 5.3.2 + dayjs: 1.11.20 + fast-csv: 4.3.6 + jszip: 3.10.1 + readable-stream: 3.6.2 + saxes: 5.0.1 + tmp: 0.2.7 + unzipper: 0.10.14 + uuid: 8.3.2 expect-type@1.4.0: {} @@ -5859,6 +6744,11 @@ snapshots: transitivePeerDependencies: - supports-color + fast-csv@4.3.6: + dependencies: + '@fast-csv/format': 4.3.5 + '@fast-csv/parse': 4.3.6 + fast-deep-equal@3.1.3: {} fast-png@6.4.0: @@ -5869,10 +6759,6 @@ snapshots: fast-uri@3.1.0: {} - fdir@6.5.0(picomatch@4.0.4): - optionalDependencies: - picomatch: 4.0.4 - fdir@6.5.0(picomatch@4.0.7): optionalDependencies: picomatch: 4.0.7 @@ -5896,26 +6782,69 @@ snapshots: font-family-papandreou@0.2.0-patch2: {} + fontkit@2.0.4: + dependencies: + '@swc/helpers': 0.5.23 + brotli: 1.3.3 + clone: 2.1.2 + dfa: 1.2.0 + fast-deep-equal: 3.1.3 + restructure: 3.0.2 + tiny-inflate: 1.0.3 + unicode-properties: 1.4.1 + unicode-trie: 2.0.0 + fontoxpath@3.34.0: dependencies: prsc: 4.0.0 xspattern: 3.1.0 + for-each@0.3.5: + dependencies: + is-callable: 1.2.7 + forwarded@0.2.0: {} fractional-indexing@3.2.0: {} fresh@2.0.0: {} + fs-constants@1.0.0: {} + + fs.realpath@1.0.0: {} + fsevents@2.3.3: optional: true + fstream@1.0.12: + dependencies: + graceful-fs: 4.2.12 + inherits: 2.0.4 + mkdirp: 0.5.6 + rimraf: 2.7.1 + function-bind@1.1.2: {} + function.prototype.name@1.2.0: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + es-define-property: 1.0.1 + es-errors: 1.3.0 + functions-have-names: 1.2.3 + has-property-descriptors: 1.0.2 + hasown: 2.0.4 + is-callable: 1.2.7 + is-document.all: 1.0.0 + + functions-have-names@1.2.3: {} + fuzzy@0.1.3: {} fzstd@0.1.1: {} + generator-function@2.0.1: {} + get-caller-file@2.0.5: optional: true @@ -5939,6 +6868,12 @@ snapshots: dunder-proto: 1.0.1 es-object-atoms: 1.1.1 + get-symbol-description@1.1.0: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + get-tsconfig@4.13.7: dependencies: resolve-pkg-maps: 1.0.0 @@ -5948,21 +6883,55 @@ snapshots: dependencies: is-glob: 4.0.3 + glob@7.2.3: + dependencies: + fs.realpath: 1.0.0 + inflight: 1.0.6 + inherits: 2.0.4 + minimatch: 3.1.5 + once: 1.4.0 + path-is-absolute: 1.0.1 + + globalthis@1.0.4: + dependencies: + define-properties: 1.2.1 + gopd: 1.2.0 + glur@1.1.2: {} gopd@1.2.0: {} + graceful-fs@4.2.12: {} + graphql@16.13.2: optional: true hachure-fill@0.5.2: {} + has-bigints@1.1.0: {} + + has-property-descriptors@1.0.2: + dependencies: + es-define-property: 1.0.1 + + has-proto@1.2.0: + dependencies: + dunder-proto: 1.0.1 + has-symbols@1.1.0: {} + has-tostringtag@1.0.2: + dependencies: + has-symbols: 1.1.0 + hasown@2.0.2: dependencies: function-bind: 1.1.2 + hasown@2.0.4: + dependencies: + function-bind: 1.1.2 + headers-polyfill@4.0.3: optional: true @@ -5992,6 +6961,8 @@ snapshots: dependencies: safer-buffer: 2.1.2 + ieee754@1.2.1: {} + image-blob-reduce@3.0.1: dependencies: pica: 7.1.1 @@ -6007,8 +6978,19 @@ snapshots: immutable@4.3.9: {} + inflight@1.0.6: + dependencies: + once: 1.4.0 + wrappy: 1.0.2 + inherits@2.0.4: {} + internal-slot@1.1.0: + dependencies: + es-errors: 1.3.0 + hasown: 2.0.2 + side-channel: 1.1.0 + internmap@1.0.1: {} internmap@2.0.3: {} @@ -6019,28 +7001,130 @@ snapshots: ipaddr.js@1.9.1: {} + is-array-buffer@3.0.5: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + get-intrinsic: 1.3.0 + + is-async-function@2.1.1: + dependencies: + async-function: 1.0.0 + call-bound: 1.0.4 + get-proto: 1.0.1 + has-tostringtag: 1.0.2 + safe-regex-test: 1.1.0 + + is-bigint@1.1.0: + dependencies: + has-bigints: 1.1.0 + is-binary-path@2.1.0: dependencies: binary-extensions: 2.3.0 + is-boolean-object@1.2.2: + dependencies: + call-bound: 1.0.4 + has-tostringtag: 1.0.2 + + is-callable@1.2.7: {} + + is-data-view@1.0.2: + dependencies: + call-bound: 1.0.4 + get-intrinsic: 1.3.0 + is-typed-array: 1.1.15 + + is-date-object@1.1.0: + dependencies: + call-bound: 1.0.4 + has-tostringtag: 1.0.2 + + is-document.all@1.0.0: + dependencies: + call-bound: 1.0.4 + is-extglob@2.1.1: {} + is-finalizationregistry@1.1.1: + dependencies: + call-bound: 1.0.4 + is-fullwidth-code-point@3.0.0: optional: true + is-generator-function@1.1.2: + dependencies: + call-bound: 1.0.4 + generator-function: 2.0.1 + get-proto: 1.0.1 + has-tostringtag: 1.0.2 + safe-regex-test: 1.1.0 + is-glob@4.0.3: dependencies: is-extglob: 2.1.1 + is-map@2.0.3: {} + + is-negative-zero@2.0.3: {} + is-node-process@1.2.0: optional: true + is-number-object@1.1.1: + dependencies: + call-bound: 1.0.4 + has-tostringtag: 1.0.2 + is-number@7.0.0: {} is-promise@4.0.0: {} + is-regex@1.2.1: + dependencies: + call-bound: 1.0.4 + gopd: 1.2.0 + has-tostringtag: 1.0.2 + hasown: 2.0.2 + + is-set@2.0.3: {} + + is-shared-array-buffer@1.0.4: + dependencies: + call-bound: 1.0.4 + + is-string@1.1.1: + dependencies: + call-bound: 1.0.4 + has-tostringtag: 1.0.2 + + is-symbol@1.1.1: + dependencies: + call-bound: 1.0.4 + has-symbols: 1.1.0 + safe-regex-test: 1.1.0 + + is-typed-array@1.1.15: + dependencies: + which-typed-array: 1.1.24 + + is-weakmap@2.0.2: {} + + is-weakref@1.1.1: + dependencies: + call-bound: 1.0.4 + + is-weakset@2.0.4: + dependencies: + call-bound: 1.0.4 + get-intrinsic: 1.3.0 + isarray@1.0.0: {} + isarray@2.0.5: {} + isexe@2.0.0: {} jiti@2.6.1: @@ -6048,8 +7132,6 @@ snapshots: jose@6.2.12: {} - jose@6.2.2: {} - jotai-scope@0.7.2(jotai@2.11.0(@types/react@19.2.14)(react@19.2.7))(react@19.2.7): dependencies: jotai: 2.11.0(@types/react@19.2.14)(react@19.2.7) @@ -6115,6 +7197,10 @@ snapshots: layout-base@2.0.1: {} + lazystream@1.0.1: + dependencies: + readable-stream: 2.3.8 + lie@3.3.0: dependencies: immediate: 3.0.6 @@ -6170,14 +7256,42 @@ snapshots: lines-and-columns@1.2.4: {} + listenercount@1.0.1: {} + lodash-es@4.17.21: {} lodash-es@4.18.1: {} lodash.debounce@4.0.8: {} + lodash.defaults@4.2.0: {} + + lodash.difference@4.5.0: {} + + lodash.escaperegexp@4.1.2: {} + + lodash.flatten@4.4.0: {} + + lodash.groupby@4.6.0: {} + + lodash.isboolean@3.0.3: {} + + lodash.isequal@4.5.0: {} + + lodash.isfunction@3.0.9: {} + + lodash.isnil@4.0.0: {} + + lodash.isplainobject@4.0.6: {} + + lodash.isundefined@3.0.1: {} + lodash.throttle@4.1.1: {} + lodash.union@4.6.0: {} + + lodash.uniq@4.5.0: {} + magic-string@0.30.21: dependencies: '@jridgewell/sourcemap-codec': 1.5.5 @@ -6224,6 +7338,20 @@ snapshots: dependencies: mime-db: 1.54.0 + minimatch@3.1.5: + dependencies: + brace-expansion: 1.1.22 + + minimatch@5.1.9: + dependencies: + brace-expansion: 2.1.8 + + minimist@1.2.8: {} + + mkdirp@0.5.6: + dependencies: + minimist: 1.2.8 + mlly@1.8.2: dependencies: acorn: 8.16.0 @@ -6293,6 +7421,17 @@ snapshots: object-inspect@1.13.4: {} + object-keys@1.1.1: {} + + object.assign@4.1.7: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-properties: 1.2.1 + es-object-atoms: 1.1.1 + has-symbols: 1.1.0 + object-keys: 1.1.1 + obug@2.2.1: {} ofetch@1.5.1: @@ -6318,6 +7457,13 @@ snapshots: outvariant@1.4.3: optional: true + own-keys@1.0.2: + dependencies: + call-bound: 1.0.4 + get-intrinsic: 1.3.0 + object-keys: 1.1.1 + safe-push-apply: 1.0.0 + oxfmt@0.41.0: dependencies: tinypool: 2.1.0 @@ -6366,6 +7512,8 @@ snapshots: package-manager-detector@1.6.0: {} + pako@0.2.9: {} + pako@1.0.11: {} pako@2.0.3: {} @@ -6376,6 +7524,8 @@ snapshots: path-data-parser@0.1.0: {} + path-is-absolute@1.0.1: {} + path-key@3.1.1: {} path-to-regexp@6.3.0: @@ -6385,6 +7535,13 @@ snapshots: pathe@2.0.3: {} + pdf-lib@1.17.1: + dependencies: + '@pdf-lib/standard-fonts': 1.0.0 + '@pdf-lib/upng': 1.0.1 + pako: 1.0.11 + tslib: 1.14.1 + pdfjs-dist@6.3.289: optionalDependencies: '@napi-rs/canvas': 1.0.11 @@ -6406,8 +7563,6 @@ snapshots: picomatch@2.3.2: {} - picomatch@4.0.4: {} - picomatch@4.0.7: {} pirates@4.0.7: {} @@ -6442,6 +7597,8 @@ snapshots: path-data-parser: 0.1.0 points-on-curve: 0.2.0 + possible-typed-array-names@1.1.0: {} + postcss@8.5.28: dependencies: nanoid: 3.3.19 @@ -6534,13 +7691,43 @@ snapshots: string_decoder: 1.1.1 util-deprecate: 1.0.2 + readable-stream@3.6.2: + dependencies: + inherits: 2.0.4 + string_decoder: 1.1.1 + util-deprecate: 1.0.2 + + readdir-glob@1.1.3: + dependencies: + minimatch: 5.1.9 + readdirp@3.6.0: dependencies: picomatch: 2.3.2 + reflect.getprototypeof@1.0.10: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-errors: 1.3.0 + es-object-atoms: 1.1.1 + get-intrinsic: 1.3.0 + get-proto: 1.0.1 + which-builtin-type: 1.2.1 + regenerator-runtime@0.13.11: optional: true + regexp.prototype.flags@1.5.4: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-errors: 1.3.0 + get-proto: 1.0.1 + gopd: 1.2.0 + set-function-name: 2.0.2 + reka-ui@2.10.4(vue@3.5.42(typescript@6.0.2)): dependencies: '@floating-ui/dom': 1.7.6 @@ -6565,12 +7752,18 @@ snapshots: resolve-pkg-maps@1.0.0: optional: true + restructure@3.0.2: {} + rettime@0.11.7: optional: true rgbcolor@1.0.1: optional: true + rimraf@2.7.1: + dependencies: + glob: 7.2.3 + robust-predicates@3.0.3: {} rolldown@1.2.11: @@ -6620,8 +7813,27 @@ snapshots: rw@1.3.3: {} + safe-array-concat@1.1.4: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + get-intrinsic: 1.3.0 + has-symbols: 1.1.0 + isarray: 2.0.5 + safe-buffer@5.1.2: {} + safe-push-apply@1.0.0: + dependencies: + es-errors: 1.3.0 + isarray: 2.0.5 + + safe-regex-test@1.1.0: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + is-regex: 1.2.1 + safer-buffer@2.1.2: {} sass@1.51.0: @@ -6630,6 +7842,10 @@ snapshots: immutable: 4.3.9 source-map-js: 1.2.1 + saxes@5.0.1: + dependencies: + xmlchars: 2.2.0 + scheduler@0.27.0: {} send@1.2.1: @@ -6657,6 +7873,28 @@ snapshots: transitivePeerDependencies: - supports-color + set-function-length@1.2.2: + dependencies: + define-data-property: 1.1.4 + es-errors: 1.3.0 + function-bind: 1.1.2 + get-intrinsic: 1.3.0 + gopd: 1.2.0 + has-property-descriptors: 1.0.2 + + set-function-name@2.0.2: + dependencies: + define-data-property: 1.1.4 + es-errors: 1.3.0 + functions-have-names: 1.2.3 + has-property-descriptors: 1.0.2 + + set-proto@1.0.0: + dependencies: + dunder-proto: 1.0.1 + es-errors: 1.3.0 + es-object-atoms: 1.1.1 + setimmediate@1.0.5: {} setprototypeof@1.2.0: {} @@ -6715,6 +7953,11 @@ snapshots: std-env@4.2.0: {} + stop-iteration-iterator@1.1.0: + dependencies: + es-errors: 1.3.0 + internal-slot: 1.1.0 + strict-event-emitter@0.5.1: optional: true @@ -6725,6 +7968,30 @@ snapshots: strip-ansi: 6.0.1 optional: true + string.prototype.trim@1.2.11: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-data-property: 1.1.4 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-object-atoms: 1.1.2 + has-property-descriptors: 1.0.2 + safe-regex-test: 1.1.0 + + string.prototype.trimend@1.0.10: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-properties: 1.2.1 + es-object-atoms: 1.1.2 + + string.prototype.trimstart@1.0.8: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-object-atoms: 1.1.1 + string_decoder@1.1.1: dependencies: safe-buffer: 5.1.2 @@ -6745,7 +8012,7 @@ snapshots: lines-and-columns: 1.2.4 mz: 2.7.0 pirates: 4.0.7 - tinyglobby: 0.2.16 + tinyglobby: 0.2.17 ts-interface-checker: 0.1.13 svg-pathdata@6.0.3: @@ -6764,6 +8031,14 @@ snapshots: tagged-tag@1.0.0: optional: true + tar-stream@2.2.0: + dependencies: + bl: 4.1.0 + end-of-stream: 1.4.5 + fs-constants: 1.0.0 + inherits: 2.0.4 + readable-stream: 3.6.2 + text-segmentation@1.0.3: dependencies: utrie: 1.0.2 @@ -6777,17 +8052,12 @@ snapshots: dependencies: any-promise: 1.3.0 - tinybench@2.9.0: {} + tiny-inflate@1.0.3: {} - tinyexec@1.1.1: {} + tinybench@2.9.0: {} tinyexec@1.3.1: {} - tinyglobby@0.2.16: - dependencies: - fdir: 6.5.0(picomatch@4.0.4) - picomatch: 4.0.4 - tinyglobby@0.2.17: dependencies: fdir: 6.5.0(picomatch@4.0.7) @@ -6805,6 +8075,8 @@ snapshots: tldts-core: 7.0.28 optional: true + tmp@0.2.7: {} + to-regex-range@5.0.1: dependencies: is-number: 7.0.0 @@ -6816,10 +8088,20 @@ snapshots: tldts: 7.0.28 optional: true + traverse@0.3.10: + dependencies: + define-data-property: 1.1.4 + es-to-primitive: 1.3.4 + gopd: 1.2.0 + typedarray.prototype.slice: 1.0.6 + which-typed-array: 1.1.24 + ts-dedent@2.2.0: {} ts-interface-checker@0.1.13: {} + tslib@1.14.1: {} + tslib@2.8.1: {} tsx@4.21.0: @@ -6851,16 +8133,76 @@ snapshots: media-typer: 1.1.0 mime-types: 3.0.2 + typed-array-buffer@1.0.3: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + is-typed-array: 1.1.15 + + typed-array-byte-length@1.0.3: + dependencies: + call-bind: 1.0.9 + for-each: 0.3.5 + gopd: 1.2.0 + has-proto: 1.2.0 + is-typed-array: 1.1.15 + + typed-array-byte-offset@1.0.5: + dependencies: + available-typed-arrays: 1.0.7 + call-bind: 1.0.9 + for-each: 0.3.5 + gopd: 1.2.0 + is-typed-array: 1.1.15 + reflect.getprototypeof: 1.0.10 + + typed-array-length@1.0.8: + dependencies: + call-bind: 1.0.9 + for-each: 0.3.5 + gopd: 1.2.0 + is-typed-array: 1.1.15 + possible-typed-array-names: 1.1.0 + reflect.getprototypeof: 1.0.10 + + typedarray.prototype.slice@1.0.6: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-errors: 1.3.0 + get-proto: 1.0.1 + math-intrinsics: 1.1.0 + typed-array-buffer: 1.0.3 + typed-array-byte-offset: 1.0.5 + typescript@6.0.2: {} ufo@1.6.3: {} + unbox-primitive@1.1.0: + dependencies: + call-bound: 1.0.4 + has-bigints: 1.1.0 + has-symbols: 1.1.0 + which-boxed-primitive: 1.1.1 + undici-types@6.21.0: {} undici-types@7.18.2: {} undici@8.10.2: {} + unicode-properties@1.4.1: + dependencies: + base64-js: 1.5.1 + unicode-trie: 2.0.0 + + unicode-trie@2.0.0: + dependencies: + pako: 0.2.9 + tiny-inflate: 1.0.3 + unifont@0.7.5: dependencies: css-tree: 3.2.1 @@ -6872,6 +8214,19 @@ snapshots: until-async@3.0.2: optional: true + unzipper@0.10.14: + dependencies: + big-integer: 1.6.52 + binary: 0.3.0 + bluebird: 3.4.7 + buffer-indexof-polyfill: 1.0.2 + duplexer2: 0.1.4 + fstream: 1.0.12 + graceful-fs: 4.2.12 + listenercount: 1.0.1 + readable-stream: 2.3.8 + setimmediate: 1.0.5 + use-callback-ref@1.3.3(@types/react@19.2.14)(react@19.2.7): dependencies: react: 19.2.7 @@ -6900,6 +8255,8 @@ snapshots: uuid@11.1.0: {} + uuid@8.3.2: {} + vary@1.1.2: {} vite@8.3.1(@types/node@25.5.0)(esbuild@0.25.12)(jiti@2.6.1)(tsx@4.21.0)(yaml@2.9.0): @@ -6982,6 +8339,47 @@ snapshots: webworkify@1.5.0: {} + which-boxed-primitive@1.1.1: + dependencies: + is-bigint: 1.1.0 + is-boolean-object: 1.2.2 + is-number-object: 1.1.1 + is-string: 1.1.1 + is-symbol: 1.1.1 + + which-builtin-type@1.2.1: + dependencies: + call-bound: 1.0.4 + function.prototype.name: 1.2.0 + has-tostringtag: 1.0.2 + is-async-function: 2.1.1 + is-date-object: 1.1.0 + is-finalizationregistry: 1.1.1 + is-generator-function: 1.1.2 + is-regex: 1.2.1 + is-weakref: 1.1.1 + isarray: 2.0.5 + which-boxed-primitive: 1.1.1 + which-collection: 1.0.2 + which-typed-array: 1.1.24 + + which-collection@1.0.2: + dependencies: + is-map: 2.0.3 + is-set: 2.0.3 + is-weakmap: 2.0.2 + is-weakset: 2.0.4 + + which-typed-array@1.1.24: + dependencies: + available-typed-arrays: 1.0.7 + call-bind: 1.0.9 + call-bound: 1.0.4 + for-each: 0.3.5 + get-proto: 1.0.1 + gopd: 1.2.0 + has-tostringtag: 1.0.2 + which@2.0.2: dependencies: isexe: 2.0.0 @@ -7011,6 +8409,8 @@ snapshots: ws@8.20.0: {} + xmlchars@2.2.0: {} + xspattern@3.1.0: dependencies: whynot: 5.0.0 @@ -7038,6 +8438,12 @@ snapshots: yoctocolors-cjs@2.1.3: optional: true + zip-stream@4.1.1: + dependencies: + archiver-utils: 3.0.4 + compress-commons: 4.1.2 + readable-stream: 3.6.2 + zod-to-json-schema@3.25.2(zod@4.6.5): dependencies: zod: 4.6.5 diff --git a/ui-plugins/invoice-maker/package.json b/ui-plugins/invoice-maker/package.json new file mode 100644 index 00000000..fc316507 --- /dev/null +++ b/ui-plugins/invoice-maker/package.json @@ -0,0 +1,38 @@ +{ + "name": "@penova/plugin-invoice-maker", + "version": "0.1.0", + "private": true, + "license": "MIT", + "type": "module", + "scripts": { + "build": "node scripts/build.mjs", + "typecheck": "tsc -p tsconfig.json --noEmit", + "test": "vitest run", + "test:e2e": "node --experimental-strip-types scripts/e2e.mts" + }, + "zcode": { + "title": "Invoice Maker", + "stub": [ + "unzipper" + ] + }, + "engines": { + "node": ">=22.0.0" + }, + "dependencies": { + "@modelcontextprotocol/sdk": "1.29.0", + "zod": "^4.6.5", + "exceljs": "4.4.0", + "pdf-lib": "1.17.1", + "fontkit": "2.0.4" + }, + "devDependencies": { + "@modelcontextprotocol/core": "2.0.0", + "@modelcontextprotocol/ext-apps": "2.0.0", + "@types/node": "25.5.0", + "esbuild": "^0.25.12", + "playwright-core": "1.59.1", + "typescript": "6.0.2", + "vitest": "4.1.4" + } +} diff --git a/ui-plugins/invoice-maker/scripts/build.mjs b/ui-plugins/invoice-maker/scripts/build.mjs new file mode 100644 index 00000000..02ff90d4 --- /dev/null +++ b/ui-plugins/invoice-maker/scripts/build.mjs @@ -0,0 +1,74 @@ +import { build } from "esbuild"; +import { copyFile, cp, mkdir, readFile, rm, writeFile } from "node:fs/promises"; +import { createRequire } from "node:module"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import { writeNotices } from "./licenses.mjs"; + +const root = resolve(dirname(fileURLToPath(import.meta.url)), ".."); +const dist = join(root, "dist"); +const pkg = JSON.parse(await readFile(join(root, "package.json"), "utf8")); +await rm(dist, { recursive: true, force: true }); +await mkdir(join(dist, "ui"), { recursive: true }); + +// 宿主只提供 HTML 本身,JS 与 CSS 全部内联到一个页面里。 +const ui = await build({ + metafile: true, + entryPoints: [join(root, "ui/main.ts")], + bundle: true, + format: "iife", + platform: "browser", + target: "es2022", + minify: true, + write: false, + outdir: join(dist, "ui"), + legalComments: "none", + loader: { ".css": "text" }, +}); +const js = ui.outputFiles.find((file) => file.path.endsWith(".js")).text; +const escape = (text) => text.replace(/<\/script/gi, "<\\/script"); +const html = `${pkg.zcode?.title ?? pkg.name}
`; +const htmlBytes = Buffer.byteLength(html); +if (htmlBytes > 4 * 1024 * 1024 - 64 * 1024) throw new Error(`panel.html is ${Math.round(htmlBytes / 1024)} KiB; keep it below 4 MiB`); +await writeFile(join(dist, "ui/panel.html"), html); + +// 用不到、且许可证不明的可选依赖(package.json 的 zcode.stub)替换为空模块。 +const stubs = pkg.zcode?.stub ?? []; +const stubPlugin = { + name: "stub", + setup(b) { + if (!stubs.length) return; + const filter = new RegExp(`^(${stubs.map((s) => s.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&")).join("|")})$`); + b.onResolve({ filter }, (args) => ({ path: args.path, namespace: "stub" })); + b.onLoad({ filter: /.*/, namespace: "stub" }, () => ({ contents: "module.exports = {};", loader: "js" })); + }, +}; + +const server = await build({ + plugins: [stubPlugin], + metafile: true, + entryPoints: [join(root, "src/main.ts")], + outfile: join(dist, "server.mjs"), + bundle: true, + platform: "node", + format: "esm", + target: "node22", + legalComments: "none", + banner: { + js: 'import { createRequire as __createRequire } from "node:module"; const require=__createRequire(import.meta.url);', + }, +}); + +// 运行时需要的 wasm 等文件(package.json 的 zcode.assets:{ 包内路径: 输出文件名 })。 +const require = createRequire(join(root, "package.json")); +for (const [from, to] of Object.entries(pkg.zcode?.assets ?? {})) await copyFile(require.resolve(from), join(dist, to)); + +// 整个目录(package.json 的 zcode.dirs:{ "包名:子目录": 输出目录 }),例如 pdf.js 的 CMap。 +for (const [spec, to] of Object.entries(pkg.zcode?.dirs ?? {})) { + const [name, sub] = spec.split(":"); + const base = dirname(require.resolve(`${name}/package.json`)); + await cp(join(base, sub), join(dist, to), { recursive: true, filter: (path) => !/(_nowasm_fallback\.js|quickjs-eval\.(js|wasm))$/.test(path) }); +} + +await writeNotices([ui.metafile, server.metafile], join(dist, "THIRD_PARTY_NOTICES.txt"), Object.keys(pkg.zcode?.assets ?? {})); +process.stdout.write(`${pkg.name}: panel ${Math.round(htmlBytes / 1024)} KiB, server ${Math.round((await readFile(join(dist, "server.mjs"))).length / 1024)} KiB\n`); diff --git a/ui-plugins/invoice-maker/scripts/e2e.mts b/ui-plugins/invoice-maker/scripts/e2e.mts new file mode 100644 index 00000000..42d8e2ee --- /dev/null +++ b/ui-plugins/invoice-maker/scripts/e2e.mts @@ -0,0 +1,76 @@ +// 浏览器端到端测试:真实打包的 server + 官方 AppBridge 宿主 + 隔离 iframe 中的面板。需要 Chrome。 +// 场景写在 test/e2e.json:用户在面板里选文件打开 → Agent 修改 → 用户在表格里改一格 → 导出。 +import assert from "node:assert/strict"; +import { cp, mkdir, mkdtemp, readFile, stat } from "node:fs/promises"; +import { existsSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import { startHarness } from "./harness.mjs"; + +const root = resolve(dirname(fileURLToPath(import.meta.url)), ".."); +const pkg = JSON.parse(await readFile(join(root, "package.json"), "utf8")); +const name = pkg.name.replace("@penova/plugin-", ""); +const spec = JSON.parse(await readFile(join(root, "test/e2e.json"), "utf8")); +const shots = process.env.E2E_SHOTS ?? join(tmpdir(), `${name}-shots`); +await mkdir(shots, { recursive: true }); +const workspace = await mkdtemp(join(tmpdir(), `${name}-e2e-`)); +const samples = process.env.SAMPLES ?? join(root, "test/samples"); +if (existsSync(samples)) await cp(samples, join(workspace, spec.folder ?? "samples"), { recursive: true }); + +const harness = await startHarness({ workspace }); +const step = (text: string) => process.stdout.write(`• ${text}\n`); +try { + const { outer, frame } = await harness.open("?locale=zh-CN", { width: 1400, height: 950 }); + step("user picks the sample in the panel and opens it"); + await frame.locator(".start").waitFor(); + for (const pick of spec.pick ?? []) await frame.locator("label.file", { hasText: pick }).first().click(); + for (const [key, value] of Object.entries(spec.startSettings ?? {})) { + const el = frame.locator(`.settings [data-key="${key}"]`); + if (typeof value === "boolean") await el.setChecked(value); + else if ((await el.evaluate((e) => e.tagName)) === "SELECT") await el.selectOption(String(value)); + else await el.fill(String(value)); + } + await frame.locator("button.open").click(); + await frame.locator(".project .summary").waitFor(); + const project = (await frame.locator(".pname").textContent())!.trim(); + if (spec.edit) { + step("agent edits the project"); + await harness.agent(outer, `${spec.prefix}_edit`, { project, ...spec.edit }); + } + if (spec.uiEdit) { + step("user edits a cell in the table"); + const input = frame.locator(`tr[data-row="${spec.uiEdit.row}"] td[data-key="${spec.uiEdit.key}"] input`); + await input.fill(String(spec.uiEdit.value)); + await input.press("Enter"); + await input.blur(); + await frame.waitForTimeout(800); + } + if (spec.expectText) await frame.locator("#root", { hasText: spec.expectText }).waitFor(); + await frame.waitForTimeout(400); + await outer.screenshot({ path: join(shots, "01-panel.png") }); + step("user exports"); + const all = frame.locator("button.expall"); + if (await all.count()) await all.click(); + else await frame.locator("button.exp").first().click(); + await frame.locator(".exported li").first().waitFor({ timeout: 300_000 }); + await frame.waitForTimeout(300); + await outer.screenshot({ path: join(shots, "02-exported.png") }); + const files = await frame.locator(".exported li").allTextContents(); + for (const f of files) assert.ok((await stat(join(workspace, f.trim()))).size > 0, `${f} is empty`); + for (const pattern of spec.expectFiles ?? []) assert.ok(files.some((f) => new RegExp(pattern).test(f)), `expected an exported file matching ${pattern}; got ${files.join(", ")}`); + + step("English panel"); + const en = await harness.open("?locale=en-US&theme=dark", { width: 1400, height: 950 }); + await harness.agent(en.outer, `${spec.prefix}_status`, { project }); + await en.frame.locator(".project .summary").waitFor(); + await en.frame.waitForTimeout(400); + await en.outer.screenshot({ path: join(shots, "03-en-dark.png") }); + assert.deepEqual(harness.errors, []); + step(`ok — ${files.length} file(s) exported; screenshots in ${shots}`); +} catch (error) { + console.error("page errors:", harness.errors, harness.stderr.join("")); + throw error; +} finally { + await harness.close(); +} diff --git a/ui-plugins/invoice-maker/scripts/harness.mjs b/ui-plugins/invoice-maker/scripts/harness.mjs new file mode 100644 index 00000000..a45e6e41 --- /dev/null +++ b/ui-plugins/invoice-maker/scripts/harness.mjs @@ -0,0 +1,162 @@ +import assert from "node:assert/strict"; +import { createServer } from "node:http"; +import { readFile } from "node:fs/promises"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import { build } from "esbuild"; +import { chromium } from "playwright-core"; +import { Client } from "@modelcontextprotocol/sdk/client/index.js"; +import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"; +import { ResourceUpdatedNotificationSchema } from "@modelcontextprotocol/sdk/types.js"; + +/** + * 浏览器测试宿主:真实打包的 server(stdio)+ 官方 AppBridge 宿主页 + 隔离 iframe 中的面板。 + * 宿主页用与 ZCode 相同的 CSP 约束面板。测试脚本同时扮演 Agent:经同一个 MCP 连接调用工具, + * 并像宿主一样把结果推给页面。 + */ +const root = resolve(dirname(fileURLToPath(import.meta.url)), ".."); + +// 与 ZCode 给 MCP App 页面的限制一致:没有网络,允许 wasm(声明了 zcode/csp.wasmUnsafeEval)。 +export const PANEL_CSP = + "default-src 'none'; script-src 'self' 'unsafe-inline' blob: data: 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data:; media-src 'self' data: blob:; worker-src 'self' blob:; connect-src 'none'; frame-src 'none'; base-uri 'self'; form-action 'none'"; + +/** server:要运行的 server 入口(默认真实打包的 dist/server.mjs)。 */ +export async function startHarness({ env = {}, workspace, server = join(root, "dist/server.mjs") }) { + const client = new Client({ name: "kit-harness", version: "1" }); + const sseClients = new Set(); + client.setNotificationHandler(ResourceUpdatedNotificationSchema, (notification) => { + for (const response of sseClients) response.write(`data: ${JSON.stringify(notification.params)}\n\n`); + }); + const stderr = []; + const transport = new StdioClientTransport({ + command: process.execPath, + args: [server], + cwd: workspace, + env: { ...process.env, ZCODE_WORKSPACE_ROOT: workspace, ...env }, + stderr: "pipe", + }); + transport.stderr?.on("data", (chunk) => stderr.push(String(chunk))); + await client.connect(transport); + const html = await readFile(join(root, "dist/ui/panel.html"), "utf8"); + const hostJs = await build({ + stdin: { + contents: ` +import { AppBridge, PostMessageTransport } from "@modelcontextprotocol/ext-apps/app-bridge"; +import { z } from "zod"; +const WidgetState = z.object({ method: z.literal('ui/set-widget-state'), params: z.object({ widgetState: z.unknown() }) }); +const rpc = async (method, args) => { + const response = await fetch('/rpc', {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({method,args})}); + const result = await response.json(); if (!response.ok) throw Error(result.error); return result; +}; +const params = new URLSearchParams(location.search); +const context = { theme: params.get('theme') || 'light', locale: params.get('locale') || 'en-US', displayMode: params.get('mode') || 'fullscreen' }; +const bridge = new AppBridge(null, {name:"kit-harness",version:"1"}, { + serverTools:{}, serverResources:{ listChanged: true }, message:{text:{}}, updateModelContext:{text:{}, structuredContent:{}}, openLinks:{}, + experimental: params.get('nosub') ? { "zcode/widgetState": {} } : { "zcode/resourceSubscribe": {}, "zcode/widgetState": {} }, +}, {hostContext:{...context, "zcode/widgetState": JSON.parse(sessionStorage.getItem('widgetState') || 'null')}}); +window.__messages = []; +window.__context = []; +window.__links = []; +window.__calls = []; +window.__initializations = 0; +bridge.oncalltool = (args) => { window.__calls.push(args.name); return rpc('callTool', args); }; +bridge.onreadresource = (args) => rpc('readResource', args); +bridge.onmessage = async (params) => { window.__messages.push(params.content[0].text); return {}; }; +bridge.onupdatemodelcontext = async (params) => { window.__context.push(params); return {}; }; +bridge.onopenlink = async (params) => { window.__links.push(params.url); return {}; }; +bridge.setRequestHandler('resources/subscribe', async (request) => { await rpc('subscribe', { uri: request.params.uri }); return {}; }); +bridge.setRequestHandler('resources/unsubscribe', async (request) => { await rpc('unsubscribe', { uri: request.params.uri }); return {}; }); +bridge.setRequestHandler(WidgetState, async (request) => { sessionStorage.setItem('widgetState', JSON.stringify(request.params.widgetState)); return {}; }); +bridge.oninitialized = () => { window.__initializations++; }; +window.__sendToolResult = (result) => bridge.sendToolResult(result); +window.__setContext = (patch) => bridge.setHostContext({ ...context, ...patch }); +new EventSource('/events').onmessage = (event) => { + bridge.notification({ method: 'notifications/resources/updated', params: JSON.parse(event.data) }); +}; +const frame = document.querySelector('iframe'); +await bridge.connect(new PostMessageTransport(frame.contentWindow, frame.contentWindow)); +frame.src = '/panel'; +`, + resolveDir: root, + sourcefile: "browser-host.mjs", + }, + bundle: true, + format: "esm", + platform: "browser", + write: false, + }); + const http = createServer(async (request, response) => { + try { + const url = new URL(request.url, "http://localhost"); + if (url.pathname === "/") { + response.setHeader("Content-Type", "text/html; charset=utf-8"); + response.end( + '', + ); + } else if (url.pathname === "/host.js") { + response.setHeader("Content-Type", "text/javascript"); + response.end(hostJs.outputFiles[0].text); + } else if (url.pathname === "/panel") { + response.setHeader("Content-Type", "text/html; charset=utf-8"); + response.setHeader("Content-Security-Policy", PANEL_CSP); + response.end(html); + } else if (url.pathname === "/events") { + response.writeHead(200, { "Content-Type": "text/event-stream", "Cache-Control": "no-cache" }); + response.write(": connected\n\n"); + sseClients.add(response); + request.on("close", () => sseClients.delete(response)); + } else if (request.method === "POST" && url.pathname === "/rpc") { + let body = ""; + for await (const chunk of request) body += chunk; + const { method, args } = JSON.parse(body); + const result = + method === "readResource" + ? await client.readResource(args) + : method === "subscribe" + ? await client.subscribeResource(args) + : method === "unsubscribe" + ? await client.unsubscribeResource(args) + : await client.callTool(args, undefined, { timeout: 300_000 }); + response.setHeader("Content-Type", "application/json"); + response.end(JSON.stringify(result ?? {})); + } else if (url.pathname === "/favicon.ico") response.writeHead(204).end(); + else response.writeHead(404).end(); + } catch (error) { + response.writeHead(500, { "Content-Type": "application/json" }).end(JSON.stringify({ error: String(error) })); + } + }); + await new Promise((done) => http.listen(0, "127.0.0.1", done)); + const base = `http://127.0.0.1:${http.address().port}`; + const browser = await chromium.launch(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : { channel: "chrome" }); + const errors = []; + const contexts = []; + + const open = async (query = "", viewport = { width: 720, height: 900 }) => { + const context = await browser.newContext({ viewport, deviceScaleFactor: 2 }); + contexts.push(context); + const outer = await context.newPage(); + outer.on("pageerror", (error) => errors.push(String(error))); + outer.on("console", (message) => { + if (message.type() === "error" && !/favicon/.test(message.text())) errors.push(message.text()); + }); + await outer.goto(`${base}/${query}`); + await outer.waitForFunction(() => window.__initializations === 1); + const frame = outer.frames().find((item) => item !== outer.mainFrame()); + assert.ok(frame, "official App iframe exists"); + return { outer, frame, context }; + }; + /** 扮演 Agent:调用工具,再像宿主一样把结果推给页面。 */ + const agent = async (outer, name, args, { expectError = false } = {}) => { + const result = await client.callTool({ name, arguments: args }, undefined, { timeout: 300_000 }); + if (expectError) assert.ok(result.isError, `${name} should fail`); + else assert.ok(!result.isError, `${name}: ${JSON.stringify(result.content)}`); + if (outer) await outer.evaluate((value) => window.__sendToolResult(value), result); + return result; + }; + const close = async () => { + await browser.close().catch(() => undefined); + await client.close().catch(() => undefined); + http.close(); + }; + return { client, open, agent, close, errors, stderr, base, contexts: () => contexts.filter((context) => context.pages().length) }; +} diff --git a/ui-plugins/invoice-maker/scripts/licenses.mjs b/ui-plugins/invoice-maker/scripts/licenses.mjs new file mode 100644 index 00000000..5107fe7c --- /dev/null +++ b/ui-plugins/invoice-maker/scripts/licenses.mjs @@ -0,0 +1,43 @@ +import { readFile, readdir, writeFile } from "node:fs/promises"; +import { dirname, join, resolve } from "node:path"; + +// 从实际参与打包的模块收集许可证,避免只列直接依赖而漏掉 Canvas/SDK 的传递依赖。 +export async function writeNotices(metafiles, destination, extra = []) { + const packages = new Map(); + const { createRequire } = await import("node:module"); + const require = createRequire(resolve("package.json")); + const extraInputs = extra.map((spec) => require.resolve(spec)); + for (const input of [...metafiles.flatMap((meta) => Object.keys(meta.inputs)), ...extraInputs]) { + if (!input.includes("node_modules/")) continue; + let directory = dirname(resolve(input)); + while (directory.includes("node_modules")) { + try { + const pkg = JSON.parse(await readFile(join(directory, "package.json"), "utf8")); + if (pkg.name && pkg.version) { + packages.set(directory, pkg); + break; + } + } catch (error) { + if (error.code !== "ENOENT") throw error; + } + directory = dirname(directory); + } + } + const notices = []; + const seen = new Set(); + for (const [directory, pkg] of [...packages].sort((a, b) => a[1].name.localeCompare(b[1].name))) { + const key = `${pkg.name}@${pkg.version}`; + if (seen.has(key)) continue; + seen.add(key); + const files = (await readdir(directory)).filter((name) => + /^(license|copying|notice)([.-]|$)/i.test(name), + ); + const texts = await Promise.all(files.map((file) => readFile(join(directory, file), "utf8"))); + if (!texts.length && !pkg.license) throw new Error(`Missing license for bundled dependency ${key}`); + if (!texts.length) texts.push(`(No license file is shipped in this package; its package.json declares the ${pkg.license} license.)`); + notices.push( + `${key} — ${typeof pkg.license === "string" ? pkg.license : JSON.stringify(pkg.license)}\n${texts.join("\n\n")}`, + ); + } + await writeFile(destination, notices.join("\n\n----------------------------------------\n\n")); +} diff --git a/ui-plugins/invoice-maker/src/invoice.ts b/ui-plugins/invoice-maker/src/invoice.ts new file mode 100644 index 00000000..d5c92a29 --- /dev/null +++ b/ui-plugins/invoice-maker/src/invoice.ts @@ -0,0 +1,167 @@ +import type { PDFPage } from "pdf-lib"; +import { num, round2 } from "./kit/columns.ts"; +import { esc } from "./kit/app.ts"; +import { hexRgb, MM, newPdf, PAGE, type PdfKit } from "./kit/pdf.ts"; + +export interface Line { invoice: string; client: string; address: string; item: string; qty: unknown; price: unknown; tax: unknown; currency?: unknown } +export interface Settings { + seller: string; sellerInfo: string; currency: string; taxRate: number; prefix: string; start: number; date: string; dueDays: number; + notes: string; accent: string; paper: "A4" | "Letter"; lang: "zh" | "en" | "both"; +} +export interface Invoice { number: string; client: string; address: string; lines: (Line & { index: number; q: number; p: number; t: number; amount: number; taxAmount: number })[]; subtotal: number; tax: number; total: number; date: string; due: string; currency: string } + +export const SYMBOL: Record = { CNY: "¥", USD: "$", EUR: "€", GBP: "£", JPY: "¥", HKD: "HK$", TWD: "NT$", SGD: "S$", AUD: "A$", CAD: "C$" }; +export const CODES = Object.keys(SYMBOL); +const CODE_ALIAS: Record = { RMB: "CNY", "人民币": "CNY", "元": "CNY", "美元": "USD", "欧元": "EUR", "英镑": "GBP", "日元": "JPY", "円": "JPY", "港币": "HKD", "港元": "HKD", "新台币": "TWD", "新加坡元": "SGD", "澳元": "AUD", "加元": "CAD" }; +/** + * 从单价或币种单元格里认出币种:先认代码(USD、RMB…)和中文名,再认带前缀的符号(HK$、NT$、US$…), + * 最后认单个符号($→USD,€→EUR,£→GBP,¥/¥→ 设置是 JPY 时为 JPY,否则 CNY)。认不出返回 undefined。 + */ +export function detectCurrency(value: unknown, fallback = "CNY"): string | undefined { + if (typeof value === "number") return undefined; + const t = String(value ?? "").trim(); + if (!t) return undefined; + const code = t.toUpperCase().match(/(?:^|[^A-Z])([A-Z]{3})(?![A-Z])/)?.[1]; + if (code && (CODES.includes(code) || code in CODE_ALIAS)) return CODE_ALIAS[code] ?? code; + for (const [k, v] of Object.entries(CODE_ALIAS).sort((x, y) => y[0].length - x[0].length)) if (/[^A-Z]/.test(k) && t.includes(k)) return v; + const pre = t.match(/(US|HK|NT|S|A|C)\$/i)?.[1]?.toUpperCase(); + if (pre) return ({ US: "USD", HK: "HKD", NT: "TWD", S: "SGD", A: "AUD", C: "CAD" } as Record)[pre]; + if (t.includes("$")) return "USD"; + if (t.includes("€")) return "EUR"; + if (t.includes("£")) return "GBP"; + if (/[¥¥]/.test(t)) return fallback === "JPY" ? "JPY" : "CNY"; + return undefined; +} +const stripMoney = (v: unknown) => (typeof v === "number" ? v : String(v ?? "").replace(/(US|HK|NT|S|A|C)\$/gi, "").replace(/(? `${SYMBOL[cur] ?? cur + " "}${(cur === "JPY" ? Math.round(n) : n).toLocaleString("en-US", { minimumFractionDigits: cur === "JPY" ? 0 : 2, maximumFractionDigits: cur === "JPY" ? 0 : 2 })}`; + +const CN_NUM: Record = { 零: 0, 一: 1, 二: 2, 两: 2, 三: 3, 四: 4, 五: 5, 六: 6, 七: 7, 八: 8, 九: 9, 十: 10 }; +export const qtyOf = (v: unknown) => { const s = String(v ?? "").trim(); return s in CN_NUM ? CN_NUM[s] : num(v === "" ? 1 : v); }; + +function addDays(date: string, days: number) { + const d = new Date(`${date}T00:00:00Z`); + d.setUTCDate(d.getUTCDate() + days); + return d.toISOString().slice(0, 10); +} + +/** 按发票号(或客户)分组,算每行金额、税额与合计;没有发票号的按客户依次编号。 */ +export function buildInvoices(lines: Line[], s: Settings) { + const issues: { level: "error" | "warn" | "info"; message: string; row?: number; key?: string }[] = []; + const groups = new Map(); + let next = s.start; + const autoNumbers = new Map(); + lines.forEach((line, index) => { + const q = qtyOf(line.qty), p = num(stripMoney(line.price)); + const t = line.tax === "" || line.tax === undefined || line.tax === null ? s.taxRate : num(line.tax); + if (!String(line.client ?? "").trim()) issues.push({ level: "error", row: index, key: "client", message: "Missing client / 缺少客户" }); + if (!String(line.item ?? "").trim()) issues.push({ level: "warn", row: index, key: "item", message: "Empty item description / 项目说明为空" }); + if (!Number.isFinite(q)) issues.push({ level: "error", row: index, key: "qty", message: `Quantity is not a number: "${line.qty}" / 数量不是数字` }); + if (!Number.isFinite(p)) issues.push({ level: "error", row: index, key: "price", message: `Price is not a number: "${line.price}" / 单价不是数字` }); + if (!Number.isFinite(t) || t < 0 || t > 100) issues.push({ level: "error", row: index, key: "tax", message: `Tax rate must be 0–100: "${line.tax}" / 税率应在 0–100` }); + const colCur = String(line.currency ?? "").trim(); + const lineCur = colCur ? detectCurrency(colCur, s.currency) ?? (CODES.includes(colCur.toUpperCase()) ? colCur.toUpperCase() : undefined) : detectCurrency(line.price, s.currency); + if (colCur && !lineCur) issues.push({ level: "error", row: index, key: "currency", message: `Unknown currency "${colCur}" (use ${CODES.join(", ")}) / 认不出的币种` }); + const client = String(line.client ?? "").trim(); + let key: string; + if (String(line.invoice ?? "").trim()) key = String(line.invoice).trim(); + else { + if (!autoNumbers.has(client)) autoNumbers.set(client, `${s.prefix}${String(next++).padStart(4, "0")}`); + key = autoNumbers.get(client)!; + } + let inv = groups.get(key!); + if (!inv) { + inv = { number: key!, client, address: String(line.address ?? "").trim(), lines: [], subtotal: 0, tax: 0, total: 0, date: s.date, due: addDays(s.date, s.dueDays), currency: "" }; + groups.set(key!, inv); + } else if (client && inv.client && client !== inv.client) issues.push({ level: "error", row: index, key: "invoice", message: `Invoice ${key} already belongs to "${inv.client}" / 同一发票号对应了不同客户` }); + if (!inv.address && line.address) inv.address = String(line.address).trim(); + if (lineCur) { + if (!inv.currency) inv.currency = lineCur; + else if (inv.currency !== lineCur) issues.push({ level: "error", row: index, key: "price", message: `Invoice ${key} mixes currencies (${inv.currency} and ${lineCur}) / 同一张发票里币种不一致` }); + } + const qq = Number.isFinite(q) ? q : 0, pp = Number.isFinite(p) ? p : 0, tt = Number.isFinite(t) ? t : 0; + const amount = round2(qq * pp), taxAmount = round2((amount * tt) / 100); + inv.lines.push({ ...line, index, q: qq, p: pp, t: tt, amount, taxAmount }); + }); + for (const inv of groups.values()) { + if (!inv.currency) inv.currency = s.currency; + else if (inv.currency !== s.currency) issues.push({ level: "info", row: inv.lines[0].index, message: `Invoice ${inv.number} is in ${inv.currency} (from the sheet), not the default ${s.currency} / 按表里的币种 ${inv.currency} 开票` }); + inv.subtotal = round2(inv.lines.reduce((a, l) => a + l.amount, 0)); + inv.tax = round2(inv.lines.reduce((a, l) => a + l.taxAmount, 0)); + inv.total = round2(inv.subtotal + inv.tax); + if (inv.total <= 0) issues.push({ level: "warn", row: inv.lines[0].index, message: `Invoice ${inv.number} total is ${inv.total} / 发票合计不大于 0` }); + if (!inv.address) issues.push({ level: "warn", row: inv.lines[0].index, key: "address", message: `Invoice ${inv.number}: no client address / 没有客户地址` }); + } + if (!s.seller.trim()) issues.push({ level: "warn", message: "Set your business name in settings (seller) / 请在设置里填写开票方名称" }); + return { invoices: [...groups.values()], issues }; +} + +const L = (s: Settings, zh: string, en: string) => (s.lang === "zh" ? zh : s.lang === "en" ? en : `${zh} ${en}`); + +export function previewHtml(inv: Invoice | undefined, s: Settings, count: number) { + if (!inv) return ""; + const rows = inv.lines.map((l) => `${esc(l.item)}${l.q}${esc(money(l.p, inv.currency))}${l.t}%${esc(money(l.amount, inv.currency))}`).join(""); + return `
${esc(s.seller || "—")}
${esc(s.sellerInfo)}
${esc(L(s, "发票", "INVOICE"))}
${esc(inv.number)}
${esc(inv.date)} → ${esc(inv.due)}
+

${esc(L(s, "客户", "Bill to"))}: ${esc(inv.client)}
${esc(inv.address)}

+${rows}
${esc(L(s, "项目", "Item"))}${esc(L(s, "数量", "Qty"))}${esc(L(s, "单价", "Price"))}${esc(L(s, "税率", "Tax"))}${esc(L(s, "金额", "Amount"))}
+

${esc(L(s, "小计", "Subtotal"))} ${esc(money(inv.subtotal, inv.currency))} · ${esc(L(s, "税额", "Tax"))} ${esc(money(inv.tax, inv.currency))}
${esc(L(s, "合计", "Total"))} ${esc(money(inv.total, inv.currency))}

+${count > 1 ? `

1 / ${count}

` : ""}
`; +} + +function drawInvoice(k: PdfKit, page: PDFPage, inv: Invoice, s: Settings) { + const size = page.getSize(); + const w = size.width, h = size.height; + const m = 18 * MM; + const accent = hexRgb(s.accent, "#2563eb"); + page.drawRectangle({ x: 0, y: h - 6, width: w, height: 6, color: accent }); + let y = h - m; + k.text(page, s.seller || "", m, y - 4, { size: 15, bold: true, maxWidth: w / 2 }); + let yy = y - 20; + for (const line of s.sellerInfo.split(/\r?\n/).filter(Boolean).slice(0, 5)) { k.text(page, line, m, yy, { size: 9, color: "#6b7280", maxWidth: w / 2 }); yy -= 12; } + k.text(page, L(s, "发票", "INVOICE"), w - m, y - 4, { size: 20, bold: true, color: s.accent, align: "right" }); + k.text(page, `${L(s, "编号", "No.")} ${inv.number}`, w - m, y - 24, { size: 10, align: "right" }); + k.text(page, `${L(s, "开票日期", "Date")} ${inv.date}`, w - m, y - 37, { size: 9, align: "right", color: "#374151" }); + k.text(page, `${L(s, "付款期限", "Due")} ${inv.due}`, w - m, y - 49, { size: 9, align: "right", color: "#374151" }); + y = Math.min(yy, y - 60) - 16; + k.text(page, L(s, "客户", "Bill to"), m, y, { size: 9, color: "#6b7280" }); + k.text(page, inv.client, m, y - 14, { size: 12, bold: true, maxWidth: w - 2 * m }); + let ay = y - 28; + for (const line of k.wrap(inv.address, 9, w / 2).slice(0, 3)) { k.text(page, line, m, ay, { size: 9, color: "#374151" }); ay -= 12; } + y = ay - 14; + const cols = [m, w - m - 300, w - m - 230, w - m - 140, w - m - 70]; + const header = [L(s, "项目", "Item"), L(s, "数量", "Qty"), L(s, "单价", "Price"), L(s, "税率", "Tax"), L(s, "金额", "Amount")]; + page.drawRectangle({ x: m, y: y - 6, width: w - 2 * m, height: 20, color: hexRgb("#f3f4f6") }); + header.forEach((t, i) => k.text(page, t, i === 0 ? cols[0] + 4 : i === 4 ? w - m - 4 : cols[i] + 60, y, { size: 9, bold: true, align: i === 0 ? "left" : "right" })); + y -= 22; + for (const l of inv.lines) { + const desc = k.wrap(String(l.item ?? ""), 9.5, cols[1] - cols[0] - 10); + if (y - desc.length * 12 < 120) break; // v0.1:单页发票,超出的行在问题列表里提示 + desc.forEach((d, i) => k.text(page, d, cols[0] + 4, y - i * 12, { size: 9.5 })); + k.text(page, String(l.q), cols[1] + 60, y, { size: 9.5, align: "right" }); + k.text(page, money(l.p, inv.currency), cols[2] + 60, y, { size: 9.5, align: "right" }); + k.text(page, `${l.t}%`, cols[3] + 60, y, { size: 9.5, align: "right" }); + k.text(page, money(l.amount, inv.currency), w - m - 4, y, { size: 9.5, align: "right" }); + y -= desc.length * 12 + 6; + page.drawLine({ start: { x: m, y: y + 11 }, end: { x: w - m, y: y + 11 }, thickness: 0.4, color: hexRgb("#e5e7eb") }); + } + y -= 8; + const tot = [[L(s, "小计", "Subtotal"), money(inv.subtotal, inv.currency)], [L(s, "税额", "Tax"), money(inv.tax, inv.currency)]]; + for (const [a, b] of tot) { k.text(page, a, w - m - 150, y, { size: 10, color: "#374151" }); k.text(page, b, w - m - 4, y, { size: 10, align: "right" }); y -= 15; } + page.drawRectangle({ x: w - m - 160, y: y - 8, width: 160, height: 22, color: accent }); + k.text(page, L(s, "合计", "Total"), w - m - 150, y - 1, { size: 11, bold: true, color: "#ffffff" }); + k.text(page, money(inv.total, inv.currency), w - m - 6, y - 1, { size: 11, bold: true, color: "#ffffff", align: "right" }); + if (s.notes.trim()) { + let ny = 100; + for (const line of k.wrap(s.notes, 9, w - 2 * m).slice(0, 5)) { k.text(page, line, m, ny, { size: 9, color: "#4b5563" }); ny -= 12; } + } +} + +export function invoiceTooLong(inv: Invoice) { + return inv.lines.length > 22; +} + +export async function renderPdf(invoices: Invoice[], s: Settings, fontPath?: string) { + const k = await newPdf(fontPath); + for (const inv of invoices) drawInvoice(k, k.doc.addPage(PAGE[s.paper] ?? PAGE.A4), inv, s); + return { bytes: await k.doc.save(), cjk: k.cjk }; +} diff --git a/ui-plugins/invoice-maker/src/kit/app.ts b/ui-plugins/invoice-maker/src/kit/app.ts new file mode 100644 index 00000000..c552e016 --- /dev/null +++ b/ui-plugins/invoice-maker/src/kit/app.ts @@ -0,0 +1,417 @@ +import { readFile } from "node:fs/promises"; +import { join } from "node:path"; +import { z } from "zod"; +import { createKitServer } from "./server-kit.ts"; +import { KitError, safeFileName, Workspace } from "./workspace.ts"; + +/** 双语文案:[中文, English]。 */ +export type L = [string, string]; +export type Row = Record; + +export interface Field { + key: string; + label: L; + type: "text" | "number" | "bool" | "select" | "color" | "textarea" | "date"; + options?: { value: string; label: L }[]; + default?: unknown; + help?: L; + min?: number; + max?: number; + /** 改了需要重新读取输入文件。 */ + reload?: boolean; +} + +export interface Column { + key: string; + label: L; + type?: "text" | "number" | "bool" | "select" | "date"; + options?: string[]; + readOnly?: boolean; + wide?: boolean; +} + +export interface Issue { + level: "error" | "warn" | "info"; + message: string; + row?: number; + key?: string; +} + +export interface Project { + name: string; + inputs: string[]; + settings: Record; + rows: Row[]; + meta: Record; + exported?: string[]; + created: string; + updated: string; +} + +export interface Computed { + /** 与 project.rows 一一对应(同顺序),可附加只读的计算列。 */ + rows?: Row[]; + issues?: Issue[]; + summary: string; + /** 面板预览:由插件生成、已转义的 HTML(可含 data: 图片)。 */ + preview?: string; + stats?: Record; +} + +export interface AppCtx { + ws: Workspace; + assetRoot: string; + log: (line: string) => void; +} + +export interface ExportCtx extends AppCtx { + project: Project; + computed: Computed; + outDir: string; + /** 写入导出目录下的文件,返回工作区相对路径。 */ + write: (name: string, data: Uint8Array | string) => Promise; +} + +export interface ExportDef { + id: string; + label: L; + description: string; + run: (ctx: ExportCtx) => Promise; +} + +export interface AppDef { + name: string; + version: string; + /** 工具名前缀,例如 "invoice" → invoice_open。 */ + prefix: string; + title: L; + /** invoice_open 的说明(给 Agent 看)。 */ + openDescription: string; + inputs: { exts: string[]; min: number; max: number; label: L; folders?: boolean }; + settings: Field[]; + columns: (project: Project) => Column[]; + load: (ctx: AppCtx & { files: string[]; settings: Record }) => Promise<{ rows: Row[]; meta?: Record }>; + compute: (project: Project, ctx: AppCtx) => Promise | Computed; + exports: ExportDef[]; + /** 允许在面板 / 工具里新增行时的空白行。 */ + newRow?: (project: Project) => Row; + /** 行描述(给 Agent 的文字列表),默认取前几列。 */ + describeRow?: (row: Row, index: number) => string; +} + +const MAX_ROWS_PANEL = 3000; + +export function coerceSettings(fields: Field[], input: Record | undefined, base: Record = {}) { + const out: Record = {}; + for (const field of fields) { + let value = input && field.key in input ? input[field.key] : field.key in base ? base[field.key] : field.default; + if (value === undefined || value === null) { + if (field.default !== undefined) out[field.key] = field.default; + continue; + } + if (field.type === "number") { + const n = typeof value === "number" ? value : Number(String(value).trim()); + if (!Number.isFinite(n)) throw new KitError("bad_setting", `${field.key} must be a number (got ${JSON.stringify(value)}).`); + value = Math.min(field.max ?? Infinity, Math.max(field.min ?? -Infinity, n)); + } else if (field.type === "bool") value = value === true || value === "true" || value === 1 || value === "1" || value === "yes"; + else if (field.type === "select") { + value = String(value); + if (field.options && !field.options.some((o) => o.value === value)) throw new KitError("bad_setting", `${field.key} must be one of ${field.options.map((o) => o.value).join(", ")} (got ${value}).`); + } else value = String(value); + out[field.key] = value; + } + return out; +} + +/** + * 把 _edit 里的列名解析成列 key:先精确匹配 key,再精确匹配中/英文标题, + * 最后忽略大小写和空白再比一次;行里已有的字段名也算。找不到返回 undefined。 + */ +export function resolveColumnKey(cols: Column[], name: string, row?: Row): string | undefined { + if (cols.some((c) => c.key === name)) return name; + const exact = cols.find((c) => c.label[0] === name || c.label[1] === name); + if (exact) return exact.key; + const norm = (x: string) => x.normalize("NFKC").replace(/\s+/g, "").toLowerCase(); + const n = norm(name); + const loose = cols.find((c) => norm(c.key) === n || norm(c.label[0]) === n || norm(c.label[1]) === n); + if (loose) return loose.key; + if (row && Object.prototype.hasOwnProperty.call(row, name)) return name; + return undefined; +} + +export function coerceCell(column: Column | undefined, value: unknown): unknown { + if (!column) return value; + if (column.type === "number") { + if (value === "" || value === null || value === undefined) return ""; + const n = typeof value === "number" ? value : Number(String(value).replace(/[,,\s]/g, "")); + return Number.isFinite(n) ? n : String(value); + } + if (column.type === "bool") return value === true || value === "true" || value === 1 || value === "1" || value === "yes"; + return value === null || value === undefined ? "" : String(value); +} + +const stem = (path: string) => (path.split("/").pop() ?? path).replace(/\.[^.]+$/, ""); + +export function createApp(def: AppDef, options: { workspaceRoot: string; assetRoot: string; log?: (line: string) => void }) { + const ws = new Workspace(options.workspaceRoot); + const log = options.log ?? (() => undefined); + const ctx: AppCtx = { ws, assetRoot: options.assetRoot, log }; + const PANEL_URI = `ui://${def.name}/panel.html`; + const { server, tool } = createKitServer({ + name: def.name, + version: def.version, + panelUri: PANEL_URI, + surface: "editor", + panelHtml: () => readFile(join(options.assetRoot, "ui/panel.html"), "utf8"), + log, + }); + const P = def.prefix; + const projectPath = (name: string) => `${def.name}/${safeFileName(name, "project")}.project.json`; + let queue: Promise = Promise.resolve(); + const serial = (work: () => Promise): Promise => { + const job = queue.catch(() => undefined).then(work); + queue = job; + return job; + }; + + async function loadProject(name: string): Promise { + if (!name) throw new KitError("missing_project", "Pass `project` (from the open result)."); + const path = projectPath(name); + if (!(await ws.exists(path))) throw new KitError("no_project", `No project named "${name}". Open input files first with ${P}_open.`); + return JSON.parse(await ws.readText(path)) as Project; + } + async function saveProject(project: Project) { + project.updated = new Date().toISOString(); + await ws.write(projectPath(project.name), JSON.stringify(project, null, 1) + "\n"); + } + async function listProjects() { + const files = await ws.list({ dir: def.name, exts: [".json"], recursive: false, limit: 500 }).catch(() => []); + return files.map((f) => f.path).filter((p) => p.endsWith(".project.json")).map((p) => p.split("/").pop()!.replace(/\.project\.json$/, "")); + } + + async function view(project: Project, extra: Record = {}) { + const computed = await def.compute(project, ctx); + const columns = def.columns(project); + const rows = computed.rows ?? project.rows; + return { + computed, + structured: { + kind: "project", + app: def.name, + project: project.name, + inputs: project.inputs, + settings: project.settings, + columns, + rows: rows.slice(0, MAX_ROWS_PANEL), + totalRows: rows.length, + canAdd: !!def.newRow, + issues: (computed.issues ?? []).slice(0, 500), + summary: computed.summary, + stats: computed.stats ?? {}, + preview: computed.preview ?? "", + exported: project.exported ?? [], + ...extra, + }, + }; + } + function describe(project: Project, computed: Computed, limit = 25) { + const rows = computed.rows ?? project.rows; + const cols = def.columns(project); + const line = def.describeRow ?? ((row: Row, i: number) => `#${i} ` + cols.slice(0, 5).map((c) => `${c.key}=${String(row[c.key] ?? "").slice(0, 40)}`).join(" · ")); + const issues = computed.issues ?? []; + return [ + `Project "${project.name}" (${project.inputs.join(", ") || "no input files"}): ${computed.summary}`, + issues.length ? `Issues (${issues.length}):\n` + issues.slice(0, 30).map((x) => `- [${x.level}]${x.row !== undefined ? ` row #${x.row}` : ""}${x.key ? ` ${x.key}` : ""}: ${x.message}`).join("\n") + (issues.length > 30 ? `\n… ${issues.length - 30} more in the panel.` : "") : "No issues found.", + rows.length ? `Rows (${rows.length}):\n` + rows.slice(0, limit).map((r, i) => line(r, i)).join("\n") + (rows.length > limit ? `\n… ${rows.length - limit} more rows in the panel.` : "") : "", + `Exports: ${def.exports.map((e) => `${e.id} (${e.description})`).join("; ")}. Edit with ${P}_edit, export with ${P}_export.`, + ].filter(Boolean).join("\n\n"); + } + + const settingsDoc = def.settings.map((f) => `${f.key} (${f.type}${f.options ? `: ${f.options.map((o) => o.value).join("|")}` : ""}${f.default !== undefined ? `, default ${JSON.stringify(f.default)}` : ""})${f.help ? ` — ${f.help[1]}` : ""}`).join("; "); + + tool( + `${P}_open`, + { + description: `${def.openDescription} Opens the editing panel. Settings: ${settingsDoc || "none"}. Re-opening the same project name replaces its rows with a fresh read of the inputs.`, + input: { + inputs: z.array(z.string()).describe(`Workspace-relative input paths (${def.inputs.exts.join(", ")}${def.inputs.folders ? " or folders" : ""}); ${def.inputs.min}–${def.inputs.max} item(s).`), + settings: z.record(z.string(), z.unknown()).optional(), + project: z.string().optional().describe("Project name (default: first input's file name)."), + }, + openPanel: true, + timeoutMs: 600_000, + }, + (args) => + serial(async () => { + const inputs: string[] = args.inputs ?? []; + if (inputs.length < def.inputs.min) throw new KitError("missing_input", `Pass at least ${def.inputs.min} input file(s) (${def.inputs.exts.join(", ")}).`); + if (inputs.length > def.inputs.max) throw new KitError("too_many_inputs", `At most ${def.inputs.max} input(s).`); + for (const i of inputs) ws.resolve(i); + const name = safeFileName(args.project || (inputs[0] ? stem(inputs[0]) : def.name), "project"); + const settings = coerceSettings(def.settings, args.settings); + const loaded = await def.load({ ...ctx, files: inputs, settings }); + const now = new Date().toISOString(); + const project: Project = { name, inputs, settings, rows: loaded.rows, meta: loaded.meta ?? {}, created: now, updated: now }; + await saveProject(project); + const v = await view(project); + return { text: describe(project, v.computed), structured: v.structured }; + }), + ); + + tool( + `${P}_edit`, + { + description: `Change a ${def.name} project: update settings, set cell values by row index (from ${P}_open / ${P}_status), add rows${def.newRow ? "" : " (not supported here)"} or remove rows. Changes are saved; returns the updated summary and issues.`, + input: { + project: z.string(), + settings: z.record(z.string(), z.unknown()).optional(), + set: z.array(z.object({ row: z.number().int().min(0), values: z.record(z.string(), z.unknown()) })).optional(), + add: z.array(z.record(z.string(), z.unknown())).optional(), + remove: z.array(z.number().int().min(0)).optional(), + }, + timeoutMs: 600_000, + }, + (args) => + serial(async () => { + const project = await loadProject(args.project); + const notes: string[] = []; + if (args.settings) { + const next = coerceSettings(def.settings, args.settings, project.settings); + const reload = def.settings.some((f) => f.reload && JSON.stringify(next[f.key]) !== JSON.stringify(project.settings[f.key])); + project.settings = next; + if (reload) { + const loaded = await def.load({ ...ctx, files: project.inputs, settings: next }); + project.rows = loaded.rows; + project.meta = loaded.meta ?? project.meta; + notes.push("Inputs re-read with the new settings (row edits were reset)."); + } + } + const cols = def.columns(project); + const byKey = new Map(cols.map((c) => [c.key, c])); + const unknown = new Set(); + for (const s of args.set ?? []) { + const row = project.rows[s.row]; + if (!row) { notes.push(`Row #${s.row} does not exist.`); continue; } + for (const [name, v] of Object.entries(s.values)) { + const k = resolveColumnKey(cols, name, row); + if (k === undefined) { unknown.add(name); continue; } + const c = byKey.get(k); + if (c?.readOnly) { notes.push(`${k} is calculated and cannot be edited.`); continue; } + row[k] = coerceCell(c, v); + } + } + if (args.add?.length) { + if (!def.newRow) throw new KitError("no_add", "This tool does not support adding rows."); + for (const a of args.add) { + const row = def.newRow(project); + for (const [name, v] of Object.entries(a)) { + const k = resolveColumnKey(cols, name, row); + if (k === undefined) { unknown.add(name); continue; } + row[k] = coerceCell(byKey.get(k), v); + } + project.rows.push(row); + } + } + if (unknown.size) notes.push(`Warning: ignored unknown column(s) ${[...unknown].map((u) => `“${u}”`).join(", ")}. Use a column key or its label: ${cols.map((c) => `${c.key} (${c.label[0]} / ${c.label[1]})`).join(", ")}.`); + if (args.remove?.length) { + const drop = new Set(args.remove); + project.rows = project.rows.filter((_, i) => !drop.has(i)); + } + await saveProject(project); + const v = await view(project); + return { text: [notes.join(" "), describe(project, v.computed, 10)].filter(Boolean).join("\n\n"), structured: v.structured }; + }), + ); + + tool( + `${P}_status`, + { description: `Show a ${def.name} project's rows, issues and summary (no changes).`, input: { project: z.string(), limit: z.number().int().min(1).max(500).optional() }, readOnly: true }, + async (args) => { + const project = await loadProject(args.project); + const v = await view(project); + return { text: describe(project, v.computed, args.limit ?? 50), structured: v.structured }; + }, + ); + + tool( + `${P}_export`, + { + description: `Write the finished files for a ${def.name} project into ${def.name}// in the workspace. Formats: ${def.exports.map((e) => `"${e.id}" — ${e.description}`).join("; ")}.`, + input: { project: z.string(), formats: z.array(z.enum(def.exports.map((e) => e.id) as [string, ...string[]])).optional().describe("Default: all formats.") }, + timeoutMs: 900_000, + }, + (args) => + serial(async () => { + const project = await loadProject(args.project); + const computed = await def.compute(project, ctx); + if ((computed.issues ?? []).some((i) => i.level === "error") && !def.exports.length) throw new KitError("has_errors", "Fix the errors first."); + const outDir = `${def.name}/${safeFileName(project.name, "project")}`; + const ids = args.formats?.length ? args.formats : def.exports.map((e) => e.id); + const files: string[] = []; + const notes: string[] = []; + for (const id of ids) { + const ex = def.exports.find((e) => e.id === id)!; + const result = await ex.run({ ...ctx, project, computed, outDir, write: (n, d) => ws.write(`${outDir}/${n}`, d) }); + if (Array.isArray(result)) files.push(...result); + else { files.push(...result.files); if (result.note) notes.push(result.note); } + } + project.exported = files; + await saveProject(project); + const v = await view(project, { justExported: files }); + const errors = (computed.issues ?? []).filter((i) => i.level === "error").length; + return { + text: `Exported ${files.length} file(s):\n${files.map((f) => `- ${f}`).join("\n")}${notes.length ? `\n${notes.join("\n")}` : ""}${errors ? `\nNote: ${errors} error(s) are still open in the project.` : ""}`, + structured: v.structured, + }; + }), + ); + + tool( + "app_info", + { description: "Panel bootstrap: tool definition, workspace files and saved projects.", input: {}, visibility: ["app"], readOnly: true }, + async () => { + const files = (await ws.list({ exts: def.inputs.exts, limit: 3000 })).map((f) => f.path).filter((p) => !p.startsWith(`${def.name}/`)); + const folders = def.inputs.folders ? [...new Set(files.map((f) => f.split("/").slice(0, -1).join("/") || "."))].sort() : []; + return { + text: "", + structured: { + kind: "info", + app: def.name, + prefix: P, + title: def.title, + inputs: def.inputs, + settings: def.settings, + exports: def.exports.map((e) => ({ id: e.id, label: e.label, description: e.description })), + files, + folders, + projects: await listProjects(), + }, + }; + }, + ); + + return { server, ws, PANEL_URI }; +} + +/** HTML 转义。 */ +export const esc = (value: unknown) => + String(value ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]!); + +/** 简单 HTML 表格(用于预览与报告)。 */ +export function htmlTable(headers: string[], rows: unknown[][], cls = "data") { + return `${headers.map((h) => ``).join("")}${rows.map((r) => `${r.map((c) => ``).join("")}`).join("")}
${esc(h)}
${esc(c)}
`; +} + +/** 独立 HTML 报告页。 */ +export function htmlPage(title: string, body: string, extraCss = "") { + return `${esc(title)}${body}`; +} + +/** CSV(带 BOM,Excel 打开中文不乱码)。 */ +export function toCsv(headers: string[], rows: unknown[][]) { + const cell = (v: unknown) => { + const s = String(v ?? ""); + return /[",\n\r]/.test(s) ? `"${s.replace(/"/g, '""')}"` : s; + }; + return "\uFEFF" + [headers, ...rows].map((r) => r.map(cell).join(",")).join("\r\n") + "\r\n"; +} diff --git a/ui-plugins/invoice-maker/src/kit/columns.ts b/ui-plugins/invoice-maker/src/kit/columns.ts new file mode 100644 index 00000000..4cb79023 --- /dev/null +++ b/ui-plugins/invoice-maker/src/kit/columns.ts @@ -0,0 +1,53 @@ +/** 表头别名匹配:把用户表格里的中英文列名对应到插件字段。 */ +const norm = (s: string) => s.toLowerCase().replace(/[\s_\-::()().#]/g, ""); + +export function mapHeaders(headers: string[], aliases: Record): Record { + const out: Record = {}; + const used = new Set(); + const nh = headers.map((h) => [h, norm(h)] as const); + for (const [key, names] of Object.entries(aliases)) { + const wanted = [key, ...names].map(norm); + let hit = nh.find(([h, n]) => !used.has(h) && wanted.includes(n)); + hit ??= nh.find(([h, n]) => !used.has(h) && wanted.some((w) => w.length >= 2 && n.includes(w))); + if (hit) { out[key] = hit[0]; used.add(hit[0]); } + } + return out; +} + +/** 解析金额 / 数字:"¥1,234.50"、"12%"、"(3)"、全角数字。失败返回 NaN。 */ +export function num(value: unknown): number { + if (typeof value === "number") return value; + let s = String(value ?? "").trim().replace(/[0-9.-]/g, (c) => String.fromCharCode(c.charCodeAt(0) - 0xfee0)); + if (!s) return NaN; + let neg = false; + if (/^\(.*\)$|^(.*)$/.test(s)) { neg = true; s = s.slice(1, -1); } + s = s.replace(/[¥¥$€£,,\s元]|RMB|CNY|USD|EUR/gi, ""); + if (s.endsWith("%")) s = s.slice(0, -1); + const n = Number(s); + return neg ? -n : n; +} + +export const round2 = (n: number) => Math.round((n + Number.EPSILON) * 100) / 100; + +/** 解析日期:2026-11-25、2026/11/25、2026年11月25日、11/25/2026、Excel 序号。返回 YYYY-MM-DD 或 ""。 */ +export function parseDate(value: unknown): string { + if (value instanceof Date && !isNaN(+value)) return value.toISOString().slice(0, 10); + const s = String(value ?? "").trim(); + if (!s) return ""; + let m = /^(\d{4})[-/.年](\d{1,2})[-/.月](\d{1,2})日?/.exec(s); + if (m) return `${m[1]}-${m[2].padStart(2, "0")}-${m[3].padStart(2, "0")}`; + m = /^(\d{1,2})\/(\d{1,2})\/(\d{4})/.exec(s); + if (m) return `${m[3]}-${m[1].padStart(2, "0")}-${m[2].padStart(2, "0")}`; + if (/^\d{5}(\.\d+)?$/.test(s)) { + const d = new Date(Date.UTC(1899, 11, 30) + Number(s) * 86400000); + return d.toISOString().slice(0, 10); + } + const d = new Date(s); + return isNaN(+d) ? "" : d.toISOString().slice(0, 10); +} + +export function addDays(date: string, days: number) { + const d = new Date(`${date}T00:00:00Z`); + d.setUTCDate(d.getUTCDate() + days); + return d.toISOString().slice(0, 10); +} diff --git a/ui-plugins/invoice-maker/src/kit/console.ts b/ui-plugins/invoice-maker/src/kit/console.ts new file mode 100644 index 00000000..f6817656 --- /dev/null +++ b/ui-plugins/invoice-maker/src/kit/console.ts @@ -0,0 +1,5 @@ +// stdout 只留给 MCP 协议;依赖库的日志改写到 stderr。 +console.log = (...args: unknown[]) => process.stderr.write(`${args.map(String).join(" ")}\n`); +console.info = console.log; +console.warn = console.log; +console.debug = console.log; diff --git a/ui-plugins/invoice-maker/src/kit/fontkit.d.ts b/ui-plugins/invoice-maker/src/kit/fontkit.d.ts new file mode 100644 index 00000000..c3ad5cd3 --- /dev/null +++ b/ui-plugins/invoice-maker/src/kit/fontkit.d.ts @@ -0,0 +1 @@ +declare module "fontkit"; diff --git a/ui-plugins/invoice-maker/src/kit/fonts.ts b/ui-plugins/invoice-maker/src/kit/fonts.ts new file mode 100644 index 00000000..84e65845 --- /dev/null +++ b/ui-plugins/invoice-maker/src/kit/fonts.ts @@ -0,0 +1,90 @@ +import { readFile, stat } from "node:fs/promises"; +import { KitError } from "./workspace.ts"; + +/** 常见系统中文字体。TrueType 优先(PDF 子集嵌入最稳定),然后是集合字体。 */ +export const CJK_FONT_CANDIDATES = [ + // macOS + "/System/Library/Fonts/Supplemental/Arial Unicode.ttf", + "/Library/Fonts/Arial Unicode.ttf", + "/System/Library/Fonts/Hiragino Sans GB.ttc", + "/System/Library/Fonts/STHeiti Medium.ttc", + "/System/Library/Fonts/STHeiti Light.ttc", + "/System/Library/Fonts/PingFang.ttc", + // Windows + "C:\\Windows\\Fonts\\simhei.ttf", + "C:\\Windows\\Fonts\\msyh.ttc", + "C:\\Windows\\Fonts\\simsun.ttc", + // Linux + "/usr/share/fonts/truetype/arphic/uming.ttc", + "/usr/share/fonts/truetype/wqy/wqy-microhei.ttc", + "/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc", + "/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc", + "/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc", +]; + +export interface LoadedFont { + path: string; + /** 原始文件(可能是 .ttc 集合)。 */ + data: Buffer; +} + +const cache = new Map(); + +/** 用户指定的字体优先,否则按候选列表找第一个存在的中文字体。 */ +export async function findCjkFont(userPath?: string | null, candidates: string[] = CJK_FONT_CANDIDATES): Promise { + const configured = userPath?.trim() && !userPath.includes("${") ? userPath.trim() : undefined; + const list = configured ? [configured, ...candidates] : candidates; + for (const path of list) { + if (cache.has(path)) return cache.get(path)!; + try { + if (!(await stat(path)).isFile()) continue; + const font = { path, data: await readFile(path) }; + cache.set(path, font); + return font; + } catch { + // 继续查找 + } + } + throw new KitError( + "font_not_found", + "No Chinese-capable font was found. Set the plugin's fontPath setting to a .ttf/.otf/.ttc font file (for example Arial Unicode.ttf, Microsoft YaHei or Noto Sans CJK).", + ); +} + +/** 从 .ttc 字体集合中取出第 index 个字体,组成独立的 sfnt 文件(pdf-lib 只能嵌入单个字体)。 */ +export function extractFace(data: Uint8Array, index = 0): Uint8Array { + const view = new DataView(data.buffer, data.byteOffset, data.byteLength); + if (view.getUint32(0) !== 0x74746366) return data; // 不是 'ttcf' + const count = view.getUint32(8); + if (index >= count) throw new KitError("font_error", `Font collection has ${count} faces.`); + const offset = view.getUint32(12 + index * 4); + const numTables = view.getUint16(offset + 4); + const tables: { tag: number; checksum: number; start: number; length: number }[] = []; + for (let i = 0; i < numTables; i++) { + const record = offset + 12 + i * 16; + tables.push({ tag: view.getUint32(record), checksum: view.getUint32(record + 4), start: view.getUint32(record + 8), length: view.getUint32(record + 12) }); + } + const headerSize = 12 + numTables * 16; + let total = headerSize; + for (const table of tables) total += (table.length + 3) & ~3; + const out = new Uint8Array(total); + const outView = new DataView(out.buffer); + out.set(data.subarray(offset, offset + 12), 0); + let cursor = headerSize; + tables.forEach((table, i) => { + const record = 12 + i * 16; + outView.setUint32(record, table.tag); + outView.setUint32(record + 4, table.checksum); + outView.setUint32(record + 8, cursor); + outView.setUint32(record + 12, table.length); + out.set(data.subarray(table.start, table.start + table.length), cursor); + cursor += (table.length + 3) & ~3; + }); + return out; +} + +/** PDF 用字体:单个字体(集合取第一个),配合 fontkit 2 子集化嵌入。 */ +export async function findPdfFont(userPath?: string | null): Promise<{ path: string; face: Uint8Array; subset: boolean }> { + const font = await findCjkFont(userPath); + return { path: font.path, face: extractFace(font.data, 0), subset: true }; +} diff --git a/ui-plugins/invoice-maker/src/kit/pdf-fontkit.ts b/ui-plugins/invoice-maker/src/kit/pdf-fontkit.ts new file mode 100644 index 00000000..4ce7990b --- /dev/null +++ b/ui-plugins/invoice-maker/src/kit/pdf-fontkit.ts @@ -0,0 +1,48 @@ +import * as fontkitModule from "fontkit"; + +/** + * pdf-lib 自带示例用的 @pdf-lib/fontkit(fontkit 1.x 分支)在子集化部分中文字体时会丢字。 + * 这里改用 fontkit 2.x,并把它的 subset.encode() 适配成 pdf-lib 需要的 encodeStream() 接口。 + */ +const fontkit: any = fontkitModule; + +function wrapSubset(subset: any) { + return new Proxy(subset, { + get(target, key) { + if (key === "encodeStream") + return () => { + const handlers: Record void> = {}; + const stream = { + on(event: string, handler: (value?: unknown) => void) { + handlers[event] = handler; + return stream; + }, + }; + queueMicrotask(() => { + try { + handlers.data?.(target.encode()); + handlers.end?.(); + } catch (error) { + handlers.error?.(error); + } + }); + return stream; + }; + const value = target[key]; + return typeof value === "function" ? value.bind(target) : value; + }, + }); +} + +export const pdfFontkit = { + create(buffer: Uint8Array, postscriptName?: string) { + const font = fontkit.create(buffer, postscriptName); + return new Proxy(font, { + get(target, key) { + if (key === "createSubset") return () => wrapSubset(target.createSubset()); + const value = target[key]; + return typeof value === "function" ? value.bind(target) : value; + }, + }); + }, +}; diff --git a/ui-plugins/invoice-maker/src/kit/pdf-fonts.ts b/ui-plugins/invoice-maker/src/kit/pdf-fonts.ts new file mode 100644 index 00000000..ab199ba4 --- /dev/null +++ b/ui-plugins/invoice-maker/src/kit/pdf-fonts.ts @@ -0,0 +1,58 @@ +import { readFile } from "node:fs/promises"; +import * as fontkitModule from "fontkit"; +import { extractFace, findCjkFont } from "./fonts.ts"; + +const fontkit: any = fontkitModule; + +const faceCount = (data: Uint8Array) => { + const view = new DataView(data.buffer, data.byteOffset, data.byteLength); + return view.getUint32(0) === 0x74746366 ? view.getUint32(8) : 1; +}; + +/** 在字体集合里挑一个字体:优先简体中文,然后按字重匹配。 */ +function pickFace(data: Uint8Array, bold: boolean): Uint8Array | undefined { + const faces: { face: Uint8Array; family: string; sub: string }[] = []; + for (let i = 0; i < Math.min(faceCount(data), 16); i++) { + try { + const face = extractFace(data, i); + const font = fontkit.create(Buffer.from(face)); + faces.push({ face, family: String(font.familyName ?? ""), sub: String(font.subfamilyName ?? "") }); + } catch { + // 跳过 + } + } + const isBold = (f: { family: string; sub: string }) => /bold|semibold|w6|w7|w8|heavy|black|medium/i.test(`${f.sub} ${f.family}`); + const pool = faces.filter((f) => isBold(f) === bold); + const list = pool.length ? pool : bold ? [] : faces; + return (list.find((f) => /\bSC\b|GB|Simplified/i.test(f.family)) ?? list[0])?.face; +} + +const BOLD_CANDIDATES = [ + "/System/Library/Fonts/Hiragino Sans GB.ttc", + "/System/Library/Fonts/STHeiti Medium.ttc", + "C:\\Windows\\Fonts\\msyhbd.ttc", + "C:\\Windows\\Fonts\\simhei.ttf", + "/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc", + "/usr/share/fonts/noto-cjk/NotoSansCJK-Bold.ttc", + "/usr/share/fonts/google-noto-cjk/NotoSansCJK-Bold.ttc", +]; + +/** PDF 正文字体 + (能找到的话)粗体。用户指定字体时只用该字体。 */ +export async function findPdfFonts(userPath?: string | null): Promise<{ path: string; regular: Uint8Array; bold?: Uint8Array; boldPath?: string }> { + const font = await findCjkFont(userPath); + const regular = pickFace(font.data, false) ?? extractFace(font.data, 0); + const configured = userPath?.trim() && !userPath.includes("${"); + if (configured) return { path: font.path, regular }; + const same = pickFace(font.data, true); + if (same) return { path: font.path, regular, bold: same, boldPath: font.path }; + for (const path of BOLD_CANDIDATES) { + try { + const data = await readFile(path); + const bold = pickFace(data, true) ?? (/simhei/i.test(path) ? extractFace(data, 0) : undefined); + if (bold) return { path: font.path, regular, bold, boldPath: path }; + } catch { + // 继续 + } + } + return { path: font.path, regular }; +} diff --git a/ui-plugins/invoice-maker/src/kit/pdf.ts b/ui-plugins/invoice-maker/src/kit/pdf.ts new file mode 100644 index 00000000..e57577eb --- /dev/null +++ b/ui-plugins/invoice-maker/src/kit/pdf.ts @@ -0,0 +1,69 @@ +import { PDFDocument, rgb, StandardFonts, type PDFFont, type PDFPage } from "pdf-lib"; +import { pdfFontkit } from "./pdf-fontkit.ts"; +import { findPdfFonts } from "./pdf-fonts.ts"; + +export const MM = 72 / 25.4; +export const PAGE = { A4: [595.28, 841.89] as [number, number], Letter: [612, 792] as [number, number], A5: [419.53, 595.28] as [number, number] }; + +export interface PdfKit { + doc: PDFDocument; + font: PDFFont; + bold: PDFFont; + /** 是否有中文字体(没有时中文会被替换成 ?)。 */ + cjk: boolean; + width: (text: string, size: number, b?: boolean) => number; + text: (page: PDFPage, text: string, x: number, y: number, o?: { size?: number; bold?: boolean; color?: string; align?: "left" | "center" | "right"; maxWidth?: number }) => void; + wrap: (text: string, size: number, maxWidth: number, b?: boolean) => string[]; +} + +export function hexRgb(hex: string | undefined, fallback = "#111827") { + const m = /^#?([0-9a-f]{6})$/i.exec((hex ?? "").trim()) ?? /^#?([0-9a-f]{6})$/i.exec(fallback)!; + const n = parseInt(m[1], 16); + return rgb(((n >> 16) & 255) / 255, ((n >> 8) & 255) / 255, (n & 255) / 255); +} + +/** 新建 PDF,并嵌入本机中文字体(找不到时退回 Helvetica)。 */ +export async function newPdf(fontPath?: string | null): Promise { + const doc = await PDFDocument.create(); + doc.setCreator("Penova"); + doc.setProducer("pdf-lib"); + let font: PDFFont, bold: PDFFont, cjk = true; + try { + const f = await findPdfFonts(fontPath); + doc.registerFontkit(pdfFontkit as never); + font = await doc.embedFont(f.regular, { subset: true }); + bold = f.bold ? await doc.embedFont(f.bold, { subset: true }) : font; + } catch { + cjk = false; + font = await doc.embedFont(StandardFonts.Helvetica); + bold = await doc.embedFont(StandardFonts.HelveticaBold); + } + const safe = (t: string) => (cjk ? t : t.replace(/[^\x20-\x7e\u00a0-\u00ff]/g, "?")); + const width = (t: string, size: number, b = false) => (b ? bold : font).widthOfTextAtSize(safe(t), size); + const wrap = (t: string, size: number, maxWidth: number, b = false) => { + const out: string[] = []; + for (const para of String(t ?? "").split(/\r?\n/)) { + let line = ""; + const tokens = para.match(/[\u2E80-\u9FFF\uF900-\uFAFF\uFF00-\uFFEF]|[^\s\u2E80-\u9FFF\uF900-\uFAFF\uFF00-\uFFEF]+|\s+/g) ?? [""]; + for (const tok of tokens) { + const next = line + tok; + if (width(next, size, b) > maxWidth && line.trim()) { + out.push(line.trimEnd()); + line = tok.trimStart(); + } else line = next; + } + out.push(line.trimEnd()); + } + return out; + }; + const text: PdfKit["text"] = (page, t, x, y, o = {}) => { + const size = o.size ?? 10; + const f = o.bold ? bold : font; + let s = safe(String(t ?? "")); + if (o.maxWidth) while (s.length > 1 && f.widthOfTextAtSize(s, size) > o.maxWidth) s = s.slice(0, -2) + "…"; + const w = f.widthOfTextAtSize(s, size); + const dx = o.align === "center" ? -w / 2 : o.align === "right" ? -w : 0; + page.drawText(s, { x: x + dx, y, size, font: f, color: hexRgb(o.color) }); + }; + return { doc, font, bold, cjk, width, text, wrap }; +} diff --git a/ui-plugins/invoice-maker/src/kit/server-kit.ts b/ui-plugins/invoice-maker/src/kit/server-kit.ts new file mode 100644 index 00000000..6bc31594 --- /dev/null +++ b/ui-plugins/invoice-maker/src/kit/server-kit.ts @@ -0,0 +1,84 @@ +import { readFile } from "node:fs/promises"; +import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { z } from "zod"; +import { KitError } from "./workspace.ts"; + +export const HTML_MIME = "text/html;profile=mcp-app"; +type Visibility = ("model" | "app")[]; +type Content = { type: "text"; text: string } | { type: "image"; data: string; mimeType: string }; + +export interface ToolOutput { + text: string; + structured?: Record; + images?: { data: string; mimeType: string }[]; +} + +export interface KitServerOptions { + name: string; + version: string; + panelUri: string; + surface: string; + panelHtml: () => Promise; + log?: (line: string) => void; + /** 页面资源的额外 _meta,例如 { "zcode/csp": { wasmUnsafeEval: true } }。 */ + panelMeta?: Record; +} + +/** 统一的工具注册:所有工具都关联同一个侧栏面板,错误带 code 返回给 Agent 与页面。 */ +export function createKitServer(options: KitServerOptions) { + const log = options.log ?? (() => undefined); + const server = new McpServer({ name: options.name, version: options.version }, { capabilities: { logging: {} } }); + const panelMeta = { ui: { prefersBorder: false }, ...options.panelMeta }; + server.registerResource("panel", options.panelUri, { mimeType: HTML_MIME, _meta: panelMeta }, async () => ({ + contents: [{ uri: options.panelUri, mimeType: HTML_MIME, _meta: panelMeta, text: await options.panelHtml() }], + })); + + const tool = ( + name: string, + config: { + description: string; + input: Record; + visibility?: Visibility; + openPanel?: boolean; + readOnly?: boolean; + timeoutMs?: number; + }, + run: (input: any) => Promise, + ) => { + server.registerTool( + name, + { + description: config.description, + inputSchema: config.input, + annotations: { readOnlyHint: !!config.readOnly, ...(config.readOnly ? {} : { destructiveHint: false }), openWorldHint: false }, + _meta: { + ui: { resourceUri: options.panelUri, surface: options.surface, visibility: config.visibility ?? ["model", "app"] }, + ...(config.timeoutMs ? { timeoutMs: config.timeoutMs } : {}), + ...(config.openPanel ? { "openai/ui": { preferredModelDisplayMode: "fullscreen" } } : {}), + }, + }, + async (input: unknown) => { + try { + const output = await run(input); + const content: Content[] = [{ type: "text", text: output.text }]; + for (const image of output.images ?? []) content.push({ type: "image", ...image }); + return { content, ...(output.structured ? { structuredContent: output.structured } : {}) }; + } catch (error) { + const code = error instanceof KitError ? error.code : "internal_error"; + const message = error instanceof Error ? error.message : String(error); + if (!(error instanceof KitError)) log(`${name} failed: ${error instanceof Error ? error.stack : message}`); + return { + isError: true, + content: [{ type: "text" as const, text: `[${code}] ${message}` }], + structuredContent: { error: { code, message } }, + }; + } + }, + ); + }; + return { server, tool }; +} + +export async function readPanel(path: string) { + return readFile(path, "utf8"); +} diff --git a/ui-plugins/invoice-maker/src/kit/sheet.ts b/ui-plugins/invoice-maker/src/kit/sheet.ts new file mode 100644 index 00000000..5956d9a6 --- /dev/null +++ b/ui-plugins/invoice-maker/src/kit/sheet.ts @@ -0,0 +1,35 @@ +import ExcelJS from "exceljs"; + +export interface SheetSpec { + name: string; + headers: string[]; + rows: unknown[][]; + /** 需要标色的单元格:row/col 从 0 开始(不含表头)。 */ + marks?: { row: number; col: number; color?: string; note?: string }[]; + widths?: number[]; + numberFormat?: Record; +} + +/** 写出 .xlsx:表头加粗冻结、数字保持数字、可选标色与批注。 */ +export async function writeXlsx(sheets: SheetSpec[]): Promise { + const book = new ExcelJS.Workbook(); + book.creator = "Penova"; + for (const spec of sheets) { + const sheet = book.addWorksheet(spec.name.replace(/[\\/?*[\]:]/g, "_").slice(0, 31) || "Sheet1"); + sheet.addRow(spec.headers); + sheet.getRow(1).font = { bold: true }; + sheet.views = [{ state: "frozen", ySplit: 1 }]; + for (const row of spec.rows) sheet.addRow(row.map((v) => (v === undefined || v === null ? "" : v instanceof Date ? v : typeof v === "number" || typeof v === "boolean" ? v : String(v)))); + spec.headers.forEach((h, i) => { + const width = spec.widths?.[i] ?? Math.min(50, Math.max(8, String(h).length * 2, ...spec.rows.slice(0, 200).map((r) => String(r[i] ?? "").length * 1.2))); + sheet.getColumn(i + 1).width = width; + if (spec.numberFormat?.[i]) sheet.getColumn(i + 1).numFmt = spec.numberFormat[i]; + }); + for (const m of spec.marks ?? []) { + const cell = sheet.getCell(m.row + 2, m.col + 1); + cell.fill = { type: "pattern", pattern: "solid", fgColor: { argb: (m.color ?? "FFFDE68A").replace("#", "FF") } }; + if (m.note) cell.note = m.note; + } + } + return Buffer.from(await book.xlsx.writeBuffer()); +} diff --git a/ui-plugins/invoice-maker/src/kit/table.ts b/ui-plugins/invoice-maker/src/kit/table.ts new file mode 100644 index 00000000..cf2b8484 --- /dev/null +++ b/ui-plugins/invoice-maker/src/kit/table.ts @@ -0,0 +1,116 @@ +import { extname } from "node:path"; +import ExcelJS from "exceljs"; +import { KitError, type Workspace } from "./workspace.ts"; + +export interface TableData { + columns: string[]; + rows: Record[]; + sheets: string[]; + sheet?: string; +} + +/** UTF-8 解码失败(出现替换字符)时按 GB18030 解码:中文版 Excel 导出的 CSV 常是 GBK。 */ +export function decodeText(bytes: Uint8Array): string { + const utf8 = new TextDecoder("utf-8").decode(bytes); + if (!utf8.includes("\uFFFD")) return utf8.replace(/^\uFEFF/, ""); + try { + return new TextDecoder("gb18030").decode(bytes); + } catch { + return utf8; + } +} + +export function parseCsv(text: string): string[][] { + const first = text.split(/\r?\n/, 1)[0] ?? ""; + const delimiter = [",", "\t", ";"].map((d) => [d, first.split(d).length] as const).sort((a, b) => b[1] - a[1])[0][0]; + const rows: string[][] = []; + let row: string[] = []; + let cell = ""; + let quoted = false; + for (let i = 0; i < text.length; i++) { + const ch = text[i]; + if (quoted) { + if (ch === '"') { + if (text[i + 1] === '"') { + cell += '"'; + i++; + } else quoted = false; + } else cell += ch; + } else if (ch === '"' && cell === "") quoted = true; + else if (ch === delimiter) { + row.push(cell); + cell = ""; + } else if (ch === "\n" || ch === "\r") { + if (ch === "\r" && text[i + 1] === "\n") i++; + row.push(cell); + rows.push(row); + row = []; + cell = ""; + } else cell += ch; + } + if (cell !== "" || row.length) { + row.push(cell); + rows.push(row); + } + return rows.filter((r) => r.some((c) => c.trim() !== "")); +} + +function cellText(value: ExcelJS.CellValue): string { + if (value === null || value === undefined) return ""; + if (value instanceof Date) { + const pad = (n: number) => String(n).padStart(2, "0"); + return `${value.getUTCFullYear()}-${pad(value.getUTCMonth() + 1)}-${pad(value.getUTCDate())}`; + } + if (typeof value === "object") { + if ("richText" in value) return value.richText.map((part) => part.text).join(""); + if ("text" in value) return String(value.text); + if ("result" in value) return cellText(value.result as ExcelJS.CellValue); + if ("error" in value) return ""; + } + return String(value); +} + +function toTable(matrix: string[][], sheets: string[], sheet?: string): TableData { + if (!matrix.length) throw new KitError("empty_table", "The table has no rows."); + const seen = new Map(); + const columns = matrix[0].map((raw, index) => { + let name = raw.trim() || `列${index + 1}`; + const count = seen.get(name) ?? 0; + seen.set(name, count + 1); + if (count) name = `${name}_${count + 1}`; + return name; + }); + const rows = matrix.slice(1).map((cells) => Object.fromEntries(columns.map((column, index) => [column, (cells[index] ?? "").trim()]))); + return { columns, rows, sheets, sheet }; +} + +/** 读取 CSV / TSV / XLSX:第一行是表头。 */ +export async function readTable(ws: Workspace, path: string, sheet?: string): Promise { + const ext = extname(path).toLowerCase(); + const bytes = await ws.read(path, 50 * 1024 * 1024); + if (ext === ".csv" || ext === ".tsv" || ext === ".txt") return toTable(parseCsv(decodeText(bytes)), []); + if (ext === ".xlsx") { + const book = new ExcelJS.Workbook(); + await book.xlsx.load(bytes as unknown as ArrayBuffer); + const sheets = book.worksheets.map((item) => item.name); + const target = sheet ? book.getWorksheet(sheet) : book.worksheets.find((item) => item.actualRowCount > 0) ?? book.worksheets[0]; + if (!target) throw new KitError("sheet_not_found", `Sheet not found: ${sheet}. Sheets: ${sheets.join(", ")}`); + const matrix: string[][] = []; + target.eachRow({ includeEmpty: false }, (row) => { + const cells: string[] = []; + for (let col = 1; col <= target.columnCount; col++) cells.push(cellText(row.getCell(col).value).trim()); + if (cells.some((cell) => cell)) matrix.push(cells); + }); + return toTable(matrix, sheets, target.name); + } + throw new KitError("unsupported_table", `Use a .csv, .tsv or .xlsx file (got ${ext || "no extension"}). Save .xls files as .xlsx first.`); +} + +/** 把 "{列名}" 占位符替换成该行的值。 */ +export function renderPattern(pattern: string, row: Record): string { + return pattern.replace(/\{([^{}]+)\}/g, (_, key: string) => row[key.trim()] ?? ""); +} + +export function patternColumns(pattern: string): string[] { + return [...pattern.matchAll(/\{([^{}=]+)\}/g)].map((match) => match[1].trim()); +} diff --git a/ui-plugins/invoice-maker/src/kit/testing.ts b/ui-plugins/invoice-maker/src/kit/testing.ts new file mode 100644 index 00000000..0d8dc72e --- /dev/null +++ b/ui-plugins/invoice-maker/src/kit/testing.ts @@ -0,0 +1,16 @@ +// 仅测试使用:通过内存传输连接 server,像 Agent 一样调用工具。 +import { Client } from "@modelcontextprotocol/sdk/client/index.js"; +import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js"; +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; + +export async function connect(server: McpServer) { + const [a, b] = InMemoryTransport.createLinkedPair(); + const client = new Client({ name: "test", version: "1" }); + await Promise.all([server.connect(a), client.connect(b)]); + const call = async (name: string, args: Record = {}) => { + const r = (await client.callTool({ name, arguments: args }, undefined, { timeout: 300_000 })) as any; + if (r.isError) throw Object.assign(new Error(r.content?.[0]?.text ?? "tool error"), { code: r.structuredContent?.error?.code }); + return { text: r.content?.[0]?.text as string, data: r.structuredContent as any }; + }; + return { client, call }; +} diff --git a/ui-plugins/invoice-maker/src/kit/workspace.ts b/ui-plugins/invoice-maker/src/kit/workspace.ts new file mode 100644 index 00000000..750d7741 --- /dev/null +++ b/ui-plugins/invoice-maker/src/kit/workspace.ts @@ -0,0 +1,170 @@ +import { lstatSync, readlinkSync, realpathSync } from "node:fs"; +import { mkdir, readFile, readdir, rename, stat, writeFile } from "node:fs/promises"; +import { dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path"; + +export class KitError extends Error { + readonly code: string; + constructor(code: string, message: string) { + super(message); + this.code = code; + this.name = "KitError"; + } +} + +const SKIP = new Set(["node_modules", ".git", "dist", "build", ".next", ".cache", "__pycache__"]); + +/** 只允许读写当前工作区内的文件;所有路径都相对工作区根目录。 */ +export class Workspace { + readonly root: string; + constructor(root: string) { + this.root = resolve(root); + } + + resolve(path: string): string { + if (typeof path !== "string" || !path.trim()) throw new KitError("bad_path", "Path is empty."); + const absolute = resolve(this.root, path); + const rel = relative(this.root, absolute); + if (rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)) + throw new KitError("outside_workspace", `Path is outside the workspace: ${path}`); + this.assertRealInside(absolute, path); + return absolute; + } + + private realRoot?: string; + + /** + * 符号链接不能把读写带出工作区:从目标往上找到第一个已存在的路径,取它的真实路径, + * 必须仍在工作区根目录的真实路径之下。还不存在的写入目标按其已存在的上级目录判断; + * 指向不存在位置的悬空链接一律拒绝(否则 writeFile 会顺着它在外部建文件)。 + */ + private assertRealInside(absolute: string, path: string) { + let realRoot: string; + try { + realRoot = this.realRoot ??= realpathSync(this.root); + } catch { + return; // 根目录本身不存在时,没有可逃出的链接 + } + const outside = (real: string) => { + const rel = relative(realRoot, real); + return rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel); + }; + let probe = absolute; + for (;;) { + let real: string | undefined; + try { + real = realpathSync(probe); + } catch { + let link = false; + try { + link = lstatSync(probe).isSymbolicLink(); + } catch {} + if (link) { + const target = resolve(dirname(probe), readlinkSync(probe)); + throw new KitError("outside_workspace", outside(target) ? `Path leaves the workspace through a link: ${path}` : `Path goes through a broken link: ${path}`); + } + } + if (real !== undefined) { + if (outside(real)) throw new KitError("outside_workspace", `Path leaves the workspace through a link: ${path}`); + return; + } + const parent = dirname(probe); + if (parent === probe) return; + probe = parent; + } + } + + rel(absolute: string): string { + return relative(this.root, absolute).split(sep).join("/") || "."; + } + + async exists(path: string): Promise { + try { + await stat(this.resolve(path)); + return true; + } catch { + return false; + } + } + + async read(path: string, maxBytes = 200 * 1024 * 1024): Promise { + const absolute = this.resolve(path); + let info; + try { + info = await stat(absolute); + } catch { + throw new KitError("not_found", `File not found: ${path}`); + } + if (!info.isFile()) throw new KitError("not_a_file", `Not a file: ${path}`); + if (info.size > maxBytes) throw new KitError("too_large", `File is larger than ${Math.round(maxBytes / 1048576)} MB: ${path}`); + return readFile(absolute); + } + + async readText(path: string): Promise { + return (await this.read(path, 20 * 1024 * 1024)).toString("utf8"); + } + + async write(path: string, data: Uint8Array | string): Promise { + const absolute = this.resolve(path); + await mkdir(dirname(absolute), { recursive: true }); + await writeFile(absolute, data); + return this.rel(absolute); + } + + /** 在工作区内移动 / 重命名文件;目标已存在时拒绝,不覆盖。 */ + async move(from: string, to: string): Promise { + const source = this.resolve(from); + const target = this.resolve(to); + if (!(await this.exists(from))) throw new KitError("not_found", `File not found: ${from}`); + if (await this.exists(to)) throw new KitError("exists", `Target already exists: ${to}`); + await mkdir(dirname(target), { recursive: true }); + await rename(source, target); + return this.rel(target); + } + + async size(path: string): Promise { + return (await stat(this.resolve(path))).size; + } + + async mtime(path: string): Promise { + return (await stat(this.resolve(path))).mtime; + } + + /** 列出文件(默认递归、跳过依赖与构建目录),按路径排序。 */ + async list({ dir = ".", exts, recursive = true, limit = 2000 }: { dir?: string; exts?: string[]; recursive?: boolean; limit?: number } = {}) { + const wanted = exts?.map((ext) => ext.toLowerCase()); + const out: { path: string; size: number }[] = []; + const walk = async (absolute: string, depth: number) => { + if (out.length >= limit || depth > 8) return; + let entries; + try { + entries = await readdir(absolute, { withFileTypes: true }); + } catch { + return; + } + entries.sort((a, b) => a.name.localeCompare(b.name, "en", { numeric: true })); + for (const entry of entries) { + if (out.length >= limit) return; + if (entry.name.startsWith(".") && entry.name !== ".") continue; + const child = join(absolute, entry.name); + if (entry.isDirectory()) { + if (recursive && !SKIP.has(entry.name)) await walk(child, depth + 1); + } else if (entry.isFile() && (!wanted || wanted.includes(extname(entry.name).toLowerCase()))) { + out.push({ path: this.rel(child), size: (await stat(child)).size }); + } + } + }; + await walk(this.resolve(dir), 0); + return out; + } +} + +/** 把文件名中不适合的字符替换掉,保留中文。 */ +export function safeFileName(name: string, fallback = "file"): string { + const cleaned = name + .replace(/[\\/:*?"<>|]+/g, "_") + .replace(/\p{Cc}+/gu, "_") + .replace(/\s+/g, " ") + .trim() + .replace(/^\.+/, ""); + return (cleaned || fallback).slice(0, 120); +} diff --git a/ui-plugins/invoice-maker/src/main.ts b/ui-plugins/invoice-maker/src/main.ts new file mode 100644 index 00000000..9cad76d6 --- /dev/null +++ b/ui-plugins/invoice-maker/src/main.ts @@ -0,0 +1,14 @@ +import "./kit/console.ts"; +import { dirname, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; +import { createServer } from "./server.ts"; + +const here = dirname(fileURLToPath(import.meta.url)); +const server = createServer({ + workspaceRoot: resolve(process.env.ZCODE_WORKSPACE_ROOT || process.cwd()), + assetRoot: here, + log: (line) => process.stderr.write(`[invoice-maker] ${line}\n`), +}); +process.stdin.once("end", () => process.exit(0)); +await server.connect(new StdioServerTransport()); diff --git a/ui-plugins/invoice-maker/src/server.ts b/ui-plugins/invoice-maker/src/server.ts new file mode 100644 index 00000000..e67211e7 --- /dev/null +++ b/ui-plugins/invoice-maker/src/server.ts @@ -0,0 +1,130 @@ +import { createApp, htmlPage, htmlTable, toCsv, type AppDef, type Row } from "./kit/app.ts"; +import { mapHeaders } from "./kit/columns.ts"; +import { writeXlsx } from "./kit/sheet.ts"; +import { readTable } from "./kit/table.ts"; +import { KitError, safeFileName } from "./kit/workspace.ts"; +import { buildInvoices, detectCurrency, invoiceTooLong, money, previewHtml, renderPdf, type Line, type Settings } from "./invoice.ts"; + +export const NAME = "invoice-maker"; +export const VERSION = "0.1.0"; + +const ALIASES = { + invoice: ["发票号", "发票编号", "单号", "invoice no", "invoice number", "number", "no"], + client: ["客户", "客户名称", "购买方", "公司", "customer", "bill to", "company", "name"], + address: ["客户地址", "地址", "address", "billing address"], + item: ["项目", "品名", "服务内容", "描述", "说明", "商品", "description", "service", "product"], + qty: ["数量", "quantity", "hours", "工时"], + price: ["单价", "价格", "unit price", "rate", "price"], + tax: ["税率", "tax rate", "vat", "tax %", "tax"], + currency: ["币种", "货币", "currency", "curr", "ccy"], +}; + +const settingsOf = (p: { settings: Record }) => p.settings as unknown as Settings; +const lines = (rows: Row[]) => rows as unknown as Line[]; + +const def: AppDef = { + name: NAME, + version: VERSION, + prefix: "invoice", + title: ["批量开发票", "Invoice Maker"], + openDescription: + "Read a sheet of invoice line items (.xlsx/.csv; one row per line; columns like invoice no., client, address, item, qty, price, tax % in Chinese or English are matched automatically). Rows with the same invoice number — or, without one, the same client — become one invoice; missing numbers are assigned from prefix+start. Calculates line amounts, tax and totals and flags bad numbers, missing clients and clashing invoice numbers.", + inputs: { exts: [".xlsx", ".csv", ".tsv"], min: 1, max: 1, label: ["选择明细表(每行一个项目)", "Pick the line-item sheet (one row per item)"] }, + settings: [ + { key: "seller", label: ["开票方名称", "Your business name"], type: "text", default: "" }, + { key: "sellerInfo", label: ["开票方信息(地址、税号、银行)", "Your details (address, tax ID, bank)"], type: "textarea", default: "" }, + { key: "currency", label: ["币种", "Currency"], type: "select", default: "CNY", options: ["CNY", "USD", "EUR", "GBP", "JPY", "HKD", "TWD", "SGD", "AUD", "CAD"].map((c) => ({ value: c, label: [c, c] as [string, string] })) }, + { key: "taxRate", label: ["默认税率 %", "Default tax %"], type: "number", default: 0, min: 0, max: 100, help: ["明细里没有税率时使用", "Used when a line has no tax rate"] }, + { key: "prefix", label: ["编号前缀", "Number prefix"], type: "text", default: "INV-" }, + { key: "start", label: ["起始编号", "First number"], type: "number", default: 1, min: 0 }, + { key: "date", label: ["开票日期", "Invoice date"], type: "date", default: new Date().toISOString().slice(0, 10) }, + { key: "dueDays", label: ["付款期限(天)", "Payment terms (days)"], type: "number", default: 30, min: 0, max: 365 }, + { key: "lang", label: ["语言", "Language"], type: "select", default: "both", options: [{ value: "zh", label: ["中文", "Chinese"] }, { value: "en", label: ["英文", "English"] }, { value: "both", label: ["中英双语", "Bilingual"] }] }, + { key: "paper", label: ["纸张", "Paper"], type: "select", default: "A4", options: [{ value: "A4", label: ["A4", "A4"] }, { value: "Letter", label: ["Letter", "Letter"] }] }, + { key: "accent", label: ["主题色", "Accent colour"], type: "color", default: "#2563eb" }, + { key: "notes", label: ["备注(付款方式等)", "Notes (payment instructions…)"], type: "textarea", default: "" }, + ], + columns: () => [ + { key: "invoice", label: ["发票号", "Invoice no."] }, + { key: "client", label: ["客户", "Client"], wide: true }, + { key: "address", label: ["客户地址", "Client address"], wide: true }, + { key: "item", label: ["项目", "Item"], wide: true }, + { key: "qty", label: ["数量", "Qty"], type: "number" }, + { key: "price", label: ["单价", "Price"], type: "number" }, + { key: "tax", label: ["税率 %", "Tax %"], type: "number" }, + { key: "currency", label: ["币种", "Currency"] }, + { key: "_number", label: ["归入发票", "On invoice"], readOnly: true }, + { key: "_amount", label: ["金额", "Amount"], type: "number", readOnly: true }, + ], + newRow: () => ({ invoice: "", client: "", address: "", item: "", qty: 1, price: 0, tax: "", currency: "" }), + async load({ ws, files }) { + const table = await readTable(ws, files[0]); + const map = mapHeaders(table.columns, ALIASES); + const missing = ["client", "item", "price"].filter((k) => !map[k]); + if (missing.length) throw new KitError("columns_not_found", `Could not find column(s) for ${missing.join(", ")}. Columns in the file: ${table.columns.join(", ")}. Rename them (e.g. 客户 / client, 项目 / item, 单价 / price) and open again.`); + const rows = table.rows.map((r) => Object.fromEntries(Object.keys(ALIASES).map((k) => [k, map[k] ? r[map[k]!] ?? "" : k === "qty" ? 1 : ""]))); + // 单价列标题里写了币种(如“单价 (USD)”)而表里没有币种列时,用标题里的币种 + const headCur = !map.currency && map.price ? detectCurrency(map.price) : undefined; + if (headCur) for (const r of rows) r.currency = headCur; + return { rows, meta: { columns: map, sheet: table.sheet } }; + }, + compute(project) { + const s = settingsOf(project); + const { invoices, issues } = buildInvoices(lines(project.rows), s); + const numberOf = new Map(); + for (const inv of invoices) for (const l of inv.lines) numberOf.set(l.index, { n: inv.number, a: l.amount }); + for (const inv of invoices) if (invoiceTooLong(inv)) issues.push({ level: "warn", row: inv.lines[0].index, message: `Invoice ${inv.number} has ${inv.lines.length} lines; v0.1 fits about 20 lines on one page / 行数过多可能放不下一页` }); + const byCur = new Map(); + for (const i of invoices) byCur.set(i.currency, (byCur.get(i.currency) ?? 0) + i.total); + const totalText = byCur.size ? [...byCur].map(([c, t]) => money(t, c)).join(" + ") : money(0, s.currency); + return { + rows: project.rows.map((r, i) => ({ ...r, _number: numberOf.get(i)?.n ?? "", _amount: numberOf.get(i)?.a ?? 0 })), + issues, + summary: `${invoices.length} invoice(s) from ${project.rows.length} line(s); grand total ${totalText} (incl. tax). 共 ${invoices.length} 张发票,含税合计 ${totalText}。`, + stats: { invoices: invoices.length, lines: project.rows.length, total: totalText }, + preview: previewHtml(invoices[0], s, invoices.length), + }; + }, + exports: [ + { + id: "pdf", + label: ["PDF 发票", "PDF invoices"], + description: "one PDF per invoice plus all-invoices.pdf", + async run(ctx) { + const s = settingsOf(ctx.project); + const { invoices, issues } = buildInvoices(lines(ctx.project.rows), s); + if (issues.some((i) => i.level === "error")) throw new KitError("has_errors", `Fix ${issues.filter((i) => i.level === "error").length} error(s) first (see the issue list).`); + const files: string[] = []; + let cjk = true; + for (const inv of invoices) { + const r = await renderPdf([inv], s); + cjk &&= r.cjk; + files.push(await ctx.write(`${safeFileName(inv.number)}-${safeFileName(inv.client, "client").slice(0, 40)}.pdf`, r.bytes)); + } + files.push(await ctx.write("all-invoices.pdf", (await renderPdf(invoices, s)).bytes)); + return { files, note: cjk ? undefined : "No Chinese font was found on this computer; non-Latin text was replaced with ?." }; + }, + }, + { + id: "ledger", + label: ["开票台账 Excel", "Ledger (Excel)"], + description: "invoices.xlsx with an invoice summary sheet and a line-item sheet", + async run(ctx) { + const s = settingsOf(ctx.project); + const { invoices } = buildInvoices(lines(ctx.project.rows), s); + const xlsx = await writeXlsx([ + { name: "Invoices", headers: ["Invoice", "Client", "Date", "Due", "Subtotal", "Tax", "Total", "Currency"], rows: invoices.map((i) => [i.number, i.client, i.date, i.due, i.subtotal, i.tax, i.total, i.currency]), numberFormat: { 4: "#,##0.00", 5: "#,##0.00", 6: "#,##0.00" } }, + { name: "Lines", headers: ["Invoice", "Client", "Item", "Qty", "Price", "Tax %", "Amount", "Tax"], rows: invoices.flatMap((i) => i.lines.map((l) => [i.number, i.client, l.item, l.q, l.p, l.t, l.amount, l.taxAmount])) }, + ]); + const csv = toCsv(["Invoice", "Client", "Date", "Due", "Subtotal", "Tax", "Total", "Currency"], invoices.map((i) => [i.number, i.client, i.date, i.due, i.subtotal, i.tax, i.total, i.currency])); + const html = htmlPage("Invoices", `

${s.seller || "Invoices"}

` + htmlTable(["Invoice", "Client", "Date", "Due", "Total"], invoices.map((i) => [i.number, i.client, i.date, i.due, money(i.total, i.currency)]))); + return [await ctx.write("invoices.xlsx", xlsx), await ctx.write("invoices.csv", csv), await ctx.write("invoices.html", html)]; + }, + }, + ], + describeRow: (r, i) => `#${i} ${r._number} · ${r.client} · ${r.item} · ${r.qty} × ${r.price} (tax ${r.tax === "" ? "default" : r.tax + "%"}) = ${r._amount}`, +}; + +export function createServer(options: { workspaceRoot: string; assetRoot: string; log?: (line: string) => void }) { + return createApp(def, options).server; +} diff --git a/ui-plugins/invoice-maker/test/app-edit.test.ts b/ui-plugins/invoice-maker/test/app-edit.test.ts new file mode 100644 index 00000000..f9fe0f53 --- /dev/null +++ b/ui-plugins/invoice-maker/test/app-edit.test.ts @@ -0,0 +1,50 @@ +import { mkdtempSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { describe, expect, it } from "vitest"; +import { createApp, resolveColumnKey, type AppDef } from "../src/kit/app.ts"; +import { connect } from "../src/kit/testing.ts"; + +// 回归测试:_edit 的 set.values 用列标题(如“月薪”)也要能改到对应的列;认不出的列名要明确警告,不能悄悄忽略。 +const cols = [ + { key: "c0", label: ["姓名", "Name"] as [string, string] }, + { key: "c1", label: ["月薪", "Monthly Salary"] as [string, string], type: "number" as const }, + { key: "c2", label: ["合计", "Total"] as [string, string], readOnly: true }, +]; +const def: AppDef = { + name: "edit-test", version: "0.0.1", prefix: "et", title: ["测试", "Test"], openDescription: "test", + inputs: { exts: [".csv"], min: 0, max: 1, label: ["", ""] }, + settings: [], + columns: () => cols, + newRow: () => ({ c0: "", c1: 0, c2: 0 }), + load: async () => ({ rows: [{ c0: "张三", c1: 8000, c2: 0 }, { c0: "李四", c1: 9000, c2: 0 }] }), + compute: (p) => ({ rows: p.rows, issues: [], summary: `${p.rows.length} rows`, stats: {} }), + exports: [{ id: "none", label: ["无", "None"], description: "nothing", run: async () => [] }], +}; + +describe("edit by column label", () => { + it("resolves keys, labels and loose labels", () => { + expect(resolveColumnKey(cols, "c1")).toBe("c1"); + expect(resolveColumnKey(cols, "月薪")).toBe("c1"); + expect(resolveColumnKey(cols, " 月 薪 ")).toBe("c1"); + expect(resolveColumnKey(cols, "monthly salary")).toBe("c1"); + expect(resolveColumnKey(cols, "Name")).toBe("c0"); + expect(resolveColumnKey(cols, "奖金")).toBeUndefined(); + expect(resolveColumnKey(cols, "hidden", { hidden: 1 })).toBe("hidden"); + }); + it("edits through the tool and warns about unknown keys", async () => { + const root = mkdtempSync(join(tmpdir(), "edit-")); + const c = await connect(createApp(def, { workspaceRoot: root, assetRoot: root }).server); + await c.call("et_open", { inputs: [], project: "p" }); + const e = await c.call("et_edit", { project: "p", set: [{ row: 0, values: { 月薪: "12000", " monthly salary ": 1 } }, { row: 1, values: { 姓名: "王五", 奖金: 500, Total: 1 } }], add: [{ Name: "赵六", 月薪: 7000, foo: 1 }] }); + const rows = e.data.rows as Record[]; + expect(rows[0].c1).toBe(1); + expect(rows[1]).toMatchObject({ c0: "王五", c1: 9000, c2: 0 }); + expect(rows[1]).not.toHaveProperty("奖金"); + expect(rows[2]).toMatchObject({ c0: "赵六", c1: 7000 }); + expect(rows[2]).not.toHaveProperty("foo"); + expect(e.text).toContain("Warning: ignored unknown column(s) “奖金”, “foo”"); + expect(e.text).toContain("c1 (月薪 / Monthly Salary)"); + expect(e.text).toContain("c2 is calculated and cannot be edited."); + }); +}); diff --git a/ui-plugins/invoice-maker/test/e2e.json b/ui-plugins/invoice-maker/test/e2e.json new file mode 100644 index 00000000..14e43507 --- /dev/null +++ b/ui-plugins/invoice-maker/test/e2e.json @@ -0,0 +1,3 @@ +{ "prefix": "invoice", "folder": "账单", "pick": ["invoices-2026-11.xlsx"], "startSettings": { "seller": "Penova Labs", "taxRate": 6 }, + "edit": { "settings": { "sellerInfo": "Sheridan, WY · billing@penova.example", "notes": "请在付款期限内转账,备注发票号。Please include the invoice number with your payment." } }, + "uiEdit": { "row": 3, "key": "qty", "value": "5" }, "expectText": "INV-0003", "expectFiles": ["all-invoices\\.pdf$", "invoices\\.xlsx$"] } diff --git a/ui-plugins/invoice-maker/test/invoice.test.ts b/ui-plugins/invoice-maker/test/invoice.test.ts new file mode 100644 index 00000000..c64012f4 --- /dev/null +++ b/ui-plugins/invoice-maker/test/invoice.test.ts @@ -0,0 +1,118 @@ +import { cp, mkdtemp, readFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; +import { PDFDocument } from "pdf-lib"; +import { describe, expect, it } from "vitest"; +import { buildInvoices, detectCurrency, money, qtyOf } from "../src/invoice.ts"; +import { connect } from "../src/kit/testing.ts"; +import { createServer } from "../src/server.ts"; + +const HERE = dirname(fileURLToPath(import.meta.url)); +const base = { seller: "Penova", sellerInfo: "", currency: "CNY", taxRate: 6, prefix: "INV-", start: 7, date: "2026-11-25", dueDays: 30, notes: "", accent: "#2563eb", paper: "A4" as const, lang: "both" as const }; + +describe("buildInvoices", () => { + it("groups by client when there is no number, numbers from start, applies default tax", () => { + const { invoices, issues } = buildInvoices([ + { invoice: "", client: "A", address: "x", item: "a", qty: 2, price: "¥1,000", tax: "" }, + { invoice: "", client: "B", address: "y", item: "b", qty: "一", price: 50, tax: 0 }, + { invoice: "", client: "A", address: "", item: "c", qty: 1, price: 0.1, tax: 13 }, + ], base); + expect(issues).toEqual([]); + expect(invoices.map((i) => [i.number, i.client, i.subtotal, i.tax, i.total, i.due])).toEqual([ + ["INV-0007", "A", 2000.1, 120.01, 2120.11, "2026-12-25"], + ["INV-0008", "B", 50, 0, 50, "2026-12-25"], + ]); + }); + it("flags bad numbers, missing clients and a number reused for another client", () => { + const { issues } = buildInvoices([ + { invoice: "X1", client: "A", address: "a", item: "a", qty: "abc", price: 1, tax: "" }, + { invoice: "X1", client: "B", address: "b", item: "b", qty: 1, price: "n/a", tax: 120 }, + { invoice: "", client: "", address: "c", item: "c", qty: 1, price: 1, tax: "" }, + ], base); + const keys = issues.filter((i) => i.level === "error").map((i) => `${i.row}:${i.key}`); + expect(keys).toEqual(expect.arrayContaining(["0:qty", "1:price", "1:tax", "1:invoice", "2:client"])); + }); + it("formats money and Chinese quantities", () => { + expect(money(1234.5, "USD")).toBe("$1,234.50"); + expect(money(1234.5, "JPY")).toBe("¥1,235"); + expect(qtyOf("三")).toBe(3); + expect(qtyOf("")).toBe(1); + }); +}); + +describe("invoice tools on the sample sheet", () => { + it("opens, edits, exports PDFs and the ledger", async () => { + const ws = await mkdtemp(join(tmpdir(), "inv-")); + await cp(join(HERE, "samples"), join(ws, "billing"), { recursive: true }); + const { call } = await connect(createServer({ workspaceRoot: ws, assetRoot: join(HERE, "..") })); + const opened = await call("invoice_open", { inputs: ["billing/invoices-2026-11.xlsx"], settings: { seller: "Penova Labs", taxRate: "6", date: "2026-11-25" } }); + expect(opened.data.stats.invoices).toBe(3); + expect(opened.text).toContain("INV-0001"); + const totals = opened.data.rows.map((r: any) => r._amount); + expect(totals).toEqual([18000, 7500, 320, 427.5, 26000, 1200, 800]); + expect(opened.data.issues.some((i: any) => i.key === "address" && i.row === 0)).toBe(false); + // 客户 B 的服务器迁移行没有地址,但同一张发票已有地址 → 不报 + expect(opened.data.issues.filter((i: any) => i.level === "error")).toEqual([]); + const edited = await call("invoice_edit", { project: "invoices-2026-11", set: [{ row: 3, values: { qty: "5" } }], settings: { currency: "USD", lang: "en" } }); + expect(edited.data.rows[3]._amount).toBe(475); + expect(edited.data.summary).toContain("$"); + const exported = await call("invoice_export", { project: "invoices-2026-11" }); + const files: string[] = exported.data.exported; + expect(files.filter((f) => f.endsWith(".pdf"))).toHaveLength(4); + const all = await PDFDocument.load(await readFile(join(ws, files.find((f) => f.endsWith("all-invoices.pdf"))!))); + expect(all.getPageCount()).toBe(3); + const csv = await readFile(join(ws, files.find((f) => f.endsWith(".csv"))!), "utf8"); + expect(csv).toContain("INV-0002,Northwind Studio LLC,2026-11-25,2026-12-25,795,0,795,USD"); + // 引入错误后 PDF 导出被拒绝 + await call("invoice_edit", { project: "invoices-2026-11", set: [{ row: 0, values: { price: "abc" } }] }); + await expect(call("invoice_export", { project: "invoices-2026-11", formats: ["pdf"] })).rejects.toMatchObject({ code: "has_errors" }); + }); + it("explains missing columns", async () => { + const ws = await mkdtemp(join(tmpdir(), "inv-")); + const { writeFile } = await import("node:fs/promises"); + await writeFile(join(ws, "x.csv"), "foo,bar\n1,2\n"); + const { call } = await connect(createServer({ workspaceRoot: ws, assetRoot: join(HERE, "..") })); + await expect(call("invoice_open", { inputs: ["x.csv"] })).rejects.toMatchObject({ code: "columns_not_found" }); + await expect(call("invoice_open", { inputs: ["../x.csv"] })).rejects.toMatchObject({ code: "outside_workspace" }); + }); +}); + +// 回归测试:$320.00 不能被当成人民币(FIX-QUEUE-100) +describe("currency from the sheet", () => { + it("detects codes, prefixed and bare symbols", () => { + expect(detectCurrency("$320.00")).toBe("USD"); + expect(detectCurrency("US$ 5")).toBe("USD"); + expect(detectCurrency("HK$1,200")).toBe("HKD"); + expect(detectCurrency("320 EUR")).toBe("EUR"); + expect(detectCurrency("£9.99")).toBe("GBP"); + expect(detectCurrency("RMB 100")).toBe("CNY"); + expect(detectCurrency("100港元")).toBe("HKD"); + expect(detectCurrency("¥500")).toBe("CNY"); + expect(detectCurrency("¥500", "JPY")).toBe("JPY"); + expect(detectCurrency("单价 (USD)")).toBe("USD"); + expect(detectCurrency(320)).toBeUndefined(); + expect(detectCurrency("320")).toBeUndefined(); + }); + it("bills $320.00 in USD even when the default is CNY", () => { + const { invoices, issues } = buildInvoices([ + { invoice: "", client: "Acme", address: "x", item: "Design", qty: 1, price: "$320.00", tax: 0 }, + { invoice: "", client: "Acme", address: "x", item: "Hosting", qty: 2, price: "15", tax: 0 }, + { invoice: "", client: "李", address: "y", item: "咨询", qty: 1, price: "¥1,000", tax: 0 }, + ], { ...base, taxRate: 0 }); + expect(invoices.map((i) => [i.client, i.currency, i.total])).toEqual([["Acme", "USD", 350], ["李", "CNY", 1000]]); + expect(money(invoices[0].total, invoices[0].currency)).toBe("$350.00"); + expect(issues.filter((i) => i.level === "error")).toEqual([]); + expect(issues.some((i) => i.level === "info" && i.message.includes("USD"))).toBe(true); + }); + it("uses a currency column and flags mixed or unknown currencies", () => { + const { invoices, issues } = buildInvoices([ + { invoice: "A1", client: "A", address: "x", item: "a", qty: 1, price: 10, tax: 0, currency: "eur" }, + { invoice: "A2", client: "B", address: "x", item: "b", qty: 1, price: "$5", tax: 0 }, + { invoice: "A2", client: "B", address: "x", item: "c", qty: 1, price: "€5", tax: 0 }, + { invoice: "A3", client: "C", address: "x", item: "d", qty: 1, price: 1, tax: 0, currency: "doubloons" }, + ], base); + expect(invoices[0].currency).toBe("EUR"); + expect(issues.filter((i) => i.level === "error").map((i) => i.row)).toEqual([2, 3]); + }); +}); diff --git a/ui-plugins/invoice-maker/test/samples/invoices-2026-11.xlsx b/ui-plugins/invoice-maker/test/samples/invoices-2026-11.xlsx new file mode 100644 index 00000000..eea66a73 Binary files /dev/null and b/ui-plugins/invoice-maker/test/samples/invoices-2026-11.xlsx differ diff --git a/ui-plugins/invoice-maker/test/workspace-links.test.ts b/ui-plugins/invoice-maker/test/workspace-links.test.ts new file mode 100644 index 00000000..f3dae538 --- /dev/null +++ b/ui-plugins/invoice-maker/test/workspace-links.test.ts @@ -0,0 +1,43 @@ +import { existsSync, mkdirSync, mkdtempSync, symlinkSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { describe, expect, it } from "vitest"; +import { Workspace } from "../src/kit/workspace.ts"; + +// 回归测试:工作区里的符号链接不能把读写带到工作区之外(TEST-FINDINGS #2) +describe("workspace symlink containment", () => { + const base = mkdtempSync(join(tmpdir(), "wslinks-")); + const root = join(base, "项目 ws"), outside = join(base, "outside"); + mkdirSync(join(root, "inner"), { recursive: true }); + mkdirSync(outside, { recursive: true }); + writeFileSync(join(outside, "secret.txt"), "SECRET"); + writeFileSync(join(root, "inner", "ok.txt"), "ok"); + symlinkSync(outside, join(root, "out-link")); + symlinkSync(join(outside, "secret.txt"), join(root, "secret-link.txt")); + symlinkSync(join(outside, "new-file.txt"), join(root, "dangling.txt")); + symlinkSync(join(root, "inner"), join(root, "inner-link")); + symlinkSync(root, join(base, "root-link")); + const ws = new Workspace(root); + + it("refuses to read through a link to outside (directory and file links)", async () => { + await expect(ws.read("out-link/secret.txt")).rejects.toMatchObject({ code: "outside_workspace" }); + await expect(ws.read("secret-link.txt")).rejects.toMatchObject({ code: "outside_workspace" }); + expect(await ws.exists("out-link/secret.txt")).toBe(false); + }); + it("refuses to write through a link, including to targets that do not exist yet", async () => { + await expect(ws.write("out-link/a/b/new.txt", "x")).rejects.toMatchObject({ code: "outside_workspace" }); + await expect(ws.write("dangling.txt", "x")).rejects.toMatchObject({ code: "outside_workspace" }); + expect(existsSync(join(outside, "a"))).toBe(false); + expect(existsSync(join(outside, "new-file.txt"))).toBe(false); + }); + it("still allows normal paths, new nested files and links that stay inside", async () => { + expect(await ws.write("新 目录/子/文件.txt", "中文")).toBe("新 目录/子/文件.txt"); + expect((await ws.read("inner-link/ok.txt")).toString()).toBe("ok"); + await expect(ws.read("../outside/secret.txt")).rejects.toMatchObject({ code: "outside_workspace" }); + }); + it("works when the workspace root itself is reached through a link", async () => { + const viaLink = new Workspace(join(base, "root-link")); + expect((await viaLink.read("inner/ok.txt")).toString()).toBe("ok"); + await expect(viaLink.read("out-link/secret.txt")).rejects.toMatchObject({ code: "outside_workspace" }); + }); +}); diff --git a/ui-plugins/invoice-maker/tsconfig.json b/ui-plugins/invoice-maker/tsconfig.json new file mode 100644 index 00000000..39f7ab60 --- /dev/null +++ b/ui-plugins/invoice-maker/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "lib": ["ES2023", "DOM", "DOM.Iterable"], + "strict": true, + "skipLibCheck": true, + "noEmit": true, + "allowImportingTsExtensions": true, + "types": ["node"] + }, + "include": ["src/**/*.ts", "ui/**/*.ts", "test/**/*.ts"] +} diff --git a/ui-plugins/invoice-maker/ui/app.css b/ui-plugins/invoice-maker/ui/app.css new file mode 100644 index 00000000..19894635 --- /dev/null +++ b/ui-plugins/invoice-maker/ui/app.css @@ -0,0 +1,39 @@ +.top { display:flex; align-items:baseline; gap:10px; } +.files { max-height: 260px; overflow:auto; border:1px solid var(--line); border-radius:6px; padding:4px; background:var(--bg); } +.file { padding:2px 4px; font-size:12px; word-break: break-all; } +.filter { width:100%; margin-bottom:6px; } +.settings { display:grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap:6px 12px; } +.set { justify-content: space-between; } +.set span { color: var(--muted); } +.set input[type=text], .set input[type=number], .set select, .set textarea, .set input[type=date] { width: 60%; } +.set-textarea { grid-column: 1 / -1; align-items: flex-start; } +.set-textarea textarea { width: 80%; } +.head .pname { font-weight:600; } +.summary { margin:8px 0 4px; } +.chips { display:flex; flex-wrap:wrap; gap:6px; margin:4px 0 8px; } +.chip { background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:1px 8px; font-size:12px; } +.issues { margin:6px 0; } +.issues ul { margin:4px 0; padding-left:18px; max-height:180px; overflow:auto; } +.issues li { cursor:pointer; } +.lvl-error { color: var(--bad); } .lvl-warn { color: var(--warn); } +.split2 { display:grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap:10px; align-items:start; } +.split2 .previewcol:empty { display:none; } +.split2:has(.previewcol:empty) { grid-template-columns: 1fr; } +@media (max-width: 900px) { .split2 { grid-template-columns: 1fr; } } +.tablewrap { overflow:auto; max-height: 60vh; border:1px solid var(--line); border-radius:6px; } +table.edit { font-size:12px; } +table.edit td { padding:1px 2px; } +table.edit th { position: sticky; top: 0; z-index: 1; white-space: nowrap; } +table.edit td input[type=text], table.edit td select { width:100%; min-width:70px; border-color: transparent; background: transparent; padding:2px 4px; } +table.edit td input:focus, table.edit td select:focus { border-color: var(--accent); background: var(--bg); } +table.edit td.wide input { min-width: 200px; } +table.edit td.ro { color: var(--muted); padding: 2px 6px; white-space: nowrap; } +table.edit .num { text-align: right; } +table.edit td.idx { color: var(--muted); text-align: right; padding: 2px 4px; } +table.edit tr.warn td.idx { background: var(--warnbg); } +table.edit tr.err td.idx { background: var(--badbg); color: var(--bad); } +table.edit tr.focus td { outline: 1px solid var(--accent); } +button.del { padding: 0 6px; } +.preview { border:1px solid var(--line); border-radius:6px; padding:8px; background: var(--bg); overflow:auto; max-height: 75vh; } +.preview img, .preview svg { max-width: 100%; height: auto; } +.exported ul { margin: 4px 0; padding-left: 18px; font-size: 12px; } diff --git a/ui-plugins/invoice-maker/ui/app.ts b/ui-plugins/invoice-maker/ui/app.ts new file mode 100644 index 00000000..dba63195 --- /dev/null +++ b/ui-plugins/invoice-maker/ui/app.ts @@ -0,0 +1,236 @@ +import css from "./kit.css"; +import appCss from "./app.css"; +import { applyTheme, call, h, initHost, locale, onHostContext, onToolResult, put, toast, updateContext } from "./kit.ts"; + +type L = [string, string]; +interface Field { key: string; label: L; type: string; options?: { value: string; label: L }[]; default?: unknown; help?: L; min?: number; max?: number } +interface Column { key: string; label: L; type?: string; options?: string[]; readOnly?: boolean; wide?: boolean } +interface Issue { level: string; message: string; row?: number; key?: string } +interface Info { app: string; prefix: string; title: L; inputs: { exts: string[]; min: number; max: number; label: L; folders?: boolean }; settings: Field[]; exports: { id: string; label: L; description: string }[]; files: string[]; folders: string[]; projects: string[] } +interface View { project: string; inputs: string[]; settings: Record; columns: Column[]; rows: Record[]; totalRows: number; canAdd: boolean; issues: Issue[]; summary: string; stats: Record; preview: string; exported: string[]; justExported?: string[] } + +const T = (l: L | undefined) => (l ? (locale() === "zh" ? l[0] : l[1]) : ""); +const t = (zh: string, en: string) => (locale() === "zh" ? zh : en); +const PAGE = 100; + +export function startApp(name: string, version: string) { + const style = document.createElement("style"); + style.textContent = css + appCss; + document.head.append(style); + const root = document.getElementById("root")!; + const state: { info?: Info; view?: View; picked: Set; filter: string; page: number; startSettings: Record; focusRow?: number; mode: "start" | "project" } = { picked: new Set(), filter: "", page: 0, startSettings: {}, mode: "start" }; + + async function busy(work: () => Promise, label: string): Promise { + root.classList.add("busy"); + const st = document.getElementById("status"); + if (st) st.textContent = label; + try { + return await work(); + } catch (error) { + toast(error instanceof Error ? error.message : String(error), "error"); + return undefined; + } finally { + root.classList.remove("busy"); + const s2 = document.getElementById("status"); + if (s2) s2.textContent = ""; + } + } + const P = () => state.info?.prefix ?? name; + function show(v: Record) { + const prev = state.view?.project; + state.view = v as unknown as View; + state.mode = "project"; + if (prev !== state.view.project) state.page = 0; + render(); + } + onToolResult((v) => { + if (v?.kind === "project" && v.app === name) show(v); + }); + + async function refreshInfo() { + const info = await call("app_info", {}); + state.info = info; + render(); + } + + function fieldInput(f: Field, value: unknown, onChange: (v: unknown) => void) { + const v = value ?? f.default ?? ""; + if (f.type === "bool") return h("input", { type: "checkbox", checked: !!v, "data-key": f.key, onchange: (e: Event) => onChange((e.target as HTMLInputElement).checked) }); + if (f.type === "select") + return h("select", { "data-key": f.key, onchange: (e: Event) => onChange((e.target as HTMLSelectElement).value) }, ...(f.options ?? []).map((o) => h("option", { value: o.value, selected: String(v) === o.value }, T(o.label)))); + if (f.type === "textarea") return h("textarea", { rows: 3, "data-key": f.key, value: String(v), onchange: (e: Event) => onChange((e.target as HTMLTextAreaElement).value) }); + return h("input", { + type: f.type === "number" ? "number" : f.type === "color" ? "color" : f.type === "date" ? "date" : "text", + "data-key": f.key, + value: String(v), + min: f.min, + max: f.max, + step: f.type === "number" ? "any" : undefined, + onchange: (e: Event) => onChange(f.type === "number" ? Number((e.target as HTMLInputElement).value) : (e.target as HTMLInputElement).value), + }); + } + function settingsForm(values: Record, onChange: (key: string, v: unknown) => void) { + const fields = state.info?.settings ?? []; + if (!fields.length) return null; + return h("div", { class: "settings" }, ...fields.map((f) => h("label", { class: `set set-${f.type}`, title: T(f.help) }, h("span", {}, T(f.label)), fieldInput(f, values[f.key], (v) => onChange(f.key, v))))); + } + + function renderStart() { + const info = state.info; + if (!info) return h("div", { class: "empty" }, t("正在连接…", "Connecting…")); + const list = info.inputs.folders ? info.folders : info.files; + const shown = list.filter((f) => !state.filter || f.toLowerCase().includes(state.filter.toLowerCase())).slice(0, 400); + const needs = info.inputs.min; + const open = () => + busy(async () => { + const r = await call(`${P()}_open`, { inputs: [...state.picked], settings: state.startSettings }); + show(r); + }, t("正在读取…", "Reading…")); + return h( + "div", + { class: "start" }, + h("div", { class: "card" }, + h("h2", {}, T(info.inputs.label)), + needs === 0 && !list.length ? h("p", { class: "muted" }, t("这个工具不需要输入文件,直接点“开始”。", "No input file needed — just press Start.")) : null, + list.length > 8 ? h("input", { class: "filter", placeholder: t("筛选文件…", "Filter files…"), value: state.filter, oninput: (e: Event) => { state.filter = (e.target as HTMLInputElement).value; render(); } }) : null, + list.length + ? h("div", { class: "files" }, ...shown.map((f) => h("label", { class: "file" }, h("input", { type: info.inputs.max === 1 ? "radio" : "checkbox", name: "pick", checked: state.picked.has(f), onchange: (e: Event) => { if (info.inputs.max === 1) state.picked.clear(); if ((e.target as HTMLInputElement).checked) state.picked.add(f); else state.picked.delete(f); render(); } }), h("span", {}, f)))) + : needs > 0 ? h("div", { class: "empty" }, t(`工作区里没有 ${info.inputs.exts.join(" / ")} 文件。把文件放进项目文件夹,或让助手帮你处理。`, `No ${info.inputs.exts.join(" / ")} files in the workspace yet. Add some to the project folder or ask the assistant.`)) : null, + ), + info.settings.length ? h("div", { class: "card" }, h("h2", {}, t("设置", "Settings")), settingsForm(state.startSettings, (k, v) => { state.startSettings[k] = v; })) : null, + h("div", { class: "row" }, + h("button", { class: "primary open", disabled: state.picked.size < needs || state.picked.size > info.inputs.max, onclick: open }, needs === 0 && !state.picked.size ? t("开始", "Start") : t(`打开(${state.picked.size})`, `Open (${state.picked.size})`)), + h("button", { onclick: () => busy(refreshInfo, "") }, t("刷新文件列表", "Refresh files")), + ), + info.projects.length + ? h("div", { class: "card" }, h("h2", {}, t("已保存的项目", "Saved projects")), h("div", { class: "row" }, ...info.projects.map((p) => h("button", { class: "proj", onclick: () => busy(async () => show(await call(`${P()}_status`, { project: p })), "") }, p)))) + : null, + ); + } + + let editQueue: Promise = Promise.resolve(); + function edit(args: Record) { + const v = state.view!; + editQueue = editQueue + .then(async () => { + const r = await call(`${P()}_edit`, { project: v.project, ...args }); + state.view = r as unknown as View; + renderProjectParts(); + }) + .catch((e) => toast(String((e as Error)?.message ?? e), "error")); + return editQueue; + } + + function cell(c: Column, row: Record, index: number) { + const value = row[c.key]; + if (c.readOnly) return h("td", { "data-key": c.key, class: `ro ${c.type === "number" ? "num" : ""}` }, typeof value === "number" ? fmtNum(value) : String(value ?? "")); + const onChange = (v: unknown) => edit({ set: [{ row: index, values: { [c.key]: v } }] }); + let input: HTMLElement; + if (c.type === "bool") input = h("input", { type: "checkbox", checked: !!value, onchange: (e: Event) => onChange((e.target as HTMLInputElement).checked) }); + else if (c.type === "select") input = h("select", { onchange: (e: Event) => onChange((e.target as HTMLSelectElement).value) }, ...[...new Set([String(value ?? ""), ...(c.options ?? [])])].map((o) => h("option", { value: o, selected: o === String(value ?? "") }, o))); + else input = h("input", { type: "text", class: c.type === "number" ? "num" : "", value: String(value ?? ""), onchange: (e: Event) => onChange((e.target as HTMLInputElement).value) }); + return h("td", { "data-key": c.key, class: c.wide ? "wide" : "" }, input); + } + const fmtNum = (n: number) => (Number.isInteger(n) ? String(n) : n.toFixed(2)); + + function tableEl() { + const v = state.view!; + const issuesByRow = new Map(); + for (const i of v.issues) if (i.row !== undefined) issuesByRow.set(i.row, [...(issuesByRow.get(i.row) ?? []), i]); + const pages = Math.max(1, Math.ceil(v.rows.length / PAGE)); + state.page = Math.min(state.page, pages - 1); + const start = state.page * PAGE; + const slice = v.rows.slice(start, start + PAGE); + if (!v.rows.length) return h("div", { class: "empty" }, t("没有数据行。", "No rows.")); + return h("div", {}, + h("div", { class: "tablewrap" }, + h("table", { class: "data edit" }, + h("thead", {}, h("tr", {}, h("th", {}, "#"), ...v.columns.map((c) => h("th", { class: c.readOnly ? "ro" : "" }, T(c.label))), v.canAdd ? h("th", {}, "") : null)), + h("tbody", {}, ...slice.map((row, k) => { + const index = start + k; + const iss = issuesByRow.get(index); + return h("tr", { class: `${iss?.some((i) => i.level === "error") ? "err" : iss ? "warn" : ""} ${state.focusRow === index ? "focus" : ""}`, "data-row": index, title: iss?.map((i) => i.message).join("\n") }, + h("td", { class: "idx" }, String(index)), ...v.columns.map((c) => cell(c, row, index)), + v.canAdd ? h("td", {}, h("button", { class: "del", title: t("删除这一行", "Delete row"), onclick: () => edit({ remove: [index] }) }, "×")) : null); + })), + ), + ), + h("div", { class: "row" }, + pages > 1 ? h("span", { class: "pager" }, h("button", { disabled: state.page === 0, onclick: () => { state.page--; renderProjectParts(); } }, "‹"), ` ${state.page + 1} / ${pages} `, h("button", { disabled: state.page >= pages - 1, onclick: () => { state.page++; renderProjectParts(); } }, "›")) : null, + v.totalRows > v.rows.length ? h("span", { class: "muted" }, t(`面板显示前 ${v.rows.length} 行,共 ${v.totalRows} 行`, `Showing ${v.rows.length} of ${v.totalRows} rows`)) : null, + v.canAdd ? h("button", { class: "add", onclick: () => edit({ add: [{}] }) }, t("+ 新增一行", "+ Add row")) : null, + ), + ); + } + + function issuesEl() { + const v = state.view!; + if (!v.issues.length) return h("div", { class: "issues ok" }, h("span", { class: "badge ok" }, t("没有发现问题", "No issues"))); + const counts = { error: 0, warn: 0, info: 0 } as Record; + for (const i of v.issues) counts[i.level] = (counts[i.level] ?? 0) + 1; + return h("details", { class: "issues", open: v.issues.length <= 12 }, + h("summary", {}, counts.error ? h("span", { class: "badge bad" }, t(`${counts.error} 个错误`, `${counts.error} error(s)`)) : null, " ", counts.warn ? h("span", { class: "badge" }, t(`${counts.warn} 个提醒`, `${counts.warn} warning(s)`)) : null, " ", counts.info ? h("span", { class: "badge ok" }, t(`${counts.info} 条说明`, `${counts.info} note(s)`)) : null), + h("ul", {}, ...v.issues.slice(0, 200).map((i) => h("li", { class: `lvl-${i.level}`, onclick: () => { if (i.row !== undefined) { state.focusRow = i.row; state.page = Math.floor(i.row / PAGE); renderProjectParts(); document.querySelector(`tr[data-row="${i.row}"]`)?.scrollIntoView({ block: "center" }); } } }, i.row !== undefined ? h("b", {}, `#${i.row} `) : null, i.key ? h("code", {}, i.key) : null, " ", i.message))), + ); + } + + function exportsEl() { + const v = state.view!; + const info = state.info; + const run = (formats?: string[]) => + busy(async () => { + const r = await call(`${P()}_export`, { project: v.project, ...(formats ? { formats } : {}) }, 900_000); + state.view = r as unknown as View; + renderProjectParts(); + toast(t(`已导出 ${state.view.exported.length} 个文件`, `Exported ${state.view.exported.length} file(s)`)); + updateContext(`User exported ${v.project}: ${state.view.exported.join(", ")}`).catch(() => undefined); + }, t("正在导出…", "Exporting…")); + return h("div", { class: "card exports" }, + h("h2", {}, t("导出", "Export")), + h("div", { class: "row" }, ...(info?.exports ?? []).map((e) => h("button", { class: "exp", title: e.description, "data-id": e.id, onclick: () => run([e.id]) }, T(e.label))), (info?.exports.length ?? 0) > 1 ? h("button", { class: "primary expall", onclick: () => run() }, t("全部导出", "Export all")) : null), + v.exported.length ? h("div", { class: "exported" }, h("div", { class: "muted" }, t("已导出:", "Exported:")), h("ul", {}, ...v.exported.map((f) => h("li", {}, h("code", {}, f))))) : null, + ); + } + + function renderProjectParts() { + const v = state.view; + if (!v) return; + const parts: Record Node | null> = { + summary: () => h("div", {}, h("div", { class: "summary" }, v.summary), Object.keys(v.stats).length ? h("div", { class: "chips" }, ...Object.entries(v.stats).map(([k, s]) => h("span", { class: "chip" }, h("b", {}, String(s)), " ", k))) : null), + issues: issuesEl, + table: tableEl, + preview: () => (v.preview ? (() => { const d = h("div", { class: "preview" }); d.innerHTML = v.preview; return d; })() : null), + exports: exportsEl, + }; + for (const [id, make] of Object.entries(parts)) { + const el = document.getElementById(`part-${id}`); + if (el) put(el, make()); + } + } + + function renderProject() { + const v = state.view!; + return h("div", { class: "project" }, + h("div", { class: "row head" }, + h("span", { class: "pname" }, v.project), + v.inputs.length ? h("span", { class: "muted" }, v.inputs.length > 3 ? t(`${v.inputs.length} 个输入`, `${v.inputs.length} inputs`) : v.inputs.join(" · ")) : null, + h("button", { class: "back", onclick: () => { state.mode = "start"; busy(refreshInfo, ""); } }, t("← 换文件", "← Other files")), + ), + state.info?.settings.length ? h("details", { class: "card", open: true }, h("summary", {}, t("设置", "Settings")), settingsForm(v.settings, (k, val) => edit({ settings: { [k]: val } }))) : null, + h("div", { id: "part-summary" }), + h("div", { id: "part-issues" }), + h("div", { class: "split2" }, h("div", { id: "part-table", class: "tablecol" }), h("div", { id: "part-preview", class: "previewcol" })), + h("div", { id: "part-exports" }), + ); + } + + function render() { + const title = state.info ? T(state.info.title) : name; + put(root, h("div", { class: "top" }, h("h1", {}, title), h("span", { id: "status", class: "muted" })), state.mode === "project" && state.view ? renderProject() : renderStart()); + if (state.mode === "project") renderProjectParts(); + } + + onHostContext(() => { applyTheme(); render(); }); + render(); + initHost(name, version).then(() => { applyTheme(); refreshInfo().catch((e) => toast(String(e?.message ?? e), "error")); }); +} diff --git a/ui-plugins/invoice-maker/ui/env.d.ts b/ui-plugins/invoice-maker/ui/env.d.ts new file mode 100644 index 00000000..4210a464 --- /dev/null +++ b/ui-plugins/invoice-maker/ui/env.d.ts @@ -0,0 +1,4 @@ +declare module "*.css" { + const text: string; + export default text; +} diff --git a/ui-plugins/invoice-maker/ui/kit.css b/ui-plugins/invoice-maker/ui/kit.css new file mode 100644 index 00000000..398bc83a --- /dev/null +++ b/ui-plugins/invoice-maker/ui/kit.css @@ -0,0 +1,34 @@ +:root { --bg:#fff; --fg:#1d1f23; --muted:#6b7280; --line:#e5e7eb; --panel:#f7f7f8; --accent:#2563eb; --warn:#b45309; --warnbg:#fef3c7; --bad:#b91c1c; --badbg:#fee2e2; --okbg:#dcfce7; --ok:#15803d; } +[data-theme="dark"] { --bg:#18191b; --fg:#e8e8ea; --muted:#9ca3af; --line:#2e3035; --panel:#222327; --accent:#60a5fa; --warn:#fbbf24; --warnbg:#3b2f10; --bad:#f87171; --badbg:#3b1717; --okbg:#12301d; --ok:#4ade80; } +* { box-sizing: border-box; } +html, body { margin:0; background:var(--bg); color:var(--fg); font:13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; } +#root { padding: 12px; } +h1 { font-size: 15px; margin: 0 0 8px; } +h2 { font-size: 13px; margin: 14px 0 6px; color: var(--muted); font-weight: 600; text-transform: none; } +button { font: inherit; border:1px solid var(--line); background:var(--panel); color:var(--fg); border-radius:6px; padding:5px 10px; cursor:pointer; } +button.primary { background:var(--accent); border-color:var(--accent); color:#fff; } +button:disabled { opacity:.5; cursor:default; } +input, select, textarea { font: inherit; color: var(--fg); background: var(--bg); border:1px solid var(--line); border-radius:5px; padding:4px 6px; } +input[type="color"] { padding: 0; width: 32px; height: 26px; } +input[type="range"] { padding: 0; } +label { display:flex; gap:6px; align-items:center; } +.row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin: 6px 0; } +.muted { color: var(--muted); } +.card { border:1px solid var(--line); border-radius:8px; padding:10px; background:var(--panel); margin: 8px 0; } +.grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(150px, 1fr)); gap:8px; } +.thumb { border:1px solid var(--line); border-radius:6px; overflow:hidden; background: var(--bg); cursor:pointer; position:relative; } +.thumb img { width:100%; display:block; aspect-ratio:1; object-fit:contain; background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 50% / 16px 16px; } +.thumb .cap { padding:4px 6px; font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } +.thumb.selected { outline: 2px solid var(--accent); } +.badge { display:inline-block; font-size:11px; padding:1px 6px; border-radius:10px; background:var(--warnbg); color:var(--warn); } +.badge.bad { background: var(--badbg); color: var(--bad); } +.badge.ok { background: var(--okbg); color: var(--ok); } +table.data { border-collapse: collapse; width: 100%; } +table.data td, table.data th { border:1px solid var(--line); padding:3px 6px; text-align:left; vertical-align:top; } +table.data th { background: var(--panel); } +.toast { position: fixed; right: 12px; bottom: 12px; padding: 8px 12px; border-radius: 6px; background: var(--okbg); color: var(--ok); z-index: 10; max-width: 80%; } +.toast.error { background: var(--badbg); color: var(--bad); } +.empty { padding: 24px; text-align:center; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; } +.busy { opacity:.6; pointer-events:none; } +.split { display:grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; } +@media (max-width: 640px) { .split { grid-template-columns: 1fr; } } diff --git a/ui-plugins/invoice-maker/ui/kit.ts b/ui-plugins/invoice-maker/ui/kit.ts new file mode 100644 index 00000000..b0646f25 --- /dev/null +++ b/ui-plugins/invoice-maker/ui/kit.ts @@ -0,0 +1,133 @@ +import { App } from "@modelcontextprotocol/ext-apps"; + +export class ToolError extends Error { + readonly code: string; + constructor(code: string, message: string) { + super(message); + this.code = code; + } +} + +let app: App | undefined; +let connection: Promise | undefined; +let created!: () => void; +const appCreated = new Promise((resolve) => (created = resolve)); +const resultListeners = new Set<(value: Record | undefined, tool?: string) => void>(); +const contextListeners = new Set<() => void>(); + +export function initHost(name: string, version: string) { + app = new App({ name, version }, { availableDisplayModes: ["inline", "fullscreen"] }); + app.ontoolresult = (result) => { + const content = result.structuredContent as Record | undefined; + resultListeners.forEach((listener) => listener(content)); + }; + app.onhostcontextchanged = () => contextListeners.forEach((listener) => listener()); + created(); + return ready(); +} + +export function ready(): Promise { + if (!app) return appCreated.then(() => ready()); + return (connection ??= app.connect().then(() => contextListeners.forEach((listener) => listener()))); +} + +export function onToolResult(listener: (value: Record | undefined) => void) { + resultListeners.add(listener); +} + +export function onHostContext(listener: () => void) { + contextListeners.add(listener); +} + +export function hostContext() { + return app?.getHostContext(); +} + +export function locale(): "zh" | "en" { + const fromHost = (app?.getHostContext()?.locale as string | undefined) ?? navigator.language ?? "en"; + return /^zh/i.test(fromHost) ? "zh" : "en"; +} + +export async function call>(name: string, args: Record = {}, timeout = 300_000): Promise { + await ready(); + let result; + try { + result = await app!.callServerTool({ name, arguments: args }, { timeout }); + } catch (error) { + throw new ToolError("host_error", error instanceof Error ? error.message : String(error)); + } + const content = result.structuredContent as Record | undefined; + const error = content?.error as { code?: string; message?: string } | undefined; + if (result.isError || error) { + const text = (result.content?.[0] as { text?: string } | undefined)?.text; + throw new ToolError(error?.code ?? "tool_error", error?.message ?? text ?? "The tool failed."); + } + return (content ?? {}) as T; +} + +/** 读取插件资源(二进制)。 */ +export async function readBlob(uri: string): Promise { + await ready(); + const result = await app!.readServerResource({ uri }); + const first = result.contents[0] as { blob?: string; text?: string } | undefined; + if (typeof first?.blob !== "string") throw new ToolError("host_error", first?.text?.slice(0, 300) ?? `Empty resource ${uri}`); + return base64ToBytes(first.blob); +} + +export function base64ToBytes(base64: string): Uint8Array { + const binary = atob(base64); + const bytes = new Uint8Array(binary.length); + for (let index = 0; index < binary.length; index++) bytes[index] = binary.charCodeAt(index); + return bytes; +} + +/** 由用户点击触发:把一句话发到对话里交给 Agent。 */ +export async function sendMessage(text: string) { + await ready(); + return app!.sendMessage({ role: "user", content: [{ type: "text", text }] }); +} + +export async function updateContext(text: string) { + await ready(); + return app!.updateModelContext({ content: [{ type: "text", text }] }); +} + +type Child = Node | string | number | null | undefined | false; +/** 极简 DOM 构建器。 */ +export function h( + tag: K, + props: Record = {}, + ...children: (Child | Child[])[] +): HTMLElementTagNameMap[K] { + const element = document.createElement(tag); + for (const [key, value] of Object.entries(props)) { + if (value === undefined || value === null || value === false) continue; + if (key.startsWith("on") && typeof value === "function") element.addEventListener(key.slice(2).toLowerCase(), value as EventListener); + else if (key === "class") element.className = String(value); + else if (key === "style" && typeof value === "object") Object.assign(element.style, value); + else if (key === "value" || (key in element && typeof value !== "string")) (element as any)[key] = value; + else element.setAttribute(key, value === true ? "" : String(value)); + } + for (const child of children.flat()) { + if (child === null || child === undefined || child === false) continue; + element.append(child instanceof Node ? child : String(child)); + } + return element; +} + +export function toast(message: string, kind: "ok" | "error" = "ok") { + const node = h("div", { class: `toast ${kind}`, role: "status" }, message); + document.body.append(node); + setTimeout(() => node.remove(), kind === "error" ? 6000 : 3000); +} + +/** 主题:跟随宿主的浅色 / 深色。 */ +export function applyTheme() { + const theme = (app?.getHostContext()?.theme as string | undefined) ?? "light"; + document.documentElement.dataset.theme = theme === "dark" ? "dark" : "light"; +} + +/** replaceChildren,跳过 null / false。 */ +export function put(element: Element, ...children: (Node | string | null | undefined | false)[]) { + element.replaceChildren(...(children.filter((c) => c !== null && c !== undefined && c !== false) as (Node | string)[])); +} diff --git a/ui-plugins/invoice-maker/ui/main.ts b/ui-plugins/invoice-maker/ui/main.ts new file mode 100644 index 00000000..ec653e1e --- /dev/null +++ b/ui-plugins/invoice-maker/ui/main.ts @@ -0,0 +1,3 @@ +import { startApp } from "./app.ts"; + +startApp("invoice-maker", "0.1.0"); diff --git a/ui-plugins/invoice-maker/vitest.config.ts b/ui-plugins/invoice-maker/vitest.config.ts new file mode 100644 index 00000000..27153a26 --- /dev/null +++ b/ui-plugins/invoice-maker/vitest.config.ts @@ -0,0 +1,2 @@ +import { defineConfig } from "vitest/config"; +export default defineConfig({ test: { include: ["src/**/*.test.ts", "test/**/*.test.ts"], testTimeout: 120000, hookTimeout: 120000 } });