Compare commits

..

No commits in common. "d75125d9fab3bbba9b2e408504a73e6ab833c1b4" and "cf010ad4f52f35c644c28c1c2f344269a9acc0db" have entirely different histories.

65 changed files with 917 additions and 872 deletions

3
.gitignore vendored
View File

@ -176,6 +176,3 @@ out
.bunext .bunext
/bin /bin
/build /build
__fixtures__
/public
/.data

2
.npmrc
View File

@ -1,2 +0,0 @@
@moduletrace:registry=https://git.tben.me/api/packages/moduletrace/npm/
//git.tben.me/api/packages/moduletrace/npm/:_authToken=${GITBEN_NPM_TOKEN}

170
README.md
View File

@ -7,7 +7,6 @@ A server-rendering framework for React, built on [Bun](https://bun.sh). Bunext h
Bunext is focused on **server-side rendering and processing**. Every page is rendered on the server on every request. The framework deliberately does not implement client-side navigation, SPA routing, or client-side state management — those concerns belong in client-side libraries and are orthogonal to what Bunext is solving. Bunext is focused on **server-side rendering and processing**. Every page is rendered on the server on every request. The framework deliberately does not implement client-side navigation, SPA routing, or client-side state management — those concerns belong in client-side libraries and are orthogonal to what Bunext is solving.
The goal is a framework that is: The goal is a framework that is:
- Fast — Bun's runtime speed and ESBuild's bundling make the full dev loop snappy - Fast — Bun's runtime speed and ESBuild's bundling make the full dev loop snappy
- Transparent — the entire request pipeline is readable and debugable - Transparent — the entire request pipeline is readable and debugable
- Standard — server functions and API handlers use native Web APIs (`Request`, `Response`, `URL`) with no custom wrappers - Standard — server functions and API handlers use native Web APIs (`Request`, `Response`, `URL`) with no custom wrappers
@ -73,10 +72,11 @@ Install Bunext directly from GitHub:
bun add github:moduletrace/bunext bun add github:moduletrace/bunext
``` ```
Install globally: Install required peer dependencies:
```bash ```bash
bun add -g github:moduletrace/bunext bun add react react-dom
bun add -d typescript @types/react @types/react-dom
``` ```
--- ---
@ -102,25 +102,13 @@ export default function HomePage() {
} }
``` ```
3. Add scripts to your `package.json`: 3. Start the development server:
```json
{
"scripts": {
"dev": "bunx bunext dev",
"build": "bunx bunext build",
"start": "bunx bunext start"
}
}
```
4. Start the development server:
```bash ```bash
bun run dev bunext dev
``` ```
5. Open `http://localhost:7000` in your browser. 4. Open `http://localhost:7000` in your browser.
--- ---
@ -132,38 +120,18 @@ bun run dev
| `bunext build` | Bundle all pages for production. Outputs artifacts to `public/pages/`. | | `bunext build` | Bundle all pages for production. Outputs artifacts to `public/pages/`. |
| `bunext start` | Start the production server using pre-built artifacts. | | `bunext start` | Start the production server using pre-built artifacts. |
### Running the CLI
Bunext exposes a `bunext` binary. How you invoke it depends on how the package is installed:
**Local install (recommended)** — add scripts to `package.json` and run them with `bun run`:
```json
{
"scripts": {
"dev": "bunx bunext dev",
"build": "bunx bunext build",
"start": "bunx bunext start"
}
}
```
```bash ```bash
bun run dev # Development
bun run build
bun run start
```
**Global install** — install once and use `bunext` from anywhere:
```bash
bun add -g github:moduletrace/bunext
bunext dev bunext dev
# Production build
bunext build bunext build
# Production server (must run build first)
bunext start bunext start
``` ```
> **Note:** `bunext start` will exit with an error if `public/pages/map.json` does not exist. Always run `bunext build` (or `bun run build`) before `bunext start`. > **Note:** `bunext start` will exit with an error if `public/pages/map.json` does not exist. Always run `bunext build` before `bunext start`.
--- ---
@ -216,11 +184,11 @@ Dynamic route parameters (e.g. `[slug]`) are available in the `server` function
Directories whose name contains `--` or a parenthesis (`(` or `)`) are completely ignored by the router. Use this to co-locate helper components, utilities, or shared logic directly inside `src/pages/` alongside the routes that use them, without them becoming routes. Directories whose name contains `--` or a parenthesis (`(` or `)`) are completely ignored by the router. Use this to co-locate helper components, utilities, or shared logic directly inside `src/pages/` alongside the routes that use them, without them becoming routes.
| Naming pattern | Effect | | Naming pattern | Effect |
| --------------- | -------------------- | | --- | --- |
| `(components)/` | Ignored — not routed | | `(components)/` | Ignored — not routed |
| `--utils--/` | Ignored — not routed | | `--utils--/` | Ignored — not routed |
| `--lib/` | Ignored — not routed | | `--lib/` | Ignored — not routed |
``` ```
src/pages/ src/pages/
@ -254,7 +222,7 @@ Export a `server` function to run server-side logic before rendering. The return
```tsx ```tsx
// src/pages/profile.tsx // src/pages/profile.tsx
import type { BunextPageServerFn } from "@moduletrace/bunext/types"; import type { BunextPageServerFn } from "bunext/src/types";
type Props = { type Props = {
props?: { username: string; bio: string }; props?: { username: string; bio: string };
@ -306,7 +274,7 @@ Every page component automatically receives a `url` prop — a copy of the reque
```tsx ```tsx
// src/pages/index.tsx // src/pages/index.tsx
import type { BunextPageModuleServerReturnURLObject } from "@moduletrace/bunext/types"; import type { BunextPageModuleServerReturnURLObject } from "bunext/src/types";
type Props = { type Props = {
url?: BunextPageModuleServerReturnURLObject; url?: BunextPageModuleServerReturnURLObject;
@ -324,20 +292,20 @@ export default function HomePage({ url }: Props) {
The `url` prop exposes the following fields from the standard Web `URL` interface: The `url` prop exposes the following fields from the standard Web `URL` interface:
| Field | Type | Example | | Field | Type | Example |
| -------------- | ----------------- | -------------------------------- | | -------------- | ---------------- | -------------------------------- |
| `href` | `string` | `"https://example.com/blog?q=1"` | | `href` | `string` | `"https://example.com/blog?q=1"` |
| `origin` | `string` | `"https://example.com"` | | `origin` | `string` | `"https://example.com"` |
| `protocol` | `string` | `"https:"` | | `protocol` | `string` | `"https:"` |
| `host` | `string` | `"example.com"` | | `host` | `string` | `"example.com"` |
| `hostname` | `string` | `"example.com"` | | `hostname` | `string` | `"example.com"` |
| `port` | `string` | `""` | | `port` | `string` | `""` |
| `pathname` | `string` | `"/blog"` | | `pathname` | `string` | `"/blog"` |
| `search` | `string` | `"?q=1"` | | `search` | `string` | `"?q=1"` |
| `searchParams` | `URLSearchParams` | `URLSearchParams { q: "1" }` | | `searchParams` | `URLSearchParams` | `URLSearchParams { q: "1" }` |
| `hash` | `string` | `""` | | `hash` | `string` | `""` |
| `username` | `string` | `""` | | `username` | `string` | `""` |
| `password` | `string` | `""` | | `password` | `string` | `""` |
### Redirects from Server ### Redirects from Server
@ -386,7 +354,7 @@ export const server: BunextPageServerFn = async (ctx) => {
Export a `meta` object to inject SEO and Open Graph tags into the `<head>`: Export a `meta` object to inject SEO and Open Graph tags into the `<head>`:
```tsx ```tsx
import type { BunextPageModuleMeta } from "@moduletrace/bunext/types"; import type { BunextPageModuleMeta } from "bunext/src/types";
export const meta: BunextPageModuleMeta = { export const meta: BunextPageModuleMeta = {
title: "My Page Title", title: "My Page Title",
@ -425,7 +393,7 @@ export default function AboutPage() {
`meta` can also be an async function that receives the request context and server response: `meta` can also be an async function that receives the request context and server response:
```tsx ```tsx
import type { BunextPageModuleMetaFn } from "@moduletrace/bunext/types"; import type { BunextPageModuleMetaFn } from "bunext/src/types";
export const meta: BunextPageModuleMetaFn = async ({ ctx, serverRes }) => { export const meta: BunextPageModuleMetaFn = async ({ ctx, serverRes }) => {
return { return {
@ -440,7 +408,7 @@ export const meta: BunextPageModuleMetaFn = async ({ ctx, serverRes }) => {
Export a `Head` functional component to inject arbitrary HTML into `<head>`. It receives the server response and request context: Export a `Head` functional component to inject arbitrary HTML into `<head>`. It receives the server response and request context:
```tsx ```tsx
import type { BunextPageHeadFCProps } from "@moduletrace/bunext/types"; import type { BunextPageHeadFCProps } from "bunext/src/types";
export function Head({ serverRes, ctx }: BunextPageHeadFCProps) { export function Head({ serverRes, ctx }: BunextPageHeadFCProps) {
return ( return (
@ -486,7 +454,7 @@ Create files under `src/pages/api/` to define API endpoints. The default export
```ts ```ts
// src/pages/api/hello.ts // src/pages/api/hello.ts
import type { BunxRouteParams } from "@moduletrace/bunext/types"; import type { BunxRouteParams } from "bunext/src/types";
export default async function handler(ctx: BunxRouteParams): Promise<Response> { export default async function handler(ctx: BunxRouteParams): Promise<Response> {
return Response.json({ message: "Hello from the API" }); return Response.json({ message: "Hello from the API" });
@ -497,7 +465,7 @@ API routes are matched at `/api/<filename>`. Because the handler returns a plain
```ts ```ts
// src/pages/api/users.ts // src/pages/api/users.ts
import type { BunxRouteParams } from "@moduletrace/bunext/types"; import type { BunxRouteParams } from "bunext/src/types";
export default async function handler(ctx: BunxRouteParams): Promise<Response> { export default async function handler(ctx: BunxRouteParams): Promise<Response> {
if (ctx.req.method !== "GET") { if (ctx.req.method !== "GET") {
@ -520,7 +488,7 @@ Export a `config` object to override the per-route request body limit (default:
import type { import type {
BunextServerRouteConfig, BunextServerRouteConfig,
BunxRouteParams, BunxRouteParams,
} from "@moduletrace/bunext/types"; } from "bunext/src/types";
export const config: BunextServerRouteConfig = { export const config: BunextServerRouteConfig = {
maxRequestBodyMB: 50, // allow up to 50 MB maxRequestBodyMB: 50, // allow up to 50 MB
@ -584,10 +552,10 @@ Bunext includes a file-based HTML cache for production. Caching is **disabled in
Cache files are stored in `public/__bunext/cache/`. Each cached page produces two files: Cache files are stored in `public/__bunext/cache/`. Each cached page produces two files:
| File | Contents | | File | Contents |
| ----------------- | ---------------------------------------------- | |---------------------------|----------------------------------------------|
| `<key>.res.html` | The cached HTML response body | | `<key>.res.html` | The cached HTML response body |
| `<key>.meta.json` | Metadata: creation timestamp, expiry, paradigm | | `<key>.meta.json` | Metadata: creation timestamp, expiry, paradigm |
The cache is **cold on first request**: the first visitor triggers a full server render and writes the cache. Every subsequent request within the expiry window receives the cached HTML directly, bypassing the server function, component render, and bundler lookup. A cache hit is indicated by the response header `X-Bunext-Cache: HIT`. The cache is **cold on first request**: the first visitor triggers a full server render and writes the cache. Every subsequent request within the expiry window receives the cached HTML directly, bypassing the server function, component render, and bundler lookup. A cache hit is indicated by the response header `X-Bunext-Cache: HIT`.
@ -597,7 +565,7 @@ Export a `config` object from a page file to opt that page into caching:
```tsx ```tsx
// src/pages/products.tsx // src/pages/products.tsx
import type { BunextRouteConfig } from "@moduletrace/bunext/types"; import type { BunextRouteConfig } from "bunext/src/types";
export const config: BunextRouteConfig = { export const config: BunextRouteConfig = {
cachePage: true, cachePage: true,
@ -614,7 +582,7 @@ export default function ProductsPage() {
Cache settings can also be returned from the `server` function, which lets you conditionally enable caching based on request data: Cache settings can also be returned from the `server` function, which lets you conditionally enable caching based on request data:
```tsx ```tsx
import type { BunextPageServerFn } from "@moduletrace/bunext/types"; import type { BunextPageServerFn } from "bunext/src/types";
export const server: BunextPageServerFn = async (ctx) => { export const server: BunextPageServerFn = async (ctx) => {
const data = await fetchProducts(); const data = await fetchProducts();
@ -627,13 +595,7 @@ export const server: BunextPageServerFn = async (ctx) => {
}; };
export default function ProductsPage({ props }: any) { export default function ProductsPage({ props }: any) {
return ( return <ul>{props.data.map((p: any) => <li key={p.id}>{p.name}</li>)}</ul>;
<ul>
{props.data.map((p: any) => (
<li key={p.id}>{p.name}</li>
))}
</ul>
);
} }
``` ```
@ -665,7 +627,7 @@ Create a `bunext.config.ts` file in your project root to configure Bunext:
```ts ```ts
// bunext.config.ts // bunext.config.ts
import type { BunextConfig } from "@moduletrace/bunext/types"; import type { BunextConfig } from "bunext/src/types";
const config: BunextConfig = { const config: BunextConfig = {
port: 3000, // default: 7000 port: 3000, // default: 7000
@ -681,18 +643,18 @@ const config: BunextConfig = {
export default config; export default config;
``` ```
| Option | Type | Default | Description | | Option | Type | Default | Description |
| -------------------- | --------------------------------------------------------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------- | | -------------- | --------------------------------------------------------------------------------- | ---------------- | -------------------------------------------------- |
| `port` | `number` | `7000` | HTTP server port | | `port` | `number` | `7000` | HTTP server port |
| `origin` | `string` | — | Canonical origin URL | | `origin` | `string` | — | Canonical origin URL |
| `distDir` | `string` | `.bunext` | Internal artifact directory | | `distDir` | `string` | `.bunext` | Internal artifact directory |
| `assetsPrefix` | `string` | `_bunext/static` | URL prefix for static assets | | `assetsPrefix` | `string` | `_bunext/static` | URL prefix for static assets |
| `globalVars` | `{ [k: string]: any }` | — | Variables injected globally at build time | | `globalVars` | `{ [k: string]: any }` | — | Variables injected globally at build time |
| `development` | `boolean` | — | Overridden to `true` by `bunext dev` automatically | | `development` | `boolean` | — | Overridden to `true` by `bunext dev` automatically |
| `defaultCacheExpiry` | `number` | `3600` | Global page cache expiry in seconds | | `defaultCacheExpiry`| `number` | `3600` | Global page cache expiry in seconds |
| `middleware` | `(params: BunextConfigMiddlewareParams) => Response \| undefined \| Promise<...>` | — | Global middleware — see [Middleware](#middleware) | | `middleware` | `(params: BunextConfigMiddlewareParams) => Response \| undefined \| Promise<...>` | — | Global middleware — see [Middleware](#middleware) |
| `websocket` | `WebSocketHandler<any>` | — | Bun WebSocket handler — see [WebSocket](#websocket) | | `websocket` | `WebSocketHandler<any>` | — | Bun WebSocket handler — see [WebSocket](#websocket) |
| `serverOptions` | `ServeOptions` | — | Extra options passed to `Bun.serve()` (excluding `fetch`) — see [Server Options](#server-options) | | `serverOptions` | `ServeOptions` | — | Extra options passed to `Bun.serve()` (excluding `fetch`) — see [Server Options](#server-options) |
### Middleware ### Middleware
@ -706,7 +668,7 @@ Middleware runs on every request before any routing. Define it in `bunext.config
import type { import type {
BunextConfig, BunextConfig,
BunextConfigMiddlewareParams, BunextConfigMiddlewareParams,
} from "@moduletrace/bunext/types"; } from "bunext/src/types";
const config: BunextConfig = { const config: BunextConfig = {
middleware: async ({ req, url }) => { middleware: async ({ req, url }) => {
@ -759,7 +721,7 @@ export const BunextWebsocket: WebSocketHandler<any> = {
```ts ```ts
// bunext.config.ts // bunext.config.ts
import type { BunextConfig } from "@moduletrace/bunext/types"; import type { BunextConfig } from "bunext/src/types";
import { BunextWebsocket } from "./websocket"; import { BunextWebsocket } from "./websocket";
const config: BunextConfig = { const config: BunextConfig = {
@ -775,7 +737,7 @@ Pass additional options to the underlying `Bun.serve()` call via `serverOptions`
```ts ```ts
// bunext.config.ts // bunext.config.ts
import type { BunextConfig } from "@moduletrace/bunext/types"; import type { BunextConfig } from "bunext/src/types";
const config: BunextConfig = { const config: BunextConfig = {
serverOptions: { serverOptions: {
@ -802,7 +764,7 @@ For full control over the `Bun.serve()` instance — custom WebSocket upgrade lo
```ts ```ts
// server.ts // server.ts
import bunext from "@moduletrace/bunext"; import bunext from "bunext";
const development = process.env.NODE_ENV === "development"; const development = process.env.NODE_ENV === "development";
const port = process.env.PORT || 3700; const port = process.env.PORT || 3700;
@ -824,11 +786,11 @@ const server = Bun.serve({
bunext.bunextLog.info(`Server running on http://localhost:${server.port} ...`); bunext.bunextLog.info(`Server running on http://localhost:${server.port} ...`);
``` ```
| Export | Type | Description | | Export | Type | Description |
| ------------------------------- | ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | |--------|------|-------------|
| `bunextInit()` | `() => Promise<void>` | Initializes config, router, and bundler. Must be called before handling requests. | | `bunextInit()` | `() => Promise<void>` | Initializes config, router, and bundler. Must be called before handling requests. |
| `bunextRequestHandler({ req })` | `(params: { req: Request }) => Promise<Response>` | The main Bunext request dispatcher — middleware, routing, SSR, static files. Only `req` is needed; the server instance is managed internally. | | `bunextRequestHandler({ req })` | `(params: { req: Request }) => Promise<Response>` | The main Bunext request dispatcher — middleware, routing, SSR, static files. Only `req` is needed; the server instance is managed internally. |
| `bunextLog` | Logger | Framework logger (`info`, `error`, `success`, `server`, `watch`). | | `bunextLog` | Logger | Framework logger (`info`, `error`, `success`, `server`, `watch`). |
Run the custom server directly with Bun: Run the custom server directly with Bun:

View File

@ -9,7 +9,6 @@
"chalk": "^5.6.2", "chalk": "^5.6.2",
"commander": "^14.0.2", "commander": "^14.0.2",
"esbuild": "^0.27.4", "esbuild": "^0.27.4",
"@moduletrace/bunext": "github:moduletrace/bunext",
"lightningcss-wasm": "^1.32.0", "lightningcss-wasm": "^1.32.0",
"lodash": "^4.17.23", "lodash": "^4.17.23",
"micromatch": "^4.0.8", "micromatch": "^4.0.8",
@ -17,15 +16,12 @@
"postcss": "^8.5.8", "postcss": "^8.5.8",
}, },
"devDependencies": { "devDependencies": {
"@testing-library/dom": "^10.4.1",
"@testing-library/react": "^16.3.2",
"@types/bun": "latest", "@types/bun": "latest",
"@types/lodash": "^4.17.24", "@types/lodash": "^4.17.24",
"@types/micromatch": "^4.0.10", "@types/micromatch": "^4.0.10",
"@types/node": "^24.10.0", "@types/node": "^24.10.0",
"@types/react": "^19.2.2", "@types/react": "^19.2.2",
"@types/react-dom": "^19.2.2", "@types/react-dom": "^19.2.2",
"happy-dom": "^20.8.4",
"react": "^19.2.4", "react": "^19.2.4",
"react-dom": "^19.2.4", "react-dom": "^19.2.4",
}, },
@ -39,12 +35,6 @@
"packages": { "packages": {
"@alloc/quick-lru": ["@alloc/quick-lru@5.2.0", "", {}, "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw=="], "@alloc/quick-lru": ["@alloc/quick-lru@5.2.0", "", {}, "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw=="],
"@babel/code-frame": ["@babel/code-frame@7.29.0", "", { "dependencies": { "@babel/helper-validator-identifier": "^7.28.5", "js-tokens": "^4.0.0", "picocolors": "^1.1.1" } }, "sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw=="],
"@babel/helper-validator-identifier": ["@babel/helper-validator-identifier@7.28.5", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
"@babel/runtime": ["@babel/runtime@7.29.2", "", {}, "sha512-JiDShH45zKHWyGe4ZNVRrCjBz8Nh9TMmZG1kh4QTK8hCBTWBi8Da+i7s1fJw7/lYpM4ccepSNfqzZ/QvABBi5g=="],
"@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.27.4", "", { "os": "aix", "cpu": "ppc64" }, "sha512-cQPwL2mp2nSmHHJlCyoXgHGhbEPMrEEU5xhkcy3Hs/O7nGZqEpZ2sUtLaL9MORLtDfRvVl2/3PAuEkYZH0Ty8Q=="], "@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.27.4", "", { "os": "aix", "cpu": "ppc64" }, "sha512-cQPwL2mp2nSmHHJlCyoXgHGhbEPMrEEU5xhkcy3Hs/O7nGZqEpZ2sUtLaL9MORLtDfRvVl2/3PAuEkYZH0Ty8Q=="],
"@esbuild/android-arm": ["@esbuild/android-arm@0.27.4", "", { "os": "android", "cpu": "arm" }, "sha512-X9bUgvxiC8CHAGKYufLIHGXPJWnr0OCdR0anD2e21vdvgCI8lIfqFbnoeOz7lBjdrAGUhqLZLcQo6MLhTO2DKQ=="], "@esbuild/android-arm": ["@esbuild/android-arm@0.27.4", "", { "os": "android", "cpu": "arm" }, "sha512-X9bUgvxiC8CHAGKYufLIHGXPJWnr0OCdR0anD2e21vdvgCI8lIfqFbnoeOz7lBjdrAGUhqLZLcQo6MLhTO2DKQ=="],
@ -107,8 +97,6 @@
"@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.31", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="], "@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.31", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="],
"@moduletrace/bunext": ["@moduletrace/bunext@github:moduletrace/bunext#632c70f", { "dependencies": { "@tailwindcss/postcss": "^4.2.2", "bun-plugin-tailwind": "^0.1.2", "chalk": "^5.6.2", "commander": "^14.0.2", "esbuild": "^0.27.4", "lightningcss-wasm": "^1.32.0", "lodash": "^4.17.23", "micromatch": "^4.0.8", "ora": "^9.0.0", "postcss": "^8.5.8" }, "peerDependencies": { "react": "^19.0.0", "react-dom": "^19.0.0", "typescript": "^5.0.0" }, "bin": { "bunext": "dist/commands/index.js" } }, "Moduletrace-bunext-632c70f"],
"@oven/bun-darwin-aarch64": ["@oven/bun-darwin-aarch64@1.3.10", "", { "os": "darwin", "cpu": "arm64" }, "sha512-PXgg5gqcS/rHwa1hF0JdM1y5TiyejVrMHoBmWY/DjtfYZoFTXie1RCFOkoG0b5diOOmUcuYarMpH7CSNTqwj+w=="], "@oven/bun-darwin-aarch64": ["@oven/bun-darwin-aarch64@1.3.10", "", { "os": "darwin", "cpu": "arm64" }, "sha512-PXgg5gqcS/rHwa1hF0JdM1y5TiyejVrMHoBmWY/DjtfYZoFTXie1RCFOkoG0b5diOOmUcuYarMpH7CSNTqwj+w=="],
"@oven/bun-darwin-x64": ["@oven/bun-darwin-x64@1.3.10", "", { "os": "darwin", "cpu": "x64" }, "sha512-Nhssuh7GBpP5PiDSOl3+qnoIG7PJo+ec2oomDevnl9pRY6x6aD2gRt0JE+uf+A8Om2D6gjeHCxjEdrw5ZHE8mA=="], "@oven/bun-darwin-x64": ["@oven/bun-darwin-x64@1.3.10", "", { "os": "darwin", "cpu": "x64" }, "sha512-Nhssuh7GBpP5PiDSOl3+qnoIG7PJo+ec2oomDevnl9pRY6x6aD2gRt0JE+uf+A8Om2D6gjeHCxjEdrw5ZHE8mA=="],
@ -163,12 +151,6 @@
"@tailwindcss/postcss": ["@tailwindcss/postcss@4.2.2", "", { "dependencies": { "@alloc/quick-lru": "^5.2.0", "@tailwindcss/node": "4.2.2", "@tailwindcss/oxide": "4.2.2", "postcss": "^8.5.6", "tailwindcss": "4.2.2" } }, "sha512-n4goKQbW8RVXIbNKRB/45LzyUqN451deQK0nzIeauVEqjlI49slUlgKYJM2QyUzap/PcpnS7kzSUmPb1sCRvYQ=="], "@tailwindcss/postcss": ["@tailwindcss/postcss@4.2.2", "", { "dependencies": { "@alloc/quick-lru": "^5.2.0", "@tailwindcss/node": "4.2.2", "@tailwindcss/oxide": "4.2.2", "postcss": "^8.5.6", "tailwindcss": "4.2.2" } }, "sha512-n4goKQbW8RVXIbNKRB/45LzyUqN451deQK0nzIeauVEqjlI49slUlgKYJM2QyUzap/PcpnS7kzSUmPb1sCRvYQ=="],
"@testing-library/dom": ["@testing-library/dom@10.4.1", "", { "dependencies": { "@babel/code-frame": "^7.10.4", "@babel/runtime": "^7.12.5", "@types/aria-query": "^5.0.1", "aria-query": "5.3.0", "dom-accessibility-api": "^0.5.9", "lz-string": "^1.5.0", "picocolors": "1.1.1", "pretty-format": "^27.0.2" } }, "sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg=="],
"@testing-library/react": ["@testing-library/react@16.3.2", "", { "dependencies": { "@babel/runtime": "^7.12.5" }, "peerDependencies": { "@testing-library/dom": "^10.0.0", "@types/react": "^18.0.0 || ^19.0.0", "@types/react-dom": "^18.0.0 || ^19.0.0", "react": "^18.0.0 || ^19.0.0", "react-dom": "^18.0.0 || ^19.0.0" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-XU5/SytQM+ykqMnAnvB2umaJNIOsLF3PVv//1Ew4CTcpz0/BRyy/af40qqrt7SjKpDdT1saBMc42CUok5gaw+g=="],
"@types/aria-query": ["@types/aria-query@5.0.4", "", {}, "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw=="],
"@types/braces": ["@types/braces@3.0.5", "", {}, "sha512-SQFof9H+LXeWNz8wDe7oN5zu7ket0qwMu5vZubW4GCJ8Kkeh6nBWUz87+KTz/G3Kqsrp0j/W253XJb3KMEeg3w=="], "@types/braces": ["@types/braces@3.0.5", "", {}, "sha512-SQFof9H+LXeWNz8wDe7oN5zu7ket0qwMu5vZubW4GCJ8Kkeh6nBWUz87+KTz/G3Kqsrp0j/W253XJb3KMEeg3w=="],
"@types/bun": ["@types/bun@1.2.3", "", { "dependencies": { "bun-types": "1.2.3" } }, "sha512-054h79ipETRfjtsCW9qJK8Ipof67Pw9bodFWmkfkaUaRiIQ1dIV2VTlheshlBx3mpKr0KeK8VqnMMCtgN9rQtw=="], "@types/bun": ["@types/bun@1.2.3", "", { "dependencies": { "bun-types": "1.2.3" } }, "sha512-054h79ipETRfjtsCW9qJK8Ipof67Pw9bodFWmkfkaUaRiIQ1dIV2VTlheshlBx3mpKr0KeK8VqnMMCtgN9rQtw=="],
@ -183,15 +165,9 @@
"@types/react-dom": ["@types/react-dom@19.2.3", "", { "peerDependencies": { "@types/react": "^19.2.0" } }, "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ=="], "@types/react-dom": ["@types/react-dom@19.2.3", "", { "peerDependencies": { "@types/react": "^19.2.0" } }, "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ=="],
"@types/whatwg-mimetype": ["@types/whatwg-mimetype@3.0.2", "", {}, "sha512-c2AKvDT8ToxLIOUlN51gTiHXflsfIFisS4pO7pDPoKouJCESkhZnEy623gwP9laCy5lnLDAw1vAzu2vM2YLOrA=="], "@types/ws": ["@types/ws@8.5.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-bd/YFLW+URhBzMXurx7lWByOu+xzU9+kb3RboOteXYDfW+tr+JZa99OyNmPINEGB/ahzKrEuc8rcv4gnpJmxTw=="],
"@types/ws": ["@types/ws@8.18.1", "", { "dependencies": { "@types/node": "*" } }, "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg=="], "ansi-regex": ["ansi-regex@6.2.2", "", {}, "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg=="],
"ansi-regex": ["ansi-regex@5.0.1", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],
"ansi-styles": ["ansi-styles@5.2.0", "", {}, "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA=="],
"aria-query": ["aria-query@5.3.0", "", { "dependencies": { "dequal": "^2.0.3" } }, "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A=="],
"braces": ["braces@3.0.3", "", { "dependencies": { "fill-range": "^7.1.1" } }, "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA=="], "braces": ["braces@3.0.3", "", { "dependencies": { "fill-range": "^7.1.1" } }, "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA=="],
@ -211,16 +187,10 @@
"csstype": ["csstype@3.2.3", "", {}, "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ=="], "csstype": ["csstype@3.2.3", "", {}, "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ=="],
"dequal": ["dequal@2.0.3", "", {}, "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA=="],
"detect-libc": ["detect-libc@2.1.2", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="], "detect-libc": ["detect-libc@2.1.2", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="],
"dom-accessibility-api": ["dom-accessibility-api@0.5.16", "", {}, "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg=="],
"enhanced-resolve": ["enhanced-resolve@5.20.1", "", { "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.3.0" } }, "sha512-Qohcme7V1inbAfvjItgw0EaxVX5q2rdVEZHRBrEQdRZTssLDGsL8Lwrznl8oQ/6kuTJONLaDcGjkNP247XEhcA=="], "enhanced-resolve": ["enhanced-resolve@5.20.1", "", { "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.3.0" } }, "sha512-Qohcme7V1inbAfvjItgw0EaxVX5q2rdVEZHRBrEQdRZTssLDGsL8Lwrznl8oQ/6kuTJONLaDcGjkNP247XEhcA=="],
"entities": ["entities@7.0.1", "", {}, "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA=="],
"esbuild": ["esbuild@0.27.4", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.27.4", "@esbuild/android-arm": "0.27.4", "@esbuild/android-arm64": "0.27.4", "@esbuild/android-x64": "0.27.4", "@esbuild/darwin-arm64": "0.27.4", "@esbuild/darwin-x64": "0.27.4", "@esbuild/freebsd-arm64": "0.27.4", "@esbuild/freebsd-x64": "0.27.4", "@esbuild/linux-arm": "0.27.4", "@esbuild/linux-arm64": "0.27.4", "@esbuild/linux-ia32": "0.27.4", "@esbuild/linux-loong64": "0.27.4", "@esbuild/linux-mips64el": "0.27.4", "@esbuild/linux-ppc64": "0.27.4", "@esbuild/linux-riscv64": "0.27.4", "@esbuild/linux-s390x": "0.27.4", "@esbuild/linux-x64": "0.27.4", "@esbuild/netbsd-arm64": "0.27.4", "@esbuild/netbsd-x64": "0.27.4", "@esbuild/openbsd-arm64": "0.27.4", "@esbuild/openbsd-x64": "0.27.4", "@esbuild/openharmony-arm64": "0.27.4", "@esbuild/sunos-x64": "0.27.4", "@esbuild/win32-arm64": "0.27.4", "@esbuild/win32-ia32": "0.27.4", "@esbuild/win32-x64": "0.27.4" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-Rq4vbHnYkK5fws5NF7MYTU68FPRE1ajX7heQ/8QXXWqNgqqJ/GkmmyxIzUnf2Sr/bakf8l54716CcMGHYhMrrQ=="], "esbuild": ["esbuild@0.27.4", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.27.4", "@esbuild/android-arm": "0.27.4", "@esbuild/android-arm64": "0.27.4", "@esbuild/android-x64": "0.27.4", "@esbuild/darwin-arm64": "0.27.4", "@esbuild/darwin-x64": "0.27.4", "@esbuild/freebsd-arm64": "0.27.4", "@esbuild/freebsd-x64": "0.27.4", "@esbuild/linux-arm": "0.27.4", "@esbuild/linux-arm64": "0.27.4", "@esbuild/linux-ia32": "0.27.4", "@esbuild/linux-loong64": "0.27.4", "@esbuild/linux-mips64el": "0.27.4", "@esbuild/linux-ppc64": "0.27.4", "@esbuild/linux-riscv64": "0.27.4", "@esbuild/linux-s390x": "0.27.4", "@esbuild/linux-x64": "0.27.4", "@esbuild/netbsd-arm64": "0.27.4", "@esbuild/netbsd-x64": "0.27.4", "@esbuild/openbsd-arm64": "0.27.4", "@esbuild/openbsd-x64": "0.27.4", "@esbuild/openharmony-arm64": "0.27.4", "@esbuild/sunos-x64": "0.27.4", "@esbuild/win32-arm64": "0.27.4", "@esbuild/win32-ia32": "0.27.4", "@esbuild/win32-x64": "0.27.4" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-Rq4vbHnYkK5fws5NF7MYTU68FPRE1ajX7heQ/8QXXWqNgqqJ/GkmmyxIzUnf2Sr/bakf8l54716CcMGHYhMrrQ=="],
"fill-range": ["fill-range@7.1.1", "", { "dependencies": { "to-regex-range": "^5.0.1" } }, "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg=="], "fill-range": ["fill-range@7.1.1", "", { "dependencies": { "to-regex-range": "^5.0.1" } }, "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg=="],
@ -229,8 +199,6 @@
"graceful-fs": ["graceful-fs@4.2.11", "", {}, "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="], "graceful-fs": ["graceful-fs@4.2.11", "", {}, "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="],
"happy-dom": ["happy-dom@20.8.4", "", { "dependencies": { "@types/node": ">=20.0.0", "@types/whatwg-mimetype": "^3.0.2", "@types/ws": "^8.18.1", "entities": "^7.0.1", "whatwg-mimetype": "^3.0.0", "ws": "^8.18.3" } }, "sha512-GKhjq4OQCYB4VLFBzv8mmccUadwlAusOZOI7hC1D9xDIT5HhzkJK17c4el2f6R6C715P9xB4uiMxeKUa2nHMwQ=="],
"is-interactive": ["is-interactive@2.0.0", "", {}, "sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ=="], "is-interactive": ["is-interactive@2.0.0", "", {}, "sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ=="],
"is-number": ["is-number@7.0.0", "", {}, "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="], "is-number": ["is-number@7.0.0", "", {}, "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="],
@ -239,8 +207,6 @@
"jiti": ["jiti@2.6.1", "", { "bin": { "jiti": "lib/jiti-cli.mjs" } }, "sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ=="], "jiti": ["jiti@2.6.1", "", { "bin": { "jiti": "lib/jiti-cli.mjs" } }, "sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ=="],
"js-tokens": ["js-tokens@4.0.0", "", {}, "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="],
"lightningcss": ["lightningcss@1.32.0", "", { "dependencies": { "detect-libc": "^2.0.3" }, "optionalDependencies": { "lightningcss-android-arm64": "1.32.0", "lightningcss-darwin-arm64": "1.32.0", "lightningcss-darwin-x64": "1.32.0", "lightningcss-freebsd-x64": "1.32.0", "lightningcss-linux-arm-gnueabihf": "1.32.0", "lightningcss-linux-arm64-gnu": "1.32.0", "lightningcss-linux-arm64-musl": "1.32.0", "lightningcss-linux-x64-gnu": "1.32.0", "lightningcss-linux-x64-musl": "1.32.0", "lightningcss-win32-arm64-msvc": "1.32.0", "lightningcss-win32-x64-msvc": "1.32.0" } }, "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ=="], "lightningcss": ["lightningcss@1.32.0", "", { "dependencies": { "detect-libc": "^2.0.3" }, "optionalDependencies": { "lightningcss-android-arm64": "1.32.0", "lightningcss-darwin-arm64": "1.32.0", "lightningcss-darwin-x64": "1.32.0", "lightningcss-freebsd-x64": "1.32.0", "lightningcss-linux-arm-gnueabihf": "1.32.0", "lightningcss-linux-arm64-gnu": "1.32.0", "lightningcss-linux-arm64-musl": "1.32.0", "lightningcss-linux-x64-gnu": "1.32.0", "lightningcss-linux-x64-musl": "1.32.0", "lightningcss-win32-arm64-msvc": "1.32.0", "lightningcss-win32-x64-msvc": "1.32.0" } }, "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ=="],
"lightningcss-android-arm64": ["lightningcss-android-arm64@1.32.0", "", { "os": "android", "cpu": "arm64" }, "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg=="], "lightningcss-android-arm64": ["lightningcss-android-arm64@1.32.0", "", { "os": "android", "cpu": "arm64" }, "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg=="],
@ -271,8 +237,6 @@
"log-symbols": ["log-symbols@7.0.1", "", { "dependencies": { "is-unicode-supported": "^2.0.0", "yoctocolors": "^2.1.1" } }, "sha512-ja1E3yCr9i/0hmBVaM0bfwDjnGy8I/s6PP4DFp+yP+a+mrHO4Rm7DtmnqROTUkHIkqffC84YY7AeqX6oFk0WFg=="], "log-symbols": ["log-symbols@7.0.1", "", { "dependencies": { "is-unicode-supported": "^2.0.0", "yoctocolors": "^2.1.1" } }, "sha512-ja1E3yCr9i/0hmBVaM0bfwDjnGy8I/s6PP4DFp+yP+a+mrHO4Rm7DtmnqROTUkHIkqffC84YY7AeqX6oFk0WFg=="],
"lz-string": ["lz-string@1.5.0", "", { "bin": { "lz-string": "bin/bin.js" } }, "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ=="],
"magic-string": ["magic-string@0.30.21", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="], "magic-string": ["magic-string@0.30.21", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="],
"micromatch": ["micromatch@4.0.8", "", { "dependencies": { "braces": "^3.0.3", "picomatch": "^2.3.1" } }, "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA=="], "micromatch": ["micromatch@4.0.8", "", { "dependencies": { "braces": "^3.0.3", "picomatch": "^2.3.1" } }, "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA=="],
@ -291,14 +255,10 @@
"postcss": ["postcss@8.5.8", "", { "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg=="], "postcss": ["postcss@8.5.8", "", { "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg=="],
"pretty-format": ["pretty-format@27.5.1", "", { "dependencies": { "ansi-regex": "^5.0.1", "ansi-styles": "^5.0.0", "react-is": "^17.0.1" } }, "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ=="],
"react": ["react@19.2.4", "", {}, "sha512-9nfp2hYpCwOjAN+8TZFGhtWEwgvWHXqESH8qT89AT/lWklpLON22Lc8pEtnpsZz7VmawabSU0gCjnj8aC0euHQ=="], "react": ["react@19.2.4", "", {}, "sha512-9nfp2hYpCwOjAN+8TZFGhtWEwgvWHXqESH8qT89AT/lWklpLON22Lc8pEtnpsZz7VmawabSU0gCjnj8aC0euHQ=="],
"react-dom": ["react-dom@19.2.4", "", { "dependencies": { "scheduler": "^0.27.0" }, "peerDependencies": { "react": "^19.2.4" } }, "sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ=="], "react-dom": ["react-dom@19.2.4", "", { "dependencies": { "scheduler": "^0.27.0" }, "peerDependencies": { "react": "^19.2.4" } }, "sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ=="],
"react-is": ["react-is@17.0.2", "", {}, "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="],
"restore-cursor": ["restore-cursor@5.1.0", "", { "dependencies": { "onetime": "^7.0.0", "signal-exit": "^4.1.0" } }, "sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA=="], "restore-cursor": ["restore-cursor@5.1.0", "", { "dependencies": { "onetime": "^7.0.0", "signal-exit": "^4.1.0" } }, "sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA=="],
"scheduler": ["scheduler@0.27.0", "", {}, "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q=="], "scheduler": ["scheduler@0.27.0", "", {}, "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q=="],
@ -323,10 +283,6 @@
"undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
"whatwg-mimetype": ["whatwg-mimetype@3.0.0", "", {}, "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q=="],
"ws": ["ws@8.19.0", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg=="],
"yoctocolors": ["yoctocolors@2.1.2", "", {}, "sha512-CzhO+pFNo8ajLM2d2IW/R93ipy99LWjtwblvC1RsoSUMZgyLbYFr221TnSNT7GjGdYui6P459mw9JH/g/zW2ug=="], "yoctocolors": ["yoctocolors@2.1.2", "", {}, "sha512-CzhO+pFNo8ajLM2d2IW/R93ipy99LWjtwblvC1RsoSUMZgyLbYFr221TnSNT7GjGdYui6P459mw9JH/g/zW2ug=="],
"@tailwindcss/oxide-wasm32-wasi/@emnapi/core": ["@emnapi/core@1.9.1", "", { "dependencies": { "@emnapi/wasi-threads": "1.2.0", "tslib": "^2.4.0" }, "bundled": true }, "sha512-mukuNALVsoix/w1BJwFzwXBN/dHeejQtuVzcDsfOEsdpCumXb/E9j8w11h5S54tT1xhifGfbbSm/ICrObRb3KA=="], "@tailwindcss/oxide-wasm32-wasi/@emnapi/core": ["@emnapi/core@1.9.1", "", { "dependencies": { "@emnapi/wasi-threads": "1.2.0", "tslib": "^2.4.0" }, "bundled": true }, "sha512-mukuNALVsoix/w1BJwFzwXBN/dHeejQtuVzcDsfOEsdpCumXb/E9j8w11h5S54tT1xhifGfbbSm/ICrObRb3KA=="],
@ -341,13 +297,13 @@
"@tailwindcss/oxide-wasm32-wasi/tslib": ["tslib@2.8.1", "", { "bundled": true }, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="], "@tailwindcss/oxide-wasm32-wasi/tslib": ["tslib@2.8.1", "", { "bundled": true }, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
"bun-types/@types/node": ["@types/node@22.13.5", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-+lTU0PxZXn0Dr1NBtC7Y8cR21AJr87dLLU953CWA6pMxxv/UDc7jYAY90upcrie1nRcD6XNG5HOYEDtgW5TxAg=="], "@types/ws/@types/node": ["@types/node@22.13.5", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-+lTU0PxZXn0Dr1NBtC7Y8cR21AJr87dLLU953CWA6pMxxv/UDc7jYAY90upcrie1nRcD6XNG5HOYEDtgW5TxAg=="],
"bun-types/@types/ws": ["@types/ws@8.5.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-bd/YFLW+URhBzMXurx7lWByOu+xzU9+kb3RboOteXYDfW+tr+JZa99OyNmPINEGB/ahzKrEuc8rcv4gnpJmxTw=="], "bun-types/@types/node": ["@types/node@22.13.5", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-+lTU0PxZXn0Dr1NBtC7Y8cR21AJr87dLLU953CWA6pMxxv/UDc7jYAY90upcrie1nRcD6XNG5HOYEDtgW5TxAg=="],
"lightningcss-wasm/napi-wasm": ["napi-wasm@1.1.3", "", { "bundled": true }, "sha512-h/4nMGsHjZDCYmQVNODIrYACVJ+I9KItbG+0si6W/jSjdA9JbWDoU4LLeMXVcEQGHjttI2tuXqDrbGF7qkUHHg=="], "lightningcss-wasm/napi-wasm": ["napi-wasm@1.1.3", "", { "bundled": true }, "sha512-h/4nMGsHjZDCYmQVNODIrYACVJ+I9KItbG+0si6W/jSjdA9JbWDoU4LLeMXVcEQGHjttI2tuXqDrbGF7qkUHHg=="],
"strip-ansi/ansi-regex": ["ansi-regex@6.2.2", "", {}, "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg=="], "@types/ws/@types/node/undici-types": ["undici-types@6.20.0", "", {}, "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="],
"bun-types/@types/node/undici-types": ["undici-types@6.20.0", "", {}, "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="], "bun-types/@types/node/undici-types": ["undici-types@6.20.0", "", {}, "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="],
} }

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,37 @@
import { describe, it, expect } from "bun:test";
import grabCacheNames from "../../../functions/cache/grab-cache-names";
describe("grabCacheNames", () => {
it("returns cache_name and cache_meta_name for a simple key", () => {
const { cache_name, cache_meta_name } = grabCacheNames({ key: "home" });
expect(cache_name).toBe("home.res.html");
expect(cache_meta_name).toBe("home.meta.json");
});
it("defaults paradigm to html", () => {
const { cache_name } = grabCacheNames({ key: "page" });
expect(cache_name).toEndWith(".res.html");
});
it("uses json paradigm when specified", () => {
const { cache_name } = grabCacheNames({ key: "api-data", paradigm: "json" });
expect(cache_name).toBe("api-data.res.json");
});
it("URL-encodes the key", () => {
const { cache_name, cache_meta_name } = grabCacheNames({
key: "/blog/hello world",
});
const encoded = encodeURIComponent("/blog/hello world");
expect(cache_name).toBe(`${encoded}.res.html`);
expect(cache_meta_name).toBe(`${encoded}.meta.json`);
});
it("handles keys with special characters", () => {
const key = "page?id=1&sort=asc";
const { cache_name } = grabCacheNames({ key });
expect(cache_name).toBe(`${encodeURIComponent(key)}.res.html`);
});
it("cache_meta_name always uses .meta.json regardless of paradigm", () => {
const { cache_meta_name } = grabCacheNames({
key: "test",
paradigm: "json",
});
expect(cache_meta_name).toBe("test.meta.json");
});
});

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,97 @@
import { describe, it, expect } from "bun:test";
import grabWebMetaHTML from "../../../functions/server/web-pages/grab-web-meta-html";
describe("grabWebMetaHTML", () => {
it("returns empty string for empty meta object", () => {
expect(grabWebMetaHTML({ meta: {} })).toBe("");
});
it("generates a title tag", () => {
const html = grabWebMetaHTML({ meta: { title: "My Page" } });
expect(html).toContain("<title>My Page</title>");
});
it("generates a description meta tag", () => {
const html = grabWebMetaHTML({ meta: { description: "A description" } });
expect(html).toContain('<meta name="description" content="A description"');
});
it("joins array keywords with comma", () => {
const html = grabWebMetaHTML({
meta: { keywords: ["react", "bun", "ssr"] },
});
expect(html).toContain('content="react, bun, ssr"');
});
it("uses string keywords directly", () => {
const html = grabWebMetaHTML({ meta: { keywords: "react, bun" } });
expect(html).toContain('content="react, bun"');
});
it("generates author meta tag", () => {
const html = grabWebMetaHTML({ meta: { author: "Alice" } });
expect(html).toContain('<meta name="author" content="Alice"');
});
it("generates robots meta tag", () => {
const html = grabWebMetaHTML({ meta: { robots: "noindex" } });
expect(html).toContain('<meta name="robots" content="noindex"');
});
it("generates canonical link tag", () => {
const html = grabWebMetaHTML({
meta: { canonical: "https://example.com/page" },
});
expect(html).toContain('<link rel="canonical" href="https://example.com/page"');
});
it("generates theme-color meta tag", () => {
const html = grabWebMetaHTML({ meta: { themeColor: "#ff0000" } });
expect(html).toContain('<meta name="theme-color" content="#ff0000"');
});
it("generates OG tags", () => {
const html = grabWebMetaHTML({
meta: {
og: {
title: "OG Title",
description: "OG Desc",
image: "https://example.com/img.png",
url: "https://example.com",
type: "website",
siteName: "Example",
locale: "en_US",
},
},
});
expect(html).toContain('<meta property="og:title" content="OG Title"');
expect(html).toContain('<meta property="og:description" content="OG Desc"');
expect(html).toContain('<meta property="og:image" content="https://example.com/img.png"');
expect(html).toContain('<meta property="og:url" content="https://example.com"');
expect(html).toContain('<meta property="og:type" content="website"');
expect(html).toContain('<meta property="og:site_name" content="Example"');
expect(html).toContain('<meta property="og:locale" content="en_US"');
});
it("generates Twitter card tags", () => {
const html = grabWebMetaHTML({
meta: {
twitter: {
card: "summary_large_image",
title: "Tweet Title",
description: "Tweet Desc",
image: "https://example.com/tw.png",
site: "@example",
creator: "@alice",
},
},
});
expect(html).toContain('<meta name="twitter:card" content="summary_large_image"');
expect(html).toContain('<meta name="twitter:title" content="Tweet Title"');
expect(html).toContain('<meta name="twitter:description" content="Tweet Desc"');
expect(html).toContain('<meta name="twitter:image" content="https://example.com/tw.png"');
expect(html).toContain('<meta name="twitter:site" content="@example"');
expect(html).toContain('<meta name="twitter:creator" content="@alice"');
});
it("skips undefined OG fields", () => {
const html = grabWebMetaHTML({ meta: { og: { title: "Only Title" } } });
expect(html).toContain("og:title");
expect(html).not.toContain("og:description");
expect(html).not.toContain("og:image");
});
it("does not emit tags for missing fields", () => {
const html = grabWebMetaHTML({ meta: { title: "Hello" } });
expect(html).not.toContain("description");
expect(html).not.toContain("og:");
expect(html).not.toContain("twitter:");
});
});

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,33 @@
import { describe, it, expect } from "bun:test";
import deserializeQuery from "../../utils/deserialize-query";
describe("deserializeQuery", () => {
it("passes through a plain object unchanged", () => {
const input = { foo: "bar" };
expect(deserializeQuery(input)).toEqual({ foo: "bar" });
});
it("parses a JSON string into an object", () => {
const input = JSON.stringify({ a: 1, b: "hello" });
expect(deserializeQuery(input)).toEqual({ a: 1, b: "hello" });
});
it("deep-parses string values that look like JSON objects", () => {
const nested = { filter: JSON.stringify({ status: "active" }) };
const result = deserializeQuery(nested);
expect(result.filter).toEqual({ status: "active" });
});
it("deep-parses string values that look like JSON arrays", () => {
const nested = { ids: JSON.stringify([1, 2, 3]) };
const result = deserializeQuery(nested);
expect(result.ids).toEqual([1, 2, 3]);
});
it("leaves plain string values alone", () => {
const input = { name: "alice", age: "30" };
expect(deserializeQuery(input)).toEqual({ name: "alice", age: "30" });
});
it("returns an empty object for an empty JSON string", () => {
expect(deserializeQuery("{}")).toEqual({});
});
it("returns an empty object for an invalid JSON string", () => {
// EJSON.parse returns undefined → Object(undefined) → {}
expect(deserializeQuery("not-json")).toEqual({});
});
});

1
dist/__tests__/utils/ejson.test.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

52
dist/__tests__/utils/ejson.test.js vendored Normal file
View File

@ -0,0 +1,52 @@
import { describe, it, expect } from "bun:test";
import EJSON from "../../utils/ejson";
describe("EJSON.parse", () => {
it("parses a valid JSON string", () => {
expect(EJSON.parse('{"a":1}')).toEqual({ a: 1 });
});
it("parses a JSON array string", () => {
expect(EJSON.parse('[1,2,3]')).toEqual([1, 2, 3]);
});
it("returns undefined for null input", () => {
expect(EJSON.parse(null)).toBeUndefined();
});
it("returns undefined for empty string", () => {
expect(EJSON.parse("")).toBeUndefined();
});
it("returns undefined for invalid JSON", () => {
expect(EJSON.parse("{bad json")).toBeUndefined();
});
it("returns the object directly when passed an object (typeof object)", () => {
const obj = { x: 1 };
expect(EJSON.parse(obj)).toBe(obj);
});
it("returns undefined for a number input", () => {
expect(EJSON.parse(42)).toBeUndefined();
});
it("applies a reviver function", () => {
const result = EJSON.parse('{"a":"2"}', (key, value) => key === "a" ? Number(value) : value);
expect(result).toEqual({ a: 2 });
});
});
describe("EJSON.stringify", () => {
it("stringifies an object", () => {
expect(EJSON.stringify({ a: 1 })).toBe('{"a":1}');
});
it("stringifies an array", () => {
expect(EJSON.stringify([1, 2, 3])).toBe("[1,2,3]");
});
it("applies spacing", () => {
expect(EJSON.stringify({ a: 1 }, null, 2)).toBe('{\n "a": 1\n}');
});
it("returns undefined for circular references", () => {
const obj = {};
obj.self = obj;
expect(EJSON.stringify(obj)).toBeUndefined();
});
it("stringifies null", () => {
expect(EJSON.stringify(null)).toBe("null");
});
it("stringifies a number", () => {
expect(EJSON.stringify(42)).toBe("42");
});
});

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,23 @@
import { describe, it, expect } from "bun:test";
import AppNames from "../../utils/grab-app-names";
describe("AppNames", () => {
it("has a defaultPort of 7000", () => {
expect(AppNames.defaultPort).toBe(7000);
});
it("has the correct defaultAssetPrefix", () => {
expect(AppNames.defaultAssetPrefix).toBe("_bunext/static");
});
it("has name Bunext", () => {
expect(AppNames.name).toBe("Bunext");
});
it("has a version string", () => {
expect(typeof AppNames.version).toBe("string");
expect(AppNames.version.length).toBeGreaterThan(0);
});
it("has defaultDistDir as .bunext", () => {
expect(AppNames.defaultDistDir).toBe(".bunext");
});
it("has RootPagesComponentName as __root", () => {
expect(AppNames.RootPagesComponentName).toBe("__root");
});
});

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,38 @@
import { describe, it, expect, beforeEach, afterEach } from "bun:test";
import grabAppPort from "../../utils/grab-app-port";
const originalEnv = process.env.PORT;
beforeEach(() => {
delete process.env.PORT;
global.CONFIG = {};
});
afterEach(() => {
if (originalEnv !== undefined) {
process.env.PORT = originalEnv;
}
else {
delete process.env.PORT;
}
});
describe("grabAppPort", () => {
it("returns the default port (7000) when no config or env set", () => {
expect(grabAppPort()).toBe(7000);
});
it("uses PORT env variable when set", () => {
process.env.PORT = "8080";
expect(grabAppPort()).toBe(8080);
});
it("uses config.port when PORT env is not set", () => {
global.CONFIG = { port: 3000 };
expect(grabAppPort()).toBe(3000);
});
it("PORT env takes precedence over config.port", () => {
process.env.PORT = "9000";
global.CONFIG = { port: 3000 };
expect(grabAppPort()).toBe(9000);
});
it("handles non-numeric PORT env gracefully via numberfy", () => {
process.env.PORT = "abc";
// numberfy strips non-numeric chars, "abc" → "" → 0
expect(grabAppPort()).toBe(0);
});
});

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,30 @@
import { describe, it, expect, beforeEach } from "bun:test";
import grabConstants from "../../utils/grab-constants";
beforeEach(() => {
global.CONFIG = {};
});
describe("grabConstants", () => {
it("has the correct ClientRootElementIDName", () => {
expect(grabConstants().ClientRootElementIDName).toBe("__bunext");
});
it("has the correct ClientWindowPagePropsName", () => {
expect(grabConstants().ClientWindowPagePropsName).toBe("__PAGE_PROPS__");
});
it("has the correct ClientRootComponentWindowName", () => {
expect(grabConstants().ClientRootComponentWindowName).toBe("BUNEXT_ROOT");
});
it("calculates MBInBytes as 1024 * 1024", () => {
expect(grabConstants().MBInBytes).toBe(1024 * 1024);
});
it("ServerDefaultRequestBodyLimitBytes is 10 MB", () => {
expect(grabConstants().ServerDefaultRequestBodyLimitBytes).toBe(10 * 1024 * 1024);
});
it("MaxBundlerRebuilds is 5", () => {
expect(grabConstants().MaxBundlerRebuilds).toBe(5);
});
it("returns the current global.CONFIG", () => {
const cfg = { port: 9000 };
global.CONFIG = cfg;
expect(grabConstants().config).toBe(cfg);
});
});

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,55 @@
import { describe, it, expect } from "bun:test";
import path from "path";
import grabDirNames from "../../utils/grab-dir-names";
describe("grabDirNames", () => {
it("derives all paths from process.cwd()", () => {
const cwd = process.cwd();
const dirs = grabDirNames();
expect(dirs.ROOT_DIR).toBe(cwd);
expect(dirs.SRC_DIR).toBe(path.join(cwd, "src"));
expect(dirs.PAGES_DIR).toBe(path.join(cwd, "src", "pages"));
expect(dirs.API_DIR).toBe(path.join(cwd, "src", "pages", "api"));
expect(dirs.PUBLIC_DIR).toBe(path.join(cwd, "public"));
});
it("nests HYDRATION_DST_DIR under public/__bunext/pages", () => {
const dirs = grabDirNames();
expect(dirs.HYDRATION_DST_DIR).toBe(path.join(dirs.PUBLIC_DIR, "__bunext", "pages"));
});
it("nests BUNEXT_CACHE_DIR under public/__bunext/cache", () => {
const dirs = grabDirNames();
expect(dirs.BUNEXT_CACHE_DIR).toBe(path.join(dirs.PUBLIC_DIR, "__bunext", "cache"));
});
it("places map JSON file inside HYDRATION_DST_DIR", () => {
const dirs = grabDirNames();
expect(dirs.HYDRATION_DST_DIR_MAP_JSON_FILE).toBe(path.join(dirs.HYDRATION_DST_DIR, "map.json"));
});
it("places CONFIG_FILE at root", () => {
const dirs = grabDirNames();
expect(dirs.CONFIG_FILE).toBe(path.join(dirs.ROOT_DIR, "bunext.config.ts"));
});
it("places BUNX_TMP_DIR inside .bunext", () => {
const dirs = grabDirNames();
expect(dirs.BUNX_TMP_DIR).toContain(".bunext");
expect(dirs.BUNX_TMP_DIR).toEndWith(".tmp");
});
it("places BUNX_HYDRATION_SRC_DIR under client/hydration-src", () => {
const dirs = grabDirNames();
expect(dirs.BUNX_HYDRATION_SRC_DIR).toContain(path.join("client", "hydration-src"));
});
it("sets 404 file name to not-found", () => {
const dirs = grabDirNames();
expect(dirs.BUNX_ROOT_404_FILE_NAME).toBe("not-found");
});
it("sets 500 file name to server-error", () => {
const dirs = grabDirNames();
expect(dirs.BUNX_ROOT_500_FILE_NAME).toBe("server-error");
});
it("preset 404 component path ends with not-found.tsx", () => {
const dirs = grabDirNames();
expect(dirs.BUNX_ROOT_404_PRESET_COMPONENT).toEndWith("not-found.tsx");
});
it("preset 500 component path ends with server-error.tsx", () => {
const dirs = grabDirNames();
expect(dirs.BUNX_ROOT_500_PRESET_COMPONENT).toEndWith("server-error.tsx");
});
});

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,32 @@
import { describe, it, expect, beforeEach, afterEach } from "bun:test";
import grabOrigin from "../../utils/grab-origin";
const originalPort = process.env.PORT;
beforeEach(() => {
delete process.env.PORT;
global.CONFIG = {};
});
afterEach(() => {
if (originalPort !== undefined) {
process.env.PORT = originalPort;
}
else {
delete process.env.PORT;
}
});
describe("grabOrigin", () => {
it("returns config.origin when set", () => {
global.CONFIG = { origin: "https://example.com" };
expect(grabOrigin()).toBe("https://example.com");
});
it("falls back to http://localhost:<port> using default port", () => {
expect(grabOrigin()).toBe("http://localhost:7000");
});
it("falls back using PORT env variable", () => {
process.env.PORT = "8080";
expect(grabOrigin()).toBe("http://localhost:8080");
});
it("falls back using config.port", () => {
global.CONFIG = { port: 3700 };
expect(grabOrigin()).toBe("http://localhost:3700");
});
});

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,46 @@
import { describe, it, expect } from "bun:test";
import grabPageName from "../../utils/grab-page-name";
describe("grabPageName", () => {
it("returns the page name for a simple page path", () => {
expect(grabPageName({ path: "/home/user/project/src/pages/about.tsx" }))
.toBe("about");
});
it("returns 'index' for a root index file (no -index stripping at root)", () => {
// -index suffix is only stripped when joined: e.g. "blog-index" → "blog"
// A standalone "index" filename has no leading dash so stays as-is
expect(grabPageName({ path: "/home/user/project/src/pages/index.tsx" }))
.toBe("index");
});
it("handles nested page paths", () => {
expect(grabPageName({ path: "/home/user/project/src/pages/blog/post.tsx" })).toBe("blog-post");
});
it("strips -index suffix from nested index files", () => {
expect(grabPageName({ path: "/home/user/project/src/pages/blog/index.tsx" })).toBe("blog");
});
it("converts dynamic segments [slug] by replacing brackets", () => {
const result = grabPageName({
path: "/home/user/project/src/pages/blog/[slug].tsx",
});
// [ → - and ] is dropped (not a-z or -), so [slug] → -slug
expect(result).toBe("blog--slug");
});
it("converts spread [...params] segments", () => {
const result = grabPageName({
path: "/home/user/project/src/pages/[...params].tsx",
});
// "[...params]" → remove ext → "[...params]"
// [ → "-" → "-...params]"
// "..." → "-" → "--params]"
// strip non [a-z-] → "--params"
expect(result).toBe("--params");
});
it("strips uppercase letters (only a-z and - are kept)", () => {
// [^a-z\-] strips uppercase — 'A' is removed, 'bout' remains
expect(grabPageName({ path: "/home/user/project/src/pages/About.tsx" })).toBe("bout");
});
it("handles deeply nested paths", () => {
expect(grabPageName({
path: "/home/user/project/src/pages/admin/users/list.tsx",
})).toBe("admin-users-list");
});
});

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,32 @@
import { describe, it, expect, beforeEach, afterEach } from "bun:test";
import isDevelopment from "../../utils/is-development";
const originalEnv = process.env.NODE_ENV;
beforeEach(() => {
// Reset global config before each test
global.CONFIG = {};
});
afterEach(() => {
process.env.NODE_ENV = originalEnv;
});
describe("isDevelopment", () => {
it("returns false when NODE_ENV is production", () => {
process.env.NODE_ENV = "production";
global.CONFIG = { development: true };
expect(isDevelopment()).toBe(false);
});
it("returns true when config.development is true and NODE_ENV is not production", () => {
process.env.NODE_ENV = "development";
global.CONFIG = { development: true };
expect(isDevelopment()).toBe(true);
});
it("returns false when config.development is false", () => {
process.env.NODE_ENV = "development";
global.CONFIG = { development: false };
expect(isDevelopment()).toBe(false);
});
it("returns false when config.development is undefined", () => {
process.env.NODE_ENV = "development";
global.CONFIG = {};
expect(isDevelopment()).toBe(false);
});
});

View File

@ -0,0 +1 @@
export {};

43
dist/__tests__/utils/numberfy.test.js vendored Normal file
View File

@ -0,0 +1,43 @@
import { describe, it, expect } from "bun:test";
import numberfy, { _n } from "../../utils/numberfy";
describe("numberfy", () => {
it("converts a plain integer string", () => {
expect(numberfy("42")).toBe(42);
});
it("converts a float string preserving decimals", () => {
expect(numberfy("3.14")).toBe(3.14);
});
it("strips non-numeric characters", () => {
expect(numberfy("$1,234.56")).toBe(1234.56);
});
it("returns 0 for an empty string", () => {
expect(numberfy("")).toBe(0);
});
it("returns 0 for undefined", () => {
expect(numberfy(undefined)).toBe(0);
});
it("returns 0 for null", () => {
expect(numberfy(null)).toBe(0);
});
it("passes through a number directly", () => {
expect(numberfy(7)).toBe(7);
});
it("rounds when no decimals specified and no decimal in input", () => {
expect(numberfy("5.0")).toBe(5);
});
it("respects decimals=0 by rounding", () => {
expect(numberfy("3.7", 0)).toBe(4);
});
it("respects explicit decimals parameter", () => {
expect(numberfy("3.14159", 2)).toBe(3.14);
});
it("preserves existing decimal places when no decimals arg given", () => {
expect(numberfy("1.500")).toBe(1.5);
});
it("strips a trailing dot", () => {
expect(numberfy("5.")).toBe(5);
});
it("_n alias works identically", () => {
expect(_n("10")).toBe(10);
});
});

View File

@ -3,7 +3,6 @@ import { program } from "commander";
import start from "./start"; import start from "./start";
import dev from "./dev"; import dev from "./dev";
import build from "./build"; import build from "./build";
import { log } from "../utils/log";
/** /**
* # Describe Program * # Describe Program
*/ */
@ -21,9 +20,7 @@ program.addCommand(build());
* # Handle Unavailable Commands * # Handle Unavailable Commands
*/ */
program.on("command:*", () => { program.on("command:*", () => {
log.error("Invalid command: %s\nSee --help for a list of available commands." + console.error("Invalid command: %s\nSee --help for a list of available commands.", program.args.join(" "));
" " +
program.args.join(" "));
process.exit(1); process.exit(1);
}); });
/** /**

View File

@ -1,4 +1,4 @@
import { existsSync, statSync, writeFileSync } from "fs"; import { writeFileSync } from "fs";
import * as esbuild from "esbuild"; import * as esbuild from "esbuild";
import grabAllPages from "../../utils/grab-all-pages"; import grabAllPages from "../../utils/grab-all-pages";
import grabDirNames from "../../utils/grab-dir-names"; import grabDirNames from "../../utils/grab-dir-names";
@ -8,10 +8,7 @@ import { log } from "../../utils/log";
import tailwindEsbuildPlugin from "../server/web-pages/tailwind-esbuild-plugin"; import tailwindEsbuildPlugin from "../server/web-pages/tailwind-esbuild-plugin";
import grabClientHydrationScript from "./grab-client-hydration-script"; import grabClientHydrationScript from "./grab-client-hydration-script";
import grabArtifactsFromBundledResults from "./grab-artifacts-from-bundled-result"; import grabArtifactsFromBundledResults from "./grab-artifacts-from-bundled-result";
import path from "path"; const { HYDRATION_DST_DIR, HYDRATION_DST_DIR_MAP_JSON_FILE } = grabDirNames();
const { HYDRATION_DST_DIR, HYDRATION_DST_DIR_MAP_JSON_FILE, ROOT_DIR } = grabDirNames();
let build_starts = 0;
const MAX_BUILD_STARTS = 10;
export default async function allPagesBundler(params) { export default async function allPagesBundler(params) {
const pages = grabAllPages({ exclude_api: true }); const pages = grabAllPages({ exclude_api: true });
const virtualEntries = {}; const virtualEntries = {};
@ -42,25 +39,11 @@ export default async function allPagesBundler(params) {
setup(build) { setup(build) {
let buildStart = 0; let buildStart = 0;
build.onStart(() => { build.onStart(() => {
build_starts++;
buildStart = performance.now(); buildStart = performance.now();
if (build_starts == MAX_BUILD_STARTS) {
const error_msg = `Build Failed. Please check all your components and imports.`;
log.error(error_msg);
// process.exit(1);
}
}); });
build.onEnd((result) => { build.onEnd((result) => {
if (result.errors.length > 0) { if (result.errors.length > 0)
for (const error of result.errors) {
const loc = error.location;
const location = loc
? ` ${loc.file}:${loc.line}:${loc.column}`
: "";
log.error(`[Build]${location} ${error.text}`);
}
return; return;
}
const artifacts = grabArtifactsFromBundledResults({ const artifacts = grabArtifactsFromBundledResults({
pages, pages,
result, result,
@ -77,7 +60,6 @@ export default async function allPagesBundler(params) {
if (params?.exit_after_first_build) { if (params?.exit_after_first_build) {
process.exit(); process.exit();
} }
build_starts = 0;
}); });
}, },
}; };

View File

@ -5,7 +5,6 @@ import path from "path";
import grabConfig from "./grab-config"; import grabConfig from "./grab-config";
export default async function () { export default async function () {
const dirNames = grabDirNames(); const dirNames = grabDirNames();
const is_dev = !Boolean(process.env.NODE_ENV == "production");
execSync(`rm -rf ${dirNames.BUNEXT_CACHE_DIR}`); execSync(`rm -rf ${dirNames.BUNEXT_CACHE_DIR}`);
execSync(`rm -rf ${dirNames.BUNX_CWD_MODULE_CACHE_DIR}`); execSync(`rm -rf ${dirNames.BUNX_CWD_MODULE_CACHE_DIR}`);
try { try {
@ -32,6 +31,6 @@ export default async function () {
const config = (await grabConfig()) || {}; const config = (await grabConfig()) || {};
global.CONFIG = { global.CONFIG = {
...config, ...config,
development: is_dev, development: true,
}; };
} }

View File

@ -2,7 +2,9 @@ import handleWebPages from "./web-pages/handle-web-pages";
import handleRoutes from "./handle-routes"; import handleRoutes from "./handle-routes";
import isDevelopment from "../../utils/is-development"; import isDevelopment from "../../utils/is-development";
import grabConstants from "../../utils/grab-constants"; import grabConstants from "../../utils/grab-constants";
import { AppData } from "../../data/app-data";
import handleHmr from "./handle-hmr"; import handleHmr from "./handle-hmr";
import handleHmrUpdate from "./handle-hmr-update";
import handlePublic from "./handle-public"; import handlePublic from "./handle-public";
import handleFiles from "./handle-files"; import handleFiles from "./handle-files";
export default async function bunextRequestHandler({ req: initial_req, }) { export default async function bunextRequestHandler({ req: initial_req, }) {
@ -24,7 +26,10 @@ export default async function bunextRequestHandler({ req: initial_req, }) {
req = middleware_res; req = middleware_res;
} }
} }
if (url.pathname === "/__hmr" && is_dev) { if (url.pathname == `/${AppData["ClientHMRPath"]}`) {
response = await handleHmrUpdate({ req });
}
else if (url.pathname === "/__hmr" && is_dev) {
response = await handleHmr({ req }); response = await handleHmr({ req });
} }
else if (url.pathname.startsWith("/api/")) { else if (url.pathname.startsWith("/api/")) {

View File

@ -1 +1 @@
export default function watcher(): Promise<void>; export default function watcher(): void;

View File

@ -1,26 +1,16 @@
import { watch, existsSync, statSync } from "fs"; import { watch, existsSync } from "fs";
import path from "path"; import path from "path";
import grabDirNames from "../../utils/grab-dir-names"; import grabDirNames from "../../utils/grab-dir-names";
import rebuildBundler from "./rebuild-bundler"; import rebuildBundler from "./rebuild-bundler";
import { log } from "../../utils/log"; import { log } from "../../utils/log";
const { ROOT_DIR } = grabDirNames(); const { ROOT_DIR } = grabDirNames();
export default async function watcher() { export default function watcher() {
await Bun.sleep(1000);
const pages_src_watcher = watch(ROOT_DIR, { const pages_src_watcher = watch(ROOT_DIR, {
recursive: true, recursive: true,
persistent: true, persistent: true,
}, async (event, filename) => { }, async (event, filename) => {
if (!filename) if (!filename)
return; return;
const full_file_path = path.join(ROOT_DIR, filename);
if (full_file_path.match(/\/styles$/)) {
global.RECOMPILING = true;
await Bun.sleep(1000);
await fullRebuild({
msg: `Detected new \`styles\` directory. Rebuilding ...`,
});
return;
}
const excluded_match = /node_modules\/|^public\/|^\.bunext\/|^\.git\/|^dist\/|bun\.lockb$/; const excluded_match = /node_modules\/|^public\/|^\.bunext\/|^\.git\/|^dist\/|bun\.lockb$/;
if (filename.match(excluded_match)) if (filename.match(excluded_match))
return; return;
@ -30,9 +20,9 @@ export default async function watcher() {
}); });
return; return;
} }
const target_files_match = /\.(tsx?|jsx?|css)$/;
if (event !== "rename") { if (event !== "rename") {
if (filename.match(target_files_match) && global.BUNDLER_CTX) { if (filename.match(/\.(tsx?|jsx?|css)$/) &&
global.BUNDLER_CTX) {
if (global.RECOMPILING) if (global.RECOMPILING)
return; return;
global.RECOMPILING = true; global.RECOMPILING = true;
@ -40,20 +30,16 @@ export default async function watcher() {
} }
return; return;
} }
const is_file_of_interest = Boolean(filename.match(target_files_match)); if (!filename.match(/^src\/pages\//))
if (!is_file_of_interest) {
return;
}
if (!filename.match(/^src\/pages\/|\.css$/))
return; return;
if (filename.match(/\/(--|\()/)) if (filename.match(/\/(--|\()/))
return; return;
if (global.RECOMPILING) if (global.RECOMPILING)
return; return;
const action = existsSync(full_file_path) ? "created" : "deleted"; const fullPath = path.join(ROOT_DIR, filename);
const type = filename.match(/\.css$/) ? "Sylesheet" : "Page"; const action = existsSync(fullPath) ? "created" : "deleted";
await fullRebuild({ await fullRebuild({
msg: `${type} ${action}: ${filename}. Rebuilding ...`, msg: `Page ${action}: ${filename}. Rebuilding ...`,
}); });
}); });
global.PAGES_SRC_WATCHER = pages_src_watcher; global.PAGES_SRC_WATCHER = pages_src_watcher;

View File

@ -1,5 +1,5 @@
import { jsx as _jsx } from "react/jsx-runtime"; import { jsx as _jsx } from "react/jsx-runtime";
import { renderToString } from "react-dom/server"; import path from "path";
import grabContants from "../../../utils/grab-constants"; import grabContants from "../../../utils/grab-constants";
import EJSON from "../../../utils/ejson"; import EJSON from "../../../utils/ejson";
import isDevelopment from "../../../utils/is-development"; import isDevelopment from "../../../utils/is-development";
@ -9,6 +9,7 @@ import { log } from "../../../utils/log";
import { AppData } from "../../../data/app-data"; import { AppData } from "../../../data/app-data";
export default async function genWebHTML({ component, pageProps, bundledMap, head: Head, module, meta, routeParams, debug, }) { export default async function genWebHTML({ component, pageProps, bundledMap, head: Head, module, meta, routeParams, debug, }) {
const { ClientRootElementIDName, ClientWindowPagePropsName } = grabContants(); const { ClientRootElementIDName, ClientWindowPagePropsName } = grabContants();
const { renderToString } = await import(path.join(process.cwd(), "node_modules", "react-dom", "server"));
if (debug) { if (debug) {
log.info("component", component); log.info("component", component);
} }

View File

@ -30,13 +30,13 @@ export default async function grabPageComponent({ req, file_path: passed_file_pa
} }
if (!file_path) { if (!file_path) {
const errMsg = `No File Path (\`file_path\`) or Request Object (\`req\`) provided not found`; const errMsg = `No File Path (\`file_path\`) or Request Object (\`req\`) provided not found`;
// log.error(errMsg); // console.error(errMsg);
throw new Error(errMsg); throw new Error(errMsg);
} }
const bundledMap = global.BUNDLER_CTX_MAP?.find((m) => m.local_path == file_path); const bundledMap = global.BUNDLER_CTX_MAP?.find((m) => m.local_path == file_path);
if (!bundledMap?.path) { if (!bundledMap?.path) {
const errMsg = `No Bundled File Path for this request path!`; const errMsg = `No Bundled File Path for this request path!`;
log.error(errMsg); console.error(errMsg);
throw new Error(errMsg); throw new Error(errMsg);
} }
if (debug) { if (debug) {
@ -127,7 +127,7 @@ export default async function grabPageComponent({ req, file_path: passed_file_pa
}; };
} }
catch (error) { catch (error) {
log.error(`Error Grabbing Page Component: ${error.message}`); console.error(`Error Grabbing Page Component: ${error.message}`);
return await grabPageErrorComponent({ return await grabPageErrorComponent({
error, error,
routeParams, routeParams,

View File

@ -21,11 +21,6 @@ export default async function grabPageErrorComponent({ error, routeParams, is404
routeParams, routeParams,
module, module,
bundledMap, bundledMap,
serverRes: {
responseOptions: {
status: is404 ? 404 : 500
}
}
}; };
} }
catch { catch {
@ -42,11 +37,6 @@ export default async function grabPageErrorComponent({ error, routeParams, is404
routeParams, routeParams,
module: { default: DefaultNotFound }, module: { default: DefaultNotFound },
bundledMap: {}, bundledMap: {},
serverRes: {
responseOptions: {
status: is404 ? 404 : 500
}
}
}; };
} }
} }

View File

@ -27,16 +27,13 @@ export default async function (params) {
script += ` try {\n`; script += ` try {\n`;
script += ` document.getElementById("__bunext_error_overlay")?.remove();\n`; script += ` document.getElementById("__bunext_error_overlay")?.remove();\n`;
script += ` const data = JSON.parse(event.data);\n`; script += ` const data = JSON.parse(event.data);\n`;
// script += ` console.log("data", data);\n`;
script += ` const oldCSSLink = document.querySelector('link[rel="stylesheet"]');\n`;
script += ` if (data.target_map.css_path) {\n`; script += ` if (data.target_map.css_path) {\n`;
script += ` const oldLink = document.querySelector('link[rel="stylesheet"]');\n`;
script += ` const newLink = document.createElement("link");\n`; script += ` const newLink = document.createElement("link");\n`;
script += ` newLink.rel = "stylesheet";\n`; script += ` newLink.rel = "stylesheet";\n`;
script += ` newLink.href = \`/\${data.target_map.css_path}?t=\${Date.now()}\`;\n`; script += ` newLink.href = \`/\${data.target_map.css_path}?t=\${Date.now()}\`;\n`;
script += ` newLink.onload = () => oldCSSLink?.remove();\n`; script += ` newLink.onload = () => oldLink?.remove();\n`;
script += ` document.head.appendChild(newLink);\n`; script += ` document.head.appendChild(newLink);\n`;
script += ` } else if (oldCSSLink) {\n`;
script += ` oldCSSLink.remove();\n`;
script += ` }\n`; script += ` }\n`;
script += ` const newScriptPath = \`/\${data.target_map.path}?t=\${Date.now()}\`;\n\n`; script += ` const newScriptPath = \`/\${data.target_map.path}?t=\${Date.now()}\`;\n\n`;
script += ` const oldScript = document.getElementById("${AppData["BunextClientHydrationScriptID"]}");\n`; script += ` const oldScript = document.getElementById("${AppData["BunextClientHydrationScriptID"]}");\n`;

View File

@ -1,5 +1,4 @@
import isDevelopment from "../../../utils/is-development"; import isDevelopment from "../../../utils/is-development";
import { log } from "../../../utils/log";
import getCache from "../../cache/get-cache"; import getCache from "../../cache/get-cache";
import generateWebPageResponseFromComponentReturn from "./generate-web-page-response-from-component-return"; import generateWebPageResponseFromComponentReturn from "./generate-web-page-response-from-component-return";
import grabPageComponent from "./grab-page-component"; import grabPageComponent from "./grab-page-component";
@ -28,7 +27,7 @@ export default async function handleWebPages({ req, }) {
}); });
} }
catch (error) { catch (error) {
log.error(`Error Handling Web Page: ${error.message}`); console.error(`Error Handling Web Page: ${error.message}`);
const componentRes = await grabPageErrorComponent({ const componentRes = await grabPageErrorComponent({
error, error,
}); });

View File

@ -2,46 +2,17 @@ import * as esbuild from "esbuild";
import postcss from "postcss"; import postcss from "postcss";
import tailwindcss from "@tailwindcss/postcss"; import tailwindcss from "@tailwindcss/postcss";
import { readFile } from "fs/promises"; import { readFile } from "fs/promises";
import path from "path";
import { existsSync } from "fs";
import grabDirNames from "../../../utils/grab-dir-names";
import { log } from "../../../utils/log";
const { ROOT_DIR } = grabDirNames();
let error_logged = false;
const tailwindEsbuildPlugin = { const tailwindEsbuildPlugin = {
name: "tailwindcss", name: "tailwindcss",
setup(build) { setup(build) {
build.onLoad({ filter: /\.css$/ }, async (args) => { build.onLoad({ filter: /\.css$/ }, async (args) => {
try { const source = await readFile(args.path, "utf-8");
const source = await readFile(args.path, "utf-8"); const result = await postcss([tailwindcss()]).process(source, {
const result = await postcss([tailwindcss()]).process(source, { from: args.path,
from: args.path, });
});
error_logged = false;
return { contents: result.css, loader: "css" };
}
catch (error) {
return { errors: [{ text: error.message }] };
}
});
build.onResolve({ filter: /\.css$/ }, async (args) => {
const css_path = path.resolve(args.resolveDir, args.path.replace(/\@\//g, ROOT_DIR + "/"));
const does_path_exist = existsSync(css_path);
if (!does_path_exist && !error_logged) {
const err_msg = `CSS Error: ${css_path} file does not exist.`;
log.error(err_msg);
error_logged = true;
// return {
// errors: [
// {
// text: err_msg,
// },
// ],
// pluginName: "tailwindcss",
// };
}
return { return {
path: css_path, contents: result.css,
loader: "css",
}; };
}); });
}, },

View File

@ -1 +0,0 @@
export default function importReactDomServer(): Promise<any>;

View File

@ -1,14 +0,0 @@
import path from "path";
import reactDomServer from "react-dom/server";
export default async function importReactDomServer() {
try {
const reactDomServerDynamicImport = await import(path.join(process.cwd(), "node_modules", "react-dom", "server"));
if (!reactDomServerDynamicImport.renderToString) {
return reactDomServer;
}
return reactDomServerDynamicImport;
}
catch (error) {
return reactDomServer;
}
}

View File

@ -2,21 +2,8 @@
"name": "@moduletrace/bunext", "name": "@moduletrace/bunext",
"module": "index.ts", "module": "index.ts",
"type": "module", "type": "module",
"version": "1.0.7", "version": "1.0.6",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"default": "./dist/index.js"
},
"./types": {
"types": "./dist/types/index.d.ts",
"import": "./dist/types/index.js",
"default": "./dist/types/index.js"
}
},
"bin": { "bin": {
"bunext": "dist/commands/index.js" "bunext": "dist/commands/index.js"
}, },
@ -27,21 +14,17 @@
], ],
"scripts": { "scripts": {
"dev": "tsc --watch", "dev": "tsc --watch",
"git:push": "tsc --noEmit && tsc && git add . && git commit -m 'Update bundler. Handle non-existent file error.' && git push", "publish": "tsc --noEmit && tsc && git add . && git commit -m 'Update watcher function. Add tests' && git push",
"compile": "bun build ./src/commands/index.ts --compile --outfile bin/bunext", "compile": "bun build ./src/commands/index.ts --compile --outfile bin/bunext",
"build": "tsc", "build": "tsc"
"test": "bun test --max-concurrency=1"
}, },
"devDependencies": { "devDependencies": {
"@testing-library/dom": "^10.4.1",
"@testing-library/react": "^16.3.2",
"@types/bun": "latest", "@types/bun": "latest",
"@types/lodash": "^4.17.24", "@types/lodash": "^4.17.24",
"@types/micromatch": "^4.0.10", "@types/micromatch": "^4.0.10",
"@types/node": "^24.10.0", "@types/node": "^24.10.0",
"@types/react": "^19.2.2", "@types/react": "^19.2.2",
"@types/react-dom": "^19.2.2", "@types/react-dom": "^19.2.2",
"happy-dom": "^20.8.4",
"react": "^19.2.4", "react": "^19.2.4",
"react-dom": "^19.2.4" "react-dom": "^19.2.4"
}, },
@ -54,7 +37,6 @@
"registry": "https://npm.pkg.github.com" "registry": "https://npm.pkg.github.com"
}, },
"dependencies": { "dependencies": {
"@moduletrace/bunext": "github:moduletrace/bunext",
"@tailwindcss/postcss": "^4.2.2", "@tailwindcss/postcss": "^4.2.2",
"bun-plugin-tailwind": "^0.1.2", "bun-plugin-tailwind": "^0.1.2",
"chalk": "^5.6.2", "chalk": "^5.6.2",

View File

@ -1,21 +0,0 @@
#!/bin/bash
set -e
if [ -z "$1" ]; then
msg="Updates"
else
msg="$1"
fi
tsc --noEmit
rm -rf dist
tsc
git add .
git commit -m "$msg"
git push
bun publish

View File

@ -1,63 +0,0 @@
import { describe, expect, test, beforeAll, afterAll } from "bun:test";
import startServer from "../../../src/functions/server/start-server";
import bunextInit from "../../../src/functions/bunext-init";
import path from "path";
import fs from "fs";
let originalCwd = process.cwd();
describe("E2E Integration", () => {
let server: any;
beforeAll(async () => {
// Change to the fixture directory to simulate actual user repo
const fixtureDir = path.resolve(__dirname, "../__fixtures__/app");
process.chdir(fixtureDir);
// Mock grabAppPort to assign dynamically to avoid port conflicts
global.CONFIG = { development: true };
});
afterAll(async () => {
if (server) {
server.stop(true);
}
process.chdir(originalCwd);
// Ensure to remove the dummy generated .bunext folder
const dotBunext = path.resolve(__dirname, "../__fixtures__/app/.bunext");
if (fs.existsSync(dotBunext)) {
fs.rmSync(dotBunext, { recursive: true, force: true });
}
const pubBunext = path.resolve(__dirname, "../__fixtures__/app/public/__bunext");
if (fs.existsSync(pubBunext)) {
fs.rmSync(pubBunext, { recursive: true, force: true });
}
});
test("boots up the server and correctly routes to index.tsx page", async () => {
// Mock to randomize port
// Note: Bun test runs modules in isolation but startServer imports grab-app-port
// If we can't easily mock we can set PORT env
process.env.PORT = "0"; // Let Bun.serve pick port
await bunextInit();
server = await startServer();
expect(server).toBeDefined();
// Fetch the index page
const response = await fetch(`http://localhost:${server.port}/`);
expect(response.status).toBe(200);
const html = await response.text();
expect(html).toContain("Hello E2E");
});
test("returns 404 for unknown route", async () => {
const response = await fetch(`http://localhost:${server.port}/unknown-foo-bar123`);
expect(response.status).toBe(404);
const text = await response.text();
// Assume default 404 preset component is rendered
expect(text).toContain("404");
});
});

View File

@ -1,86 +0,0 @@
import { describe, expect, test, mock, afterAll } from "bun:test";
import bunextRequestHandler from "../../../../src/functions/server/bunext-req-handler";
mock.module("../../../../src/utils/is-development", () => ({
default: () => true
}));
mock.module("../../../../src/utils/grab-constants", () => ({
default: () => ({
config: {
middleware: async ({ url }: any) => {
if (url.pathname === "/blocked") {
return new Response("Blocked by middleware", { status: 403 });
}
return undefined;
}
}
})
}));
mock.module("../../../../src/functions/server/handle-routes", () => ({
default: async () => new Response("api-routes")
}));
mock.module("../../../../src/functions/server/handle-public", () => ({
default: async () => new Response("public")
}));
mock.module("../../../../src/functions/server/handle-files", () => ({
default: async () => new Response("files")
}));
mock.module("../../../../src/functions/server/web-pages/handle-web-pages", () => ({
default: async () => new Response("web-pages")
}));
/**
* Tests for the `bunext-req-handler` module.
* Ensures that requests are correctly routed to the proper subsystem.
*/
describe("bunext-req-handler", () => {
afterAll(() => {
mock.restore();
});
test("middleware is caught", async () => {
const req = new Request("http://localhost/blocked");
const res = await bunextRequestHandler({ req });
expect(res.status).toBe(403);
expect(await res.text()).toBe("Blocked by middleware");
});
test("routes /__hmr to handleHmr in dev", async () => {
global.ROUTER = { match: () => ({}) } as any;
global.HMR_CONTROLLERS = [];
const req = new Request("http://localhost/__hmr", {
headers: { referer: "http://localhost/" }
});
const res = await bunextRequestHandler({ req });
expect(res.headers.get("Content-Type")).toBe("text/event-stream");
});
test("routes /api/ to handleRoutes", async () => {
const req = new Request("http://localhost/api/users");
const res = await bunextRequestHandler({ req });
expect(await res.text()).toBe("api-routes");
});
test("routes /public/ to handlePublic", async () => {
const req = new Request("http://localhost/public/image.png");
const res = await bunextRequestHandler({ req });
expect(await res.text()).toBe("public");
});
test("routes files like .js to handleFiles", async () => {
const req = new Request("http://localhost/script.js");
const res = await bunextRequestHandler({ req });
expect(await res.text()).toBe("files");
});
test("routes anything else to handleWebPages", async () => {
const req = new Request("http://localhost/about");
const res = await bunextRequestHandler({ req });
expect(await res.text()).toBe("web-pages");
});
});

View File

@ -1,42 +0,0 @@
import { describe, expect, test, mock, beforeEach, afterEach } from "bun:test";
import handleHmr from "../../../../src/functions/server/handle-hmr";
describe("handle-hmr", () => {
beforeEach(() => {
global.ROUTER = {
match: (path: string) => {
if (path === "/test") return { filePath: "/test-file" };
return null;
}
} as any;
global.HMR_CONTROLLERS = [];
global.BUNDLER_CTX_MAP = [
{ local_path: "/test-file" } as any
];
});
afterEach(() => {
global.ROUTER = undefined as any;
global.HMR_CONTROLLERS = [];
global.BUNDLER_CTX_MAP = undefined as any;
});
test("sets up SSE stream and pushes to HMR_CONTROLLERS", async () => {
const req = new Request("http://localhost/hmr", {
headers: {
"referer": "http://localhost/test"
}
});
const res = await handleHmr({ req });
expect(res.status).toBe(200);
expect(res.headers.get("Content-Type")).toBe("text/event-stream");
expect(res.headers.get("Connection")).toBe("keep-alive");
expect(global.HMR_CONTROLLERS.length).toBe(1);
const controller = global.HMR_CONTROLLERS[0];
expect(controller.page_url).toBe("http://localhost/test");
expect(controller.target_map?.local_path).toBe("/test-file");
});
});

View File

@ -1,76 +0,0 @@
import { describe, expect, test, mock, afterAll } from "bun:test";
import handleRoutes from "../../../../src/functions/server/handle-routes";
mock.module("../../../../src/utils/is-development", () => ({
default: () => false
}));
mock.module("../../../../src/utils/grab-constants", () => ({
default: () => ({ MBInBytes: 1048576, ServerDefaultRequestBodyLimitBytes: 5242880 })
}));
mock.module("../../../../src/utils/grab-router", () => ({
default: () => ({
match: (path: string) => {
if (path === "/api/test") return { filePath: "/test-path" };
if (path === "/api/large") return { filePath: "/large-path" };
return null;
}
})
}));
mock.module("../../../../src/utils/grab-route-params", () => ({
default: async () => ({ params: {}, searchParams: {} })
}));
mock.module("/test-path", () => ({
default: async () => new Response("OK", { status: 200 })
}));
mock.module("/large-path", () => ({
default: async () => new Response("Large OK", { status: 200 }),
config: { maxRequestBodyMB: 1 }
}));
/**
* Tests for routing logic within `handle-routes`.
*/
describe("handle-routes", () => {
afterAll(() => {
mock.restore();
});
test("returns 401 for unknown route", async () => {
const req = new Request("http://localhost/api/unknown");
const res = await handleRoutes({ req });
expect(res.status).toBe(401);
const json = await res.json();
expect(json.success).toBe(false);
expect(json.msg).toContain("not found");
});
test("calls matched module default export", async () => {
const req = new Request("http://localhost/api/test");
const res = await handleRoutes({ req });
expect(res.status).toBe(200);
expect(await res.text()).toBe("OK");
});
test("enforces request body size limits", async () => {
// limit is 1MB from mock config
const req = new Request("http://localhost/api/large", {
method: "POST",
headers: {
"content-length": "2000000" // ~2MB
},
body: "x".repeat(10) // the actual body doesn't matter since handleRoutes only checks the header
});
const res = await handleRoutes({ req });
expect(res.status).toBe(413);
const json = await res.json();
expect(json.success).toBe(false);
});
});

View File

@ -1,44 +0,0 @@
import { describe, expect, test, mock, afterEach } from "bun:test";
import startServer from "../../../../src/functions/server/start-server";
import { log } from "../../../../src/utils/log";
// Mock log so we don't spam terminal during tests
mock.module("../../../../src/utils/log", () => ({
log: {
server: mock((msg: string) => {}),
info: mock((msg: string) => {}),
error: mock((msg: string) => {}),
}
}));
// Mock grabConfig so it doesn't try to look for bunext.config.ts and exit process
mock.module("../../../../src/functions/grab-config", () => ({
default: async () => ({})
}));
// Mock grabAppPort to return 0 so Bun.serve picks a random port
mock.module("../../../../src/utils/grab-app-port", () => ({
default: () => 0
}));
describe("startServer", () => {
afterEach(() => {
if (global.SERVER) {
global.SERVER.stop(true);
global.SERVER = undefined;
}
});
test("starts the server and assigns to global.SERVER", async () => {
global.CONFIG = { development: true };
const server = await startServer();
expect(server).toBeDefined();
expect(server.port).toBeGreaterThan(0);
expect(global.SERVER).toBe(server);
expect(log.server).toHaveBeenCalled();
server.stop(true);
});
});

View File

@ -1,79 +0,0 @@
import { describe, expect, test, beforeEach, afterEach } from "bun:test";
import React, { useState } from "react";
import { renderToString } from "react-dom/server";
import { hydrateRoot } from "react-dom/client";
import { GlobalWindow } from "happy-dom";
// A mock application component to test hydration
function App() {
const [count, setCount] = useState(0);
return (
<div id="app-root">
<h1>Test Hydration</h1>
<p data-testid="count">Count: {count}</p>
<button data-testid="btn" onClick={() => setCount(c => c + 1)}>Increment</button>
</div>
);
}
describe("React Hydration", () => {
let window: GlobalWindow;
let document: any;
beforeEach(() => {
window = new GlobalWindow();
document = window.document;
global.window = window as any;
global.document = document as any;
global.navigator = { userAgent: "node.js" } as any;
});
afterEach(() => {
// Clean up global mocks
delete (global as any).window;
delete (global as any).document;
delete (global as any).navigator;
window.close();
});
test("hydrates a server-rendered component and binds events", async () => {
// 1. Server-side render
const html = renderToString(<App />);
// 2. Setup DOM as it would be delivered to the client
document.body.innerHTML = `<div id="root">${html}</div>`;
const rootNode = document.getElementById("root");
// 3. Hydrate
let hydrateError = null;
try {
await new Promise((resolve) => {
hydrateRoot(rootNode, <App />, {
onRecoverableError: (err) => {
hydrateError = err;
}
});
setTimeout(resolve, 50); // let React finish hydration
});
} catch (e) {
hydrateError = e;
}
// Verify no hydration errors
expect(hydrateError).toBeNull();
// 4. Verify client-side interactivity
const button = document.querySelector('[data-testid="btn"]');
const countText = document.querySelector('[data-testid="count"]');
expect(countText.textContent).toBe("Count: 0");
// Simulate click
button.dispatchEvent(new window.Event("click", { bubbles: true }));
// Let async state updates process
await new Promise(r => setTimeout(r, 50));
expect(countText.textContent).toBe("Count: 1");
});
});

156
src/build/build.ts Normal file
View File

@ -0,0 +1,156 @@
#!/usr/bin/env bun
import type { BuildConfig } from "bun";
import plugin from "bun-plugin-tailwind";
import { existsSync } from "fs";
import { rm } from "fs/promises";
import path from "path";
if (process.argv.includes("--help") || process.argv.includes("-h")) {
console.log(`
🏗 Bun Build Script
Usage: bun run build.ts [options]
Common Options:
--outdir <path> Output directory (default: "dist")
--minify Enable minification (or --minify.whitespace, --minify.syntax, etc)
--sourcemap <type> Sourcemap type: none|linked|inline|external
--target <target> Build target: browser|bun|node
--format <format> Output format: esm|cjs|iife
--splitting Enable code splitting
--packages <type> Package handling: bundle|external
--public-path <path> Public path for assets
--env <mode> Environment handling: inline|disable|prefix*
--conditions <list> Package.json export conditions (comma separated)
--external <list> External packages (comma separated)
--banner <text> Add banner text to output
--footer <text> Add footer text to output
--define <obj> Define global constants (e.g. --define.VERSION=1.0.0)
--help, -h Show this help message
Example:
bun run build.ts --outdir=dist --minify --sourcemap=linked --external=react,react-dom
`);
process.exit(0);
}
const toCamelCase = (str: string): string =>
str.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
const parseValue = (value: string): any => {
if (value === "true") return true;
if (value === "false") return false;
if (/^\d+$/.test(value)) return parseInt(value, 10);
if (/^\d*\.\d+$/.test(value)) return parseFloat(value);
if (value.includes(",")) return value.split(",").map((v) => v.trim());
return value;
};
function parseArgs(): Partial<BuildConfig> {
const config: any = {};
const args = process.argv.slice(2);
for (let i = 0; i < args.length; i++) {
const arg = args[i];
if (arg === undefined) continue;
if (!arg.startsWith("--")) continue;
if (arg.startsWith("--no-")) {
const key = toCamelCase(arg.slice(5));
config[key] = false;
continue;
}
if (
!arg.includes("=") &&
(i === args.length - 1 || args[i + 1]?.startsWith("--"))
) {
const key = toCamelCase(arg.slice(2));
config[key] = true;
continue;
}
let key: string;
let value: string;
if (arg.includes("=")) {
[key, value] = arg.slice(2).split("=", 2) as [string, string];
} else {
key = arg.slice(2);
value = args[++i] ?? "";
}
key = toCamelCase(key);
if (key.includes(".")) {
const [parentKey, childKey] = key.split(".");
config[parentKey] = config[parentKey] || {};
config[parentKey][childKey] = parseValue(value);
} else {
config[key] = parseValue(value);
}
}
return config;
}
const formatFileSize = (bytes: number): string => {
const units = ["B", "KB", "MB", "GB"];
let size = bytes;
let unitIndex = 0;
while (size >= 1024 && unitIndex < units.length - 1) {
size /= 1024;
unitIndex++;
}
return `${size.toFixed(2)} ${units[unitIndex]}`;
};
console.log("\n🚀 Starting build process...\n");
const cliConfig = parseArgs();
const outdir = cliConfig.outdir || path.join(process.cwd(), "dist");
if (existsSync(outdir)) {
console.log(`🗑️ Cleaning previous build at ${outdir}`);
await rm(outdir, { recursive: true, force: true });
}
const start = performance.now();
const entrypoints = [...new Bun.Glob("**.html").scanSync("src/app")]
.map((a) => path.resolve("src/app", a))
.filter((dir) => !dir.includes("node_modules"));
console.log(
`📄 Found ${entrypoints.length} HTML ${entrypoints.length === 1 ? "file" : "files"} to process\n`,
);
const result = await Bun.build({
entrypoints,
outdir,
plugins: [plugin],
minify: true,
target: "browser",
sourcemap: "linked",
define: {
"process.env.NODE_ENV": JSON.stringify("production"),
},
...cliConfig,
});
const end = performance.now();
const outputTable = result.outputs.map((output) => ({
File: path.relative(process.cwd(), output.path),
Type: output.kind,
Size: formatFileSize(output.size),
}));
console.table(outputTable);
const buildTime = (end - start).toFixed(2);
console.log(`\n✅ Build completed in ${buildTime}ms\n`);

View File

@ -4,7 +4,6 @@ import { program } from "commander";
import start from "./start"; import start from "./start";
import dev from "./dev"; import dev from "./dev";
import build from "./build"; import build from "./build";
import { log } from "../utils/log";
/** /**
* # Describe Program * # Describe Program
@ -25,12 +24,10 @@ program.addCommand(build());
* # Handle Unavailable Commands * # Handle Unavailable Commands
*/ */
program.on("command:*", () => { program.on("command:*", () => {
log.error( console.error(
"Invalid command: %s\nSee --help for a list of available commands." + "Invalid command: %s\nSee --help for a list of available commands.",
" " + program.args.join(" "),
program.args.join(" "),
); );
process.exit(1); process.exit(1);
}); });

View File

@ -1,4 +1,4 @@
import { existsSync, statSync, writeFileSync } from "fs"; import { writeFileSync } from "fs";
import * as esbuild from "esbuild"; import * as esbuild from "esbuild";
import grabAllPages from "../../utils/grab-all-pages"; import grabAllPages from "../../utils/grab-all-pages";
import grabDirNames from "../../utils/grab-dir-names"; import grabDirNames from "../../utils/grab-dir-names";
@ -9,13 +9,8 @@ import { log } from "../../utils/log";
import tailwindEsbuildPlugin from "../server/web-pages/tailwind-esbuild-plugin"; import tailwindEsbuildPlugin from "../server/web-pages/tailwind-esbuild-plugin";
import grabClientHydrationScript from "./grab-client-hydration-script"; import grabClientHydrationScript from "./grab-client-hydration-script";
import grabArtifactsFromBundledResults from "./grab-artifacts-from-bundled-result"; import grabArtifactsFromBundledResults from "./grab-artifacts-from-bundled-result";
import path from "path";
const { HYDRATION_DST_DIR, HYDRATION_DST_DIR_MAP_JSON_FILE, ROOT_DIR } = const { HYDRATION_DST_DIR, HYDRATION_DST_DIR_MAP_JSON_FILE } = grabDirNames();
grabDirNames();
let build_starts = 0;
const MAX_BUILD_STARTS = 10;
type Params = { type Params = {
watch?: boolean; watch?: boolean;
@ -61,27 +56,11 @@ export default async function allPagesBundler(params?: Params) {
let buildStart = 0; let buildStart = 0;
build.onStart(() => { build.onStart(() => {
build_starts++;
buildStart = performance.now(); buildStart = performance.now();
if (build_starts == MAX_BUILD_STARTS) {
const error_msg = `Build Failed. Please check all your components and imports.`;
log.error(error_msg);
// process.exit(1);
}
}); });
build.onEnd((result) => { build.onEnd((result) => {
if (result.errors.length > 0) { if (result.errors.length > 0) return;
for (const error of result.errors) {
const loc = error.location;
const location = loc
? ` ${loc.file}:${loc.line}:${loc.column}`
: "";
log.error(`[Build]${location} ${error.text}`);
}
return;
}
const artifacts = grabArtifactsFromBundledResults({ const artifacts = grabArtifactsFromBundledResults({
pages, pages,
@ -107,8 +86,6 @@ export default async function allPagesBundler(params?: Params) {
if (params?.exit_after_first_build) { if (params?.exit_after_first_build) {
process.exit(); process.exit();
} }
build_starts = 0;
}); });
}, },
}; };

View File

@ -7,7 +7,6 @@ import type { BunextConfig } from "../types";
export default async function () { export default async function () {
const dirNames = grabDirNames(); const dirNames = grabDirNames();
const is_dev = !Boolean(process.env.NODE_ENV == "production");
execSync(`rm -rf ${dirNames.BUNEXT_CACHE_DIR}`); execSync(`rm -rf ${dirNames.BUNEXT_CACHE_DIR}`);
execSync(`rm -rf ${dirNames.BUNX_CWD_MODULE_CACHE_DIR}`); execSync(`rm -rf ${dirNames.BUNX_CWD_MODULE_CACHE_DIR}`);
@ -49,6 +48,6 @@ export default async function () {
global.CONFIG = { global.CONFIG = {
...config, ...config,
development: is_dev, development: true,
}; };
} }

View File

@ -2,7 +2,9 @@ import handleWebPages from "./web-pages/handle-web-pages";
import handleRoutes from "./handle-routes"; import handleRoutes from "./handle-routes";
import isDevelopment from "../../utils/is-development"; import isDevelopment from "../../utils/is-development";
import grabConstants from "../../utils/grab-constants"; import grabConstants from "../../utils/grab-constants";
import { AppData } from "../../data/app-data";
import handleHmr from "./handle-hmr"; import handleHmr from "./handle-hmr";
import handleHmrUpdate from "./handle-hmr-update";
import handlePublic from "./handle-public"; import handlePublic from "./handle-public";
import handleFiles from "./handle-files"; import handleFiles from "./handle-files";
type Params = { type Params = {
@ -37,7 +39,9 @@ export default async function bunextRequestHandler({
} }
} }
if (url.pathname === "/__hmr" && is_dev) { if (url.pathname == `/${AppData["ClientHMRPath"]}`) {
response = await handleHmrUpdate({ req });
} else if (url.pathname === "/__hmr" && is_dev) {
response = await handleHmr({ req }); response = await handleHmr({ req });
} else if (url.pathname.startsWith("/api/")) { } else if (url.pathname.startsWith("/api/")) {
response = await handleRoutes({ req }); response = await handleRoutes({ req });

View File

@ -0,0 +1,82 @@
import grabDirNames from "../../utils/grab-dir-names";
import { AppData } from "../../data/app-data";
import path from "path";
import grabRootFile from "./web-pages/grab-root-file";
import grabPageBundledReactComponent from "./web-pages/grab-page-bundled-react-component";
import writeHMRTsxModule from "./web-pages/write-hmr-tsx-module";
const { BUNX_HYDRATION_SRC_DIR } = grabDirNames();
type Params = {
req: Request;
};
export default async function ({ req }: Params): Promise<Response> {
try {
const url = new URL(req.url);
const target_href = url.searchParams.get("href");
if (!target_href) {
return new Response(
`No HREF passed to /${AppData["ClientHMRPath"]}`,
{ status: 404 },
);
}
const target_href_url = new URL(target_href);
const match = global.ROUTER.match(target_href_url.pathname);
if (!match?.filePath) {
return new Response(`No pages file matched for this path`, {
status: 404,
});
}
const out_file = path.join(
BUNX_HYDRATION_SRC_DIR,
target_href_url.pathname,
"index.js",
);
const { root_file } = grabRootFile();
const { tsx } =
(await grabPageBundledReactComponent({
file_path: match.filePath,
root_file,
})) || {};
if (!tsx) {
throw new Error(`Couldn't grab txt string`);
}
const artifact = await writeHMRTsxModule({
tsx,
out_file,
});
const file = Bun.file(out_file);
if (await file.exists()) {
return new Response(file, {
headers: {
"Content-Type": "text/javascript",
},
});
}
return new Response("Not found", {
status: 404,
});
} catch (error: any) {
const error_msg = error.message;
console.error(error_msg);
return new Response(error_msg || "HMR Error", {
status: 404,
});
}
}

View File

@ -1,4 +1,4 @@
import { watch, existsSync, statSync } from "fs"; import { watch, existsSync } from "fs";
import path from "path"; import path from "path";
import grabDirNames from "../../utils/grab-dir-names"; import grabDirNames from "../../utils/grab-dir-names";
import rebuildBundler from "./rebuild-bundler"; import rebuildBundler from "./rebuild-bundler";
@ -6,9 +6,7 @@ import { log } from "../../utils/log";
const { ROOT_DIR } = grabDirNames(); const { ROOT_DIR } = grabDirNames();
export default async function watcher() { export default function watcher() {
await Bun.sleep(1000);
const pages_src_watcher = watch( const pages_src_watcher = watch(
ROOT_DIR, ROOT_DIR,
{ {
@ -17,18 +15,6 @@ export default async function watcher() {
}, },
async (event, filename) => { async (event, filename) => {
if (!filename) return; if (!filename) return;
const full_file_path = path.join(ROOT_DIR, filename);
if (full_file_path.match(/\/styles$/)) {
global.RECOMPILING = true;
await Bun.sleep(1000);
await fullRebuild({
msg: `Detected new \`styles\` directory. Rebuilding ...`,
});
return;
}
const excluded_match = const excluded_match =
/node_modules\/|^public\/|^\.bunext\/|^\.git\/|^dist\/|bun\.lockb$/; /node_modules\/|^public\/|^\.bunext\/|^\.git\/|^dist\/|bun\.lockb$/;
@ -41,10 +27,11 @@ export default async function watcher() {
return; return;
} }
const target_files_match = /\.(tsx?|jsx?|css)$/;
if (event !== "rename") { if (event !== "rename") {
if (filename.match(target_files_match) && global.BUNDLER_CTX) { if (
filename.match(/\.(tsx?|jsx?|css)$/) &&
global.BUNDLER_CTX
) {
if (global.RECOMPILING) return; if (global.RECOMPILING) return;
global.RECOMPILING = true; global.RECOMPILING = true;
await global.BUNDLER_CTX.rebuild(); await global.BUNDLER_CTX.rebuild();
@ -52,24 +39,16 @@ export default async function watcher() {
return; return;
} }
const is_file_of_interest = Boolean( if (!filename.match(/^src\/pages\//)) return;
filename.match(target_files_match),
);
if (!is_file_of_interest) {
return;
}
if (!filename.match(/^src\/pages\/|\.css$/)) return;
if (filename.match(/\/(--|\()/)) return; if (filename.match(/\/(--|\()/)) return;
if (global.RECOMPILING) return; if (global.RECOMPILING) return;
const action = existsSync(full_file_path) ? "created" : "deleted"; const fullPath = path.join(ROOT_DIR, filename);
const type = filename.match(/\.css$/) ? "Sylesheet" : "Page"; const action = existsSync(fullPath) ? "created" : "deleted";
await fullRebuild({ await fullRebuild({
msg: `${type} ${action}: ${filename}. Rebuilding ...`, msg: `Page ${action}: ${filename}. Rebuilding ...`,
}); });
}, },
); );

View File

@ -1,4 +1,4 @@
import { renderToString } from "react-dom/server"; import path from "path";
import grabContants from "../../../utils/grab-constants"; import grabContants from "../../../utils/grab-constants";
import EJSON from "../../../utils/ejson"; import EJSON from "../../../utils/ejson";
import type { LivePageDistGenParams } from "../../../types"; import type { LivePageDistGenParams } from "../../../types";
@ -21,6 +21,10 @@ export default async function genWebHTML({
const { ClientRootElementIDName, ClientWindowPagePropsName } = const { ClientRootElementIDName, ClientWindowPagePropsName } =
grabContants(); grabContants();
const { renderToString } = await import(
path.join(process.cwd(), "node_modules", "react-dom", "server")
);
if (debug) { if (debug) {
log.info("component", component); log.info("component", component);
} }

View File

@ -58,7 +58,7 @@ export default async function grabPageComponent({
if (!file_path) { if (!file_path) {
const errMsg = `No File Path (\`file_path\`) or Request Object (\`req\`) provided not found`; const errMsg = `No File Path (\`file_path\`) or Request Object (\`req\`) provided not found`;
// log.error(errMsg); // console.error(errMsg);
throw new Error(errMsg); throw new Error(errMsg);
} }
@ -68,7 +68,7 @@ export default async function grabPageComponent({
if (!bundledMap?.path) { if (!bundledMap?.path) {
const errMsg = `No Bundled File Path for this request path!`; const errMsg = `No Bundled File Path for this request path!`;
log.error(errMsg); console.error(errMsg);
throw new Error(errMsg); throw new Error(errMsg);
} }
@ -172,7 +172,7 @@ export default async function grabPageComponent({
head: Head, head: Head,
}; };
} catch (error: any) { } catch (error: any) {
log.error(`Error Grabbing Page Component: ${error.message}`); console.error(`Error Grabbing Page Component: ${error.message}`);
return await grabPageErrorComponent({ return await grabPageErrorComponent({
error, error,

View File

@ -47,11 +47,6 @@ export default async function grabPageErrorComponent({
routeParams, routeParams,
module, module,
bundledMap, bundledMap,
serverRes: {
responseOptions: {
status: is404 ? 404 : 500
}
} as any
}; };
} catch { } catch {
const DefaultNotFound: FC = () => ( const DefaultNotFound: FC = () => (
@ -75,11 +70,6 @@ export default async function grabPageErrorComponent({
routeParams, routeParams,
module: { default: DefaultNotFound }, module: { default: DefaultNotFound },
bundledMap: {} as BundlerCTXMap, bundledMap: {} as BundlerCTXMap,
serverRes: {
responseOptions: {
status: is404 ? 404 : 500
}
} as any
}; };
} }
} }

View File

@ -36,18 +36,14 @@ export default async function (params?: Params) {
script += ` try {\n`; script += ` try {\n`;
script += ` document.getElementById("__bunext_error_overlay")?.remove();\n`; script += ` document.getElementById("__bunext_error_overlay")?.remove();\n`;
script += ` const data = JSON.parse(event.data);\n`; script += ` const data = JSON.parse(event.data);\n`;
// script += ` console.log("data", data);\n`;
script += ` const oldCSSLink = document.querySelector('link[rel="stylesheet"]');\n`;
script += ` if (data.target_map.css_path) {\n`; script += ` if (data.target_map.css_path) {\n`;
script += ` const oldLink = document.querySelector('link[rel="stylesheet"]');\n`;
script += ` const newLink = document.createElement("link");\n`; script += ` const newLink = document.createElement("link");\n`;
script += ` newLink.rel = "stylesheet";\n`; script += ` newLink.rel = "stylesheet";\n`;
script += ` newLink.href = \`/\${data.target_map.css_path}?t=\${Date.now()}\`;\n`; script += ` newLink.href = \`/\${data.target_map.css_path}?t=\${Date.now()}\`;\n`;
script += ` newLink.onload = () => oldCSSLink?.remove();\n`; script += ` newLink.onload = () => oldLink?.remove();\n`;
script += ` document.head.appendChild(newLink);\n`; script += ` document.head.appendChild(newLink);\n`;
script += ` } else if (oldCSSLink) {\n`;
script += ` oldCSSLink.remove();\n`;
script += ` }\n`; script += ` }\n`;
script += ` const newScriptPath = \`/\${data.target_map.path}?t=\${Date.now()}\`;\n\n`; script += ` const newScriptPath = \`/\${data.target_map.path}?t=\${Date.now()}\`;\n\n`;

View File

@ -1,5 +1,4 @@
import isDevelopment from "../../../utils/is-development"; import isDevelopment from "../../../utils/is-development";
import { log } from "../../../utils/log";
import getCache from "../../cache/get-cache"; import getCache from "../../cache/get-cache";
import generateWebPageResponseFromComponentReturn from "./generate-web-page-response-from-component-return"; import generateWebPageResponseFromComponentReturn from "./generate-web-page-response-from-component-return";
import grabPageComponent from "./grab-page-component"; import grabPageComponent from "./grab-page-component";
@ -39,7 +38,7 @@ export default async function handleWebPages({
...componentRes, ...componentRes,
}); });
} catch (error: any) { } catch (error: any) {
log.error(`Error Handling Web Page: ${error.message}`); console.error(`Error Handling Web Page: ${error.message}`);
const componentRes = await grabPageErrorComponent({ const componentRes = await grabPageErrorComponent({
error, error,

View File

@ -2,59 +2,19 @@ import * as esbuild from "esbuild";
import postcss from "postcss"; import postcss from "postcss";
import tailwindcss from "@tailwindcss/postcss"; import tailwindcss from "@tailwindcss/postcss";
import { readFile } from "fs/promises"; import { readFile } from "fs/promises";
import path from "path";
import { existsSync } from "fs";
import grabDirNames from "../../../utils/grab-dir-names";
import { log } from "../../../utils/log";
const { ROOT_DIR } = grabDirNames();
let error_logged = false;
const tailwindEsbuildPlugin: esbuild.Plugin = { const tailwindEsbuildPlugin: esbuild.Plugin = {
name: "tailwindcss", name: "tailwindcss",
setup(build) { setup(build) {
build.onLoad({ filter: /\.css$/ }, async (args) => { build.onLoad({ filter: /\.css$/ }, async (args) => {
try { const source = await readFile(args.path, "utf-8");
const source = await readFile(args.path, "utf-8"); const result = await postcss([tailwindcss()]).process(source, {
const result = await postcss([tailwindcss()]).process(source, { from: args.path,
from: args.path, });
});
error_logged = false;
return { contents: result.css, loader: "css" };
} catch (error: any) {
return { errors: [{ text: error.message }] };
}
});
build.onResolve({ filter: /\.css$/ }, async (args) => {
const css_path = path.resolve(
args.resolveDir,
args.path.replace(/\@\//g, ROOT_DIR + "/"),
);
const does_path_exist = existsSync(css_path);
if (!does_path_exist && !error_logged) {
const err_msg = `CSS Error: ${css_path} file does not exist.`;
log.error(err_msg);
error_logged = true;
// return {
// errors: [
// {
// text: err_msg,
// },
// ],
// pluginName: "tailwindcss",
// };
}
return { return {
path: css_path, contents: result.css,
loader: "css",
}; };
}); });
}, },

View File

@ -1,18 +0,0 @@
import path from "path";
import reactDomServer from "react-dom/server";
export default async function importReactDomServer() {
try {
const reactDomServerDynamicImport = await import(
path.join(process.cwd(), "node_modules", "react-dom", "server")
);
if (!reactDomServerDynamicImport.renderToString) {
return reactDomServer;
}
return reactDomServerDynamicImport;
} catch (error) {
return reactDomServer;
}
}

View File

@ -19,11 +19,5 @@
"declaration": true "declaration": true
}, },
"include": ["src"], "include": ["src"],
"exclude": [ "exclude": ["node_modules", "dist"]
"node_modules",
"dist",
"src/__tests__",
"**/__tests__",
"__tests__"
]
} }