Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
"comark-quiz": "workspace:*",
"comark-ui": "workspace:*",
"drizzle-orm": "catalog:",
"nuxt": "^4.6.2",
"lru-cache": "catalog:",
"nitro": "catalog:",
"nuxt": "catalog:",
"tailwindcss": "^4.1.0",
"valibot": "catalog:",
"vite-hub": "catalog:",
Expand Down
10 changes: 6 additions & 4 deletions docs/server/middleware/site.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { defineEventHandler, getRequestURL } from "nuxt/server";
import { fromAssets, redirectTarget } from "../utils/site.ts";

type Platform = { request: Request; env: { ASSETS?: Parameters<typeof fromAssets>[1] } };
// Nitro 3's Cloudflare entry puts the Worker's env on the request.
type Cloudflare = { env: { ASSETS?: Parameters<typeof fromAssets>[1] } };

// The Worker runs before the static assets (wrangler.jsonc), as it did before Nitro, so old hosts and paths redirect
// first. Anonymous requests still end at a prerendered file; only the paths with none reach Nitro's routes.
export default defineEventHandler(async (event) => {
const url = getRequestURL(event);
const target = redirectTarget(url);
if (target) return Response.redirect(target, 301);
const platform = event.context.cloudflare as Platform | undefined;
if (!platform?.env.ASSETS || url.pathname === "/badge.svg") return;
return fromAssets(platform.request, platform.env.ASSETS);
const { runtime } = event.req as Request & { runtime?: { cloudflare?: Cloudflare } };
const assets = runtime?.cloudflare?.env.ASSETS;
if (!assets || url.pathname === "/badge.svg") return;
return fromAssets(event.req, assets);
});
13 changes: 9 additions & 4 deletions docs/server/routes/badge.svg.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import { defineEventHandler, getRequestURL } from "nuxt/server";
import { createBadgeHandler } from "../../../packages/badge/src/server.ts";

type Platform = {
// Nitro 3's Cloudflare entry puts the Worker's env and context on the request.
type Cloudflare = {
env: { GITHUB_TOKEN?: string };
context?: { waitUntil(promise: Promise<unknown>): void };
};

let badge: ReturnType<typeof createBadgeHandler> | undefined;

export default defineEventHandler(async (event) => {
const platform = event.context.cloudflare as Platform | undefined;
const { runtime } = event.req as Request & { runtime?: { cloudflare?: Cloudflare } };
const cloudflare = runtime?.cloudflare;
badge ??= createBadgeHandler({
token: platform?.env.GITHUB_TOKEN,
token: cloudflare?.env.GITHUB_TOKEN,
// Node, which runs the tests and dev server, has no Cache API.
cache: "caches" in globalThis ? await caches.open("badges") : undefined,
});
return badge(new Request(getRequestURL(event), { method: event.req.method }), platform?.context);
return badge(
new Request(getRequestURL(event), { method: event.req.method }),
cloudflare?.context,
);
});
2 changes: 1 addition & 1 deletion docs/server/utils/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function fromAssets(request: Request, assets: Assets): Promise<Resp
if (request.method !== "GET" && request.method !== "HEAD") return;
const url = new URL(request.url);
if (url.pathname.endsWith("/") && request.headers.get("accept")?.includes("text/markdown")) {
url.pathname = url.pathname === "/" ? "/index.md" : `${url.pathname.slice(0, -1)}.md`;
url.pathname = url.pathname === "/" ? "/raw/index.md" : `/raw${url.pathname.slice(0, -1)}.md`;
const markdown = await assets.fetch(new Request(url, request));
if (markdown.ok) return markdown;
}
Expand Down
643 changes: 0 additions & 643 deletions patches/@vite-hub__docs@0.0.0-preview-4a7b419.patch

This file was deleted.

34 changes: 0 additions & 34 deletions patches/@vite-hub__web-container@0.0.0-preview-4a7b419.patch

This file was deleted.

11 changes: 3 additions & 8 deletions patches/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
# Dependency backports

The docs use vite-hub/vitehub `main` from pkg.pr.new, since `@vite-hub/docs` isn't on npm yet. Every `@vite-hub/*` entry in the catalog names the same commit, so a bump moves them all together.
The docs use [vite-hub/vitehub#3544](https://github.com/vite-hub/vitehub/pull/3544) from pkg.pr.new for Nuxt 5 and Nitro 3 support, since `@vite-hub/docs` isn't on npm yet. Every `@vite-hub/*` entry in the catalog names the same commit, so a bump moves them all together.

## Comark syntax highlighting

`comark@0.8.1` is patched with [comarkdown/comark#523](https://github.com/comarkdown/comark/pull/523). It removes exponential backtracking from the component attribute grammar, so Markdown samples followed by punctuation cannot stall docs generation. The patch was generated with `pnpm patch` and `pnpm patch-commit`. The fix merged on 2026-10-28 but is not in a release yet (0.8.1 is the latest). Remove `patches/comark.patch` and its `patchedDependencies` entry after upgrading to a Comark release containing it.

## @vite-hub/docs and @vite-hub/web-container
## PKCE in Workers

Both are patched with [vite-hub/vitehub#3372](https://github.com/vite-hub/vitehub/pull/3372), built from its branch and committed with `pnpm patch-commit`.

- `@vite-hub/docs` gets Nuxt SEO: a share image for every page, rendered while the build prerenders, plus site config and Schema.org. The patch adds dependencies that pnpm resolves before it applies the patch, so they come from the `packageExtensions` entry for `@vite-hub/docs` and the `@vite-hub/docs>nuxt-agent-discovery` override.
- `@vite-hub/web-container` stops importing `@webcontainer/env`, so the Worker bundles without an alias for `@blitz/internal/env`.

Once the PR merges, move the catalog to a vitehub commit that contains it. Then remove both patches, their `patchedDependencies` entries, the `packageExtensions` entry, and the override.
`pkce-challenge@5.0.1` needs a `workerd` export condition for Nitro 3's Cloudflare build. The patch backports [crouchcd/pkce-challenge#50](https://github.com/crouchcd/pkce-challenge/pull/50), which merged but is not released. Remove it after upgrading to a release with the export.
22 changes: 22 additions & 0 deletions patches/pkce-challenge@5.0.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/package.json b/package.json
index 3d2315888db6ad74f0d857f3da8d804f473f4523..c3577cf4c094f76eec3217669d707f9df840153b 100644
--- a/package.json
+++ b/package.json
@@ -10,6 +10,7 @@
"require": "./dist/index.node.d.cts",
"import": "./dist/index.node.d.ts"
},
+ "workerd": "./dist/index.browser.js",
"browser": {
"types": "./dist/index.browser.d.ts",
"default": "./dist/index.browser.js"
@@ -17,7 +18,8 @@
"node": {
"import": "./dist/index.node.js",
"require": "./dist/index.node.cjs"
- }
+ },
+ "default": "./dist/index.browser.js"
}
},
"files": [
Loading
Loading