mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-11-26 10:13:46 +00:00
Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 86ea09774f | |||
| c44efc3460 | |||
| cac0684247 | |||
| 41779f668b | |||
| b00040d467 | |||
| cd6d35c3f0 | |||
| 461b1675c0 | |||
| 7741627af3 | |||
| 9f6e35da87 | |||
| 5cab25764f | |||
| 412cd06c7d | |||
| 7af524a834 | |||
| 3ec61a78cf | |||
| 7f08fb14d1 | |||
| 867da7b94c | |||
| 76e1abd7e1 | |||
| 48fe81b58f | |||
| 596b8c5705 | |||
| 22df281316 | |||
| 5755e6db32 | |||
| bd38317ba5 | |||
| adbc358dd5 | |||
| 21b96e17a7 | |||
| d2be88590f | |||
| 873856ae98 | |||
| 4cbbda7fab | |||
| 63a4a98384 | |||
| 060f1f63ca | |||
| 7cee30ecb8 | |||
| a035d196f0 |
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Point agents to the site MCP server from Markdown pages, the page HTML, llms.txt and llms-full.txt.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Serve the site AI Catalog as specification version 0.9, with identifiers in its `urn:air:{publisher}:{name}:{kind}` format.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Name a site's MCP server as docs, such as "Acme Docs MCP Server", in AI clients and in the install commands and links, so it is not confused with a product's own MCP server.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Prevent self-redirect loops and skip redirects targeting hidden adaptive content.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Keep published site search results visible while visitors refine a query.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Apply the default language-aware search scope to legacy search links.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Count only MCP tool calls in the MCP request insights event.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Answer GET requests to the MCP endpoint with an `Allow: POST` header.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Support MCP protocol version 2025-11-25 on published site MCP servers.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Keep published revision URLs out of search results.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Resolve GitBook links in OpenAPI schema descriptions to the site's published URLs instead of the editor.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Render a page's search keywords in its metadata.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Drop description HTML supplied by OpenAPI specs and sanitize example descriptions that could render HTML.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Track the displayed position and search request ID when a visitor opens a search result.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Include navigation-hidden published spaces in direct browser search lookup and avoid latching on unknown spaces.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Load Shiki languages and themes from static assets instead of bundling them.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Show site revision previews as their site revision pins them, including OpenAPI specs.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Update the GitBook API SDK for site revision responses.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Fix wide content in Updates blocks overflowing into the page outline.
|
||||
@@ -127,7 +127,7 @@
|
||||
"@gitbook/react-math": "workspace:*",
|
||||
"@gitbook/react-openapi": "workspace:*",
|
||||
"@mermaid-js/mermaid-zenuml": "^0.2.2",
|
||||
"@modelcontextprotocol/sdk": "1.17.5",
|
||||
"@modelcontextprotocol/sdk": "1.26.0",
|
||||
"@opennextjs/aws": "4.2.0",
|
||||
"@opennextjs/cloudflare": "1.20.18",
|
||||
"@panzoom/panzoom": "^4.6.1",
|
||||
@@ -148,7 +148,7 @@
|
||||
"jsontoxml": "^1.0.1",
|
||||
"jwt-decode": "^4.0.0",
|
||||
"leven": "^4.1.0",
|
||||
"mcp-handler": "^1.0.2",
|
||||
"mcp-handler": "^1.1.0",
|
||||
"mdast-util-from-markdown": "^2.0.2",
|
||||
"mdast-util-frontmatter": "^2.0.1",
|
||||
"mdast-util-gfm": "^3.1.0",
|
||||
@@ -190,7 +190,7 @@
|
||||
"url-join": "^5.0.0",
|
||||
"usehooks-ts": "catalog:",
|
||||
"warn-once": "^0.1.1",
|
||||
"zod": "^3",
|
||||
"zod": "^3.25",
|
||||
"zod-to-json-schema": "^3.25.1",
|
||||
"zustand": "^5.0.3",
|
||||
},
|
||||
@@ -357,7 +357,7 @@
|
||||
},
|
||||
"catalog": {
|
||||
"@base-ui/react": "^1.7.0",
|
||||
"@gitbook/api": "0.211.0",
|
||||
"@gitbook/api": "0.214.0",
|
||||
"@scalar/api-client-react": "^1.3.46",
|
||||
"@tsconfig/node20": "^20.1.6",
|
||||
"@tsconfig/strictest": "^2.0.6",
|
||||
@@ -725,7 +725,7 @@
|
||||
|
||||
"@fortawesome/fontawesome-svg-core": ["@fortawesome/fontawesome-svg-core@7.2.0", "", { "dependencies": { "@fortawesome/fontawesome-common-types": "7.2.0" } }, "sha512-6639htZMjEkwskf3J+e6/iar+4cTNM9qhoWuRfj9F3eJD6r7iCzV1SWnQr2Mdv0QT0suuqU8BoJCZUyCtP9R4Q=="],
|
||||
|
||||
"@gitbook/api": ["@gitbook/api@0.211.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-G+rY2m7ZvyR1RA4oilarzrNDABDkYhARoIyfNCE5mYqZQgpgsLShn3rGgzTudO2iqwt/5iK6RcJc2enfj+37Jg=="],
|
||||
"@gitbook/api": ["@gitbook/api@0.214.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-rNmnQIgg0mhdknDMc2/3dhoKk+XmCP1P5qTrhazI458WsqkPCSMV2o7B6cJADUzs9svH78y5z7bSRzrrOMmV4g=="],
|
||||
|
||||
"@gitbook/browser-types": ["@gitbook/browser-types@workspace:packages/browser-types"],
|
||||
|
||||
@@ -759,6 +759,8 @@
|
||||
|
||||
"@headlessui/vue": ["@headlessui/vue@1.7.23", "", { "dependencies": { "@tanstack/vue-virtual": "^3.0.0-beta.60" }, "peerDependencies": { "vue": "^3.2.0" } }, "sha512-JzdCNqurrtuu0YW6QaDtR2PIYCKPUWq28csDyMvN4zmGccmE7lz40Is6hc3LA4HFeCI7sekZ/PQMTNmn9I/4Wg=="],
|
||||
|
||||
"@hono/node-server": ["@hono/node-server@1.19.19", "", { "peerDependencies": { "hono": "^4" } }, "sha512-Fy9R7PACOzHU9LDpfnuzVyuVYevKQRcEG2mZhmfc+DRdmayEd3RVfa2XOt2IgGcPNgA77Yk63KBszepcMFK5Ng=="],
|
||||
|
||||
"@hyperjump/browser": ["@hyperjump/browser@1.1.6", "", { "dependencies": { "@hyperjump/json-pointer": "^1.1.0", "@hyperjump/uri": "^1.2.0", "content-type": "^1.0.5", "just-curry-it": "^5.3.0" } }, "sha512-i27uPV7SxK1GOn7TLTRxTorxchYa5ur9JHgtl6TxZ1MHuyb9ROAnXxEeu4q4H1836Xb7lL2PGPsaa5Jl3p+R6g=="],
|
||||
|
||||
"@hyperjump/json-pointer": ["@hyperjump/json-pointer@1.1.0", "", {}, "sha512-tFCKxMKDKK3VEdtUA3EBOS9GmSOS4mbrTjh9v3RnK10BphDMOb6+bxTh++/ae1AyfHyWb6R54O/iaoAtPMZPCg=="],
|
||||
@@ -885,7 +887,7 @@
|
||||
|
||||
"@mermaid-js/parser": ["@mermaid-js/parser@1.2.1", "", { "dependencies": { "@chevrotain/types": "~11.1.2" } }, "sha512-n12NohV3mrUyUL2o93IgG/ifeW9FTyeJn3zDxkhwa8MJ9Fxg3HQMlA3RiGmD/3UnJvheztkjjQAjA2T4LmUcpw=="],
|
||||
|
||||
"@modelcontextprotocol/sdk": ["@modelcontextprotocol/sdk@1.17.5", "", { "dependencies": { "ajv": "^6.12.6", "content-type": "^1.0.5", "cors": "^2.8.5", "cross-spawn": "^7.0.5", "eventsource": "^3.0.2", "eventsource-parser": "^3.0.0", "express": "^5.0.1", "express-rate-limit": "^7.5.0", "pkce-challenge": "^5.0.0", "raw-body": "^3.0.0", "zod": "^3.23.8", "zod-to-json-schema": "^3.24.1" } }, "sha512-QakrKIGniGuRVfWBdMsDea/dx1PNE739QJ7gCM41s9q+qaCYTHCdsIBXQVVXry3mfWAiaM9kT22Hyz53Uw8mfg=="],
|
||||
"@modelcontextprotocol/sdk": ["@modelcontextprotocol/sdk@1.26.0", "", { "dependencies": { "@hono/node-server": "^1.19.9", "ajv": "^8.17.1", "ajv-formats": "^3.0.1", "content-type": "^1.0.5", "cors": "^2.8.5", "cross-spawn": "^7.0.5", "eventsource": "^3.0.2", "eventsource-parser": "^3.0.0", "express": "^5.2.1", "express-rate-limit": "^8.2.1", "hono": "^4.11.4", "jose": "^6.1.3", "json-schema-typed": "^8.0.2", "pkce-challenge": "^5.0.0", "raw-body": "^3.0.0", "zod": "^3.25 || ^4.0", "zod-to-json-schema": "^3.25.1" }, "peerDependencies": { "@cfworker/json-schema": "^4.1.1" }, "optionalPeers": ["@cfworker/json-schema"] }, "sha512-Y5RmPncpiDtTXDbLKswIJzTqu2hyBKxTNsgKqKclDbhIgg1wgtf1fRuvxgTnRfcnxtvvgbIEcqUOzZrJ6iSReg=="],
|
||||
|
||||
"@napi-rs/wasm-runtime": ["@napi-rs/wasm-runtime@1.0.6", "", { "dependencies": { "@emnapi/core": "^1.5.0", "@emnapi/runtime": "^1.5.0", "@tybys/wasm-util": "^0.10.1" } }, "sha512-DXj75ewm11LIWUk198QSKUTxjyRjsBwk09MuMk5DGK+GDUtyPhhEHOGP/Xwwj3DjQXXkivoBirmOnKrLfc0+9g=="],
|
||||
|
||||
@@ -1615,7 +1617,7 @@
|
||||
|
||||
"ai": ["ai@4.3.0", "", { "dependencies": { "@ai-sdk/provider": "1.1.0", "@ai-sdk/provider-utils": "2.2.4", "@ai-sdk/react": "1.2.6", "@ai-sdk/ui-utils": "1.2.5", "@opentelemetry/api": "1.9.0", "jsondiffpatch": "0.6.0" }, "peerDependencies": { "react": "^18 || ^19 || ^19.0.0-rc", "zod": "^3.23.8" }, "optionalPeers": ["react"] }, "sha512-PxyQYKhWaU3LiZEpeKRaekVonZIbWdKAwgnqm0CSAxy1MFufmYEC5SM5Mc9uiK2DoHcbAL3d1jyaQ2fSDAJL8w=="],
|
||||
|
||||
"ajv": ["ajv@6.12.6", "", { "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" } }, "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g=="],
|
||||
"ajv": ["ajv@8.20.0", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2" } }, "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA=="],
|
||||
|
||||
"ajv-draft-04": ["ajv-draft-04@1.0.0", "", { "peerDependencies": { "ajv": "^8.5.0" }, "optionalPeers": ["ajv"] }, "sha512-mv00Te6nmYbRp5DCwclxtt7yV/joXJPGS7nM+97GdxvuttCOfgI3K4U25zboyeX0O+myI8ERluxQe5wljMmVIw=="],
|
||||
|
||||
@@ -1643,8 +1645,6 @@
|
||||
|
||||
"array-differ": ["array-differ@3.0.0", "", {}, "sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg=="],
|
||||
|
||||
"array-flatten": ["array-flatten@3.0.0", "", {}, "sha512-zPMVc3ZYlGLNk4mpK1NzP2wg0ml9t7fUgDsayR5Y5rSzxQilzR9FGu/EH2jQOcKSAeAfWeylyW8juy3OkWRvNA=="],
|
||||
|
||||
"array-timsort": ["array-timsort@1.0.3", "", {}, "sha512-/+3GRL7dDAGEfM6TseQk/U+mi18TU2Ms9I3UlLdUMhz2hbvGNTKdj9xniwXfUqgYhHxRx0+8UnKkvlNwVU+cWQ=="],
|
||||
|
||||
"array-union": ["array-union@2.1.0", "", {}, "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw=="],
|
||||
@@ -1695,7 +1695,7 @@
|
||||
|
||||
"blake3-wasm": ["blake3-wasm@2.1.5", "", {}, "sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g=="],
|
||||
|
||||
"body-parser": ["body-parser@2.0.2", "", { "dependencies": { "bytes": "3.1.2", "content-type": "~1.0.5", "debug": "3.1.0", "destroy": "1.2.0", "http-errors": "2.0.0", "iconv-lite": "0.5.2", "on-finished": "2.4.1", "qs": "6.13.0", "raw-body": "^3.0.0", "type-is": "~1.6.18" } }, "sha512-SNMk0OONlQ01uk8EPeiBvTW7W4ovpL5b1O3t1sjpPgfxOQ6BqQJ6XjxinDPR79Z6HdcD5zBBwr5ssiTlgdNztQ=="],
|
||||
"body-parser": ["body-parser@2.2.1", "", { "dependencies": { "bytes": "^3.1.2", "content-type": "^1.0.5", "debug": "^4.4.3", "http-errors": "^2.0.0", "iconv-lite": "^0.7.0", "on-finished": "^2.4.1", "qs": "^6.14.0", "raw-body": "^3.0.1", "type-is": "^2.0.1" } }, "sha512-nfDwkulwiZYQIGwxdy0RUmowMhKcFVcYXUU7m4QlKYim1rUtg83xm2yjZ40QjDuc291AJjjeSc9b++AWHSgSHw=="],
|
||||
|
||||
"boolbase": ["boolbase@1.0.0", "", {}, "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww=="],
|
||||
|
||||
@@ -1723,8 +1723,6 @@
|
||||
|
||||
"cacheable": ["cacheable@1.8.9", "", { "dependencies": { "hookified": "^1.7.1", "keyv": "^5.3.1" } }, "sha512-FicwAUyWnrtnd4QqYAoRlNs44/a1jTL7XDKqm5gJ90wz1DQPlC7U2Rd1Tydpv+E7WAr4sQHuw8Q8M3nZMAyecQ=="],
|
||||
|
||||
"call-bind": ["call-bind@1.0.7", "", { "dependencies": { "es-define-property": "^1.0.0", "es-errors": "^1.3.0", "function-bind": "^1.1.2", "get-intrinsic": "^1.2.4", "set-function-length": "^1.2.1" } }, "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w=="],
|
||||
|
||||
"call-bind-apply-helpers": ["call-bind-apply-helpers@1.0.2", "", { "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2" } }, "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ=="],
|
||||
|
||||
"call-bound": ["call-bound@1.0.4", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "get-intrinsic": "^1.3.0" } }, "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg=="],
|
||||
@@ -1923,8 +1921,6 @@
|
||||
|
||||
"deepmerge": ["deepmerge@4.3.1", "", {}, "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A=="],
|
||||
|
||||
"define-data-property": ["define-data-property@1.1.4", "", { "dependencies": { "es-define-property": "^1.0.0", "es-errors": "^1.3.0", "gopd": "^1.0.1" } }, "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A=="],
|
||||
|
||||
"defu": ["defu@6.1.4", "", {}, "sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg=="],
|
||||
|
||||
"degenerator": ["degenerator@5.0.1", "", { "dependencies": { "ast-types": "^0.13.4", "escodegen": "^2.1.0", "esprima": "^4.0.1" } }, "sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ=="],
|
||||
@@ -2011,7 +2007,7 @@
|
||||
|
||||
"error-stack-parser-es": ["error-stack-parser-es@1.0.5", "", {}, "sha512-5qucVt2XcuGMcEGgWI7i+yZpmpByQ8J1lHhcL7PwqCwu9FPP3VUXzT4ltHe5i2z9dePwEHcDVOAfSnHsOlCXRA=="],
|
||||
|
||||
"es-define-property": ["es-define-property@1.0.0", "", { "dependencies": { "get-intrinsic": "^1.2.4" } }, "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ=="],
|
||||
"es-define-property": ["es-define-property@1.0.1", "", {}, "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g=="],
|
||||
|
||||
"es-errors": ["es-errors@1.3.0", "", {}, "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw=="],
|
||||
|
||||
@@ -2069,9 +2065,9 @@
|
||||
|
||||
"execa": ["execa@3.2.0", "", { "dependencies": { "cross-spawn": "^7.0.0", "get-stream": "^5.0.0", "human-signals": "^1.1.1", "is-stream": "^2.0.0", "merge-stream": "^2.0.0", "npm-run-path": "^4.0.0", "onetime": "^5.1.0", "p-finally": "^2.0.0", "signal-exit": "^3.0.2", "strip-final-newline": "^2.0.0" } }, "sha512-kJJfVbI/lZE1PZYDI5VPxp8zXPO9rtxOkhpZ0jMKha56AI9y2gGVC6bkukStQf0ka5Rh15BA5m7cCCH4jmHqkw=="],
|
||||
|
||||
"express": ["express@5.0.1", "", { "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.0.1", "content-disposition": "^1.0.0", "content-type": "~1.0.4", "cookie": "0.7.1", "cookie-signature": "^1.2.1", "debug": "4.3.6", "depd": "2.0.0", "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "etag": "~1.8.1", "finalhandler": "^2.0.0", "fresh": "2.0.0", "http-errors": "2.0.0", "merge-descriptors": "^2.0.0", "methods": "~1.1.2", "mime-types": "^3.0.0", "on-finished": "2.4.1", "once": "1.4.0", "parseurl": "~1.3.3", "proxy-addr": "~2.0.7", "qs": "6.13.0", "range-parser": "~1.2.1", "router": "^2.0.0", "safe-buffer": "5.2.1", "send": "^1.1.0", "serve-static": "^2.1.0", "setprototypeof": "1.2.0", "statuses": "2.0.1", "type-is": "^2.0.0", "utils-merge": "1.0.1", "vary": "~1.1.2" } }, "sha512-ORF7g6qGnD+YtUG9yx4DFoqCShNMmUKiXuT5oWMHiOvt/4WFbHC6yCwQMTSBMno7AqntNCAzzcnnjowRkTL9eQ=="],
|
||||
"express": ["express@5.2.1", "", { "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.1", "content-disposition": "^1.0.0", "content-type": "^1.0.5", "cookie": "^0.7.1", "cookie-signature": "^1.2.1", "debug": "^4.4.0", "depd": "^2.0.0", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "etag": "^1.8.1", "finalhandler": "^2.1.0", "fresh": "^2.0.0", "http-errors": "^2.0.0", "merge-descriptors": "^2.0.0", "mime-types": "^3.0.0", "on-finished": "^2.4.1", "once": "^1.4.0", "parseurl": "^1.3.3", "proxy-addr": "^2.0.7", "qs": "^6.14.0", "range-parser": "^1.2.1", "router": "^2.2.0", "send": "^1.1.0", "serve-static": "^2.2.0", "statuses": "^2.0.1", "type-is": "^2.0.1", "vary": "^1.1.2" } }, "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw=="],
|
||||
|
||||
"express-rate-limit": ["express-rate-limit@7.5.1", "", { "peerDependencies": { "express": ">= 4.11" } }, "sha512-7iN8iPMDzOMHPUYllBEsQdWVB6fPDMPqwjBaFrgr4Jgr/+okjvzAy+UHlYYL/Vs0OsOrMkwS6PJDkFlJwoxUnw=="],
|
||||
"express-rate-limit": ["express-rate-limit@8.7.5", "", { "dependencies": { "debug": "^4.4.3", "ip-address": "^10.2.0" }, "peerDependencies": { "express": ">= 4.11" } }, "sha512-wi+v38cx2EqD0JnhE/e74o5tFqKWUOAPFJIgyEiqJ8v2MNpoOAA3kI2hXYOI+YM+HE5yqbdAlVxm2GqOIeYOgA=="],
|
||||
|
||||
"ext": ["ext@1.7.0", "", { "dependencies": { "type": "^2.7.2" } }, "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw=="],
|
||||
|
||||
@@ -2085,8 +2081,6 @@
|
||||
|
||||
"fast-glob": ["fast-glob@3.3.3", "", { "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", "glob-parent": "^5.1.2", "merge2": "^1.3.0", "micromatch": "^4.0.8" } }, "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg=="],
|
||||
|
||||
"fast-json-stable-stringify": ["fast-json-stable-stringify@2.1.0", "", {}, "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw=="],
|
||||
|
||||
"fast-redact": ["fast-redact@3.5.0", "", {}, "sha512-dwsoQlS7h9hMeYUq1W++23NDcBLV4KqONnITDV9DjfS3q1SgDGVrBdvvTLUotWtPSD7asWDV9/CmsZPy8Hf70A=="],
|
||||
|
||||
"fast-uri": ["fast-uri@3.0.2", "", {}, "sha512-GR6f0hD7XXyNJa25Tb9BuIdN0tdr+0BMi6/CJPH3wJO1JjNG3n/VsSw38AwRdKZABm8lGbPfakLRkYzx2V9row=="],
|
||||
@@ -2113,7 +2107,7 @@
|
||||
|
||||
"fill-range": ["fill-range@7.1.1", "", { "dependencies": { "to-regex-range": "^5.0.1" } }, "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg=="],
|
||||
|
||||
"finalhandler": ["finalhandler@2.0.0", "", { "dependencies": { "debug": "2.6.9", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "on-finished": "2.4.1", "parseurl": "~1.3.3", "statuses": "2.0.1", "unpipe": "~1.0.0" } }, "sha512-MX6Zo2adDViYh+GcxxB1dpO43eypOGUOL12rLCOTMQv/DfIbpSJUy4oQIIZhVZkH9e+bZWKMon0XHFEju16tkQ=="],
|
||||
"finalhandler": ["finalhandler@2.1.1", "", { "dependencies": { "debug": "^4.4.0", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "on-finished": "^2.4.1", "parseurl": "^1.3.3", "statuses": "^2.0.1" } }, "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA=="],
|
||||
|
||||
"find-up": ["find-up@4.1.0", "", { "dependencies": { "locate-path": "^5.0.0", "path-exists": "^4.0.0" } }, "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw=="],
|
||||
|
||||
@@ -2155,7 +2149,7 @@
|
||||
|
||||
"get-east-asian-width": ["get-east-asian-width@1.7.0", "", {}, "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q=="],
|
||||
|
||||
"get-intrinsic": ["get-intrinsic@1.2.4", "", { "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2", "has-proto": "^1.0.1", "has-symbols": "^1.0.3", "hasown": "^2.0.0" } }, "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ=="],
|
||||
"get-intrinsic": ["get-intrinsic@1.3.0", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "es-define-property": "^1.0.1", "es-errors": "^1.3.0", "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", "get-proto": "^1.0.1", "gopd": "^1.2.0", "has-symbols": "^1.1.0", "hasown": "^2.0.2", "math-intrinsics": "^1.1.0" } }, "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ=="],
|
||||
|
||||
"get-own-enumerable-keys": ["get-own-enumerable-keys@1.0.0", "", {}, "sha512-PKsK2FSrQCyxcGHsGrLDcK0lx+0Ke+6e8KFFozA9/fIQLhQzPaRvJFdcz7+Axg3jUH/Mq+NI4xa5u/UT2tQskA=="],
|
||||
|
||||
@@ -2187,7 +2181,7 @@
|
||||
|
||||
"google-font-metadata": ["google-font-metadata@6.0.7", "", { "dependencies": { "@evan/concurrency": "^0.0.3", "@octokit/core": "^6.1.2", "cac": "^6.7.14", "consola": "^3.3.3", "deepmerge": "^4.3.1", "json-stringify-pretty-compact": "^4.0.0", "linkedom": "^0.18.6", "pathe": "^1.1.2", "picocolors": "^1.1.1", "playwright": "^1.49.1", "stylis": "^4.3.4", "zod": "^3.24.1" }, "bin": { "gfm": "dist/cli.mjs" } }, "sha512-Zw+AmoVRZNfQdis1+cYu0Zo6OWk+SQNEDzGKgRjC8nTopghZw2AtfcY6R9MWLR04gsZBkTNYPE8Pahm9i4Z/aA=="],
|
||||
|
||||
"gopd": ["gopd@1.0.1", "", { "dependencies": { "get-intrinsic": "^1.1.3" } }, "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA=="],
|
||||
"gopd": ["gopd@1.2.0", "", {}, "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg=="],
|
||||
|
||||
"graceful-fs": ["graceful-fs@4.2.11", "", {}, "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="],
|
||||
|
||||
@@ -2197,11 +2191,7 @@
|
||||
|
||||
"has-flag": ["has-flag@4.0.0", "", {}, "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="],
|
||||
|
||||
"has-property-descriptors": ["has-property-descriptors@1.0.2", "", { "dependencies": { "es-define-property": "^1.0.0" } }, "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg=="],
|
||||
|
||||
"has-proto": ["has-proto@1.0.3", "", {}, "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q=="],
|
||||
|
||||
"has-symbols": ["has-symbols@1.0.3", "", {}, "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A=="],
|
||||
"has-symbols": ["has-symbols@1.1.0", "", {}, "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ=="],
|
||||
|
||||
"hasown": ["hasown@2.0.2", "", { "dependencies": { "function-bind": "^1.1.2" } }, "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ=="],
|
||||
|
||||
@@ -2245,6 +2235,8 @@
|
||||
|
||||
"highlightjs-vue": ["highlightjs-vue@1.0.0", "", {}, "sha512-PDEfEF102G23vHmPhLyPboFCD+BkMGu+GuJe2d9/eH4FsCwvgBpnc9n0pGE+ffKdph38s6foEZiEjdgHdzp+IA=="],
|
||||
|
||||
"hono": ["hono@4.13.21", "", {}, "sha512-h9UsguqfVk4kjUwLvQpHOmOaJpW10jz9lp8bvKUUa04wJG/fabKFBqXZ06D6LFaeKQZtUZRVeg0gfkTTEsX7Mw=="],
|
||||
|
||||
"hookable": ["hookable@5.5.3", "", {}, "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ=="],
|
||||
|
||||
"hookified": ["hookified@1.8.1", "", {}, "sha512-GrO2l93P8xCWBSTBX9l2BxI78VU/MAAYag+pG8curS3aBGy0++ZlxrQ7PdUOUVMbn5BwkGb6+eRrnf43ipnFEA=="],
|
||||
@@ -2293,7 +2285,7 @@
|
||||
|
||||
"internmap": ["internmap@1.0.1", "", {}, "sha512-lDB5YccMydFBtasVtxnZ3MRBHuaoE8GKsppq+EchKL2U4nK/DmEpPHNH8MZe5HkMtpSiTSOZwfN0tzYjO/lJEw=="],
|
||||
|
||||
"ip-address": ["ip-address@10.1.0", "", {}, "sha512-XXADHxXmvT9+CRxhXg56LJovE+bmWnEWB78LB83VZTprKTmaC5QfruXocxzTZ2Kl0DNwKuBdlIhjL8LeY8Sf8Q=="],
|
||||
"ip-address": ["ip-address@10.7.6", "", {}, "sha512-00LYkM6byILa9eQIx6qoaXCM40xTLd56AZ4vyaPW3YTyb49VZYPo5xsiAq4tuQ54GH4R7gVdYScJ1B7B77PuTg=="],
|
||||
|
||||
"ipaddr.js": ["ipaddr.js@1.9.1", "", {}, "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g=="],
|
||||
|
||||
@@ -2363,7 +2355,9 @@
|
||||
|
||||
"json-schema-to-ts": ["json-schema-to-ts@1.6.4", "", { "dependencies": { "@types/json-schema": "^7.0.6", "ts-toolbelt": "^6.15.5" } }, "sha512-pR4yQ9DHz6itqswtHCm26mw45FSNfQ9rEQjosaZErhn5J3J2sIViQiz8rDaezjKAhFGpmsoczYVBgGHzFw/stA=="],
|
||||
|
||||
"json-schema-traverse": ["json-schema-traverse@0.4.1", "", {}, "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="],
|
||||
"json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
||||
|
||||
"json-schema-typed": ["json-schema-typed@8.0.2", "", {}, "sha512-fQhoXdcvc3V28x7C7BMs4P5+kNlgUURe2jmUT1T//oBRMDrqy1QPelJimwZGo7Hg9VPV3EQV5Bnq4hbFy2vetA=="],
|
||||
|
||||
"json-stringify-deterministic": ["json-stringify-deterministic@1.0.12", "", {}, "sha512-q3PN0lbUdv0pmurkBNdJH3pfFvOTL/Zp0lquqpvcjfKzt6Y0j49EPHAmVHCAS4Ceq/Y+PejWTzyiVpoY71+D6g=="],
|
||||
|
||||
@@ -2485,7 +2479,7 @@
|
||||
|
||||
"mathml-tag-names": ["mathml-tag-names@2.1.3", "", {}, "sha512-APMBEanjybaPzUrfqU0IMU5I0AswKMH7k8OTLs0vvV4KZpExkTkY87nR/zpbuTPj+gARop7aGUbl11pnDfW6xg=="],
|
||||
|
||||
"mcp-handler": ["mcp-handler@1.0.2", "", { "dependencies": { "chalk": "^5.3.0", "commander": "^11.1.0", "redis": "^4.6.0" }, "peerDependencies": { "@modelcontextprotocol/sdk": "^1.12.0", "next": ">=13.0.0" }, "optionalPeers": ["next"], "bin": { "mcp-adapter": "dist/cli/index.js", "mcp-handler": "dist/cli/index.js", "create-mcp-route": "dist/cli/index.js" } }, "sha512-dTZR0KZ0rqIORHFUmG4wFMJwp608gtc2x602hxaFQOmb0L2Ahc++Vcc6QoRWr92VTK7DQmEIqrHbhVCjomTplg=="],
|
||||
"mcp-handler": ["mcp-handler@1.1.0", "", { "dependencies": { "chalk": "^5.3.0", "commander": "^11.1.0", "redis": "^4.6.0" }, "peerDependencies": { "@modelcontextprotocol/sdk": "1.26.0", "next": ">=13.0.0" }, "optionalPeers": ["next"], "bin": { "mcp-adapter": "dist/cli/index.js", "mcp-handler": "dist/cli/index.js", "create-mcp-route": "dist/cli/index.js" } }, "sha512-MVCES7g18gcoZy+R/3v5nadkUMzMAWdos8jRl6DyljOKvd2/ZKDmwlCjL6zp4vo+7FeCXOYL1uWinHWlkKAAUg=="],
|
||||
|
||||
"mdast-util-find-and-replace": ["mdast-util-find-and-replace@3.0.1", "", { "dependencies": { "@types/mdast": "^4.0.0", "escape-string-regexp": "^5.0.0", "unist-util-is": "^6.0.0", "unist-util-visit-parents": "^6.0.0" } }, "sha512-SG21kZHGC3XRTSUhtofZkBzZTJNM5ecCi0SK2IMKmSXR8vO3peL+kb1O0z7Zl83jKtutG4k5Wv/W7V3/YHvzPA=="],
|
||||
|
||||
@@ -2529,8 +2523,6 @@
|
||||
|
||||
"mermaid": ["mermaid@11.16.1", "", { "dependencies": { "@braintree/sanitize-url": "^7.1.2", "@iconify/utils": "^3.0.2", "@mermaid-js/parser": "^1.2.0", "@types/d3": "^7.4.3", "@upsetjs/venn.js": "^2.0.0", "cytoscape": "^3.33.3", "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.20", "dompurify": "^3.3.3", "es-toolkit": "^1.45.1", "katex": "^0.16.45", "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" } }, "sha512-TQsq6u22fAn3rek5VOubrhKPo1g5hwC3FXUN9hiyupTckcYiGuuKGkNQrKYwGJkXUxZdojwRG46gsSCFZMDp4g=="],
|
||||
|
||||
"methods": ["methods@1.1.2", "", {}, "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w=="],
|
||||
|
||||
"micro": ["micro@9.3.5-canary.3", "", { "dependencies": { "arg": "4.1.0", "content-type": "1.0.4", "raw-body": "2.4.1" }, "bin": { "micro": "./bin/micro.js" } }, "sha512-viYIo9PefV+w9dvoIBh1gI44Mvx1BOk67B4BpC2QK77qdY0xZF0Q+vWLt/BII6cLkIc8rLmSIcJaB/OrXXKe1g=="],
|
||||
|
||||
"microdiff": ["microdiff@1.5.0", "", {}, "sha512-Drq+/THMvDdzRYrK0oxJmOKiC24ayUV8ahrt8l3oRK51PWt6gdtrIGrlIH3pT/lFh1z93FbAcidtsHcWbnRz8Q=="],
|
||||
@@ -2667,7 +2659,7 @@
|
||||
|
||||
"object-identity": ["object-identity@0.2.1", "", {}, "sha512-itX2N4m0IvaLhFZMi9YkW4nFML6FshKCCpnn6iKJZVIkCNM/ZRaG4t1bzD2ncaW4r6cHJa59XY+7oZAH7tg8tA=="],
|
||||
|
||||
"object-inspect": ["object-inspect@1.13.2", "", {}, "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g=="],
|
||||
"object-inspect": ["object-inspect@1.13.4", "", {}, "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew=="],
|
||||
|
||||
"obliterator": ["obliterator@1.6.1", "", {}, "sha512-9WXswnqINnnhOG/5SLimUlzuU1hFJUc8zkwyD59Sd+dPOMf05PmnYG/d6Q7HZ+KmgkZJa1PxRso6QdM3sTNHig=="],
|
||||
|
||||
@@ -2825,7 +2817,7 @@
|
||||
|
||||
"punycode": ["punycode@2.3.1", "", {}, "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg=="],
|
||||
|
||||
"qs": ["qs@6.13.0", "", { "dependencies": { "side-channel": "^1.0.6" } }, "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg=="],
|
||||
"qs": ["qs@6.14.0", "", { "dependencies": { "side-channel": "^1.1.0" } }, "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w=="],
|
||||
|
||||
"quansync": ["quansync@0.2.11", "", {}, "sha512-AifT7QEbW9Nri4tAwR5M/uzpBuqfZf+zwaEM/QkzEjj7NBuFD2rBuy0K3dE+8wltbezDV7JMA0WfnCPYRSYbXA=="],
|
||||
|
||||
@@ -2843,7 +2835,7 @@
|
||||
|
||||
"range-parser": ["range-parser@1.2.1", "", {}, "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="],
|
||||
|
||||
"raw-body": ["raw-body@3.0.0", "", { "dependencies": { "bytes": "3.1.2", "http-errors": "2.0.0", "iconv-lite": "0.6.3", "unpipe": "1.0.0" } }, "sha512-RmkhL8CAyCRPXCE28MMH0z2PNWQBNk2Q09ZdxM9IOOXwxwZbN+qbWaatPkdkWIKL2ZVDImrN/pK5HTRz2PcS4g=="],
|
||||
"raw-body": ["raw-body@3.0.2", "", { "dependencies": { "bytes": "~3.1.2", "http-errors": "~2.0.1", "iconv-lite": "~0.7.0", "unpipe": "~1.0.0" } }, "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA=="],
|
||||
|
||||
"react": ["react@19.1.0", "", {}, "sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg=="],
|
||||
|
||||
@@ -2921,7 +2913,7 @@
|
||||
|
||||
"roughjs": ["roughjs@4.6.6", "", { "dependencies": { "hachure-fill": "^0.5.2", "path-data-parser": "^0.1.0", "points-on-curve": "^0.2.0", "points-on-path": "^0.2.1" } }, "sha512-ZUz/69+SYpFN/g/lUlo2FXcIjRkSu3nDarreVdGGndHEBJ6cXPdKguS8JGxwj5HA5xIbVKSmLgr5b3AWxtRfvQ=="],
|
||||
|
||||
"router": ["router@2.0.0", "", { "dependencies": { "array-flatten": "3.0.0", "is-promise": "4.0.0", "methods": "~1.1.2", "parseurl": "~1.3.3", "path-to-regexp": "^8.0.0", "setprototypeof": "1.2.0", "utils-merge": "1.0.1" } }, "sha512-dIM5zVoG8xhC6rnSN8uoAgFARwTE7BQs8YwHEvK0VCmfxQXMaOuA1uiR1IPwsW7JyK5iTt7Od/TC9StasS2NPQ=="],
|
||||
"router": ["router@2.2.0", "", { "dependencies": { "debug": "^4.4.0", "depd": "^2.0.0", "is-promise": "^4.0.0", "parseurl": "^1.3.3", "path-to-regexp": "^8.0.0" } }, "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ=="],
|
||||
|
||||
"rss-parser": ["rss-parser@3.13.0", "", { "dependencies": { "entities": "^2.0.3", "xml2js": "^0.5.0" } }, "sha512-7jWUBV5yGN3rqMMj7CZufl/291QAhvrrGpDNE4k/02ZchL0npisiYYqULF71jCEKoIiHvK/Q2e6IkDwPziT7+w=="],
|
||||
|
||||
@@ -2945,12 +2937,10 @@
|
||||
|
||||
"send": ["send@1.1.0", "", { "dependencies": { "debug": "^4.3.5", "destroy": "^1.2.0", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "etag": "^1.8.1", "fresh": "^0.5.2", "http-errors": "^2.0.0", "mime-types": "^2.1.35", "ms": "^2.1.3", "on-finished": "^2.4.1", "range-parser": "^1.2.1", "statuses": "^2.0.1" } }, "sha512-v67WcEouB5GxbTWL/4NeToqcZiAWEq90N888fczVArY8A79J0L4FD7vj5hm3eUMua5EpoQ59wa/oovY6TLvRUA=="],
|
||||
|
||||
"serve-static": ["serve-static@2.1.0", "", { "dependencies": { "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "parseurl": "^1.3.3", "send": "^1.0.0" } }, "sha512-A3We5UfEjG8Z7VkDv6uItWw6HY2bBSBJT1KtVESn6EOoOr2jAxNhxWCLY3jDE2WcuHXByWju74ck3ZgLwL8xmA=="],
|
||||
"serve-static": ["serve-static@2.2.0", "", { "dependencies": { "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "parseurl": "^1.3.3", "send": "^1.2.0" } }, "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ=="],
|
||||
|
||||
"server-only": ["server-only@0.0.1", "", {}, "sha512-qepMx2JxAa5jjfzxG79yPPq+8BuFToHd1hm7kI+Z4zAq1ftQiP7HcxMhDDItrbtwVeLg/cY2JnKnrcFkmiswNA=="],
|
||||
|
||||
"set-function-length": ["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.2.4", "gopd": "^1.0.1", "has-property-descriptors": "^1.0.2" } }, "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg=="],
|
||||
|
||||
"setprototypeof": ["setprototypeof@1.2.0", "", {}, "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="],
|
||||
|
||||
"sharp": ["sharp@0.35.5", "", { "dependencies": { "@img/colour": "^1.1.0", "detect-libc": "^2.1.2", "semver": "^7.8.5" }, "optionalDependencies": { "@img/sharp-darwin-arm64": "0.35.5", "@img/sharp-darwin-x64": "0.35.5", "@img/sharp-freebsd-wasm32": "0.35.5", "@img/sharp-libvips-darwin-arm64": "1.3.4", "@img/sharp-libvips-darwin-x64": "1.3.4", "@img/sharp-libvips-linux-arm": "1.3.4", "@img/sharp-libvips-linux-arm64": "1.3.4", "@img/sharp-libvips-linux-ppc64": "1.3.4", "@img/sharp-libvips-linux-riscv64": "1.3.4", "@img/sharp-libvips-linux-s390x": "1.3.4", "@img/sharp-libvips-linux-x64": "1.3.4", "@img/sharp-libvips-linuxmusl-arm64": "1.3.4", "@img/sharp-libvips-linuxmusl-x64": "1.3.4", "@img/sharp-linux-arm": "0.35.5", "@img/sharp-linux-arm64": "0.35.5", "@img/sharp-linux-ppc64": "0.35.5", "@img/sharp-linux-riscv64": "0.35.5", "@img/sharp-linux-s390x": "0.35.5", "@img/sharp-linux-x64": "0.35.5", "@img/sharp-linuxmusl-arm64": "0.35.5", "@img/sharp-linuxmusl-x64": "0.35.5", "@img/sharp-webcontainers-wasm32": "0.35.5", "@img/sharp-win32-arm64": "0.35.5", "@img/sharp-win32-ia32": "0.35.5", "@img/sharp-win32-x64": "0.35.5" }, "peerDependencies": { "@types/node": "*" }, "optionalPeers": ["@types/node"] }, "sha512-Ywn4OnzGukp7CDMrp08RQ50YKmuwG47brZgIVPTvBaaAfQlRlygrRqSrxdCiL9M+LlzLBiJ68IR1QqvzHyjC7g=="],
|
||||
@@ -2963,7 +2953,7 @@
|
||||
|
||||
"shiki": ["shiki@3.21.0", "", { "dependencies": { "@shikijs/core": "3.21.0", "@shikijs/engine-javascript": "3.21.0", "@shikijs/engine-oniguruma": "3.21.0", "@shikijs/langs": "3.21.0", "@shikijs/themes": "3.21.0", "@shikijs/types": "3.21.0", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-N65B/3bqL/TI2crrXr+4UivctrAGEjmsib5rPMMPpFp1xAx/w03v8WZ9RDDFYteXoEgY7qZ4HGgl5KBIu1153w=="],
|
||||
|
||||
"side-channel": ["side-channel@1.0.6", "", { "dependencies": { "call-bind": "^1.0.7", "es-errors": "^1.3.0", "get-intrinsic": "^1.2.4", "object-inspect": "^1.13.1" } }, "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA=="],
|
||||
"side-channel": ["side-channel@1.1.0", "", { "dependencies": { "es-errors": "^1.3.0", "object-inspect": "^1.13.3", "side-channel-list": "^1.0.0", "side-channel-map": "^1.0.1", "side-channel-weakmap": "^1.0.2" } }, "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw=="],
|
||||
|
||||
"side-channel-list": ["side-channel-list@1.0.0", "", { "dependencies": { "es-errors": "^1.3.0", "object-inspect": "^1.13.3" } }, "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA=="],
|
||||
|
||||
@@ -3137,7 +3127,7 @@
|
||||
|
||||
"type-fest": ["type-fest@5.0.0", "", { "dependencies": { "tagged-tag": "^1.0.0" } }, "sha512-GeJop7+u7BYlQ6yQCAY1nBQiRSHR+6OdCEtd8Bwp9a3NK3+fWAVjOaPKJDteB9f6cIJ0wt4IfnScjLG450EpXA=="],
|
||||
|
||||
"type-is": ["type-is@2.0.0", "", { "dependencies": { "content-type": "^1.0.5", "media-typer": "^1.1.0", "mime-types": "^3.0.0" } }, "sha512-gd0sGezQYCbWSbkZr75mln4YBidWUN60+devscpLF5mtRDUpiaTvKpBNrdaCvel1NdR2k6vclXybU5fBd2i+nw=="],
|
||||
"type-is": ["type-is@2.0.1", "", { "dependencies": { "content-type": "^1.0.5", "media-typer": "^1.1.0", "mime-types": "^3.0.0" } }, "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw=="],
|
||||
|
||||
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
||||
|
||||
@@ -3191,8 +3181,6 @@
|
||||
|
||||
"util-deprecate": ["util-deprecate@1.0.2", "", {}, "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="],
|
||||
|
||||
"utils-merge": ["utils-merge@1.0.1", "", {}, "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA=="],
|
||||
|
||||
"uuid": ["uuid@11.1.0", "", { "bin": { "uuid": "dist/esm/bin/uuid" } }, "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A=="],
|
||||
|
||||
"vary": ["vary@1.1.2", "", {}, "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg=="],
|
||||
@@ -3283,7 +3271,7 @@
|
||||
|
||||
"youch-core": ["youch-core@0.3.3", "", { "dependencies": { "@poppinss/exception": "^1.2.2", "error-stack-parser-es": "^1.0.5" } }, "sha512-ho7XuGjLaJ2hWHoK8yFnsUGy2Y5uDpqSTq1FkHLK4/oqKtyUU1AFbOOxY4IpC9f0fTLjwYbslUz0Po5BpD1wrA=="],
|
||||
|
||||
"zod": ["zod@3.24.2", "", {}, "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ=="],
|
||||
"zod": ["zod@3.25.76", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
|
||||
|
||||
"zod-to-json-schema": ["zod-to-json-schema@3.25.1", "", { "peerDependencies": { "zod": "^3.25 || ^4" } }, "sha512-pM/SU9d3YAggzi6MtR4h7ruuQlqKtad8e9S0fmxcMi+ueAK5Korys/aWcV9LIIHTVbj01NdzxcnXSN+O74ZIVA=="],
|
||||
|
||||
@@ -3447,9 +3435,7 @@
|
||||
|
||||
"@modelcontextprotocol/sdk/cross-spawn": ["cross-spawn@7.0.6", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA=="],
|
||||
|
||||
"@modelcontextprotocol/sdk/zod-to-json-schema": ["zod-to-json-schema@3.24.5", "", { "peerDependencies": { "zod": "^3.24.1" } }, "sha512-/AuWwMP+YqiPbsJx5D6TfgRTc4kTLjsh5SOcd4bLsfUg2RcEXrFMJl1DGgdHy2aCfsIA/cr/1JM0xcB2GZji8g=="],
|
||||
|
||||
"@opennextjs/aws/express": ["express@5.2.1", "", { "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.1", "content-disposition": "^1.0.0", "content-type": "^1.0.5", "cookie": "^0.7.1", "cookie-signature": "^1.2.1", "debug": "^4.4.0", "depd": "^2.0.0", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "etag": "^1.8.1", "finalhandler": "^2.1.0", "fresh": "^2.0.0", "http-errors": "^2.0.0", "merge-descriptors": "^2.0.0", "mime-types": "^3.0.0", "on-finished": "^2.4.1", "once": "^1.4.0", "parseurl": "^1.3.3", "proxy-addr": "^2.0.7", "qs": "^6.14.0", "range-parser": "^1.2.1", "router": "^2.2.0", "send": "^1.1.0", "serve-static": "^2.2.0", "statuses": "^2.0.1", "type-is": "^2.0.1", "vary": "^1.1.2" } }, "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw=="],
|
||||
"@modelcontextprotocol/sdk/jose": ["jose@6.2.18", "", {}, "sha512-doV4thUwgkrycJH4yLeqwTGIIZphHl+pk7CPReuMIhYhncmgzdko85MaCG4YQFTxqMFr1/oEH32tZuKKovcDEg=="],
|
||||
|
||||
"@oxc-transform/binding-wasm32-wasi/@napi-rs/wasm-runtime": ["@napi-rs/wasm-runtime@1.1.1", "", { "dependencies": { "@emnapi/core": "^1.7.1", "@emnapi/runtime": "^1.7.1", "@tybys/wasm-util": "^0.10.1" } }, "sha512-p64ah1M1ld8xjWv3qbvFwHiFVWrq1yFvV4f7w+mzaqiR4IlSgkqhcRdHwsGgomwzBH51sRY4NEowLxnaBjcW/A=="],
|
||||
|
||||
@@ -3527,8 +3513,6 @@
|
||||
|
||||
"@scalar/json-schema-validator/@scalar/types": ["@scalar/types@0.26.0", "", { "dependencies": { "@scalar/helpers": "0.16.4", "nanoid": "^5.1.16", "type-fest": "^5.10.0", "zod": "^4.6.7" } }, "sha512-T78Dj1Q+W0E1RsMyPoydfR+L+p9IUIkntBCRYlWaRibM98jAxABRYGQoU/qDHX0PR1IAFdE+d7ZqslypZbJzcg=="],
|
||||
|
||||
"@scalar/json-schema-validator/ajv": ["ajv@8.20.0", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2" } }, "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA=="],
|
||||
|
||||
"@scalar/oas-utils/@scalar/helpers": ["@scalar/helpers@0.1.1", "", {}, "sha512-eJjuCI5djqU0adTwrHvpDf0xuwNRpwZinCfJ03QjnmIFBM9Ch0u3tn/0EZOhcVNbdEyJ+3yvSVy1dCmmvgtpvQ=="],
|
||||
|
||||
"@scalar/oas-utils/@scalar/json-magic": ["@scalar/json-magic@0.8.1", "", { "dependencies": { "@scalar/helpers": "0.1.1", "xxhash-wasm": "^1.1.0", "yaml": "2.8.0" } }, "sha512-PtG0gJxw+iE9492pqy9V+ZbnfRnycIxTAxknKQCOGRyFYfDvYSs0/uyFCHoQPl7HEZoNNA7q/fr0LBZXMRzv7g=="],
|
||||
@@ -3697,8 +3681,6 @@
|
||||
|
||||
"acorn-walk/acorn": ["acorn@8.12.1", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg=="],
|
||||
|
||||
"ajv-draft-04/ajv": ["ajv@8.17.1", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2" } }, "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g=="],
|
||||
|
||||
"ajv-formats/ajv": ["ajv@8.17.1", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2" } }, "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g=="],
|
||||
|
||||
"anymatch/picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
|
||||
@@ -3707,18 +3689,10 @@
|
||||
|
||||
"ast-kit/pathe": ["pathe@2.0.3", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="],
|
||||
|
||||
"body-parser/debug": ["debug@3.1.0", "", { "dependencies": { "ms": "2.0.0" } }, "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g=="],
|
||||
|
||||
"body-parser/iconv-lite": ["iconv-lite@0.5.2", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3" } }, "sha512-kERHXvpSaB4aU3eANwidg79K8FlrN77m8G9V+0vOR3HYaRifrlwMEpT7ZBJqLSEIHnEgJTHcWK82wwLwwKwtag=="],
|
||||
|
||||
"body-parser/type-is": ["type-is@1.6.18", "", { "dependencies": { "media-typer": "0.3.0", "mime-types": "~2.1.24" } }, "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g=="],
|
||||
|
||||
"brace-expansion/balanced-match": ["balanced-match@4.0.4", "", {}, "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA=="],
|
||||
|
||||
"bun-types/@types/node": ["@types/node@20.12.14", "", { "dependencies": { "undici-types": "~5.26.4" } }, "sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg=="],
|
||||
|
||||
"call-bound/get-intrinsic": ["get-intrinsic@1.3.0", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "es-define-property": "^1.0.1", "es-errors": "^1.3.0", "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", "get-proto": "^1.0.1", "gopd": "^1.2.0", "has-symbols": "^1.1.0", "hasown": "^2.0.2", "math-intrinsics": "^1.1.0" } }, "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ=="],
|
||||
|
||||
"cliui/string-width": ["string-width@7.2.0", "", { "dependencies": { "emoji-regex": "^10.3.0", "get-east-asian-width": "^1.0.0", "strip-ansi": "^7.1.0" } }, "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ=="],
|
||||
|
||||
"cliui/strip-ansi": ["strip-ansi@7.1.0", "", { "dependencies": { "ansi-regex": "^6.0.1" } }, "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ=="],
|
||||
@@ -3761,8 +3735,6 @@
|
||||
|
||||
"dom-serializer/entities": ["entities@4.5.0", "", {}, "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw=="],
|
||||
|
||||
"dunder-proto/gopd": ["gopd@1.2.0", "", {}, "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg=="],
|
||||
|
||||
"duplexify/end-of-stream": ["end-of-stream@1.4.4", "", { "dependencies": { "once": "^1.4.0" } }, "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q=="],
|
||||
|
||||
"duplexify/readable-stream": ["readable-stream@3.6.2", "", { "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", "util-deprecate": "^1.0.1" } }, "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA=="],
|
||||
@@ -3783,20 +3755,16 @@
|
||||
|
||||
"express/cookie": ["cookie@0.7.1", "", {}, "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w=="],
|
||||
|
||||
"express/debug": ["debug@4.3.6", "", { "dependencies": { "ms": "2.1.2" } }, "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg=="],
|
||||
|
||||
"express/mime-types": ["mime-types@3.0.0", "", { "dependencies": { "mime-db": "^1.53.0" } }, "sha512-XqoSHeCGjVClAmoGFG3lVFqQFRIrTVw2OH3axRqAcfaw+gHWIfnASS92AV+Rl/mk0MupgZTRHQOjxY6YVnzK5w=="],
|
||||
|
||||
"finalhandler/debug": ["debug@2.6.9", "", { "dependencies": { "ms": "2.0.0" } }, "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA=="],
|
||||
|
||||
"finalhandler/encodeurl": ["encodeurl@1.0.2", "", {}, "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w=="],
|
||||
|
||||
"global-prefix/which": ["which@1.3.1", "", { "dependencies": { "isexe": "^2.0.0" }, "bin": { "which": "./bin/which" } }, "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ=="],
|
||||
|
||||
"globby/fast-glob": ["fast-glob@3.3.2", "", { "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", "glob-parent": "^5.1.2", "merge2": "^1.3.0", "micromatch": "^4.0.4" } }, "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow=="],
|
||||
|
||||
"globby/ignore": ["ignore@5.3.2", "", {}, "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g=="],
|
||||
|
||||
"google-font-metadata/zod": ["zod@3.24.2", "", {}, "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ=="],
|
||||
|
||||
"htmlparser2/entities": ["entities@6.0.1", "", {}, "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g=="],
|
||||
|
||||
"https-proxy-agent/debug": ["debug@4.4.0", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA=="],
|
||||
@@ -3809,8 +3777,6 @@
|
||||
|
||||
"lowlight/highlight.js": ["highlight.js@11.9.0", "", {}, "sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw=="],
|
||||
|
||||
"mcp-handler/chalk": ["chalk@5.4.1", "", {}, "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w=="],
|
||||
|
||||
"mcp-handler/commander": ["commander@11.1.0", "", {}, "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ=="],
|
||||
|
||||
"mdast-util-gfm-footnote/mdast-util-from-markdown": ["mdast-util-from-markdown@2.0.1", "", { "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", "decode-named-character-reference": "^1.0.0", "devlop": "^1.0.0", "mdast-util-to-string": "^4.0.0", "micromark": "^4.0.0", "micromark-util-decode-numeric-character-reference": "^2.0.0", "micromark-util-decode-string": "^2.0.0", "micromark-util-normalize-identifier": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0", "unist-util-stringify-position": "^4.0.0" } }, "sha512-aJEUyzZ6TzlsX2s5B4Of7lN7EQtAxvtradMMglCQDyaTFgse6CmtmdJ15ElnVRlCg1vpNyVtbem0PWzlNieZsA=="],
|
||||
@@ -3875,7 +3841,7 @@
|
||||
|
||||
"radix-vue/nanoid": ["nanoid@5.0.7", "", { "bin": { "nanoid": "bin/nanoid.js" } }, "sha512-oLxFY2gd2IqnjcYyOXD8XGCftpGtZP2AbHbOkthDkvRywH5ayNtPVy9YlOPcHckXzbLTCHpkb7FB+yuxKV13pQ=="],
|
||||
|
||||
"raw-body/iconv-lite": ["iconv-lite@0.6.3", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw=="],
|
||||
"raw-body/http-errors": ["http-errors@2.0.1", "", { "dependencies": { "depd": "~2.0.0", "inherits": "~2.0.4", "setprototypeof": "~1.2.0", "statuses": "~2.0.2", "toidentifier": "~1.0.1" } }, "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ=="],
|
||||
|
||||
"read-cache/pify": ["pify@2.3.0", "", {}, "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog=="],
|
||||
|
||||
@@ -3899,17 +3865,11 @@
|
||||
|
||||
"send/fresh": ["fresh@0.5.2", "", {}, "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q=="],
|
||||
|
||||
"serve-static/send": ["send@1.2.0", "", { "dependencies": { "debug": "^4.3.5", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "etag": "^1.8.1", "fresh": "^2.0.0", "http-errors": "^2.0.0", "mime-types": "^3.0.1", "ms": "^2.1.3", "on-finished": "^2.4.1", "range-parser": "^1.2.1", "statuses": "^2.0.1" } }, "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw=="],
|
||||
|
||||
"sharp/detect-libc": ["detect-libc@2.1.2", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="],
|
||||
|
||||
"side-channel-list/object-inspect": ["object-inspect@1.13.4", "", {}, "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew=="],
|
||||
|
||||
"side-channel-map/get-intrinsic": ["get-intrinsic@1.3.0", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "es-define-property": "^1.0.1", "es-errors": "^1.3.0", "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", "get-proto": "^1.0.1", "gopd": "^1.2.0", "has-symbols": "^1.1.0", "hasown": "^2.0.2", "math-intrinsics": "^1.1.0" } }, "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ=="],
|
||||
|
||||
"side-channel-map/object-inspect": ["object-inspect@1.13.4", "", {}, "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew=="],
|
||||
|
||||
"side-channel-weakmap/get-intrinsic": ["get-intrinsic@1.3.0", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "es-define-property": "^1.0.1", "es-errors": "^1.3.0", "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", "get-proto": "^1.0.1", "gopd": "^1.2.0", "has-symbols": "^1.1.0", "hasown": "^2.0.2", "math-intrinsics": "^1.1.0" } }, "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ=="],
|
||||
|
||||
"side-channel-weakmap/object-inspect": ["object-inspect@1.13.4", "", {}, "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew=="],
|
||||
"socks/ip-address": ["ip-address@10.1.0", "", {}, "sha512-XXADHxXmvT9+CRxhXg56LJovE+bmWnEWB78LB83VZTprKTmaC5QfruXocxzTZ2Kl0DNwKuBdlIhjL8LeY8Sf8Q=="],
|
||||
|
||||
"spawndamnit/cross-spawn": ["cross-spawn@7.0.6", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA=="],
|
||||
|
||||
@@ -3947,8 +3907,6 @@
|
||||
|
||||
"youch/cookie": ["cookie@1.0.2", "", {}, "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA=="],
|
||||
|
||||
"zod-to-json-schema/zod": ["zod@4.6.7", "", {}, "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg=="],
|
||||
|
||||
"@ampproject/remapping/@jridgewell/gen-mapping/@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.5.0", "", {}, "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ=="],
|
||||
|
||||
"@ampproject/remapping/@jridgewell/trace-mapping/@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.5.0", "", {}, "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ=="],
|
||||
@@ -4059,22 +4017,6 @@
|
||||
|
||||
"@jridgewell/source-map/@jridgewell/trace-mapping/@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.5.0", "", {}, "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ=="],
|
||||
|
||||
"@opennextjs/aws/express/body-parser": ["body-parser@2.2.1", "", { "dependencies": { "bytes": "^3.1.2", "content-type": "^1.0.5", "debug": "^4.4.3", "http-errors": "^2.0.0", "iconv-lite": "^0.7.0", "on-finished": "^2.4.1", "qs": "^6.14.0", "raw-body": "^3.0.1", "type-is": "^2.0.1" } }, "sha512-nfDwkulwiZYQIGwxdy0RUmowMhKcFVcYXUU7m4QlKYim1rUtg83xm2yjZ40QjDuc291AJjjeSc9b++AWHSgSHw=="],
|
||||
|
||||
"@opennextjs/aws/express/cookie": ["cookie@0.7.1", "", {}, "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w=="],
|
||||
|
||||
"@opennextjs/aws/express/finalhandler": ["finalhandler@2.1.1", "", { "dependencies": { "debug": "^4.4.0", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "on-finished": "^2.4.1", "parseurl": "^1.3.3", "statuses": "^2.0.1" } }, "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA=="],
|
||||
|
||||
"@opennextjs/aws/express/mime-types": ["mime-types@3.0.0", "", { "dependencies": { "mime-db": "^1.53.0" } }, "sha512-XqoSHeCGjVClAmoGFG3lVFqQFRIrTVw2OH3axRqAcfaw+gHWIfnASS92AV+Rl/mk0MupgZTRHQOjxY6YVnzK5w=="],
|
||||
|
||||
"@opennextjs/aws/express/qs": ["qs@6.14.0", "", { "dependencies": { "side-channel": "^1.1.0" } }, "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w=="],
|
||||
|
||||
"@opennextjs/aws/express/router": ["router@2.2.0", "", { "dependencies": { "debug": "^4.4.0", "depd": "^2.0.0", "is-promise": "^4.0.0", "parseurl": "^1.3.3", "path-to-regexp": "^8.0.0" } }, "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ=="],
|
||||
|
||||
"@opennextjs/aws/express/serve-static": ["serve-static@2.2.0", "", { "dependencies": { "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "parseurl": "^1.3.3", "send": "^1.2.0" } }, "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ=="],
|
||||
|
||||
"@opennextjs/aws/express/type-is": ["type-is@2.0.1", "", { "dependencies": { "content-type": "^1.0.5", "media-typer": "^1.1.0", "mime-types": "^3.0.0" } }, "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw=="],
|
||||
|
||||
"@oxc-transform/binding-wasm32-wasi/@napi-rs/wasm-runtime/@emnapi/core": ["@emnapi/core@1.8.1", "", { "dependencies": { "@emnapi/wasi-threads": "1.1.0", "tslib": "^2.4.0" } }, "sha512-AvT9QFpxK0Zd8J0jopedNm+w/2fIzvtPKPjqyw9jwvBaReTTqPBk9Hixaz7KbjimP+QNz605/XnjFcDAL2pqBg=="],
|
||||
|
||||
"@oxc-transform/binding-wasm32-wasi/@napi-rs/wasm-runtime/@emnapi/runtime": ["@emnapi/runtime@1.8.1", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-mehfKSMWjjNol8659Z8KxEMrdSJDDot5SXMq00dM8BN4o+CLNXQ0xH2V7EchNHV4RmbZLmmPdEaXZc5H2FXmDg=="],
|
||||
@@ -4137,8 +4079,6 @@
|
||||
|
||||
"@scalar/json-schema-validator/@scalar/types/zod": ["zod@4.6.7", "", {}, "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg=="],
|
||||
|
||||
"@scalar/json-schema-validator/ajv/json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
||||
|
||||
"@scalar/openapi-parser/@scalar/types/nanoid": ["nanoid@5.1.16", "", { "bin": { "nanoid": "bin/nanoid.js" } }, "sha512-kVrnsrJqMR8+oLJnGEmSWw9BivK5mt7H3FZatVRjrc5wGqFYuBxX1yG7+A7Gi5AefkX6t/oCkizcQgpu0cY1dQ=="],
|
||||
|
||||
"@scalar/openapi-parser/@scalar/types/type-fest": ["type-fest@5.10.0", "", { "dependencies": { "tagged-tag": "^1.0.0" } }, "sha512-NoSdpq/WEiAg5sjmBkmV/hfxv6HJH4NqPNrqjtSO5CwRmpsDfaf4begxW34KdJykH/l1yHtwBWQkCRdoXO8mPA=="],
|
||||
@@ -4271,8 +4211,6 @@
|
||||
|
||||
"@vercel/rust/execa/signal-exit": ["signal-exit@3.0.7", "", {}, "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ=="],
|
||||
|
||||
"@vercel/static-config/ajv/json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
||||
|
||||
"@vue/compiler-core/@babel/parser/@babel/types": ["@babel/types@7.28.2", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.27.1" } }, "sha512-ruv7Ae4J5dUYULmeXw1gmb7rYRz57OWCPM57pHojnLq/3Z1CK2lNSLTCVjxVk1F/TZHwOZZrOWi0ur95BbLxNQ=="],
|
||||
|
||||
"@vue/compiler-sfc/@babel/parser/@babel/types": ["@babel/types@7.28.2", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.27.1" } }, "sha512-ruv7Ae4J5dUYULmeXw1gmb7rYRz57OWCPM57pHojnLq/3Z1CK2lNSLTCVjxVk1F/TZHwOZZrOWi0ur95BbLxNQ=="],
|
||||
@@ -4293,22 +4231,8 @@
|
||||
|
||||
"accepts/mime-types/mime-db": ["mime-db@1.53.0", "", {}, "sha512-oHlN/w+3MQ3rba9rqFr6V/ypF10LSkdwUysQL7GkXoTgIWeV+tcXGA852TBxH+gsh8UWoyhR1hKcoMJTuWflpg=="],
|
||||
|
||||
"ajv-draft-04/ajv/json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
||||
|
||||
"ajv-formats/ajv/json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
||||
|
||||
"body-parser/debug/ms": ["ms@2.0.0", "", {}, "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="],
|
||||
|
||||
"body-parser/type-is/media-typer": ["media-typer@0.3.0", "", {}, "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ=="],
|
||||
|
||||
"bun-types/@types/node/undici-types": ["undici-types@5.26.5", "", {}, "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="],
|
||||
|
||||
"call-bound/get-intrinsic/es-define-property": ["es-define-property@1.0.1", "", {}, "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g=="],
|
||||
|
||||
"call-bound/get-intrinsic/gopd": ["gopd@1.2.0", "", {}, "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg=="],
|
||||
|
||||
"call-bound/get-intrinsic/has-symbols": ["has-symbols@1.1.0", "", {}, "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ=="],
|
||||
|
||||
"cliui/string-width/emoji-regex": ["emoji-regex@10.4.0", "", {}, "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw=="],
|
||||
|
||||
"cliui/string-width/get-east-asian-width": ["get-east-asian-width@1.3.0", "", {}, "sha512-vpeMIQKxczTD/0s2CdEWHcb0eeJe6TFjxb+J5xgX7hScxqrGuyjmv4c1D4A/gelKfyox0gJJwIHF+fLjeaM8kQ=="],
|
||||
@@ -4337,12 +4261,8 @@
|
||||
|
||||
"edge-runtime/pretty-ms/parse-ms": ["parse-ms@2.1.0", "", {}, "sha512-kHt7kzLoS9VBZfUsiKjv43mr91ea+U05EyKkEtqp7vNbHxmaVuEqN7XxeEVnGrMtYOAxGrDElSi96K7EgO1zCA=="],
|
||||
|
||||
"express/debug/ms": ["ms@2.1.2", "", {}, "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="],
|
||||
|
||||
"express/mime-types/mime-db": ["mime-db@1.53.0", "", {}, "sha512-oHlN/w+3MQ3rba9rqFr6V/ypF10LSkdwUysQL7GkXoTgIWeV+tcXGA852TBxH+gsh8UWoyhR1hKcoMJTuWflpg=="],
|
||||
|
||||
"finalhandler/debug/ms": ["ms@2.0.0", "", {}, "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="],
|
||||
|
||||
"micro/raw-body/bytes": ["bytes@3.1.0", "", {}, "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg=="],
|
||||
|
||||
"micro/raw-body/http-errors": ["http-errors@1.7.3", "", { "dependencies": { "depd": "~1.1.2", "inherits": "2.0.4", "setprototypeof": "1.1.1", "statuses": ">= 1.5.0 < 2", "toidentifier": "1.0.0" } }, "sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw=="],
|
||||
@@ -4415,6 +4335,8 @@
|
||||
|
||||
"radix-vue/@vueuse/core/@vueuse/metadata": ["@vueuse/metadata@10.11.1", "", {}, "sha512-IGa5FXd003Ug1qAZmyE8wF3sJ81xGLSqTqtQ6jaVfkeZ4i5kS2mwQF61yhVqojRnenVew5PldLyRgvdl4YYuSw=="],
|
||||
|
||||
"raw-body/http-errors/statuses": ["statuses@2.0.2", "", {}, "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw=="],
|
||||
|
||||
"read-yaml-file/js-yaml/argparse": ["argparse@1.0.10", "", { "dependencies": { "sprintf-js": "~1.0.2" } }, "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg=="],
|
||||
|
||||
"remark-gfm/mdast-util-gfm/mdast-util-from-markdown": ["mdast-util-from-markdown@2.0.1", "", { "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", "decode-named-character-reference": "^1.0.0", "devlop": "^1.0.0", "mdast-util-to-string": "^4.0.0", "micromark": "^4.0.0", "micromark-util-decode-numeric-character-reference": "^2.0.0", "micromark-util-decode-string": "^2.0.0", "micromark-util-normalize-identifier": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0", "unist-util-stringify-position": "^4.0.0" } }, "sha512-aJEUyzZ6TzlsX2s5B4Of7lN7EQtAxvtradMMglCQDyaTFgse6CmtmdJ15ElnVRlCg1vpNyVtbem0PWzlNieZsA=="],
|
||||
@@ -4427,24 +4349,12 @@
|
||||
|
||||
"rimraf/glob/path-scurry": ["path-scurry@1.11.1", "", { "dependencies": { "lru-cache": "^10.2.0", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" } }, "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA=="],
|
||||
|
||||
"side-channel-map/get-intrinsic/es-define-property": ["es-define-property@1.0.1", "", {}, "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g=="],
|
||||
|
||||
"side-channel-map/get-intrinsic/gopd": ["gopd@1.2.0", "", {}, "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg=="],
|
||||
|
||||
"side-channel-map/get-intrinsic/has-symbols": ["has-symbols@1.1.0", "", {}, "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ=="],
|
||||
|
||||
"side-channel-weakmap/get-intrinsic/es-define-property": ["es-define-property@1.0.1", "", {}, "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g=="],
|
||||
|
||||
"side-channel-weakmap/get-intrinsic/gopd": ["gopd@1.2.0", "", {}, "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg=="],
|
||||
|
||||
"side-channel-weakmap/get-intrinsic/has-symbols": ["has-symbols@1.1.0", "", {}, "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ=="],
|
||||
"serve-static/send/mime-types": ["mime-types@3.0.2", "", { "dependencies": { "mime-db": "^1.54.0" } }, "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A=="],
|
||||
|
||||
"stylelint-no-unsupported-browser-features/postcss/nanoid": ["nanoid@3.3.11", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="],
|
||||
|
||||
"stylelint/postcss/nanoid": ["nanoid@3.3.8", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w=="],
|
||||
|
||||
"table/ajv/json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
||||
|
||||
"type-is/mime-types/mime-db": ["mime-db@1.53.0", "", {}, "sha512-oHlN/w+3MQ3rba9rqFr6V/ypF10LSkdwUysQL7GkXoTgIWeV+tcXGA852TBxH+gsh8UWoyhR1hKcoMJTuWflpg=="],
|
||||
|
||||
"wrap-ansi/string-width/emoji-regex": ["emoji-regex@10.4.0", "", {}, "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw=="],
|
||||
@@ -4473,20 +4383,6 @@
|
||||
|
||||
"@headlessui/react/@floating-ui/react/@floating-ui/react-dom/@floating-ui/dom": ["@floating-ui/dom@1.7.5", "", { "dependencies": { "@floating-ui/core": "^1.7.4", "@floating-ui/utils": "^0.2.10" } }, "sha512-N0bD2kIPInNHUHehXhMke1rBGs1dwqvC9O9KYMyyjK7iXt7GAhnro7UlcuYcGdS/yYOlq0MAVgrow8IbWJwyqg=="],
|
||||
|
||||
"@opennextjs/aws/express/body-parser/raw-body": ["raw-body@3.0.2", "", { "dependencies": { "bytes": "~3.1.2", "http-errors": "~2.0.1", "iconv-lite": "~0.7.0", "unpipe": "~1.0.0" } }, "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA=="],
|
||||
|
||||
"@opennextjs/aws/express/mime-types/mime-db": ["mime-db@1.53.0", "", {}, "sha512-oHlN/w+3MQ3rba9rqFr6V/ypF10LSkdwUysQL7GkXoTgIWeV+tcXGA852TBxH+gsh8UWoyhR1hKcoMJTuWflpg=="],
|
||||
|
||||
"@opennextjs/aws/express/qs/side-channel": ["side-channel@1.1.0", "", { "dependencies": { "es-errors": "^1.3.0", "object-inspect": "^1.13.3", "side-channel-list": "^1.0.0", "side-channel-map": "^1.0.1", "side-channel-weakmap": "^1.0.2" } }, "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw=="],
|
||||
|
||||
"@opennextjs/aws/express/router/is-promise": ["is-promise@4.0.0", "", {}, "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ=="],
|
||||
|
||||
"@opennextjs/aws/express/router/path-to-regexp": ["path-to-regexp@8.2.0", "", {}, "sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ=="],
|
||||
|
||||
"@opennextjs/aws/express/serve-static/send": ["send@1.2.0", "", { "dependencies": { "debug": "^4.3.5", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "etag": "^1.8.1", "fresh": "^2.0.0", "http-errors": "^2.0.0", "mime-types": "^3.0.1", "ms": "^2.1.3", "on-finished": "^2.4.1", "range-parser": "^1.2.1", "statuses": "^2.0.1" } }, "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw=="],
|
||||
|
||||
"@scalar/api-client/@scalar/openapi-parser/ajv/json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
||||
|
||||
"@scalar/components/@scalar/oas-utils/@scalar/workspace-store/@scalar/openapi-upgrader": ["@scalar/openapi-upgrader@0.1.3", "", { "dependencies": { "@scalar/openapi-types": "0.5.0" } }, "sha512-iROhcgy3vge6zsviPtoTLHale0nYt1PLhuMmJweQwJ0U23ZYyYhV5xgHtAd0OBEXuqT6rjYbJFvKOJZmJOwpNQ=="],
|
||||
|
||||
"@scalar/components/@scalar/themes/@scalar/types/@scalar/openapi-types": ["@scalar/openapi-types@0.5.0", "", { "dependencies": { "zod": "4.1.11" } }, "sha512-HJBcLa+/mPP+3TCcQngj/iW5UqynRosOQdEETXjmdy6Ngw8wBjwIcT6C86J5jufJ6sI8++HYnt+e7pAvp5FO6A=="],
|
||||
@@ -4501,8 +4397,6 @@
|
||||
|
||||
"@scalar/import/@scalar/openapi-parser/@scalar/openapi-types/zod": ["zod@4.1.11", "", {}, "sha512-WPsqwxITS2tzx1bzhIKsEs19ABD5vmCVa4xBo2tq/SrV4RNZtfws1EnCWQXM6yh8bD08a1idvkB5MZSBiZsjwg=="],
|
||||
|
||||
"@scalar/import/@scalar/openapi-parser/ajv/json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
||||
|
||||
"@scalar/postman-to-openapi/@scalar/oas-utils/@scalar/workspace-store/@scalar/openapi-upgrader": ["@scalar/openapi-upgrader@0.1.3", "", { "dependencies": { "@scalar/openapi-types": "0.5.0" } }, "sha512-iROhcgy3vge6zsviPtoTLHale0nYt1PLhuMmJweQwJ0U23ZYyYhV5xgHtAd0OBEXuqT6rjYbJFvKOJZmJOwpNQ=="],
|
||||
|
||||
"@scalar/use-toasts/vue/@vue/compiler-sfc/@babel/parser": ["@babel/parser@7.28.3", "", { "dependencies": { "@babel/types": "^7.28.2" }, "bin": "./bin/babel-parser.js" }, "sha512-7+Ey1mAgYqFAx2h0RuoxcQT5+MlG3GTV0TQrgr7/ZliKsm/MNDxVVutlWaziMq7wJNAz8MTqz55XLpWvva6StA=="],
|
||||
@@ -4545,6 +4439,8 @@
|
||||
|
||||
"rimraf/glob/path-scurry/lru-cache": ["lru-cache@10.4.3", "", {}, "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="],
|
||||
|
||||
"serve-static/send/mime-types/mime-db": ["mime-db@1.54.0", "", {}, "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ=="],
|
||||
|
||||
"yargs/string-width/strip-ansi/ansi-regex": ["ansi-regex@6.4.0", "", {}, "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw=="],
|
||||
|
||||
"@argos-ci/core/sharp/@img/sharp-freebsd-wasm32/@img/sharp-wasm32/@emnapi/runtime": ["@emnapi/runtime@1.11.2", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-kyOl3X0DuTiT1h2ft8r2fYO8JYtU9a9Xis/zBSiGArNaagCOWx90N1k2wxp18czFDH+OgcWGb5ZP/XMt3dcyPA=="],
|
||||
@@ -4555,12 +4451,6 @@
|
||||
|
||||
"@headlessui/react/@floating-ui/react/@floating-ui/react-dom/@floating-ui/dom/@floating-ui/core": ["@floating-ui/core@1.7.4", "", { "dependencies": { "@floating-ui/utils": "^0.2.10" } }, "sha512-C3HlIdsBxszvm5McXlB8PeOEWfBhcGBTZGkGlWc2U0KFY5IwG5OQEuQ8rq52DZmcHDlPLd+YFBK+cZcytwIFWg=="],
|
||||
|
||||
"@opennextjs/aws/express/body-parser/raw-body/http-errors": ["http-errors@2.0.1", "", { "dependencies": { "depd": "~2.0.0", "inherits": "~2.0.4", "setprototypeof": "~1.2.0", "statuses": "~2.0.2", "toidentifier": "~1.0.1" } }, "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ=="],
|
||||
|
||||
"@opennextjs/aws/express/qs/side-channel/object-inspect": ["object-inspect@1.13.4", "", {}, "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew=="],
|
||||
|
||||
"@opennextjs/aws/express/serve-static/send/mime-types": ["mime-types@3.0.2", "", { "dependencies": { "mime-db": "^1.54.0" } }, "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A=="],
|
||||
|
||||
"@scalar/draggable/vue/@vue/compiler-sfc/@babel/parser/@babel/types": ["@babel/types@7.28.2", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.27.1" } }, "sha512-ruv7Ae4J5dUYULmeXw1gmb7rYRz57OWCPM57pHojnLq/3Z1CK2lNSLTCVjxVk1F/TZHwOZZrOWi0ur95BbLxNQ=="],
|
||||
|
||||
"@scalar/draggable/vue/@vue/compiler-sfc/magic-string/@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.5.0", "", {}, "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ=="],
|
||||
@@ -4580,9 +4470,5 @@
|
||||
"@zenuml/core/tailwindcss/chokidar/readdirp/picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
|
||||
|
||||
"rimraf/glob/minimatch/brace-expansion/balanced-match": ["balanced-match@1.0.2", "", {}, "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="],
|
||||
|
||||
"@opennextjs/aws/express/body-parser/raw-body/http-errors/statuses": ["statuses@2.0.2", "", {}, "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw=="],
|
||||
|
||||
"@opennextjs/aws/express/serve-static/send/mime-types/mime-db": ["mime-db@1.54.0", "", {}, "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ=="],
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@
|
||||
"@tsconfig/strictest": "^2.0.6",
|
||||
"@tsconfig/node20": "^20.1.6",
|
||||
"@base-ui/react": "^1.7.0",
|
||||
"@gitbook/api": "0.211.0",
|
||||
"@gitbook/api": "0.214.0",
|
||||
"@scalar/api-client-react": "^1.3.46",
|
||||
"@types/react": "^19.0.0",
|
||||
"@types/react-dom": "^19.0.0",
|
||||
|
||||
@@ -442,6 +442,48 @@ const searchTestCases: Test[] = [
|
||||
expect(new URL(page.url()).pathname).toBe(new URL(topResult.href, page.url()).pathname);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Search - Enter opens the visible result while a new query loads',
|
||||
url: `blocks/lists${getCustomizationURL({
|
||||
ai: {
|
||||
mode: CustomizationAIMode.None,
|
||||
},
|
||||
})}`,
|
||||
screenshot: false,
|
||||
run: async (page) => {
|
||||
await waitForHydration(page);
|
||||
const heldSearch = await holdSearchRequests(page);
|
||||
const searchInput = page.getByTestId('search-input');
|
||||
const searchPopup = page.getByTestId('search-popover');
|
||||
await searchInput.focus();
|
||||
await page.waitForURL(/[?&]q=/);
|
||||
await searchInput.pressSequentially('gitbook');
|
||||
const initialSearch = await heldSearch('gitbook');
|
||||
const { siteSpaceId } = initialSearch.request().postDataJSON().scope;
|
||||
const topResult = searchPageResult(
|
||||
initialSearch,
|
||||
siteSpaceId,
|
||||
'Headings',
|
||||
'blocks/headings'
|
||||
);
|
||||
await initialSearch.fulfill({ json: [topResult] });
|
||||
const firstResult = searchPopup.getByTestId('search-page-result').first();
|
||||
await expect(firstResult).toHaveAttribute('href', topResult.href);
|
||||
|
||||
await searchInput.pressSequentially(' docs');
|
||||
const pendingSearch = await heldSearch('gitbook docs');
|
||||
await expect(searchPopup.locator('output[aria-busy="true"]')).toBeVisible();
|
||||
await expect(firstResult).toHaveAttribute('href', topResult.href);
|
||||
await expect(searchPopup.locator('[data-search-placeholder-row]')).toHaveCount(0);
|
||||
|
||||
await searchInput.press('Enter');
|
||||
await expect(searchPopup).toBeHidden();
|
||||
await expect
|
||||
.poll(() => new URL(page.url()).pathname)
|
||||
.toBe(new URL(topResult.href, page.url()).pathname);
|
||||
await pendingSearch.abort().catch(() => {});
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Search - Enter opens the result under the mouse',
|
||||
url: `blocks/lists${getCustomizationURL({
|
||||
|
||||
@@ -120,6 +120,11 @@ const nextConfig = {
|
||||
],
|
||||
},
|
||||
|
||||
// Shiki grammars and themes are read from disk at runtime, see shiki-assets.server.ts.
|
||||
outputFileTracingIncludes: {
|
||||
'/**': ['./public/~gitbook/static/shiki/**/*'],
|
||||
},
|
||||
|
||||
webpack(config, { isServer }) {
|
||||
if (isServer) {
|
||||
// mcp-handler only needs redis for SSE, which we disable: keep the client out of the server bundle.
|
||||
|
||||
@@ -12,6 +12,13 @@
|
||||
"observability": {
|
||||
"enabled": false,
|
||||
},
|
||||
// Lets the server read Shiki grammars and themes without a network hop.
|
||||
// run_worker_first keeps every request going to the worker, as before.
|
||||
"assets": {
|
||||
"directory": "../../.open-next/assets",
|
||||
"binding": "ASSETS",
|
||||
"run_worker_first": true,
|
||||
},
|
||||
"vars": {
|
||||
"NEXT_CACHE_DO_QUEUE_DISABLE_SQLITE": "true",
|
||||
},
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"@gitbook/react-math": "workspace:*",
|
||||
"@gitbook/react-openapi": "workspace:*",
|
||||
"@mermaid-js/mermaid-zenuml": "^0.2.2",
|
||||
"@modelcontextprotocol/sdk": "1.17.5",
|
||||
"@modelcontextprotocol/sdk": "1.26.0",
|
||||
"@opennextjs/aws": "4.2.0",
|
||||
"@opennextjs/cloudflare": "1.20.18",
|
||||
"@panzoom/panzoom": "^4.6.1",
|
||||
@@ -40,7 +40,7 @@
|
||||
"jsontoxml": "^1.0.1",
|
||||
"jwt-decode": "^4.0.0",
|
||||
"leven": "^4.1.0",
|
||||
"mcp-handler": "^1.0.2",
|
||||
"mcp-handler": "^1.1.0",
|
||||
"mdast-util-from-markdown": "^2.0.2",
|
||||
"mdast-util-frontmatter": "^2.0.1",
|
||||
"mdast-util-gfm": "^3.1.0",
|
||||
@@ -82,7 +82,7 @@
|
||||
"url-join": "^5.0.0",
|
||||
"usehooks-ts": "catalog:",
|
||||
"warn-once": "^0.1.1",
|
||||
"zod": "^3",
|
||||
"zod": "^3.25",
|
||||
"zod-to-json-schema": "^3.25.1",
|
||||
"zustand": "^5.0.3"
|
||||
},
|
||||
@@ -119,9 +119,9 @@
|
||||
},
|
||||
"scripts": {
|
||||
"generate": "./scripts/generate.sh",
|
||||
"generate:assets": "bun ./scripts/generate-mermaid-runtime.ts && bun ./scripts/generate-scalar-runtime.ts && bun ./scripts/download-fonts.ts",
|
||||
"generate:assets": "bun ./scripts/generate-shiki-assets.ts && bun ./scripts/generate-mermaid-runtime.ts && bun ./scripts/generate-scalar-runtime.ts && bun ./scripts/download-fonts.ts",
|
||||
"generate:fonts": "bun ./scripts/generate-font-faces.ts",
|
||||
"clean": "rm -rf ./.next && rm -rf ./public/~gitbook/static/icons && rm -rf ./public/~gitbook/static/math && rm -rf ./public/~gitbook/static/mermaid && rm -rf ./public/~gitbook/static/scalar && rm -rf ./public/~gitbook/static/fonts",
|
||||
"clean": "rm -rf ./.next && rm -rf ./public/~gitbook/static/icons && rm -rf ./public/~gitbook/static/math && rm -rf ./public/~gitbook/static/mermaid && rm -rf ./public/~gitbook/static/scalar && rm -rf ./public/~gitbook/static/fonts && rm -rf ./public/~gitbook/static/shiki",
|
||||
"dev": "bun run generate:assets && env-cmd --silent -f ../../.env.local next --webpack",
|
||||
"build": "bun run generate:assets && next build --webpack",
|
||||
"build:local": "bun run generate:assets && GITBOOK_URL=http://localhost:3000 next build --webpack",
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import { spawn } from 'bun';
|
||||
|
||||
import type { DocumentBlockCode } from '@gitbook/api';
|
||||
|
||||
/**
|
||||
* Time the first highlights in fresh processes, where grammars and themes are loaded.
|
||||
* Usage: bun scripts/bench-highlight-cold.ts [runs]
|
||||
*/
|
||||
|
||||
const SAMPLES: Record<string, string> = {
|
||||
javascript: 'const answer = await fetch("/api").then((r) => r.json());',
|
||||
python: 'def greet(name: str) -> str:\n return f"Hello {name}"',
|
||||
vue: '<template><p>{{ msg }}</p></template>\n<script setup>\nconst msg = "hi";\n</script>',
|
||||
};
|
||||
|
||||
function codeBlock(syntax: string, code: string): DocumentBlockCode {
|
||||
return {
|
||||
object: 'block',
|
||||
type: 'code',
|
||||
data: { syntax },
|
||||
nodes: code.split('\n').map((text) => ({
|
||||
object: 'block',
|
||||
type: 'code-line',
|
||||
data: {},
|
||||
nodes: [{ object: 'text', leaves: [{ object: 'leaf', marks: [], text }] }],
|
||||
})),
|
||||
} as DocumentBlockCode;
|
||||
}
|
||||
|
||||
if (process.env.BENCH_CHILD) {
|
||||
const importStart = performance.now();
|
||||
const { highlight } = await import('../src/components/DocumentView/CodeBlock/highlight');
|
||||
const importMs = performance.now() - importStart;
|
||||
const start = performance.now();
|
||||
await Promise.all(
|
||||
Object.entries(SAMPLES).map(([syntax, code]) => highlight(codeBlock(syntax, code), []))
|
||||
);
|
||||
const firstMs = performance.now() - start;
|
||||
console.log(JSON.stringify({ importMs, firstMs, rssMB: process.memoryUsage().rss / 1e6 }));
|
||||
} else {
|
||||
const runs = Number(process.argv[2] ?? 5);
|
||||
const results: { importMs: number; firstMs: number; rssMB: number }[] = [];
|
||||
for (let i = 0; i < runs; i++) {
|
||||
const child = spawn(['bun', import.meta.path], {
|
||||
env: { ...process.env, BENCH_CHILD: '1' },
|
||||
stdout: 'pipe',
|
||||
});
|
||||
results.push(JSON.parse(await new Response(child.stdout).text()));
|
||||
}
|
||||
const median = (values: number[]) =>
|
||||
values.sort((a, b) => a - b)[Math.floor(values.length / 2)]!;
|
||||
console.log(
|
||||
JSON.stringify({
|
||||
runs,
|
||||
importMsMedian: Math.round(median(results.map((r) => r.importMs))),
|
||||
firstHighlightMsMedian: Math.round(median(results.map((r) => r.firstMs))),
|
||||
rssMBMedian: Math.round(median(results.map((r) => r.rssMB))),
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
import { $ } from 'bun';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { mkdir, rm, writeFile } from 'node:fs/promises';
|
||||
import { createRequire } from 'node:module';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { bundledLanguagesInfo } from 'shiki/langs';
|
||||
import { bundledThemesInfo } from 'shiki/themes';
|
||||
|
||||
/**
|
||||
* Write every Shiki language and theme as static JSON, so the app loads them on demand
|
||||
* instead of bundling them, and generate the catalog of their names.
|
||||
*/
|
||||
|
||||
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
||||
const staticDir = join(scriptDir, '../public/~gitbook/static');
|
||||
const codeBlockDir = join(scriptDir, '../src/components/DocumentView/CodeBlock');
|
||||
const require = createRequire(import.meta.url);
|
||||
const { version } = require('shiki/package.json') as { version: string };
|
||||
|
||||
const languages: Record<string, string> = {};
|
||||
const languageGrammars: Record<string, string[]> = {};
|
||||
const grammars = new Map<string, string>();
|
||||
for (const info of bundledLanguagesInfo) {
|
||||
// A language module exports its embedded grammars followed by its own, in registration order.
|
||||
const registrations = (await info.import()).default;
|
||||
for (const registration of registrations) {
|
||||
const json = JSON.stringify(registration);
|
||||
const existing = grammars.get(registration.name);
|
||||
if (existing !== undefined && existing !== json) {
|
||||
throw new Error(`Grammar "${registration.name}" differs between languages`);
|
||||
}
|
||||
grammars.set(registration.name, json);
|
||||
}
|
||||
languageGrammars[info.id] = registrations.map((registration) => registration.name);
|
||||
languages[info.id] = info.id;
|
||||
for (const alias of info.aliases ?? []) {
|
||||
languages[alias] ??= info.id;
|
||||
}
|
||||
}
|
||||
|
||||
const themes: Record<string, { type: 'light' | 'dark' }> = {};
|
||||
const themeFiles = new Map<string, string>();
|
||||
for (const info of bundledThemesInfo) {
|
||||
themeFiles.set(info.id, JSON.stringify((await info.import()).default));
|
||||
themes[info.id] = { type: info.type };
|
||||
}
|
||||
|
||||
// Hash the content into the path: assets are served immutable, so any change needs a new URL.
|
||||
const hash = createHash('sha256');
|
||||
for (const [name, json] of [...grammars, ...themeFiles].sort(compareEntries)) {
|
||||
hash.update(name).update('\0').update(json).update('\0');
|
||||
}
|
||||
const assetsPath = `shiki/${version}-${hash.digest('hex').slice(0, 8)}`;
|
||||
|
||||
await rm(join(staticDir, 'shiki'), { force: true, recursive: true });
|
||||
await mkdir(join(staticDir, assetsPath, 'grammars'), { recursive: true });
|
||||
await mkdir(join(staticDir, assetsPath, 'themes'), { recursive: true });
|
||||
|
||||
// One file per grammar so embedded grammars are stored and downloaded once.
|
||||
for (const [name, json] of grammars) {
|
||||
await writeFile(join(staticDir, assetsPath, 'grammars', `${name}.json`), json);
|
||||
}
|
||||
for (const [id, json] of themeFiles) {
|
||||
await writeFile(join(staticDir, assetsPath, 'themes', `${id}.json`), json);
|
||||
}
|
||||
|
||||
await writeFile(
|
||||
join(codeBlockDir, 'shiki-catalog.ts'),
|
||||
`// Generated by scripts/generate-shiki-assets.ts, do not edit.
|
||||
|
||||
export const SHIKI_ASSETS_PATH = ${JSON.stringify(assetsPath)};
|
||||
|
||||
/** Every Shiki language id and alias, mapped to the id of its asset. */
|
||||
export const SHIKI_LANGUAGES: Record<string, string> = ${JSON.stringify(sorted(languages), null, 4)};
|
||||
|
||||
/** Grammars to register for each language, embedded ones first. */
|
||||
export const SHIKI_LANGUAGE_GRAMMARS: Record<string, string[]> = ${JSON.stringify(sorted(languageGrammars), null, 4)};
|
||||
|
||||
export function getShikiGrammarAssetPath(name: string): string {
|
||||
return \`\${SHIKI_ASSETS_PATH}/grammars/\${name}.json\`;
|
||||
}
|
||||
|
||||
export function getShikiThemeAssetPath(id: string): string {
|
||||
return \`\${SHIKI_ASSETS_PATH}/themes/\${id}.json\`;
|
||||
}
|
||||
`
|
||||
);
|
||||
|
||||
// Separate from the catalog: plain highlighting only needs theme types and ships in the eager chunk.
|
||||
await writeFile(
|
||||
join(codeBlockDir, 'shiki-themes.ts'),
|
||||
`// Generated by scripts/generate-shiki-assets.ts, do not edit.
|
||||
|
||||
/** Every bundled Shiki theme id, with its type. */
|
||||
export const SHIKI_THEMES: Record<string, { type: 'light' | 'dark' }> = ${JSON.stringify(sorted(themes), null, 4)};
|
||||
`
|
||||
);
|
||||
|
||||
// Format like the rest of the repo so regenerating doesn't leave the committed files modified.
|
||||
await $`bunx oxfmt ${join(codeBlockDir, 'shiki-catalog.ts')} ${join(codeBlockDir, 'shiki-themes.ts')}`.quiet();
|
||||
|
||||
function compareEntries([a]: [string, unknown], [b]: [string, unknown]) {
|
||||
// Code-point order keeps the output identical whatever the machine's locale.
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
}
|
||||
|
||||
function sorted<T>(record: Record<string, T>) {
|
||||
return Object.fromEntries(Object.entries(record).sort(compareEntries));
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
import { $, Glob, file, gzipSync } from 'bun';
|
||||
import { stat } from 'node:fs/promises';
|
||||
import { dirname, join } from 'node:path';
|
||||
|
||||
/**
|
||||
* Measure how much of the build output is made of Shiki grammars and themes.
|
||||
* Usage: bun scripts/measure-shiki-bundles.ts next|cloudflare
|
||||
*/
|
||||
|
||||
const appPath = join(import.meta.dir, '..');
|
||||
const mode = process.argv[2];
|
||||
|
||||
// Every Shiki grammar carries a scopeName, so it is a cheap marker for grammar chunks.
|
||||
const GRAMMAR_MARKER = 'scopeName';
|
||||
|
||||
async function measureFiles(root: string, pattern: string) {
|
||||
let bytes = 0;
|
||||
let count = 0;
|
||||
let grammarBytes = 0;
|
||||
let grammarCount = 0;
|
||||
for await (const path of new Glob(pattern).scan({ cwd: root, onlyFiles: true })) {
|
||||
const content = await file(join(root, path)).text();
|
||||
const size = Buffer.byteLength(content);
|
||||
bytes += size;
|
||||
count += 1;
|
||||
if (content.includes(GRAMMAR_MARKER)) {
|
||||
grammarBytes += size;
|
||||
grammarCount += 1;
|
||||
}
|
||||
}
|
||||
return { bytes, count, grammarBytes, grammarCount };
|
||||
}
|
||||
|
||||
// Next keeps shiki external on the server, so its files reach the function through the trace.
|
||||
async function measurePageTrace() {
|
||||
const nftPath = join(
|
||||
appPath,
|
||||
'.next/server/app/sites/dynamic/[mode]/[siteURL]/[siteData]/(content)/[pagePath]/page.js.nft.json'
|
||||
);
|
||||
const { files } = (await file(nftPath).json()) as { files: string[] };
|
||||
let bytes = 0;
|
||||
let shikiBytes = 0;
|
||||
for (const relative of files) {
|
||||
const size = (await stat(join(dirname(nftPath), relative))).size;
|
||||
bytes += size;
|
||||
if (/@shikijs\/(langs|themes)|shiki\/dist\/(langs|themes)/.test(relative)) {
|
||||
shikiBytes += size;
|
||||
}
|
||||
}
|
||||
return { bytes, shikiBytes, count: files.length };
|
||||
}
|
||||
|
||||
async function measureNext() {
|
||||
const client = await measureFiles(join(appPath, '.next/static/chunks'), '**/*.js');
|
||||
const server = await measureFiles(join(appPath, '.next/server'), '**/*.js');
|
||||
const serverAll = await measureFiles(join(appPath, '.next/server'), '**/*');
|
||||
const trace = await measurePageTrace();
|
||||
return {
|
||||
pageTraceBytes: trace.bytes,
|
||||
pageTraceFiles: trace.count,
|
||||
pageTraceShikiAssetBytes: trace.shikiBytes,
|
||||
clientChunksBytes: client.bytes,
|
||||
clientChunksCount: client.count,
|
||||
clientGrammarChunksBytes: client.grammarBytes,
|
||||
clientGrammarChunksCount: client.grammarCount,
|
||||
serverBytes: serverAll.bytes,
|
||||
serverGrammarBytes: server.grammarBytes,
|
||||
serverGrammarFiles: server.grammarCount,
|
||||
};
|
||||
}
|
||||
|
||||
async function measureCloudflare() {
|
||||
const handlerPath = join(
|
||||
appPath,
|
||||
'.open-next/server-functions/default/packages/gitbook/handler.mjs'
|
||||
);
|
||||
const metafile = (await file(`${handlerPath}.meta.json`).json()) as {
|
||||
outputs: Record<string, { inputs: Record<string, { bytesInOutput: number }> }>;
|
||||
};
|
||||
const output = Object.values(metafile.outputs)[0];
|
||||
if (!output) {
|
||||
throw new Error('No output in handler metafile');
|
||||
}
|
||||
const shikiBytes = Object.entries(output.inputs).reduce(
|
||||
(total, [path, input]) =>
|
||||
path.includes('@shikijs/langs') || path.includes('@shikijs/themes')
|
||||
? total + input.bytesInOutput
|
||||
: total,
|
||||
0
|
||||
);
|
||||
|
||||
const dryRun =
|
||||
await $`bunx wrangler deploy --dry-run --config openNext/customWorkers/defaultWrangler.jsonc --env dev`
|
||||
.cwd(appPath)
|
||||
.quiet()
|
||||
.nothrow()
|
||||
.text();
|
||||
const upload = dryRun.match(/Total Upload: ([\d.]+) KiB \/ gzip: ([\d.]+) KiB/);
|
||||
|
||||
return {
|
||||
handlerBytes: (await stat(handlerPath)).size,
|
||||
handlerGzipBytes: gzipSync(await file(handlerPath).arrayBuffer()).byteLength,
|
||||
shikiBytes,
|
||||
uploadKiB: upload ? Number(upload[1]) : null,
|
||||
uploadGzipKiB: upload ? Number(upload[2]) : null,
|
||||
};
|
||||
}
|
||||
|
||||
if (mode === 'next') {
|
||||
console.log(JSON.stringify(await measureNext(), null, 2));
|
||||
} else if (mode === 'cloudflare') {
|
||||
console.log(JSON.stringify(await measureCloudflare(), null, 2));
|
||||
} else {
|
||||
throw new Error('Usage: bun scripts/measure-shiki-bundles.ts next|cloudflare');
|
||||
}
|
||||
+24
-15
@@ -19,28 +19,37 @@ export async function handleMcpRequest(
|
||||
return new Response('Not Found', { status: 404 });
|
||||
}
|
||||
|
||||
// The server is stateless, so it has no notification stream for a GET to open. `Allow` tells
|
||||
// clients to stop asking, as the Streamable HTTP transport expects.
|
||||
if (rawRequest.method === 'GET') {
|
||||
return new Response('Method Not Allowed', { status: 405, headers: { Allow: 'POST' } });
|
||||
}
|
||||
|
||||
// Next.js request.url is the original URL and not the rewritten one from the middleware
|
||||
const requestURL = new URL(context.linker.toAbsoluteURL(context.linker.toPathInSite(endpoint)));
|
||||
requestURL.search = rawRequest.nextUrl.search;
|
||||
const request = new Request(requestURL, rawRequest);
|
||||
|
||||
trackMcpEvent({
|
||||
organizationId: context.organizationId,
|
||||
siteId: context.site.id,
|
||||
events: [
|
||||
{
|
||||
type: 'mcp_request',
|
||||
location: {
|
||||
displayContext: SiteInsightsDisplayContext.Server,
|
||||
},
|
||||
},
|
||||
],
|
||||
request,
|
||||
});
|
||||
|
||||
const mcpHandler = createMcpHandler(
|
||||
(server) => {
|
||||
registerSiteMcpTools(server, createSiteMcpTools(context, { request }));
|
||||
registerSiteMcpTools(server, createSiteMcpTools(context, { request }), {
|
||||
// Connecting, listing tools and notifications are protocol overhead, several
|
||||
// requests per client session: only tool calls count as usage.
|
||||
onToolCall: () =>
|
||||
trackMcpEvent({
|
||||
organizationId: context.organizationId,
|
||||
siteId: context.site.id,
|
||||
events: [
|
||||
{
|
||||
type: 'mcp_request',
|
||||
location: {
|
||||
displayContext: SiteInsightsDisplayContext.Server,
|
||||
},
|
||||
},
|
||||
],
|
||||
request,
|
||||
}),
|
||||
});
|
||||
},
|
||||
{
|
||||
// The same identity the server card republishes, so the card and the handshake agree.
|
||||
|
||||
+41
-2
@@ -2,7 +2,8 @@ import { type NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { SEARCH_FALLBACK_HEADER } from '@/components/Search/search-pass-store';
|
||||
import type { SearchSiteContentRequest } from '@/components/Search/search-types';
|
||||
import { throwIfDataError } from '@/lib/data';
|
||||
import type { SiteURLData } from '@/lib/context';
|
||||
import { type SearchRouteReason, throwIfDataError } from '@/lib/data';
|
||||
import { getLogger } from '@/lib/logger';
|
||||
import { getSiteURLDataFromMiddleware } from '@/lib/middleware';
|
||||
import { transformSitePageResult } from '@/lib/search';
|
||||
@@ -14,7 +15,8 @@ const SEARCH_FALLBACK_REASON =
|
||||
/^(\d{3}|expired|pass_request|network|timeout|invalid|unknown_space)$/;
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
const { asEmbeddable, query, scope } = (await request.json()) as SearchSiteContentRequest;
|
||||
const { asEmbeddable, query, scope, searchId } =
|
||||
(await request.json()) as SearchSiteContentRequest;
|
||||
const [context, siteURLData] = await Promise.all([
|
||||
getServerActionBaseContext({ isEmbeddable: asEmbeddable }),
|
||||
getSiteURLDataFromMiddleware(),
|
||||
@@ -40,6 +42,8 @@ export async function POST(request: NextRequest) {
|
||||
siteId: siteURLData.site,
|
||||
query,
|
||||
scope,
|
||||
searchId,
|
||||
routeReason: getSearchRouteReason(siteURLData, fallback),
|
||||
})
|
||||
),
|
||||
throwIfDataError(
|
||||
@@ -88,3 +92,38 @@ export async function POST(request: NextRequest) {
|
||||
|
||||
return NextResponse.json(results);
|
||||
}
|
||||
|
||||
function getSearchRouteReason(
|
||||
siteURLData: SiteURLData,
|
||||
fallback: string | null
|
||||
): SearchRouteReason {
|
||||
if (siteURLData.changeRequest) {
|
||||
return 'change_request';
|
||||
}
|
||||
if (siteURLData.revision) {
|
||||
return 'revision';
|
||||
}
|
||||
if (siteURLData.preview) {
|
||||
return 'preview';
|
||||
}
|
||||
|
||||
switch (fallback) {
|
||||
case null:
|
||||
case 'expired':
|
||||
case 'pass_request':
|
||||
return 'no_pass';
|
||||
case '401':
|
||||
case '403':
|
||||
case '429':
|
||||
case 'network':
|
||||
case 'timeout':
|
||||
case 'invalid':
|
||||
case 'unknown_space':
|
||||
return `fallback:${fallback}`;
|
||||
default:
|
||||
if (/^5\d{2}$/.test(fallback)) {
|
||||
return 'fallback:5xx';
|
||||
}
|
||||
return /^\d{3}$/.test(fallback) ? 'fallback:http' : 'unknown';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,11 @@ export async function hasContentBeenUpdated(props: { revisionId: string }) {
|
||||
const context = await getServerActionBaseContext();
|
||||
const siteURLData = await getSiteURLDataFromMiddleware();
|
||||
|
||||
// A site revision never changes what it shows.
|
||||
if (siteURLData.siteRevision) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (siteURLData.changeRequest) {
|
||||
const changeRequest = await getDataOrNull(
|
||||
context.dataFetcher.getChangeRequest({
|
||||
|
||||
@@ -23,6 +23,8 @@ export type ClientBlockProps = Pick<BlockProps<DocumentBlockCode>, 'block' | 'st
|
||||
evaluateInlineExpression?: (expression: string) => string;
|
||||
mode: BlockProps<DocumentBlockCode>['context']['mode'];
|
||||
themes?: CustomizationThemedCodeTheme;
|
||||
/** Base URL of `~gitbook/static`, where the Shiki assets are loaded from. */
|
||||
staticAssetsURL: string;
|
||||
embedded?: boolean;
|
||||
/** Node key for comments, set only where commenting is possible. */
|
||||
commentKey?: string;
|
||||
@@ -35,8 +37,17 @@ export const CODE_BLOCK_DEFAULT_COLLAPSED_LINE_COUNT = 10;
|
||||
* It allows us to defer some load to avoid blocking the rendering of the whole page with block highlighting.
|
||||
*/
|
||||
export function ClientCodeBlock(props: ClientBlockProps) {
|
||||
const { block, mode, style, inlines, evaluateInlineExpression, themes, embedded, commentKey } =
|
||||
props;
|
||||
const {
|
||||
block,
|
||||
mode,
|
||||
style,
|
||||
inlines,
|
||||
evaluateInlineExpression,
|
||||
themes,
|
||||
staticAssetsURL,
|
||||
embedded,
|
||||
commentKey,
|
||||
} = props;
|
||||
const blockRef = useRef<HTMLDivElement>(null);
|
||||
const isInViewportRef = useRef(false);
|
||||
const [isInViewport, setIsInViewport] = useState(false);
|
||||
@@ -50,8 +61,10 @@ export function ClientCodeBlock(props: ClientBlockProps) {
|
||||
|
||||
// Preload the highlighter when the block is mounted.
|
||||
useEffect(() => {
|
||||
import('./highlight').then(({ preloadHighlight }) => preloadHighlight(block, themes));
|
||||
}, [block, themes]);
|
||||
import('./highlight-client').then(({ getClientHighlight }) =>
|
||||
getClientHighlight(staticAssetsURL).preloadHighlight(block, themes)
|
||||
);
|
||||
}, [block, themes, staticAssetsURL]);
|
||||
|
||||
// When user scrolls, we need to wait for the scroll to finish before running the highlight
|
||||
const isScrollingRef = useRef(false);
|
||||
@@ -99,7 +112,8 @@ export function ClientCodeBlock(props: ClientBlockProps) {
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
setHighlighting(true);
|
||||
import('./highlight').then(({ highlight }) => {
|
||||
import('./highlight-client').then(({ getClientHighlight }) => {
|
||||
const { highlight } = getClientHighlight(staticAssetsURL);
|
||||
highlight(block, inlines, { evaluateInlineExpression, themes }).then(
|
||||
(theme) => {
|
||||
if (cancelled) {
|
||||
@@ -120,7 +134,7 @@ export function ClientCodeBlock(props: ClientBlockProps) {
|
||||
|
||||
// Otherwise if the block is not in viewport, we reset to the plain lines
|
||||
setTheme(null);
|
||||
}, [isInViewport, block, inlines, evaluateInlineExpression, themes]);
|
||||
}, [isInViewport, block, inlines, evaluateInlineExpression, themes, staticAssetsURL]);
|
||||
|
||||
const expandable = block.data.expandable;
|
||||
|
||||
|
||||
@@ -15,8 +15,9 @@ export function ClientPlainCodeBlock(props: {
|
||||
syntax: string;
|
||||
mode?: DocumentContext['mode'];
|
||||
themes?: CustomizationThemedCodeTheme;
|
||||
staticAssetsURL: string;
|
||||
}) {
|
||||
const { code, syntax, mode = 'default', themes } = props;
|
||||
const { code, syntax, mode = 'default', themes, staticAssetsURL } = props;
|
||||
const id = useId();
|
||||
|
||||
const block = convertCodeStringToBlock({ key: id, code, syntax });
|
||||
@@ -28,6 +29,7 @@ export function ClientPlainCodeBlock(props: {
|
||||
inlineExprVariables={{}}
|
||||
mode={mode}
|
||||
themes={themes}
|
||||
staticAssetsURL={staticAssetsURL}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ export async function CodeBlock(
|
||||
inlineExprVariables: variables,
|
||||
mode: context.mode,
|
||||
themes,
|
||||
staticAssetsURL: getAssetURL(''),
|
||||
embedded,
|
||||
...getCommentKeyProp(context, block.key),
|
||||
};
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import { afterAll, describe, expect, it } from 'bun:test';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { getClientHighlight } from './highlight-client';
|
||||
import { getShikiGrammarAssetPath } from './shiki-catalog';
|
||||
|
||||
const staticDir = join(import.meta.dir, '../../../../public/~gitbook/static');
|
||||
const requested: string[] = [];
|
||||
|
||||
// Stands in for the CDN serving `~gitbook/static`.
|
||||
const server = Bun.serve({
|
||||
port: 0,
|
||||
fetch(request) {
|
||||
const { pathname } = new URL(request.url);
|
||||
requested.push(pathname);
|
||||
const prefix = '/~gitbook/static/';
|
||||
if (!pathname.startsWith(prefix)) {
|
||||
return new Response('not found', { status: 404 });
|
||||
}
|
||||
const file = Bun.file(join(staticDir, pathname.slice(prefix.length)));
|
||||
return new Response(file);
|
||||
},
|
||||
});
|
||||
|
||||
afterAll(() => server.stop(true));
|
||||
|
||||
const jsBlock = {
|
||||
object: 'block',
|
||||
type: 'code',
|
||||
data: { syntax: 'javascript' },
|
||||
nodes: [
|
||||
{
|
||||
object: 'block',
|
||||
type: 'code-line',
|
||||
data: {},
|
||||
nodes: [
|
||||
{ object: 'text', leaves: [{ object: 'leaf', marks: [], text: 'const a = 1;' }] },
|
||||
],
|
||||
},
|
||||
],
|
||||
} as never;
|
||||
|
||||
describe('getClientHighlight', () => {
|
||||
it('fetches assets relative to the given static assets URL', async () => {
|
||||
const { highlight } = getClientHighlight(`${server.url}~gitbook/static/`);
|
||||
const result = await highlight(jsBlock, []);
|
||||
expect(result.lines[0]?.tokens.some((token) => token.type === 'shiki')).toBe(true);
|
||||
expect(requested).toContain(`/~gitbook/static/${getShikiGrammarAssetPath('javascript')}`);
|
||||
});
|
||||
|
||||
it('reuses one highlighter per assets URL', () => {
|
||||
const url = `${server.url}~gitbook/static/`;
|
||||
expect(getClientHighlight(url)).toBe(getClientHighlight(url));
|
||||
});
|
||||
|
||||
it('falls back to plain when the assets host answers an error', async () => {
|
||||
const { highlight } = getClientHighlight(`${server.url}missing/`);
|
||||
const result = await highlight(jsBlock, []);
|
||||
expect(result.lines[0]?.tokens.map((token) => token.type)).toEqual(['plain']);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import { createHighlight } from './highlighter';
|
||||
import { joinPathWithBaseURL } from '@/lib/paths';
|
||||
|
||||
const highlighters = new Map<string, ReturnType<typeof createHighlight>>();
|
||||
|
||||
/**
|
||||
* Highlighting functions for the browser, loading Shiki assets from the static assets URL.
|
||||
* The URL comes from the server because the client build doesn't know the runtime assets host.
|
||||
*/
|
||||
export function getClientHighlight(staticAssetsURL: string) {
|
||||
let highlighter = highlighters.get(staticAssetsURL);
|
||||
if (!highlighter) {
|
||||
highlighter = createHighlight(async (path) => {
|
||||
const response = await fetch(joinPathWithBaseURL(staticAssetsURL, path));
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch ${path}: ${response.status}`);
|
||||
}
|
||||
return response.json();
|
||||
});
|
||||
highlighters.set(staticAssetsURL, highlighter);
|
||||
}
|
||||
return highlighter;
|
||||
}
|
||||
@@ -1,178 +1,7 @@
|
||||
import { createSingletonShorthands, createdBundledHighlighter } from 'shiki/core';
|
||||
import { createJavaScriptRegexEngine } from 'shiki/engine/javascript';
|
||||
import { type BundledLanguage, bundledLanguages } from 'shiki/langs';
|
||||
import { bundledThemes } from 'shiki/themes';
|
||||
|
||||
import type { CustomizationThemedCodeTheme, DocumentBlockCode } from '@gitbook/api';
|
||||
|
||||
import { customThemes } from './customThemes';
|
||||
import {
|
||||
DEFAULT_THEMES,
|
||||
type HighlightTheme,
|
||||
type HighlightToken,
|
||||
type PositionedToken,
|
||||
type RenderedInline,
|
||||
getPlainCodeBlock,
|
||||
matchTokenAndInlines,
|
||||
parseDiffNotation,
|
||||
truncateHighlightTokens,
|
||||
} from './highlight-tokens';
|
||||
import { plainHighlight } from './plain-highlight';
|
||||
import { createHighlight } from './highlighter';
|
||||
import { loadShikiAssetOnServer } from './shiki-assets.server';
|
||||
|
||||
export * from './highlight-tokens';
|
||||
export { getLanguageForSyntax } from './highlighter';
|
||||
|
||||
// Merge bundled Shiki themes with our custom themes so both are available to the highlighter
|
||||
const { getSingletonHighlighter } = createSingletonShorthands(
|
||||
createdBundledHighlighter<any, any>({
|
||||
langs: bundledLanguages,
|
||||
themes: { ...bundledThemes, ...customThemes },
|
||||
engine: () => createJavaScriptRegexEngine({ forgiving: true, target: 'ES2018' }),
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* Preload the highlighter for a code block.
|
||||
*/
|
||||
export async function preloadHighlight(
|
||||
block: DocumentBlockCode,
|
||||
themes: CustomizationThemedCodeTheme = DEFAULT_THEMES
|
||||
) {
|
||||
const langName = getBlockLang(block);
|
||||
if (langName) {
|
||||
await getSingletonHighlighter({
|
||||
langs: [langName],
|
||||
themes: [themes.light, themes.dark],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Highlight a code block while preserving inline elements.
|
||||
*/
|
||||
export async function highlight(
|
||||
block: DocumentBlockCode,
|
||||
inlines: RenderedInline[],
|
||||
options?: {
|
||||
evaluateInlineExpression?: (expr: string) => string;
|
||||
themes?: CustomizationThemedCodeTheme;
|
||||
}
|
||||
): Promise<HighlightTheme> {
|
||||
const langName = getBlockLang(block);
|
||||
|
||||
if (!langName) {
|
||||
// Fallback to plain highlighting if language is not found
|
||||
return plainHighlight(block, inlines, options);
|
||||
}
|
||||
|
||||
const themes = options?.themes ?? DEFAULT_THEMES;
|
||||
|
||||
const code = getPlainCodeBlock(block, undefined, options);
|
||||
|
||||
const highlighter = await getSingletonHighlighter({
|
||||
langs: [langName],
|
||||
themes: [themes.light, themes.dark],
|
||||
});
|
||||
|
||||
const resolvedThemes = {
|
||||
light: highlighter.getTheme(themes.light),
|
||||
dark: highlighter.getTheme(themes.dark),
|
||||
};
|
||||
|
||||
let tokenizeMaxLineLength = 400;
|
||||
// In some cases, people will use unindented code blocks with a single line.
|
||||
// In this case, we can safely increase the max line length to avoid not highlighting the code.
|
||||
if (block.nodes.length === 1) {
|
||||
tokenizeMaxLineLength = 5000;
|
||||
}
|
||||
|
||||
const result = highlighter.codeToTokens(code, {
|
||||
lang: langName,
|
||||
themes: resolvedThemes,
|
||||
// Shiki's light-dark() CSS function provides different colors for light/dark modes based on the resolved themes
|
||||
defaultColor: 'light-dark()',
|
||||
tokenizeMaxLineLength,
|
||||
});
|
||||
|
||||
const lines = result.tokens;
|
||||
|
||||
let currentIndex = 0;
|
||||
return {
|
||||
bg: result.bg,
|
||||
fg: result.fg,
|
||||
themes: resolvedThemes,
|
||||
lines: lines.map((tokens, index) => {
|
||||
const lineBlock = block.nodes[index];
|
||||
const result: HighlightToken[] = [];
|
||||
|
||||
const lineText = tokens.map((token) => token.content).join('');
|
||||
const notation = parseDiffNotation(lineText);
|
||||
|
||||
const eatToken = (): PositionedToken | null => {
|
||||
const token = tokens.shift();
|
||||
if (token) {
|
||||
currentIndex += token.content.length;
|
||||
}
|
||||
return token
|
||||
? { ...token, start: currentIndex - token.content.length, end: currentIndex }
|
||||
: null;
|
||||
};
|
||||
|
||||
while (tokens.length > 0) {
|
||||
result.push(...matchTokenAndInlines(eatToken, inlines));
|
||||
}
|
||||
|
||||
currentIndex += 1; // for the \n
|
||||
|
||||
const finalTokens = notation
|
||||
? truncateHighlightTokens(result, notation.markerStart)
|
||||
: result;
|
||||
|
||||
return {
|
||||
highlighted: Boolean(lineBlock?.data.highlighted),
|
||||
diff: notation?.diff ?? null,
|
||||
tokens: finalTokens,
|
||||
};
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the language of a code block.
|
||||
*/
|
||||
function getBlockLang(block: DocumentBlockCode): string | null {
|
||||
return block.data.syntax ? getLanguageForSyntax(block.data.syntax) : null;
|
||||
}
|
||||
|
||||
const syntaxAliases: Record<string, BundledLanguage> = {
|
||||
// "Parser" language does not exist in Shiki, but it's used in GitBook
|
||||
// The closest language is "Blade"
|
||||
parser: 'blade',
|
||||
|
||||
// From GitBook App we receive "objectivec" instead of "objective-c"
|
||||
objectivec: 'objective-c',
|
||||
};
|
||||
|
||||
function checkIsBundledLanguage(lang: string): lang is BundledLanguage {
|
||||
return lang in bundledLanguages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a language name.
|
||||
*/
|
||||
function getLanguageForSyntax(syntax: string): BundledLanguage | null {
|
||||
// Normalize the syntax to lowercase.
|
||||
syntax = syntax.toLowerCase();
|
||||
|
||||
// Check if the syntax is a bundled language.
|
||||
if (checkIsBundledLanguage(syntax)) {
|
||||
return syntax;
|
||||
}
|
||||
|
||||
// Check if there is a valid alias for the syntax.
|
||||
const alias = syntaxAliases[syntax];
|
||||
if (alias && checkIsBundledLanguage(alias)) {
|
||||
return alias;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
export const { highlight, preloadHighlight } = createHighlight(loadShikiAssetOnServer);
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
import { beforeEach, describe, expect, it } from 'bun:test';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import type { DocumentBlockCode } from '@gitbook/api';
|
||||
|
||||
import type { HighlightTheme } from './highlight-tokens';
|
||||
import { type ShikiAssetLoader, createHighlight } from './highlighter';
|
||||
import { getShikiGrammarAssetPath } from './shiki-catalog';
|
||||
|
||||
const staticDir = join(import.meta.dir, '../../../../public/~gitbook/static');
|
||||
|
||||
let calls: Map<string, number>;
|
||||
|
||||
const readAsset: ShikiAssetLoader = async (path) =>
|
||||
JSON.parse(await readFile(join(staticDir, path), 'utf8'));
|
||||
|
||||
const countingLoader: ShikiAssetLoader = async (path) => {
|
||||
calls.set(path, (calls.get(path) ?? 0) + 1);
|
||||
return readAsset(path);
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
calls = new Map();
|
||||
});
|
||||
|
||||
function codeBlock(syntax: string, code: string): DocumentBlockCode {
|
||||
return {
|
||||
object: 'block',
|
||||
type: 'code',
|
||||
data: { syntax },
|
||||
nodes: code.split('\n').map((text) => ({
|
||||
object: 'block',
|
||||
type: 'code-line',
|
||||
data: {},
|
||||
nodes: [{ object: 'text', leaves: [{ object: 'leaf', marks: [], text }] }],
|
||||
})),
|
||||
} as DocumentBlockCode;
|
||||
}
|
||||
|
||||
const jsBlock = codeBlock('javascript', 'const answer = 42;');
|
||||
|
||||
function isHighlighted(result: HighlightTheme) {
|
||||
return result.lines.some((line) => line.tokens.some((token) => token.type === 'shiki'));
|
||||
}
|
||||
|
||||
function colorOf(result: HighlightTheme, content: string) {
|
||||
for (const line of result.lines) {
|
||||
for (const token of line.tokens) {
|
||||
if (token.type === 'shiki' && token.token.content.trim() === content) {
|
||||
// light-dark() output puts the colour in htmlStyle rather than color.
|
||||
const style = token.token.htmlStyle;
|
||||
return typeof style === 'object' ? style.color : undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
describe('createHighlight', () => {
|
||||
it('loads each grammar once under concurrency', async () => {
|
||||
const { highlight } = createHighlight(countingLoader);
|
||||
const results = await Promise.all(Array.from({ length: 10 }, () => highlight(jsBlock, [])));
|
||||
expect(results.every(isHighlighted)).toBe(true);
|
||||
expect(calls.get(getShikiGrammarAssetPath('javascript'))).toBe(1);
|
||||
});
|
||||
|
||||
it('falls back to plain highlighting and retries after a failure', async () => {
|
||||
let failed = false;
|
||||
const failOnceLoader: ShikiAssetLoader = async (path) => {
|
||||
if (!failed && path === getShikiGrammarAssetPath('javascript')) {
|
||||
failed = true;
|
||||
throw new Error('asset unavailable');
|
||||
}
|
||||
return readAsset(path);
|
||||
};
|
||||
const { highlight } = createHighlight(failOnceLoader);
|
||||
|
||||
const first = await highlight(jsBlock, []);
|
||||
expect(isHighlighted(first)).toBe(false);
|
||||
expect(first.lines[0]?.tokens.map((token) => token.type)).toEqual(['plain']);
|
||||
|
||||
const second = await highlight(jsBlock, []);
|
||||
expect(isHighlighted(second)).toBe(true);
|
||||
});
|
||||
|
||||
it('highlights embedded languages', async () => {
|
||||
const { highlight } = createHighlight(countingLoader);
|
||||
const result = await highlight(
|
||||
codeBlock('vue', '<template><p>hi</p></template>\n<script>\nconst msg = 1;\n</script>'),
|
||||
[]
|
||||
);
|
||||
const keywordColor = colorOf(result, 'const');
|
||||
expect(keywordColor).toBeDefined();
|
||||
expect(keywordColor).not.toBe(colorOf(result, 'msg'));
|
||||
});
|
||||
|
||||
it('loads custom themes from code, not from assets', async () => {
|
||||
const { highlight } = createHighlight(countingLoader);
|
||||
const result = await highlight(jsBlock, [], {
|
||||
themes: { light: 'default-light', dark: 'github-dark' } as never,
|
||||
});
|
||||
expect(isHighlighted(result)).toBe(true);
|
||||
expect([...calls.keys()].some((path) => path.includes('default-light'))).toBe(false);
|
||||
expect([...calls.keys()].some((path) => path.endsWith('themes/github-dark.json'))).toBe(
|
||||
true
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,247 @@
|
||||
import {
|
||||
type HighlighterCore,
|
||||
type LanguageRegistration,
|
||||
type ThemeRegistrationAny,
|
||||
createHighlighterCore,
|
||||
} from 'shiki/core';
|
||||
import { createJavaScriptRegexEngine } from 'shiki/engine/javascript';
|
||||
|
||||
import type { CustomizationThemedCodeTheme, DocumentBlockCode } from '@gitbook/api';
|
||||
|
||||
import { customThemes } from './customThemes';
|
||||
import {
|
||||
DEFAULT_THEMES,
|
||||
type HighlightTheme,
|
||||
type HighlightToken,
|
||||
type PositionedToken,
|
||||
type RenderedInline,
|
||||
getPlainCodeBlock,
|
||||
matchTokenAndInlines,
|
||||
parseDiffNotation,
|
||||
truncateHighlightTokens,
|
||||
} from './highlight-tokens';
|
||||
import { plainHighlight } from './plain-highlight';
|
||||
import {
|
||||
SHIKI_LANGUAGES,
|
||||
SHIKI_LANGUAGE_GRAMMARS,
|
||||
getShikiGrammarAssetPath,
|
||||
getShikiThemeAssetPath,
|
||||
} from './shiki-catalog';
|
||||
import { SHIKI_THEMES } from './shiki-themes';
|
||||
|
||||
/**
|
||||
* Read a Shiki asset (grammar or theme JSON) from its path relative to `~gitbook/static`.
|
||||
*/
|
||||
export type ShikiAssetLoader = (path: string) => Promise<unknown>;
|
||||
|
||||
// Syntaxes sent by GitBook that are not Shiki ids or aliases.
|
||||
const syntaxAliases: Record<string, string> = {
|
||||
// "Parser" language does not exist in Shiki, but it's used in GitBook
|
||||
// The closest language is "Blade"
|
||||
parser: 'blade',
|
||||
|
||||
// From GitBook App we receive "objectivec" instead of "objective-c"
|
||||
objectivec: 'objective-c',
|
||||
};
|
||||
|
||||
/**
|
||||
* Resolve a code block syntax to a canonical Shiki language id.
|
||||
*/
|
||||
export function getLanguageForSyntax(syntax: string): string | null {
|
||||
const normalized = syntax.toLowerCase();
|
||||
return SHIKI_LANGUAGES[normalized] ?? SHIKI_LANGUAGES[syntaxAliases[normalized] ?? ''] ?? null;
|
||||
}
|
||||
|
||||
function getBlockLang(block: DocumentBlockCode): string | null {
|
||||
return block.data.syntax ? getLanguageForSyntax(block.data.syntax) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the highlighting functions, loading grammars and themes on demand through `loadAsset`.
|
||||
*/
|
||||
export function createHighlight(loadAsset: ShikiAssetLoader) {
|
||||
let highlighterPromise: Promise<HighlighterCore> | null = null;
|
||||
const pending = new Map<string, Promise<unknown>>();
|
||||
|
||||
// Share in-flight and finished loads; forget failures so a later render retries.
|
||||
function once<T>(key: string, load: () => Promise<T>): Promise<T> {
|
||||
let promise = pending.get(key) as Promise<T> | undefined;
|
||||
if (!promise) {
|
||||
promise = load();
|
||||
pending.set(key, promise);
|
||||
promise.catch(() => pending.delete(key));
|
||||
}
|
||||
return promise;
|
||||
}
|
||||
|
||||
function getHighlighter() {
|
||||
highlighterPromise ??= createHighlighterCore({
|
||||
engine: createJavaScriptRegexEngine({ forgiving: true, target: 'ES2018' }),
|
||||
});
|
||||
return highlighterPromise;
|
||||
}
|
||||
|
||||
function loadLanguage(highlighter: HighlighterCore, lang: string) {
|
||||
return once(`lang:${lang}`, async () => {
|
||||
const names = SHIKI_LANGUAGE_GRAMMARS[lang];
|
||||
if (!names) {
|
||||
throw new Error(`Unknown language "${lang}"`);
|
||||
}
|
||||
const grammars = await Promise.all(
|
||||
names.map(
|
||||
(name) =>
|
||||
once(`grammar:${name}`, () =>
|
||||
loadAsset(getShikiGrammarAssetPath(name))
|
||||
) as Promise<LanguageRegistration>
|
||||
)
|
||||
);
|
||||
const loaded = new Set(highlighter.getLoadedLanguages());
|
||||
await highlighter.loadLanguage(
|
||||
...grammars.filter((grammar) => !loaded.has(grammar.name))
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function loadTheme(highlighter: HighlighterCore, theme: string) {
|
||||
return once(`theme:${theme}`, async () => {
|
||||
const custom = customThemes[theme];
|
||||
if (custom) {
|
||||
await highlighter.loadTheme(custom);
|
||||
return;
|
||||
}
|
||||
if (!SHIKI_THEMES[theme]) {
|
||||
throw new Error(`Unknown theme "${theme}"`);
|
||||
}
|
||||
await highlighter.loadTheme(
|
||||
(await loadAsset(getShikiThemeAssetPath(theme))) as ThemeRegistrationAny
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
async function loadHighlighter(lang: string, themes: CustomizationThemedCodeTheme) {
|
||||
const highlighter = await getHighlighter();
|
||||
await Promise.all([
|
||||
loadLanguage(highlighter, lang),
|
||||
loadTheme(highlighter, themes.light),
|
||||
loadTheme(highlighter, themes.dark),
|
||||
]);
|
||||
return highlighter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Preload the highlighter for a code block.
|
||||
*/
|
||||
async function preloadHighlight(
|
||||
block: DocumentBlockCode,
|
||||
themes: CustomizationThemedCodeTheme = DEFAULT_THEMES
|
||||
) {
|
||||
const langName = getBlockLang(block);
|
||||
if (langName) {
|
||||
await loadHighlighter(langName, themes).catch(() => {
|
||||
// Rendering retries and reports the failure.
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Highlight a code block while preserving inline elements.
|
||||
*/
|
||||
async function highlight(
|
||||
block: DocumentBlockCode,
|
||||
inlines: RenderedInline[],
|
||||
options?: {
|
||||
evaluateInlineExpression?: (expr: string) => string;
|
||||
themes?: CustomizationThemedCodeTheme;
|
||||
}
|
||||
): Promise<HighlightTheme> {
|
||||
const langName = getBlockLang(block);
|
||||
|
||||
if (!langName) {
|
||||
// Fallback to plain highlighting if language is not found
|
||||
return plainHighlight(block, inlines, options);
|
||||
}
|
||||
|
||||
const themes = options?.themes ?? DEFAULT_THEMES;
|
||||
|
||||
const code = getPlainCodeBlock(block, undefined, options);
|
||||
|
||||
let highlighter: HighlighterCore;
|
||||
try {
|
||||
highlighter = await loadHighlighter(langName, themes);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Failed to load the "${langName}" highlighter, falling back to plain`,
|
||||
error
|
||||
);
|
||||
return plainHighlight(block, inlines, options);
|
||||
}
|
||||
|
||||
const resolvedThemes = {
|
||||
light: highlighter.getTheme(themes.light),
|
||||
dark: highlighter.getTheme(themes.dark),
|
||||
};
|
||||
|
||||
let tokenizeMaxLineLength = 400;
|
||||
// In some cases, people will use unindented code blocks with a single line.
|
||||
// In this case, we can safely increase the max line length to avoid not highlighting the code.
|
||||
if (block.nodes.length === 1) {
|
||||
tokenizeMaxLineLength = 5000;
|
||||
}
|
||||
|
||||
const result = highlighter.codeToTokens(code, {
|
||||
lang: langName,
|
||||
themes: resolvedThemes,
|
||||
// Shiki's light-dark() CSS function provides different colors for light/dark modes based on the resolved themes
|
||||
defaultColor: 'light-dark()',
|
||||
tokenizeMaxLineLength,
|
||||
});
|
||||
|
||||
const lines = result.tokens;
|
||||
|
||||
let currentIndex = 0;
|
||||
return {
|
||||
bg: result.bg,
|
||||
fg: result.fg,
|
||||
themes: resolvedThemes,
|
||||
lines: lines.map((tokens, index) => {
|
||||
const lineBlock = block.nodes[index];
|
||||
const result: HighlightToken[] = [];
|
||||
|
||||
const lineText = tokens.map((token) => token.content).join('');
|
||||
const notation = parseDiffNotation(lineText);
|
||||
|
||||
const eatToken = (): PositionedToken | null => {
|
||||
const token = tokens.shift();
|
||||
if (token) {
|
||||
currentIndex += token.content.length;
|
||||
}
|
||||
return token
|
||||
? {
|
||||
...token,
|
||||
start: currentIndex - token.content.length,
|
||||
end: currentIndex,
|
||||
}
|
||||
: null;
|
||||
};
|
||||
|
||||
while (tokens.length > 0) {
|
||||
result.push(...matchTokenAndInlines(eatToken, inlines));
|
||||
}
|
||||
|
||||
currentIndex += 1; // for the \n
|
||||
|
||||
const finalTokens = notation
|
||||
? truncateHighlightTokens(result, notation.markerStart)
|
||||
: result;
|
||||
|
||||
return {
|
||||
highlighted: Boolean(lineBlock?.data.highlighted),
|
||||
diff: notation?.diff ?? null,
|
||||
tokens: finalTokens,
|
||||
};
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
return { highlight, preloadHighlight };
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import { bundledThemesInfo } from 'shiki/themes';
|
||||
|
||||
import type { CustomizationThemedCodeTheme, DocumentBlockCode } from '@gitbook/api';
|
||||
|
||||
import { customThemes } from './customThemes';
|
||||
@@ -11,6 +9,7 @@ import {
|
||||
parseDiffNotation,
|
||||
truncateHighlightTokens,
|
||||
} from './highlight-tokens';
|
||||
import { SHIKI_THEMES } from './shiki-themes';
|
||||
import { getNodeText } from '@/lib/document';
|
||||
|
||||
/**
|
||||
@@ -29,11 +28,11 @@ export function plainHighlight(
|
||||
// Resolve theme objects: first check bundled Shiki themes, then custom themes, finally fallback to type-only
|
||||
// The type-only fallback ensures HighlightTheme always has valid theme objects even when theme names don't match
|
||||
const themes = {
|
||||
light: bundledThemesInfo.find((theme) => theme.id === options?.themes?.light) ??
|
||||
light: getBundledThemeInfo(options?.themes?.light) ??
|
||||
Object.values(customThemes).find((theme) => theme.name === options?.themes?.light) ?? {
|
||||
type: 'light',
|
||||
},
|
||||
dark: bundledThemesInfo.find((theme) => theme.id === options?.themes?.dark) ??
|
||||
dark: getBundledThemeInfo(options?.themes?.dark) ??
|
||||
Object.values(customThemes).find((theme) => theme.name === options?.themes?.dark) ?? {
|
||||
type: 'dark',
|
||||
},
|
||||
@@ -82,3 +81,8 @@ export function plainHighlight(
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
function getBundledThemeInfo(name: string | undefined) {
|
||||
const info = name ? SHIKI_THEMES[name] : undefined;
|
||||
return info ? { name, type: info.type } : undefined;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import type { ShikiAssetLoader } from './highlighter';
|
||||
import { getCloudflareContext } from '@/lib/data/cloudflare';
|
||||
|
||||
const SHIKI_PREFIX = 'shiki/';
|
||||
|
||||
/**
|
||||
* Read a Shiki asset on the server without a network hop.
|
||||
*/
|
||||
export const loadShikiAssetOnServer: ShikiAssetLoader = async (path) => {
|
||||
if (!path.startsWith(SHIKI_PREFIX)) {
|
||||
throw new Error(`Not a Shiki asset: ${path}`);
|
||||
}
|
||||
|
||||
const cloudflare = getCloudflareContext();
|
||||
if (cloudflare) {
|
||||
const assets = cloudflare.env.ASSETS;
|
||||
if (!assets) {
|
||||
throw new Error('The ASSETS binding is missing on this worker');
|
||||
}
|
||||
// The host is ignored by the assets binding, only the path matters.
|
||||
const response = await assets.fetch(
|
||||
new URL(`/~gitbook/static/${path}`, 'https://assets.local')
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to read ${path} from assets: ${response.status}`);
|
||||
}
|
||||
return response.json();
|
||||
}
|
||||
|
||||
// Keep `shiki` in the literal so file tracing only pulls this folder, not all of `static`.
|
||||
const file = join(
|
||||
process.cwd(),
|
||||
'public/~gitbook/static/shiki',
|
||||
path.slice(SHIKI_PREFIX.length)
|
||||
);
|
||||
return JSON.parse(await readFile(file, 'utf8'));
|
||||
};
|
||||
@@ -0,0 +1,69 @@
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { getLanguageForSyntax } from './highlight';
|
||||
import {
|
||||
SHIKI_ASSETS_PATH,
|
||||
SHIKI_LANGUAGES,
|
||||
SHIKI_LANGUAGE_GRAMMARS,
|
||||
getShikiGrammarAssetPath,
|
||||
getShikiThemeAssetPath,
|
||||
} from './shiki-catalog';
|
||||
import { SHIKI_THEMES } from './shiki-themes';
|
||||
|
||||
const staticDir = join(import.meta.dir, '../../../../public/~gitbook/static');
|
||||
|
||||
describe('shiki catalog', () => {
|
||||
it('maps ids and aliases to canonical ids', () => {
|
||||
expect(SHIKI_LANGUAGES.javascript).toBe('javascript');
|
||||
expect(SHIKI_LANGUAGES.js).toBe('javascript');
|
||||
expect(SHIKI_LANGUAGES['objective-c']).toBe('objective-c');
|
||||
});
|
||||
|
||||
it('lists embedded grammars before the language grammar', () => {
|
||||
const vue = SHIKI_LANGUAGE_GRAMMARS.vue ?? [];
|
||||
expect(vue.at(-1)).toBe('vue');
|
||||
expect(vue).toEqual(expect.arrayContaining(['html', 'css', 'javascript']));
|
||||
});
|
||||
|
||||
it('writes one JSON file per grammar, including internal ones', async () => {
|
||||
const grammar = await Bun.file(
|
||||
join(staticDir, getShikiGrammarAssetPath('cpp-macro'))
|
||||
).json();
|
||||
expect(grammar.name).toBe('cpp-macro');
|
||||
expect(grammar.scopeName).toBeString();
|
||||
});
|
||||
|
||||
it('writes every bundled theme', async () => {
|
||||
expect(SHIKI_THEMES['github-dark']?.type).toBe('dark');
|
||||
expect(
|
||||
await Bun.file(join(staticDir, getShikiThemeAssetPath('github-dark'))).exists()
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('shiki assets path', () => {
|
||||
it('changes with the generated content, not only the shiki version', () => {
|
||||
// Assets are served immutable, so a format change must move them to a new URL.
|
||||
expect(SHIKI_ASSETS_PATH).toMatch(/^shiki\/\d+\.\d+\.\d+-[0-9a-f]{8}$/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('client bundle', () => {
|
||||
it('keeps the language catalog out of plain highlighting', async () => {
|
||||
// plain-highlight is in the eager ClientCodeBlock chunk; only theme types are needed there.
|
||||
const source = await Bun.file(join(import.meta.dir, 'plain-highlight.ts')).text();
|
||||
expect(source).not.toContain("'./shiki-catalog'");
|
||||
expect(source).toContain("'./shiki-themes'");
|
||||
});
|
||||
});
|
||||
|
||||
describe('getLanguageForSyntax', () => {
|
||||
it('resolves GitBook syntaxes to canonical ids', () => {
|
||||
expect(getLanguageForSyntax('JSON')).toBe('json');
|
||||
expect(getLanguageForSyntax('js')).toBe('javascript');
|
||||
expect(getLanguageForSyntax('objectivec')).toBe('objective-c');
|
||||
expect(getLanguageForSyntax('parser')).toBe('blade');
|
||||
expect(getLanguageForSyntax('not-a-language')).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,902 @@
|
||||
// Generated by scripts/generate-shiki-assets.ts, do not edit.
|
||||
|
||||
export const SHIKI_ASSETS_PATH = 'shiki/3.21.0-f9eb29ba';
|
||||
|
||||
/** Every Shiki language id and alias, mapped to the id of its asset. */
|
||||
export const SHIKI_LANGUAGES: Record<string, string> = {
|
||||
'1c': 'bsl',
|
||||
'1c-query': 'sdbl',
|
||||
abap: 'abap',
|
||||
'actionscript-3': 'actionscript-3',
|
||||
ada: 'ada',
|
||||
adoc: 'asciidoc',
|
||||
'angular-html': 'angular-html',
|
||||
'angular-ts': 'angular-ts',
|
||||
apache: 'apache',
|
||||
apex: 'apex',
|
||||
apl: 'apl',
|
||||
applescript: 'applescript',
|
||||
ara: 'ara',
|
||||
asciidoc: 'asciidoc',
|
||||
asm: 'asm',
|
||||
astro: 'astro',
|
||||
awk: 'awk',
|
||||
ballerina: 'ballerina',
|
||||
bash: 'shellscript',
|
||||
bat: 'bat',
|
||||
batch: 'bat',
|
||||
be: 'berry',
|
||||
beancount: 'beancount',
|
||||
berry: 'berry',
|
||||
bibtex: 'bibtex',
|
||||
bicep: 'bicep',
|
||||
blade: 'blade',
|
||||
bsl: 'bsl',
|
||||
c: 'c',
|
||||
'c#': 'csharp',
|
||||
'c++': 'cpp',
|
||||
c3: 'c3',
|
||||
cadence: 'cadence',
|
||||
cairo: 'cairo',
|
||||
cdc: 'cadence',
|
||||
cjs: 'javascript',
|
||||
clarity: 'clarity',
|
||||
clj: 'clojure',
|
||||
clojure: 'clojure',
|
||||
'closure-templates': 'soy',
|
||||
cmake: 'cmake',
|
||||
cmd: 'vb',
|
||||
cobol: 'cobol',
|
||||
codeowners: 'codeowners',
|
||||
codeql: 'codeql',
|
||||
coffee: 'coffee',
|
||||
coffeescript: 'coffee',
|
||||
'common-lisp': 'common-lisp',
|
||||
console: 'shellsession',
|
||||
coq: 'coq',
|
||||
cpp: 'cpp',
|
||||
cql: 'cypher',
|
||||
crystal: 'crystal',
|
||||
cs: 'csharp',
|
||||
csharp: 'csharp',
|
||||
css: 'css',
|
||||
csv: 'csv',
|
||||
cts: 'typescript',
|
||||
cue: 'cue',
|
||||
cypher: 'cypher',
|
||||
d: 'd',
|
||||
dart: 'dart',
|
||||
dax: 'dax',
|
||||
desktop: 'desktop',
|
||||
diff: 'diff',
|
||||
docker: 'docker',
|
||||
dockerfile: 'docker',
|
||||
dotenv: 'dotenv',
|
||||
'dream-maker': 'dream-maker',
|
||||
edge: 'edge',
|
||||
elisp: 'emacs-lisp',
|
||||
elixir: 'elixir',
|
||||
elm: 'elm',
|
||||
'emacs-lisp': 'emacs-lisp',
|
||||
erb: 'erb',
|
||||
erl: 'erlang',
|
||||
erlang: 'erlang',
|
||||
f: 'fortran-fixed-form',
|
||||
'f#': 'fsharp',
|
||||
f03: 'fortran-free-form',
|
||||
f08: 'fortran-free-form',
|
||||
f18: 'fortran-free-form',
|
||||
f77: 'fortran-fixed-form',
|
||||
f90: 'fortran-free-form',
|
||||
f95: 'fortran-free-form',
|
||||
fennel: 'fennel',
|
||||
fish: 'fish',
|
||||
fluent: 'fluent',
|
||||
for: 'fortran-fixed-form',
|
||||
'fortran-fixed-form': 'fortran-fixed-form',
|
||||
'fortran-free-form': 'fortran-free-form',
|
||||
fs: 'fsharp',
|
||||
fsharp: 'fsharp',
|
||||
fsl: 'jssm',
|
||||
ftl: 'fluent',
|
||||
gdresource: 'gdresource',
|
||||
gdscript: 'gdscript',
|
||||
gdshader: 'gdshader',
|
||||
genie: 'genie',
|
||||
gherkin: 'gherkin',
|
||||
'git-commit': 'git-commit',
|
||||
'git-rebase': 'git-rebase',
|
||||
gjs: 'glimmer-js',
|
||||
gleam: 'gleam',
|
||||
'glimmer-js': 'glimmer-js',
|
||||
'glimmer-ts': 'glimmer-ts',
|
||||
glsl: 'glsl',
|
||||
gn: 'gn',
|
||||
gnuplot: 'gnuplot',
|
||||
go: 'go',
|
||||
gql: 'graphql',
|
||||
graphql: 'graphql',
|
||||
groovy: 'groovy',
|
||||
gts: 'glimmer-ts',
|
||||
hack: 'hack',
|
||||
haml: 'haml',
|
||||
handlebars: 'handlebars',
|
||||
haskell: 'haskell',
|
||||
haxe: 'haxe',
|
||||
hbs: 'handlebars',
|
||||
hcl: 'hcl',
|
||||
hjson: 'hjson',
|
||||
hlsl: 'hlsl',
|
||||
hs: 'haskell',
|
||||
html: 'html',
|
||||
'html-derivative': 'html-derivative',
|
||||
http: 'http',
|
||||
hurl: 'hurl',
|
||||
hxml: 'hxml',
|
||||
hy: 'hy',
|
||||
imba: 'imba',
|
||||
ini: 'ini',
|
||||
jade: 'pug',
|
||||
java: 'java',
|
||||
javascript: 'javascript',
|
||||
jinja: 'jinja',
|
||||
jison: 'jison',
|
||||
jl: 'julia',
|
||||
js: 'javascript',
|
||||
json: 'json',
|
||||
json5: 'json5',
|
||||
jsonc: 'jsonc',
|
||||
jsonl: 'jsonl',
|
||||
jsonnet: 'jsonnet',
|
||||
jssm: 'jssm',
|
||||
jsx: 'jsx',
|
||||
julia: 'julia',
|
||||
kdl: 'kdl',
|
||||
kotlin: 'kotlin',
|
||||
kql: 'kusto',
|
||||
kt: 'kotlin',
|
||||
kts: 'kotlin',
|
||||
kusto: 'kusto',
|
||||
latex: 'latex',
|
||||
lean: 'lean',
|
||||
lean4: 'lean',
|
||||
less: 'less',
|
||||
liquid: 'liquid',
|
||||
lisp: 'common-lisp',
|
||||
lit: 'ts-tags',
|
||||
llvm: 'llvm',
|
||||
log: 'log',
|
||||
logo: 'logo',
|
||||
lua: 'lua',
|
||||
luau: 'luau',
|
||||
make: 'make',
|
||||
makefile: 'make',
|
||||
markdown: 'markdown',
|
||||
marko: 'marko',
|
||||
matlab: 'matlab',
|
||||
mbt: 'moonbit',
|
||||
mbti: 'moonbit',
|
||||
md: 'markdown',
|
||||
mdc: 'mdc',
|
||||
mdx: 'mdx',
|
||||
mediawiki: 'wikitext',
|
||||
mermaid: 'mermaid',
|
||||
mips: 'mipsasm',
|
||||
mipsasm: 'mipsasm',
|
||||
mjs: 'javascript',
|
||||
mmd: 'mermaid',
|
||||
mojo: 'mojo',
|
||||
moonbit: 'moonbit',
|
||||
move: 'move',
|
||||
mts: 'typescript',
|
||||
nar: 'narrat',
|
||||
narrat: 'narrat',
|
||||
nextflow: 'nextflow',
|
||||
nf: 'nextflow',
|
||||
nginx: 'nginx',
|
||||
nim: 'nim',
|
||||
nix: 'nix',
|
||||
nu: 'nushell',
|
||||
nushell: 'nushell',
|
||||
objc: 'objective-c',
|
||||
'objective-c': 'objective-c',
|
||||
'objective-cpp': 'objective-cpp',
|
||||
ocaml: 'ocaml',
|
||||
openscad: 'openscad',
|
||||
pascal: 'pascal',
|
||||
perl: 'perl',
|
||||
perl6: 'raku',
|
||||
php: 'php',
|
||||
pkl: 'pkl',
|
||||
plsql: 'plsql',
|
||||
po: 'po',
|
||||
polar: 'polar',
|
||||
postcss: 'postcss',
|
||||
pot: 'po',
|
||||
potx: 'po',
|
||||
powerquery: 'powerquery',
|
||||
powershell: 'powershell',
|
||||
prisma: 'prisma',
|
||||
prolog: 'prolog',
|
||||
properties: 'ini',
|
||||
proto: 'proto',
|
||||
protobuf: 'proto',
|
||||
ps: 'powershell',
|
||||
ps1: 'powershell',
|
||||
pug: 'pug',
|
||||
puppet: 'puppet',
|
||||
purescript: 'purescript',
|
||||
py: 'python',
|
||||
python: 'python',
|
||||
ql: 'codeql',
|
||||
qml: 'qml',
|
||||
qmldir: 'qmldir',
|
||||
qss: 'qss',
|
||||
r: 'r',
|
||||
racket: 'racket',
|
||||
raku: 'raku',
|
||||
razor: 'razor',
|
||||
rb: 'ruby',
|
||||
reg: 'reg',
|
||||
regex: 'regexp',
|
||||
regexp: 'regexp',
|
||||
rel: 'rel',
|
||||
riscv: 'riscv',
|
||||
rosmsg: 'rosmsg',
|
||||
rs: 'rust',
|
||||
rst: 'rst',
|
||||
ruby: 'ruby',
|
||||
rust: 'rust',
|
||||
sas: 'sas',
|
||||
sass: 'sass',
|
||||
scad: 'openscad',
|
||||
scala: 'scala',
|
||||
scheme: 'scheme',
|
||||
scss: 'scss',
|
||||
sdbl: 'sdbl',
|
||||
sh: 'shellscript',
|
||||
shader: 'shaderlab',
|
||||
shaderlab: 'shaderlab',
|
||||
shell: 'shellscript',
|
||||
shellscript: 'shellscript',
|
||||
shellsession: 'shellsession',
|
||||
smalltalk: 'smalltalk',
|
||||
solidity: 'solidity',
|
||||
soy: 'soy',
|
||||
sparql: 'sparql',
|
||||
spl: 'splunk',
|
||||
splunk: 'splunk',
|
||||
sql: 'sql',
|
||||
'ssh-config': 'ssh-config',
|
||||
stata: 'stata',
|
||||
styl: 'stylus',
|
||||
stylus: 'stylus',
|
||||
svelte: 'svelte',
|
||||
swift: 'swift',
|
||||
'system-verilog': 'system-verilog',
|
||||
systemd: 'systemd',
|
||||
talon: 'talonscript',
|
||||
talonscript: 'talonscript',
|
||||
tasl: 'tasl',
|
||||
tcl: 'tcl',
|
||||
templ: 'templ',
|
||||
terraform: 'terraform',
|
||||
tex: 'tex',
|
||||
tf: 'terraform',
|
||||
tfvars: 'terraform',
|
||||
toml: 'toml',
|
||||
ts: 'typescript',
|
||||
'ts-tags': 'ts-tags',
|
||||
tsp: 'typespec',
|
||||
tsv: 'tsv',
|
||||
tsx: 'tsx',
|
||||
turtle: 'turtle',
|
||||
twig: 'twig',
|
||||
typ: 'typst',
|
||||
typescript: 'typescript',
|
||||
typespec: 'typespec',
|
||||
typst: 'typst',
|
||||
v: 'v',
|
||||
vala: 'vala',
|
||||
vb: 'vb',
|
||||
verilog: 'verilog',
|
||||
vhdl: 'vhdl',
|
||||
vim: 'viml',
|
||||
viml: 'viml',
|
||||
vimscript: 'viml',
|
||||
vue: 'vue',
|
||||
'vue-html': 'vue-html',
|
||||
'vue-vine': 'vue-vine',
|
||||
vy: 'vyper',
|
||||
vyper: 'vyper',
|
||||
wasm: 'wasm',
|
||||
wenyan: 'wenyan',
|
||||
wgsl: 'wgsl',
|
||||
wiki: 'wikitext',
|
||||
wikitext: 'wikitext',
|
||||
wit: 'wit',
|
||||
wl: 'wolfram',
|
||||
wolfram: 'wolfram',
|
||||
xml: 'xml',
|
||||
xsl: 'xsl',
|
||||
yaml: 'yaml',
|
||||
yml: 'yaml',
|
||||
zenscript: 'zenscript',
|
||||
zig: 'zig',
|
||||
zsh: 'shellscript',
|
||||
文言: 'wenyan',
|
||||
};
|
||||
|
||||
/** Grammars to register for each language, embedded ones first. */
|
||||
export const SHIKI_LANGUAGE_GRAMMARS: Record<string, string[]> = {
|
||||
abap: ['abap'],
|
||||
'actionscript-3': ['actionscript-3'],
|
||||
ada: ['ada'],
|
||||
'angular-html': [
|
||||
'javascript',
|
||||
'css',
|
||||
'html',
|
||||
'angular-expression',
|
||||
'angular-expression',
|
||||
'angular-let-declaration',
|
||||
'angular-expression',
|
||||
'angular-template',
|
||||
'angular-expression',
|
||||
'angular-expression',
|
||||
'angular-template',
|
||||
'angular-template-blocks',
|
||||
'angular-html',
|
||||
],
|
||||
'angular-ts': [
|
||||
'angular-expression',
|
||||
'css',
|
||||
'scss',
|
||||
'angular-inline-style',
|
||||
'javascript',
|
||||
'css',
|
||||
'html',
|
||||
'angular-expression',
|
||||
'angular-expression',
|
||||
'angular-let-declaration',
|
||||
'angular-expression',
|
||||
'angular-template',
|
||||
'angular-expression',
|
||||
'angular-expression',
|
||||
'angular-template',
|
||||
'angular-template-blocks',
|
||||
'angular-html',
|
||||
'angular-expression',
|
||||
'angular-template',
|
||||
'angular-inline-template',
|
||||
'angular-expression',
|
||||
'angular-let-declaration',
|
||||
'angular-expression',
|
||||
'angular-template',
|
||||
'angular-expression',
|
||||
'angular-expression',
|
||||
'angular-template',
|
||||
'angular-template-blocks',
|
||||
'angular-ts',
|
||||
],
|
||||
apache: ['apache'],
|
||||
apex: ['apex'],
|
||||
apl: ['javascript', 'css', 'html', 'java', 'xml', 'css', 'javascript', 'json', 'apl'],
|
||||
applescript: ['applescript'],
|
||||
ara: ['ara'],
|
||||
asciidoc: ['asciidoc'],
|
||||
asm: ['asm'],
|
||||
astro: ['json', 'javascript', 'typescript', 'css', 'postcss', 'tsx', 'astro'],
|
||||
awk: ['awk'],
|
||||
ballerina: ['ballerina'],
|
||||
bat: ['bat'],
|
||||
beancount: ['beancount'],
|
||||
berry: ['berry'],
|
||||
bibtex: ['bibtex'],
|
||||
bicep: ['bicep'],
|
||||
blade: [
|
||||
'javascript',
|
||||
'css',
|
||||
'html',
|
||||
'html-derivative',
|
||||
'javascript',
|
||||
'css',
|
||||
'html',
|
||||
'java',
|
||||
'xml',
|
||||
'sql',
|
||||
'javascript',
|
||||
'json',
|
||||
'css',
|
||||
'blade',
|
||||
],
|
||||
bsl: ['sdbl', 'bsl'],
|
||||
c: ['c'],
|
||||
c3: ['c3'],
|
||||
cadence: ['cadence'],
|
||||
cairo: ['python', 'cairo'],
|
||||
clarity: ['clarity'],
|
||||
clojure: ['clojure'],
|
||||
cmake: ['cmake'],
|
||||
cobol: ['javascript', 'css', 'html', 'java', 'cobol'],
|
||||
codeowners: ['codeowners'],
|
||||
codeql: ['codeql'],
|
||||
coffee: ['javascript', 'coffee'],
|
||||
'common-lisp': ['common-lisp'],
|
||||
coq: ['coq'],
|
||||
cpp: ['regexp', 'c', 'glsl', 'sql', 'cpp-macro', 'regexp', 'c', 'glsl', 'sql', 'cpp'],
|
||||
crystal: [
|
||||
'javascript',
|
||||
'css',
|
||||
'html',
|
||||
'sql',
|
||||
'css',
|
||||
'c',
|
||||
'javascript',
|
||||
'shellscript',
|
||||
'crystal',
|
||||
],
|
||||
csharp: ['csharp'],
|
||||
css: ['css'],
|
||||
csv: ['csv'],
|
||||
cue: ['cue'],
|
||||
cypher: ['cypher'],
|
||||
d: ['d'],
|
||||
dart: ['dart'],
|
||||
dax: ['dax'],
|
||||
desktop: ['desktop'],
|
||||
diff: ['diff'],
|
||||
docker: ['docker'],
|
||||
dotenv: ['dotenv'],
|
||||
'dream-maker': ['dream-maker'],
|
||||
edge: [
|
||||
'typescript',
|
||||
'javascript',
|
||||
'css',
|
||||
'html',
|
||||
'javascript',
|
||||
'css',
|
||||
'html',
|
||||
'html-derivative',
|
||||
'edge',
|
||||
],
|
||||
elixir: ['javascript', 'css', 'html', 'elixir'],
|
||||
elm: ['c', 'glsl', 'elm'],
|
||||
'emacs-lisp': ['emacs-lisp'],
|
||||
erb: [
|
||||
'javascript',
|
||||
'css',
|
||||
'html',
|
||||
'javascript',
|
||||
'css',
|
||||
'html',
|
||||
'javascript',
|
||||
'css',
|
||||
'haml',
|
||||
'java',
|
||||
'xml',
|
||||
'sql',
|
||||
'javascript',
|
||||
'typescript',
|
||||
'jsx',
|
||||
'tsx',
|
||||
'graphql',
|
||||
'css',
|
||||
'regexp',
|
||||
'c',
|
||||
'glsl',
|
||||
'sql',
|
||||
'cpp-macro',
|
||||
'regexp',
|
||||
'c',
|
||||
'glsl',
|
||||
'sql',
|
||||
'cpp',
|
||||
'c',
|
||||
'javascript',
|
||||
'shellscript',
|
||||
'c',
|
||||
'lua',
|
||||
'yaml',
|
||||
'ruby',
|
||||
'erb',
|
||||
],
|
||||
erlang: ['markdown', 'erlang'],
|
||||
fennel: ['fennel'],
|
||||
fish: ['fish'],
|
||||
fluent: ['fluent'],
|
||||
'fortran-fixed-form': ['fortran-free-form', 'fortran-fixed-form'],
|
||||
'fortran-free-form': ['fortran-free-form'],
|
||||
fsharp: ['markdown', 'fsharp'],
|
||||
gdresource: ['gdshader', 'gdscript', 'gdresource'],
|
||||
gdscript: ['gdscript'],
|
||||
gdshader: ['gdshader'],
|
||||
genie: ['genie'],
|
||||
gherkin: ['gherkin'],
|
||||
'git-commit': ['diff', 'git-commit'],
|
||||
'git-rebase': ['shellscript', 'git-rebase'],
|
||||
gleam: ['gleam'],
|
||||
'glimmer-js': ['javascript', 'typescript', 'css', 'javascript', 'css', 'html', 'glimmer-js'],
|
||||
'glimmer-ts': ['typescript', 'css', 'javascript', 'javascript', 'css', 'html', 'glimmer-ts'],
|
||||
glsl: ['c', 'glsl'],
|
||||
gn: ['gn'],
|
||||
gnuplot: ['gnuplot'],
|
||||
go: ['go'],
|
||||
graphql: ['javascript', 'typescript', 'jsx', 'tsx', 'graphql'],
|
||||
groovy: ['groovy'],
|
||||
hack: ['javascript', 'css', 'html', 'sql', 'hack'],
|
||||
haml: ['javascript', 'css', 'haml'],
|
||||
handlebars: ['javascript', 'css', 'html', 'css', 'javascript', 'yaml', 'handlebars'],
|
||||
haskell: ['haskell'],
|
||||
haxe: ['haxe'],
|
||||
hcl: ['hcl'],
|
||||
hjson: ['hjson'],
|
||||
hlsl: ['hlsl'],
|
||||
html: ['javascript', 'css', 'html'],
|
||||
'html-derivative': ['javascript', 'css', 'html', 'html-derivative'],
|
||||
http: [
|
||||
'shellscript',
|
||||
'json',
|
||||
'java',
|
||||
'xml',
|
||||
'javascript',
|
||||
'typescript',
|
||||
'jsx',
|
||||
'tsx',
|
||||
'graphql',
|
||||
'http',
|
||||
],
|
||||
hurl: ['javascript', 'typescript', 'jsx', 'tsx', 'graphql', 'java', 'xml', 'csv', 'hurl'],
|
||||
hxml: ['haxe', 'hxml'],
|
||||
hy: ['hy'],
|
||||
imba: ['imba'],
|
||||
ini: ['ini'],
|
||||
java: ['java'],
|
||||
javascript: ['javascript'],
|
||||
jinja: ['javascript', 'css', 'html', 'jinja-html', 'jinja'],
|
||||
jison: ['javascript', 'jison'],
|
||||
json: ['json'],
|
||||
json5: ['json5'],
|
||||
jsonc: ['jsonc'],
|
||||
jsonl: ['jsonl'],
|
||||
jsonnet: ['jsonnet'],
|
||||
jssm: ['jssm'],
|
||||
jsx: ['jsx'],
|
||||
julia: [
|
||||
'regexp',
|
||||
'c',
|
||||
'glsl',
|
||||
'sql',
|
||||
'cpp-macro',
|
||||
'regexp',
|
||||
'c',
|
||||
'glsl',
|
||||
'sql',
|
||||
'cpp',
|
||||
'python',
|
||||
'javascript',
|
||||
'r',
|
||||
'sql',
|
||||
'julia',
|
||||
],
|
||||
kdl: ['kdl'],
|
||||
kotlin: ['kotlin'],
|
||||
kusto: ['kusto'],
|
||||
latex: ['r', 'tex', 'latex'],
|
||||
lean: ['lean'],
|
||||
less: ['less'],
|
||||
liquid: ['javascript', 'css', 'html', 'css', 'json', 'javascript', 'liquid'],
|
||||
llvm: ['llvm'],
|
||||
log: ['log'],
|
||||
logo: ['logo'],
|
||||
lua: ['c', 'lua'],
|
||||
luau: ['luau'],
|
||||
make: ['make'],
|
||||
markdown: ['markdown'],
|
||||
marko: ['css', 'less', 'css', 'scss', 'typescript', 'marko'],
|
||||
matlab: ['matlab'],
|
||||
mdc: ['markdown', 'yaml', 'javascript', 'css', 'html', 'html-derivative', 'mdc'],
|
||||
mdx: ['mdx'],
|
||||
mermaid: ['mermaid'],
|
||||
mipsasm: ['mipsasm'],
|
||||
mojo: ['mojo'],
|
||||
moonbit: ['moonbit'],
|
||||
move: ['move'],
|
||||
narrat: ['narrat'],
|
||||
nextflow: ['nextflow'],
|
||||
nginx: ['c', 'lua', 'nginx'],
|
||||
nim: [
|
||||
'c',
|
||||
'javascript',
|
||||
'css',
|
||||
'html',
|
||||
'java',
|
||||
'xml',
|
||||
'javascript',
|
||||
'css',
|
||||
'c',
|
||||
'glsl',
|
||||
'markdown',
|
||||
'nim',
|
||||
],
|
||||
nix: ['markdown-nix', 'nix'],
|
||||
nushell: ['nushell'],
|
||||
'objective-c': ['objective-c'],
|
||||
'objective-cpp': ['objective-cpp'],
|
||||
ocaml: ['ocaml'],
|
||||
openscad: ['openscad'],
|
||||
pascal: ['pascal'],
|
||||
perl: ['javascript', 'css', 'html', 'java', 'xml', 'css', 'javascript', 'sql', 'perl'],
|
||||
php: ['javascript', 'css', 'html', 'java', 'xml', 'sql', 'javascript', 'json', 'css', 'php'],
|
||||
pkl: ['pkl'],
|
||||
plsql: ['plsql'],
|
||||
po: ['po'],
|
||||
polar: ['polar'],
|
||||
postcss: ['postcss'],
|
||||
powerquery: ['powerquery'],
|
||||
powershell: ['powershell'],
|
||||
prisma: ['prisma'],
|
||||
prolog: ['prolog'],
|
||||
proto: ['proto'],
|
||||
pug: ['javascript', 'css', 'javascript', 'css', 'html', 'pug'],
|
||||
puppet: ['puppet'],
|
||||
purescript: ['purescript'],
|
||||
python: ['python'],
|
||||
qml: ['javascript', 'qml'],
|
||||
qmldir: ['qmldir'],
|
||||
qss: ['qss'],
|
||||
r: ['r'],
|
||||
racket: ['racket'],
|
||||
raku: ['raku'],
|
||||
razor: ['javascript', 'css', 'html', 'csharp', 'razor'],
|
||||
reg: ['reg'],
|
||||
regexp: ['regexp'],
|
||||
rel: ['rel'],
|
||||
riscv: ['riscv'],
|
||||
rosmsg: ['rosmsg'],
|
||||
rst: [
|
||||
'javascript',
|
||||
'css',
|
||||
'html',
|
||||
'html-derivative',
|
||||
'regexp',
|
||||
'c',
|
||||
'glsl',
|
||||
'sql',
|
||||
'cpp-macro',
|
||||
'regexp',
|
||||
'c',
|
||||
'glsl',
|
||||
'sql',
|
||||
'cpp',
|
||||
'python',
|
||||
'javascript',
|
||||
'shellscript',
|
||||
'yaml',
|
||||
'cmake',
|
||||
'javascript',
|
||||
'css',
|
||||
'html',
|
||||
'javascript',
|
||||
'css',
|
||||
'haml',
|
||||
'java',
|
||||
'xml',
|
||||
'sql',
|
||||
'javascript',
|
||||
'typescript',
|
||||
'jsx',
|
||||
'tsx',
|
||||
'graphql',
|
||||
'css',
|
||||
'regexp',
|
||||
'c',
|
||||
'glsl',
|
||||
'sql',
|
||||
'cpp-macro',
|
||||
'regexp',
|
||||
'c',
|
||||
'glsl',
|
||||
'sql',
|
||||
'cpp',
|
||||
'c',
|
||||
'javascript',
|
||||
'shellscript',
|
||||
'c',
|
||||
'lua',
|
||||
'yaml',
|
||||
'ruby',
|
||||
'rst',
|
||||
],
|
||||
ruby: [
|
||||
'javascript',
|
||||
'css',
|
||||
'html',
|
||||
'javascript',
|
||||
'css',
|
||||
'haml',
|
||||
'java',
|
||||
'xml',
|
||||
'sql',
|
||||
'javascript',
|
||||
'typescript',
|
||||
'jsx',
|
||||
'tsx',
|
||||
'graphql',
|
||||
'css',
|
||||
'regexp',
|
||||
'c',
|
||||
'glsl',
|
||||
'sql',
|
||||
'cpp-macro',
|
||||
'regexp',
|
||||
'c',
|
||||
'glsl',
|
||||
'sql',
|
||||
'cpp',
|
||||
'c',
|
||||
'javascript',
|
||||
'shellscript',
|
||||
'c',
|
||||
'lua',
|
||||
'yaml',
|
||||
'ruby',
|
||||
],
|
||||
rust: ['rust'],
|
||||
sas: ['sql', 'sas'],
|
||||
sass: ['sass'],
|
||||
scala: ['scala'],
|
||||
scheme: ['scheme'],
|
||||
scss: ['css', 'scss'],
|
||||
sdbl: ['sdbl'],
|
||||
shaderlab: ['hlsl', 'shaderlab'],
|
||||
shellscript: ['shellscript'],
|
||||
shellsession: ['shellscript', 'shellsession'],
|
||||
smalltalk: ['smalltalk'],
|
||||
solidity: ['solidity'],
|
||||
soy: ['javascript', 'css', 'html', 'soy'],
|
||||
sparql: ['turtle', 'sparql'],
|
||||
splunk: ['splunk'],
|
||||
sql: ['sql'],
|
||||
'ssh-config': ['ssh-config'],
|
||||
stata: ['sql', 'stata'],
|
||||
stylus: ['stylus'],
|
||||
svelte: ['javascript', 'typescript', 'css', 'postcss', 'svelte'],
|
||||
swift: ['swift'],
|
||||
'system-verilog': ['system-verilog'],
|
||||
systemd: ['systemd'],
|
||||
talonscript: ['talonscript'],
|
||||
tasl: ['tasl'],
|
||||
tcl: ['tcl'],
|
||||
templ: ['go', 'javascript', 'css', 'templ'],
|
||||
terraform: ['terraform'],
|
||||
tex: ['r', 'tex'],
|
||||
toml: ['toml'],
|
||||
'ts-tags': [
|
||||
'typescript',
|
||||
'typescript',
|
||||
'css',
|
||||
'javascript',
|
||||
'es-tag-css',
|
||||
'typescript',
|
||||
'c',
|
||||
'glsl',
|
||||
'javascript',
|
||||
'es-tag-glsl',
|
||||
'typescript',
|
||||
'javascript',
|
||||
'css',
|
||||
'html',
|
||||
'javascript',
|
||||
'es-tag-html',
|
||||
'typescript',
|
||||
'sql',
|
||||
'es-tag-sql',
|
||||
'java',
|
||||
'xml',
|
||||
'es-tag-xml',
|
||||
'ts-tags',
|
||||
],
|
||||
tsv: ['tsv'],
|
||||
tsx: ['tsx'],
|
||||
turtle: ['turtle'],
|
||||
twig: [
|
||||
'css',
|
||||
'javascript',
|
||||
'css',
|
||||
'scss',
|
||||
'javascript',
|
||||
'css',
|
||||
'html',
|
||||
'java',
|
||||
'xml',
|
||||
'sql',
|
||||
'javascript',
|
||||
'json',
|
||||
'css',
|
||||
'php',
|
||||
'python',
|
||||
'javascript',
|
||||
'css',
|
||||
'html',
|
||||
'javascript',
|
||||
'css',
|
||||
'haml',
|
||||
'java',
|
||||
'xml',
|
||||
'sql',
|
||||
'javascript',
|
||||
'typescript',
|
||||
'jsx',
|
||||
'tsx',
|
||||
'graphql',
|
||||
'css',
|
||||
'regexp',
|
||||
'c',
|
||||
'glsl',
|
||||
'sql',
|
||||
'cpp-macro',
|
||||
'regexp',
|
||||
'c',
|
||||
'glsl',
|
||||
'sql',
|
||||
'cpp',
|
||||
'c',
|
||||
'javascript',
|
||||
'shellscript',
|
||||
'c',
|
||||
'lua',
|
||||
'yaml',
|
||||
'ruby',
|
||||
'twig',
|
||||
],
|
||||
typescript: ['typescript'],
|
||||
typespec: ['typespec'],
|
||||
typst: ['typst'],
|
||||
v: ['v'],
|
||||
vala: ['vala'],
|
||||
vb: ['vb'],
|
||||
verilog: ['verilog'],
|
||||
vhdl: ['vhdl'],
|
||||
viml: ['viml'],
|
||||
vue: [
|
||||
'css',
|
||||
'javascript',
|
||||
'typescript',
|
||||
'json',
|
||||
'javascript',
|
||||
'css',
|
||||
'html',
|
||||
'javascript',
|
||||
'css',
|
||||
'html',
|
||||
'html-derivative',
|
||||
'markdown-vue',
|
||||
'vue-directives',
|
||||
'vue-interpolations',
|
||||
'javascript',
|
||||
'vue-sfc-style-variable-injection',
|
||||
'vue',
|
||||
],
|
||||
'vue-html': ['javascript', 'vue-html'],
|
||||
'vue-vine': ['css', 'css', 'scss', 'less', 'stylus', 'postcss', 'javascript', 'vue-vine'],
|
||||
vyper: ['vyper'],
|
||||
wasm: ['wasm'],
|
||||
wenyan: ['wenyan'],
|
||||
wgsl: ['wgsl'],
|
||||
wikitext: ['wikitext'],
|
||||
wit: ['wit'],
|
||||
wolfram: ['wolfram'],
|
||||
xml: ['java', 'xml'],
|
||||
xsl: ['java', 'xml', 'xsl'],
|
||||
yaml: ['yaml'],
|
||||
zenscript: ['zenscript'],
|
||||
zig: ['zig'],
|
||||
};
|
||||
|
||||
export function getShikiGrammarAssetPath(name: string): string {
|
||||
return `${SHIKI_ASSETS_PATH}/grammars/${name}.json`;
|
||||
}
|
||||
|
||||
export function getShikiThemeAssetPath(id: string): string {
|
||||
return `${SHIKI_ASSETS_PATH}/themes/${id}.json`;
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
// Generated by scripts/generate-shiki-assets.ts, do not edit.
|
||||
|
||||
/** Every bundled Shiki theme id, with its type. */
|
||||
export const SHIKI_THEMES: Record<string, { type: 'light' | 'dark' }> = {
|
||||
andromeeda: {
|
||||
type: 'dark',
|
||||
},
|
||||
'aurora-x': {
|
||||
type: 'dark',
|
||||
},
|
||||
'ayu-dark': {
|
||||
type: 'dark',
|
||||
},
|
||||
'catppuccin-frappe': {
|
||||
type: 'dark',
|
||||
},
|
||||
'catppuccin-latte': {
|
||||
type: 'light',
|
||||
},
|
||||
'catppuccin-macchiato': {
|
||||
type: 'dark',
|
||||
},
|
||||
'catppuccin-mocha': {
|
||||
type: 'dark',
|
||||
},
|
||||
'dark-plus': {
|
||||
type: 'dark',
|
||||
},
|
||||
dracula: {
|
||||
type: 'dark',
|
||||
},
|
||||
'dracula-soft': {
|
||||
type: 'dark',
|
||||
},
|
||||
'everforest-dark': {
|
||||
type: 'dark',
|
||||
},
|
||||
'everforest-light': {
|
||||
type: 'light',
|
||||
},
|
||||
'github-dark': {
|
||||
type: 'dark',
|
||||
},
|
||||
'github-dark-default': {
|
||||
type: 'dark',
|
||||
},
|
||||
'github-dark-dimmed': {
|
||||
type: 'dark',
|
||||
},
|
||||
'github-dark-high-contrast': {
|
||||
type: 'dark',
|
||||
},
|
||||
'github-light': {
|
||||
type: 'light',
|
||||
},
|
||||
'github-light-default': {
|
||||
type: 'light',
|
||||
},
|
||||
'github-light-high-contrast': {
|
||||
type: 'light',
|
||||
},
|
||||
'gruvbox-dark-hard': {
|
||||
type: 'dark',
|
||||
},
|
||||
'gruvbox-dark-medium': {
|
||||
type: 'dark',
|
||||
},
|
||||
'gruvbox-dark-soft': {
|
||||
type: 'dark',
|
||||
},
|
||||
'gruvbox-light-hard': {
|
||||
type: 'light',
|
||||
},
|
||||
'gruvbox-light-medium': {
|
||||
type: 'light',
|
||||
},
|
||||
'gruvbox-light-soft': {
|
||||
type: 'light',
|
||||
},
|
||||
houston: {
|
||||
type: 'dark',
|
||||
},
|
||||
'kanagawa-dragon': {
|
||||
type: 'dark',
|
||||
},
|
||||
'kanagawa-lotus': {
|
||||
type: 'light',
|
||||
},
|
||||
'kanagawa-wave': {
|
||||
type: 'dark',
|
||||
},
|
||||
laserwave: {
|
||||
type: 'dark',
|
||||
},
|
||||
'light-plus': {
|
||||
type: 'light',
|
||||
},
|
||||
'material-theme': {
|
||||
type: 'dark',
|
||||
},
|
||||
'material-theme-darker': {
|
||||
type: 'dark',
|
||||
},
|
||||
'material-theme-lighter': {
|
||||
type: 'light',
|
||||
},
|
||||
'material-theme-ocean': {
|
||||
type: 'dark',
|
||||
},
|
||||
'material-theme-palenight': {
|
||||
type: 'dark',
|
||||
},
|
||||
'min-dark': {
|
||||
type: 'dark',
|
||||
},
|
||||
'min-light': {
|
||||
type: 'light',
|
||||
},
|
||||
monokai: {
|
||||
type: 'dark',
|
||||
},
|
||||
'night-owl': {
|
||||
type: 'dark',
|
||||
},
|
||||
nord: {
|
||||
type: 'dark',
|
||||
},
|
||||
'one-dark-pro': {
|
||||
type: 'dark',
|
||||
},
|
||||
'one-light': {
|
||||
type: 'light',
|
||||
},
|
||||
plastic: {
|
||||
type: 'dark',
|
||||
},
|
||||
poimandres: {
|
||||
type: 'dark',
|
||||
},
|
||||
red: {
|
||||
type: 'dark',
|
||||
},
|
||||
'rose-pine': {
|
||||
type: 'dark',
|
||||
},
|
||||
'rose-pine-dawn': {
|
||||
type: 'light',
|
||||
},
|
||||
'rose-pine-moon': {
|
||||
type: 'dark',
|
||||
},
|
||||
'slack-dark': {
|
||||
type: 'dark',
|
||||
},
|
||||
'slack-ochin': {
|
||||
type: 'light',
|
||||
},
|
||||
'snazzy-light': {
|
||||
type: 'light',
|
||||
},
|
||||
'solarized-dark': {
|
||||
type: 'dark',
|
||||
},
|
||||
'solarized-light': {
|
||||
type: 'light',
|
||||
},
|
||||
'synthwave-84': {
|
||||
type: 'dark',
|
||||
},
|
||||
'tokyo-night': {
|
||||
type: 'dark',
|
||||
},
|
||||
vesper: {
|
||||
type: 'dark',
|
||||
},
|
||||
'vitesse-black': {
|
||||
type: 'dark',
|
||||
},
|
||||
'vitesse-dark': {
|
||||
type: 'dark',
|
||||
},
|
||||
'vitesse-light': {
|
||||
type: 'light',
|
||||
},
|
||||
};
|
||||
@@ -39,6 +39,7 @@ export type OpenAPIBlockClientContextProps = {
|
||||
headingNode: React.ReactNode;
|
||||
descriptionNode: React.ReactNode;
|
||||
scalarRuntimeURL: string;
|
||||
staticAssetsURL: string;
|
||||
};
|
||||
|
||||
type OpenAPIBlockVariant =
|
||||
@@ -65,7 +66,13 @@ export function OpenAPIBlockClient(props: OpenAPIBlockClientProps) {
|
||||
id: props.id,
|
||||
blockKey: props.blockKey,
|
||||
renderCodeBlock: ({ code, syntax }) => (
|
||||
<ClientPlainCodeBlock code={code} syntax={syntax} mode={mode} themes={codeTheme} />
|
||||
<ClientPlainCodeBlock
|
||||
code={code}
|
||||
syntax={syntax}
|
||||
mode={mode}
|
||||
themes={codeTheme}
|
||||
staticAssetsURL={props.staticAssetsURL}
|
||||
/>
|
||||
),
|
||||
renderDocument: () => descriptionNode,
|
||||
renderHeading: () => headingNode,
|
||||
|
||||
@@ -166,6 +166,7 @@ export function getOpenAPIBlockClientProps(args: {
|
||||
return {
|
||||
...serializable,
|
||||
mode: props.context.mode,
|
||||
staticAssetsURL: getAssetURL(''),
|
||||
codeTheme:
|
||||
context && 'customization' in context
|
||||
? context.customization.styling.codeTheme.openapi
|
||||
|
||||
@@ -75,7 +75,7 @@ export function Update(props: BlockProps<DocumentBlockUpdate>) {
|
||||
{...contextProps}
|
||||
nodes={block.nodes}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
style="flex flex-1 flex-col [&>*+*]:mt-5 [&>*:first-child]:!pt-0"
|
||||
style="flex min-w-0 flex-1 flex-col [&>*+*]:mt-5 [&>*:first-child]:!pt-0"
|
||||
/>
|
||||
</FilteredUpdate>
|
||||
);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { SiteInsightsDisplayContext } from '@gitbook/api';
|
||||
|
||||
import { useTrackEvent } from '../Insights';
|
||||
import { LinkContext } from '../primitives';
|
||||
import { useIsVisible } from '../VisibilityContext';
|
||||
@@ -37,9 +39,10 @@ export function EmbeddableSearch(props: EmbeddableSearchProps) {
|
||||
return;
|
||||
}
|
||||
|
||||
trackEvent({
|
||||
type: 'search_open',
|
||||
});
|
||||
trackEvent(
|
||||
{ type: 'search_open' },
|
||||
{ pageId: null, displayContext: SiteInsightsDisplayContext.Embed }
|
||||
);
|
||||
}, [trackEvent, isVisible]);
|
||||
|
||||
const tabsRef = React.useRef<HTMLDivElement>(null);
|
||||
@@ -56,6 +59,7 @@ export function EmbeddableSearch(props: EmbeddableSearchProps) {
|
||||
query,
|
||||
results,
|
||||
resultsId,
|
||||
resultsQuery,
|
||||
resultsRef,
|
||||
searchValue,
|
||||
setQuery,
|
||||
@@ -79,6 +83,7 @@ export function EmbeddableSearch(props: EmbeddableSearchProps) {
|
||||
query={query}
|
||||
results={results}
|
||||
resultsId={resultsId}
|
||||
resultsQuery={resultsQuery}
|
||||
resultsRef={resultsRef}
|
||||
onResultSelect={onResultSelect}
|
||||
onResultHover={onResultHover}
|
||||
|
||||
@@ -15,6 +15,7 @@ import { Button } from '@/components/primitives/Button';
|
||||
import { DropdownMenuItem, useDropdownMenuClose } from '@/components/primitives/DropdownMenu';
|
||||
import { getURLForLLM } from '@/components/utils';
|
||||
import { tString, useLanguage } from '@/intl/client';
|
||||
import { getSiteMcpServerName } from '@/lib/mcp/naming';
|
||||
|
||||
type PageActionType = 'button' | 'dropdown-menu-item';
|
||||
|
||||
@@ -296,7 +297,7 @@ export function ActionOpenMCP(props: {
|
||||
const providerInfo = React.useMemo<{ label: string; icon: IconName; url: string }>(() => {
|
||||
switch (provider) {
|
||||
case 'vscode': {
|
||||
const vscodeConfig = { name: siteTitle, url: mcpURL };
|
||||
const vscodeConfig = { name: getSiteMcpServerName(siteTitle), url: mcpURL };
|
||||
return {
|
||||
label: 'VSCode',
|
||||
icon: 'vscode',
|
||||
@@ -332,7 +333,7 @@ export function ActionCopyMCPCommand(props: {
|
||||
const language = useLanguage();
|
||||
|
||||
const slug =
|
||||
siteTitle
|
||||
getSiteMcpServerName(siteTitle)
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9]+/g, '-')
|
||||
.replace(/^-|-$/g, '') || 'docs';
|
||||
|
||||
@@ -63,6 +63,7 @@ export function SearchContainer({
|
||||
query,
|
||||
results,
|
||||
resultsId,
|
||||
resultsQuery,
|
||||
resultsRef,
|
||||
searchValue,
|
||||
setQuery,
|
||||
@@ -178,6 +179,7 @@ export function SearchContainer({
|
||||
query={query}
|
||||
results={results}
|
||||
resultsId={resultsId}
|
||||
resultsQuery={resultsQuery}
|
||||
resultsRef={resultsRef}
|
||||
onResultSelect={onResultSelect}
|
||||
onResultHover={onResultHover}
|
||||
|
||||
@@ -27,6 +27,7 @@ export function SearchFrame(props: {
|
||||
query: string;
|
||||
results: ResultType[];
|
||||
resultsId: string;
|
||||
resultsQuery: string;
|
||||
resultsRef: React.Ref<SearchResultsRef>;
|
||||
onResultSelect?: () => void;
|
||||
/** Select the result under the mouse, so hover and keyboard share one highlight. */
|
||||
@@ -50,6 +51,7 @@ export function SearchFrame(props: {
|
||||
query,
|
||||
results,
|
||||
resultsId,
|
||||
resultsQuery,
|
||||
resultsRef,
|
||||
onResultSelect,
|
||||
onResultHover,
|
||||
@@ -78,7 +80,7 @@ export function SearchFrame(props: {
|
||||
fetching ? 'block animate-fade-in' : 'hidden animate-fade-out-slow'
|
||||
)}
|
||||
style={{
|
||||
animationDelay: fetching ? '2s' : undefined,
|
||||
animationDelay: fetching && results.length === 0 ? '2s' : undefined,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
@@ -118,7 +120,7 @@ export function SearchFrame(props: {
|
||||
) : (
|
||||
<SearchResults
|
||||
ref={resultsRef}
|
||||
query={query}
|
||||
query={resultsQuery}
|
||||
id={resultsId}
|
||||
fetching={fetching}
|
||||
results={results}
|
||||
|
||||
@@ -135,7 +135,7 @@ export const SearchInput = React.forwardRef<HTMLDivElement, SearchInputProps>(
|
||||
}
|
||||
}
|
||||
trailing={
|
||||
!showAsk && value && resultsCount > 0 ? (
|
||||
!showAsk && !fetching && value && resultsCount > 0 ? (
|
||||
<div className="animate-blur-in mr-2 text-sm text-tint-subtle">
|
||||
{t(language, 'search_results_count', resultsCount.toString())}
|
||||
</div>
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useResizeObserver } from '../hooks';
|
||||
import { Tooltip } from '../primitives';
|
||||
import { getPageResultPresentation } from './getPageResultHref';
|
||||
import { HighlightQuery } from './HighlightQuery';
|
||||
import type { ComputedPageResult } from './search-types';
|
||||
import type { ComputedPageResult, SearchResultSource } from './search-types';
|
||||
import { SearchResultItem } from './SearchResultItem';
|
||||
import { tString, useLanguage } from '@/intl/client';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
@@ -14,13 +14,15 @@ import { tcls } from '@/lib/tailwind';
|
||||
export const SearchPageResultItem = React.forwardRef(function SearchPageResultItem(
|
||||
props: {
|
||||
query: string;
|
||||
item: ComputedPageResult;
|
||||
item: ComputedPageResult & SearchResultSource;
|
||||
position: number;
|
||||
resultsCount: number;
|
||||
active: boolean;
|
||||
style?: React.CSSProperties;
|
||||
},
|
||||
ref: React.Ref<HTMLAnchorElement>
|
||||
) {
|
||||
const { query, item, active, style, ...rest } = props;
|
||||
const { query, item, active, position, resultsCount, style, ...rest } = props;
|
||||
const language = useLanguage();
|
||||
|
||||
const { preview: bestSection, description, href } = getPageResultPresentation(item);
|
||||
@@ -30,7 +32,9 @@ export const SearchPageResultItem = React.forwardRef(function SearchPageResultIt
|
||||
|
||||
const insights = {
|
||||
type: 'search_open_result' as const,
|
||||
query,
|
||||
...item.search,
|
||||
position,
|
||||
resultsCount,
|
||||
result: {
|
||||
pageId: item.pageId,
|
||||
spaceId: item.spaceId,
|
||||
|
||||
@@ -4,24 +4,36 @@ import { Icon } from '@gitbook/icons';
|
||||
|
||||
import { Favicon } from '../utils';
|
||||
import { HighlightQuery } from './HighlightQuery';
|
||||
import type { ComputedRecordResult } from './search-types';
|
||||
import type { ComputedRecordResult, SearchResultSource } from './search-types';
|
||||
import { SearchResultItem } from './SearchResultItem';
|
||||
import { tString, useLanguage } from '@/intl/client';
|
||||
|
||||
export const SearchRecordResultItem = React.forwardRef(function SearchRecordResultItem(
|
||||
props: {
|
||||
query: string;
|
||||
item: ComputedRecordResult;
|
||||
item: ComputedRecordResult & SearchResultSource;
|
||||
position: number;
|
||||
resultsCount: number;
|
||||
active: boolean;
|
||||
style?: React.CSSProperties;
|
||||
},
|
||||
ref: React.Ref<HTMLAnchorElement>
|
||||
) {
|
||||
const { query, item, active, style, ...rest } = props;
|
||||
const { query, item, active, position, resultsCount, style, ...rest } = props;
|
||||
const language = useLanguage();
|
||||
|
||||
const domain = getDomain(item.href);
|
||||
|
||||
const insights = {
|
||||
type: 'search_open_result' as const,
|
||||
...item.search,
|
||||
position,
|
||||
resultsCount,
|
||||
result: {
|
||||
recordId: item.id,
|
||||
},
|
||||
};
|
||||
|
||||
return (
|
||||
<SearchResultItem
|
||||
ref={ref}
|
||||
@@ -36,13 +48,7 @@ export const SearchRecordResultItem = React.forwardRef(function SearchRecordResu
|
||||
fallback={<Icon icon="memo" className="size-4" />}
|
||||
/>
|
||||
}
|
||||
insights={{
|
||||
type: 'search_open_result',
|
||||
query,
|
||||
result: {
|
||||
recordId: item.id,
|
||||
},
|
||||
}}
|
||||
insights={insights}
|
||||
aria-label={tString(language, 'search_page_result_title', item.title)}
|
||||
style={{ ...style }}
|
||||
{...rest}
|
||||
|
||||
@@ -72,7 +72,7 @@ export const SearchResults = React.forwardRef(function SearchResults(
|
||||
|
||||
const language = useLanguage();
|
||||
const { siteSpaceId } = useCurrentContent();
|
||||
const shouldAnimateResults = !query || fetching;
|
||||
const shouldAnimateResults = !query;
|
||||
const previousCursor = React.useRef<number | null>(cursor);
|
||||
const seenResultKeys = React.useRef(new Set<string>());
|
||||
const lastQuery = React.useRef(query);
|
||||
@@ -228,9 +228,8 @@ export const SearchResults = React.forwardRef(function SearchResults(
|
||||
// users should keep their place in it.
|
||||
if (navigatesCurrentWindow(event)) {
|
||||
event.currentTarget.blur();
|
||||
onResultSelect?.();
|
||||
}
|
||||
|
||||
onResultSelect?.();
|
||||
};
|
||||
const resultItemProps = {
|
||||
'aria-posinset': index + 1,
|
||||
@@ -272,6 +271,8 @@ export const SearchResults = React.forwardRef(function SearchResults(
|
||||
}}
|
||||
query={query}
|
||||
item={item}
|
||||
position={index + 1}
|
||||
resultsCount={results.length}
|
||||
active={index === cursor}
|
||||
style={{
|
||||
animationDelay: `${index * 25}ms,${100 + index * 25}ms`,
|
||||
@@ -341,6 +342,8 @@ export const SearchResults = React.forwardRef(function SearchResults(
|
||||
key={itemKey}
|
||||
query={query}
|
||||
item={item}
|
||||
position={index + 1}
|
||||
resultsCount={results.length}
|
||||
active={index === cursor}
|
||||
style={{
|
||||
animationDelay: `${index * 25}ms,${100 + index * 25}ms`,
|
||||
@@ -359,15 +362,11 @@ export const SearchResults = React.forwardRef(function SearchResults(
|
||||
{!fetching && results.length === 0 ? noResults : null}
|
||||
</>
|
||||
)}
|
||||
{fetching ? (
|
||||
{fetching && results.length === 0 ? (
|
||||
<div
|
||||
role="status"
|
||||
aria-busy="true"
|
||||
className={tcls(
|
||||
results.length > 0 ? 'mt-1' : '',
|
||||
'flex flex-col gap-1',
|
||||
'animate-[fadeIn_150ms_ease-out_both,pulse_2.4s_ease-in-out_600ms_infinite] motion-reduce:animate-none'
|
||||
)}
|
||||
className="flex animate-[fadeIn_150ms_ease-out_both,pulse_2.4s_ease-in-out_600ms_infinite] flex-col gap-1 motion-reduce:animate-none"
|
||||
>
|
||||
<SearchResultsPlaceholder />
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
|
||||
import { computeFilterSiteSpaceIds, filterResultsBySiteSpaces } from './filter';
|
||||
import { computeFilterSiteSpaceIds, getDisplayedSearchResults } from './filter';
|
||||
import type { OrderedComputedResult } from './search-types';
|
||||
|
||||
describe('computeFilterSiteSpaceIds', () => {
|
||||
@@ -36,7 +36,7 @@ describe('computeFilterSiteSpaceIds', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('filterResultsBySiteSpaces', () => {
|
||||
describe('getDisplayedSearchResults', () => {
|
||||
const page = (id: string, siteSpaceId?: string): OrderedComputedResult => ({
|
||||
type: 'page',
|
||||
id,
|
||||
@@ -52,7 +52,7 @@ describe('filterResultsBySiteSpaces', () => {
|
||||
|
||||
it('keeps the server order and drops pages outside the scope', () => {
|
||||
const results = [page('a', 'current'), page('b', 'other'), page('c', 'current'), page('d')];
|
||||
expect(filterResultsBySiteSpaces(results, ['current']).map((result) => result.id)).toEqual([
|
||||
expect(getDisplayedSearchResults(results, ['current']).map((result) => result.id)).toEqual([
|
||||
'a',
|
||||
'c',
|
||||
]);
|
||||
@@ -60,6 +60,24 @@ describe('filterResultsBySiteSpaces', () => {
|
||||
|
||||
it('returns every result when the scope is unrestricted', () => {
|
||||
const results = [page('b', 'other'), page('a', 'current')];
|
||||
expect(filterResultsBySiteSpaces(results, undefined)).toBe(results);
|
||||
expect(getDisplayedSearchResults(results, undefined)).toBe(results);
|
||||
});
|
||||
|
||||
it('caps the displayed list after applying the site space filter', () => {
|
||||
const pages = Array.from({ length: 10 }, (_, index) => page(`page-${index}`, 'current'));
|
||||
const records = Array.from({ length: 11 }, (_, index): OrderedComputedResult => ({
|
||||
type: 'record',
|
||||
id: `record-${index}`,
|
||||
title: `Record ${index}`,
|
||||
description: undefined,
|
||||
href: `/record-${index}`,
|
||||
score: 1,
|
||||
}));
|
||||
const results = [page('hidden', 'other'), ...pages, ...records];
|
||||
|
||||
expect(getDisplayedSearchResults(results, ['current'])).toEqual([
|
||||
...pages,
|
||||
...records.slice(0, 10),
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import type { OrderedComputedResult } from './search-types';
|
||||
import type { SearchScope } from './useSearch';
|
||||
|
||||
// Keep aligned with SiteInsightsSearchResultNumber in the GitBook API schema.
|
||||
const MAX_DISPLAYED_SEARCH_RESULTS = 20;
|
||||
|
||||
/**
|
||||
* Site spaces whose pages may be shown for a UI search scope, or `undefined` for no restriction.
|
||||
*
|
||||
@@ -29,20 +32,20 @@ export function computeFilterSiteSpaceIds(
|
||||
}
|
||||
}
|
||||
|
||||
/** Keep the server's order, dropping pages owned by a site space outside the scope. */
|
||||
export function filterResultsBySiteSpaces(
|
||||
results: OrderedComputedResult[],
|
||||
/** Keep the first results in server order within the selected site spaces. */
|
||||
export function getDisplayedSearchResults<Result extends OrderedComputedResult>(
|
||||
results: Result[],
|
||||
allowedSiteSpaceIds: string[] | undefined
|
||||
): OrderedComputedResult[] {
|
||||
if (!allowedSiteSpaceIds) {
|
||||
return results;
|
||||
}
|
||||
|
||||
const allowed = new Set(allowedSiteSpaceIds);
|
||||
|
||||
return results.filter(
|
||||
(result) =>
|
||||
result.type === 'record' ||
|
||||
(result.siteSpaceId !== undefined && allowed.has(result.siteSpaceId))
|
||||
);
|
||||
): Result[] {
|
||||
const allowed = allowedSiteSpaceIds && new Set(allowedSiteSpaceIds);
|
||||
const matching = allowed
|
||||
? results.filter(
|
||||
(result) =>
|
||||
result.type === 'record' ||
|
||||
(result.siteSpaceId !== undefined && allowed.has(result.siteSpaceId))
|
||||
)
|
||||
: results;
|
||||
return matching.length > MAX_DISPLAYED_SEARCH_RESULTS
|
||||
? matching.slice(0, MAX_DISPLAYED_SEARCH_RESULTS)
|
||||
: matching;
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@ export function computeRemoteSearchScope(
|
||||
}
|
||||
|
||||
switch (scope) {
|
||||
case 'all':
|
||||
return { mode: 'all' };
|
||||
case 'default':
|
||||
return { mode: 'current', siteSpaceId };
|
||||
case 'extended':
|
||||
|
||||
@@ -87,6 +87,11 @@ describe('createSearchPassStore', () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
expect(await search(store)).toEqual({ type: 'results', results: [] });
|
||||
expect(authorizations).toEqual(sent);
|
||||
|
||||
const refresh = store.requestPass();
|
||||
expect(await search(store)).toEqual({ type: 'route', reason: undefined });
|
||||
await refresh;
|
||||
expect(authorizations).toEqual(sent);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -136,4 +141,47 @@ describe('createSearchPassStore', () => {
|
||||
expect(await search(store)).toEqual({ type: 'results', results: [] });
|
||||
expect(authorizations).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('falls back for an unknown space without latching later searches to the route', async () => {
|
||||
let searchCalls = 0;
|
||||
const fetchSpy = spyOn(globalThis, 'fetch').mockImplementation((async (
|
||||
input: RequestInfo | URL
|
||||
) => {
|
||||
if (String(input) === '/~gitbook/search-pass') {
|
||||
return Response.json({ token: 'pass-1', expiresIn: 300_000 });
|
||||
}
|
||||
searchCalls += 1;
|
||||
if (searchCalls === 1) {
|
||||
return Response.json({
|
||||
items: [
|
||||
{
|
||||
type: 'space',
|
||||
id: 'space_unknown',
|
||||
title: 'Unknown',
|
||||
score: 1,
|
||||
pages: [
|
||||
{
|
||||
id: 'page_1',
|
||||
title: 'Page 1',
|
||||
path: 'page-1',
|
||||
score: 1,
|
||||
rank: 1,
|
||||
ancestors: [],
|
||||
urls: { app: 'https://app.gitbook.com/o/org/s/space' },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
return Response.json({ items: [] });
|
||||
}) as typeof fetch);
|
||||
restore = () => fetchSpy.mockRestore();
|
||||
const store = createSearchPassStore(directSearch);
|
||||
await store.requestPass();
|
||||
|
||||
expect(await search(store)).toEqual({ type: 'route', reason: 'unknown_space' });
|
||||
expect(await search(store)).toEqual({ type: 'results', results: [] });
|
||||
expect(searchCalls).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -124,11 +124,12 @@ export function createSearchPassStore(directSearch: DirectSearchProps | undefine
|
||||
|
||||
const search = async (input: {
|
||||
query: string;
|
||||
searchId?: string;
|
||||
scope: SearchSiteContentScope;
|
||||
signal: AbortSignal;
|
||||
asEmbeddable: boolean;
|
||||
}): Promise<DirectSearchOutcome> => {
|
||||
const { query, scope, signal, asEmbeddable } = input;
|
||||
const { query, searchId, scope, signal, asEmbeddable } = input;
|
||||
if (!directSearch) {
|
||||
return { type: 'route' };
|
||||
}
|
||||
@@ -139,7 +140,7 @@ export function createSearchPassStore(directSearch: DirectSearchProps | undefine
|
||||
return waitForCooldown(state, signal);
|
||||
}
|
||||
if (state.status !== 'ready') {
|
||||
return { type: 'route', reason: state.reason };
|
||||
return { type: 'route', reason: state.reason === '401' ? undefined : state.reason };
|
||||
}
|
||||
if (query.length <= 1) {
|
||||
return { type: 'results', results: [] };
|
||||
@@ -163,7 +164,7 @@ export function createSearchPassStore(directSearch: DirectSearchProps | undefine
|
||||
Authorization: `Bearer ${token}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(toSearchSiteContentBody(query, scope)),
|
||||
body: JSON.stringify(toSearchSiteContentBody(query, scope, searchId)),
|
||||
credentials: 'omit',
|
||||
signal: request.signal,
|
||||
});
|
||||
@@ -210,7 +211,8 @@ export function createSearchPassStore(directSearch: DirectSearchProps | undefine
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
|
||||
return results ? { type: 'results', results } : fallBack('unknown_space');
|
||||
// An unmapped space can come from a structure change after page load; fall back for this query only.
|
||||
return results ? { type: 'results', results } : { type: 'route', reason: 'unknown_space' };
|
||||
};
|
||||
|
||||
return { requestPass, search };
|
||||
|
||||
@@ -2,6 +2,10 @@ import type { IconName } from '@gitbook/icons';
|
||||
|
||||
export type OrderedComputedResult = ComputedPageResult | ComputedRecordResult;
|
||||
|
||||
export type SearchResultSource = {
|
||||
search: { query: string; searchId: string | undefined };
|
||||
};
|
||||
|
||||
export type BaseComputedResult = {
|
||||
id: string;
|
||||
title: string;
|
||||
@@ -55,6 +59,7 @@ export type SearchSiteContentScope =
|
||||
|
||||
export interface SearchSiteContentRequest {
|
||||
asEmbeddable?: boolean;
|
||||
searchId?: string;
|
||||
query: string;
|
||||
scope: SearchSiteContentScope;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
import { NuqsTestingAdapter } from 'nuqs/adapters/testing';
|
||||
import { createElement } from 'react';
|
||||
import { renderToString } from 'react-dom/server';
|
||||
|
||||
import { shouldKeepSearchState } from './useSearch';
|
||||
import { SearchContextProvider, shouldKeepSearchState, useSearchState } from './useSearch';
|
||||
|
||||
function SearchScopeValue() {
|
||||
return useSearchState()?.scope ?? null;
|
||||
}
|
||||
|
||||
describe('shouldKeepSearchState', () => {
|
||||
it('discards an empty default search state', () => {
|
||||
@@ -23,3 +30,25 @@ describe('shouldKeepSearchState', () => {
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it.each([
|
||||
['scope=all', 'default'],
|
||||
['global=true', 'default'],
|
||||
['scope=current&global=true', 'current'],
|
||||
['scope=extended&global=true', 'extended'],
|
||||
])('resolves %s to %s for a linked search', (params, scope) => {
|
||||
const search = createElement(
|
||||
SearchContextProvider,
|
||||
{ prewarmURL: '/~gitbook/search' },
|
||||
createElement(SearchScopeValue)
|
||||
);
|
||||
|
||||
expect(
|
||||
renderToString(
|
||||
createElement(NuqsTestingAdapter, {
|
||||
searchParams: `q=setup&${params}`,
|
||||
children: search,
|
||||
})
|
||||
)
|
||||
).toBe(scope);
|
||||
});
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import {
|
||||
type Values,
|
||||
parseAsBoolean,
|
||||
parseAsString,
|
||||
parseAsStringLiteral,
|
||||
useQueryStates,
|
||||
} from 'nuqs';
|
||||
import { type Values, parseAsString, parseAsStringLiteral, useQueryStates } from 'nuqs';
|
||||
import React from 'react';
|
||||
|
||||
import type { LinkProps } from '../primitives';
|
||||
@@ -16,8 +10,6 @@ import { useSearchPrewarm } from './useSearchPrewarm';
|
||||
import type { DirectSearchProps } from '@/lib/search-results';
|
||||
|
||||
export type SearchScope =
|
||||
/** Search all content on the site */
|
||||
| 'all'
|
||||
/** Search the current section's variant + matched/default variant for other sections */
|
||||
| 'default'
|
||||
/** Search all variants of the current section */
|
||||
@@ -41,9 +33,8 @@ export interface SearchState {
|
||||
const keyMap = {
|
||||
q: parseAsString,
|
||||
ask: parseAsString,
|
||||
scope: parseAsStringLiteral(['all', 'default', 'extended', 'current']).withDefault('default'),
|
||||
scope: parseAsStringLiteral(['default', 'extended', 'current']).withDefault('default'),
|
||||
section: parseAsString,
|
||||
global: parseAsBoolean, // Legacy support for global=true
|
||||
};
|
||||
|
||||
export type UpdateSearchState = (
|
||||
@@ -62,11 +53,6 @@ function normalizeRawState(values: Values<typeof keyMap>) {
|
||||
if (values.ask === 'true' && values.q) {
|
||||
return { ...values, q: null, ask: values.q };
|
||||
}
|
||||
// Handle legacy global=true
|
||||
if (values.global === true) {
|
||||
return { ...values, scope: 'all' as const, global: null };
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,6 @@ function useSearchKeyboardNavigation(props: {
|
||||
requestKey: string;
|
||||
flush: () => void;
|
||||
resultsRef: React.RefObject<SearchResultsRef | null>;
|
||||
abort: () => void;
|
||||
askCount: number;
|
||||
onAskSelect: (index: number) => void;
|
||||
}) {
|
||||
@@ -154,7 +153,6 @@ function useSearchKeyboardNavigation(props: {
|
||||
requestKey,
|
||||
flush,
|
||||
resultsRef,
|
||||
abort,
|
||||
askCount,
|
||||
onAskSelect,
|
||||
} = props;
|
||||
@@ -190,8 +188,6 @@ function useSearchKeyboardNavigation(props: {
|
||||
}
|
||||
|
||||
if (resultsRef.current?.select()) {
|
||||
// Stop any in-flight search request only when activating a result.
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -207,7 +203,6 @@ function useSearchKeyboardNavigation(props: {
|
||||
results.length,
|
||||
onAskSelect,
|
||||
resultsRef,
|
||||
abort,
|
||||
query,
|
||||
fetching,
|
||||
requestKey,
|
||||
@@ -229,13 +224,11 @@ function useSearchKeyboardNavigation(props: {
|
||||
}
|
||||
pendingOpenRef.current = null;
|
||||
if (results.length > 0) {
|
||||
if (resultsRef.current?.selectFirst()) {
|
||||
abort();
|
||||
}
|
||||
resultsRef.current?.selectFirst();
|
||||
} else if (!error && askCount > 0) {
|
||||
onAskSelect(0);
|
||||
}
|
||||
}, [isOpen, requestKey, fetching, error, results, resultsRef, abort, askCount, onAskSelect]);
|
||||
}, [isOpen, requestKey, fetching, error, results, resultsRef, askCount, onAskSelect]);
|
||||
|
||||
return {
|
||||
cursor,
|
||||
@@ -379,9 +372,10 @@ export function useSearchController(
|
||||
const selectedSection = state?.section ? findSearchSection(sections, state.section) : undefined;
|
||||
|
||||
const { consumeImmediate, flushRef, inputHandlers } = useSearchInputIntent();
|
||||
const { results, fetching, error, requestKey, flush, abort } = useSearchResults({
|
||||
const { results, resultsQuery, fetching, error, requestKey, flush, abort } = useSearchResults({
|
||||
asEmbeddable,
|
||||
disabled: options.requestsEnabled === false || !(normalizedQuery || withAI),
|
||||
disabled: options.requestsEnabled === false || showAsk || !(normalizedQuery || withAI),
|
||||
retainPreviousResults: Boolean(state?.open),
|
||||
query: normalizedQuery,
|
||||
siteSpaceId: siteSpace.id,
|
||||
siteSpaceIds,
|
||||
@@ -442,7 +436,6 @@ export function useSearchController(
|
||||
requestKey,
|
||||
flush,
|
||||
resultsRef,
|
||||
abort,
|
||||
askCount,
|
||||
onAskSelect: askInAssistant,
|
||||
});
|
||||
@@ -463,6 +456,7 @@ export function useSearchController(
|
||||
query: normalizedQuery,
|
||||
results,
|
||||
resultsId: searchResultsId,
|
||||
resultsQuery,
|
||||
resultsRef,
|
||||
searchValue,
|
||||
setQuery,
|
||||
|
||||
@@ -8,22 +8,36 @@ import {
|
||||
createRecommendedQuestionResult,
|
||||
getEmptySearchResults,
|
||||
} from './empty-search-results';
|
||||
import { computeFilterSiteSpaceIds, filterResultsBySiteSpaces } from './filter';
|
||||
import { computeFilterSiteSpaceIds, getDisplayedSearchResults } from './filter';
|
||||
import { useRecentSearchQueries } from './recent-queries';
|
||||
import { computeRemoteSearchScope } from './remote-scope';
|
||||
import { SEARCH_FALLBACK_HEADER, type SearchPassStore } from './search-pass-store';
|
||||
import type { OrderedComputedResult, SearchSiteContentScope } from './search-types';
|
||||
import type {
|
||||
OrderedComputedResult,
|
||||
SearchResultSource,
|
||||
SearchSiteContentScope,
|
||||
} from './search-types';
|
||||
import { streamRecommendedQuestions } from './server-actions';
|
||||
import { type SearchScope, useSearchPass } from './useSearch';
|
||||
import { useAI } from '@/components/AI';
|
||||
|
||||
export type ResultType = OrderedComputedResult | RecommendedQuestionResult;
|
||||
export type ResultType = RemoteSearchResult | RecommendedQuestionResult;
|
||||
|
||||
const SEARCH_ID_BYTES = 16;
|
||||
|
||||
type RemoteSearchResult = OrderedComputedResult & SearchResultSource;
|
||||
|
||||
type SearchAnswer = {
|
||||
scopeKey: string;
|
||||
query: string;
|
||||
results: RemoteSearchResult[];
|
||||
};
|
||||
|
||||
type RemoteSearchState =
|
||||
| { status: 'idle' }
|
||||
| { status: 'loading' }
|
||||
| { status: 'ready'; requestKey: string; results: OrderedComputedResult[] }
|
||||
| { status: 'error' };
|
||||
| { status: 'loading'; requestKey: string; answer?: SearchAnswer }
|
||||
| { status: 'ready'; requestKey: string; answer: SearchAnswer }
|
||||
| { status: 'error'; requestKey: string };
|
||||
|
||||
/**
|
||||
* We cache the recommended questions globally to avoid calling the API multiple times
|
||||
@@ -37,6 +51,7 @@ export function useSearchResults(props: {
|
||||
asEmbeddable?: boolean;
|
||||
disabled: boolean;
|
||||
query: string;
|
||||
retainPreviousResults: boolean;
|
||||
siteSpaceId: string;
|
||||
siteSpaceIds: string[];
|
||||
selectedSectionSiteSpaceIds?: string[];
|
||||
@@ -53,6 +68,7 @@ export function useSearchResults(props: {
|
||||
asEmbeddable,
|
||||
disabled,
|
||||
query,
|
||||
retainPreviousResults,
|
||||
siteSpaceId,
|
||||
siteSpaceIds,
|
||||
selectedSectionSiteSpaceIds,
|
||||
@@ -83,8 +99,15 @@ export function useSearchResults(props: {
|
||||
computeRemoteSearchScope(scope, siteSpaceId, siteSpaceIds, selectedSectionSiteSpaceIds),
|
||||
[scope, siteSpaceId, siteSpaceIds, selectedSectionSiteSpaceIds]
|
||||
);
|
||||
// Identifies the answer the UI needs now; an answer for any other key is never shown as current.
|
||||
const requestKey = JSON.stringify([query, remoteScope]);
|
||||
const scopeKey = JSON.stringify([
|
||||
searchURL,
|
||||
asEmbeddable,
|
||||
siteSpaceId,
|
||||
scope,
|
||||
remoteScope,
|
||||
filterSiteSpaceIds,
|
||||
]);
|
||||
const requestKey = JSON.stringify([scopeKey, query]);
|
||||
|
||||
const [remoteState, setRemoteState] = React.useState<RemoteSearchState>({ status: 'idle' });
|
||||
|
||||
@@ -100,6 +123,7 @@ export function useSearchResults(props: {
|
||||
|
||||
React.useEffect(() => {
|
||||
if (disabled) {
|
||||
setRemoteState({ status: 'idle' });
|
||||
return;
|
||||
}
|
||||
if (!query) {
|
||||
@@ -126,7 +150,7 @@ export function useSearchResults(props: {
|
||||
// We currently have a bug where the same question can be returned multiple times.
|
||||
// This is a workaround to avoid that.
|
||||
const questions = new Set<string>();
|
||||
const recommendedQuestions: RecommendedQuestionResult[] = [];
|
||||
let recommendedQuestions: RecommendedQuestionResult[] = [];
|
||||
|
||||
if (suggestions && suggestions.length > 0) {
|
||||
suggestions.forEach((question) => {
|
||||
@@ -153,7 +177,10 @@ export function useSearchResults(props: {
|
||||
}
|
||||
|
||||
questions.add(question);
|
||||
recommendedQuestions.push(createRecommendedQuestionResult(question, question));
|
||||
recommendedQuestions = [
|
||||
...recommendedQuestions,
|
||||
createRecommendedQuestionResult(question, question),
|
||||
];
|
||||
cachedRecommendedQuestions.set(siteSpaceId, recommendedQuestions);
|
||||
|
||||
if (!cancelled) {
|
||||
@@ -168,14 +195,19 @@ export function useSearchResults(props: {
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
}
|
||||
setRemoteState({ status: 'loading' });
|
||||
setRemoteState((state) => {
|
||||
const answer = 'answer' in state ? state.answer : undefined;
|
||||
return answer?.scopeKey === scopeKey
|
||||
? { status: 'loading', requestKey, answer }
|
||||
: { status: 'loading', requestKey };
|
||||
});
|
||||
let cancelled = false;
|
||||
const abortController = new AbortController();
|
||||
const send = async () => {
|
||||
flushRef.current = null;
|
||||
const fetchSearch = (
|
||||
scope: Parameters<typeof fetchSearchResults>[1]
|
||||
): Promise<OrderedComputedResult[]> =>
|
||||
): Promise<RemoteSearchResult[]> =>
|
||||
fetchSearchResults(
|
||||
searchURL,
|
||||
scope,
|
||||
@@ -188,25 +220,29 @@ export function useSearchResults(props: {
|
||||
try {
|
||||
const resultsPromise = fetchSearch(remoteScope);
|
||||
|
||||
const onResults = (results: OrderedComputedResult[]) => {
|
||||
const onResults = (results: RemoteSearchResult[]) => {
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!results) {
|
||||
// Can happen when the route cannot be found and returns the page's html.
|
||||
setRemoteState({ status: 'error' });
|
||||
setRemoteState({ status: 'error', requestKey });
|
||||
return;
|
||||
}
|
||||
|
||||
setRemoteState({ status: 'ready', requestKey, results });
|
||||
setRemoteState({
|
||||
status: 'ready',
|
||||
requestKey,
|
||||
answer: { scopeKey, query, results },
|
||||
});
|
||||
trackEvent({ type: 'search_type_query', query });
|
||||
};
|
||||
const onError = () => {
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
setRemoteState({ status: 'error' });
|
||||
setRemoteState({ status: 'error', requestKey });
|
||||
};
|
||||
|
||||
await resultsPromise.then(onResults, onError);
|
||||
@@ -215,7 +251,7 @@ export function useSearchResults(props: {
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
setRemoteState({ status: 'error' });
|
||||
setRemoteState({ status: 'error', requestKey });
|
||||
}
|
||||
};
|
||||
const timeout = setTimeout(send, consumeImmediate?.(query) ? 0 : 100);
|
||||
@@ -241,6 +277,7 @@ export function useSearchResults(props: {
|
||||
query,
|
||||
remoteScope,
|
||||
requestKey,
|
||||
scopeKey,
|
||||
trackEvent,
|
||||
withAI,
|
||||
siteSpaceId,
|
||||
@@ -252,6 +289,16 @@ export function useSearchResults(props: {
|
||||
searchPass,
|
||||
]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!retainPreviousResults) {
|
||||
setRemoteState((state) =>
|
||||
state.status === 'loading' && state.answer
|
||||
? { status: 'loading', requestKey: state.requestKey }
|
||||
: state
|
||||
);
|
||||
}
|
||||
}, [retainPreviousResults, requestKey]);
|
||||
|
||||
const flush = React.useCallback(() => {
|
||||
flushRef.current?.();
|
||||
}, []);
|
||||
@@ -262,10 +309,20 @@ export function useSearchResults(props: {
|
||||
setRemoteState((prev) => (prev.status === 'loading' ? { status: 'idle' } : prev));
|
||||
}, []);
|
||||
|
||||
const answer = 'answer' in remoteState ? remoteState.answer : undefined;
|
||||
const visibleAnswer =
|
||||
query &&
|
||||
!disabled &&
|
||||
answer?.scopeKey === scopeKey &&
|
||||
(answer.query === query || retainPreviousResults)
|
||||
? answer
|
||||
: undefined;
|
||||
|
||||
const streamedQuestions = cachedRecommendedQuestions.get(siteSpaceId);
|
||||
const results = React.useMemo<ResultType[]>(() => {
|
||||
if (!query) {
|
||||
const recommendedQuestions =
|
||||
cachedRecommendedQuestions.get(siteSpaceId) ??
|
||||
streamedQuestions ??
|
||||
suggestions?.map((question, index) =>
|
||||
createRecommendedQuestionResult(`recommended-question-${index}`, question)
|
||||
) ??
|
||||
@@ -278,27 +335,32 @@ export function useSearchResults(props: {
|
||||
});
|
||||
}
|
||||
|
||||
return remoteState.status === 'ready' && remoteState.requestKey === requestKey
|
||||
? filterResultsBySiteSpaces(remoteState.results, filterSiteSpaceIds)
|
||||
return visibleAnswer
|
||||
? getDisplayedSearchResults(visibleAnswer.results, filterSiteSpaceIds)
|
||||
: [];
|
||||
}, [
|
||||
remoteState,
|
||||
requestKey,
|
||||
visibleAnswer,
|
||||
query,
|
||||
filterSiteSpaceIds,
|
||||
withAI,
|
||||
siteSpaceId,
|
||||
streamedQuestions,
|
||||
suggestions,
|
||||
recentQueries,
|
||||
]);
|
||||
|
||||
// Between a query change and its loading state, the previous answer must still read as loading.
|
||||
const isOutdated = remoteState.status === 'ready' && remoteState.requestKey !== requestKey;
|
||||
|
||||
return {
|
||||
results,
|
||||
fetching: remoteState.status === 'loading' || (Boolean(query) && isOutdated),
|
||||
error: remoteState.status === 'error',
|
||||
resultsQuery: visibleAnswer?.query ?? query,
|
||||
fetching:
|
||||
Boolean(query) &&
|
||||
!disabled &&
|
||||
(remoteState.status === 'loading' ||
|
||||
(remoteState.status !== 'idle' && remoteState.requestKey !== requestKey)),
|
||||
error:
|
||||
Boolean(query) &&
|
||||
!disabled &&
|
||||
remoteState.status === 'error' &&
|
||||
remoteState.requestKey === requestKey,
|
||||
requestKey,
|
||||
flush,
|
||||
abort,
|
||||
@@ -315,17 +377,21 @@ async function fetchSearchResults(
|
||||
signal: AbortSignal,
|
||||
asEmbeddable: boolean | undefined,
|
||||
searchPass: SearchPassStore | null
|
||||
): Promise<OrderedComputedResult[]> {
|
||||
): Promise<RemoteSearchResult[]> {
|
||||
const directSearchId = generateSearchId();
|
||||
const direct = await searchPass?.search({
|
||||
query,
|
||||
searchId: directSearchId,
|
||||
scope,
|
||||
signal,
|
||||
asEmbeddable: Boolean(asEmbeddable),
|
||||
});
|
||||
if (direct?.type === 'results') {
|
||||
return direct.results;
|
||||
const search = { query, searchId: directSearchId };
|
||||
return direct.results.map((result) => ({ ...result, search }));
|
||||
}
|
||||
|
||||
const searchId = direct ? generateSearchId() : directSearchId;
|
||||
const response = await fetch(searchURL, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -335,6 +401,7 @@ async function fetchSearchResults(
|
||||
body: JSON.stringify({
|
||||
asEmbeddable,
|
||||
query,
|
||||
searchId,
|
||||
scope,
|
||||
}),
|
||||
signal,
|
||||
@@ -344,5 +411,12 @@ async function fetchSearchResults(
|
||||
throw new Error(`Search request failed: ${response.status}`);
|
||||
}
|
||||
|
||||
return response.json() as Promise<OrderedComputedResult[]>;
|
||||
const results: OrderedComputedResult[] = await response.json();
|
||||
const search = { query, searchId };
|
||||
return results.map((result) => ({ ...result, search }));
|
||||
}
|
||||
|
||||
function generateSearchId() {
|
||||
const bytes = globalThis.crypto?.getRandomValues(new Uint8Array(SEARCH_ID_BYTES));
|
||||
return bytes && Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');
|
||||
}
|
||||
|
||||
@@ -17,9 +17,11 @@ export function useSearchResultsCursor(props: {
|
||||
}, [query]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (fetching && resultCount === 0) {
|
||||
// Nothing is highlighted while results load, so Enter can't open the Ask row instead.
|
||||
setCursor(null);
|
||||
if (fetching) {
|
||||
if (resultCount === 0) {
|
||||
// Nothing is highlighted while results load, so Enter can't open the Ask row instead.
|
||||
setCursor(null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
import { getLLMsTxtURL } from '@/lib/llms-directive';
|
||||
import { getAdvertisedMcpEndpoint, getLLMsTxtURL } from '@/lib/llms-directive';
|
||||
|
||||
/**
|
||||
* Agent-facing pointer to the site index and the Markdown versions of pages.
|
||||
* Agent-facing pointer to the site index, the Markdown versions of pages and the MCP server.
|
||||
*/
|
||||
export function LLMsTxtDirective(props: { context: GitBookSiteContext }) {
|
||||
const { context } = props;
|
||||
const mcpEndpoint = getAdvertisedMcpEndpoint(context);
|
||||
|
||||
return (
|
||||
<div className="sr-only">
|
||||
For the complete documentation index, see <a href={getLLMsTxtURL(context)}>llms.txt</a>.
|
||||
Markdown versions of documentation pages are available by appending <code>.md</code> to
|
||||
page URLs.
|
||||
{mcpEndpoint ? (
|
||||
<>
|
||||
{' '}
|
||||
Agents can also search and read this documentation through its{' '}
|
||||
<a href={mcpEndpoint}>MCP server</a>.
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -241,6 +241,7 @@ export async function generateSitePageMetadata(props: SitePageProps): Promise<Me
|
||||
return {
|
||||
title: getPageFullTitle(context, page),
|
||||
description: page.description ?? '',
|
||||
keywords: page.keywords?.length ? page.keywords : undefined,
|
||||
alternates: {
|
||||
canonical,
|
||||
languages: alternates?.languages,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it, mock } from 'bun:test';
|
||||
|
||||
import type { RevisionPageDocument } from '@gitbook/api';
|
||||
import type { RevisionPageDocument, SiteRedirectDestination } from '@gitbook/api';
|
||||
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
|
||||
@@ -23,15 +23,28 @@ const page = {
|
||||
|
||||
describe('resolveMissingPagePath', () => {
|
||||
function createRedirectContext(options: {
|
||||
siteRedirect?: { source?: string; target: string; permanent?: boolean };
|
||||
siteRedirect?: {
|
||||
source?: string;
|
||||
target: string;
|
||||
permanent?: boolean;
|
||||
destination?: SiteRedirectDestination;
|
||||
};
|
||||
spaceRedirectPageId?: string;
|
||||
contextId?: string;
|
||||
structure?: GitBookSiteContext['structure'];
|
||||
revisionsBySpace?: Record<string, RevisionPageDocument[]>;
|
||||
}) {
|
||||
const getSiteRedirectBySource = mock(async ({ source }: { source: string }) =>
|
||||
options.siteRedirect && source === (options.siteRedirect.source ?? '/old')
|
||||
? {
|
||||
data: {
|
||||
target: options.siteRedirect.target,
|
||||
redirect: { permanent: options.siteRedirect.permanent ?? false },
|
||||
redirect: {
|
||||
permanent: options.siteRedirect.permanent ?? false,
|
||||
...(options.siteRedirect.destination
|
||||
? { destination: options.siteRedirect.destination }
|
||||
: {}),
|
||||
},
|
||||
},
|
||||
}
|
||||
: { error: { code: 404, message: 'Not found' } }
|
||||
@@ -41,19 +54,35 @@ describe('resolveMissingPagePath', () => {
|
||||
? { data: { id: options.spaceRedirectPageId } }
|
||||
: { error: { code: 404, message: 'Not found' } }
|
||||
);
|
||||
const getRevision = mock(async ({ spaceId }: { spaceId: string }) =>
|
||||
options.revisionsBySpace?.[spaceId]
|
||||
? { data: { pages: options.revisionsBySpace[spaceId] } }
|
||||
: { error: { code: 404, message: 'Not found' } }
|
||||
);
|
||||
|
||||
const defaultSiteSpace = {
|
||||
id: 'site-space-1',
|
||||
space: { id: 'space-1', revision: 'revision-1' },
|
||||
};
|
||||
|
||||
return {
|
||||
organizationId: 'org-1',
|
||||
site: { id: 'site-1' },
|
||||
siteSpace: defaultSiteSpace,
|
||||
structure: options.structure ?? {
|
||||
type: 'siteSpaces',
|
||||
structure: [defaultSiteSpace],
|
||||
},
|
||||
space: { id: 'space-1', revision: 'revision-1' },
|
||||
revisionId: 'revision-1',
|
||||
revision: { pages: [page] },
|
||||
contextId: options.contextId,
|
||||
linker: {
|
||||
toPathInSpace: (path: string) => path,
|
||||
toRelativePathInSite: (path: string) => path,
|
||||
toLinkForContent: (url: string) => new URL(url).pathname,
|
||||
},
|
||||
dataFetcher: { getSiteRedirectBySource, getRevisionPageByPath },
|
||||
dataFetcher: { getSiteRedirectBySource, getRevisionPageByPath, getRevision },
|
||||
} as unknown as GitBookSiteContext;
|
||||
}
|
||||
|
||||
@@ -87,6 +116,224 @@ describe('resolveMissingPagePath', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('ignores a site redirect that targets the current path', async () => {
|
||||
const context = createRedirectContext({
|
||||
siteRedirect: {
|
||||
source: '/release-notes/restricted',
|
||||
target: 'https://docs.example.com/release-notes/restricted',
|
||||
},
|
||||
});
|
||||
|
||||
expect(await resolveMissingPagePath(context, 'release-notes/restricted')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('ignores a site redirect that targets the current path with trailing slash, case, or query differences', async () => {
|
||||
const context = createRedirectContext({
|
||||
siteRedirect: {
|
||||
source: '/release-notes/restricted',
|
||||
target: 'https://docs.example.com/Release-Notes/Restricted/?tab=1#top',
|
||||
},
|
||||
});
|
||||
|
||||
expect(await resolveMissingPagePath(context, 'release-notes/restricted')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('ignores a space-relative redirect that resolves back to the current section path', async () => {
|
||||
const context = {
|
||||
...createRedirectContext({
|
||||
siteRedirect: {
|
||||
source: '/v3/getting-started',
|
||||
target: 'https://docs.example.com/docs/v3/getting-started',
|
||||
},
|
||||
}),
|
||||
linker: createLinker({
|
||||
host: 'docs.example.com',
|
||||
siteBasePath: '/',
|
||||
spaceBasePath: '/docs/',
|
||||
}),
|
||||
} as unknown as GitBookSiteContext;
|
||||
|
||||
expect(await resolveMissingPagePath(context, 'v3/getting-started')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('ignores a site redirect targeting a hidden site space on an adaptive site', async () => {
|
||||
const context = createRedirectContext({
|
||||
contextId: 'adaptive-ctx',
|
||||
siteRedirect: {
|
||||
source: '/getting-started',
|
||||
target: 'https://docs.example.com/docs/v3/getting-started',
|
||||
destination: {
|
||||
kind: 'site-page',
|
||||
siteSpaceId: 'site-space-hidden',
|
||||
pageId: 'page-v3',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(await resolveMissingPagePath(context, 'getting-started')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('ignores a site redirect targeting a hidden section on an adaptive site', async () => {
|
||||
const context = createRedirectContext({
|
||||
contextId: 'adaptive-ctx',
|
||||
structure: {
|
||||
type: 'sections',
|
||||
structure: [
|
||||
{
|
||||
object: 'site-section',
|
||||
id: 'section-visible',
|
||||
siteSpaces: [
|
||||
{
|
||||
id: 'site-space-1',
|
||||
space: { id: 'space-1', revision: 'revision-1' },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
} as unknown as GitBookSiteContext['structure'],
|
||||
siteRedirect: {
|
||||
source: '/old-section',
|
||||
target: 'https://docs.example.com/hidden-section',
|
||||
destination: {
|
||||
kind: 'site-section',
|
||||
siteSectionId: 'section-hidden',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(await resolveMissingPagePath(context, 'old-section')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('ignores a site redirect targeting a hidden page in the current space on an adaptive site', async () => {
|
||||
const context = createRedirectContext({
|
||||
contextId: 'adaptive-ctx',
|
||||
siteRedirect: {
|
||||
source: '/release-notes/restricted.html',
|
||||
target: 'https://docs.example.com/release-notes/restricted',
|
||||
destination: {
|
||||
kind: 'site-page',
|
||||
siteSpaceId: 'site-space-1',
|
||||
pageId: 'hidden-page',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(
|
||||
await resolveMissingPagePath(context, 'release-notes/restricted.html')
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it('checks target page visibility in another accessible space on an adaptive site', async () => {
|
||||
const otherSpace = {
|
||||
id: 'site-space-2',
|
||||
space: { id: 'space-2', revision: 'revision-2' },
|
||||
};
|
||||
const structure = {
|
||||
type: 'siteSpaces',
|
||||
structure: [
|
||||
{ id: 'site-space-1', space: { id: 'space-1', revision: 'revision-1' } },
|
||||
otherSpace,
|
||||
],
|
||||
} as unknown as GitBookSiteContext['structure'];
|
||||
|
||||
const hiddenContext = createRedirectContext({
|
||||
contextId: 'adaptive-ctx',
|
||||
structure,
|
||||
revisionsBySpace: { 'space-2': [] },
|
||||
siteRedirect: {
|
||||
source: '/old',
|
||||
target: 'https://docs.example.com/other/secret',
|
||||
destination: {
|
||||
kind: 'site-page',
|
||||
siteSpaceId: 'site-space-2',
|
||||
pageId: 'page-secret',
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(await resolveMissingPagePath(hiddenContext, 'old')).toBeUndefined();
|
||||
|
||||
const visibleContext = createRedirectContext({
|
||||
contextId: 'adaptive-ctx',
|
||||
structure,
|
||||
revisionsBySpace: { 'space-2': [{ ...page, id: 'page-secret', path: 'secret' }] },
|
||||
siteRedirect: {
|
||||
source: '/old',
|
||||
target: 'https://docs.example.com/other/secret',
|
||||
destination: {
|
||||
kind: 'site-page',
|
||||
siteSpaceId: 'site-space-2',
|
||||
pageId: 'page-secret',
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(await resolveMissingPagePath(visibleContext, 'old')).toEqual({
|
||||
type: 'redirect',
|
||||
destination: '/other/secret',
|
||||
permanent: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('ignores a site redirect targeting the reassigned default variant path of the current space', async () => {
|
||||
const context = {
|
||||
...createRedirectContext({
|
||||
contextId: 'adaptive-ctx',
|
||||
siteRedirect: {
|
||||
source: '/guide/missing',
|
||||
target: 'https://docs.example.com/guide/v3/missing',
|
||||
destination: {
|
||||
kind: 'site-space',
|
||||
siteSpaceId: 'site-space-v3',
|
||||
},
|
||||
},
|
||||
structure: {
|
||||
type: 'sections',
|
||||
structure: [
|
||||
{
|
||||
object: 'site-section',
|
||||
id: 'section-guide',
|
||||
siteSpaces: [
|
||||
{
|
||||
id: 'site-space-v3',
|
||||
path: 'v3',
|
||||
default: true,
|
||||
space: { id: 'space-v3', revision: 'revision-1' },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
} as unknown as GitBookSiteContext['structure'],
|
||||
}),
|
||||
siteSpace: {
|
||||
id: 'site-space-v3',
|
||||
path: 'v3',
|
||||
default: true,
|
||||
space: { id: 'space-v3', revision: 'revision-1' },
|
||||
},
|
||||
linker: createLinker({
|
||||
host: 'docs.example.com',
|
||||
siteBasePath: '/',
|
||||
spaceBasePath: '/guide/',
|
||||
}),
|
||||
} as unknown as GitBookSiteContext;
|
||||
|
||||
expect(await resolveMissingPagePath(context, 'missing')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('keeps a redirect whose current path contains a literal question mark', async () => {
|
||||
const context = createRedirectContext({
|
||||
siteRedirect: {
|
||||
source: '/foo/bar%3Fbaz',
|
||||
target: 'https://docs.example.com/foo/bar',
|
||||
},
|
||||
});
|
||||
|
||||
expect(await resolveMissingPagePath(context, 'foo/bar?baz')).toEqual({
|
||||
type: 'redirect',
|
||||
destination: '/foo/bar',
|
||||
permanent: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('resolves a space redirect to a page', async () => {
|
||||
const context = createRedirectContext({ spaceRedirectPageId: page.id });
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { permanentRedirect, redirect } from 'next/navigation';
|
||||
|
||||
import {
|
||||
type RevisionPageDocument,
|
||||
type SiteRedirect,
|
||||
SITE_REDIRECT_SOURCE_PATH_MAX_LENGTH,
|
||||
SITE_REDIRECT_SOURCE_PATH_PATTERN,
|
||||
} from '@gitbook/api';
|
||||
@@ -10,7 +11,12 @@ import { type GitBookSiteContext, fetchSiteContextForSiteSpace } from '@/lib/con
|
||||
import { getDataOrNull } from '@/lib/data';
|
||||
import { type ResolvedPagePath, resolvePageId } from '@/lib/pages';
|
||||
import { withLeadingSlash } from '@/lib/paths';
|
||||
import { findSiteSpaceByUrl, resolveSiteSpacePagePath } from '@/lib/sites';
|
||||
import {
|
||||
findSiteSpaceBy,
|
||||
findSiteSpaceByUrl,
|
||||
getSiteStructureSections,
|
||||
resolveSiteSpacePagePath,
|
||||
} from '@/lib/sites';
|
||||
|
||||
const MAX_PAGE_URL_REDIRECTS = 5;
|
||||
|
||||
@@ -113,6 +119,14 @@ export async function resolveMissingPagePath(
|
||||
.filter((source) => SITE_REDIRECT_SOURCE_PATH_REGEX.test(source))
|
||||
);
|
||||
|
||||
const currentPath = linker.toPathInSpace(redirectPathname);
|
||||
let currentPathWithDefaultVariant: string | null = null;
|
||||
if (context.siteSpace.default && context.siteSpace.path) {
|
||||
currentPathWithDefaultVariant = linker.toPathInSpace(
|
||||
`/${context.siteSpace.path}${redirectPathname}`
|
||||
);
|
||||
}
|
||||
|
||||
for (const source of redirectSources) {
|
||||
// We try to resolve the site redirect
|
||||
const resolvedSiteRedirect =
|
||||
@@ -126,6 +140,18 @@ export async function resolveMissingPagePath(
|
||||
})
|
||||
));
|
||||
if (resolvedSiteRedirect) {
|
||||
const destination = linker.toLinkForContent(resolvedSiteRedirect.target);
|
||||
// Skip self-redirects (including default-variant canonical aliases) and hidden adaptive targets.
|
||||
const targetsCurrentPath =
|
||||
isSameRedirectPath(currentPath, destination) ||
|
||||
(currentPathWithDefaultVariant !== null &&
|
||||
isSameRedirectPath(currentPathWithDefaultVariant, destination));
|
||||
if (
|
||||
targetsCurrentPath ||
|
||||
!(await isRedirectDestinationAccessible(context, resolvedSiteRedirect.redirect))
|
||||
) {
|
||||
break;
|
||||
}
|
||||
const isPublicLiveContext =
|
||||
!shareKey &&
|
||||
!context.changeRequest &&
|
||||
@@ -134,7 +160,7 @@ export async function resolveMissingPagePath(
|
||||
!context.isLoggedInVisitor;
|
||||
return {
|
||||
type: 'redirect',
|
||||
destination: linker.toLinkForContent(resolvedSiteRedirect.target),
|
||||
destination,
|
||||
permanent: Boolean(
|
||||
resolvedSiteRedirect.redirect?.permanent &&
|
||||
!resolvedSiteRedirect.redirect.draft &&
|
||||
@@ -202,6 +228,17 @@ export async function resolveSitePageFromURL(
|
||||
return null;
|
||||
}
|
||||
|
||||
export function isSameRedirectPath(currentPath: string, destination: string): boolean {
|
||||
if (!destination.startsWith('/') || destination.startsWith('//')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const destinationPathname = new URL(destination, 'https://gitbook.invalid').pathname;
|
||||
return (
|
||||
normalizeRedirectPathname(currentPath) === normalizeRedirectPathname(destinationPathname)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a pathname into a candidate source for site redirect matching.
|
||||
* The pathname is already percent-encoded, so each segment is decoded before being encoded
|
||||
@@ -226,6 +263,60 @@ function safeDecodeURIComponent(segment: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
async function isRedirectDestinationAccessible(
|
||||
context: GitBookSiteContext,
|
||||
siteRedirect: SiteRedirect | null
|
||||
): Promise<boolean> {
|
||||
if (!context.contextId || !siteRedirect?.destination) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const { destination } = siteRedirect;
|
||||
switch (destination.kind) {
|
||||
case 'external':
|
||||
return true;
|
||||
case 'site-section':
|
||||
return getSiteStructureSections(context.structure, { ignoreGroups: true }).some(
|
||||
(section) => section.id === destination.siteSectionId
|
||||
);
|
||||
case 'site-space':
|
||||
return Boolean(
|
||||
findSiteSpaceBy(context.structure, (entry) => entry.id === destination.siteSpaceId)
|
||||
);
|
||||
case 'site-page': {
|
||||
const target = findSiteSpaceBy(
|
||||
context.structure,
|
||||
(entry) => entry.id === destination.siteSpaceId
|
||||
);
|
||||
if (!target) {
|
||||
return false;
|
||||
}
|
||||
if (destination.siteSpaceId === context.siteSpace.id) {
|
||||
return Boolean(resolvePageId(context.revision.pages, destination.pageId));
|
||||
}
|
||||
const targetRevision = await getDataOrNull(
|
||||
context.dataFetcher.getRevision({
|
||||
spaceId: target.siteSpace.space.id,
|
||||
revisionId: target.siteSpace.space.revision,
|
||||
})
|
||||
);
|
||||
if (!targetRevision) {
|
||||
return false;
|
||||
}
|
||||
return Boolean(resolvePageId(targetRevision.pages, destination.pageId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeRedirectPathname(pathname: string): string {
|
||||
const normalized = pathname
|
||||
.split('/')
|
||||
.filter(Boolean)
|
||||
.map((segment) => safeDecodeURIComponent(segment).toLowerCase())
|
||||
.join('/');
|
||||
return `/${normalized}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the page path from the params.
|
||||
*/
|
||||
|
||||
@@ -13,9 +13,9 @@ import type { GitBookSiteContext } from '@/lib/context';
|
||||
import { createLinker } from '@/lib/links';
|
||||
|
||||
/**
|
||||
* `urn:air:{publisher}:{namespace}:{name}`, per the AI Catalog specification.
|
||||
* `urn:air:{publisher}:{name}[:{kind}]`, per the AI Catalog specification.
|
||||
*/
|
||||
const AIR_URN_PATTERN = /^urn:air:[^:]+:[^:]+:[^:]+$/;
|
||||
const AIR_URN_PATTERN = /^urn:air:[^:]+:[^:]+(:[^:]+)?$/;
|
||||
|
||||
function makeContext(
|
||||
options: {
|
||||
@@ -49,7 +49,7 @@ describe('buildSiteAiCatalog', () => {
|
||||
specVersion: AI_CATALOG_SPEC_VERSION,
|
||||
entries: [
|
||||
{
|
||||
identifier: 'urn:air:docs.acme.org:mcp:site_123',
|
||||
identifier: 'urn:air:docs.acme.org:site_123:mcp',
|
||||
type: 'application/mcp-server-card+json',
|
||||
url: 'https://docs.acme.org/~gitbook/mcp/server-card',
|
||||
},
|
||||
@@ -75,19 +75,19 @@ describe('buildSiteAiCatalog', () => {
|
||||
{
|
||||
scenario: 'a custom domain',
|
||||
options: { host: 'docs.acme.org', siteBasePath: '/' },
|
||||
identifier: 'urn:air:docs.acme.org:mcp:site_123',
|
||||
identifier: 'urn:air:docs.acme.org:site_123:mcp',
|
||||
url: 'https://docs.acme.org/~gitbook/mcp/server-card',
|
||||
},
|
||||
{
|
||||
scenario: 'a gitbook.io subdomain',
|
||||
options: { host: 'acme.gitbook.io', siteBasePath: '/' },
|
||||
identifier: 'urn:air:acme.gitbook.io:mcp:site_123',
|
||||
identifier: 'urn:air:acme.gitbook.io:site_123:mcp',
|
||||
url: 'https://acme.gitbook.io/~gitbook/mcp/server-card',
|
||||
},
|
||||
{
|
||||
scenario: 'a subpath site',
|
||||
options: { host: 'gitbook.com', siteBasePath: '/docs/' },
|
||||
identifier: 'urn:air:gitbook.com:mcp:site_123',
|
||||
identifier: 'urn:air:gitbook.com:site_123:mcp',
|
||||
url: 'https://gitbook.com/docs/~gitbook/mcp/server-card',
|
||||
},
|
||||
])('anchors the entry to $scenario', ({ options, identifier, url }) => {
|
||||
@@ -106,7 +106,7 @@ describe('buildSiteAiCatalog', () => {
|
||||
});
|
||||
const entry = buildSiteAiCatalog({ ...context, linker })?.entries[0];
|
||||
|
||||
expect(entry?.identifier).toBe('urn:air:localhost:mcp:site_123');
|
||||
expect(entry?.identifier).toBe('urn:air:localhost:site_123:mcp');
|
||||
expect(entry?.identifier).toMatch(AIR_URN_PATTERN);
|
||||
});
|
||||
|
||||
|
||||
@@ -5,7 +5,10 @@ import { MCP_SERVER_CARD_PATH } from '@/lib/mcp/paths';
|
||||
import { SERVER_CARD_MEDIA_TYPE } from '@/lib/mcp/serverCard';
|
||||
|
||||
export const AI_CATALOG_MEDIA_TYPE = 'application/ai-catalog+json';
|
||||
export const AI_CATALOG_SPEC_VERSION = '1.0';
|
||||
/**
|
||||
* The v1.0 release candidate. The final v1.0 is not published yet.
|
||||
*/
|
||||
export const AI_CATALOG_SPEC_VERSION = '0.9';
|
||||
|
||||
/**
|
||||
* The AI Catalog a site publishes at `/.well-known/ai-catalog.json`, per the
|
||||
@@ -24,7 +27,7 @@ export interface AiCatalog {
|
||||
|
||||
export interface AiCatalogEntry {
|
||||
/**
|
||||
* Required. Domain-anchored `urn:air:{publisher}:{namespace}:{name}`.
|
||||
* Required. Domain-anchored `urn:air:{publisher}:{name}[:{kind}]`.
|
||||
*/
|
||||
identifier: string;
|
||||
/**
|
||||
@@ -47,7 +50,7 @@ export function buildSiteAiCatalog(context: GitBookSiteContext): AiCatalog | nul
|
||||
|
||||
if (isSiteMcpEnabled(context)) {
|
||||
entries.push({
|
||||
identifier: buildCatalogIdentifier(context, 'mcp', site.id),
|
||||
identifier: buildCatalogIdentifier(context, site.id, 'mcp'),
|
||||
type: SERVER_CARD_MEDIA_TYPE,
|
||||
url: linker.toAbsoluteURL(linker.toPathInSite(MCP_SERVER_CARD_PATH)),
|
||||
});
|
||||
@@ -78,13 +81,9 @@ export async function serveSiteAiCatalog(
|
||||
});
|
||||
}
|
||||
|
||||
function buildCatalogIdentifier(
|
||||
context: GitBookSiteContext,
|
||||
namespace: string,
|
||||
name: string
|
||||
): string {
|
||||
function buildCatalogIdentifier(context: GitBookSiteContext, name: string, kind: string): string {
|
||||
const publisher = new URL(context.linker.toAbsoluteURL(context.linker.toPathInSite('')))
|
||||
.hostname;
|
||||
|
||||
return `urn:air:${publisher}:${namespace}:${name}`;
|
||||
return `urn:air:${publisher}:${name}:${kind}`;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import { assert } from 'ts-essentials';
|
||||
import type {
|
||||
ChangeRequest,
|
||||
CustomizationDefaultThemeMode,
|
||||
PublishedSiteContent,
|
||||
Revision,
|
||||
RevisionPageDocument,
|
||||
Site,
|
||||
@@ -32,6 +31,7 @@ import { isPublishedPreviewAllowed } from './preview';
|
||||
import type { AskVisitorAgent } from '@/lib/ask-visitor';
|
||||
import {
|
||||
type GitBookDataFetcher,
|
||||
type PublishedSiteContent,
|
||||
createDataFetcher,
|
||||
getDataOrNull,
|
||||
throwIfDataError,
|
||||
@@ -44,6 +44,7 @@ import {
|
||||
getLinkerForSiteSpace,
|
||||
getLocalizedTitle,
|
||||
getSiteStructureSections,
|
||||
listAllSiteSpaces,
|
||||
} from '@/lib/sites';
|
||||
|
||||
/**
|
||||
@@ -57,8 +58,6 @@ export type SiteURLData = Pick<
|
||||
| 'site'
|
||||
| 'siteSpace'
|
||||
| 'space'
|
||||
| 'revision'
|
||||
| 'changeRequest'
|
||||
| 'shareKey'
|
||||
| 'siteSection'
|
||||
| 'siteBasePath'
|
||||
@@ -71,6 +70,14 @@ export type SiteURLData = Pick<
|
||||
*/
|
||||
imagesContextId: string;
|
||||
|
||||
/**
|
||||
* Space revision, change request or site revision the URL previews: at most one is set. The
|
||||
* middleware reads them from the resolved content, which types them as exclusive.
|
||||
*/
|
||||
revision?: string;
|
||||
changeRequest?: string;
|
||||
siteRevision?: string;
|
||||
|
||||
/**
|
||||
* Whether this request is a fallback rendering.
|
||||
* We use this when switching variant as we don't know if the page exists in the other variant.
|
||||
@@ -217,6 +224,9 @@ export type GitBookSiteContext = GitBookSpaceContext & {
|
||||
/** Whether search indexation is blocked for this deployment. */
|
||||
noIndexSearch: boolean;
|
||||
|
||||
/** Site revision the URL previews. Content is read as it pins it. */
|
||||
siteRevision?: string;
|
||||
|
||||
/** Whether the request included a visitor token. */
|
||||
isLoggedInVisitor: boolean;
|
||||
|
||||
@@ -250,6 +260,13 @@ export function getBaseContext(input: {
|
||||
|
||||
const dataFetcher = createDataFetcher({
|
||||
apiToken: siteURLData.apiToken ?? null,
|
||||
siteRevision: siteURLData.siteRevision
|
||||
? {
|
||||
organizationId: siteURLData.organization,
|
||||
siteId: siteURLData.site,
|
||||
siteRevisionId: siteURLData.siteRevision,
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
|
||||
const linkerInput: SiteLinkerInput = {
|
||||
@@ -305,6 +322,7 @@ export async function fetchSiteContextByURLLookup(
|
||||
contextId: data.contextId,
|
||||
isFallback: data.isFallback ?? false,
|
||||
noIndexSearch: data.noIndexSearch ?? false,
|
||||
siteRevision: data.siteRevision,
|
||||
isLoggedInVisitor: data.isLoggedInVisitor ?? false,
|
||||
preview: data.preview ?? false,
|
||||
displayAgentInstructions: data.displayAgentInstructions,
|
||||
@@ -329,6 +347,7 @@ export async function fetchSiteContextByIds(
|
||||
contextId?: string;
|
||||
isFallback: boolean;
|
||||
noIndexSearch: boolean;
|
||||
siteRevision?: string;
|
||||
isLoggedInVisitor: boolean;
|
||||
preview: boolean;
|
||||
displayAgentInstructions?: boolean;
|
||||
@@ -462,6 +481,12 @@ export async function fetchSiteContextByIds(
|
||||
|
||||
return {
|
||||
...spaceContext,
|
||||
// Only the site's own spaces are read at the site revision it previews.
|
||||
dataFetcher: ids.siteRevision
|
||||
? spaceContext.dataFetcher.withSiteRevisionSpaces(
|
||||
listAllSiteSpaces(siteStructure).map((entry) => entry.space.id)
|
||||
)
|
||||
: spaceContext.dataFetcher,
|
||||
locale: siteSpace.space.language ?? spaceContext.locale,
|
||||
linker: getLinkerForSiteSpace(siteLinker, siteSpace, spaceContext.revision.pages),
|
||||
organizationId: ids.organization,
|
||||
@@ -477,6 +502,7 @@ export async function fetchSiteContextByIds(
|
||||
contextId: ids.contextId,
|
||||
isFallback: ids.isFallback,
|
||||
noIndexSearch: ids.noIndexSearch,
|
||||
siteRevision: ids.siteRevision,
|
||||
isLoggedInVisitor: ids.isLoggedInVisitor,
|
||||
preview: ids.preview,
|
||||
displayAgentInstructions: ids.displayAgentInstructions,
|
||||
|
||||
@@ -33,6 +33,7 @@ describe('searchSiteContent', () => {
|
||||
organizationId: 'org-1',
|
||||
siteId: 'site-1',
|
||||
query: 'test',
|
||||
routeReason: 'fallback:403' as const,
|
||||
scope: { mode: 'all' as const },
|
||||
};
|
||||
|
||||
@@ -45,6 +46,9 @@ describe('searchSiteContent', () => {
|
||||
'https://api.example.com/cache/v1/orgs/org-1/sites/site-1/search'
|
||||
);
|
||||
expect(new Headers(init?.headers).get('authorization')).toBe('Bearer site-token');
|
||||
expect(new Headers(init?.headers).get('x-gitbook-search-route-reason')).toBe(
|
||||
'fallback:403'
|
||||
);
|
||||
expect(cacheLife).not.toHaveBeenCalled();
|
||||
expect(cacheTag).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -6,14 +6,14 @@ import {
|
||||
GitBookAPI,
|
||||
type HttpResponse,
|
||||
type RenderIntegrationUI,
|
||||
type SiteSearchScope,
|
||||
} from '@gitbook/api';
|
||||
import { getCacheTag, getComputedContentSourceCacheTags } from '@gitbook/cache-tags';
|
||||
|
||||
import { cache } from '../cache';
|
||||
import { DataFetcherError, wrapDataFetcherError } from './errors';
|
||||
import type { GitBookDataFetcher } from './types';
|
||||
import type { DataFetcherResponse, GitBookDataFetcher } from './types';
|
||||
import { GITBOOK_API_TOKEN, GITBOOK_API_URL, GITBOOK_USER_AGENT } from '@/lib/env';
|
||||
import { toSearchSiteContentBody } from '@/lib/search-results';
|
||||
import { trace } from '@/lib/tracing';
|
||||
|
||||
interface DataFetcherInput {
|
||||
@@ -21,6 +21,25 @@ interface DataFetcherInput {
|
||||
* API token.
|
||||
*/
|
||||
apiToken: string | null;
|
||||
|
||||
/**
|
||||
* Site revision being previewed. The site's spaces and OpenAPI specs are read at it.
|
||||
*/
|
||||
siteRevision?: DataFetcherSiteRevision;
|
||||
}
|
||||
|
||||
/**
|
||||
* A site revision, as a preview URL resolves it.
|
||||
*/
|
||||
export interface DataFetcherSiteRevision {
|
||||
organizationId: string;
|
||||
siteId: string;
|
||||
siteRevisionId: string;
|
||||
/**
|
||||
* Spaces of the site, read at the site revision. Other spaces are read live. Until the site
|
||||
* structure is known, every space is read at the site revision.
|
||||
*/
|
||||
spaceIds?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,10 +65,18 @@ export function createDataFetcher(
|
||||
|
||||
withToken({ apiToken }) {
|
||||
return createDataFetcher({
|
||||
...input,
|
||||
apiToken,
|
||||
});
|
||||
},
|
||||
|
||||
withSiteRevisionSpaces(spaceIds) {
|
||||
return createDataFetcher({
|
||||
...input,
|
||||
siteRevision: input.siteRevision ? { ...input.siteRevision, spaceIds } : undefined,
|
||||
});
|
||||
},
|
||||
|
||||
//
|
||||
// API that are tied to the token
|
||||
//
|
||||
@@ -77,61 +104,120 @@ export function createDataFetcher(
|
||||
});
|
||||
},
|
||||
getRevision(params) {
|
||||
return getRevision(input, {
|
||||
spaceId: params.spaceId,
|
||||
revisionId: params.revisionId,
|
||||
metadata: params.metadata ?? false,
|
||||
});
|
||||
return readAtSiteRevision(
|
||||
input,
|
||||
params.spaceId,
|
||||
(siteRevisionInput) =>
|
||||
getRevisionAtSiteRevision(siteRevisionInput, {
|
||||
spaceId: params.spaceId,
|
||||
metadata: params.metadata ?? false,
|
||||
}),
|
||||
() =>
|
||||
getRevision(input, {
|
||||
spaceId: params.spaceId,
|
||||
revisionId: params.revisionId,
|
||||
metadata: params.metadata ?? false,
|
||||
})
|
||||
);
|
||||
},
|
||||
getRevisionPageByPath(params) {
|
||||
return getRevisionPageByPath(input, {
|
||||
spaceId: params.spaceId,
|
||||
revisionId: params.revisionId,
|
||||
path: params.path,
|
||||
metadata: params.metadata,
|
||||
cachedMetadata: params.cachedMetadata,
|
||||
});
|
||||
return readAtSiteRevision(
|
||||
input,
|
||||
params.spaceId,
|
||||
(siteRevisionInput) =>
|
||||
getPageByPathAtSiteRevision(siteRevisionInput, {
|
||||
spaceId: params.spaceId,
|
||||
path: params.path,
|
||||
metadata: params.metadata ?? false,
|
||||
cachedMetadata: params.cachedMetadata ?? false,
|
||||
}),
|
||||
() =>
|
||||
getRevisionPageByPath(input, {
|
||||
spaceId: params.spaceId,
|
||||
revisionId: params.revisionId,
|
||||
path: params.path,
|
||||
metadata: params.metadata,
|
||||
cachedMetadata: params.cachedMetadata,
|
||||
})
|
||||
);
|
||||
},
|
||||
getRevisionPageMarkdown(params) {
|
||||
return getRevisionPageMarkdown(
|
||||
return readAtSiteRevision(
|
||||
input,
|
||||
{
|
||||
spaceId: params.spaceId,
|
||||
revisionId: params.revisionId,
|
||||
pageId: params.pageId,
|
||||
},
|
||||
// We pass the name of the function to distinguish between cache entries
|
||||
// By default Next only uses the arguments, the filename and the position of the function inside the file
|
||||
// By adding a dummy argument with the function name, we can change the order without breaking anything
|
||||
'getRevisionPageMarkdown'
|
||||
params.spaceId,
|
||||
(siteRevisionInput) =>
|
||||
getPageMarkdownAtSiteRevision(siteRevisionInput, {
|
||||
spaceId: params.spaceId,
|
||||
pageId: params.pageId,
|
||||
}),
|
||||
() =>
|
||||
getRevisionPageMarkdown(
|
||||
input,
|
||||
{
|
||||
spaceId: params.spaceId,
|
||||
revisionId: params.revisionId,
|
||||
pageId: params.pageId,
|
||||
},
|
||||
// We pass the name of the function to distinguish between cache entries
|
||||
// By default Next only uses the arguments, the filename and the position of the function inside the file
|
||||
// By adding a dummy argument with the function name, we can change the order without breaking anything
|
||||
'getRevisionPageMarkdown'
|
||||
)
|
||||
);
|
||||
},
|
||||
getRevisionPageDocument(params) {
|
||||
return getRevisionPageDocument(
|
||||
return readAtSiteRevision(
|
||||
input,
|
||||
{
|
||||
spaceId: params.spaceId,
|
||||
revisionId: params.revisionId,
|
||||
pageId: params.pageId,
|
||||
},
|
||||
// We pass the name of the function to distinguish between cache entries
|
||||
// By default Next only uses the arguments, the filename and the position of the function inside the file
|
||||
// By adding a dummy argument with the function name, we can change the order without breaking anything
|
||||
'getRevisionPageDocument'
|
||||
params.spaceId,
|
||||
(siteRevisionInput) =>
|
||||
getPageDocumentAtSiteRevision(siteRevisionInput, {
|
||||
spaceId: params.spaceId,
|
||||
pageId: params.pageId,
|
||||
}),
|
||||
() =>
|
||||
getRevisionPageDocument(
|
||||
input,
|
||||
{
|
||||
spaceId: params.spaceId,
|
||||
revisionId: params.revisionId,
|
||||
pageId: params.pageId,
|
||||
},
|
||||
// We pass the name of the function to distinguish between cache entries
|
||||
// By default Next only uses the arguments, the filename and the position of the function inside the file
|
||||
// By adding a dummy argument with the function name, we can change the order without breaking anything
|
||||
'getRevisionPageDocument'
|
||||
)
|
||||
);
|
||||
},
|
||||
getRevisionReusableContentDocument(params) {
|
||||
return getRevisionReusableContentDocument(input, {
|
||||
spaceId: params.spaceId,
|
||||
revisionId: params.revisionId,
|
||||
reusableContentId: params.reusableContentId,
|
||||
});
|
||||
return readAtSiteRevision(
|
||||
input,
|
||||
params.spaceId,
|
||||
(siteRevisionInput) =>
|
||||
getReusableContentDocumentAtSiteRevision(siteRevisionInput, {
|
||||
spaceId: params.spaceId,
|
||||
reusableContentId: params.reusableContentId,
|
||||
}),
|
||||
() =>
|
||||
getRevisionReusableContentDocument(input, {
|
||||
spaceId: params.spaceId,
|
||||
revisionId: params.revisionId,
|
||||
reusableContentId: params.reusableContentId,
|
||||
})
|
||||
);
|
||||
},
|
||||
getLatestOpenAPISpecVersionContent(params) {
|
||||
return getLatestOpenAPISpecVersionContent(input, {
|
||||
organizationId: params.organizationId,
|
||||
slug: params.slug,
|
||||
});
|
||||
return readAtSiteRevision(
|
||||
input,
|
||||
null,
|
||||
(siteRevisionInput) =>
|
||||
getOpenAPISpecContentAtSiteRevision(siteRevisionInput, { slug: params.slug }),
|
||||
() =>
|
||||
getLatestOpenAPISpecVersionContent(input, {
|
||||
organizationId: params.organizationId,
|
||||
slug: params.slug,
|
||||
})
|
||||
);
|
||||
},
|
||||
getSpace(params) {
|
||||
return getSpace(input, {
|
||||
@@ -195,15 +281,233 @@ export function createDataFetcher(
|
||||
},
|
||||
|
||||
listRevisionPageMetaLinks(params) {
|
||||
return listRevisionPageMetaLinks(input, {
|
||||
spaceId: params.spaceId,
|
||||
revisionId: params.revisionId,
|
||||
pageId: params.pageId,
|
||||
});
|
||||
return readAtSiteRevision(
|
||||
input,
|
||||
params.spaceId,
|
||||
(siteRevisionInput) =>
|
||||
listPageMetaLinksAtSiteRevision(siteRevisionInput, {
|
||||
spaceId: params.spaceId,
|
||||
pageId: params.pageId,
|
||||
}),
|
||||
() =>
|
||||
listRevisionPageMetaLinks(input, {
|
||||
spaceId: params.spaceId,
|
||||
revisionId: params.revisionId,
|
||||
pageId: params.pageId,
|
||||
})
|
||||
);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Data fetcher input to read at a site revision. It leaves out the site's space IDs, which only
|
||||
* choose what to read at the site revision, so they stay out of cache keys.
|
||||
*/
|
||||
type SiteRevisionDataFetcherInput = DataFetcherInput & {
|
||||
siteRevision: Omit<DataFetcherSiteRevision, 'spaceIds'>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Read content at the site revision of the input, or `live` when there is no site revision or
|
||||
* for a space outside the site. An OpenAPI spec (no space) is always read at the site revision.
|
||||
*/
|
||||
async function readAtSiteRevision<T>(
|
||||
input: DataFetcherInput,
|
||||
spaceId: string | null,
|
||||
atSiteRevision: (input: SiteRevisionDataFetcherInput) => Promise<DataFetcherResponse<T>>,
|
||||
live: () => Promise<DataFetcherResponse<T>>
|
||||
): Promise<DataFetcherResponse<T>> {
|
||||
const { siteRevision } = input;
|
||||
if (!siteRevision || (spaceId && siteRevision.spaceIds?.includes(spaceId) === false)) {
|
||||
return live();
|
||||
}
|
||||
|
||||
const { spaceIds: _spaceIds, ...cacheableSiteRevision } = siteRevision;
|
||||
return atSiteRevision({ ...input, siteRevision: cacheableSiteRevision });
|
||||
}
|
||||
|
||||
// Each read at a site revision sends the same query as its live counterpart.
|
||||
|
||||
const getRevisionAtSiteRevision = cache(
|
||||
async (input: SiteRevisionDataFetcherInput, params: { spaceId: string; metadata: boolean }) => {
|
||||
'use cache';
|
||||
return fetchAtSiteRevision(
|
||||
input,
|
||||
`getRevisionAtSiteRevision(${params.spaceId})`,
|
||||
(api, { organizationId, siteId, siteRevisionId }) =>
|
||||
api.orgs.getRevisionInSiteRevision(
|
||||
organizationId,
|
||||
siteId,
|
||||
siteRevisionId,
|
||||
params.spaceId,
|
||||
{ metadata: params.metadata },
|
||||
{ ...noCacheFetchOptions }
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
const getPageByPathAtSiteRevision = cache(
|
||||
async (
|
||||
input: SiteRevisionDataFetcherInput,
|
||||
params: { spaceId: string; path: string; metadata: boolean; cachedMetadata: boolean }
|
||||
) => {
|
||||
'use cache';
|
||||
return fetchAtSiteRevision(
|
||||
input,
|
||||
`getPageByPathAtSiteRevision(${params.spaceId}, ${params.path})`,
|
||||
(api, { organizationId, siteId, siteRevisionId }) =>
|
||||
api.orgs.getPageByPathInSiteRevision(
|
||||
organizationId,
|
||||
siteId,
|
||||
siteRevisionId,
|
||||
params.spaceId,
|
||||
encodeURIComponent(params.path),
|
||||
{ metadata: params.metadata, cachedMetadata: params.cachedMetadata },
|
||||
{ ...noCacheFetchOptions }
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
const getPageMarkdownAtSiteRevision = cache(
|
||||
async (input: SiteRevisionDataFetcherInput, params: { spaceId: string; pageId: string }) => {
|
||||
'use cache';
|
||||
return wrapDataFetcherError(async () => {
|
||||
return trace(
|
||||
`getPageMarkdownAtSiteRevision(${params.spaceId}, ${params.pageId})`,
|
||||
async () => {
|
||||
const { organizationId, siteId, siteRevisionId } = input.siteRevision;
|
||||
const res = await apiClient(input).orgs.getPageInSiteRevision(
|
||||
organizationId,
|
||||
siteId,
|
||||
siteRevisionId,
|
||||
params.spaceId,
|
||||
params.pageId,
|
||||
{
|
||||
format: 'markdown',
|
||||
'format.markdown.refs': 'stable',
|
||||
evaluated: 'deterministic-only',
|
||||
metadata: false,
|
||||
},
|
||||
{ ...noCacheFetchOptions }
|
||||
);
|
||||
cacheTag(...getCacheTagsFromResponse(res));
|
||||
cacheLife('max');
|
||||
|
||||
if (!('markdown' in res.data)) {
|
||||
throw new DataFetcherError('Page is not a document', 404);
|
||||
}
|
||||
return res.data.markdown;
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const getPageDocumentAtSiteRevision = cache(
|
||||
async (input: SiteRevisionDataFetcherInput, params: { spaceId: string; pageId: string }) => {
|
||||
'use cache';
|
||||
return fetchAtSiteRevision(
|
||||
input,
|
||||
`getPageDocumentAtSiteRevision(${params.spaceId}, ${params.pageId})`,
|
||||
(api, { organizationId, siteId, siteRevisionId }) =>
|
||||
api.orgs.getPageDocumentInSiteRevision(
|
||||
organizationId,
|
||||
siteId,
|
||||
siteRevisionId,
|
||||
params.spaceId,
|
||||
params.pageId,
|
||||
{ evaluated: 'deterministic-only', dereferenced: 'reusable-contents' },
|
||||
{ ...noCacheFetchOptions }
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
const getReusableContentDocumentAtSiteRevision = cache(
|
||||
async (
|
||||
input: SiteRevisionDataFetcherInput,
|
||||
params: { spaceId: string; reusableContentId: string }
|
||||
) => {
|
||||
'use cache';
|
||||
return fetchAtSiteRevision(
|
||||
input,
|
||||
`getReusableContentDocumentAtSiteRevision(${params.spaceId}, ${params.reusableContentId})`,
|
||||
(api, { organizationId, siteId, siteRevisionId }) =>
|
||||
api.orgs.getReusableContentDocumentInSiteRevision(
|
||||
organizationId,
|
||||
siteId,
|
||||
siteRevisionId,
|
||||
params.spaceId,
|
||||
params.reusableContentId,
|
||||
{ evaluated: 'deterministic-only' },
|
||||
{ ...noCacheFetchOptions }
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
const listPageMetaLinksAtSiteRevision = cache(
|
||||
async (input: SiteRevisionDataFetcherInput, params: { spaceId: string; pageId: string }) => {
|
||||
'use cache';
|
||||
return fetchAtSiteRevision(
|
||||
input,
|
||||
`listPageMetaLinksAtSiteRevision(${params.spaceId}, ${params.pageId})`,
|
||||
(api, { organizationId, siteId, siteRevisionId }) =>
|
||||
api.orgs.listPageMetaLinksInSiteRevision(
|
||||
organizationId,
|
||||
siteId,
|
||||
siteRevisionId,
|
||||
params.spaceId,
|
||||
params.pageId,
|
||||
{ ...noCacheFetchOptions }
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
const getOpenAPISpecContentAtSiteRevision = cache(
|
||||
async (input: SiteRevisionDataFetcherInput, params: { slug: string }) => {
|
||||
'use cache';
|
||||
return fetchAtSiteRevision(
|
||||
input,
|
||||
`getOpenAPISpecContentAtSiteRevision(${params.slug})`,
|
||||
(api, { organizationId, siteId, siteRevisionId }) =>
|
||||
api.orgs.getOpenApiSpecContentInSiteRevision(
|
||||
organizationId,
|
||||
siteId,
|
||||
siteRevisionId,
|
||||
params.slug,
|
||||
{ ...noCacheFetchOptions }
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Fetch from an endpoint at a site revision. What a site revision pins never changes, so the
|
||||
* response is cached forever.
|
||||
*/
|
||||
function fetchAtSiteRevision<T>(
|
||||
input: SiteRevisionDataFetcherInput,
|
||||
name: string,
|
||||
request: (
|
||||
api: ReturnType<typeof apiClient>,
|
||||
siteRevision: SiteRevisionDataFetcherInput['siteRevision']
|
||||
) => Promise<HttpResponse<T, unknown>>
|
||||
): Promise<DataFetcherResponse<T>> {
|
||||
return wrapDataFetcherError(async () => {
|
||||
return trace(name, async () => {
|
||||
const res = await request(apiClient(input), input.siteRevision);
|
||||
cacheTag(...getCacheTagsFromResponse(res));
|
||||
cacheLife('max');
|
||||
return res.data;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Infer the cache life from the api response headers.
|
||||
* @param response The response from the API call.
|
||||
@@ -793,28 +1097,16 @@ async function searchSiteContent(
|
||||
return trace(
|
||||
`searchSiteContent(${params.organizationId}, ${params.siteId}, ${params.query})`,
|
||||
async () => {
|
||||
const { organizationId, siteId, query, scope } = params;
|
||||
const { organizationId, siteId, query, scope, searchId, routeReason } = params;
|
||||
const api = apiClient(input);
|
||||
const res = await api.orgs.searchSiteContent(
|
||||
organizationId,
|
||||
siteId,
|
||||
{
|
||||
query,
|
||||
...(scope.mode === 'current' && scope.restrictTo
|
||||
? {
|
||||
// `restrictTo` only exists in the newer `scope` request shape,
|
||||
// and the published @gitbook/api types don't include it yet.
|
||||
scope: {
|
||||
mode: 'default',
|
||||
currentSiteSpace: scope.siteSpaceId,
|
||||
restrictTo: scope.restrictTo,
|
||||
} as SiteSearchScope,
|
||||
}
|
||||
: scope),
|
||||
},
|
||||
toSearchSiteContentBody(query, scope, searchId),
|
||||
{},
|
||||
{
|
||||
...noCacheFetchOptions,
|
||||
headers: { 'x-gitbook-search-route-reason': routeReason },
|
||||
}
|
||||
);
|
||||
return res.data.items;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { GitBookAPI, PublishedSiteContentLookup, SiteVisitorPayload } from '@gitbook/api';
|
||||
import type * as API from '@gitbook/api';
|
||||
|
||||
import { apiClient } from './api';
|
||||
import { getExposableError } from './errors';
|
||||
@@ -8,13 +8,16 @@ import { tryCatch } from '@/lib/async';
|
||||
import { isPreviewRequest } from '@/lib/preview';
|
||||
import { trace } from '@/lib/tracing';
|
||||
|
||||
type ResolveBody = Parameters<GitBookAPI['urls']['resolvePublishedContentByUrl']>[0];
|
||||
type ResolveBody = Parameters<API.GitBookAPI['urls']['resolvePublishedContentByUrl']>[0];
|
||||
|
||||
export type PublishedSiteContent = API.PublishedSiteContent &
|
||||
Partial<API.PublishedSiteContentAtRevision & API.PublishedSiteContentInChangeRequest>;
|
||||
|
||||
interface LookupPublishedContentByUrlInput {
|
||||
url: string;
|
||||
redirectOnError: boolean;
|
||||
apiToken: string | null;
|
||||
visitorPayload: SiteVisitorPayload;
|
||||
visitorPayload: API.SiteVisitorPayload;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -22,7 +25,7 @@ interface LookupPublishedContentByUrlInput {
|
||||
*/
|
||||
export async function lookupPublishedContentByUrl(
|
||||
input: LookupPublishedContentByUrlInput
|
||||
): Promise<DataFetcherResponse<PublishedSiteContentLookup>> {
|
||||
): Promise<DataFetcherResponse<PublishedSiteContent | API.PublishedContentRedirect>> {
|
||||
const lookupURL = new URL(input.url);
|
||||
const lookup = getURLLookup(stripURLSearch(lookupURL));
|
||||
|
||||
@@ -61,7 +64,11 @@ export async function lookupPublishedContentByUrl(
|
||||
data: { data },
|
||||
} = callResult;
|
||||
|
||||
if ('redirect' in data && data.target === 'application' && isPreviewRequest(lookupURL)) {
|
||||
if (!('redirect' in data)) {
|
||||
return { data };
|
||||
}
|
||||
|
||||
if (data.target === 'application' && isPreviewRequest(lookupURL)) {
|
||||
// The cached lookup omits the query params needed after login.
|
||||
const redirect = new URL(data.redirect);
|
||||
redirect.searchParams.set('redirect', lookupURL.toString());
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
import type * as api from '@gitbook/api';
|
||||
|
||||
export type SearchRouteReason =
|
||||
| 'preview'
|
||||
| 'revision'
|
||||
| 'change_request'
|
||||
| 'mcp'
|
||||
| 'no_pass'
|
||||
| 'fallback:401'
|
||||
| 'fallback:403'
|
||||
| 'fallback:429'
|
||||
| 'fallback:5xx'
|
||||
| 'fallback:http'
|
||||
| 'fallback:network'
|
||||
| 'fallback:timeout'
|
||||
| 'fallback:invalid'
|
||||
| 'fallback:unknown_space'
|
||||
| 'unknown';
|
||||
|
||||
export type DataFetcherErrorData = {
|
||||
code: number;
|
||||
message: string;
|
||||
@@ -34,6 +51,12 @@ export interface GitBookDataFetcher {
|
||||
*/
|
||||
withToken(input: { apiToken: string }): GitBookDataFetcher;
|
||||
|
||||
/**
|
||||
* Create a data fetcher that reads only these spaces at the site revision it previews, and
|
||||
* other spaces live.
|
||||
*/
|
||||
withSiteRevisionSpaces(spaceIds: string[]): GitBookDataFetcher;
|
||||
|
||||
/**
|
||||
* Get a user by its ID.
|
||||
*/
|
||||
@@ -180,6 +203,8 @@ export interface GitBookDataFetcher {
|
||||
organizationId: string;
|
||||
siteId: string;
|
||||
query: string;
|
||||
routeReason: SearchRouteReason;
|
||||
searchId?: string;
|
||||
scope:
|
||||
| { mode: 'all' }
|
||||
| {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
|
||||
import type { RevisionPageDocument } from '@gitbook/api';
|
||||
import { CustomizationPageActionType, type RevisionPageDocument } from '@gitbook/api';
|
||||
|
||||
import type { GitBookSiteContext } from './context';
|
||||
import { createLinker } from './links';
|
||||
@@ -17,6 +17,7 @@ describe('llms directive', () => {
|
||||
siteBasePath: '/docs',
|
||||
spaceBasePath: '/docs/v1',
|
||||
}),
|
||||
customization: { pageActions: { items: [] as CustomizationPageActionType[] } },
|
||||
} as GitBookSiteContext;
|
||||
|
||||
const page = {
|
||||
@@ -38,4 +39,15 @@ describe('llms directive', () => {
|
||||
'> For the complete documentation index, see [llms.txt](https://docs.company.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.company.com/docs/v1/guides/start.md).'
|
||||
);
|
||||
});
|
||||
|
||||
it('points to the MCP server when the site publishes one', () => {
|
||||
const mcpContext = {
|
||||
...context,
|
||||
customization: { pageActions: { items: [CustomizationPageActionType.Mcp] } },
|
||||
} as GitBookSiteContext;
|
||||
|
||||
expect(renderLLMsTxtMarkdownDirective(mcpContext, page)).toEndWith(
|
||||
' Agents can also search and read this documentation through its [MCP server](https://docs.company.com/docs/~gitbook/mcp).'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { RevisionPageDocument, RevisionPageGroup } from '@gitbook/api';
|
||||
|
||||
import type { GitBookSiteContext } from './context';
|
||||
import { getSiteMcpEndpoint, isSiteMcpEnabled } from './mcp/endpoints';
|
||||
|
||||
/**
|
||||
* Return the URL for the site-level llms.txt file.
|
||||
@@ -19,6 +20,24 @@ export function getPageMarkdownURL(
|
||||
return `${context.linker.toAbsoluteURL(context.linker.toPathInSpace(page.path))}.md`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the MCP endpoint to point agents to, or `undefined` when the site publishes none.
|
||||
*/
|
||||
export function getAdvertisedMcpEndpoint(context: GitBookSiteContext): string | undefined {
|
||||
return isSiteMcpEnabled(context) ? getSiteMcpEndpoint(context) : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the sentence that points agents to the site's MCP server, or `undefined` when the site
|
||||
* publishes none.
|
||||
*/
|
||||
export function renderMcpMarkdownDirective(context: GitBookSiteContext): string | undefined {
|
||||
const mcpEndpoint = getAdvertisedMcpEndpoint(context);
|
||||
return mcpEndpoint
|
||||
? `Agents can also search and read this documentation through its [MCP server](${mcpEndpoint}).`
|
||||
: undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the agent-facing directive that points agents to the site index.
|
||||
*/
|
||||
@@ -26,5 +45,6 @@ export function renderLLMsTxtMarkdownDirective(
|
||||
context: GitBookSiteContext,
|
||||
page: RevisionPageDocument | RevisionPageGroup
|
||||
): string {
|
||||
return `> For the complete documentation index, see [llms.txt](${getLLMsTxtURL(context)}). Markdown versions of documentation pages are available by appending \`.md\` to page URLs; this page is available as [Markdown](${getPageMarkdownURL(context, page)}).`;
|
||||
const mcpDirective = renderMcpMarkdownDirective(context);
|
||||
return `> For the complete documentation index, see [llms.txt](${getLLMsTxtURL(context)}). Markdown versions of documentation pages are available by appending \`.md\` to page URLs; this page is available as [Markdown](${getPageMarkdownURL(context, page)}).${mcpDirective ? ` ${mcpDirective}` : ''}`;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,13 @@ export function isSiteMcpEnabled(context: GitBookSiteContext): boolean {
|
||||
return context.customization.pageActions.items.includes(CustomizationPageActionType.Mcp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Absolute URL of the site's public MCP endpoint.
|
||||
*/
|
||||
export function getSiteMcpEndpoint(context: GitBookSiteContext): string {
|
||||
return context.linker.toAbsoluteURL(context.linker.toPathInSite('~gitbook/mcp'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether `~gitbook/mcp` endpoint requires auth for the site (i.e VA site).
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
const DOCS_SUFFIX = ' Docs';
|
||||
const DOCS_WORD_PATTERN = /\bdoc(s|umentation)?\b/i;
|
||||
|
||||
/**
|
||||
* Characters {@link getSiteMcpServerName} can add to a title, for callers that cap its length.
|
||||
*/
|
||||
export const SITE_MCP_SERVER_NAME_MAX_ADDED_LENGTH = DOCS_SUFFIX.length;
|
||||
|
||||
/**
|
||||
* Get the name a client lists a site's MCP server under: the site title, marked as docs unless it
|
||||
* already says so.
|
||||
*/
|
||||
export function getSiteMcpServerName(siteTitle: string): string {
|
||||
const title = siteTitle.trim();
|
||||
if (!title) {
|
||||
return DOCS_SUFFIX.trim();
|
||||
}
|
||||
|
||||
// A customer often runs an MCP server for its own product, listed under the same name.
|
||||
return DOCS_WORD_PATTERN.test(title) ? title : `${title}${DOCS_SUFFIX}`;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ describe('buildSiteMcpServerCard', () => {
|
||||
it('keeps the description and title within 100 characters', () => {
|
||||
const card = buildCard({ title: 'Acme' });
|
||||
|
||||
expect(card.title).toBe('Acme MCP Server');
|
||||
expect(card.title).toBe('Acme Docs MCP Server');
|
||||
expect(card.description).toBe('Search and read the Acme documentation over MCP.');
|
||||
expect(card.description.length).toBeLessThanOrEqual(MAX_TEXT_LENGTH);
|
||||
expect(card.title.length).toBeLessThanOrEqual(MAX_TEXT_LENGTH);
|
||||
@@ -102,7 +102,7 @@ describe('buildSiteMcpServerCard', () => {
|
||||
it('does not repeat an article a customer title already carries', () => {
|
||||
const card = buildCard({ title: 'The Acme Handbook' });
|
||||
|
||||
expect(card.title).toBe('The Acme Handbook MCP Server');
|
||||
expect(card.title).toBe('The Acme Handbook Docs MCP Server');
|
||||
expect(card.description).toBe(
|
||||
'Search and read The Acme Handbook documentation over MCP.'
|
||||
);
|
||||
@@ -112,7 +112,7 @@ describe('buildSiteMcpServerCard', () => {
|
||||
const card = buildCard({ title: 'A'.repeat(500) });
|
||||
|
||||
expect(card.title.length).toBe(MAX_TEXT_LENGTH);
|
||||
expect(card.title.endsWith('… MCP Server')).toBe(true);
|
||||
expect(card.title.endsWith('… Docs MCP Server')).toBe(true);
|
||||
expect(card.description.length).toBe(MAX_TEXT_LENGTH);
|
||||
expect(card.description.startsWith('Search and read the ')).toBe(true);
|
||||
expect(card.description.endsWith('… documentation over MCP.')).toBe(true);
|
||||
@@ -170,8 +170,18 @@ describe('buildSiteMcpServerCard', () => {
|
||||
|
||||
expect(acme.name).toBe('docs.acme.com/~gitbook/mcp');
|
||||
expect(other.name).toBe('gitbook.com/other/~gitbook/mcp');
|
||||
expect(acme.title).toBe('Acme MCP Server');
|
||||
expect(other.title).toBe('Other MCP Server');
|
||||
expect(acme.title).toBe('Acme Docs MCP Server');
|
||||
expect(other.title).toBe('Other Docs MCP Server');
|
||||
});
|
||||
|
||||
it('marks the server as docs only when the site title does not already say so', () => {
|
||||
for (const [title, expected] of [
|
||||
['Acme Docs', 'Acme Docs MCP Server'],
|
||||
['Acme Documentation', 'Acme Documentation MCP Server'],
|
||||
['Docker', 'Docker Docs MCP Server'],
|
||||
] as const) {
|
||||
expect(buildMcpServerInfo(makeContext({ title })).title).toBe(expected);
|
||||
}
|
||||
});
|
||||
|
||||
it('declares the capabilities the SDK reports at initialize', () => {
|
||||
|
||||
@@ -2,7 +2,13 @@ import type { Implementation, ServerCapabilities, Tool } from '@modelcontextprot
|
||||
import { SUPPORTED_PROTOCOL_VERSIONS } from '@modelcontextprotocol/sdk/types.js';
|
||||
|
||||
import packageJSON from '../../../package.json';
|
||||
import { hasAdaptiveMcpEndpoint, isSiteMcpEnabled, mcpEndpointRequiresAuth } from './endpoints';
|
||||
import {
|
||||
getSiteMcpEndpoint,
|
||||
hasAdaptiveMcpEndpoint,
|
||||
isSiteMcpEnabled,
|
||||
mcpEndpointRequiresAuth,
|
||||
} from './endpoints';
|
||||
import { SITE_MCP_SERVER_NAME_MAX_ADDED_LENGTH, getSiteMcpServerName } from './naming';
|
||||
import { type SiteMcpTool, createSiteMcpTools } from './tools';
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
import { serveDiscoveryDocument } from '@/lib/discoveryDocument';
|
||||
@@ -156,10 +162,6 @@ export function buildMcpServerInfo(context: GitBookSiteContext): SiteMcpServerIn
|
||||
};
|
||||
}
|
||||
|
||||
export function getSiteMcpEndpoint(context: GitBookSiteContext): string {
|
||||
return context.linker.toAbsoluteURL(context.linker.toPathInSite('~gitbook/mcp'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Serve a site's MCP server card.
|
||||
*
|
||||
@@ -223,7 +225,8 @@ function authorizationHeader(description: string): SiteMcpServerCardRemote['head
|
||||
* Name the server after the site it serves, within the 100 characters the schema allows a `title`.
|
||||
*/
|
||||
function buildTitle(siteTitle: string): string {
|
||||
return `${truncate(siteTitle, MAX_TEXT_LENGTH - TITLE_SUFFIX.length)}${TITLE_SUFFIX}`;
|
||||
const budget = MAX_TEXT_LENGTH - TITLE_SUFFIX.length - SITE_MCP_SERVER_NAME_MAX_ADDED_LENGTH;
|
||||
return `${getSiteMcpServerName(truncate(siteTitle, budget))}${TITLE_SUFFIX}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -93,6 +93,7 @@ export function createSiteMcpTools(
|
||||
organizationId: context.organizationId,
|
||||
siteId: site.id,
|
||||
query,
|
||||
routeReason: 'mcp',
|
||||
scope: getLanguageSearchScope(context.structure, searchLanguage),
|
||||
})
|
||||
);
|
||||
@@ -523,8 +524,24 @@ export function trackMcpEvent(args: Parameters<typeof trackServerInsightsEvents>
|
||||
* Register tools on the MCP server. Only used by the transport: the server card reads the same
|
||||
* definitions without registering anything.
|
||||
*/
|
||||
export function registerSiteMcpTools(server: McpServer, tools: SiteMcpTool[]) {
|
||||
export function registerSiteMcpTools(
|
||||
server: McpServer,
|
||||
tools: SiteMcpTool[],
|
||||
options: {
|
||||
/**
|
||||
* Called when a tool runs, after the server has matched its name and validated its
|
||||
* arguments.
|
||||
*/
|
||||
onToolCall?: () => void;
|
||||
} = {}
|
||||
) {
|
||||
const { onToolCall } = options;
|
||||
|
||||
for (const tool of tools) {
|
||||
server.tool(tool.name, tool.description, tool.inputSchema, tool.annotations, tool.handler);
|
||||
const handler: SiteMcpTool['handler'] = (...args) => {
|
||||
onToolCall?.();
|
||||
return tool.handler(...args);
|
||||
};
|
||||
server.tool(tool.name, tool.description, tool.inputSchema, tool.annotations, handler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,4 +35,61 @@ describe('#enrichFilesystem', () => {
|
||||
expect(paths['/a'].get['x-gitbook-description-html']).toBe('<p>constructor</p>');
|
||||
expect(paths['/b'].get['x-gitbook-description-html']).toBe('<p>constructor</p>');
|
||||
});
|
||||
|
||||
async function enrichSchemas(schemas: Record<string, unknown>) {
|
||||
const { filesystem } = await parseOpenAPI({
|
||||
value: JSON.stringify({
|
||||
openapi: '3.0.0',
|
||||
info: { title: 'Test', version: '1.0.0' },
|
||||
paths: {},
|
||||
components: { schemas },
|
||||
}),
|
||||
rootURL: null,
|
||||
});
|
||||
const enriched = await enrichFilesystem(filesystem);
|
||||
return enriched[0]?.specification.components.schemas;
|
||||
}
|
||||
|
||||
it('drops description fields supplied by the specification', async () => {
|
||||
const schemas = await enrichSchemas({
|
||||
Pet: {
|
||||
type: 'object',
|
||||
'x-gitbook-description-html': '<b>spec</b>',
|
||||
'x-gitbook-description-document': { nodes: [] },
|
||||
},
|
||||
});
|
||||
expect(schemas.Pet['x-gitbook-description-html']).toBeUndefined();
|
||||
expect(schemas.Pet['x-gitbook-description-document']).toBeUndefined();
|
||||
});
|
||||
|
||||
it('sanitizes descriptions of schemas named example', async () => {
|
||||
const schemas = await enrichSchemas({
|
||||
example: { type: 'string', description: '<img src=x onerror=alert(1)>' },
|
||||
});
|
||||
const html = schemas.example['x-gitbook-description-html'];
|
||||
expect(html).toContain('<img');
|
||||
expect(html).not.toContain('onerror');
|
||||
});
|
||||
|
||||
it('sanitizes descriptions in example values that could render HTML', async () => {
|
||||
const schemas = await enrichSchemas({
|
||||
Pet: {
|
||||
type: 'object',
|
||||
example: {
|
||||
description: '<img src=x onerror=alert(1)>',
|
||||
'x-gitbook-description-html': '<img src=x onerror=alert(2)>',
|
||||
},
|
||||
},
|
||||
});
|
||||
const html = schemas.Pet.example['x-gitbook-description-html'];
|
||||
expect(html).toBeDefined();
|
||||
expect(html).not.toContain('onerror');
|
||||
});
|
||||
|
||||
it('keeps example values without HTML as written', async () => {
|
||||
const schemas = await enrichSchemas({
|
||||
Pet: { type: 'object', example: { description: 'A **good** dog' } },
|
||||
});
|
||||
expect(schemas.Pet.example).toEqual({ description: 'A **good** dog' });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,19 +8,21 @@ import { parseMarkdown } from '../markdown';
|
||||
export async function enrichFilesystem(filesystem: Filesystem) {
|
||||
const parseMarkdownWithCache = createMarkdownParser();
|
||||
return traverse(filesystem, async (node, path) => {
|
||||
// Examples included: a `$ref` can render an example value as a schema.
|
||||
delete node['x-gitbook-description-html'];
|
||||
delete node['x-gitbook-description-document'];
|
||||
|
||||
if (
|
||||
path !== undefined &&
|
||||
'description' in node &&
|
||||
typeof node.description === 'string' &&
|
||||
node.description
|
||||
) {
|
||||
const key = path[path.length - 1];
|
||||
// Avoid parsing descriptions in examples.
|
||||
if (key !== 'example') {
|
||||
const description = node.description.trim();
|
||||
if (description) {
|
||||
node['x-gitbook-description-html'] = await parseMarkdownWithCache(description);
|
||||
}
|
||||
const description = node.description.trim();
|
||||
// Examples stay as written, except where their raw description could render a tag.
|
||||
const isExample = path[path.length - 1] === 'example';
|
||||
if (description && (!isExample || description.includes('<'))) {
|
||||
node['x-gitbook-description-html'] = await parseMarkdownWithCache(description);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
} from '@gitbook/openapi-parser';
|
||||
|
||||
import { enrichFilesystem } from './enrich';
|
||||
import { resolveOpenAPIDescriptionLinks } from './resolveDescriptionLinks';
|
||||
import type {
|
||||
AnyOpenAPIOperationsBlock,
|
||||
OpenAPISchemasBlock,
|
||||
@@ -41,7 +42,9 @@ export async function fetchOpenAPIFilesystem(
|
||||
// If the reference is a new OpenAPI reference, we return it.
|
||||
if (ref.kind === 'openapi') {
|
||||
assert(resolved.openapi?.filesystem);
|
||||
return resolved.openapi.filesystem;
|
||||
return resolveOpenAPIDescriptionLinks(resolved.openapi.filesystem, (contentRef) =>
|
||||
resolveContentRef(contentRef, context)
|
||||
);
|
||||
}
|
||||
// For legacy blocks ("swagger"), we need to fetch the file system.
|
||||
return fetchFilesystem(resolved.href, context.space.id);
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
|
||||
import { parseOpenAPI } from '@gitbook/openapi-parser';
|
||||
|
||||
import { resolveOpenAPIDescriptionLinks } from './resolveDescriptionLinks';
|
||||
|
||||
const APP_URL = 'https://app.gitbook.com/s/space-1/tables';
|
||||
|
||||
describe('resolveOpenAPIDescriptionLinks', () => {
|
||||
it('points tagged links at their resolved URL without mutating the input', async () => {
|
||||
const original =
|
||||
`<p><a href="${APP_URL}" data-gitbook-ref="/spaces/space-1/pages/page-1">Fields</a>` +
|
||||
` <a href="${APP_URL}" data-gitbook-ref="/spaces/space-1/pages/missing">Gone</a>` +
|
||||
' <a href="https://example.com">Docs</a></p>';
|
||||
const { filesystem } = await parseOpenAPI({
|
||||
value: JSON.stringify({
|
||||
openapi: '3.0.0',
|
||||
info: { title: 'Test', version: '1.0.0' },
|
||||
paths: {},
|
||||
components: {
|
||||
schemas: {
|
||||
Condition: { type: 'object', 'x-gitbook-description-html': original },
|
||||
},
|
||||
},
|
||||
}),
|
||||
rootURL: null,
|
||||
});
|
||||
|
||||
const resolved = await resolveOpenAPIDescriptionLinks(filesystem, async (ref) =>
|
||||
ref.kind === 'page' && ref.page === 'page-1' ? { href: '/docs/tables' } : null
|
||||
);
|
||||
|
||||
expect(resolved[0]?.specification.components?.schemas?.Condition).toMatchObject({
|
||||
'x-gitbook-description-html':
|
||||
'<p><a href="/docs/tables" data-gitbook-ref="/spaces/space-1/pages/page-1">Fields</a>' +
|
||||
` <a href="${APP_URL}" data-gitbook-ref="/spaces/space-1/pages/missing">Gone</a>` +
|
||||
' <a href="https://example.com">Docs</a></p>',
|
||||
});
|
||||
// The spec content comes from the data cache, shared across sites.
|
||||
expect(filesystem[0]?.specification.components?.schemas?.Condition).toMatchObject({
|
||||
'x-gitbook-description-html': original,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,173 @@
|
||||
import { type DefaultTreeAdapterMap, parseFragment } from 'parse5';
|
||||
import * as React from 'react';
|
||||
|
||||
import type { ContentRef } from '@gitbook/api';
|
||||
import type { Filesystem, OpenAPIV3xDocument } from '@gitbook/openapi-parser';
|
||||
|
||||
import { escapeHTML } from '@/lib/html';
|
||||
import { resolveStringContentRef } from '@/lib/references';
|
||||
|
||||
const DESCRIPTION_HTML_KEY = 'x-gitbook-description-html';
|
||||
// Slate JSON, which never holds description HTML: skipped to keep the walk short.
|
||||
const DESCRIPTION_DOCUMENT_KEY = 'x-gitbook-description-document';
|
||||
// Set by spec processing on links to GitBook content, e.g. `/spaces/{space}/pages/{page}`.
|
||||
const CONTENT_REF_ATTRIBUTE = 'data-gitbook-ref';
|
||||
|
||||
type OpenAPIFilesystem = Filesystem<OpenAPIV3xDocument>;
|
||||
type ResolveContentRef = (ref: ContentRef) => Promise<{ href: string } | null>;
|
||||
|
||||
// Per request: resolved hrefs depend on the site being rendered.
|
||||
const getResolvedFilesystems = React.cache(
|
||||
() => new WeakMap<OpenAPIFilesystem, Promise<OpenAPIFilesystem>>()
|
||||
);
|
||||
|
||||
/**
|
||||
* Point description links that spec processing tagged with a content ref at their URL in the
|
||||
* current site. Links whose ref doesn't resolve keep the href written in the spec.
|
||||
* Returns a copy when something changed: the input may be shared through the data cache.
|
||||
*/
|
||||
export function resolveOpenAPIDescriptionLinks(
|
||||
filesystem: OpenAPIFilesystem,
|
||||
resolveContentRef: ResolveContentRef
|
||||
): Promise<OpenAPIFilesystem> {
|
||||
const resolvedFilesystems = getResolvedFilesystems();
|
||||
let promise = resolvedFilesystems.get(filesystem);
|
||||
if (!promise) {
|
||||
promise = baseResolveOpenAPIDescriptionLinks(filesystem, resolveContentRef);
|
||||
resolvedFilesystems.set(filesystem, promise);
|
||||
}
|
||||
return promise;
|
||||
}
|
||||
|
||||
async function baseResolveOpenAPIDescriptionLinks(
|
||||
filesystem: OpenAPIFilesystem,
|
||||
resolveContentRef: ResolveContentRef
|
||||
): Promise<OpenAPIFilesystem> {
|
||||
// Tagged HTML → its rewritten version, filled in once the refs resolve.
|
||||
const rewritten = new Map<string, string>();
|
||||
mapDescriptionHTML(filesystem, (html) => {
|
||||
if (html.includes(CONTENT_REF_ATTRIBUTE)) {
|
||||
rewritten.set(html, html);
|
||||
}
|
||||
return html;
|
||||
});
|
||||
|
||||
if (rewritten.size === 0) {
|
||||
return filesystem;
|
||||
}
|
||||
|
||||
const hrefs = new Map<string, Promise<string | null>>();
|
||||
const resolveHref = (source: string) => {
|
||||
let href = hrefs.get(source);
|
||||
if (!href) {
|
||||
const ref = resolveStringContentRef(source);
|
||||
href = ref
|
||||
? resolveContentRef(ref).then((resolved) => resolved?.href ?? null)
|
||||
: Promise.resolve(null);
|
||||
hrefs.set(source, href);
|
||||
}
|
||||
return href;
|
||||
};
|
||||
|
||||
await Promise.all(
|
||||
Array.from(rewritten.keys(), async (html) => {
|
||||
rewritten.set(html, await rewriteLinks(html, resolveHref));
|
||||
})
|
||||
);
|
||||
|
||||
return mapDescriptionHTML(filesystem, (html) => rewritten.get(html) ?? html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the href of each tagged link with its resolved URL.
|
||||
*/
|
||||
async function rewriteLinks(
|
||||
html: string,
|
||||
resolveHref: (source: string) => Promise<string | null>
|
||||
): Promise<string> {
|
||||
const fragment = parseFragment(html, { sourceCodeLocationInfo: true });
|
||||
const replacements: { start: number; end: number; value: string }[] = [];
|
||||
|
||||
await Promise.all(
|
||||
collectLinks(fragment).map(async (link) => {
|
||||
const source = link.attrs.find((attr) => attr.name === CONTENT_REF_ATTRIBUTE)?.value;
|
||||
const location = link.sourceCodeLocation?.attrs?.href;
|
||||
if (!source || !location) {
|
||||
return;
|
||||
}
|
||||
|
||||
const href = await resolveHref(source);
|
||||
if (href) {
|
||||
replacements.push({
|
||||
start: location.startOffset,
|
||||
end: location.endOffset,
|
||||
value: `href="${escapeHTML(href)}"`,
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
// Apply from the end so earlier offsets stay valid.
|
||||
replacements.sort((a, b) => b.start - a.start);
|
||||
let result = html;
|
||||
for (const { start, end, value } of replacements) {
|
||||
result = result.slice(0, start) + value + result.slice(end);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function collectLinks(
|
||||
node: DefaultTreeAdapterMap['node'],
|
||||
links: DefaultTreeAdapterMap['element'][] = []
|
||||
): DefaultTreeAdapterMap['element'][] {
|
||||
if ('tagName' in node && node.tagName === 'a') {
|
||||
links.push(node);
|
||||
}
|
||||
if ('childNodes' in node) {
|
||||
for (const child of node.childNodes) {
|
||||
collectLinks(child, links);
|
||||
}
|
||||
}
|
||||
return links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map every description HTML in a JSON value, copying only the objects on a changed path.
|
||||
*/
|
||||
function mapDescriptionHTML<T>(value: T, transform: (html: string) => string): T {
|
||||
if (typeof value !== 'object' || value === null) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
let result: unknown[] | null = null;
|
||||
for (let index = 0; index < value.length; index++) {
|
||||
const item = value[index];
|
||||
const next = mapDescriptionHTML(item, transform);
|
||||
if (next !== item) {
|
||||
result ??= [...value];
|
||||
result[index] = next;
|
||||
}
|
||||
}
|
||||
return (result ?? value) as T;
|
||||
}
|
||||
|
||||
const record = value as Record<string, unknown>;
|
||||
let result: Record<string, unknown> | null = null;
|
||||
// `for...in` over plain JSON objects: several times faster than `Object.entries` on large specs.
|
||||
for (const key in record) {
|
||||
if (key === DESCRIPTION_DOCUMENT_KEY) {
|
||||
continue;
|
||||
}
|
||||
const child = record[key];
|
||||
const next =
|
||||
key === DESCRIPTION_HTML_KEY && typeof child === 'string'
|
||||
? transform(child)
|
||||
: mapDescriptionHTML(child, transform);
|
||||
if (next !== child) {
|
||||
result ??= { ...record };
|
||||
result[key] = next;
|
||||
}
|
||||
}
|
||||
return (result ?? record) as T;
|
||||
}
|
||||
@@ -76,3 +76,7 @@ export function getExtension(path: string): string {
|
||||
export function isGitBookInternalPath(path: string): boolean {
|
||||
return /(^|\/)~gitbook(\/|$)/.test(path);
|
||||
}
|
||||
|
||||
export function hasRevisionSelector(path: string): boolean {
|
||||
return /(?:^|\/)~\/revisions\/[^/]+/.test(path);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ function siteSpace(id: string, title: string, published: string, extra: Partial<
|
||||
path: '',
|
||||
default: false,
|
||||
draft: false,
|
||||
space: { id: `space_${id}`, title, language: 'en' },
|
||||
space: { id: `space_${id}`, title, language: 'en', permissions: { view: true } },
|
||||
urls: { published },
|
||||
...extra,
|
||||
} as SiteSpace;
|
||||
@@ -102,6 +102,7 @@ const items: (SearchSpaceResult | SearchRecordResult)[] = [
|
||||
{ id: 'status', path: 'https://status.example.com/', rank: 3 },
|
||||
]),
|
||||
space('v1', 1, [{ id: 'legacy', path: 'legacy/authentication', rank: 4 }]),
|
||||
space('v0', 1, [{ id: 'reference', path: 'reference', rank: 5 }]),
|
||||
{
|
||||
type: 'record',
|
||||
id: 'record_1',
|
||||
@@ -164,14 +165,45 @@ describe('computePublishedSearchResults', () => {
|
||||
'space_v2/auth',
|
||||
'space_guides/status',
|
||||
'space_v1/legacy',
|
||||
'space_v0/reference',
|
||||
'record_1',
|
||||
]);
|
||||
});
|
||||
|
||||
it('leaves hidden variants out of the lookup, so their results go to the route', () => {
|
||||
it('includes readable published hidden spaces and excludes draft, denied, or unpublished placements', () => {
|
||||
const hidden = siteSpace('hidden', 'Older docs', 'https://docs.example.com/old/', {
|
||||
hidden: true,
|
||||
});
|
||||
const denied = siteSpace('denied', 'Denied', 'https://docs.example.com/denied/');
|
||||
denied.space.permissions.view = false;
|
||||
const draft = siteSpace('draft', 'Draft', 'https://docs.example.com/draft/', {
|
||||
draft: true,
|
||||
});
|
||||
const unpublished = siteSpace('unpublished', 'Unpublished', '', {
|
||||
urls: {},
|
||||
});
|
||||
|
||||
const spaces = getSearchSpaceLookup({
|
||||
type: 'siteSpaces',
|
||||
structure: [hidden, denied, draft, unpublished],
|
||||
});
|
||||
expect(spaces).toEqual({
|
||||
space_hidden: {
|
||||
siteSpaceId: 'ss_hidden',
|
||||
spaceURL: 'https://docs.example.com/old/',
|
||||
breadcrumbs: [],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('falls back when a result belongs to an unknown space', () => {
|
||||
const spaces = getSearchSpaceLookup(structure);
|
||||
expect(Object.keys(spaces).sort()).toEqual(['space_guides', 'space_v1', 'space_v2']);
|
||||
expect(JSON.stringify(spaces)).not.toContain('/api/v0/');
|
||||
expect(Object.keys(spaces).sort()).toEqual([
|
||||
'space_guides',
|
||||
'space_v0',
|
||||
'space_v1',
|
||||
'space_v2',
|
||||
]);
|
||||
|
||||
const linker = createSiteLinker({
|
||||
urlMode: 'url-host',
|
||||
@@ -180,7 +212,7 @@ describe('computePublishedSearchResults', () => {
|
||||
spaceBasePath: '/api/',
|
||||
gitbookURL: undefined,
|
||||
});
|
||||
const searchResults = [...items, space('v0', 1, [{ id: 'draft', path: 'draft', rank: 5 }])];
|
||||
const searchResults = [space('unknown', 1, [{ id: 'page', path: 'page', rank: 1 }])];
|
||||
expect(
|
||||
computePublishedSearchResults({ asEmbeddable: false, linker, searchResults, spaces })
|
||||
).toBeNull();
|
||||
|
||||
@@ -52,10 +52,12 @@ export type DirectSearchProps = {
|
||||
*/
|
||||
export function toSearchSiteContentBody(
|
||||
query: string,
|
||||
scope: SearchSiteContentScope
|
||||
): Parameters<GitBookAPI['orgs']['searchSiteContent']>[2] {
|
||||
scope: SearchSiteContentScope,
|
||||
searchId?: string
|
||||
): Parameters<GitBookAPI['orgs']['searchSiteContent']>[2] & { searchId?: string } {
|
||||
return {
|
||||
query,
|
||||
searchId,
|
||||
...(scope.mode === 'current' && scope.restrictTo
|
||||
? {
|
||||
// `restrictTo` only exists in the newer `scope` request shape,
|
||||
@@ -119,7 +121,7 @@ export function computePublishedSearchResults(input: {
|
||||
const { asEmbeddable, linker, searchResults, spaces } = input;
|
||||
|
||||
const hasUnknownSpace = searchResults.some(
|
||||
(item) => item.type === 'space' && item.pages.length > 0 && !spaces[item.id]
|
||||
(item) => item.type === 'space' && item.pages.length > 0 && !Object.hasOwn(spaces, item.id)
|
||||
);
|
||||
if (hasUnknownSpace) {
|
||||
return null;
|
||||
|
||||
@@ -81,18 +81,25 @@ export function transformSitePageResult(args: {
|
||||
}
|
||||
|
||||
/**
|
||||
* Index the visible site spaces by space, resolving each space as the search route does.
|
||||
* Index readable published site spaces by space.
|
||||
*/
|
||||
export function getSearchSpaceLookup(structure: SiteStructure): SearchSpaceLookup {
|
||||
const lookup: SearchSpaceLookup = {};
|
||||
|
||||
for (const { space } of listAllSiteSpaces(structure)) {
|
||||
if (lookup[space.id]) {
|
||||
if (Object.hasOwn(lookup, space.id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const found = findSiteSpaceBy(structure, (siteSpace) => siteSpace.space.id === space.id);
|
||||
if (found && !found.siteSpace.hidden) {
|
||||
const found = findSiteSpaceBy(
|
||||
structure,
|
||||
(siteSpace) =>
|
||||
siteSpace.space.id === space.id &&
|
||||
!siteSpace.draft &&
|
||||
siteSpace.space.permissions.view &&
|
||||
Boolean(siteSpace.urls.published)
|
||||
);
|
||||
if (found) {
|
||||
lookup[space.id] = getSearchSpaceEntry({
|
||||
siteSpace: found.siteSpace,
|
||||
siteSection: found.siteSection ?? undefined,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { type RevisionPageDocument, type RevisionPageGroup, SiteVisibility } from '@gitbook/api';
|
||||
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
import { hasRevisionSelector } from '@/lib/paths';
|
||||
|
||||
/**
|
||||
* Return true if a page is indexable in search.
|
||||
@@ -29,8 +30,12 @@ export function isSiteIndexable(context: GitBookSiteContext) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Prevent indexation of preview of revisions / change-requests
|
||||
if (context.changeRequest || context.revisionId !== context.space.revision) {
|
||||
if (
|
||||
context.changeRequest ||
|
||||
context.siteRevision ||
|
||||
context.revisionId !== context.space.revision ||
|
||||
hasRevisionSelector(context.linker.spaceBasePath)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
ContentType,
|
||||
CustomizationDefaultThemeMode,
|
||||
CustomizationThemeMode,
|
||||
type PublishedSiteContent,
|
||||
SiteInsightsDisplayContext,
|
||||
type SiteInsightsEventLocation,
|
||||
SiteInsightsLLMSVariant,
|
||||
@@ -31,6 +30,7 @@ import { getContentSecurityPolicy } from '@/lib/csp';
|
||||
import { validateSerializedCustomization } from '@/lib/customization';
|
||||
import {
|
||||
DataFetcherError,
|
||||
type PublishedSiteContent,
|
||||
apiClient,
|
||||
getVisitorAuthBasePath,
|
||||
lookupPublishedContentByUrl,
|
||||
@@ -51,7 +51,7 @@ import {
|
||||
isOAuthProtectedResourceMetadataRequestForAuthEndpoint,
|
||||
isOAuthProtectedResourceRequest,
|
||||
} from '@/lib/oauth-protected';
|
||||
import { removeLeadingSlash, removeTrailingSlash } from '@/lib/paths';
|
||||
import { hasRevisionSelector, removeLeadingSlash, removeTrailingSlash } from '@/lib/paths';
|
||||
import {
|
||||
getPreviewCookieResponse,
|
||||
getPreviewRequestIdentifier,
|
||||
@@ -85,6 +85,8 @@ export const config = {
|
||||
|
||||
type URLWithMode = { url: URL; mode: 'url' | 'url-host' };
|
||||
|
||||
const REVISION_ROBOTS_TAG = 'noindex, nofollow';
|
||||
|
||||
export async function middleware(request: NextRequest) {
|
||||
try {
|
||||
const requestURL = new URL(request.url);
|
||||
@@ -168,6 +170,20 @@ async function serveSiteRoutes(requestURL: URL, request: NextRequest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const response = await serveSiteRequest(requestURL, request, match);
|
||||
if (
|
||||
response &&
|
||||
hasRevisionSelector(match.url.pathname) &&
|
||||
!response.headers.has('x-robots-tag')
|
||||
) {
|
||||
const revisionResponse = new Response(response.body, response);
|
||||
revisionResponse.headers.set('x-robots-tag', REVISION_ROBOTS_TAG);
|
||||
return revisionResponse;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
async function serveSiteRequest(requestURL: URL, request: NextRequest, match: URLWithMode) {
|
||||
const { url: siteRequestURL, mode } = match;
|
||||
|
||||
if (isAITrainingOrIndexingRequest(request)) {
|
||||
@@ -180,6 +196,13 @@ async function serveSiteRoutes(requestURL: URL, request: NextRequest) {
|
||||
// Normalize URL after extracting the URL from the request to make sure the client is redirected to the proper one
|
||||
const normalization = normalizeRequestURL(siteRequestURL, mode);
|
||||
if (normalization instanceof Response) {
|
||||
const location = normalization.headers.get('location');
|
||||
if (location && hasRevisionSelector(new URL(location).pathname)) {
|
||||
return NextResponse.redirect(location, {
|
||||
status: normalization.status,
|
||||
headers: { 'x-robots-tag': REVISION_ROBOTS_TAG },
|
||||
});
|
||||
}
|
||||
return normalization;
|
||||
}
|
||||
const isNormalizedURL = normalization.isNormalized;
|
||||
@@ -426,8 +449,7 @@ async function serveSiteRoutes(requestURL: URL, request: NextRequest) {
|
||||
basePath: siteURLData.basePath,
|
||||
space: siteURLData.space,
|
||||
organization: siteURLData.organization,
|
||||
changeRequest: siteURLData.changeRequest,
|
||||
revision: siteURLData.revision,
|
||||
...getPreviewedContent(siteURLData),
|
||||
shareKey: siteURLData.shareKey,
|
||||
preview: siteURLData.preview,
|
||||
apiToken: siteURLData.apiToken,
|
||||
@@ -622,6 +644,8 @@ async function serveSiteRoutes(requestURL: URL, request: NextRequest) {
|
||||
// noindex search/assistant deep links, kept crawlable so Google sees the directive.
|
||||
if (rewrittenURL.searchParams.has('ask') || rewrittenURL.searchParams.has('q')) {
|
||||
response.headers.set('x-robots-tag', 'none');
|
||||
} else if (hasRevisionSelector(siteURLData.basePath)) {
|
||||
response.headers.set('x-robots-tag', REVISION_ROBOTS_TAG);
|
||||
}
|
||||
|
||||
// Allow cross-origin requests from the same parent domain as the site.
|
||||
@@ -940,7 +964,7 @@ function encodePathInSiteContent(
|
||||
siteSpace: siteURLData.siteSpace,
|
||||
siteShareKey: siteURLData.shareKey,
|
||||
space: siteURLData.space,
|
||||
revision: siteURLData.revision,
|
||||
revision: getPreviewedContent(siteURLData).revision,
|
||||
displayContext: SiteInsightsDisplayContext.Server,
|
||||
};
|
||||
|
||||
@@ -1204,3 +1228,21 @@ function acceptsMarkdown(request: Request): boolean {
|
||||
const htmlIndex = mediaTypes.findIndex((type) => type === 'text/html' || type === '*/*');
|
||||
return htmlIndex === -1 || markdownIndex < htmlIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* The revision, change request or site revision a URL previews: at most one of them.
|
||||
*/
|
||||
function getPreviewedContent(
|
||||
content: PublishedSiteContent
|
||||
): Pick<SiteURLData, 'revision' | 'changeRequest' | 'siteRevision'> {
|
||||
if ('revision' in content) {
|
||||
return { revision: content.revision };
|
||||
}
|
||||
if ('changeRequest' in content) {
|
||||
return { changeRequest: content.changeRequest };
|
||||
}
|
||||
if ('siteRevision' in content) {
|
||||
return { siteRevision: content.siteRevision };
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
fetchSiteContextForSiteSpace,
|
||||
} from '@/lib/context';
|
||||
import { throwIfDataError } from '@/lib/data';
|
||||
import { renderMcpMarkdownDirective } from '@/lib/llms-directive';
|
||||
import { fromPageMarkdown, toPageMarkdown } from '@/lib/markdownPage';
|
||||
import { getIndexablePages } from '@/lib/sitemap';
|
||||
import { filterSiteSpacesByLocale, getSiteStructureSections } from '@/lib/sites';
|
||||
@@ -260,6 +261,11 @@ async function streamMarkdownPart(
|
||||
}
|
||||
|
||||
// Rendered up front, on every part, since agents may only read the start of the file.
|
||||
const mcpDirective = renderMcpMarkdownDirective(context);
|
||||
if (mcpDirective) {
|
||||
stream.enqueue(new TextEncoder().encode(`> ${mcpDirective}\n\n`));
|
||||
}
|
||||
|
||||
const agentInstructions = renderSiteAgentInstructions(context);
|
||||
if (agentInstructions) {
|
||||
stream.enqueue(new TextEncoder().encode(`${agentInstructions}\n---\n\n`));
|
||||
|
||||
@@ -8,6 +8,7 @@ import { renderSiteAgentInstructions } from '@/lib/ask-prompt';
|
||||
import { type GitBookSiteContext, checkIsRootSiteContext } from '@/lib/context';
|
||||
import { throwIfDataError } from '@/lib/data';
|
||||
import { type GitBookLinker, linkerWithMarkdownPages } from '@/lib/links';
|
||||
import { getAdvertisedMcpEndpoint } from '@/lib/llms-directive';
|
||||
import { type FlatPageEntry, getIndexablePages } from '@/lib/sitemap';
|
||||
import {
|
||||
filterSiteSpacesByLocale,
|
||||
@@ -39,6 +40,7 @@ export async function serveLLMsTxt(baseContext: GitBookSiteContext) {
|
||||
depth: 1,
|
||||
children: [{ type: 'text', value: site.title }],
|
||||
},
|
||||
...getMcpServerNodes(context),
|
||||
...(await getNodesFromSiteStructure(context)),
|
||||
],
|
||||
};
|
||||
@@ -59,6 +61,39 @@ export async function serveLLMsTxt(baseContext: GitBookSiteContext) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Point agents to the site's MCP server, right under the title where they read first.
|
||||
*/
|
||||
function getMcpServerNodes(context: GitBookSiteContext): RootContent[] {
|
||||
const mcpEndpoint = getAdvertisedMcpEndpoint(context);
|
||||
if (!mcpEndpoint) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
type: 'blockquote',
|
||||
children: [
|
||||
{
|
||||
type: 'paragraph',
|
||||
children: [
|
||||
{
|
||||
type: 'text',
|
||||
value: 'Agents can also search and read this documentation through its ',
|
||||
},
|
||||
{
|
||||
type: 'link',
|
||||
url: mcpEndpoint,
|
||||
children: [{ type: 'text', value: 'MCP server' }],
|
||||
},
|
||||
{ type: 'text', value: '.' },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get MDAST nodes from site structure.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it, mock } from 'bun:test';
|
||||
|
||||
import type { RevisionPageDocument } from '@gitbook/api';
|
||||
import { type RevisionPageDocument, SiteVisibility } from '@gitbook/api';
|
||||
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
import { createLinker } from '@/lib/links';
|
||||
@@ -26,7 +26,7 @@ function createContext(options: {
|
||||
return {
|
||||
displayAgentInstructions: false,
|
||||
organizationId: 'org-1',
|
||||
site: { id: 'site-1' },
|
||||
site: { id: 'site-1', visibility: SiteVisibility.Public },
|
||||
siteSpace: { id: 'site-space-1' },
|
||||
space: { id: 'space-1', revision: 'revision-1' },
|
||||
revisionId: 'revision-1',
|
||||
@@ -66,6 +66,23 @@ describe('servePageMarkdown', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('serves the current revision by selector with a noindex header for AI agents', async () => {
|
||||
const context = createContext({});
|
||||
const response = await servePageMarkdown(
|
||||
{
|
||||
...context,
|
||||
isAiAgent: true,
|
||||
linker: context.linker.fork({
|
||||
spaceBasePath: `/docs/~/revisions/${context.revisionId}/`,
|
||||
}),
|
||||
},
|
||||
'new-page'
|
||||
);
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.headers.get('X-Robots-Tag')).toBe('noindex, nofollow');
|
||||
});
|
||||
|
||||
it('redirects to the markdown version of a site redirect target', async () => {
|
||||
const context = createContext({
|
||||
siteRedirect: { target: 'https://docs.example.com/docs/new-page', permanent: true },
|
||||
@@ -77,6 +94,17 @@ describe('servePageMarkdown', () => {
|
||||
expect(response.headers.get('Location')).toBe('/docs/new-page.md');
|
||||
});
|
||||
|
||||
it('returns not-found markdown instead of looping when a site redirect targets the same markdown path', async () => {
|
||||
const context = createContext({
|
||||
siteRedirect: { target: 'https://docs.example.com/docs/old-page.md', permanent: false },
|
||||
});
|
||||
|
||||
const response = await servePageMarkdown(context, 'old-page');
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(await response.text()).toContain('# Page Not Found');
|
||||
});
|
||||
|
||||
it('redirects to the markdown version of a space redirect target', async () => {
|
||||
const context = createContext({ spaceRedirectPageId: page.id });
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { RevisionPageDocument, RevisionPageGroup } from '@gitbook/api';
|
||||
|
||||
import { resolveMissingPagePath } from '@/components/SitePage/fetch';
|
||||
import { isSameRedirectPath, resolveMissingPagePath } from '@/components/SitePage/fetch';
|
||||
import { isAIEnabled } from '@/components/utils/isAIChatEnabled';
|
||||
import { renderPageAgentInstructions, renderQueryingDocumentation } from '@/lib/ask-prompt';
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
@@ -38,10 +38,15 @@ export async function servePageMarkdown(baseContext: GitBookSiteContext, pagePat
|
||||
if (!pageLookup) {
|
||||
const fallback = await resolveMissingPagePath(baseContext, pagePath);
|
||||
if (fallback?.type === 'redirect') {
|
||||
return markdownRedirect(
|
||||
toMarkdownDestination(fallback.destination),
|
||||
fallback.permanent
|
||||
);
|
||||
const destination = toMarkdownDestination(fallback.destination);
|
||||
if (
|
||||
!isSameRedirectPath(
|
||||
context.linker.toPathForPagePath({ path: pagePath }),
|
||||
destination
|
||||
)
|
||||
) {
|
||||
return markdownRedirect(destination, fallback.permanent);
|
||||
}
|
||||
}
|
||||
if (fallback?.type === 'page') {
|
||||
return markdownRedirect(
|
||||
|
||||
@@ -67,6 +67,15 @@ it(
|
||||
{ timeout: 15_000 }
|
||||
);
|
||||
|
||||
it('should refuse to open a notification stream', async () => {
|
||||
const response = await fetch(getContentTestURL('https://gitbook.com/docs/~gitbook/mcp'), {
|
||||
headers: { accept: 'text/event-stream' },
|
||||
});
|
||||
|
||||
expect(response.status).toBe(405);
|
||||
expect(response.headers.get('allow')).toBe('POST');
|
||||
});
|
||||
|
||||
it(
|
||||
'should get a page from another site space through MCP',
|
||||
async () => {
|
||||
|
||||
Reference in New Issue
Block a user