diff --git a/scripts/ui-assets.cmake b/scripts/ui-assets.cmake index bfaa4ca4c..90d0bdf33 100644 --- a/scripts/ui-assets.cmake +++ b/scripts/ui-assets.cmake @@ -41,7 +41,7 @@ function(mime_from_ext name out_var) set(m "text/html; charset=utf-8") elseif(ext_str STREQUAL "css") set(m "text/css") - elseif(ext_str STREQUAL "js") + elseif(ext_str STREQUAL "js" OR ext_str STREQUAL "mjs") set(m "application/javascript") elseif(ext_str STREQUAL "json") set(m "application/json") @@ -98,9 +98,12 @@ function(ui_validate_assets files in_dir) set(found_build_json TRUE) elseif(base STREQUAL "version.json") set(found_version_json TRUE) - elseif(base MATCHES "^bundle.*\\.js$") + # the app's entry: bundle[hash].js/.css from a single-bundle build (builds before the + # split one, prebuilt archives included), or entry/start[hash].js and the CSS in + # _app/immutable/assets from a split build + elseif(base MATCHES "^bundle.*\\.js$" OR f MATCHES "(^|/)_app/immutable/entry/start\\.[^/]*\\.js$") set(found_bundle_js TRUE) - elseif(base MATCHES "^bundle.*\\.css$") + elseif(base MATCHES "^bundle.*\\.css$" OR f MATCHES "(^|/)_app/immutable/assets/[^/]*\\.css$") set(found_bundle_css TRUE) endif() endforeach() @@ -125,10 +128,10 @@ function(ui_validate_assets files in_dir) list(APPEND missing "version.json") endif() if(NOT found_bundle_js) - list(APPEND missing "bundle[hash].js") + list(APPEND missing "_app/immutable/entry/start[hash].js (or bundle[hash].js)") endif() if(NOT found_bundle_css) - list(APPEND missing "bundle[hash].css") + list(APPEND missing "_app/immutable/assets/[name][hash].css (or bundle[hash].css)") endif() if(missing) diff --git a/ui/apps/chat/package-lock.json b/ui/apps/chat/package-lock.json index 11778042c..ef7891ba3 100644 --- a/ui/apps/chat/package-lock.json +++ b/ui/apps/chat/package-lock.json @@ -51,8 +51,8 @@ "dompurify": "3.4.17", "eslint": "10.14.0", "eslint-config-prettier": "10.1.8", - "eslint-plugin-perfectionist": "^5.10.1", - "eslint-plugin-simple-import-sort": "^14.0.0", + "eslint-plugin-perfectionist": "5.13.0", + "eslint-plugin-simple-import-sort": "14.0.0", "eslint-plugin-storybook": "10.6.6", "eslint-plugin-svelte": "3.24.1", "fflate": "0.8.3", @@ -60,9 +60,9 @@ "highlight.js": "11.11.1", "http-server": "14.1.1", "mdsvex": "0.12.7", - "mermaid": "11.17.2", "mode-watcher": "1.1.0", "pdfjs-dist": "5.4.54", + "pele": "1.13.0", "playwright": "1.56.1", "prettier": "3.8.3", "prettier-plugin-svelte": "4.1.0", @@ -107,20 +107,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@antfu/install-pkg": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@antfu/install-pkg/-/install-pkg-2.1.0.tgz", - "integrity": "sha512-sdg9NxU3zR4Mnawfbc/x6GB5Wf17WYud5qOuEuxXjaKpYpMkISSJEjItGebXJ2bQ4DIcly4NYH23mtkGJjvKUw==", - "dev": true, - "license": "MIT", - "dependencies": { - "package-manager-detector": "^1.8.0", - "tinyexec": "^1.3.1" - }, - "funding": { - "url": "https://github.com/sponsors/antfu" - } - }, "node_modules/@babel/code-frame": { "version": "7.29.7", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", @@ -220,13 +206,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@braintree/sanitize-url": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/@braintree/sanitize-url/-/sanitize-url-7.1.2.tgz", - "integrity": "sha512-jigsZK+sMF/cuiB7sERuo9V7N9jx+dhmHHnQyDSVdpZwVutaBu7WvNYqMDLSgFgfB30n452TP3vjDAvFC973mA==", - "dev": true, - "license": "MIT" - }, "node_modules/@cacheable/memory": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@cacheable/memory/-/memory-2.2.0.tgz", @@ -258,13 +237,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@chevrotain/types": { - "version": "11.1.2", - "resolved": "https://registry.npmjs.org/@chevrotain/types/-/types-11.1.2.tgz", - "integrity": "sha512-U+HFai5+zmJCkK86QsaJtoITlboZHBqrVketcO2ROv865xfCMSFpELQoz1GkX5GzME8pTa+3kbKrZHQtI0gdbw==", - "dev": true, - "license": "Apache-2.0" - }, "node_modules/@chromatic-com/storybook": { "version": "5.5.1", "resolved": "https://registry.npmjs.org/@chromatic-com/storybook/-/storybook-5.5.1.tgz", @@ -1190,25 +1162,6 @@ "url": "https://github.com/sponsors/nzakas" } }, - "node_modules/@iconify/types": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@iconify/types/-/types-2.0.0.tgz", - "integrity": "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==", - "dev": true, - "license": "MIT" - }, - "node_modules/@iconify/utils": { - "version": "3.1.7", - "resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-3.1.7.tgz", - "integrity": "sha512-JZHlwdID+dy+lTgbYC8NEC4zeugqeYsc6jewvzb4c58kHauJn+X7rNwQjxz5p2qSjqaEeQoLkCIQ9v/H4PK0/w==", - "dev": true, - "license": "MIT", - "dependencies": { - "@antfu/install-pkg": "^2.0.1", - "@iconify/types": "^2.0.0", - "import-meta-resolve": "^4.2.0" - } - }, "node_modules/@img/colour": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz", @@ -1984,16 +1937,6 @@ "react": ">=16" } }, - "node_modules/@mermaid-js/parser": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@mermaid-js/parser/-/parser-1.2.1.tgz", - "integrity": "sha512-n12NohV3mrUyUL2o93IgG/ifeW9FTyeJn3zDxkhwa8MJ9Fxg3HQMlA3RiGmD/3UnJvheztkjjQAjA2T4LmUcpw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@chevrotain/types": "~11.1.2" - } - }, "node_modules/@modelcontextprotocol/sdk": { "version": "1.32.1", "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.32.1.tgz", @@ -4640,290 +4583,6 @@ "assertion-error": "^2.0.1" } }, - "node_modules/@types/d3": { - "version": "7.4.3", - "resolved": "https://registry.npmjs.org/@types/d3/-/d3-7.4.3.tgz", - "integrity": "sha512-lZXZ9ckh5R8uiFVt8ogUNf+pIrK4EsWrx2Np75WvF/eTpJ0FMHNhjXk8CKEx/+gpHbNQyJWehbFaTvqmHWB3ww==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/d3-array": "*", - "@types/d3-axis": "*", - "@types/d3-brush": "*", - "@types/d3-chord": "*", - "@types/d3-color": "*", - "@types/d3-contour": "*", - "@types/d3-delaunay": "*", - "@types/d3-dispatch": "*", - "@types/d3-drag": "*", - "@types/d3-dsv": "*", - "@types/d3-ease": "*", - "@types/d3-fetch": "*", - "@types/d3-force": "*", - "@types/d3-format": "*", - "@types/d3-geo": "*", - "@types/d3-hierarchy": "*", - "@types/d3-interpolate": "*", - "@types/d3-path": "*", - "@types/d3-polygon": "*", - "@types/d3-quadtree": "*", - "@types/d3-random": "*", - "@types/d3-scale": "*", - "@types/d3-scale-chromatic": "*", - "@types/d3-selection": "*", - "@types/d3-shape": "*", - "@types/d3-time": "*", - "@types/d3-time-format": "*", - "@types/d3-timer": "*", - "@types/d3-transition": "*", - "@types/d3-zoom": "*" - } - }, - "node_modules/@types/d3-array": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/@types/d3-array/-/d3-array-3.2.2.tgz", - "integrity": "sha512-hOLWVbm7uRza0BYXpIIW5pxfrKe0W+D5lrFiAEYR+pb6w3N2SwSMaJbXdUfSEv+dT4MfHBLtn5js0LAWaO6otw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-axis": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/@types/d3-axis/-/d3-axis-3.0.6.tgz", - "integrity": "sha512-pYeijfZuBd87T0hGn0FO1vQ/cgLk6E1ALJjfkC0oJ8cbwkZl3TpgS8bVBLZN+2jjGgg38epgxb2zmoGtSfvgMw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/d3-selection": "*" - } - }, - "node_modules/@types/d3-brush": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/@types/d3-brush/-/d3-brush-3.0.6.tgz", - "integrity": "sha512-nH60IZNNxEcrh6L1ZSMNA28rj27ut/2ZmI3r96Zd+1jrZD++zD3LsMIjWlvg4AYrHn/Pqz4CF3veCxGjtbqt7A==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/d3-selection": "*" - } - }, - "node_modules/@types/d3-chord": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/@types/d3-chord/-/d3-chord-3.0.6.tgz", - "integrity": "sha512-LFYWWd8nwfwEmTZG9PfQxd17HbNPksHBiJHaKuY1XeqscXacsS2tyoo6OdRsjf+NQYeB6XrNL3a25E3gH69lcg==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-color": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/@types/d3-color/-/d3-color-3.1.3.tgz", - "integrity": "sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-contour": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/@types/d3-contour/-/d3-contour-3.0.6.tgz", - "integrity": "sha512-BjzLgXGnCWjUSYGfH1cpdo41/hgdWETu4YxpezoztawmqsvCeep+8QGfiY6YbDvfgHz/DkjeIkkZVJavB4a3rg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/d3-array": "*", - "@types/geojson": "*" - } - }, - "node_modules/@types/d3-delaunay": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/@types/d3-delaunay/-/d3-delaunay-6.0.4.tgz", - "integrity": "sha512-ZMaSKu4THYCU6sV64Lhg6qjf1orxBthaC161plr5KuPHo3CNm8DTHiLw/5Eq2b6TsNP0W0iJrUOFscY6Q450Hw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-dispatch": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/@types/d3-dispatch/-/d3-dispatch-3.0.7.tgz", - "integrity": "sha512-5o9OIAdKkhN1QItV2oqaE5KMIiXAvDWBDPrD85e58Qlz1c1kI/J0NcqbEG88CoTwJrYe7ntUCVfeUl2UJKbWgA==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-drag": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/@types/d3-drag/-/d3-drag-3.0.7.tgz", - "integrity": "sha512-HE3jVKlzU9AaMazNufooRJ5ZpWmLIoc90A37WU2JMmeq28w1FQqCZswHZ3xR+SuxYftzHq6WU6KJHvqxKzTxxQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/d3-selection": "*" - } - }, - "node_modules/@types/d3-dsv": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/@types/d3-dsv/-/d3-dsv-3.0.7.tgz", - "integrity": "sha512-n6QBF9/+XASqcKK6waudgL0pf/S5XHPPI8APyMLLUHd8NqouBGLsU8MgtO7NINGtPBtk9Kko/W4ea0oAspwh9g==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-ease": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/d3-ease/-/d3-ease-3.0.2.tgz", - "integrity": "sha512-NcV1JjO5oDzoK26oMzbILE6HW7uVXOHLQvHshBUW4UMdZGfiY6v5BeQwh9a9tCzv+CeefZQHJt5SRgK154RtiA==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-fetch": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/@types/d3-fetch/-/d3-fetch-3.0.7.tgz", - "integrity": "sha512-fTAfNmxSb9SOWNB9IoG5c8Hg6R+AzUHDRlsXsDZsNp6sxAEOP0tkP3gKkNSO/qmHPoBFTxNrjDprVHDQDvo5aA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/d3-dsv": "*" - } - }, - "node_modules/@types/d3-force": { - "version": "3.0.10", - "resolved": "https://registry.npmjs.org/@types/d3-force/-/d3-force-3.0.10.tgz", - "integrity": "sha512-ZYeSaCF3p73RdOKcjj+swRlZfnYpK1EbaDiYICEEp5Q6sUiqFaFQ9qgoshp5CzIyyb/yD09kD9o2zEltCexlgw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-format": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@types/d3-format/-/d3-format-3.0.4.tgz", - "integrity": "sha512-fALi2aI6shfg7vM5KiR1wNJnZ7r6UuggVqtDA+xiEdPZQwy/trcQaHnwShLuLdta2rTymCNpxYTiMZX/e09F4g==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-geo": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/@types/d3-geo/-/d3-geo-3.1.1.tgz", - "integrity": "sha512-65Emv9fQiQQqphLlRkuQ5ypPsOmWPhtBGCMv61JDPEPMvsx+gzhGf74yw1a78xFKPj6zw4AgQICJoQv0vK9M2w==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/geojson": "*" - } - }, - "node_modules/@types/d3-hierarchy": { - "version": "3.1.7", - "resolved": "https://registry.npmjs.org/@types/d3-hierarchy/-/d3-hierarchy-3.1.7.tgz", - "integrity": "sha512-tJFtNoYBtRtkNysX1Xq4sxtjK8YgoWUNpIiUee0/jHGRwqvzYxkq0hGVbbOGSz+JgFxxRu4K8nb3YpG3CMARtg==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-interpolate": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@types/d3-interpolate/-/d3-interpolate-3.0.4.tgz", - "integrity": "sha512-mgLPETlrpVV1YRJIglr4Ez47g7Yxjl1lj7YKsiMCb27VJH9W8NVM6Bb9d8kkpG/uAQS5AmbA48q2IAolKKo1MA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/d3-color": "*" - } - }, - "node_modules/@types/d3-path": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/@types/d3-path/-/d3-path-3.1.1.tgz", - "integrity": "sha512-VMZBYyQvbGmWyWVea0EHs/BwLgxc+MKi1zLDCONksozI4YJMcTt8ZEuIR4Sb1MMTE8MMW49v0IwI5+b7RmfWlg==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-polygon": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/d3-polygon/-/d3-polygon-3.0.2.tgz", - "integrity": "sha512-ZuWOtMaHCkN9xoeEMr1ubW2nGWsp4nIql+OPQRstu4ypeZ+zk3YKqQT0CXVe/PYqrKpZAi+J9mTs05TKwjXSRA==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-quadtree": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/@types/d3-quadtree/-/d3-quadtree-3.0.6.tgz", - "integrity": "sha512-oUzyO1/Zm6rsxKRHA1vH0NEDG58HrT5icx/azi9MF1TWdtttWl0UIUsjEQBBh+SIkrpd21ZjEv7ptxWys1ncsg==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-random": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@types/d3-random/-/d3-random-3.0.4.tgz", - "integrity": "sha512-UHYId5WTCx4L4YNel7NU00XUXXgvgpgZOvp10PuvsQENjMDXhh2RyFc0KBjO7B45ne4Ha1yVH7ii0vnzKkuzWA==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-scale": { - "version": "4.0.9", - "resolved": "https://registry.npmjs.org/@types/d3-scale/-/d3-scale-4.0.9.tgz", - "integrity": "sha512-dLmtwB8zkAeO/juAMfnV+sItKjlsw2lKdZVVy6LRr0cBmegxSABiLEpGVmSJJ8O08i4+sGR6qQtb6WtuwJdvVw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/d3-time": "*" - } - }, - "node_modules/@types/d3-scale-chromatic": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@types/d3-scale-chromatic/-/d3-scale-chromatic-3.1.0.tgz", - "integrity": "sha512-iWMJgwkK7yTRmWqRB5plb1kadXyQ5Sj8V/zYlFGMUBbIPKQScw+Dku9cAAMgJG+z5GYDoMjWGLVOvjghDEFnKQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-selection": { - "version": "3.0.12", - "resolved": "https://registry.npmjs.org/@types/d3-selection/-/d3-selection-3.0.12.tgz", - "integrity": "sha512-Qe/KWYhEiIIxGs7HrAAjMfShxKldx19SJtr5zu53f3afPsdZNz7HHtdTLXo/kqeiWNXVycI24kSnfzBYkTzpgw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-shape": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/@types/d3-shape/-/d3-shape-3.2.0.tgz", - "integrity": "sha512-kVd74ta9eof3eJOvbNd1vGKS/XERRyQbT26Og63hIsvDO84cjD5gEOhsXf26w3FSoNlPVz84DOFcKv/oou+fMw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/d3-path": "*" - } - }, - "node_modules/@types/d3-time": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@types/d3-time/-/d3-time-3.0.4.tgz", - "integrity": "sha512-yuzZug1nkAAaBlBBikKZTgzCeA+k1uy4ZFwWANOfKw5z5LRhV0gNA7gNkKm7HoK+HRN0wX3EkxGk0fpbWhmB7g==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-time-format": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-4.0.3.tgz", - "integrity": "sha512-5xg9rC+wWL8kdDj153qZcsJ0FWiFt0J5RB6LYUNZjwSnesfblqrI/bJ1wBdJ8OQfncgbJG5+2F+qfqnqyzYxyg==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-timer": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/d3-timer/-/d3-timer-3.0.2.tgz", - "integrity": "sha512-Ps3T8E8dZDam6fUyNiMkekK3XUsaUEik+idO9/YjPtfj2qruF8tFBXS7XhtE4iIXBLxhmLjP3SXpLhVf21I9Lw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/d3-transition": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/@types/d3-transition/-/d3-transition-3.0.9.tgz", - "integrity": "sha512-uZS5shfxzO3rGlu0cC3bjmMFKsXv+SmZZcgp0KD22ts4uGXp5EVYGzu/0YdwZeKmddhcAccYtREJKkPfXkZuCg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/d3-selection": "*" - } - }, - "node_modules/@types/d3-zoom": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/@types/d3-zoom/-/d3-zoom-3.0.9.tgz", - "integrity": "sha512-0sE1406XBYJGiqD3AusTl9ZqC//2mIXix51tbom25gDCA8ri4xnSZg28CaSE8Srl6FClqABUKfsn0qghgdepMA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/d3-interpolate": "*", - "@types/d3-selection": "*" - } - }, "node_modules/@types/debug": { "version": "4.1.13", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.13.tgz", @@ -4955,13 +4614,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/geojson": { - "version": "7946.0.16", - "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz", - "integrity": "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==", - "dev": true, - "license": "MIT" - }, "node_modules/@types/hast": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.5.tgz", @@ -5296,17 +4948,6 @@ "dev": true, "license": "ISC" }, - "node_modules/@upsetjs/venn.js": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@upsetjs/venn.js/-/venn.js-2.0.0.tgz", - "integrity": "sha512-WbBhLrooyePuQ1VZxrJjtLvTc4NVfpOyKx0sKqioq9bX1C1m7Jgykkn8gLrtwumBioXIqam8DLxp88Adbue6Hw==", - "dev": true, - "license": "MIT", - "optionalDependencies": { - "d3-selection": "^3.0.0", - "d3-transition": "^3.0.1" - } - }, "node_modules/@valibot/to-json-schema": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/@valibot/to-json-schema/-/to-json-schema-1.8.0.tgz", @@ -6162,16 +5803,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/commander": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", - "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10" - } - }, "node_modules/consola": { "version": "3.4.2", "resolved": "https://registry.npmjs.org/consola/-/consola-3.4.2.tgz", @@ -6265,16 +5896,6 @@ "node": ">= 0.4.0" } }, - "node_modules/cose-base": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/cose-base/-/cose-base-1.0.3.tgz", - "integrity": "sha512-s9whTXInMSgAp/NVXVNuVxVKzGH2qck3aQlVHxDCdAEPgtMKwc4Wq6/QKhgdEdgbLSi9rBTAcPoRa6JpiG4ksg==", - "dev": true, - "license": "MIT", - "dependencies": { - "layout-base": "^1.0.0" - } - }, "node_modules/crelt": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.7.tgz", @@ -6325,568 +5946,6 @@ "license": "MIT", "peer": true }, - "node_modules/cytoscape": { - "version": "3.34.4", - "resolved": "https://registry.npmjs.org/cytoscape/-/cytoscape-3.34.4.tgz", - "integrity": "sha512-msY99tMY8iWTg+sIPGfSqDcPNOt4xcj+v/K/7qUFaCUxxlqnMkUYLBjRUzn9W5CU/R2hrmtJa5+UtovrEM2ctg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10" - } - }, - "node_modules/cytoscape-cose-bilkent": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/cytoscape-cose-bilkent/-/cytoscape-cose-bilkent-4.1.0.tgz", - "integrity": "sha512-wgQlVIUJF13Quxiv5e1gstZ08rnZj2XaLHGoFMYXz7SkNfCDOOteKBE6SYRfA9WxxI/iBc3ajfDoc6hb/MRAHQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "cose-base": "^1.0.0" - }, - "peerDependencies": { - "cytoscape": "^3.2.0" - } - }, - "node_modules/cytoscape-fcose": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cytoscape-fcose/-/cytoscape-fcose-2.2.0.tgz", - "integrity": "sha512-ki1/VuRIHFCzxWNrsshHYPs6L7TvLu3DL+TyIGEsRcvVERmxokbf5Gdk7mFxZnTdiGtnA4cfSmjZJMviqSuZrQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "cose-base": "^2.2.0" - }, - "peerDependencies": { - "cytoscape": "^3.2.0" - } - }, - "node_modules/cytoscape-fcose/node_modules/cose-base": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cose-base/-/cose-base-2.2.0.tgz", - "integrity": "sha512-AzlgcsCbUMymkADOJtQm3wO9S3ltPfYOFD5033keQn9NJzIbtnZj+UdBJe7DYml/8TdbtHJW3j58SOnKhWY/5g==", - "dev": true, - "license": "MIT", - "dependencies": { - "layout-base": "^2.0.0" - } - }, - "node_modules/cytoscape-fcose/node_modules/layout-base": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/layout-base/-/layout-base-2.0.1.tgz", - "integrity": "sha512-dp3s92+uNI1hWIpPGH3jK2kxE2lMjdXdr+DH8ynZHpd6PUlH6x6cbuXnoMmiNumznqaNO31xu9e79F0uuZ0JFg==", - "dev": true, - "license": "MIT" - }, - "node_modules/d3": { - "version": "7.9.2", - "resolved": "https://registry.npmjs.org/d3/-/d3-7.9.2.tgz", - "integrity": "sha512-ZKb/mONPVKzaO5UlcWcwN8bS4ezvQaYu+bsou+XgNABdGC800kwH651ADTbbTxMPHW13UlvbQafdmJQDk1w7Mg==", - "dev": true, - "license": "ISC", - "dependencies": { - "d3-array": "^3.2.5", - "d3-axis": "^3.0.1", - "d3-brush": "^3.0.1", - "d3-chord": "^3.0.2", - "d3-color": "^3.1.1", - "d3-contour": "^4.0.3", - "d3-delaunay": "^6.0.6", - "d3-dispatch": "^3.0.2", - "d3-drag": "^3.0.1", - "d3-dsv": "^3.0.2", - "d3-ease": "^3.0.2", - "d3-fetch": "^3.0.2", - "d3-force": "^3.0.1", - "d3-format": "^3.1.3", - "d3-geo": "^3.1.2", - "d3-hierarchy": "^3.1.3", - "d3-interpolate": "^3.0.2", - "d3-path": "^3.1.1", - "d3-polygon": "^3.0.2", - "d3-quadtree": "^3.0.2", - "d3-random": "^3.0.2", - "d3-scale": "^4.0.3", - "d3-scale-chromatic": "^3.1.1", - "d3-selection": "^3.0.1", - "d3-shape": "^3.2.1", - "d3-time": "^3.1.1", - "d3-time-format": "^4.1.1", - "d3-timer": "^3.0.2", - "d3-transition": "^3.0.2", - "d3-zoom": "^3.0.1" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-array": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.5.tgz", - "integrity": "sha512-Th8qGXoBalmWsstpkuhmBuTsBQIFqYOJtjlBvNVvBfJ8E3uYusBUwUR8HU20U0qKKQkgCvKyR1YjiozWadk5QA==", - "dev": true, - "license": "ISC", - "dependencies": { - "internmap": "1 - 2" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-axis": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/d3-axis/-/d3-axis-3.0.1.tgz", - "integrity": "sha512-E5QCXfaf/uJZEHHiqoWRq+bQEm2PzoVFv2rDC7CZ3wwI0MjfMW3w83J3ubobG4IJj3lShAI5eiPJhOu/8wHofA==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-brush": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/d3-brush/-/d3-brush-3.0.1.tgz", - "integrity": "sha512-L5Glqa/Gb7LU3ndIOMtA5mDzlJ0aXKp5ELP2X09ctWF23jO7+faIUVDbmaIi+D6k3EemXFWn1F3lkfguExoVhA==", - "dev": true, - "license": "ISC", - "dependencies": { - "d3-dispatch": "1 - 3", - "d3-drag": "2 - 3", - "d3-interpolate": "1 - 3", - "d3-selection": "3", - "d3-transition": "3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-chord": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/d3-chord/-/d3-chord-3.0.2.tgz", - "integrity": "sha512-cGmADo5M2PTi3ewJZ2lcE32eURd4JmHtQ5JwRIUcas5L1SXqufG9yPyjWp8fW0gRi7aZi9bgbZPFZO1eyZ+1CQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "d3-path": "1 - 3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-color": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/d3-color/-/d3-color-3.1.1.tgz", - "integrity": "sha512-lfab8x0Bj0UO7SNsY8dZSbNIA6ipbkE3X0NG9nqjCu6CfCHZseuDnOSJY7hidKrjpP++i1M2qT+FlAdPKYRilA==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-contour": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/d3-contour/-/d3-contour-4.0.3.tgz", - "integrity": "sha512-5DYURc8KwXPOhSUBblU0P9rVcArsSPxPOxsfO0Eud0s28oU0sB2e80aRHRL9AZW3usT8ikFKyIHpHHLNWLdRVA==", - "dev": true, - "license": "ISC", - "dependencies": { - "d3-array": "^3.2.4" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-delaunay": { - "version": "6.0.6", - "resolved": "https://registry.npmjs.org/d3-delaunay/-/d3-delaunay-6.0.6.tgz", - "integrity": "sha512-DMQIEvSJhZCB6pwedcXaAlQ+MeKU5LlM2XakKtc73b/VM+RBiI1SRXycOEOKg2jsKj4zZ9F0KGYG6nCGwwWu/g==", - "dev": true, - "license": "ISC", - "dependencies": { - "delaunator": "5" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-dispatch": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/d3-dispatch/-/d3-dispatch-3.0.2.tgz", - "integrity": "sha512-sAzH4Y4nsLo8eSqw5jKiZt+LU2wZmL/qS+OkxQGjhwazB/D7TY34R/QK1eshfGr7cZEKymKZ/Haem7m+lu98Sg==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-drag": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/d3-drag/-/d3-drag-3.0.1.tgz", - "integrity": "sha512-OWeoayCq8J69hUIjvL+Mb6Q6Oaj/fyHV5XaXByEUAG+JUjIfTGDnk3qGpcXrD3VmQ3BSV96fcbM6fqq7C0tbPA==", - "dev": true, - "license": "ISC", - "dependencies": { - "d3-dispatch": "1 - 3", - "d3-selection": "3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-dsv": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/d3-dsv/-/d3-dsv-3.0.2.tgz", - "integrity": "sha512-FUnXhX7I4/AXyRCZzwfZTDGSq8PGZ4oR0tiCBqNGOZMsDrQ+6sIWNQnBzcCGhzJKZ6uCvCezTwflUqI209RRiQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "commander": "7", - "iconv-lite": "0.6", - "rw": "1" - }, - "bin": { - "csv2json": "bin/dsv2json.js", - "csv2tsv": "bin/dsv2dsv.js", - "dsv2dsv": "bin/dsv2dsv.js", - "dsv2json": "bin/dsv2json.js", - "json2csv": "bin/json2dsv.js", - "json2dsv": "bin/json2dsv.js", - "json2tsv": "bin/json2dsv.js", - "tsv2csv": "bin/dsv2dsv.js", - "tsv2json": "bin/dsv2json.js" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-dsv/node_modules/iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "dev": true, - "license": "MIT", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/d3-ease": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-3.0.2.tgz", - "integrity": "sha512-B5znKqRmKROAN4oHWQ50W/qisVjA9GXh2WMsVKdFVp4DxWmcrOsweqgUOUVsv5th96kwaZlokU6SlV4J3gak1w==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-fetch": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/d3-fetch/-/d3-fetch-3.0.2.tgz", - "integrity": "sha512-1wGF62bgjMRbF6mqbD+6rRWBL2hwWVYQjFO2UP3Wm1nIAvJZKaQxXM5caVY7athoCa8wIq9lCf7g44lPWFk50g==", - "dev": true, - "license": "ISC", - "dependencies": { - "d3-dsv": "1 - 3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-force": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/d3-force/-/d3-force-3.0.1.tgz", - "integrity": "sha512-kAaaHLFebBYwgi5cYBXAI8vKrQFMCD2MEswj2QuPKKbdU1wYLc8WXtS7O8F/b6POCIe3gJjY6hkDstHi1yMETQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "d3-dispatch": "1 - 3", - "d3-quadtree": "1 - 3", - "d3-timer": "1 - 3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-format": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/d3-format/-/d3-format-3.1.3.tgz", - "integrity": "sha512-+F+/49swqmGuQJmSKnVMIDH/QkEFV5li9QRj0xm/KhyAUBv099O5PrvpQFxBp24PYph17Mnvt9mjKQV0ii0nMA==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-geo": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/d3-geo/-/d3-geo-3.1.2.tgz", - "integrity": "sha512-5R8ZgDQorIxmauv7R6gpE/ndz+Z0qAZssigq0aXFdvPHdY41RqtW02jrRUQAL724NdPABYXo1+gQEGBBr7uKNg==", - "dev": true, - "license": "ISC", - "dependencies": { - "d3-array": "2.5.0 - 3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-hierarchy": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/d3-hierarchy/-/d3-hierarchy-3.1.3.tgz", - "integrity": "sha512-GRajN5ZcnEwYFWqqdzhG1qJ3+fDg6WWzk47TJg7ePY7yvYAgRfD2r1mUx+wviBOWuCwamCUzjwMSdato43jbGA==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-interpolate": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-3.0.2.tgz", - "integrity": "sha512-IRzGU62DtxhvsnSTWMQIdnoZ6gA+BCWwBon1EJI6SjoN595799b6z/QRBzXfFhE8iupUPp3042yBNo0STPqnzQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "d3-color": "1 - 3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-path": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-3.1.1.tgz", - "integrity": "sha512-jsbgV8zIT38ReB9O7X7gcLndTQRONSqNNd+oGIaTBdUug4r5jFmp0N6RY9R5GWbdUDucn0qoTGyfjapT4tDhcg==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-polygon": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/d3-polygon/-/d3-polygon-3.0.2.tgz", - "integrity": "sha512-WAUvPudGU1Dn4mDPfb6+JnnbeVEV53hG/BoT+bxts6AkZsOpTEiV1jHYX+2vtwCICNFG9Wxv8QS+eW1zE/Dwfg==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-quadtree": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/d3-quadtree/-/d3-quadtree-3.0.2.tgz", - "integrity": "sha512-9Lu9mqJKRbIk0d6mKDjpvPURaPdwHVK5CYbcdd0/4vBgz4ldz/7TIOse3kNERsByGNfld58KEco507AztJWyTQ==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-random": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/d3-random/-/d3-random-3.0.2.tgz", - "integrity": "sha512-PxJi9LNV+7mulaYO77nd+oGurXGL1fhedXjHnB3pWLUcqDnQtF4VASoqnQGHgoXLByVdv5QJ/2kfwkGn5HTS8g==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-sankey": { - "version": "0.12.3", - "resolved": "https://registry.npmjs.org/d3-sankey/-/d3-sankey-0.12.3.tgz", - "integrity": "sha512-nQhsBRmM19Ax5xEIPLMY9ZmJ/cDvd1BG3UVvt5h3WRxKg5zGRbvnteTyWAbzeSvlh3tW7ZEmq4VwR5mB3tutmQ==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "d3-array": "1 - 2", - "d3-shape": "^1.2.0" - } - }, - "node_modules/d3-sankey/node_modules/d3-array": { - "version": "2.12.1", - "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-2.12.1.tgz", - "integrity": "sha512-B0ErZK/66mHtEsR1TkPEEkwdy+WDesimkM5gpZr5Dsg54BiTA5RXtYW5qTLIAcekaS9xfZrzBLF/OAkB3Qn1YQ==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "internmap": "^1.0.0" - } - }, - "node_modules/d3-sankey/node_modules/d3-path": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-1.0.9.tgz", - "integrity": "sha512-VLaYcn81dtHVTjEHd8B+pbe9yHWpXKZUC87PzoFmsFrJqgFwDe/qxfp5MlfsfM1V5E/iVt0MmEbWQ7FVIXh/bg==", - "dev": true, - "license": "BSD-3-Clause" - }, - "node_modules/d3-sankey/node_modules/d3-shape": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-1.3.7.tgz", - "integrity": "sha512-EUkvKjqPFUAZyOlhY5gzCxCeI0Aep04LwIRpsZ/mLFelJiUfnK56jo5JMDSE7yyP2kLSb6LtF+S5chMk7uqPqw==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "d3-path": "1" - } - }, - "node_modules/d3-sankey/node_modules/internmap": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/internmap/-/internmap-1.0.1.tgz", - "integrity": "sha512-lDB5YccMydFBtasVtxnZ3MRBHuaoE8GKsppq+EchKL2U4nK/DmEpPHNH8MZe5HkMtpSiTSOZwfN0tzYjO/lJEw==", - "dev": true, - "license": "ISC" - }, - "node_modules/d3-scale": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-4.0.3.tgz", - "integrity": "sha512-66cWobCNzcMvlfoaDHCxuIv9TBUWG1BLOWdv9kHHFuCr1JdqAWPvTmsaEYDD5NRMyWZ5+7u0GqiCDfMXMqh3hg==", - "dev": true, - "license": "ISC", - "dependencies": { - "d3-array": "2.10.0 - 3", - "d3-format": "1 - 3", - "d3-interpolate": "1.2.0 - 3", - "d3-time": "2.1.1 - 3", - "d3-time-format": "2 - 4" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-scale-chromatic": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/d3-scale-chromatic/-/d3-scale-chromatic-3.1.1.tgz", - "integrity": "sha512-lA5gfN2yMvmChubmptnDiBfeGpHD7Yb1EbvCz0TZE0WHXhyR6W2allPuhKtzV5ILQRqeOdefF0qYtERReLUBDg==", - "dev": true, - "license": "ISC", - "dependencies": { - "d3-color": "1 - 3", - "d3-interpolate": "1 - 3", - "d3-scale": "1 - 4" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-selection": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.1.tgz", - "integrity": "sha512-ODSf35vqCrlCfp7hrm0eZjvOosSXSYLjqvIlhMBV9q9VOx7EBJG6pc+uXBswEZNJgCGJ+qnKYcWutbZDIxe/Xg==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-shape": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-3.2.1.tgz", - "integrity": "sha512-dm2o+lbKdzg9tY7GEag/dB9hcbodLfwkE/DkvqbELJXaMz0yKzWWhZqhbI7CKubukA7HnRyz0avdtvi7EPxPvw==", - "dev": true, - "license": "ISC", - "dependencies": { - "d3-path": "^3.1.1" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-time": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/d3-time/-/d3-time-3.1.1.tgz", - "integrity": "sha512-Ze7rjrhMzdeulh0/hjcfFj7XLAHOfowtEMfsoG6DU866HPynQNW7Wfen6hzXcqKTv8XzxvF6Hzr5XD6bMHr2ug==", - "dev": true, - "license": "ISC", - "dependencies": { - "d3-array": "2 - 3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-time-format": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-4.1.1.tgz", - "integrity": "sha512-22XaqjyCjpqgda20erhsOjGmC3vvYwTNYniKAd45W5UWLDF43moeOuV9qYpRqobIlsnK0UhnKZjUUJm3VgORUA==", - "dev": true, - "license": "ISC", - "dependencies": { - "d3-time": "1 - 3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-timer": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-3.0.2.tgz", - "integrity": "sha512-1Il1aliroVSErrv5aulRBxAY+7+DnaoLIWGd1C6SsBTWDeobWiP/V69vwb8vT6abR1kKwaNe1196pmaQ1fK90A==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=12" - } - }, - "node_modules/d3-transition": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/d3-transition/-/d3-transition-3.0.2.tgz", - "integrity": "sha512-RcjCsdFgyFoDB+QXLC5m60ZkTN0k9zH+ovoLlTdJnDS1AbfbcuowiM4pCKSTOclNibS4f4J4cbv2m7O7y8NTOQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "d3-color": "1 - 3", - "d3-dispatch": "1 - 3", - "d3-ease": "1 - 3", - "d3-interpolate": "1 - 3", - "d3-timer": "1 - 3" - }, - "engines": { - "node": ">=12" - }, - "peerDependencies": { - "d3-selection": "2 - 3" - } - }, - "node_modules/d3-zoom": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/d3-zoom/-/d3-zoom-3.0.1.tgz", - "integrity": "sha512-kfjD3BDQu/FOatpZ6JdMSyIoDwTxIpI29ySTI2J5ZlDaH1WbuJGQJ2Q9oJkWTEZEW98j6idezoomSD3Cn2zwiw==", - "dev": true, - "license": "ISC", - "dependencies": { - "d3-dispatch": "1 - 3", - "d3-drag": "2 - 3", - "d3-interpolate": "1 - 3", - "d3-selection": "2 - 3", - "d3-transition": "2 - 3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/dagre-d3-es": { - "version": "7.0.14", - "resolved": "https://registry.npmjs.org/dagre-d3-es/-/dagre-d3-es-7.0.14.tgz", - "integrity": "sha512-P4rFMVq9ESWqmOgK+dlXvOtLwYg0i7u0HBGJER0LZDJT2VHIPAMZ/riPxqJceWMStH5+E61QxFra9kIS3AqdMg==", - "dev": true, - "license": "MIT", - "dependencies": { - "d3": "^7.9.0", - "lodash-es": "^4.17.21" - } - }, - "node_modules/dayjs": { - "version": "1.11.23", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.23.tgz", - "integrity": "sha512-QDTCU0M0MxR3hQfnlDJfwekQiaanm1ubOD231u73WBckQ/fsamwRLiE2GBz6D3a/xF1NgfiDLJjXBa1hYOYTtQ==", - "dev": true, - "license": "MIT" - }, "node_modules/debug": { "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", @@ -7047,16 +6106,6 @@ "dev": true, "license": "MIT" }, - "node_modules/delaunator": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/delaunator/-/delaunator-5.1.0.tgz", - "integrity": "sha512-AGrQ4QSgssa1NGmWmLPqN5NY2KajF5MqxetNEO+o0n3ZwZZeTmt7bBnvzHWrmkZFxGgr4HdyFgelzgi06otLuQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "robust-predicates": "^3.0.2" - } - }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -7848,16 +6897,6 @@ ], "license": "BSD-3-Clause" }, - "node_modules/fastdom": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/fastdom/-/fastdom-1.0.12.tgz", - "integrity": "sha512-LB+xjSTEbjHE1cWsxu+tN2Xqr1kpi+V9aADI7sVM5ZMaXyYGPHULQMzpJMYqOTULK/73pUkWVzzObFRBkPr+hg==", - "dev": true, - "license": "MIT", - "dependencies": { - "strictdom": "^1.0.1" - } - }, "node_modules/fdir": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", @@ -8102,13 +7141,6 @@ "dev": true, "license": "ISC" }, - "node_modules/hachure-fill": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/hachure-fill/-/hachure-fill-0.5.2.tgz", - "integrity": "sha512-3GKBOn+m2LX9iq+JC1064cSFprJY4jL1jCXTcpnfER5HYE2l/4EfWSGzkPa/ZDBmYI0ZOEj5VHV/eKnPGkHuOg==", - "dev": true, - "license": "MIT" - }, "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -8519,17 +7551,6 @@ "dev": true, "license": "MIT" }, - "node_modules/import-meta-resolve": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-4.2.0.tgz", - "integrity": "sha512-Iqv2fzaTQN28s/FwZAoFq0ZSs/7hMAHJVX+w8PZl3cY19Pxk6jFFalxQoIfW2826i/fDLXv8IiEZRIT0lDuWcg==", - "dev": true, - "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -8564,16 +7585,6 @@ "dev": true, "license": "MIT" }, - "node_modules/internmap": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz", - "integrity": "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=12" - } - }, "node_modules/ip-address": { "version": "10.7.6", "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.6.tgz", @@ -8856,12 +7867,6 @@ "@keyv/serialize": "^1.1.1" } }, - "node_modules/khroma": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/khroma/-/khroma-2.1.0.tgz", - "integrity": "sha512-Ls993zuzfayK269Svk9hzpeGUKob/sIgZzyHYdjQoAdQetRKpOLj+k/QQQ/6Qi0Yz65mlROrfd+Ev+1+7dz9Kw==", - "dev": true - }, "node_modules/known-css-properties": { "version": "0.37.0", "resolved": "https://registry.npmjs.org/known-css-properties/-/known-css-properties-0.37.0.tgz", @@ -8869,13 +7874,6 @@ "dev": true, "license": "MIT" }, - "node_modules/layout-base": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/layout-base/-/layout-base-1.0.2.tgz", - "integrity": "sha512-8h2oVEZNktL4BH2JCOI90iD1yXwL6iNW7KcCKT2QZgQJR2vbqDsldCTPRU9NifTCqHZci57XvQQ15YTu+sTYPg==", - "dev": true, - "license": "MIT" - }, "node_modules/levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", @@ -9196,13 +8194,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/lodash-es": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.18.1.tgz", - "integrity": "sha512-J8xewKD/Gk22OZbhpOVSwcs60zhd95ESDwezOFuA3/099925PdHJ7OFHNTGtajL3AlZkykD32HykiMo+BIBI8A==", - "dev": true, - "license": "MIT" - }, "node_modules/longest-streak": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-3.1.0.tgz", @@ -9296,19 +8287,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/marked": { - "version": "16.4.2", - "resolved": "https://registry.npmjs.org/marked/-/marked-16.4.2.tgz", - "integrity": "sha512-TI3V8YYWvkVf3KJe1dRkpnjs68JUPyEa5vjKrp1XEEJUAOaQc+Qj+L1qWbPd0SJuAdQkFU0h73sXXqwDYxsiDA==", - "dev": true, - "license": "MIT", - "bin": { - "marked": "bin/marked.js" - }, - "engines": { - "node": ">= 20" - } - }, "node_modules/math-intrinsics": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", @@ -9687,37 +8665,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/mermaid": { - "version": "11.17.2", - "resolved": "https://registry.npmjs.org/mermaid/-/mermaid-11.17.2.tgz", - "integrity": "sha512-V6K3C8EBdEsPFZXSKMJe6ppQOENxuHARr9GvHX4hh47lAbhMRD9qf4oEK7LoaRQxULMa80/qt5gHO73aCleBBg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@braintree/sanitize-url": "^7.1.2", - "@iconify/utils": "^3.0.2", - "@mermaid-js/parser": "^1.2.1", - "@types/d3": "^7.4.3", - "@upsetjs/venn.js": "^2.0.0", - "cytoscape": "^3.34.0", - "cytoscape-cose-bilkent": "^4.1.0", - "cytoscape-fcose": "^2.2.0", - "d3": "^7.9.0", - "d3-sankey": "^0.12.3", - "dagre-d3-es": "7.0.14", - "dayjs": "^1.11.21", - "dompurify": "^3.3.3", - "es-toolkit": "^1.45.1", - "fastdom": "1.0.12", - "katex": "^0.16.47", - "khroma": "^2.1.0", - "marked": "^16.3.0", - "roughjs": "^4.6.6", - "stylis": "^4.3.6", - "ts-dedent": "^2.2.0", - "uuid": "^11.1.0 || ^12 || ^13 || ^14.0.0" - } - }, "node_modules/micromark": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.3.tgz", @@ -10803,13 +9750,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/package-manager-detector": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/package-manager-detector/-/package-manager-detector-1.9.0.tgz", - "integrity": "sha512-zAMfbta9nPA8AKkA4WdmNAT8R8s6Dk0/xwPsqNnRidMFcLo1YkLuPDTgs2f64XdzS8vbLNnoJ+uUIkgbz7oRHA==", - "dev": true, - "license": "MIT" - }, "node_modules/parse5": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.1.1.tgz", @@ -10833,13 +9773,6 @@ "node": ">= 0.8" } }, - "node_modules/path-data-parser": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/path-data-parser/-/path-data-parser-0.1.0.tgz", - "integrity": "sha512-NOnmBpt5Y2RWbuv0LMzsayp3lVylAHLPUTut412ZA3l+C4uw4ZVkQbjShYCQ8TCpUMdPapr4YjUqLYD6v68j+w==", - "dev": true, - "license": "MIT" - }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -10901,6 +9834,16 @@ "@napi-rs/canvas": "^0.1.74" } }, + "node_modules/pele": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/pele/-/pele-1.13.0.tgz", + "integrity": "sha512-Ie8UKY9x00MsuR3jO6AzUwzK2Z6MIV3Tf4EDdITiuk8Uaz8K7g0R082WqsqNaSU8DdgkrRvZThzhit83mi/uiw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + } + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -10973,24 +9916,6 @@ "node": ">=14.19.0" } }, - "node_modules/points-on-curve": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/points-on-curve/-/points-on-curve-0.2.0.tgz", - "integrity": "sha512-0mYKnYYe9ZcqMCWhUjItv/oHjvgEsfKvnUTg8sAtnHr3GVy7rGkXCb6d5cSyqrWqL4k81b9CPg3urd+T7aop3A==", - "dev": true, - "license": "MIT" - }, - "node_modules/points-on-path": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/points-on-path/-/points-on-path-0.2.1.tgz", - "integrity": "sha512-25ClnWWuw7JbWZcgqY/gJ4FQWadKxGWk+3kR/7kD0tCaDtPPMj7oHu2ToLaVhfpnHrZzYby2w6tUA0eOIuUg8g==", - "dev": true, - "license": "MIT", - "dependencies": { - "path-data-parser": "0.1.0", - "points-on-curve": "0.2.0" - } - }, "node_modules/portfinder": { "version": "1.0.38", "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.38.tgz", @@ -11713,13 +10638,6 @@ "dev": true, "license": "MIT" }, - "node_modules/robust-predicates": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.3.tgz", - "integrity": "sha512-NS3levdsRIUOmiJ8FZWCP7LG3QpJyrs/TE0Zpf1yvZu8cAJJ6QMW92H1c7kWpdIHo8RvmLxN/o2JXTKHp74lUA==", - "dev": true, - "license": "Unlicense" - }, "node_modules/rolldown": { "version": "1.2.18", "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.18.tgz", @@ -11764,19 +10682,6 @@ "url": "https://github.com/sponsors/oxc-project" } }, - "node_modules/roughjs": { - "version": "4.6.6", - "resolved": "https://registry.npmjs.org/roughjs/-/roughjs-4.6.6.tgz", - "integrity": "sha512-ZUz/69+SYpFN/g/lUlo2FXcIjRkSu3nDarreVdGGndHEBJ6cXPdKguS8JGxwj5HA5xIbVKSmLgr5b3AWxtRfvQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "hachure-fill": "^0.5.2", - "path-data-parser": "^0.1.0", - "points-on-curve": "^0.2.0", - "points-on-path": "^0.2.1" - } - }, "node_modules/router": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", @@ -11823,13 +10728,6 @@ "svelte": "^5.7.0" } }, - "node_modules/rw": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/rw/-/rw-1.3.3.tgz", - "integrity": "sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ==", - "dev": true, - "license": "BSD-3-Clause" - }, "node_modules/sade": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz", @@ -12273,13 +11171,6 @@ "url": "https://opencollective.com/vitest" } }, - "node_modules/strictdom": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/strictdom/-/strictdom-1.0.1.tgz", - "integrity": "sha512-cEmp9QeXXRmjj/rVp9oyiqcvyocWab/HaoN4+bwFeZ7QzykJD6L3yD4v12K1x0tHpqRqVpJevN3gW7kyM39Bqg==", - "dev": true, - "license": "MIT" - }, "node_modules/stringify-entities": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.4.tgz", @@ -12354,13 +11245,6 @@ "inline-style-parser": "0.2.7" } }, - "node_modules/stylis": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.4.0.tgz", - "integrity": "sha512-5Z9ZpRzfuH6l/UAvCPAPUo3665Nk2wLaZU3x+TLHKVzIz33+sbJqbtrYoC3KD4/uVOr2Zp+L0LySezP9OHV9yA==", - "dev": true, - "license": "MIT" - }, "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", diff --git a/ui/apps/chat/package.json b/ui/apps/chat/package.json index b7716287c..bc3f0d331 100644 --- a/ui/apps/chat/package.json +++ b/ui/apps/chat/package.json @@ -110,8 +110,8 @@ "dompurify": "3.4.17", "eslint": "10.14.0", "eslint-config-prettier": "10.1.8", - "eslint-plugin-perfectionist": "^5.10.1", - "eslint-plugin-simple-import-sort": "^14.0.0", + "eslint-plugin-perfectionist": "5.13.0", + "eslint-plugin-simple-import-sort": "14.0.0", "eslint-plugin-storybook": "10.6.6", "eslint-plugin-svelte": "3.24.1", "fflate": "0.8.3", @@ -120,9 +120,9 @@ "http-server": "14.1.1", "@ggml-org/llama-brand": "0.1.0", "mdsvex": "0.12.7", - "mermaid": "11.17.2", "mode-watcher": "1.1.0", "pdfjs-dist": "5.4.54", + "pele": "1.13.0", "playwright": "1.56.1", "prettier": "3.8.3", "prettier-plugin-svelte": "4.1.0", diff --git a/ui/apps/chat/scripts/vite-plugin-nerdamer.ts b/ui/apps/chat/scripts/vite-plugin-nerdamer.ts index 84e463c6d..c1551eb5a 100644 --- a/ui/apps/chat/scripts/vite-plugin-nerdamer.ts +++ b/ui/apps/chat/scripts/vite-plugin-nerdamer.ts @@ -10,7 +10,9 @@ const RESOLVED_ID = '\0' + VIRTUAL_ID; /** * Bundle the vendored nerdamer-prime source into a minified IIFE string, - * exposed as the `virtual:nerdamer` module. Flags mirror the upstream + * loaded through the `virtual:nerdamer` module. In the client build it is + * its own file, fetched on first use, so it stays out of the app bundle. + * Flags mirror the upstream * build (esbuild --bundle --minify --format=iife --global-name=nerdamer), * so only human readable source lives in the repo and minification is a * build artifact. Vendored under src/lib/vendors/, upstream snapshot: @@ -41,7 +43,13 @@ export function nerdamerPlugin(): Plugin { bundled = result.outputFiles[0].text; } - return `export default ${JSON.stringify(bundled)};`; + if (this.environment.mode === 'build' && this.environment.name === 'client') { + const ref = this.emitFile({ name: 'nerdamer.js', source: bundled, type: 'asset' }); + + return `export default () => fetch(import.meta.ROLLUP_FILE_URL_${ref}).then((res) => res.text());`; + } + + return `export default async () => ${JSON.stringify(bundled)};`; }, name: 'llamacpp:nerdamer', resolveId(id) { diff --git a/ui/apps/chat/src/app.css b/ui/apps/chat/src/app.css index 4c7fd9016..cca440844 100644 --- a/ui/apps/chat/src/app.css +++ b/ui/apps/chat/src/app.css @@ -356,8 +356,22 @@ } } -.mermaidTooltip { - display: none !important; +/* + * Mermaid diagrams are drawn by Pele, which reads its colors from these. They sit on :root + * so the svg also inherits them inside the preview dialog's shadow root, and follow the theme. + */ +:root { + --pele-bg: var(--code-background); + --pele-fg: var(--code-foreground); + --pele-muted: var(--muted-foreground); + --pele-line: var(--muted-foreground); + --pele-surface: var(--background); + --pele-surface-alt: var(--muted); + --pele-border: var(--border); + --pele-accent: var(--primary); + --pele-critical: var(--destructive); + --pele-error: var(--destructive); + --pele-radius: calc(var(--radius) - 4px); } /* diff --git a/ui/apps/chat/src/lib/components/app/content/MarkdownContent/MarkdownContent.svelte b/ui/apps/chat/src/lib/components/app/content/MarkdownContent/MarkdownContent.svelte index ab3c5ffec..0edd8cbcd 100644 --- a/ui/apps/chat/src/lib/components/app/content/MarkdownContent/MarkdownContent.svelte +++ b/ui/apps/chat/src/lib/components/app/content/MarkdownContent/MarkdownContent.svelte @@ -625,7 +625,7 @@ if ((hasRenderedBlocks || hasUnstableBlock) && containerRef) { setupCodeBlockActions(); setupImageErrorHandlers(); - renderMermaidDiagrams(containerRef, mode.current === ColorMode.DARK); + renderMermaidDiagrams(containerRef); renderSvgDiagrams(containerRef); } }); diff --git a/ui/apps/chat/src/lib/components/app/content/MarkdownContent/markdown-content.css b/ui/apps/chat/src/lib/components/app/content/MarkdownContent/markdown-content.css index 49aee0e04..49e04bf0c 100644 --- a/ui/apps/chat/src/lib/components/app/content/MarkdownContent/markdown-content.css +++ b/ui/apps/chat/src/lib/components/app/content/MarkdownContent/markdown-content.css @@ -626,10 +626,24 @@ div.markdown-user-content :global(.table-wrapper) { /* Hide mermaid code text until rendered - prevents flash */ .markdown-content :global(pre.mermaid:not([data-mermaid-rendered])), -.markdown-content :global(pre.mermaid[data-mermaid-rendered]:not(:has(svg))) { +.markdown-content :global(pre.mermaid[data-mermaid-rendered]:not(:has(svg, .mermaid-error))) { display: none; } +/* A diagram Pele can't draw shows why, with the line it stopped at */ +.markdown-content :global(.mermaid-error) { + max-width: 100%; + padding: 1rem; + color: var(--destructive); + font-family: var(--font-mono); + font-size: 0.8125rem; + /* the caret line under the source must line up character by character */ + font-variant-ligatures: none; + text-align: left; + white-space: pre-wrap; + cursor: default; +} + /* Hide svg source until rendered - prevents flash. A rendered-but-unsanitized block (oversized source) keeps its raw text visible as a safe fallback. */ .markdown-content :global(pre.svg-block:not([data-svg-rendered])) { diff --git a/ui/apps/chat/src/lib/components/app/content/MarkdownContent/markdown-diagrams.ts b/ui/apps/chat/src/lib/components/app/content/MarkdownContent/markdown-diagrams.ts index 4bb7e44b3..ba607bfbc 100644 --- a/ui/apps/chat/src/lib/components/app/content/MarkdownContent/markdown-diagrams.ts +++ b/ui/apps/chat/src/lib/components/app/content/MarkdownContent/markdown-diagrams.ts @@ -7,9 +7,15 @@ import { DIAGRAM_VIEW_RENDERED, DIAGRAM_VIEW_SOURCE, MERMAID_BLOCK_CLASS, + MERMAID_ERROR_CLASS, + MERMAID_ID_ATTR, MERMAID_RENDERED_ATTR, + MERMAID_SCROLL_CONTAINER_CLASS, + MERMAID_SVG_PADDING_X_REM, MERMAID_SYNTAX_ATTR, MERMAID_WRAPPER_CLASS, + PELE_SVG_CLASS, + PELE_THEME_VARIABLES, SVG, TOGGLE_SOURCE_BTN_CLASS } from '#lib/constants/index.ts'; @@ -19,11 +25,30 @@ import { mountSvgShadow } from '#lib/utils/svg-shadow.ts'; export type DiagramAction = { copy: string } | { previewSvg: string }; +// The width a diagram can take in its block: the scroll container's content box, less the +// svg's own horizontal padding. Undefined when the block isn't laid out (detached, hidden). +function diagramWidth(node: HTMLElement): number | undefined { + const scroll = node.closest(`.${MERMAID_SCROLL_CONTAINER_CLASS}`); + + if (!scroll?.clientWidth) return undefined; + + const box = getComputedStyle(scroll); + const rem = parseFloat(getComputedStyle(document.documentElement).fontSize); + const width = + scroll.clientWidth - + parseFloat(box.paddingLeft) - + parseFloat(box.paddingRight) - + MERMAID_SVG_PADDING_X_REM * rem; + + return width > 0 ? width : undefined; +} + /** - * Renders the mermaid diagrams in `container` that haven't been rendered yet. - * Marks nodes immediately to prevent duplicate renders during streaming. + * Renders the mermaid diagrams in `container` that haven't been rendered yet, with Pele. + * Marks nodes immediately to prevent duplicate renders during streaming. Colors come + * from the `--pele-*` variables in app.css, so a diagram follows the theme without a redraw. */ -export async function renderMermaidDiagrams(container: HTMLElement, isDark: boolean) { +export async function renderMermaidDiagrams(container: HTMLElement) { const nodes = container.querySelectorAll( `pre.${MERMAID_BLOCK_CLASS}:not([${MERMAID_RENDERED_ATTR}])` ); @@ -34,32 +59,56 @@ export async function renderMermaidDiagrams(container: HTMLElement, isDark: bool // This avoids needing a guard that would block node discovery. nodes.forEach((node) => node.setAttribute(MERMAID_RENDERED_ATTR, BooleanString.TRUE)); - // lazy load the mermaid dependecy only when needed to reduce bundle size. - const { default: mermaid } = await import('mermaid'); + const { render } = await import('pele'); - mermaid.initialize({ - flowchart: { - htmlLabels: true, - useMaxWidth: false - }, - gantt: { - useMaxWidth: false - }, - securityLevel: 'strict', - sequence: { - useMaxWidth: false - }, - startOnLoad: false, - theme: isDark ? 'dark' : 'default' - }); + // Pele measures labels with the font it is given, so wait until the page font is in + await document.fonts?.ready; - try { - await mermaid.run({ nodes: Array.from(nodes) as unknown as NodeListOf }); - } catch (error) { - console.error('Failed to render mermaid diagram:', error); + for (const node of nodes) { + const source = node.getAttribute(MERMAID_SYNTAX_ATTR) ?? node.textContent ?? ''; + const id = node.getAttribute(MERMAID_ID_ATTR); + + try { + const { svg } = render(source, { + fontFamily: getComputedStyle(node).fontFamily, + idPrefix: id ? id.replace(/[^\w-]/g, '_') : undefined, + // narrow blocks (phones) may turn a left-to-right diagram top-to-bottom + maxWidth: diagramWidth(node) + }); + + node.innerHTML = svg; + } catch (error) { + // the message quotes the diagram source, so it goes in as text + const message = document.createElement('div'); + + message.className = MERMAID_ERROR_CLASS; + message.textContent = error instanceof Error ? error.message : String(error); + node.replaceChildren(message); + } } } +/** + * A Pele diagram takes its colors from the page's `--pele-*` variables. Writes their current + * values into the svg, so a downloaded file keeps the colors it had on screen. Any other svg + * comes back unchanged. + */ +export function withThemeColors(svgHtml: string): string { + const svg = new DOMParser().parseFromString(svgHtml, 'image/svg+xml').documentElement; + + if (!(svg instanceof SVGElement) || !svg.classList.contains(PELE_SVG_CLASS)) return svgHtml; + + const theme = getComputedStyle(document.documentElement); + + for (const name of PELE_THEME_VARIABLES) { + const value = theme.getPropertyValue(name).trim(); + + if (value) svg.style.setProperty(name, value); + } + + return new XMLSerializer().serializeToString(svg); +} + /** * Renders the svg diagrams in `container` that haven't been rendered yet. * Sanitizes the source before injecting and marks each node so it renders once. diff --git a/ui/apps/chat/src/lib/components/app/content/MarkdownContent/markdown-processor.ts b/ui/apps/chat/src/lib/components/app/content/MarkdownContent/markdown-processor.ts index d7c4feac6..aed4b93e5 100644 --- a/ui/apps/chat/src/lib/components/app/content/MarkdownContent/markdown-processor.ts +++ b/ui/apps/chat/src/lib/components/app/content/MarkdownContent/markdown-processor.ts @@ -13,6 +13,7 @@ import { rehypeEnhanceMermaidBlocks } from './plugins/rehype/enhance-mermaid-blo import { rehypeEnhanceSvgBlocks } from './plugins/rehype/enhance-svg-blocks'; import { rehypeEnhanceTables } from './plugins/rehype/enhance-tables'; import { rehypeFileBadge } from './plugins/rehype/file-badge'; +import { rehypeLazyKatex } from './plugins/rehype/lazy-katex'; import { rehypeMermaidPre } from './plugins/rehype/mermaid-pre'; import { rehypeRtlSupport } from './plugins/rehype/rehype-rtl-support'; import { rehypeResolveAttachmentImages } from './plugins/rehype/resolve-attachment-images'; @@ -25,7 +26,6 @@ import type { Root as HastRoot } from 'hast'; import { all as lowlightAll } from 'lowlight'; import type { Root as MdastRoot } from 'mdast'; import rehypeHighlight from 'rehype-highlight'; -import rehypeKatex from 'rehype-katex'; import rehypeStringify from 'rehype-stringify'; import { remark } from 'remark'; import remarkBreaks from 'remark-breaks'; @@ -71,7 +71,7 @@ function buildPipeline({ proc = proc.use(remarkRehype, allowHtml ? { allowDangerousHtml: true } : undefined); if (!disableMath) { - proc = proc.use(rehypeKatex); // Render math using KaTeX + proc = proc.use(rehypeLazyKatex); // Render math using KaTeX, loaded on the first message with math } const pipeline = proc diff --git a/ui/apps/chat/src/lib/components/app/content/MarkdownContent/plugins/rehype/lazy-katex.ts b/ui/apps/chat/src/lib/components/app/content/MarkdownContent/plugins/rehype/lazy-katex.ts new file mode 100644 index 000000000..e94a36bf4 --- /dev/null +++ b/ui/apps/chat/src/lib/components/app/content/MarkdownContent/plugins/rehype/lazy-katex.ts @@ -0,0 +1,56 @@ +/** + * Rehype plugin that renders math with rehype-katex, loading KaTeX only when a message has math. + * + * remark-math marks math as elements with a `language-math`, `math-inline` or `math-display` + * class; a tree without one is left alone, so a chat without math never downloads KaTeX. + */ + +import type { Element, Root } from 'hast'; +import type { Plugin, Transformer } from 'unified'; +import { visit } from 'unist-util-visit'; + +const MATH_CLASSES = ['language-math', 'math-inline', 'math-display']; + +let katexLoading: Promise> | undefined; +let katexTransformer: Transformer | undefined; + +function hasMath(tree: Root): boolean { + let found = false; + + visit(tree, 'element', (node: Element) => { + const className = node.properties?.className; + + if (Array.isArray(className) && className.some((c) => MATH_CLASSES.includes(String(c)))) { + found = true; + + return false; + } + }); + + return found; +} + +// synchronous when there is no math or KaTeX has loaded, so only the first message with math +// waits for it, and every other one renders in the same pass as before +export const rehypeLazyKatex: Plugin<[], Root> = () => { + return (tree, file) => { + if (!hasMath(tree)) return; + + // rehype-katex changes the tree in place + if (katexTransformer) { + katexTransformer(tree, file, () => {}); + + return; + } + + katexLoading ??= import('rehype-katex').then(({ default: rehypeKatex }) => { + katexTransformer = rehypeKatex() as Transformer; + + return katexTransformer; + }); + + return katexLoading.then((transform) => { + transform(tree, file, () => {}); + }); + }; +}; diff --git a/ui/apps/chat/src/lib/components/app/content/MarkdownEditor/markdown-block-widget.ts b/ui/apps/chat/src/lib/components/app/content/MarkdownEditor/markdown-block-widget.ts index 6deae1d3c..66bdd3a83 100644 --- a/ui/apps/chat/src/lib/components/app/content/MarkdownEditor/markdown-block-widget.ts +++ b/ui/apps/chat/src/lib/components/app/content/MarkdownEditor/markdown-block-widget.ts @@ -12,14 +12,12 @@ import { import { getMarkdownProcessor } from '#lib/components/app/content/MarkdownContent/markdown-processor.ts'; import { getCodeInfoFromTarget } from '#lib/components/app/content/MarkdownContent/markdown-utils.ts'; import { MERMAID_BLOCK_CLASS } from '#lib/constants/index.ts'; -import { ColorMode } from '#lib/enums/index.ts'; import { copyCodeToClipboard, copyToClipboard, preprocessLaTeX, splitGluedClosingCodeFences } from '#lib/utils/index.ts'; -import { mode } from 'mode-watcher'; export interface MarkdownBlockWidgetOptions { onPreviewCode?: (code: string, language: string) => void; @@ -311,9 +309,7 @@ export class MarkdownBlockWidget extends WidgetType { // mermaid draws asynchronously and changes the block's height when done if (dom.querySelector(`pre.${MERMAID_BLOCK_CLASS}`)) { - void renderMermaidDiagrams(dom, mode.current === ColorMode.DARK).then(() => - this.measure(dom, view, key) - ); + void renderMermaidDiagrams(dom).then(() => this.measure(dom, view, key)); } } } diff --git a/ui/apps/chat/src/lib/components/app/content/MermaidPreviewControls.svelte b/ui/apps/chat/src/lib/components/app/content/MermaidPreviewControls.svelte index 5c0e03021..1899db389 100644 --- a/ui/apps/chat/src/lib/components/app/content/MermaidPreviewControls.svelte +++ b/ui/apps/chat/src/lib/components/app/content/MermaidPreviewControls.svelte @@ -3,6 +3,7 @@ import RotateCcwIcon from '@lucide/svelte/icons/rotate-ccw'; import ZoomInIcon from '@lucide/svelte/icons/zoom-in'; import ZoomOutIcon from '@lucide/svelte/icons/zoom-out'; + import { withThemeColors } from '#lib/components/app/content/MarkdownContent/markdown-diagrams.ts'; import { ICON_CLASS_DEFAULT } from '#lib/constants/index.ts'; interface Props { @@ -18,7 +19,7 @@ function downloadSvg() { if (!svgHtml) return; - const blob = new Blob([svgHtml], { type: 'image/svg+xml' }); + const blob = new Blob([withThemeColors(svgHtml)], { type: 'image/svg+xml' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); diff --git a/ui/apps/chat/src/lib/components/app/models/ModelsManager/row-actions.ts b/ui/apps/chat/src/lib/components/app/models/ModelsManager/row-actions.ts index 4265d1296..274f87c0f 100644 --- a/ui/apps/chat/src/lib/components/app/models/ModelsManager/row-actions.ts +++ b/ui/apps/chat/src/lib/components/app/models/ModelsManager/row-actions.ts @@ -1,4 +1,9 @@ -import { Compass, Eye, EyeOff, Heart, HeartOff, Trash2 } from '@lucide/svelte'; +import Compass from '@lucide/svelte/icons/compass'; +import Eye from '@lucide/svelte/icons/eye'; +import EyeOff from '@lucide/svelte/icons/eye-off'; +import Heart from '@lucide/svelte/icons/heart'; +import HeartOff from '@lucide/svelte/icons/heart-off'; +import Trash2 from '@lucide/svelte/icons/trash-2'; import { MODEL_DOWNLOAD_ICONS } from '#lib/constants/index.ts'; import { ModelRowDownloadState } from '#lib/enums/index.ts'; import { modelsStore, uiStore } from '#lib/stores/index.ts'; diff --git a/ui/apps/chat/src/lib/constants/icons.constants.ts b/ui/apps/chat/src/lib/constants/icons.constants.ts index fa0a36e20..ff2918ee2 100644 --- a/ui/apps/chat/src/lib/constants/icons.constants.ts +++ b/ui/apps/chat/src/lib/constants/icons.constants.ts @@ -4,25 +4,23 @@ */ import { MODALITY_FLAG_KEYS, MODALITY_ORDER } from '@ggml-org/llama-ui/models'; -import { - CircleAlert as LoadFailedIcon, - Compass as DiscoverIcon, - Eject as UnloadIcon, - File as FileIcon, - FileText as FileTextIcon, - FolderOpen as CwdCommandIcon, - FoldVertical as CompactCommandIcon, - Image as ImageIcon, - Loader2 as LoadingIcon, - Mic as AudioIcon, - Package as ModelIcon, - Pause as PauseDownloadIcon, - Play as ResumeDownloadIcon, - Power as LoadIcon, - RotateCw as RetryIcon, - Sparkles as PromptCommandIcon, - Video as VideoIcon -} from '@lucide/svelte'; +import LoadFailedIcon from '@lucide/svelte/icons/circle-alert'; +import DiscoverIcon from '@lucide/svelte/icons/compass'; +import UnloadIcon from '@lucide/svelte/icons/eject'; +import FileIcon from '@lucide/svelte/icons/file'; +import FileTextIcon from '@lucide/svelte/icons/file-text'; +import CompactCommandIcon from '@lucide/svelte/icons/fold-vertical'; +import CwdCommandIcon from '@lucide/svelte/icons/folder-open'; +import ImageIcon from '@lucide/svelte/icons/image'; +import LoadingIcon from '@lucide/svelte/icons/loader-2'; +import AudioIcon from '@lucide/svelte/icons/mic'; +import ModelIcon from '@lucide/svelte/icons/package'; +import PauseDownloadIcon from '@lucide/svelte/icons/pause'; +import ResumeDownloadIcon from '@lucide/svelte/icons/play'; +import LoadIcon from '@lucide/svelte/icons/power'; +import RetryIcon from '@lucide/svelte/icons/rotate-cw'; +import PromptCommandIcon from '@lucide/svelte/icons/sparkles'; +import VideoIcon from '@lucide/svelte/icons/video'; import { ChatFormCommandAction, FileTypeCategory, ModelCapability } from '#lib/enums/index.ts'; import type { ModelCapabilities } from '#lib/types/models.js'; import type { Component } from 'svelte'; diff --git a/ui/apps/chat/src/lib/constants/mcp.constants.ts b/ui/apps/chat/src/lib/constants/mcp.constants.ts index 2a469ffbc..fffbdc9de 100644 --- a/ui/apps/chat/src/lib/constants/mcp.constants.ts +++ b/ui/apps/chat/src/lib/constants/mcp.constants.ts @@ -1,4 +1,6 @@ -import { Globe, Radio, Zap } from '@lucide/svelte'; +import Globe from '@lucide/svelte/icons/globe'; +import Radio from '@lucide/svelte/icons/radio'; +import Zap from '@lucide/svelte/icons/zap'; import { MimeTypeImage } from '#lib/enums/files.enums.ts'; import { MCPTransportType } from '#lib/enums/index.ts'; import type { ClientCapabilities, Implementation } from '#lib/types/index.ts'; diff --git a/ui/apps/chat/src/lib/constants/mermaid-blocks.constants.ts b/ui/apps/chat/src/lib/constants/mermaid-blocks.constants.ts index cd9467fb6..379e85c77 100644 --- a/ui/apps/chat/src/lib/constants/mermaid-blocks.constants.ts +++ b/ui/apps/chat/src/lib/constants/mermaid-blocks.constants.ts @@ -1,6 +1,25 @@ export const MERMAID_WRAPPER_CLASS = 'mermaid-block-wrapper'; export const MERMAID_SCROLL_CONTAINER_CLASS = 'mermaid-scroll-container'; export const MERMAID_BLOCK_CLASS = 'mermaid'; +export const MERMAID_ERROR_CLASS = 'mermaid-error'; +// left plus right padding of a diagram's svg, see `pre.mermaid svg` in markdown-content.css +export const MERMAID_SVG_PADDING_X_REM = 2; + +// class Pele puts on the root of every diagram it draws +export const PELE_SVG_CLASS = 'pele'; +// the Pele colors app.css maps to the theme, written into a downloaded diagram +export const PELE_THEME_VARIABLES = [ + '--pele-bg', + '--pele-fg', + '--pele-muted', + '--pele-line', + '--pele-surface', + '--pele-surface-alt', + '--pele-border', + '--pele-accent', + '--pele-critical', + '--pele-radius' +] as const; export const MERMAID_LANGUAGE = 'mermaid'; diff --git a/ui/apps/chat/src/lib/constants/settings.constants.ts b/ui/apps/chat/src/lib/constants/settings.constants.ts index f3b4b2af4..4f1f77237 100644 --- a/ui/apps/chat/src/lib/constants/settings.constants.ts +++ b/ui/apps/chat/src/lib/constants/settings.constants.ts @@ -5,19 +5,17 @@ import { DEFAULT_MCP_CONFIG } from './mcp.constants'; import { SETTINGS_KEYS } from './settings-keys.constants'; import { TITLE_GENERATION } from './title-generation.constants'; import { FILE_GLOB_SEARCH_PICKERS } from './working-directory.constants'; -import { - Code, - Database, - File, - Funnel, - GlassWater, - ListRestart, - Monitor, - Moon, - PencilRuler, - SlidersVertical, - Sun -} from '@lucide/svelte'; +import Code from '@lucide/svelte/icons/code'; +import Database from '@lucide/svelte/icons/database'; +import File from '@lucide/svelte/icons/file'; +import Funnel from '@lucide/svelte/icons/funnel'; +import GlassWater from '@lucide/svelte/icons/glass-water'; +import ListRestart from '@lucide/svelte/icons/list-restart'; +import Monitor from '@lucide/svelte/icons/monitor'; +import Moon from '@lucide/svelte/icons/moon'; +import PencilRuler from '@lucide/svelte/icons/pencil-ruler'; +import SlidersVertical from '@lucide/svelte/icons/sliders-vertical'; +import Sun from '@lucide/svelte/icons/sun'; import { SurfaceTheme, SyncableParameterType } from '#lib/enums/index.ts'; import { SettingsFieldType } from '#lib/enums/settings.enums.ts'; import { ColorMode } from '#lib/enums/ui.enums.ts'; diff --git a/ui/apps/chat/src/lib/constants/tool-ui.constants.ts b/ui/apps/chat/src/lib/constants/tool-ui.constants.ts index 12abe60e8..dce125262 100644 --- a/ui/apps/chat/src/lib/constants/tool-ui.constants.ts +++ b/ui/apps/chat/src/lib/constants/tool-ui.constants.ts @@ -7,19 +7,17 @@ // (see ChatMessageToolCallBlockGetDatetime and // ChatMessageToolCallBlockSearchResults for prior art). -import { - Braces, - Clock, - Eye, - FilePen, - FilePlus, - FileSearch, - FileText, - Info, - MessagesSquare, - SearchCode, - Terminal -} from '@lucide/svelte'; +import Braces from '@lucide/svelte/icons/braces'; +import Clock from '@lucide/svelte/icons/clock'; +import Eye from '@lucide/svelte/icons/eye'; +import FilePen from '@lucide/svelte/icons/file-pen'; +import FilePlus from '@lucide/svelte/icons/file-plus'; +import FileSearch from '@lucide/svelte/icons/file-search'; +import FileText from '@lucide/svelte/icons/file-text'; +import Info from '@lucide/svelte/icons/info'; +import MessagesSquare from '@lucide/svelte/icons/messages-square'; +import SearchCode from '@lucide/svelte/icons/search-code'; +import Terminal from '@lucide/svelte/icons/terminal'; import { BuiltInTool, ToolSource } from '#lib/enums/index.ts'; import type { ToolUiEntry } from '#lib/types/index.ts'; diff --git a/ui/apps/chat/src/lib/constants/ui.constants.ts b/ui/apps/chat/src/lib/constants/ui.constants.ts index e76cd31b7..5ac2adfbb 100644 --- a/ui/apps/chat/src/lib/constants/ui.constants.ts +++ b/ui/apps/chat/src/lib/constants/ui.constants.ts @@ -6,7 +6,9 @@ import { SHORTCUT_SETTINGS } from './keyboard-shortcuts.constants'; import { MCP_SERVERS_ROUTE_ID, MODELS_ROUTE_ID, SETTINGS_ROUTE_ID } from './routes.constants'; -import { Search, Settings, SquarePen } from '@lucide/svelte'; +import Search from '@lucide/svelte/icons/search'; +import Settings from '@lucide/svelte/icons/settings'; +import SquarePen from '@lucide/svelte/icons/square-pen'; import McpLogo from '#lib/components/app/mcp/McpLogo.svelte'; import { SidebarAction, ToolSource } from '#lib/enums/index.ts'; import type { DesktopIconStripItem } from '#lib/types/index.ts'; diff --git a/ui/apps/chat/src/lib/services/sandbox.service.ts b/ui/apps/chat/src/lib/services/sandbox.service.ts index a52e68898..223771fc6 100644 --- a/ui/apps/chat/src/lib/services/sandbox.service.ts +++ b/ui/apps/chat/src/lib/services/sandbox.service.ts @@ -33,9 +33,9 @@ async function getHarness(): Promise { if (!harnessCache[key]) { if (enabled) { - const { default: nerdamerJs } = await import('virtual:nerdamer'); + const { default: loadNerdamer } = await import('virtual:nerdamer'); - harnessCache[key] = buildSandboxHarness(nerdamerJs); + harnessCache[key] = buildSandboxHarness(await loadNerdamer()); } else { harnessCache[key] = buildSandboxHarness(''); } diff --git a/ui/apps/chat/src/lib/utils/mcp.ts b/ui/apps/chat/src/lib/utils/mcp.ts index 75ec000c2..232099e2b 100644 --- a/ui/apps/chat/src/lib/utils/mcp.ts +++ b/ui/apps/chat/src/lib/utils/mcp.ts @@ -1,14 +1,12 @@ import { extractRootDomain } from './url'; -import { - AlertTriangle, - Code, - Database, - File, - FileText, - Image, - Info, - XCircle -} from '@lucide/svelte'; +import AlertTriangle from '@lucide/svelte/icons/alert-triangle'; +import Code from '@lucide/svelte/icons/code'; +import Database from '@lucide/svelte/icons/database'; +import File from '@lucide/svelte/icons/file'; +import FileText from '@lucide/svelte/icons/file-text'; +import Image from '@lucide/svelte/icons/image'; +import Info from '@lucide/svelte/icons/info'; +import XCircle from '@lucide/svelte/icons/x-circle'; import { CODE_FILE_EXTENSION_REGEX, DEFAULT_RESOURCE_FILENAME, diff --git a/ui/apps/chat/src/lib/utils/pdf-processing.ts b/ui/apps/chat/src/lib/utils/pdf-processing.ts index a67a117c7..ca5074db1 100644 --- a/ui/apps/chat/src/lib/utils/pdf-processing.ts +++ b/ui/apps/chat/src/lib/utils/pdf-processing.ts @@ -5,23 +5,23 @@ import { MimeTypeApplication, MimeTypeImage } from '#lib/enums/index.ts'; import { browser } from '$app/env'; -import * as pdfjs from 'pdfjs-dist'; +import pdfWorkerUrl from 'pdfjs-dist/build/pdf.worker.min.mjs?url'; type TextContent = { items: Array<{ str: string }>; }; -if (browser) { - // Import worker as text and create blob URL for inline bundling - import('pdfjs-dist/build/pdf.worker.min.mjs?raw') - .then((workerModule) => { - const workerBlob = new Blob([workerModule.default], { type: 'application/javascript' }); +let pdfjsModule: Promise | undefined; - pdfjs.GlobalWorkerOptions.workerSrc = URL.createObjectURL(workerBlob); - }) - .catch(() => { - console.warn('Failed to load PDF.js worker, PDF processing may not work'); - }); +// pdf.js and its worker are files of their own, so the app loads them only when it opens a PDF +function loadPdfjs(): Promise { + pdfjsModule ??= import('pdfjs-dist').then((pdfjs) => { + pdfjs.GlobalWorkerOptions.workerSrc = pdfWorkerUrl; + + return pdfjs; + }); + + return pdfjsModule; } /** @@ -58,7 +58,7 @@ export async function convertPDFToText(file: File): Promise { } try { - const buffer = await getFileAsBuffer(file); + const [pdfjs, buffer] = await Promise.all([loadPdfjs(), getFileAsBuffer(file)]); const pdf = await pdfjs.getDocument({ data: buffer }).promise; const numPages = pdf.numPages; const textContentPromises: Promise[] = []; @@ -96,7 +96,7 @@ export async function convertPDFToImage(file: File, scale: number = 1.5): Promis } try { - const buffer = await getFileAsBuffer(file); + const [pdfjs, buffer] = await Promise.all([loadPdfjs(), getFileAsBuffer(file)]); const doc = await pdfjs.getDocument({ data: buffer }).promise; const pages: Promise[] = []; diff --git a/ui/apps/chat/src/virtual-nerdamer.d.ts b/ui/apps/chat/src/virtual-nerdamer.d.ts index 433fb2b3b..19fcd36f6 100644 --- a/ui/apps/chat/src/virtual-nerdamer.d.ts +++ b/ui/apps/chat/src/virtual-nerdamer.d.ts @@ -1,4 +1,4 @@ declare module 'virtual:nerdamer' { - const code: string; - export default code; + const loadNerdamer: () => Promise; + export default loadNerdamer; } diff --git a/ui/apps/chat/tests/client/pdf-processing.svelte.test.ts b/ui/apps/chat/tests/client/pdf-processing.svelte.test.ts new file mode 100644 index 000000000..63e941306 --- /dev/null +++ b/ui/apps/chat/tests/client/pdf-processing.svelte.test.ts @@ -0,0 +1,48 @@ +// pdf.js loads on first use, with its worker as a file of its own: extracting a PDF's text +// and drawing its pages go through that load. +import { convertPDFToImage, convertPDFToText } from '#lib/utils/pdf-processing.ts'; +import { describe, expect, it } from 'vitest'; + +/** A one-page PDF that shows `text`, with a correct cross-reference table. */ +function pdfWithText(text: string): File { + const stream = `BT /F1 24 Tf 72 720 Td (${text}) Tj ET`; + const objects = [ + '<< /Type /Catalog /Pages 2 0 R >>', + '<< /Type /Pages /Kids [3 0 R] /Count 1 >>', + '<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 4 0 R /Resources << /Font << /F1 5 0 R >> >> >>', + `<< /Length ${stream.length} >>\nstream\n${stream}\nendstream`, + '<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>' + ]; + + let body = '%PDF-1.4\n'; + + const offsets: number[] = []; + + objects.forEach((object, i) => { + offsets.push(body.length); + body += `${i + 1} 0 obj\n${object}\nendobj\n`; + }); + + const xref = body.length; + const entries = offsets.map((offset) => `${String(offset).padStart(10, '0')} 00000 n \n`); + + body += `xref\n0 ${objects.length + 1}\n0000000000 65535 f \n${entries.join('')}`; + body += `trailer\n<< /Size ${objects.length + 1} /Root 1 0 R >>\nstartxref\n${xref}\n%%EOF\n`; + + return new File([body], 'hello.pdf', { type: 'application/pdf' }); +} + +describe('pdf-processing', () => { + it('extracts the text of a PDF', async () => { + const text = await convertPDFToText(pdfWithText('Hello from a PDF')); + + expect(text).toContain('Hello from a PDF'); + }); + + it('draws each page of a PDF as a PNG', async () => { + const pages = await convertPDFToImage(pdfWithText('Page one')); + + expect(pages).toHaveLength(1); + expect(pages[0]).toMatch(/^data:image\/png;base64,/); + }); +}); diff --git a/ui/apps/chat/tests/e2e/pwa.e2e.ts b/ui/apps/chat/tests/e2e/pwa.e2e.ts index 1b7636886..061cf5e1f 100644 --- a/ui/apps/chat/tests/e2e/pwa.e2e.ts +++ b/ui/apps/chat/tests/e2e/pwa.e2e.ts @@ -40,9 +40,10 @@ test.describe('PWA Service Worker', () => { const swResponse = await page.request.get(swActive!); const swContent = await swResponse.text(); - // Precache contains SvelteKit content-hashed bundle paths - expect(swContent).toMatch(/["'`]_app\/immutable\/bundle\.[a-zA-Z0-9_-]+\.js["'`]/); - expect(swContent).toMatch(/["'`]_app\/immutable\/assets\/bundle\.[a-zA-Z0-9_-]+\.css["'`]/); + // Precache contains SvelteKit's content-hashed entry points and CSS (a split build) + expect(swContent).toMatch(/["'`]_app\/immutable\/entry\/start\.[a-zA-Z0-9_-]+\.js["'`]/); + expect(swContent).toMatch(/["'`]_app\/immutable\/entry\/app\.[a-zA-Z0-9_-]+\.js["'`]/); + expect(swContent).toMatch(/["'`]_app\/immutable\/assets\/[a-zA-Z0-9_.-]+\.css["'`]/); expect(swContent).toMatch(/["'`]manifest\.webmanifest["'`]/); expect(swContent).toMatch(/["'`]_app\/version\.json["'`]/); }); @@ -120,16 +121,17 @@ test.describe('PWA Service Worker', () => { expect(manifest.icons.length).toBeGreaterThan(0); }); - test('index.html contains content-hashed bundle references', async ({ page }) => { + test('index.html contains content-hashed entry references', async ({ page }) => { const response = await page.request.get('/'); expect(response.ok()).toBeTruthy(); const html = await response.text(); - // SvelteKit outputs content-hashed bundle names in _app/immutable/ - expect(html).toMatch(/href="(\.\/|\/)_app\/immutable\/bundle\.[a-zA-Z0-9_-]+\.js"/); - expect(html).toMatch(/href="(\.\/|\/)_app\/immutable\/assets\/bundle\.[a-zA-Z0-9_-]+\.css"/); - expect(html).toMatch(/import\("(\.\/|\/)_app\/immutable\/bundle\.[a-zA-Z0-9_-]+\.js"\)/); + // a split build: SvelteKit's content-hashed entry points in _app/immutable/entry/ + expect(html).toMatch(/href="(\.\/|\/)_app\/immutable\/entry\/start\.[a-zA-Z0-9_-]+\.js"/); + expect(html).toMatch(/href="(\.\/|\/)_app\/immutable\/assets\/[a-zA-Z0-9_.-]+\.css"/); + expect(html).toMatch(/import\("(\.\/|\/)_app\/immutable\/entry\/start\.[a-zA-Z0-9_-]+\.js"\)/); + expect(html).toMatch(/import\("(\.\/|\/)_app\/immutable\/entry\/app\.[a-zA-Z0-9_-]+\.js"\)/); }); }); diff --git a/ui/apps/chat/tests/stories/content/MarkdownContent.stories.svelte b/ui/apps/chat/tests/stories/content/MarkdownContent.stories.svelte index a569a0643..dbc8481c5 100644 --- a/ui/apps/chat/tests/stories/content/MarkdownContent.stories.svelte +++ b/ui/apps/chat/tests/stories/content/MarkdownContent.stories.svelte @@ -1,7 +1,9 @@