From 5a3b7faad02a1952a4a04a1130c3cbd08e6700d5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 Aug 2025 01:10:51 +0000 Subject: [PATCH 01/15] Initial plan From 2b4c3415e2846221a240a45cb08d864cef63de07 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 Aug 2025 01:16:00 +0000 Subject: [PATCH 02/15] Add Vercel build adapter with production-optimized builds Co-authored-by: andylovescode <144629051+andylovescode@users.noreply.github.com> --- packages/wormhole/src/build/adapters/index.ts | 2 + .../wormhole/src/build/adapters/vercel.ts | 234 ++++++++++++++++++ packages/wormhole/src/index.ts | 1 + 3 files changed, 237 insertions(+) create mode 100644 packages/wormhole/src/build/adapters/index.ts create mode 100644 packages/wormhole/src/build/adapters/vercel.ts diff --git a/packages/wormhole/src/build/adapters/index.ts b/packages/wormhole/src/build/adapters/index.ts new file mode 100644 index 0000000..7284567 --- /dev/null +++ b/packages/wormhole/src/build/adapters/index.ts @@ -0,0 +1,2 @@ +export { DevAdapter, type DevAdapterResult } from "./dev"; +export { VercelAdapter, type VercelAdapterResult } from "./vercel"; \ No newline at end of file diff --git a/packages/wormhole/src/build/adapters/vercel.ts b/packages/wormhole/src/build/adapters/vercel.ts new file mode 100644 index 0000000..fabf846 --- /dev/null +++ b/packages/wormhole/src/build/adapters/vercel.ts @@ -0,0 +1,234 @@ +import type { EntrypointProps } from "~/runtime"; +import type { Build, BuildAdapter, TargetLocation } from "../build"; +import type { Export } from "~/local/export"; +import { addTask } from "~/cli/statusboard"; +import { join } from "node:path"; + +export interface VercelAdapterResult { + clientEntry: string; + serverEntry: string; + cssEntry: string; + outdir: string; +} + +export interface VercelAdapter extends BuildAdapter { + buildForLocation(build: Build, location: TargetLocation): Promise; + buildCSS(build: Build): Promise; +} + +export function VercelAdapter(): VercelAdapter { + return { + async buildForLocation(build: Build, location: TargetLocation) { + using _task = addTask({ + name: `Building ${location} for Vercel` + }); + let codegenSource = ""; + + codegenSource += `import { INTERNAL_entrypoint } from "@vortexjs/wormhole";`; + codegenSource += `import { Lifetime } from "@vortexjs/core";` + + if (location === "client") { + codegenSource += `import { html } from "@vortexjs/dom";`; + } + + const imports: Export[] = []; + + function getExportIndex(exp: Export): number { + const index = imports.findIndex(x => x.file === exp.file && x.name === exp.name); + if (index === -1) { + imports.push(exp); + return imports.length - 1; + } + return index; + } + + const entrypointProps: EntrypointProps = { + routes: build.routes.filter(x => x.type === "route").map(x => ({ + matcher: x.matcher, + frames: x.frames.map((frame) => ({ + index: getExportIndex(frame), + })), + is404: x.is404, + })) + } + + codegenSource += `const entrypointProps = JSON.parse(${JSON.stringify(JSON.stringify(entrypointProps))});`; + + codegenSource += `export function main(props) {`; + + codegenSource += 'const loaders = ['; + + for (const exp of imports) { + const reexporterName = "proxy-" + Bun.hash(`${exp.file}-${exp.name}`).toString(36); + + const path = await build.writeCodegenned(reexporterName, `export { ${JSON.stringify(exp.name)} } from ${JSON.stringify(exp.file)}`); + + codegenSource += `(async () => (await import(${JSON.stringify(path)}))[${JSON.stringify(exp.name)}]),`; + } + + codegenSource += '];'; + + if (location === "server") { + codegenSource += `const renderer = props.renderer;`; + codegenSource += `const root = props.root;`; + } else { + codegenSource += `const renderer = html();`; + codegenSource += `const root = document.documentElement;`; + } + + codegenSource += `return INTERNAL_entrypoint({ + props: entrypointProps, + loaders, + renderer, + root, + pathname: props.pathname, + context: props.context, + lifetime: props.lifetime ?? new Lifetime(), + });`; + + codegenSource += `}`; + + if (location === "server") { + codegenSource += `import {INTERNAL_tryHandleAPI} from "@vortexjs/wormhole";` + codegenSource += `export async function tryHandleAPI(request) {`; + + const apiIndicies: Export[] = []; + + const apiRoutes = build.routes.filter(x => x.type === "api"); + + const getApiExportIndex = (exp: Export): number => { + const index = apiIndicies.findIndex(x => x.file === exp.file && x.name === exp.name); + if (index === -1) { + apiIndicies.push(exp); + return apiIndicies.length - 1; + } + return index; + } + + codegenSource += `const apis = ${JSON.stringify(apiRoutes.map(x => ({ + matcher: x.matcher, + impl: getApiExportIndex(x.impl), + schema: getApiExportIndex(x.schema), + method: x.method, + })))};`; + + codegenSource += `return INTERNAL_tryHandleAPI(request, apis, [`; + + for (const exp of apiIndicies) { + const reexporterName = "proxy-" + Bun.hash(`${exp.file}-${exp.name}`).toString(36); + + const path = await build.writeCodegenned(reexporterName, `export { ${JSON.stringify(exp.name)} } from ${JSON.stringify(exp.file)}`); + + codegenSource += `(async () => (await import(${JSON.stringify(path)}))[${JSON.stringify(exp.name)}]),`; + } + + codegenSource += `]);`; + + codegenSource += `}`; + + // Add Vercel serverless function export for page routes + codegenSource += `import { createHTMLRoot, ssr, printHTML } from "@vortexjs/ssr";`; + codegenSource += `import { ContextScope } from "@vortexjs/core";`; + + codegenSource += `export default async function handler(request, response) {`; + codegenSource += `const url = new URL(request.url || '/', \`https://\${request.headers.host || 'localhost'}\`);`; + codegenSource += `const pathname = url.pathname;`; + + // Handle API routes first + codegenSource += `const apiResponse = await tryHandleAPI(request);`; + codegenSource += `if (apiResponse) {`; + codegenSource += `const body = await apiResponse.text();`; + codegenSource += `const headers = {};`; + codegenSource += `for (const [key, value] of apiResponse.headers) { headers[key] = value; }`; + codegenSource += `response.status(apiResponse.status);`; + codegenSource += `Object.entries(headers).forEach(([key, value]) => response.setHeader(key, value));`; + codegenSource += `response.send(body);`; + codegenSource += `return;`; + codegenSource += `}`; + + // Handle page routes + codegenSource += `const renderer = ssr();`; + codegenSource += `const root = createHTMLRoot();`; + codegenSource += `const lifetime = new ContextScope();`; + codegenSource += `try {`; + codegenSource += `const result = await main({ renderer, root, pathname, context: {}, lifetime });`; + codegenSource += `const html = printHTML(root);`; + codegenSource += `response.setHeader('Content-Type', 'text/html');`; + codegenSource += `response.status(200).send(html);`; + codegenSource += `} catch (error) {`; + codegenSource += `console.error('Rendering error:', error);`; + codegenSource += `response.status(500).send('Internal Server Error');`; + codegenSource += `} finally {`; + codegenSource += `lifetime.close();`; + codegenSource += `}`; + codegenSource += `}`; + } + + if (location === "server") { + codegenSource += `import { matchPath } from "@vortexjs/wormhole";`; + codegenSource += `export function isRoute404(pathname) {`; + codegenSource += `const route = entrypointProps.routes.find(x => matchPath(x.matcher, pathname).matched);`; + codegenSource += `return route ? route.is404 : false;`; + codegenSource += `}`; + } + + if (location === "client") { + codegenSource += `window.wormhole = {};`; + codegenSource += `window.wormhole.hydrate = main;`; + + // Add client-side hydration initialization + codegenSource += `document.addEventListener('DOMContentLoaded', () => {`; + codegenSource += `const pathname = window.location.pathname;`; + codegenSource += `main({ pathname, context: {}, lifetime: new Lifetime() });`; + codegenSource += `});`; + } + + const filename = `entrypoint-${location}`; + + const path = await build.writeCodegenned(filename, codegenSource); + + const bundled = await build.bundle({ + target: location, + inputPaths: { + main: path, + }, + dev: false // Production build for Vercel + }) + + return bundled.outputs.main; + }, + async buildCSS(build: Build) { + let codegenCSS = ""; + + const appCSSPath = join(build.project.projectDir, "src", "app.css"); + + if (await Bun.file(appCSSPath).exists()) { + codegenCSS += `@import "${appCSSPath}";`; + } + + const cssPath = await build.writeCodegenned("styles", codegenCSS, "css"); + + const bundled = await build.bundle({ + target: "client", + inputPaths: { + main: cssPath, + }, + dev: false // Production build for Vercel + }); + + return bundled.outputs.main; + }, + async run(build) { + const clientEntry = this.buildForLocation(build, "client"); + const serverEntry = this.buildForLocation(build, "server"); + const cssEntry = this.buildCSS(build); + + return { + clientEntry: await clientEntry, + serverEntry: await serverEntry, + cssEntry: await cssEntry, + outdir: build.outputPath + } + } + }; +} \ No newline at end of file diff --git a/packages/wormhole/src/index.ts b/packages/wormhole/src/index.ts index ed5fa59..05b1ad5 100644 --- a/packages/wormhole/src/index.ts +++ b/packages/wormhole/src/index.ts @@ -1,2 +1,3 @@ export * from "./build/router"; +export * from "./build/adapters"; export * from "./runtime"; From 0a86d75c924ed9231b3f163d2ef786971bcbb9f3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 Aug 2025 01:18:19 +0000 Subject: [PATCH 03/15] Complete Vercel adapter implementation with CLI and documentation Co-authored-by: andylovescode <144629051+andylovescode@users.noreply.github.com> --- packages/wormhole/README.md | 26 ++++++++++++++++ .../src/build/adapters/vercel.test.ts | 24 ++++++++++++++ packages/wormhole/src/cli/entry.ts | 31 +++++++++++++++++-- 3 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 packages/wormhole/src/build/adapters/vercel.test.ts diff --git a/packages/wormhole/README.md b/packages/wormhole/README.md index d6b86be..8f3f864 100644 --- a/packages/wormhole/README.md +++ b/packages/wormhole/README.md @@ -8,6 +8,32 @@ Wormhole is the metaframework for Vortex, providing an opinionated way to build - What we believe is the best way to structure applications - Provides a set of tools that synergize with said reccommended structure +## Build Adapters + +Wormhole supports different build adapters for various deployment targets: + +### Development +```bash +wormhole dev +``` +Uses the DevAdapter for local development with hot reloading and debugging features. + +### Vercel +```bash +wormhole build vercel +``` +Uses the VercelAdapter for production deployment to Vercel. This adapter: +- Generates production-optimized builds (minified, no dev flags) +- Creates serverless functions compatible with Vercel's runtime +- Handles both static assets and server-side rendering +- Supports API routes + +The build output includes: +- `clientEntry`: Client-side JavaScript bundle +- `serverEntry`: Server-side bundle for Vercel functions +- `cssEntry`: Compiled CSS bundle +- `outdir`: Output directory containing all build artifacts + ## Who this isn't for - People who don't want to use Vortex diff --git a/packages/wormhole/src/build/adapters/vercel.test.ts b/packages/wormhole/src/build/adapters/vercel.test.ts new file mode 100644 index 0000000..fd75c1a --- /dev/null +++ b/packages/wormhole/src/build/adapters/vercel.test.ts @@ -0,0 +1,24 @@ +import { describe, expect, test } from "bun:test"; +import { VercelAdapter } from "./vercel"; + +describe("VercelAdapter", () => { + test("should create adapter instance", () => { + const adapter = VercelAdapter(); + + expect(adapter).toBeDefined(); + expect(typeof adapter.run).toBe("function"); + expect(typeof adapter.buildForLocation).toBe("function"); + expect(typeof adapter.buildCSS).toBe("function"); + }); + + test("should have correct interface methods", () => { + const adapter = VercelAdapter(); + + // Check that it implements the BuildAdapter interface + expect(adapter.run).toBeDefined(); + + // Check that it implements the VercelAdapter interface + expect(adapter.buildForLocation).toBeDefined(); + expect(adapter.buildCSS).toBeDefined(); + }); +}); \ No newline at end of file diff --git a/packages/wormhole/src/cli/entry.ts b/packages/wormhole/src/cli/entry.ts index ffa5265..1f7feba 100644 --- a/packages/wormhole/src/cli/entry.ts +++ b/packages/wormhole/src/cli/entry.ts @@ -7,6 +7,8 @@ import { Project } from "~/state"; import { Lifetime } from "@vortexjs/core"; import { DevServer } from "~/dev/dev-server"; import { StatusBoard } from "./statusboard"; +import { Build } from "~/build/build"; +import { VercelAdapter } from "~/build/adapters/vercel"; function showHelp() { const printer = createPrinter(); @@ -28,7 +30,7 @@ function showHelp() { const commands = [ ["wh help", "Show this help command"], ["wh dev", "Start the development server"], - ["wh build [platform]", "Build for a certain platform"] + ["wh build vercel", "Build for Vercel deployment"] ]; const firstColumnWidth = Math.max(...commands.map(c => c[0]!.length)) + 2; @@ -53,7 +55,32 @@ const commands = [ DevServer(state); StatusBoard(state); - }, "dev") + }, "dev"), + command(async (platform?: string) => { + const lt = new Lifetime(); + const state = new Project(process.cwd(), lt); + + await state.init(); + + let adapter; + switch (platform) { + case "vercel": + adapter = VercelAdapter(); + break; + default: + console.error(`Unknown platform: ${platform}. Supported platforms: vercel`); + process.exit(1); + } + + const build = new Build(state, adapter); + const result = await build.run(); + + console.log(`Build completed successfully!`); + console.log(`Output directory: ${result.outdir}`); + console.log(`Client entry: ${result.clientEntry}`); + console.log(`Server entry: ${result.serverEntry}`); + console.log(`CSS entry: ${result.cssEntry}`); + }, "build") ] export async function cliMain(args: string[]) { From bbb5308147385a3d14373b8a573212f5a05acccd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 Aug 2025 01:38:06 +0000 Subject: [PATCH 04/15] Implement Vercel Build Output API with lightweight edge functions Co-authored-by: andylovescode <144629051+andylovescode@users.noreply.github.com> --- packages/wormhole/README.md | 20 +- .../src/build/adapters/vercel.test.ts | 8 +- .../wormhole/src/build/adapters/vercel.ts | 480 ++++++++++++++---- packages/wormhole/src/cli/entry.ts | 8 +- 4 files changed, 393 insertions(+), 123 deletions(-) diff --git a/packages/wormhole/README.md b/packages/wormhole/README.md index 8f3f864..05d5412 100644 --- a/packages/wormhole/README.md +++ b/packages/wormhole/README.md @@ -22,17 +22,17 @@ Uses the DevAdapter for local development with hot reloading and debugging featu ```bash wormhole build vercel ``` -Uses the VercelAdapter for production deployment to Vercel. This adapter: +Uses the VercelAdapter with the Vercel Build Output API for production deployment to Vercel. This adapter: - Generates production-optimized builds (minified, no dev flags) -- Creates serverless functions compatible with Vercel's runtime -- Handles both static assets and server-side rendering -- Supports API routes - -The build output includes: -- `clientEntry`: Client-side JavaScript bundle -- `serverEntry`: Server-side bundle for Vercel functions -- `cssEntry`: Compiled CSS bundle -- `outdir`: Output directory containing all build artifacts +- Creates lightweight edge functions for each route and API endpoint +- Outputs in the `.vercel/output` directory structure +- Handles static assets separately from serverless functions +- Supports both server-side rendering and API routes + +The build output follows the Vercel Build Output API format: +- `.vercel/output/static/`: Client-side JavaScript and CSS bundles +- `.vercel/output/functions/`: Individual edge functions for each route +- `.vercel/output/config.json`: Vercel configuration and routing rules ## Who this isn't for diff --git a/packages/wormhole/src/build/adapters/vercel.test.ts b/packages/wormhole/src/build/adapters/vercel.test.ts index fd75c1a..059479d 100644 --- a/packages/wormhole/src/build/adapters/vercel.test.ts +++ b/packages/wormhole/src/build/adapters/vercel.test.ts @@ -7,8 +7,10 @@ describe("VercelAdapter", () => { expect(adapter).toBeDefined(); expect(typeof adapter.run).toBe("function"); - expect(typeof adapter.buildForLocation).toBe("function"); + expect(typeof adapter.buildClientBundle).toBe("function"); expect(typeof adapter.buildCSS).toBe("function"); + expect(typeof adapter.buildRouteFunction).toBe("function"); + expect(typeof adapter.buildCatchAllFunction).toBe("function"); }); test("should have correct interface methods", () => { @@ -18,7 +20,9 @@ describe("VercelAdapter", () => { expect(adapter.run).toBeDefined(); // Check that it implements the VercelAdapter interface - expect(adapter.buildForLocation).toBeDefined(); + expect(adapter.buildClientBundle).toBeDefined(); expect(adapter.buildCSS).toBeDefined(); + expect(adapter.buildRouteFunction).toBeDefined(); + expect(adapter.buildCatchAllFunction).toBeDefined(); }); }); \ No newline at end of file diff --git a/packages/wormhole/src/build/adapters/vercel.ts b/packages/wormhole/src/build/adapters/vercel.ts index fabf846..167970f 100644 --- a/packages/wormhole/src/build/adapters/vercel.ts +++ b/packages/wormhole/src/build/adapters/vercel.ts @@ -1,35 +1,37 @@ import type { EntrypointProps } from "~/runtime"; -import type { Build, BuildAdapter, TargetLocation } from "../build"; +import type { Build, BuildAdapter, TargetLocation, BuildRoute } from "../build"; import type { Export } from "~/local/export"; import { addTask } from "~/cli/statusboard"; -import { join } from "node:path"; +import { join, dirname } from "node:path"; +import { mkdir, writeFile } from "node:fs/promises"; +import { printRoutePath } from "../router"; export interface VercelAdapterResult { - clientEntry: string; - serverEntry: string; - cssEntry: string; - outdir: string; + outputDir: string; + staticDir: string; + functionsDir: string; + configFile: string; } export interface VercelAdapter extends BuildAdapter { - buildForLocation(build: Build, location: TargetLocation): Promise; + buildClientBundle(build: Build): Promise; buildCSS(build: Build): Promise; + buildRouteFunction(build: Build, route: BuildRoute): Promise; + buildCatchAllFunction(build: Build): Promise; } export function VercelAdapter(): VercelAdapter { return { - async buildForLocation(build: Build, location: TargetLocation) { + async buildClientBundle(build: Build) { using _task = addTask({ - name: `Building ${location} for Vercel` + name: "Building client bundle for Vercel" }); + let codegenSource = ""; codegenSource += `import { INTERNAL_entrypoint } from "@vortexjs/wormhole";`; - codegenSource += `import { Lifetime } from "@vortexjs/core";` - - if (location === "client") { - codegenSource += `import { html } from "@vortexjs/dom";`; - } + codegenSource += `import { Lifetime } from "@vortexjs/core";`; + codegenSource += `import { html } from "@vortexjs/dom";`; const imports: Export[] = []; @@ -50,11 +52,11 @@ export function VercelAdapter(): VercelAdapter { })), is404: x.is404, })) - } + }; codegenSource += `const entrypointProps = JSON.parse(${JSON.stringify(JSON.stringify(entrypointProps))});`; - codegenSource += `export function main(props) {`; + codegenSource += `function main(props) {`; codegenSource += 'const loaders = ['; @@ -68,13 +70,8 @@ export function VercelAdapter(): VercelAdapter { codegenSource += '];'; - if (location === "server") { - codegenSource += `const renderer = props.renderer;`; - codegenSource += `const root = props.root;`; - } else { - codegenSource += `const renderer = html();`; - codegenSource += `const root = document.documentElement;`; - } + codegenSource += `const renderer = html();`; + codegenSource += `const root = document.documentElement;`; codegenSource += `return INTERNAL_entrypoint({ props: entrypointProps, @@ -88,33 +85,121 @@ export function VercelAdapter(): VercelAdapter { codegenSource += `}`; - if (location === "server") { - codegenSource += `import {INTERNAL_tryHandleAPI} from "@vortexjs/wormhole";` - codegenSource += `export async function tryHandleAPI(request) {`; + codegenSource += `window.wormhole = {};`; + codegenSource += `window.wormhole.hydrate = main;`; + + // Add client-side hydration initialization + codegenSource += `document.addEventListener('DOMContentLoaded', () => {`; + codegenSource += `const pathname = window.location.pathname;`; + codegenSource += `main({ pathname, context: {}, lifetime: new Lifetime() });`; + codegenSource += `});`; + + const filename = "client-bundle"; + const path = await build.writeCodegenned(filename, codegenSource); + + const bundled = await build.bundle({ + target: "client", + inputPaths: { + main: path, + }, + dev: false + }); + + return bundled.outputs.main; + }, + + async buildCSS(build: Build) { + using _task = addTask({ + name: "Building CSS for Vercel" + }); + + let codegenCSS = ""; + + const appCSSPath = join(build.project.projectDir, "src", "app.css"); + + if (await Bun.file(appCSSPath).exists()) { + codegenCSS += `@import "${appCSSPath}";`; + } + + const cssPath = await build.writeCodegenned("styles", codegenCSS, "css"); + + const bundled = await build.bundle({ + target: "client", + inputPaths: { + main: cssPath, + }, + dev: false + }); + + return bundled.outputs.main; + }, - const apiIndicies: Export[] = []; + async buildRouteFunction(build: Build, route: BuildRoute) { + using _task = addTask({ + name: `Building function for route: ${printRoutePath(route.matcher)}` + }); - const apiRoutes = build.routes.filter(x => x.type === "api"); + let codegenSource = ""; - const getApiExportIndex = (exp: Export): number => { - const index = apiIndicies.findIndex(x => x.file === exp.file && x.name === exp.name); + if (route.type === "api") { + // API route function + codegenSource += `import {INTERNAL_tryHandleAPI} from "@vortexjs/wormhole";`; + + const reexporterName = "proxy-" + Bun.hash(`${route.impl.file}-${route.impl.name}`).toString(36); + const implPath = await build.writeCodegenned(reexporterName, `export { ${JSON.stringify(route.impl.name)} } from ${JSON.stringify(route.impl.file)}`); + + const schemaName = "proxy-" + Bun.hash(`${route.schema.file}-${route.schema.name}`).toString(36); + const schemaPath = await build.writeCodegenned(schemaName, `export { ${JSON.stringify(route.schema.name)} } from ${JSON.stringify(route.schema.file)}`); + + codegenSource += `const apis = [{ + matcher: ${JSON.stringify(route.matcher)}, + impl: 0, + schema: 1, + method: ${JSON.stringify(route.method)}, + }];`; + + codegenSource += `const loaders = [`; + codegenSource += `(async () => (await import(${JSON.stringify(implPath)}))[${JSON.stringify(route.impl.name)}]),`; + codegenSource += `(async () => (await import(${JSON.stringify(schemaPath)}))[${JSON.stringify(route.schema.name)}]),`; + codegenSource += `];`; + + codegenSource += `export default async function handler(request) {`; + codegenSource += `const response = await INTERNAL_tryHandleAPI(request, apis, loaders);`; + codegenSource += `return response || new Response("Not Found", { status: 404 });`; + codegenSource += `}`; + } else { + // Page route function + codegenSource += `import { INTERNAL_entrypoint } from "@vortexjs/wormhole";`; + codegenSource += `import { Lifetime } from "@vortexjs/core";`; + codegenSource += `import { createHTMLRoot, ssr, printHTML } from "@vortexjs/ssr";`; + codegenSource += `import { ContextScope } from "@vortexjs/core";`; + + const imports: Export[] = []; + + function getExportIndex(exp: Export): number { + const index = imports.findIndex(x => x.file === exp.file && x.name === exp.name); if (index === -1) { - apiIndicies.push(exp); - return apiIndicies.length - 1; + imports.push(exp); + return imports.length - 1; } return index; } - codegenSource += `const apis = ${JSON.stringify(apiRoutes.map(x => ({ - matcher: x.matcher, - impl: getApiExportIndex(x.impl), - schema: getApiExportIndex(x.schema), - method: x.method, - })))};`; + const entrypointProps: EntrypointProps = { + routes: [{ + matcher: route.matcher, + frames: route.frames.map((frame) => ({ + index: getExportIndex(frame), + })), + is404: route.is404, + }] + }; - codegenSource += `return INTERNAL_tryHandleAPI(request, apis, [`; + codegenSource += `const entrypointProps = JSON.parse(${JSON.stringify(JSON.stringify(entrypointProps))});`; - for (const exp of apiIndicies) { + codegenSource += 'const loaders = ['; + + for (const exp of imports) { const reexporterName = "proxy-" + Bun.hash(`${exp.file}-${exp.name}`).toString(36); const path = await build.writeCodegenned(reexporterName, `export { ${JSON.stringify(exp.name)} } from ${JSON.stringify(exp.file)}`); @@ -122,113 +207,294 @@ export function VercelAdapter(): VercelAdapter { codegenSource += `(async () => (await import(${JSON.stringify(path)}))[${JSON.stringify(exp.name)}]),`; } - codegenSource += `]);`; + codegenSource += '];'; - codegenSource += `}`; - - // Add Vercel serverless function export for page routes - codegenSource += `import { createHTMLRoot, ssr, printHTML } from "@vortexjs/ssr";`; - codegenSource += `import { ContextScope } from "@vortexjs/core";`; - - codegenSource += `export default async function handler(request, response) {`; - codegenSource += `const url = new URL(request.url || '/', \`https://\${request.headers.host || 'localhost'}\`);`; + codegenSource += `export default async function handler(request) {`; + codegenSource += `const url = new URL(request.url);`; codegenSource += `const pathname = url.pathname;`; - // Handle API routes first - codegenSource += `const apiResponse = await tryHandleAPI(request);`; - codegenSource += `if (apiResponse) {`; - codegenSource += `const body = await apiResponse.text();`; - codegenSource += `const headers = {};`; - codegenSource += `for (const [key, value] of apiResponse.headers) { headers[key] = value; }`; - codegenSource += `response.status(apiResponse.status);`; - codegenSource += `Object.entries(headers).forEach(([key, value]) => response.setHeader(key, value));`; - codegenSource += `response.send(body);`; - codegenSource += `return;`; - codegenSource += `}`; - - // Handle page routes codegenSource += `const renderer = ssr();`; codegenSource += `const root = createHTMLRoot();`; codegenSource += `const lifetime = new ContextScope();`; codegenSource += `try {`; - codegenSource += `const result = await main({ renderer, root, pathname, context: {}, lifetime });`; + codegenSource += `await INTERNAL_entrypoint({ + props: entrypointProps, + loaders, + renderer, + root, + pathname, + context: {}, + lifetime, + });`; codegenSource += `const html = printHTML(root);`; - codegenSource += `response.setHeader('Content-Type', 'text/html');`; - codegenSource += `response.status(200).send(html);`; + codegenSource += `return new Response(html, {`; + codegenSource += `status: 200,`; + codegenSource += `headers: { 'Content-Type': 'text/html' }`; + codegenSource += `});`; codegenSource += `} catch (error) {`; codegenSource += `console.error('Rendering error:', error);`; - codegenSource += `response.status(500).send('Internal Server Error');`; + codegenSource += `return new Response('Internal Server Error', { status: 500 });`; codegenSource += `} finally {`; codegenSource += `lifetime.close();`; codegenSource += `}`; codegenSource += `}`; } - if (location === "server") { - codegenSource += `import { matchPath } from "@vortexjs/wormhole";`; - codegenSource += `export function isRoute404(pathname) {`; - codegenSource += `const route = entrypointProps.routes.find(x => matchPath(x.matcher, pathname).matched);`; - codegenSource += `return route ? route.is404 : false;`; - codegenSource += `}`; - } - - if (location === "client") { - codegenSource += `window.wormhole = {};`; - codegenSource += `window.wormhole.hydrate = main;`; - - // Add client-side hydration initialization - codegenSource += `document.addEventListener('DOMContentLoaded', () => {`; - codegenSource += `const pathname = window.location.pathname;`; - codegenSource += `main({ pathname, context: {}, lifetime: new Lifetime() });`; - codegenSource += `});`; - } - - const filename = `entrypoint-${location}`; - + const routeId = printRoutePath(route.matcher).replace(/\[\.\.\.([^\]]+)\]/g, '[...$1]').replace(/\[([^\]]+)\]/g, '[$1]') || 'index'; + const filename = `function-${route.type}-${routeId}`; const path = await build.writeCodegenned(filename, codegenSource); const bundled = await build.bundle({ - target: location, + target: "server", inputPaths: { main: path, }, - dev: false // Production build for Vercel - }) + dev: false + }); return bundled.outputs.main; }, - async buildCSS(build: Build) { - let codegenCSS = ""; - const appCSSPath = join(build.project.projectDir, "src", "app.css"); + async buildCatchAllFunction(build: Build) { + using _task = addTask({ + name: "Building catch-all function for Vercel" + }); - if (await Bun.file(appCSSPath).exists()) { - codegenCSS += `@import "${appCSSPath}";`; + let codegenSource = ""; + + codegenSource += `import { INTERNAL_entrypoint } from "@vortexjs/wormhole";`; + codegenSource += `import { Lifetime } from "@vortexjs/core";`; + codegenSource += `import { createHTMLRoot, ssr, printHTML } from "@vortexjs/ssr";`; + codegenSource += `import { ContextScope } from "@vortexjs/core";`; + codegenSource += `import {INTERNAL_tryHandleAPI} from "@vortexjs/wormhole";`; + + const imports: Export[] = []; + const apiImports: Export[] = []; + + function getExportIndex(exp: Export): number { + const index = imports.findIndex(x => x.file === exp.file && x.name === exp.name); + if (index === -1) { + imports.push(exp); + return imports.length - 1; + } + return index; } - const cssPath = await build.writeCodegenned("styles", codegenCSS, "css"); + function getApiExportIndex(exp: Export): number { + const index = apiImports.findIndex(x => x.file === exp.file && x.name === exp.name); + if (index === -1) { + apiImports.push(exp); + return apiImports.length - 1; + } + return index; + } + + const pageRoutes = build.routes.filter(x => x.type === "route"); + const apiRoutes = build.routes.filter(x => x.type === "api"); + + const entrypointProps: EntrypointProps = { + routes: pageRoutes.map(x => ({ + matcher: x.matcher, + frames: x.frames.map((frame) => ({ + index: getExportIndex(frame), + })), + is404: x.is404, + })) + }; + + codegenSource += `const entrypointProps = JSON.parse(${JSON.stringify(JSON.stringify(entrypointProps))});`; + + // Page route loaders + codegenSource += 'const loaders = ['; + for (const exp of imports) { + const reexporterName = "proxy-" + Bun.hash(`${exp.file}-${exp.name}`).toString(36); + const path = await build.writeCodegenned(reexporterName, `export { ${JSON.stringify(exp.name)} } from ${JSON.stringify(exp.file)}`); + codegenSource += `(async () => (await import(${JSON.stringify(path)}))[${JSON.stringify(exp.name)}]),`; + } + codegenSource += '];'; + + // API configuration + codegenSource += `const apis = ${JSON.stringify(apiRoutes.map(x => ({ + matcher: x.matcher, + impl: getApiExportIndex(x.impl), + schema: getApiExportIndex(x.schema), + method: x.method, + })))};`; + + // API loaders + codegenSource += `const apiLoaders = [`; + for (const exp of apiImports) { + const reexporterName = "proxy-" + Bun.hash(`${exp.file}-${exp.name}`).toString(36); + const path = await build.writeCodegenned(reexporterName, `export { ${JSON.stringify(exp.name)} } from ${JSON.stringify(exp.file)}`); + codegenSource += `(async () => (await import(${JSON.stringify(path)}))[${JSON.stringify(exp.name)}]),`; + } + codegenSource += `];`; + + codegenSource += `export default async function handler(request) {`; + codegenSource += `const url = new URL(request.url);`; + codegenSource += `const pathname = url.pathname;`; + + // Handle API routes first + codegenSource += `const apiResponse = await INTERNAL_tryHandleAPI(request, apis, apiLoaders);`; + codegenSource += `if (apiResponse) {`; + codegenSource += `return apiResponse;`; + codegenSource += `}`; + + // Handle page routes + codegenSource += `const renderer = ssr();`; + codegenSource += `const root = createHTMLRoot();`; + codegenSource += `const lifetime = new ContextScope();`; + codegenSource += `try {`; + codegenSource += `await INTERNAL_entrypoint({ + props: entrypointProps, + loaders, + renderer, + root, + pathname, + context: {}, + lifetime, + });`; + codegenSource += `const html = printHTML(root);`; + codegenSource += `return new Response(html, {`; + codegenSource += `status: 200,`; + codegenSource += `headers: { 'Content-Type': 'text/html' }`; + codegenSource += `});`; + codegenSource += `} catch (error) {`; + codegenSource += `console.error('Rendering error:', error);`; + codegenSource += `return new Response('Internal Server Error', { status: 500 });`; + codegenSource += `} finally {`; + codegenSource += `lifetime.close();`; + codegenSource += `}`; + codegenSource += `}`; + + const filename = "catch-all-function"; + const path = await build.writeCodegenned(filename, codegenSource); const bundled = await build.bundle({ - target: "client", + target: "server", inputPaths: { - main: cssPath, + main: path, }, - dev: false // Production build for Vercel + dev: false }); return bundled.outputs.main; }, + async run(build) { - const clientEntry = this.buildForLocation(build, "client"); - const serverEntry = this.buildForLocation(build, "server"); - const cssEntry = this.buildCSS(build); + using _task = addTask({ + name: "Building for Vercel Build Output API" + }); - return { - clientEntry: await clientEntry, - serverEntry: await serverEntry, - cssEntry: await cssEntry, - outdir: build.outputPath + const outputDir = join(build.project.projectDir, ".vercel", "output"); + const staticDir = join(outputDir, "static"); + const functionsDir = join(outputDir, "functions"); + + // Ensure directories exist + await mkdir(outputDir, { recursive: true }); + await mkdir(staticDir, { recursive: true }); + await mkdir(functionsDir, { recursive: true }); + + // Build client bundle and CSS + const clientBundlePath = await this.buildClientBundle(build); + const cssBundlePath = await this.buildCSS(build); + + // Copy static assets to static directory + const staticClientPath = join(staticDir, "client.js"); + const staticCssPath = join(staticDir, "styles.css"); + + await Bun.write(staticClientPath, await Bun.file(clientBundlePath).text()); + await Bun.write(staticCssPath, await Bun.file(cssBundlePath).text()); + + // Build individual route functions + const routeFunctions: string[] = []; + for (const route of build.routes) { + const functionPath = await this.buildRouteFunction(build, route); + routeFunctions.push(functionPath); + + // Create function directory in Vercel output + const routeId = printRoutePath(route.matcher).replace(/\[\.\.\.([^\]]+)\]/g, '[...$1]').replace(/\[([^\]]+)\]/g, '[$1]') || 'index'; + const functionDir = join(functionsDir, `${route.type}-${routeId}.func`); + await mkdir(functionDir, { recursive: true }); + + // Copy function file + const functionIndexPath = join(functionDir, "index.js"); + await Bun.write(functionIndexPath, await Bun.file(functionPath).text()); + + // Create .vc-config.json for each function + const vcConfig = { + runtime: "edge", + entrypoint: "index.js" + }; + await writeFile(join(functionDir, ".vc-config.json"), JSON.stringify(vcConfig, null, 2)); + } + + // Build catch-all function for unmatched routes + const catchAllPath = await this.buildCatchAllFunction(build); + const catchAllDir = join(functionsDir, "index.func"); + await mkdir(catchAllDir, { recursive: true }); + + const catchAllIndexPath = join(catchAllDir, "index.js"); + await Bun.write(catchAllIndexPath, await Bun.file(catchAllPath).text()); + + const catchAllVcConfig = { + runtime: "edge", + entrypoint: "index.js" + }; + await writeFile(join(catchAllDir, ".vc-config.json"), JSON.stringify(catchAllVcConfig, null, 2)); + + // Create main config.json + const routes = []; + + // Add routes for static assets + routes.push({ + src: "/client.js", + dest: "/static/client.js" + }); + routes.push({ + src: "/styles.css", + dest: "/static/styles.css" + }); + + // Add routes for each specific route function + for (const route of build.routes) { + const routeId = printRoutePath(route.matcher).replace(/\[\.\.\.([^\]]+)\]/g, '[...$1]').replace(/\[([^\]]+)\]/g, '[$1]') || 'index'; + const routePath = "/" + printRoutePath(route.matcher).replace(/\[\.\.\.([^\]]+)\]/g, '*').replace(/\[([^\]]+)\]/g, '*'); + + if (route.type === "api") { + routes.push({ + src: routePath, + dest: `/functions/${route.type}-${routeId}.func`, + methods: [route.method] + }); + } else { + routes.push({ + src: routePath, + dest: `/functions/${route.type}-${routeId}.func` + }); + } } + + // Add catch-all route last + routes.push({ + src: "/(.*)", + dest: "/functions/index.func" + }); + + const config = { + version: 3, + routes + }; + + const configPath = join(outputDir, "config.json"); + await writeFile(configPath, JSON.stringify(config, null, 2)); + + return { + outputDir, + staticDir, + functionsDir, + configFile: configPath + }; } }; } \ No newline at end of file diff --git a/packages/wormhole/src/cli/entry.ts b/packages/wormhole/src/cli/entry.ts index 1f7feba..9c389b1 100644 --- a/packages/wormhole/src/cli/entry.ts +++ b/packages/wormhole/src/cli/entry.ts @@ -76,10 +76,10 @@ const commands = [ const result = await build.run(); console.log(`Build completed successfully!`); - console.log(`Output directory: ${result.outdir}`); - console.log(`Client entry: ${result.clientEntry}`); - console.log(`Server entry: ${result.serverEntry}`); - console.log(`CSS entry: ${result.cssEntry}`); + console.log(`Output directory: ${result.outputDir}`); + console.log(`Static directory: ${result.staticDir}`); + console.log(`Functions directory: ${result.functionsDir}`); + console.log(`Config file: ${result.configFile}`); }, "build") ] From a39e9310390713a2be9c15d9c56afa3260051290 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 Aug 2025 01:53:03 +0000 Subject: [PATCH 05/15] Remove adapter exports, fix CLI args, and remove barrel module and tests Co-authored-by: andylovescode <144629051+andylovescode@users.noreply.github.com> --- packages/cataloger/src/index.ts | 0 packages/locounter/src/index.ts | 0 packages/wormhole/src/build/adapters/index.ts | 2 -- .../src/build/adapters/vercel.test.ts | 28 ------------------- packages/wormhole/src/cli/entry.ts | 6 ++-- packages/wormhole/src/index.ts | 1 - 6 files changed, 3 insertions(+), 34 deletions(-) mode change 100644 => 100755 packages/cataloger/src/index.ts mode change 100644 => 100755 packages/locounter/src/index.ts delete mode 100644 packages/wormhole/src/build/adapters/index.ts delete mode 100644 packages/wormhole/src/build/adapters/vercel.test.ts diff --git a/packages/cataloger/src/index.ts b/packages/cataloger/src/index.ts old mode 100644 new mode 100755 diff --git a/packages/locounter/src/index.ts b/packages/locounter/src/index.ts old mode 100644 new mode 100755 diff --git a/packages/wormhole/src/build/adapters/index.ts b/packages/wormhole/src/build/adapters/index.ts deleted file mode 100644 index 7284567..0000000 --- a/packages/wormhole/src/build/adapters/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { DevAdapter, type DevAdapterResult } from "./dev"; -export { VercelAdapter, type VercelAdapterResult } from "./vercel"; \ No newline at end of file diff --git a/packages/wormhole/src/build/adapters/vercel.test.ts b/packages/wormhole/src/build/adapters/vercel.test.ts deleted file mode 100644 index 059479d..0000000 --- a/packages/wormhole/src/build/adapters/vercel.test.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { describe, expect, test } from "bun:test"; -import { VercelAdapter } from "./vercel"; - -describe("VercelAdapter", () => { - test("should create adapter instance", () => { - const adapter = VercelAdapter(); - - expect(adapter).toBeDefined(); - expect(typeof adapter.run).toBe("function"); - expect(typeof adapter.buildClientBundle).toBe("function"); - expect(typeof adapter.buildCSS).toBe("function"); - expect(typeof adapter.buildRouteFunction).toBe("function"); - expect(typeof adapter.buildCatchAllFunction).toBe("function"); - }); - - test("should have correct interface methods", () => { - const adapter = VercelAdapter(); - - // Check that it implements the BuildAdapter interface - expect(adapter.run).toBeDefined(); - - // Check that it implements the VercelAdapter interface - expect(adapter.buildClientBundle).toBeDefined(); - expect(adapter.buildCSS).toBeDefined(); - expect(adapter.buildRouteFunction).toBeDefined(); - expect(adapter.buildCatchAllFunction).toBeDefined(); - }); -}); \ No newline at end of file diff --git a/packages/wormhole/src/cli/entry.ts b/packages/wormhole/src/cli/entry.ts index 9c389b1..a318b40 100644 --- a/packages/wormhole/src/cli/entry.ts +++ b/packages/wormhole/src/cli/entry.ts @@ -2,7 +2,7 @@ import chalk from "chalk"; import { createPrinter } from "./printer"; import { colors } from "@vortexjs/cli"; import { version } from "../../package.json" assert { type: "json" }; -import { command, parseArgs } from "@vortexjs/args"; +import { command, parseArgs, optional, positional } from "@vortexjs/args"; import { Project } from "~/state"; import { Lifetime } from "@vortexjs/core"; import { DevServer } from "~/dev/dev-server"; @@ -56,7 +56,7 @@ const commands = [ DevServer(state); StatusBoard(state); }, "dev"), - command(async (platform?: string) => { + command(async ({ platform }: { platform?: string }) => { const lt = new Lifetime(); const state = new Project(process.cwd(), lt); @@ -80,7 +80,7 @@ const commands = [ console.log(`Static directory: ${result.staticDir}`); console.log(`Functions directory: ${result.functionsDir}`); console.log(`Config file: ${result.configFile}`); - }, "build") + }, "build", optional(positional("platform"))) ] export async function cliMain(args: string[]) { diff --git a/packages/wormhole/src/index.ts b/packages/wormhole/src/index.ts index 05b1ad5..ed5fa59 100644 --- a/packages/wormhole/src/index.ts +++ b/packages/wormhole/src/index.ts @@ -1,3 +1,2 @@ export * from "./build/router"; -export * from "./build/adapters"; export * from "./runtime"; From 1786bb81bd95ac1dfab362e5923b15aed0785b54 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 Aug 2025 02:21:23 +0000 Subject: [PATCH 06/15] Fix bundle function extensions and add noSplitting option for edge functions Co-authored-by: andylovescode <144629051+andylovescode@users.noreply.github.com> --- bun.lock | 12 ++++++------ packages/wormhole/src/build/adapters/vercel.ts | 6 ++++-- packages/wormhole/src/build/build.ts | 15 ++++++++++++--- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/bun.lock b/bun.lock index 4562d86..0bcb172 100644 --- a/bun.lock +++ b/bun.lock @@ -59,7 +59,7 @@ }, "packages/example": { "name": "@vortexjs/bun-example", - "version": "1.5.4", + "version": "1.5.5", "dependencies": { "@vortexjs/core": "workspace:*", "@vortexjs/dom": "workspace:*", @@ -180,7 +180,7 @@ }, "packages/vortex-core": { "name": "@vortexjs/core", - "version": "2.5.0", + "version": "2.6.0", "dependencies": { "@vortexjs/common": "workspace:*", }, @@ -194,7 +194,7 @@ }, "packages/vortex-dom": { "name": "@vortexjs/dom", - "version": "2.0.4", + "version": "2.0.5", "dependencies": { "@vortexjs/common": "workspace:*", "@vortexjs/core": "workspace:*", @@ -224,7 +224,7 @@ }, "packages/vortex-prime": { "name": "@vortexjs/prime", - "version": "1.3.4", + "version": "1.3.5", "dependencies": { "@vortexjs/common": "workspace:*", "@vortexjs/core": "workspace:*", @@ -240,7 +240,7 @@ }, "packages/vortex-ssr": { "name": "@vortexjs/ssr", - "version": "0.0.4", + "version": "0.0.5", "dependencies": { "@vortexjs/common": "workspace:*", "@vortexjs/core": "workspace:*", @@ -256,7 +256,7 @@ }, "packages/wormhole": { "name": "@vortexjs/wormhole", - "version": "0.2.0", + "version": "0.3.0", "bin": { "wormhole": "./dist/cli.js", "wh": "./dist/cli.js", diff --git a/packages/wormhole/src/build/adapters/vercel.ts b/packages/wormhole/src/build/adapters/vercel.ts index 167970f..6758903 100644 --- a/packages/wormhole/src/build/adapters/vercel.ts +++ b/packages/wormhole/src/build/adapters/vercel.ts @@ -249,7 +249,8 @@ export function VercelAdapter(): VercelAdapter { inputPaths: { main: path, }, - dev: false + dev: false, + noSplitting: true }); return bundled.outputs.main; @@ -375,7 +376,8 @@ export function VercelAdapter(): VercelAdapter { inputPaths: { main: path, }, - dev: false + dev: false, + noSplitting: true }); return bundled.outputs.main; diff --git a/packages/wormhole/src/build/build.ts b/packages/wormhole/src/build/build.ts index dfa2cfd..4dbae55 100644 --- a/packages/wormhole/src/build/build.ts +++ b/packages/wormhole/src/build/build.ts @@ -73,10 +73,11 @@ export class Build { analyze = Build_analyze; async bundle( - { inputPaths, target, dev = false }: { + { inputPaths, target, dev = false, noSplitting = false }: { inputPaths: Record, target: TargetLocation; dev?: boolean; + noSplitting?: boolean; } ): Promise<{ outputs: Record; @@ -95,7 +96,7 @@ export class Build { const build = await Bun.build({ plugins: [p], - splitting: true, + splitting: !noSplitting, entrypoints, outdir: this.outputPath, target: target === "server" ? "bun" : "browser", @@ -111,7 +112,15 @@ export class Build { for (const [id, entry] of Object.entries(inputPaths)) { const name = basename(entry as string); const fileName = name.slice(0, name.lastIndexOf(".")); - const path = join(this.outputPath, fileName + ".js"); + const originalExt = extname(entry as string); + + // Use correct extension based on input file type + let outputExt = ".js"; // default + if (originalExt === ".css") { + outputExt = ".css"; + } + + const path = join(this.outputPath, fileName + outputExt); results[id as Files] = path; } From ffa62316633ff3e7867da205b28b31e35a644b80 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 Aug 2025 04:03:47 +0000 Subject: [PATCH 07/15] Fix Vercel routing and SSR lifetime usage Co-authored-by: andylovescode <144629051+andylovescode@users.noreply.github.com> --- .../.vercel/output/config.json | 40 +++++++++++++++++++ .../api-api/add.func/.vc-config.json | 4 ++ .../functions/api-api/add.func/index.js | 8 ++++ .../functions/index.func/.vc-config.json | 4 ++ .../output/functions/index.func/index.js | 8 ++++ .../route-[...404].func/.vc-config.json | 4 ++ .../functions/route-[...404].func/index.js | 6 +++ .../route-docs/[...page].func/.vc-config.json | 4 ++ .../route-docs/[...page].func/index.js | 6 +++ .../route-index.func/.vc-config.json | 4 ++ .../functions/route-index.func/index.js | 6 +++ .../.vercel/output/static/client.js | 1 + .../.vercel/output/static/styles.css | 1 + .../wormhole/src/build/adapters/vercel.ts | 10 +++-- 14 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 packages/example-wormhole/.vercel/output/config.json create mode 100644 packages/example-wormhole/.vercel/output/functions/api-api/add.func/.vc-config.json create mode 100644 packages/example-wormhole/.vercel/output/functions/api-api/add.func/index.js create mode 100644 packages/example-wormhole/.vercel/output/functions/index.func/.vc-config.json create mode 100644 packages/example-wormhole/.vercel/output/functions/index.func/index.js create mode 100644 packages/example-wormhole/.vercel/output/functions/route-[...404].func/.vc-config.json create mode 100644 packages/example-wormhole/.vercel/output/functions/route-[...404].func/index.js create mode 100644 packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/.vc-config.json create mode 100644 packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/index.js create mode 100644 packages/example-wormhole/.vercel/output/functions/route-index.func/.vc-config.json create mode 100644 packages/example-wormhole/.vercel/output/functions/route-index.func/index.js create mode 100644 packages/example-wormhole/.vercel/output/static/client.js create mode 100644 packages/example-wormhole/.vercel/output/static/styles.css diff --git a/packages/example-wormhole/.vercel/output/config.json b/packages/example-wormhole/.vercel/output/config.json new file mode 100644 index 0000000..b9e121d --- /dev/null +++ b/packages/example-wormhole/.vercel/output/config.json @@ -0,0 +1,40 @@ +{ + "version": 3, + "routes": [ + { + "src": "/client.js", + "dest": "/static/client.js" + }, + { + "src": "/entrypoint-client.js", + "dest": "/static/client.js" + }, + { + "src": "/styles.css", + "dest": "/static/styles.css" + }, + { + "src": "/api/add", + "dest": "/functions/api-api/add.func", + "methods": [ + "GET" + ] + }, + { + "src": "/", + "dest": "/functions/route-index.func" + }, + { + "src": "/docs/*", + "dest": "/functions/route-docs/[...page].func" + }, + { + "src": "/*", + "dest": "/functions/route-[...404].func" + }, + { + "src": "/(.*)", + "dest": "/functions/index.func" + } + ] +} \ No newline at end of file diff --git a/packages/example-wormhole/.vercel/output/functions/api-api/add.func/.vc-config.json b/packages/example-wormhole/.vercel/output/functions/api-api/add.func/.vc-config.json new file mode 100644 index 0000000..bd4af02 --- /dev/null +++ b/packages/example-wormhole/.vercel/output/functions/api-api/add.func/.vc-config.json @@ -0,0 +1,4 @@ +{ + "runtime": "edge", + "entrypoint": "index.js" +} \ No newline at end of file diff --git a/packages/example-wormhole/.vercel/output/functions/api-api/add.func/index.js b/packages/example-wormhole/.vercel/output/functions/api-api/add.func/index.js new file mode 100644 index 0000000..d0f2749 --- /dev/null +++ b/packages/example-wormhole/.vercel/output/functions/api-api/add.func/index.js @@ -0,0 +1,8 @@ +// @bun +var je=Object.defineProperty;var Z=(e,n)=>{for(var r in n)je(e,r,{get:n[r],enumerable:!0,configurable:!0,set:(s)=>n[r]=()=>s})};var p=(e,n)=>()=>(e&&(n=e(e=0)),n);var Pe,Q=(e,n)=>{for(var r in n)Pe(e,r,{get:n[r],enumerable:!0})};var Y=p(()=>{Pe=Object.defineProperty});function ee(e){return typeof e==="object"&&e!==null&&typeof e.then==="function"}function $(e,n){if(e===n)return!0;if(typeof e!==typeof n)return!1;if(Array.isArray(e)!==Array.isArray(n))return!1;if(ee(e)||ee(n))return!1;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let r=0;r="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}function A(e){return e>="0"&&e<="9"}function re(e){return O(e)||A(e)}function*te(e){let n=0,r=()=>e[n]??"",s=()=>e[n++]??"",t=()=>{n++};while(n=e.tokens.length)return null;return e.tokens[e.current++]??null}function I(e){if(e.current>=e.tokens.length)return null;return e.tokens[e.current]??null}function k(e){let n=I(e);if(n!==null)e.current++;return n}function D(e){let n=k(e);if(n===null)throw new Error("Unexpected end of input");if(n[0]==="number")return n[1];if(n[0]==="string")return n[1];if(n[0]==="keyword"){if(n[1]===g.null)return null;if(n[1]===g.undefined)return;if(n[1]===g.true)return!0;if(n[1]===g.false)return!1;throw new Error(`Unexpected keyword: ${n[1]}`)}let r=null;if(n[0]==="identifier")r=n[1],n=k(e);if(n===null)throw new Error("Unexpected end of input (after reading class)");if(n[0]==="symbol"&&n[1]==="LeftParenthesis"){let s={};while(!0){let t=k(e);if(t===null)throw new Error("Unexpected end of input (when trying to read key)");if(t[0]==="symbol"&&t[1]==="RightParenthesis")break;if(t[0]!=="identifier"&&t[0]!=="string")throw new Error(`Expected identifier or string, got ${t[0]}`);let i=k(e);if(i===null||i[0]!=="symbol"||i[1]!=="Equals")throw new Error(`Expected '=', got ${i?i[0]:"end of input"}`);let o=t[1],l=D(e);s[o]=l}if(r!==null){if(r==="date")return new Date(s.unix);if(r==="set")return new Set(s.items);if(r==="map"){let t=new Map;for(let[i,o]of s.entries)t.set(i,o);return t}throw new Error(`Unknown class: ${r}`)}return s}if(n[0]==="symbol"&&n[1]==="LeftSquareBracket"){let s=[];while(!0){if(I(e)?.[0]==="symbol"&&I(e)?.[1]==="RightSquareBracket"){k(e);break}let t=D(e);s.push(t)}return s}}function Ne(e){let n=[...te(e)],r=ie(n),s=D(r);if(r.currentt[0]).join(", ")}`);return s}function se(){return{output:"",indentLevel:0,minified:!1}}function w(e){e.indentLevel++}function _(e){e.indentLevel=Math.max(0,e.indentLevel-1)}function h(e){if(e.minified){a(e," ");return}a(e,` +`),a(e," ".repeat(e.indentLevel))}function a(e,n){e.output+=n}function q(e){let n=Number.POSITIVE_INFINITY,r="";for(let s of['"',"'","`"]){let t="";t+=s;for(let i of e)if(i===s)t+=`\\${i}`;else if(i==="\\")t+="\\\\";else if(i===` +`)t+="\\n";else if(i==="\t")t+="\\t";else if(i==="\r")t+="\\r";else t+=i;if(t+=s,t.length{Y();S={};Q(S,{escapeStr:()=>q,isAlphabetic:()=>O,isAlphanumeric:()=>re,isNumeric:()=>A,isWhitespace:()=>ne,keywords:()=>g,lex:()=>te,parse:()=>Ne,parseContext_create:()=>ie,parseContext_next:()=>Ce,parseContext_peek:()=>I,parseContext_read:()=>k,parseContext_readObj:()=>D,serialize:()=>ue,serializeContext_create:()=>se,serializeContext_dedent:()=>_,serializeContext_indent:()=>w,serializeContext_newline:()=>h,serializeContext_write:()=>a,serializeContext_writeObject:()=>b,stringify:()=>Te,symbols:()=>L});g={null:"Null",true:"True",false:"False",undefined:"Undefined"},L={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};Te=ue});var Re,z,ze,oe,Me,Fe,le=(e,n)=>function(){return n||(0,e[oe(e)[0]])((n={exports:{}}).exports,n),n.exports},ce=(e,n)=>{for(var r in n)z(e,r,{get:n[r],enumerable:!0})},Ge=(e,n,r,s)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var t=oe(n),i=0,o=t.length,l;in[u]).bind(null,l),enumerable:!(s=ze(n,l))||s.enumerable})}return e},j=(e,n,r)=>(r=e!=null?Re(Me(e)):{},Ge(n||!e||!e.__esModule?z(r,"default",{value:e,enumerable:!0}):r,e));var fe=p(()=>{Re=Object.create,z=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,oe=Object.getOwnPropertyNames,Me=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty});function pe(e){let n,r=e,s=[];return n&&console.log(`[${n}]: initialized with `,r),{setId(t){n=t},[ae](){return r},subscribe(t,i){if(s.push(t),n&&console.trace(`[${n}]: subscribed with `,t),i?.callInitially!==!1)t(r);return new M().onClosed(()=>{s.splice(s.indexOf(t),1),n&&console.log(`[${n}]: unsubscribed `,t)})},set(t){if(n&&console.log(`[${n}]: trying to switch from `,r," -> ",t),!$(r,t)){r=t;for(let i of s)i(r);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}var Ue,M,ae="@vortex-get-internal",P,E;var C=p(()=>{v();Ue=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let r=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=r},[Symbol.dispose](){e.hookLifetime=r}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},M=class extends R({package:"@vortexjs/core",name:"Lifetime"},Ue){};P=pe,E=R({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});var Be,Je,Ke=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)Je(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=Be(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},Ve=class e{contexts={};streaming=new Ke;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,r){this.contexts[n]=r}static current=null;static setCurrent(n){let r=e.current;return e.current=n,{[Symbol.dispose](){e.current=r}}}},He,x=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(r){if(r instanceof de)for(let s of r.children)n(s);else e.push(r)}for(let r of this.children)n(r);return e}},de,Ze,Qe,Ye,F,Ln,qn,Rn;var G=p(()=>{fe();C();v();v();Be=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),Je=globalThis.clearImmediate??((e)=>{clearTimeout(e)}),He={};ce(He,{FLElement:()=>Qe,FLFragment:()=>de,FLNode:()=>x,FLPortal:()=>Ye,FLText:()=>Ze});de=class extends x{onChildrenChanged(){this.parent?.onChildrenChanged()}},Ze=class extends x{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??y(),e)}constructor(e,n,r,s){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(r,s),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},Qe=class extends x{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??y(),e,n)}constructor(e,n,r){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,r)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??y());this.renderer.setChildren(this.rendererNode??y(),e)}},Ye=class extends x{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??y()))}},F=le({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function r(){var s=typeof SuppressedError=="function"?SuppressedError:function(l,u){var c=Error();return c.name="SuppressedError",c.error=l,c.suppressed=u,c},t={},i=[];function o(l,u){if(u!=null){if(Object(u)!==u)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(l)var c=u[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(c===void 0&&(c=u[Symbol.dispose||Symbol.for("Symbol.dispose")],l))var f=c;if(typeof c!="function")throw new TypeError("Object is not disposable.");f&&(c=function m(){try{f.call(u)}catch(d){return Promise.reject(d)}}),i.push({v:u,d:c,a:l})}else l&&i.push({d:u,a:l});return u}return{e:t,u:o.bind(null,!1),a:o.bind(null,!0),d(){var l,u=this.e,c=0;function f(){for(;l=i.pop();)try{if(!l.a&&c===1)return c=0,i.push(l),Promise.resolve().then(f);if(l.d){var d=l.d.call(l.v);if(l.a)return c|=2,Promise.resolve(d).then(f,m)}else c|=1}catch(T){return m(T)}if(c===1)return u!==t?Promise.reject(u):Promise.resolve();if(u!==t)throw u}function m(d){return u=u!==t?new s(d,u):d,f()}return f()}}}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),Ln=j(F(),1),qn=j(F(),1),Rn=j(F(),1)});function ge(e,n){let r=n.split("/").map((t)=>t.trim()).filter((t)=>t!=="");function s(t,i,o,l){if(t===e.length&&i===r.length)return{matched:!0,params:{...o},spreads:{...l}};if(t===e.length||i>r.length)return{matched:!1};let u=e[t]??y();if(u.type==="static"){if(i>=r.length||r[i]!==u.match)return{matched:!1};return s(t+1,i+1,o,l)}else if(u.type==="slug"){if(i>=r.length)return{matched:!1};let c={...o,[u.name]:r[i]};return s(t+1,i+1,c,l)}else if(u.type==="spread"){for(let c=0;c<=r.length-i;c++){let f={...l,[u.name]:r.slice(i,i+c)},m=s(t+1,i+c,o,f);if(m.matched)return m}return{matched:!1}}return{matched:!1}}return s(0,0,{},{})}var ke=p(()=>{v();G();v()});var be=p(()=>{C()});var we=p(()=>{be()});function _e(e){return async function(n){return await e.impl(n)}}async function Ee(e,n,r){let s=new URL(e.url).pathname;for(let t of n){if(!ge(t.matcher,s).matched)continue;if(t.method!==e.method)continue;let i=(r[t.schema]??y())(),o=(r[t.impl]??y())(),l=e.method==="GET"?new URL(e.url).searchParams.get("props")??"":await e.text(),u;try{u=S.parse(l)}catch{return new Response(["Your API request failed.","Why: The request body is not valid SKL"].join(` +`),{status:400,statusText:"Invalid SKL"})}let f=await(await i)["~standard"].validate(u);if("issues"in f)return new Response(["Your API request failed.","Why: The request body did not match the expected schema"].join(` +`),{status:400,statusText:"Failed to match against schema"});let m=f.value,T=await(await o)(m);return new Response(S.stringify(T))}}var yr;var U=p(()=>{ke();v();G();we();v();yr=P(typeof window!=="undefined"?window.location.href:"/")});function en(e){return{lang:e?.lang??W?.lang,message:e?.message,abortEarly:e?.abortEarly??W?.abortEarly,abortPipeEarly:e?.abortPipeEarly??W?.abortPipeEarly}}function rn(e){return nn?.get(e)}function sn(e){return tn?.get(e)}function on(e,n){return un?.get(e)?.get(n)}function ln(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function X(e,n,r,s,t){let i=t&&"input"in t?t.input:r.value,o=t?.expected??e.expects??null,l=t?.received??ln(i),u={kind:e.kind,type:e.type,input:i,expected:o,received:l,message:`Invalid ${n}: ${o?`Expected ${o} but r`:"R"}eceived ${l}`,requirement:e.requirement,path:t?.path,issues:t?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},c=e.kind==="schema",f=t?.message??e.message??on(e.reference,u.lang)??(c?sn(u.lang):null)??s.message??rn(u.lang);if(f!==void 0)u.message=typeof f==="function"?f(u):f;if(c)r.typed=!1;if(r.issues)r.issues.push(u);else r.issues=[u]}function xe(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},en())}}}function cn(e,n,r){return typeof e.fallback==="function"?e.fallback(n,r):e.fallback}function fn(e,n,r){return typeof e.default==="function"?e.default(n,r):e.default}function N(e){return{kind:"schema",type:"number",reference:N,expects:"number",async:!1,message:e,get "~standard"(){return xe(this)},"~run"(n,r){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else X(this,"type",n,r);return n}}}function B(e,n){return{kind:"schema",type:"object",reference:B,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return xe(this)},"~run"(r,s){let t=r.value;if(t&&typeof t==="object"){r.typed=!0,r.value={};for(let i in this.entries){let o=this.entries[i];if(i in t||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){let l=i in t?t[i]:fn(o),u=o["~run"]({value:l},s);if(u.issues){let c={type:"object",origin:"value",input:t,key:i,value:l};for(let f of u.issues){if(f.path)f.path.unshift(c);else f.path=[c];r.issues?.push(f)}if(!r.issues)r.issues=u.issues;if(s.abortEarly){r.typed=!1;break}}if(!u.typed)r.typed=!1;r.value[i]=u.value}else if(o.fallback!==void 0)r.value[i]=cn(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"){if(X(this,"key",r,s,{input:void 0,expected:`"${i}"`,path:[{type:"object",origin:"key",input:t,key:i,value:t[i]}]}),s.abortEarly)break}}}else X(this,"type",r,s);return r}}}var W,nn,tn,un;var $e=()=>{};var Ae=p(()=>{C()});var J=p(()=>{Ae()});var wr,K=function({a:e,b:n}){return e+n},V;var H=p(()=>{$e();U();J();wr=_e({schema:V,impl:K,endpoint:"/api/add",method:"GET",isQuery:!0}),V=B({a:N(),b:N()})});var Ie={};Z(Ie,{$d_1395_1435:()=>K});var De=p(()=>{H()});var Se={};Z(Se,{$d_1323_1385:()=>V});var Oe=p(()=>{H()});U();var pn=[{matcher:[{type:"static",match:"api"},{type:"static",match:"add"}],impl:0,schema:1,method:"GET"}],yn=[async()=>(await Promise.resolve().then(() => (De(),Ie))).$d_1395_1435,async()=>(await Promise.resolve().then(() => (Oe(),Se))).$d_1323_1385];async function hn(e){return await Ee(e,pn,yn)||new Response("Not Found",{status:404})}export{hn as default}; diff --git a/packages/example-wormhole/.vercel/output/functions/index.func/.vc-config.json b/packages/example-wormhole/.vercel/output/functions/index.func/.vc-config.json new file mode 100644 index 0000000..bd4af02 --- /dev/null +++ b/packages/example-wormhole/.vercel/output/functions/index.func/.vc-config.json @@ -0,0 +1,4 @@ +{ + "runtime": "edge", + "entrypoint": "index.js" +} \ No newline at end of file diff --git a/packages/example-wormhole/.vercel/output/functions/index.func/index.js b/packages/example-wormhole/.vercel/output/functions/index.func/index.js new file mode 100644 index 0000000..64250fa --- /dev/null +++ b/packages/example-wormhole/.vercel/output/functions/index.func/index.js @@ -0,0 +1,8 @@ +// @bun +var En=Object.defineProperty;var C=(e,n)=>{for(var t in n)En(e,t,{get:n[t],enumerable:!0,configurable:!0,set:(i)=>n[t]=()=>i})};var v=(e,n)=>()=>(e&&(n=e(e=0)),n);var $n,$e=(e,n)=>{for(var t in n)$n(e,t,{get:n[t],enumerable:!0})};var Ae=v(()=>{$n=Object.defineProperty});function Ie(e){return typeof e==="object"&&e!==null&&typeof e.then==="function"}function J(e,n){if(e===n)return!0;if(typeof e!==typeof n)return!1;if(Array.isArray(e)!==Array.isArray(n))return!1;if(Ie(e)||Ie(n))return!1;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let t=0;t="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}function B(e){return e>="0"&&e<="9"}function Oe(e){return H(e)||B(e)}function*Ne(e){let n=0,t=()=>e[n]??"",i=()=>e[n++]??"",r=()=>{n++};while(n=e.tokens.length)return null;return e.tokens[e.current++]??null}function X(e){if(e.current>=e.tokens.length)return null;return e.tokens[e.current]??null}function j(e){let n=X(e);if(n!==null)e.current++;return n}function K(e){let n=j(e);if(n===null)throw new Error("Unexpected end of input");if(n[0]==="number")return n[1];if(n[0]==="string")return n[1];if(n[0]==="keyword"){if(n[1]===S.null)return null;if(n[1]===S.undefined)return;if(n[1]===S.true)return!0;if(n[1]===S.false)return!1;throw new Error(`Unexpected keyword: ${n[1]}`)}let t=null;if(n[0]==="identifier")t=n[1],n=j(e);if(n===null)throw new Error("Unexpected end of input (after reading class)");if(n[0]==="symbol"&&n[1]==="LeftParenthesis"){let i={};while(!0){let r=j(e);if(r===null)throw new Error("Unexpected end of input (when trying to read key)");if(r[0]==="symbol"&&r[1]==="RightParenthesis")break;if(r[0]!=="identifier"&&r[0]!=="string")throw new Error(`Expected identifier or string, got ${r[0]}`);let u=j(e);if(u===null||u[0]!=="symbol"||u[1]!=="Equals")throw new Error(`Expected '=', got ${u?u[0]:"end of input"}`);let s=r[1],l=K(e);i[s]=l}if(t!==null){if(t==="date")return new Date(i.unix);if(t==="set")return new Set(i.items);if(t==="map"){let r=new Map;for(let[u,s]of i.entries)r.set(u,s);return r}throw new Error(`Unknown class: ${t}`)}return i}if(n[0]==="symbol"&&n[1]==="LeftSquareBracket"){let i=[];while(!0){if(X(e)?.[0]==="symbol"&&X(e)?.[1]==="RightSquareBracket"){j(e);break}let r=K(e);i.push(r)}return i}}function In(e){let n=[...Ne(e)],t=De(n),i=K(t);if(t.currentr[0]).join(", ")}`);return i}function Ce(){return{output:"",indentLevel:0,minified:!1}}function q(e){e.indentLevel++}function R(e){e.indentLevel=Math.max(0,e.indentLevel-1)}function _(e){if(e.minified){h(e," ");return}h(e,` +`),h(e," ".repeat(e.indentLevel))}function h(e,n){e.output+=n}function ue(e){let n=Number.POSITIVE_INFINITY,t="";for(let i of['"',"'","`"]){let r="";r+=i;for(let u of e)if(u===i)r+=`\\${u}`;else if(u==="\\")r+="\\\\";else if(u===` +`)r+="\\n";else if(u==="\t")r+="\\t";else if(u==="\r")r+="\\r";else r+=u;if(r+=i,r.length{Ae();V={};$e(V,{escapeStr:()=>ue,isAlphabetic:()=>H,isAlphanumeric:()=>Oe,isNumeric:()=>B,isWhitespace:()=>Se,keywords:()=>S,lex:()=>Ne,parse:()=>In,parseContext_create:()=>De,parseContext_next:()=>An,parseContext_peek:()=>X,parseContext_read:()=>j,parseContext_readObj:()=>K,serialize:()=>je,serializeContext_create:()=>Ce,serializeContext_dedent:()=>R,serializeContext_indent:()=>q,serializeContext_newline:()=>_,serializeContext_write:()=>h,serializeContext_writeObject:()=>T,stringify:()=>Sn,symbols:()=>se});S={null:"Null",true:"True",false:"False",undefined:"Undefined"},se={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};Sn=je});var Dn,ce,Cn,Pe,jn,Tn,Le=(e,n)=>function(){return n||(0,e[Pe(e)[0]])((n={exports:{}}).exports,n),n.exports},qe=(e,n)=>{for(var t in n)ce(e,t,{get:n[t],enumerable:!0})},Pn=(e,n,t,i)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var r=Pe(n),u=0,s=r.length,l;un[o]).bind(null,l),enumerable:!(i=Cn(n,l))||i.enumerable})}return e},Z=(e,n,t)=>(t=e!=null?Dn(jn(e)):{},Pn(n||!e||!e.__esModule?ce(t,"default",{value:e,enumerable:!0}):t,e));var Re=v(()=>{Dn=Object.create,ce=Object.defineProperty,Cn=Object.getOwnPropertyDescriptor,Pe=Object.getOwnPropertyNames,jn=Object.getPrototypeOf,Tn=Object.prototype.hasOwnProperty});function Y(){if(d.hookLifetime===null)throw new Error("No hook lifetime available");return d.hookLifetime}function z(e){let n,t=e,i=[];return n&&console.log(`[${n}]: initialized with `,t),{setId(r){n=r},[E](){return t},subscribe(r,u){if(i.push(r),n&&console.trace(`[${n}]: subscribed with `,r),u?.callInitially!==!1)r(t);return new d().onClosed(()=>{i.splice(i.indexOf(r),1),n&&console.log(`[${n}]: unsubscribed `,r)})},set(r){if(n&&console.log(`[${n}]: trying to switch from `,t," -> ",r),!J(t,r)){t=r;for(let u of i)u(t);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}function P(e){return e[E]()}function fe(e,n,t=Y()){let i=n?.dynamic??!1,r=[],u=z(e((o)=>{if(!r.includes(o))r.push(o);return o[E]()}));function s(){if(i){let o=new Set(r);u.set(e((p)=>{return o.add(p),p[E]()}));let c=new Set(r),a=c.difference(o);for(let p of a){let y=r.indexOf(p);if(y!==-1)r.splice(y,1),l[y]?.close(),l.splice(y,1)}let f=o.difference(c);for(let p of f){let y=p.subscribe(()=>{s()},{callInitially:!1});r.push(p),l.push(y)}}else u.set(e(P))}let l=r.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(t)});return{...u}}function pe(e,n,t=Y()){let i=n?.dynamic??!1,r=[],u=new d;e((o)=>{if(!r.includes(o))r.push(o);return o[E]()},{lifetime:u});function s(){if(i){let o=new Set(r);u.close(),u=new d().cascadesFrom(t),e((p)=>{return o.add(p),p[E]()},{lifetime:u});let c=new Set(r),a=c.difference(o);for(let p of a){let y=r.indexOf(p);if(y!==-1)r.splice(y,1),l[y]?.close(),l.splice(y,1)}let f=o.difference(c);for(let p of f){let y=p.subscribe(()=>{s()},{callInitially:!1});r.push(p),l.push(y)}}else u.close(),u=new d().cascadesFrom(t),e(P,{lifetime:u})}let l=r.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(t)})}function M(e){return typeof e==="object"&&e!==null&&E in e}function ae(e){if(M(e))return e;return z(e)}function ye(e,n=Y()){return fe((t)=>{function i(r){if(M(r))return i(t(r));return r}return i(e)},{dynamic:!0},n)}function A(e){if(e===void 0)return[];return[e].flat().filter((n)=>n!==null&&n!==void 0).map((n)=>typeof n==="string"||typeof n==="number"||typeof n==="boolean"?Q(n):M(n)?{type:"dynamic",value:$((t)=>{let i=t(n);return typeof i==="number"||typeof i==="string"||typeof i==="boolean"?Q(i):i})}:n)}function Q(e,n){return{type:"text",value:e,...n}}function F(e,n,t,i){let r=A(t).map((a)=>{if(typeof a==="string"||typeof a==="number"||typeof a==="boolean")return Q(a);return a}),u={},s={},l={},o=[],c={};for(let[a,f]of Object.entries(n))if(f!==void 0)if(a.startsWith("bind:")){let p=a.slice(5);if(!M(f)||!("set"in f))throw new Error(`Binding value for "${p}" must be a writable store.`);s[p]=f}else if(a.startsWith("on:")){let p=a.slice(3);if(typeof f!=="function")throw new Error(`Event handler for "${p}" must be a function.`);l[p]=f}else if(a==="use"){if(typeof f!=="function"&&!Array.isArray(f))throw new Error("Use hook must be a function or an array of functions.");o.push(f)}else if(a==="style"){for(let[p,y]of Object.entries(f))if(y!==void 0)c[p]=ae(y)}else u[a]=ae(f);return{type:"element",name:e,attributes:u,children:r,bindings:s,eventHandlers:l,use:o,styles:c}}var Ln,d,E="@vortex-get-internal",L,$,k;var ee=v(()=>{w();Ln=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let t=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=t},[Symbol.dispose](){e.hookLifetime=t}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},d=class extends le({package:"@vortexjs/core",name:"Lifetime"},Ln){};L=z,$=fe;k=le({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});function Mn(){let e=N.current;if(!e)throw new Error("No context scope found, you should have one if you're rendering a component.");return e}function Fe(){return Mn().streaming}function Fn(){let e=N.current;if(!e)return null;return e}function Gn(){let e=Fn();if(!e)return null;return e.streaming}function Me({renderer:e,root:n,component:t,context:i}){try{var r=(0,Jn.default)();r.u(oe("Initial page render"));let u=new Wn(e,n),s=new d,l=u.render({node:t,hydration:e.getHydrationContext(n),lt:s,context:i??N.current??new N}),o=new We(n,e);return o.children=[l],s}catch(u){r.e=u}finally{r.d()}}function Je(e,n,t){if("renderer"in e)return Me(e);else return Me({renderer:e,root:n,component:t})}function Be(){let e=Gn();return(n)=>{let t=L(void 0);async function i(){if(e)try{var r=(0,Bn.default)();r.u(e.markLoading()),t.set(await n)}catch(u){r.e=u}finally{r.d()}else t.set(await n)}return i(),t}}var qn,Rn,zn=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)Rn(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=qn(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},N=class e{contexts={};streaming=new zn;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,t){this.contexts[n]=t}static current=null;static setCurrent(n){let t=e.current;return e.current=n,{[Symbol.dispose](){e.current=t}}}},ze="~vortex:intrinsic",Un,G=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(t){if(t instanceof O)for(let i of t.children)n(i);else e.push(t)}for(let t of this.children)n(t);return e}},O,Ge,Ue,We,ve,he,Wn=class{constructor(e,n){this.renderer=e,this.root=n}render({node:e,hydration:n,lt:t,context:i}){if(e===void 0||e===null)return new O;if(Array.isArray(e))return this.render({node:{type:"fragment",children:e},hydration:n,lt:t,context:i});switch(e.type){case"fragment":{let s=new O;return s.children=e.children.map((l)=>this.render({node:l,hydration:n,lt:t,context:i})),s}case"text":return new Ge(e.value.toString(),this.renderer,n,i);case"element":{let s=new Ue(e.name,this.renderer,n),l=this.renderer.getHydrationContext(s.rendererNode??m());s.children=e.children.map((c)=>this.render({node:c,hydration:l,lt:t,context:i}));for(let[c,a]of Object.entries(e.attributes))a.subscribe((f)=>{s.setAttribute(c,f)}).cascadesFrom(t);for(let[c,a]of Object.entries(e.bindings))this.renderer.bindValue(s.rendererNode??m(),c,a).cascadesFrom(t);for(let[c,a]of Object.entries(e.eventHandlers))this.renderer.addEventListener(s.rendererNode??m(),c,a).cascadesFrom(t);for(let[c,a]of Object.entries(e.styles))a.subscribe((f)=>{this.renderer.setStyle(s.rendererNode??m(),c,f)}).cascadesFrom(t);let o=[e.use].flat();for(let c of o)c(s.rendererNode??m());return s}case"component":try{var r=(0,he.default)();r.u(d.changeHookLifetime(t)),r.u(N.setCurrent(i)),r.u(oe(`Rendering ${e.impl.name}`));let s=e.impl;if(ze in s&&typeof s[ze]==="string"){let o=this.renderer.implementations?.find((c)=>c.intrinsic===s);if(o)s=o.implementation}let l=s(e.props);return this.render({node:l,hydration:n,lt:t,context:i})}catch(s){r.e=s}finally{r.d()}case"dynamic":{let s=new O;return pe((l,{lifetime:o})=>{let c=this.render({node:l(e.value),hydration:n,lt:o,context:i});s.children=[c]},void 0,t),s}case"list":{new O;let s=new Map,l=new O,o="";return pe((c)=>{let a=c(e.items),f=a.map((b,I)=>e.getKey(b,I));for(let b of s.keys())if(!f.includes(b))(s.get(b)??m()).lifetime.close(),s.delete(b);for(let b of f)if(!s.has(b))try{var p=(0,he.default)();let I=a[f.indexOf(b)],_n=z(I),ie=new d;p.u(d.changeHookLifetime(ie));let xn=this.render({node:e.renderItem(I,f.indexOf(b)),hydration:n,lt:ie,context:i});s.set(b,{node:xn,item:_n,lifetime:ie})}catch(I){p.e=I}finally{p.d()}let y=f.join("|||");if(y!==o)o=y,l.children=f.map((b)=>(s.get(b)??m()).node)}),l}case"context":try{var u=(0,he.default)();let s=i.fork();return u.u(N.setCurrent(s)),s.addContext(e.id,e.value),this.render({node:e.children,hydration:n,lt:t,context:s})}catch(s){u.e=s}finally{u.d()}default:Te(e,`No rendering implementation for ${JSON.stringify(e)}`)}}},Jn,Bn;var U=v(()=>{Re();ee();w();w();qn=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),Rn=globalThis.clearImmediate??((e)=>{clearTimeout(e)});Un={};qe(Un,{FLElement:()=>Ue,FLFragment:()=>O,FLNode:()=>G,FLPortal:()=>We,FLText:()=>Ge});O=class extends G{onChildrenChanged(){this.parent?.onChildrenChanged()}},Ge=class extends G{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??m(),e)}constructor(e,n,t,i){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(t,i),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},Ue=class extends G{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??m(),e,n)}constructor(e,n,t){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,t)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??m());this.renderer.setChildren(this.rendererNode??m(),e)}},We=class extends G{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??m()))}},ve=Le({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function t(){var i=typeof SuppressedError=="function"?SuppressedError:function(l,o){var c=Error();return c.name="SuppressedError",c.error=l,c.suppressed=o,c},r={},u=[];function s(l,o){if(o!=null){if(Object(o)!==o)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(l)var c=o[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(c===void 0&&(c=o[Symbol.dispose||Symbol.for("Symbol.dispose")],l))var a=c;if(typeof c!="function")throw new TypeError("Object is not disposable.");a&&(c=function f(){try{a.call(o)}catch(p){return Promise.reject(p)}}),u.push({v:o,d:c,a:l})}else l&&u.push({d:o,a:l});return o}return{e:r,u:s.bind(null,!1),a:s.bind(null,!0),d(){var l,o=this.e,c=0;function a(){for(;l=u.pop();)try{if(!l.a&&c===1)return c=0,u.push(l),Promise.resolve().then(a);if(l.d){var p=l.d.call(l.v);if(l.a)return c|=2,Promise.resolve(p).then(a,f)}else c|=1}catch(y){return f(y)}if(c===1)return o!==r?Promise.reject(o):Promise.resolve();if(o!==r)throw o}function f(p){return o=o!==r?new i(p,o):p,a()}return a()}}}n.exports=t,n.exports.__esModule=!0,n.exports.default=n.exports}}),he=Z(ve(),1),Jn=Z(ve(),1);Bn=Z(ve(),1)});function ne(e,n){let t=n.split("/").map((r)=>r.trim()).filter((r)=>r!=="");function i(r,u,s,l){if(r===e.length&&u===t.length)return{matched:!0,params:{...s},spreads:{...l}};if(r===e.length||u>t.length)return{matched:!1};let o=e[r]??m();if(o.type==="static"){if(u>=t.length||t[u]!==o.match)return{matched:!1};return i(r+1,u+1,s,l)}else if(o.type==="slug"){if(u>=t.length)return{matched:!1};let c={...s,[o.name]:t[u]};return i(r+1,u+1,c,l)}else if(o.type==="spread"){for(let c=0;c<=t.length-u;c++){let a={...l,[o.name]:t.slice(u,u+c)},f=i(r+1,u+c,s,a);if(f.matched)return f}return{matched:!1}}return{matched:!1}}return i(0,0,{},{})}var Xe=v(()=>{w();U();w()});function x(e,n){let{children:t,...i}=n||{};if(e===k)return{type:"fragment",children:A(t)};if(typeof e==="string")return F(e,i,t);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:A(t)}};throw new Error(`Invalid JSX type: ${e}`)}var de;var Ke=v(()=>{ee();de=x});var Ve=v(()=>{Ke()});function Xn(){return $((e)=>{return new URL(e(W)).pathname})}function Kn(){if(typeof window==="undefined")return;W.subscribe((e)=>{if(window.location.href!==e)window.history.pushState({},"",e)},{callInitially:!1}),window.addEventListener("popstate",()=>{W.set(window.location.href)}),document.addEventListener("click",(e)=>{let t=e.composedPath().find((i)=>i instanceof HTMLAnchorElement);if(t?.href){let i=new URL(t.href,P(W));if(i.origin!==window.location.origin)return;e.preventDefault(),W.set(i.href)}})}function Vn({pathname:e,props:n,loaders:t}){if("location"in globalThis)Kn();Fe();let i=Be(),r=e?L(e):Xn(),u=$((c)=>{let a=c(r);return n.routes.find((f)=>ne(f.matcher,a))}),s=$(async(c)=>{let a=c(u)??m(),f=[];for(let p of a.frames)f.push(await(t[p.index]??m())());return f}),l=ye($((c)=>{return i(c(s))})),o=$((c)=>{let a=x(k,{}),f=c(l);if(!f)return x("h1",{children:"loading"});for(let p of f.toReversed())a=x(p,{children:a});return a});return de("html",{children:[de("head",{children:[x("link",{rel:"stylesheet",href:"/styles.css"}),x("script",{src:"/entrypoint-client.js",type:"module"})]}),x("body",{children:o})]})}async function He({props:e,loaders:n,renderer:t,root:i,pathname:r,lifetime:u=new d,context:s}){e:if("window"in globalThis){let l=r??window.location.pathname,o=e.routes.find((c)=>ne(c.matcher,l));if(!o)break e;for(let c of o.frames)await(n[c.index]??m())()}Je({context:s,renderer:t,root:i,component:x(Vn,{pathname:r,props:e,loaders:n})}).cascadesFrom(u)}function Ze(e){return async function(n){return await e.impl(n)}}async function Qe(e,n,t){let i=new URL(e.url).pathname;for(let r of n){if(!ne(r.matcher,i).matched)continue;if(r.method!==e.method)continue;let u=(t[r.schema]??m())(),s=(t[r.impl]??m())(),l=e.method==="GET"?new URL(e.url).searchParams.get("props")??"":await e.text(),o;try{o=V.parse(l)}catch{return new Response(["Your API request failed.","Why: The request body is not valid SKL"].join(` +`),{status:400,statusText:"Invalid SKL"})}let a=await(await u)["~standard"].validate(o);if("issues"in a)return new Response(["Your API request failed.","Why: The request body did not match the expected schema"].join(` +`),{status:400,statusText:"Failed to match against schema"});let f=a.value,y=await(await s)(f);return new Response(V.stringify(y))}}var W;var te=v(()=>{Xe();w();U();Ve();w();W=L(typeof window!=="undefined"?window.location.href:"/")});function Yn(e){return{lang:e?.lang??be?.lang,message:e?.message,abortEarly:e?.abortEarly??be?.abortEarly,abortPipeEarly:e?.abortPipeEarly??be?.abortPipeEarly}}function nt(e){return et?.get(e)}function rt(e){return tt?.get(e)}function st(e,n){return it?.get(e)?.get(n)}function ut(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function ke(e,n,t,i,r){let u=r&&"input"in r?r.input:t.value,s=r?.expected??e.expects??null,l=r?.received??ut(u),o={kind:e.kind,type:e.type,input:u,expected:s,received:l,message:`Invalid ${n}: ${s?`Expected ${s} but r`:"R"}eceived ${l}`,requirement:e.requirement,path:r?.path,issues:r?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},c=e.kind==="schema",a=r?.message??e.message??st(e.reference,o.lang)??(c?rt(o.lang):null)??i.message??nt(o.lang);if(a!==void 0)o.message=typeof a==="function"?a(o):a;if(c)t.typed=!1;if(t.issues)t.issues.push(o);else t.issues=[o]}function tn(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Yn())}}}function ot(e,n,t){return typeof e.fallback==="function"?e.fallback(n,t):e.fallback}function lt(e,n,t){return typeof e.default==="function"?e.default(n,t):e.default}function re(e){return{kind:"schema",type:"number",reference:re,expects:"number",async:!1,message:e,get "~standard"(){return tn(this)},"~run"(n,t){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else ke(this,"type",n,t);return n}}}function we(e,n){return{kind:"schema",type:"object",reference:we,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return tn(this)},"~run"(t,i){let r=t.value;if(r&&typeof r==="object"){t.typed=!0,t.value={};for(let u in this.entries){let s=this.entries[u];if(u in r||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){let l=u in r?r[u]:lt(s),o=s["~run"]({value:l},i);if(o.issues){let c={type:"object",origin:"value",input:r,key:u,value:l};for(let a of o.issues){if(a.path)a.path.unshift(c);else a.path=[c];t.issues?.push(a)}if(!t.issues)t.issues=o.issues;if(i.abortEarly){t.typed=!1;break}}if(!o.typed)t.typed=!1;t.value[u]=o.value}else if(s.fallback!==void 0)t.value[u]=ot(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"){if(ke(this,"key",t,i,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:r,key:u,value:r[u]}]}),i.abortEarly)break}}}else ke(this,"type",t,i);return t}}}var be,et,tt,it;var rn=()=>{};function g(e,n,t,i,r,u){let{children:s,...l}=n||{};if(e===k)return{type:"fragment",children:A(s),...r};if(typeof e==="string")return F(e,l,s,r);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:A(s)},...r};throw new Error(`Invalid JSX type: ${e}`)}var sn=v(()=>{ee()});var _e=v(()=>{sn()});var at,un=function(){return g(k,{children:[g("h1",{class:"text-4xl font-bold",children:["Welcome to Wormhole, ",Object.entries(globalThis).length]},void 0,!0,void 0,this),g("p",{children:["This is an example app, go to the"," ",g("a",{href:"/docs/tada",children:"docs"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),g("button",{"on:click":async()=>{console.log(await at({a:1,b:2}))},children:"add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},on=function({children:e}){return g(k,{children:[g("title",{children:"Wormhole Example"},void 0,!1,void 0,this),e]},void 0,!0,void 0,this)},ln=function(){return g(k,{children:g("h1",{children:"404 not found"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},cn=function({page:e}){return g(k,{children:[g("h1",{children:["Documentation for ",e.join(", ")]},void 0,!0,void 0,this),g("p",{children:["This is the documentation page for ",e.join(", "),"."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},xe=function({a:e,b:n}){return e+n},Ee;var D=v(()=>{rn();te();_e();at=Ze({schema:Ee,impl:xe,endpoint:"/api/add",method:"GET",isQuery:!0}),Ee=we({a:re(),b:re()})});var an={};C(an,{$d_109_720:()=>un});var fn=v(()=>{D()});var pn={};C(pn,{$d_732_888:()=>on});var yn=v(()=>{D()});var hn={};C(hn,{$d_1050_1265:()=>cn});var mn=v(()=>{D()});var vn={};C(vn,{$d_902_1009:()=>ln});var dn=v(()=>{D()});var gn={};C(gn,{$d_1395_1435:()=>xe});var bn=v(()=>{D()});var kn={};C(kn,{$d_1323_1385:()=>Ee});var wn=v(()=>{D()});te();U();w();U();w();function Hn(e){return"tagName"in e?e.tagName:"Text"}function Zn(){return{html:"",write(e){this.html+=e},lastType:""}}function Ye(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function ge(e,n=Zn()){let t=Hn(e);if(t==="Text"&&n.lastType==="Text")n.write("");if(n.lastType=t,"tagName"in e){n.write("<"),n.write(e.tagName);for(let[i,r]of Object.entries(e.attributes)){if(r===void 0)continue;n.write(` ${i}="${Ye(r)}"`)}n.write(">");for(let i of e.children)ge(i,n);n.write("")}if("content"in e)n.write(Ye(e.content.toString()));return n.html}function Qn(e){return e.split(/(?=[A-Z])/).map((t)=>t.toLowerCase()).join("-")}function en(){return{createNode(e,n){return{tagName:e,attributes:{},children:[],parent:void 0}},setAttribute(e,n,t){if(!("tagName"in e))throw new Error("Cannot set attribute on a text node");e.attributes[n]=t},createTextNode(e){return{content:"",parent:void 0}},setTextContent(e,n){if(!("content"in e))throw new Error("Cannot set text content on a non-text node");e.content=n},setChildren(e,n){if(!("children"in e))throw new Error("Cannot set children on a text node");e.children=n;for(let t of n)t.parent=e},getHydrationContext(e){return},addEventListener(e,n,t){return new d},bindValue(e,n,t){return new d},setStyle(e,n,t){if(!("attributes"in e))throw new Error("Cannot set style on a text node");let i=e.attributes.style??"";i+=`${Qn(n)}: ${t};`,e.attributes.style=i}}}function nn(){return{tagName:"html",attributes:{},children:[],parent:void 0,fixedIdent:"document.documentElement"}}te();var ft=JSON.parse('{"routes":[{"matcher":[],"frames":[{"index":0}],"is404":false},{"matcher":[{"type":"static","match":"docs"},{"type":"spread","name":"page"}],"frames":[{"index":1},{"index":2}],"is404":false},{"matcher":[{"type":"spread","name":"404"}],"frames":[{"index":1},{"index":3}],"is404":true}]}'),pt=[async()=>(await Promise.resolve().then(() => (fn(),an))).$d_109_720,async()=>(await Promise.resolve().then(() => (yn(),pn))).$d_732_888,async()=>(await Promise.resolve().then(() => (mn(),hn))).$d_1050_1265,async()=>(await Promise.resolve().then(() => (dn(),vn))).$d_902_1009],yt=[{matcher:[{type:"static",match:"api"},{type:"static",match:"add"}],impl:0,schema:1,method:"GET"}],ht=[async()=>(await Promise.resolve().then(() => (bn(),gn))).$d_1395_1435,async()=>(await Promise.resolve().then(() => (wn(),kn))).$d_1323_1385];async function mt(e){let t=new URL(e.url).pathname,i=await Qe(e,yt,ht);if(i)return i;let r=en(),u=nn(),s=new d;try{await He({props:ft,loaders:pt,renderer:r,root:u,pathname:t,context:{},lifetime:s});let l=ge(u);return new Response(l,{status:200,headers:{"Content-Type":"text/html"}})}catch(l){return console.error("Rendering error:",l),new Response("Internal Server Error",{status:500})}finally{s.close()}}export{mt as default}; diff --git a/packages/example-wormhole/.vercel/output/functions/route-[...404].func/.vc-config.json b/packages/example-wormhole/.vercel/output/functions/route-[...404].func/.vc-config.json new file mode 100644 index 0000000..bd4af02 --- /dev/null +++ b/packages/example-wormhole/.vercel/output/functions/route-[...404].func/.vc-config.json @@ -0,0 +1,4 @@ +{ + "runtime": "edge", + "entrypoint": "index.js" +} \ No newline at end of file diff --git a/packages/example-wormhole/.vercel/output/functions/route-[...404].func/index.js b/packages/example-wormhole/.vercel/output/functions/route-[...404].func/index.js new file mode 100644 index 0000000..16974ab --- /dev/null +++ b/packages/example-wormhole/.vercel/output/functions/route-[...404].func/index.js @@ -0,0 +1,6 @@ +// @bun +var fn=Object.defineProperty;var we=(e,n)=>{for(var r in n)fn(e,r,{get:n[r],enumerable:!0,configurable:!0,set:(i)=>n[r]=()=>i})};var d=(e,n)=>()=>(e&&(n=e(e=0)),n);var pn,xe=(e,n)=>{for(var r in n)pn(e,r,{get:n[r],enumerable:!0})};var _e=d(()=>{pn=Object.defineProperty});function Ee(e){return typeof e==="object"&&e!==null&&typeof e.then==="function"}function U(e,n){if(e===n)return!0;if(typeof e!==typeof n)return!1;if(Array.isArray(e)!==Array.isArray(n))return!1;if(Ee(e)||Ee(n))return!1;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let r=0;r="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}function W(e){return e>="0"&&e<="9"}function Ie(e){return X(e)||W(e)}function*Se(e){let n=0,r=()=>e[n]??"",i=()=>e[n++]??"",t=()=>{n++};while(n=e.tokens.length)return null;return e.tokens[e.current++]??null}function J(e){if(e.current>=e.tokens.length)return null;return e.tokens[e.current]??null}function N(e){let n=J(e);if(n!==null)e.current++;return n}function B(e){let n=N(e);if(n===null)throw new Error("Unexpected end of input");if(n[0]==="number")return n[1];if(n[0]==="string")return n[1];if(n[0]==="keyword"){if(n[1]===I.null)return null;if(n[1]===I.undefined)return;if(n[1]===I.true)return!0;if(n[1]===I.false)return!1;throw new Error(`Unexpected keyword: ${n[1]}`)}let r=null;if(n[0]==="identifier")r=n[1],n=N(e);if(n===null)throw new Error("Unexpected end of input (after reading class)");if(n[0]==="symbol"&&n[1]==="LeftParenthesis"){let i={};while(!0){let t=N(e);if(t===null)throw new Error("Unexpected end of input (when trying to read key)");if(t[0]==="symbol"&&t[1]==="RightParenthesis")break;if(t[0]!=="identifier"&&t[0]!=="string")throw new Error(`Expected identifier or string, got ${t[0]}`);let u=N(e);if(u===null||u[0]!=="symbol"||u[1]!=="Equals")throw new Error(`Expected '=', got ${u?u[0]:"end of input"}`);let s=t[1],c=B(e);i[s]=c}if(r!==null){if(r==="date")return new Date(i.unix);if(r==="set")return new Set(i.items);if(r==="map"){let t=new Map;for(let[u,s]of i.entries)t.set(u,s);return t}throw new Error(`Unknown class: ${r}`)}return i}if(n[0]==="symbol"&&n[1]==="LeftSquareBracket"){let i=[];while(!0){if(J(e)?.[0]==="symbol"&&J(e)?.[1]==="RightSquareBracket"){N(e);break}let t=B(e);i.push(t)}return i}}function hn(e){let n=[...Se(e)],r=Oe(n),i=B(r);if(r.currentt[0]).join(", ")}`);return i}function Ne(){return{output:"",indentLevel:0,minified:!1}}function T(e){e.indentLevel++}function P(e){e.indentLevel=Math.max(0,e.indentLevel-1)}function w(e){if(e.minified){y(e," ");return}y(e,` +`),y(e," ".repeat(e.indentLevel))}function y(e,n){e.output+=n}function ne(e){let n=Number.POSITIVE_INFINITY,r="";for(let i of['"',"'","`"]){let t="";t+=i;for(let u of e)if(u===i)t+=`\\${u}`;else if(u==="\\")t+="\\\\";else if(u===` +`)t+="\\n";else if(u==="\t")t+="\\t";else if(u==="\r")t+="\\r";else t+=u;if(t+=i,t.length{_e();$e={};xe($e,{escapeStr:()=>ne,isAlphabetic:()=>X,isAlphanumeric:()=>Ie,isNumeric:()=>W,isWhitespace:()=>Ae,keywords:()=>I,lex:()=>Se,parse:()=>hn,parseContext_create:()=>Oe,parseContext_next:()=>yn,parseContext_peek:()=>J,parseContext_read:()=>N,parseContext_readObj:()=>B,serialize:()=>De,serializeContext_create:()=>Ne,serializeContext_dedent:()=>P,serializeContext_indent:()=>T,serializeContext_newline:()=>w,serializeContext_write:()=>y,serializeContext_writeObject:()=>D,stringify:()=>mn,symbols:()=>ee});I={null:"Null",true:"True",false:"False",undefined:"Undefined"},ee={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};mn=De});var gn,ie,bn,je,kn,wn,Te=(e,n)=>function(){return n||(0,e[je(e)[0]])((n={exports:{}}).exports,n),n.exports},Pe=(e,n)=>{for(var r in n)ie(e,r,{get:n[r],enumerable:!0})},xn=(e,n,r,i)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var t=je(n),u=0,s=t.length,c;un[o]).bind(null,c),enumerable:!(i=bn(n,c))||i.enumerable})}return e},K=(e,n,r)=>(r=e!=null?gn(kn(e)):{},xn(n||!e||!e.__esModule?ie(r,"default",{value:e,enumerable:!0}):r,e));var Le=d(()=>{gn=Object.create,ie=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,je=Object.getOwnPropertyNames,kn=Object.getPrototypeOf,wn=Object.prototype.hasOwnProperty});function H(){if(v.hookLifetime===null)throw new Error("No hook lifetime available");return v.hookLifetime}function L(e){let n,r=e,i=[];return n&&console.log(`[${n}]: initialized with `,r),{setId(t){n=t},[_](){return r},subscribe(t,u){if(i.push(t),n&&console.trace(`[${n}]: subscribed with `,t),u?.callInitially!==!1)t(r);return new v().onClosed(()=>{i.splice(i.indexOf(t),1),n&&console.log(`[${n}]: unsubscribed `,t)})},set(t){if(n&&console.log(`[${n}]: trying to switch from `,r," -> ",t),!U(r,t)){r=t;for(let u of i)u(r);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}function C(e){return e[_]()}function ue(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=L(e((o)=>{if(!t.includes(o))t.push(o);return o[_]()}));function s(){if(i){let o=new Set(t);u.set(e((p)=>{return o.add(p),p[_]()}));let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.set(e(C))}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)});return{...u}}function oe(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=new v;e((o)=>{if(!t.includes(o))t.push(o);return o[_]()},{lifetime:u});function s(){if(i){let o=new Set(t);u.close(),u=new v().cascadesFrom(r),e((p)=>{return o.add(p),p[_]()},{lifetime:u});let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.close(),u=new v().cascadesFrom(r),e(C,{lifetime:u})}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)})}function R(e){return typeof e==="object"&&e!==null&&_ in e}function se(e){if(R(e))return e;return L(e)}function le(e,n=H()){return ue((r)=>{function i(t){if(R(t))return i(r(t));return t}return i(e)},{dynamic:!0},n)}function $(e){if(e===void 0)return[];return[e].flat().filter((n)=>n!==null&&n!==void 0).map((n)=>typeof n==="string"||typeof n==="number"||typeof n==="boolean"?V(n):R(n)?{type:"dynamic",value:E((r)=>{let i=r(n);return typeof i==="number"||typeof i==="string"||typeof i==="boolean"?V(i):i})}:n)}function V(e,n){return{type:"text",value:e,...n}}function q(e,n,r,i){let t=$(r).map((a)=>{if(typeof a==="string"||typeof a==="number"||typeof a==="boolean")return V(a);return a}),u={},s={},c={},o=[],l={};for(let[a,f]of Object.entries(n))if(f!==void 0)if(a.startsWith("bind:")){let p=a.slice(5);if(!R(f)||!("set"in f))throw new Error(`Binding value for "${p}" must be a writable store.`);s[p]=f}else if(a.startsWith("on:")){let p=a.slice(3);if(typeof f!=="function")throw new Error(`Event handler for "${p}" must be a function.`);c[p]=f}else if(a==="use"){if(typeof f!=="function"&&!Array.isArray(f))throw new Error("Use hook must be a function or an array of functions.");o.push(f)}else if(a==="style"){for(let[p,h]of Object.entries(f))if(h!==void 0)l[p]=se(h)}else u[a]=se(f);return{type:"element",name:e,attributes:u,children:t,bindings:s,eventHandlers:c,use:o,styles:l}}var _n,v,_="@vortex-get-internal",j,E,k;var Z=d(()=>{b();_n=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let r=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=r},[Symbol.dispose](){e.hookLifetime=r}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},v=class extends te({package:"@vortexjs/core",name:"Lifetime"},_n){};j=L,E=ue;k=te({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});function In(){let e=O.current;if(!e)throw new Error("No context scope found, you should have one if you're rendering a component.");return e}function ze(){return In().streaming}function Sn(){let e=O.current;if(!e)return null;return e}function On(){let e=Sn();if(!e)return null;return e.streaming}function qe({renderer:e,root:n,component:r,context:i}){try{var t=(0,Cn.default)();t.u(re("Initial page render"));let u=new Dn(e,n),s=new v,c=u.render({node:r,hydration:e.getHydrationContext(n),lt:s,context:i??O.current??new O}),o=new Ge(n,e);return o.children=[c],s}catch(u){t.e=u}finally{t.d()}}function Ue(e,n,r){if("renderer"in e)return qe(e);else return qe({renderer:e,root:n,component:r})}function We(){let e=On();return(n)=>{let r=j(void 0);async function i(){if(e)try{var t=(0,jn.default)();t.u(e.markLoading()),r.set(await n)}catch(u){t.e=u}finally{t.d()}else r.set(await n)}return i(),r}}var En,$n,An=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)$n(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=En(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},O=class e{contexts={};streaming=new An;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,r){this.contexts[n]=r}static current=null;static setCurrent(n){let r=e.current;return e.current=n,{[Symbol.dispose](){e.current=r}}}},Re="~vortex:intrinsic",Nn,z=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(r){if(r instanceof S)for(let i of r.children)n(i);else e.push(r)}for(let r of this.children)n(r);return e}},S,Me,Fe,Ge,fe,ce,Dn=class{constructor(e,n){this.renderer=e,this.root=n}render({node:e,hydration:n,lt:r,context:i}){if(e===void 0||e===null)return new S;if(Array.isArray(e))return this.render({node:{type:"fragment",children:e},hydration:n,lt:r,context:i});switch(e.type){case"fragment":{let s=new S;return s.children=e.children.map((c)=>this.render({node:c,hydration:n,lt:r,context:i})),s}case"text":return new Me(e.value.toString(),this.renderer,n,i);case"element":{let s=new Fe(e.name,this.renderer,n),c=this.renderer.getHydrationContext(s.rendererNode??m());s.children=e.children.map((l)=>this.render({node:l,hydration:c,lt:r,context:i}));for(let[l,a]of Object.entries(e.attributes))a.subscribe((f)=>{s.setAttribute(l,f)}).cascadesFrom(r);for(let[l,a]of Object.entries(e.bindings))this.renderer.bindValue(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.eventHandlers))this.renderer.addEventListener(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.styles))a.subscribe((f)=>{this.renderer.setStyle(s.rendererNode??m(),l,f)}).cascadesFrom(r);let o=[e.use].flat();for(let l of o)l(s.rendererNode??m());return s}case"component":try{var t=(0,ce.default)();t.u(v.changeHookLifetime(r)),t.u(O.setCurrent(i)),t.u(re(`Rendering ${e.impl.name}`));let s=e.impl;if(Re in s&&typeof s[Re]==="string"){let o=this.renderer.implementations?.find((l)=>l.intrinsic===s);if(o)s=o.implementation}let c=s(e.props);return this.render({node:c,hydration:n,lt:r,context:i})}catch(s){t.e=s}finally{t.d()}case"dynamic":{let s=new S;return oe((c,{lifetime:o})=>{let l=this.render({node:c(e.value),hydration:n,lt:o,context:i});s.children=[l]},void 0,r),s}case"list":{new S;let s=new Map,c=new S,o="";return oe((l)=>{let a=l(e.items),f=a.map((g,A)=>e.getKey(g,A));for(let g of s.keys())if(!f.includes(g))(s.get(g)??m()).lifetime.close(),s.delete(g);for(let g of f)if(!s.has(g))try{var p=(0,ce.default)();let A=a[f.indexOf(g)],cn=L(A),Y=new v;p.u(v.changeHookLifetime(Y));let an=this.render({node:e.renderItem(A,f.indexOf(g)),hydration:n,lt:Y,context:i});s.set(g,{node:an,item:cn,lifetime:Y})}catch(A){p.e=A}finally{p.d()}let h=f.join("|||");if(h!==o)o=h,c.children=f.map((g)=>(s.get(g)??m()).node)}),c}case"context":try{var u=(0,ce.default)();let s=i.fork();return u.u(O.setCurrent(s)),s.addContext(e.id,e.value),this.render({node:e.children,hydration:n,lt:r,context:s})}catch(s){u.e=s}finally{u.d()}default:Ce(e,`No rendering implementation for ${JSON.stringify(e)}`)}}},Cn,jn;var M=d(()=>{Le();Z();b();b();En=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),$n=globalThis.clearImmediate??((e)=>{clearTimeout(e)});Nn={};Pe(Nn,{FLElement:()=>Fe,FLFragment:()=>S,FLNode:()=>z,FLPortal:()=>Ge,FLText:()=>Me});S=class extends z{onChildrenChanged(){this.parent?.onChildrenChanged()}},Me=class extends z{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??m(),e)}constructor(e,n,r,i){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(r,i),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},Fe=class extends z{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??m(),e,n)}constructor(e,n,r){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,r)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??m());this.renderer.setChildren(this.rendererNode??m(),e)}},Ge=class extends z{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??m()))}},fe=Te({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function r(){var i=typeof SuppressedError=="function"?SuppressedError:function(c,o){var l=Error();return l.name="SuppressedError",l.error=c,l.suppressed=o,l},t={},u=[];function s(c,o){if(o!=null){if(Object(o)!==o)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(c)var l=o[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(l===void 0&&(l=o[Symbol.dispose||Symbol.for("Symbol.dispose")],c))var a=l;if(typeof l!="function")throw new TypeError("Object is not disposable.");a&&(l=function f(){try{a.call(o)}catch(p){return Promise.reject(p)}}),u.push({v:o,d:l,a:c})}else c&&u.push({d:o,a:c});return o}return{e:t,u:s.bind(null,!1),a:s.bind(null,!0),d(){var c,o=this.e,l=0;function a(){for(;c=u.pop();)try{if(!c.a&&l===1)return l=0,u.push(c),Promise.resolve().then(a);if(c.d){var p=c.d.call(c.v);if(c.a)return l|=2,Promise.resolve(p).then(a,f)}else l|=1}catch(h){return f(h)}if(l===1)return o!==t?Promise.reject(o):Promise.resolve();if(o!==t)throw o}function f(p){return o=o!==t?new i(p,o):p,a()}return a()}}}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),ce=K(fe(),1),Cn=K(fe(),1);jn=K(fe(),1)});function pe(e,n){let r=n.split("/").map((t)=>t.trim()).filter((t)=>t!=="");function i(t,u,s,c){if(t===e.length&&u===r.length)return{matched:!0,params:{...s},spreads:{...c}};if(t===e.length||u>r.length)return{matched:!1};let o=e[t]??m();if(o.type==="static"){if(u>=r.length||r[u]!==o.match)return{matched:!1};return i(t+1,u+1,s,c)}else if(o.type==="slug"){if(u>=r.length)return{matched:!1};let l={...s,[o.name]:r[u]};return i(t+1,u+1,l,c)}else if(o.type==="spread"){for(let l=0;l<=r.length-u;l++){let a={...c,[o.name]:r.slice(u,u+l)},f=i(t+1,u+l,s,a);if(f.matched)return f}return{matched:!1}}return{matched:!1}}return i(0,0,{},{})}var Je=d(()=>{b();M();b()});function x(e,n){let{children:r,...i}=n||{};if(e===k)return{type:"fragment",children:$(r)};if(typeof e==="string")return q(e,i,r);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(r)}};throw new Error(`Invalid JSX type: ${e}`)}var ye;var Be=d(()=>{Z();ye=x});var Xe=d(()=>{Be()});function Tn(){return E((e)=>{return new URL(e(F)).pathname})}function Pn(){if(typeof window==="undefined")return;F.subscribe((e)=>{if(window.location.href!==e)window.history.pushState({},"",e)},{callInitially:!1}),window.addEventListener("popstate",()=>{F.set(window.location.href)}),document.addEventListener("click",(e)=>{let r=e.composedPath().find((i)=>i instanceof HTMLAnchorElement);if(r?.href){let i=new URL(r.href,C(F));if(i.origin!==window.location.origin)return;e.preventDefault(),F.set(i.href)}})}function Ln({pathname:e,props:n,loaders:r}){if("location"in globalThis)Pn();ze();let i=We(),t=e?j(e):Tn(),u=E((l)=>{let a=l(t);return n.routes.find((f)=>pe(f.matcher,a))}),s=E(async(l)=>{let a=l(u)??m(),f=[];for(let p of a.frames)f.push(await(r[p.index]??m())());return f}),c=le(E((l)=>{return i(l(s))})),o=E((l)=>{let a=x(k,{}),f=l(c);if(!f)return x("h1",{children:"loading"});for(let p of f.toReversed())a=x(p,{children:a});return a});return ye("html",{children:[ye("head",{children:[x("link",{rel:"stylesheet",href:"/styles.css"}),x("script",{src:"/entrypoint-client.js",type:"module"})]}),x("body",{children:o})]})}async function Ke({props:e,loaders:n,renderer:r,root:i,pathname:t,lifetime:u=new v,context:s}){e:if("window"in globalThis){let c=t??window.location.pathname,o=e.routes.find((l)=>pe(l.matcher,c));if(!o)break e;for(let l of o.frames)await(n[l.index]??m())()}Ue({context:s,renderer:r,root:i,component:x(Ln,{pathname:t,props:e,loaders:n})}).cascadesFrom(u)}function Ve(e){return async function(n){return await e.impl(n)}}var F;var he=d(()=>{Je();b();M();Xe();b();F=j(typeof window!=="undefined"?window.location.href:"/")});function Mn(e){return{lang:e?.lang??ve?.lang,message:e?.message,abortEarly:e?.abortEarly??ve?.abortEarly,abortPipeEarly:e?.abortPipeEarly??ve?.abortPipeEarly}}function Gn(e){return Fn?.get(e)}function Wn(e){return Un?.get(e)}function Bn(e,n){return Jn?.get(e)?.get(n)}function Xn(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function de(e,n,r,i,t){let u=t&&"input"in t?t.input:r.value,s=t?.expected??e.expects??null,c=t?.received??Xn(u),o={kind:e.kind,type:e.type,input:u,expected:s,received:c,message:`Invalid ${n}: ${s?`Expected ${s} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:t?.path,issues:t?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},l=e.kind==="schema",a=t?.message??e.message??Bn(e.reference,o.lang)??(l?Wn(o.lang):null)??i.message??Gn(o.lang);if(a!==void 0)o.message=typeof a==="function"?a(o):a;if(l)r.typed=!1;if(r.issues)r.issues.push(o);else r.issues=[o]}function Ye(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Mn())}}}function Kn(e,n,r){return typeof e.fallback==="function"?e.fallback(n,r):e.fallback}function Vn(e,n,r){return typeof e.default==="function"?e.default(n,r):e.default}function Q(e){return{kind:"schema",type:"number",reference:Q,expects:"number",async:!1,message:e,get "~standard"(){return Ye(this)},"~run"(n,r){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else de(this,"type",n,r);return n}}}function ge(e,n){return{kind:"schema",type:"object",reference:ge,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return Ye(this)},"~run"(r,i){let t=r.value;if(t&&typeof t==="object"){r.typed=!0,r.value={};for(let u in this.entries){let s=this.entries[u];if(u in t||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){let c=u in t?t[u]:Vn(s),o=s["~run"]({value:c},i);if(o.issues){let l={type:"object",origin:"value",input:t,key:u,value:c};for(let a of o.issues){if(a.path)a.path.unshift(l);else a.path=[l];r.issues?.push(a)}if(!r.issues)r.issues=o.issues;if(i.abortEarly){r.typed=!1;break}}if(!o.typed)r.typed=!1;r.value[u]=o.value}else if(s.fallback!==void 0)r.value[u]=Kn(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"){if(de(this,"key",r,i,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:t,key:u,value:t[u]}]}),i.abortEarly)break}}}else de(this,"type",r,i);return r}}}var ve,Fn,Un,Jn;var en=()=>{};function G(e,n,r,i,t,u){let{children:s,...c}=n||{};if(e===k)return{type:"fragment",children:$(s),...t};if(typeof e==="string")return q(e,c,s,t);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(s)},...t};throw new Error(`Invalid JSX type: ${e}`)}var nn=d(()=>{Z()});var be=d(()=>{nn()});var Vr,rn=function({children:e}){return G(k,{children:[G("title",{children:"Wormhole Example"},void 0,!1,void 0,this),e]},void 0,!0,void 0,this)},tn=function(){return G(k,{children:G("h1",{children:"404 not found"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},Zn=function({a:e,b:n}){return e+n},Qn;var ke=d(()=>{en();he();be();Vr=Ve({schema:Qn,impl:Zn,endpoint:"/api/add",method:"GET",isQuery:!0}),Qn=ge({a:Q(),b:Q()})});var sn={};we(sn,{$d_732_888:()=>rn});var un=d(()=>{ke()});var on={};we(on,{$d_902_1009:()=>tn});var ln=d(()=>{ke()});he();M();b();M();b();function Rn(e){return"tagName"in e?e.tagName:"Text"}function qn(){return{html:"",write(e){this.html+=e},lastType:""}}function He(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function me(e,n=qn()){let r=Rn(e);if(r==="Text"&&n.lastType==="Text")n.write("");if(n.lastType=r,"tagName"in e){n.write("<"),n.write(e.tagName);for(let[i,t]of Object.entries(e.attributes)){if(t===void 0)continue;n.write(` ${i}="${He(t)}"`)}n.write(">");for(let i of e.children)me(i,n);n.write("")}if("content"in e)n.write(He(e.content.toString()));return n.html}function zn(e){return e.split(/(?=[A-Z])/).map((r)=>r.toLowerCase()).join("-")}function Ze(){return{createNode(e,n){return{tagName:e,attributes:{},children:[],parent:void 0}},setAttribute(e,n,r){if(!("tagName"in e))throw new Error("Cannot set attribute on a text node");e.attributes[n]=r},createTextNode(e){return{content:"",parent:void 0}},setTextContent(e,n){if(!("content"in e))throw new Error("Cannot set text content on a non-text node");e.content=n},setChildren(e,n){if(!("children"in e))throw new Error("Cannot set children on a text node");e.children=n;for(let r of n)r.parent=e},getHydrationContext(e){return},addEventListener(e,n,r){return new v},bindValue(e,n,r){return new v},setStyle(e,n,r){if(!("attributes"in e))throw new Error("Cannot set style on a text node");let i=e.attributes.style??"";i+=`${zn(n)}: ${r};`,e.attributes.style=i}}}function Qe(){return{tagName:"html",attributes:{},children:[],parent:void 0,fixedIdent:"document.documentElement"}}var Yn=JSON.parse('{"routes":[{"matcher":[{"type":"spread","name":"404"}],"frames":[{"index":0},{"index":1}],"is404":true}]}'),er=[async()=>(await Promise.resolve().then(() => (un(),sn))).$d_732_888,async()=>(await Promise.resolve().then(() => (ln(),on))).$d_902_1009];async function nr(e){let r=new URL(e.url).pathname,i=Ze(),t=Qe(),u=new v;try{await Ke({props:Yn,loaders:er,renderer:i,root:t,pathname:r,context:{},lifetime:u});let s=me(t);return new Response(s,{status:200,headers:{"Content-Type":"text/html"}})}catch(s){return console.error("Rendering error:",s),new Response("Internal Server Error",{status:500})}finally{u.close()}}export{nr as default}; diff --git a/packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/.vc-config.json b/packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/.vc-config.json new file mode 100644 index 0000000..bd4af02 --- /dev/null +++ b/packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/.vc-config.json @@ -0,0 +1,4 @@ +{ + "runtime": "edge", + "entrypoint": "index.js" +} \ No newline at end of file diff --git a/packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/index.js b/packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/index.js new file mode 100644 index 0000000..bd76c7c --- /dev/null +++ b/packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/index.js @@ -0,0 +1,6 @@ +// @bun +var fn=Object.defineProperty;var we=(e,n)=>{for(var r in n)fn(e,r,{get:n[r],enumerable:!0,configurable:!0,set:(i)=>n[r]=()=>i})};var d=(e,n)=>()=>(e&&(n=e(e=0)),n);var pn,xe=(e,n)=>{for(var r in n)pn(e,r,{get:n[r],enumerable:!0})};var _e=d(()=>{pn=Object.defineProperty});function Ee(e){return typeof e==="object"&&e!==null&&typeof e.then==="function"}function U(e,n){if(e===n)return!0;if(typeof e!==typeof n)return!1;if(Array.isArray(e)!==Array.isArray(n))return!1;if(Ee(e)||Ee(n))return!1;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let r=0;r="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}function W(e){return e>="0"&&e<="9"}function Ie(e){return X(e)||W(e)}function*Se(e){let n=0,r=()=>e[n]??"",i=()=>e[n++]??"",t=()=>{n++};while(n=e.tokens.length)return null;return e.tokens[e.current++]??null}function J(e){if(e.current>=e.tokens.length)return null;return e.tokens[e.current]??null}function N(e){let n=J(e);if(n!==null)e.current++;return n}function B(e){let n=N(e);if(n===null)throw new Error("Unexpected end of input");if(n[0]==="number")return n[1];if(n[0]==="string")return n[1];if(n[0]==="keyword"){if(n[1]===I.null)return null;if(n[1]===I.undefined)return;if(n[1]===I.true)return!0;if(n[1]===I.false)return!1;throw new Error(`Unexpected keyword: ${n[1]}`)}let r=null;if(n[0]==="identifier")r=n[1],n=N(e);if(n===null)throw new Error("Unexpected end of input (after reading class)");if(n[0]==="symbol"&&n[1]==="LeftParenthesis"){let i={};while(!0){let t=N(e);if(t===null)throw new Error("Unexpected end of input (when trying to read key)");if(t[0]==="symbol"&&t[1]==="RightParenthesis")break;if(t[0]!=="identifier"&&t[0]!=="string")throw new Error(`Expected identifier or string, got ${t[0]}`);let u=N(e);if(u===null||u[0]!=="symbol"||u[1]!=="Equals")throw new Error(`Expected '=', got ${u?u[0]:"end of input"}`);let s=t[1],c=B(e);i[s]=c}if(r!==null){if(r==="date")return new Date(i.unix);if(r==="set")return new Set(i.items);if(r==="map"){let t=new Map;for(let[u,s]of i.entries)t.set(u,s);return t}throw new Error(`Unknown class: ${r}`)}return i}if(n[0]==="symbol"&&n[1]==="LeftSquareBracket"){let i=[];while(!0){if(J(e)?.[0]==="symbol"&&J(e)?.[1]==="RightSquareBracket"){N(e);break}let t=B(e);i.push(t)}return i}}function hn(e){let n=[...Se(e)],r=Oe(n),i=B(r);if(r.currentt[0]).join(", ")}`);return i}function Ne(){return{output:"",indentLevel:0,minified:!1}}function P(e){e.indentLevel++}function L(e){e.indentLevel=Math.max(0,e.indentLevel-1)}function w(e){if(e.minified){y(e," ");return}y(e,` +`),y(e," ".repeat(e.indentLevel))}function y(e,n){e.output+=n}function ne(e){let n=Number.POSITIVE_INFINITY,r="";for(let i of['"',"'","`"]){let t="";t+=i;for(let u of e)if(u===i)t+=`\\${u}`;else if(u==="\\")t+="\\\\";else if(u===` +`)t+="\\n";else if(u==="\t")t+="\\t";else if(u==="\r")t+="\\r";else t+=u;if(t+=i,t.length{_e();$e={};xe($e,{escapeStr:()=>ne,isAlphabetic:()=>X,isAlphanumeric:()=>Ie,isNumeric:()=>W,isWhitespace:()=>Ae,keywords:()=>I,lex:()=>Se,parse:()=>hn,parseContext_create:()=>Oe,parseContext_next:()=>yn,parseContext_peek:()=>J,parseContext_read:()=>N,parseContext_readObj:()=>B,serialize:()=>De,serializeContext_create:()=>Ne,serializeContext_dedent:()=>L,serializeContext_indent:()=>P,serializeContext_newline:()=>w,serializeContext_write:()=>y,serializeContext_writeObject:()=>D,stringify:()=>mn,symbols:()=>ee});I={null:"Null",true:"True",false:"False",undefined:"Undefined"},ee={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};mn=De});var gn,ie,bn,je,kn,wn,Te=(e,n)=>function(){return n||(0,e[je(e)[0]])((n={exports:{}}).exports,n),n.exports},Pe=(e,n)=>{for(var r in n)ie(e,r,{get:n[r],enumerable:!0})},xn=(e,n,r,i)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var t=je(n),u=0,s=t.length,c;un[o]).bind(null,c),enumerable:!(i=bn(n,c))||i.enumerable})}return e},K=(e,n,r)=>(r=e!=null?gn(kn(e)):{},xn(n||!e||!e.__esModule?ie(r,"default",{value:e,enumerable:!0}):r,e));var Le=d(()=>{gn=Object.create,ie=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,je=Object.getOwnPropertyNames,kn=Object.getPrototypeOf,wn=Object.prototype.hasOwnProperty});function H(){if(v.hookLifetime===null)throw new Error("No hook lifetime available");return v.hookLifetime}function q(e){let n,r=e,i=[];return n&&console.log(`[${n}]: initialized with `,r),{setId(t){n=t},[_](){return r},subscribe(t,u){if(i.push(t),n&&console.trace(`[${n}]: subscribed with `,t),u?.callInitially!==!1)t(r);return new v().onClosed(()=>{i.splice(i.indexOf(t),1),n&&console.log(`[${n}]: unsubscribed `,t)})},set(t){if(n&&console.log(`[${n}]: trying to switch from `,r," -> ",t),!U(r,t)){r=t;for(let u of i)u(r);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}function C(e){return e[_]()}function ue(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=q(e((o)=>{if(!t.includes(o))t.push(o);return o[_]()}));function s(){if(i){let o=new Set(t);u.set(e((p)=>{return o.add(p),p[_]()}));let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.set(e(C))}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)});return{...u}}function oe(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=new v;e((o)=>{if(!t.includes(o))t.push(o);return o[_]()},{lifetime:u});function s(){if(i){let o=new Set(t);u.close(),u=new v().cascadesFrom(r),e((p)=>{return o.add(p),p[_]()},{lifetime:u});let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.close(),u=new v().cascadesFrom(r),e(C,{lifetime:u})}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)})}function R(e){return typeof e==="object"&&e!==null&&_ in e}function se(e){if(R(e))return e;return q(e)}function le(e,n=H()){return ue((r)=>{function i(t){if(R(t))return i(r(t));return t}return i(e)},{dynamic:!0},n)}function $(e){if(e===void 0)return[];return[e].flat().filter((n)=>n!==null&&n!==void 0).map((n)=>typeof n==="string"||typeof n==="number"||typeof n==="boolean"?V(n):R(n)?{type:"dynamic",value:E((r)=>{let i=r(n);return typeof i==="number"||typeof i==="string"||typeof i==="boolean"?V(i):i})}:n)}function V(e,n){return{type:"text",value:e,...n}}function z(e,n,r,i){let t=$(r).map((a)=>{if(typeof a==="string"||typeof a==="number"||typeof a==="boolean")return V(a);return a}),u={},s={},c={},o=[],l={};for(let[a,f]of Object.entries(n))if(f!==void 0)if(a.startsWith("bind:")){let p=a.slice(5);if(!R(f)||!("set"in f))throw new Error(`Binding value for "${p}" must be a writable store.`);s[p]=f}else if(a.startsWith("on:")){let p=a.slice(3);if(typeof f!=="function")throw new Error(`Event handler for "${p}" must be a function.`);c[p]=f}else if(a==="use"){if(typeof f!=="function"&&!Array.isArray(f))throw new Error("Use hook must be a function or an array of functions.");o.push(f)}else if(a==="style"){for(let[p,h]of Object.entries(f))if(h!==void 0)l[p]=se(h)}else u[a]=se(f);return{type:"element",name:e,attributes:u,children:t,bindings:s,eventHandlers:c,use:o,styles:l}}var _n,v,_="@vortex-get-internal",j,E,k;var Z=d(()=>{b();_n=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let r=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=r},[Symbol.dispose](){e.hookLifetime=r}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},v=class extends te({package:"@vortexjs/core",name:"Lifetime"},_n){};j=q,E=ue;k=te({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});function In(){let e=O.current;if(!e)throw new Error("No context scope found, you should have one if you're rendering a component.");return e}function ze(){return In().streaming}function Sn(){let e=O.current;if(!e)return null;return e}function On(){let e=Sn();if(!e)return null;return e.streaming}function Re({renderer:e,root:n,component:r,context:i}){try{var t=(0,Cn.default)();t.u(re("Initial page render"));let u=new Dn(e,n),s=new v,c=u.render({node:r,hydration:e.getHydrationContext(n),lt:s,context:i??O.current??new O}),o=new Ge(n,e);return o.children=[c],s}catch(u){t.e=u}finally{t.d()}}function Ue(e,n,r){if("renderer"in e)return Re(e);else return Re({renderer:e,root:n,component:r})}function We(){let e=On();return(n)=>{let r=j(void 0);async function i(){if(e)try{var t=(0,jn.default)();t.u(e.markLoading()),r.set(await n)}catch(u){t.e=u}finally{t.d()}else r.set(await n)}return i(),r}}var En,$n,An=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)$n(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=En(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},O=class e{contexts={};streaming=new An;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,r){this.contexts[n]=r}static current=null;static setCurrent(n){let r=e.current;return e.current=n,{[Symbol.dispose](){e.current=r}}}},qe="~vortex:intrinsic",Nn,M=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(r){if(r instanceof S)for(let i of r.children)n(i);else e.push(r)}for(let r of this.children)n(r);return e}},S,Me,Fe,Ge,fe,ce,Dn=class{constructor(e,n){this.renderer=e,this.root=n}render({node:e,hydration:n,lt:r,context:i}){if(e===void 0||e===null)return new S;if(Array.isArray(e))return this.render({node:{type:"fragment",children:e},hydration:n,lt:r,context:i});switch(e.type){case"fragment":{let s=new S;return s.children=e.children.map((c)=>this.render({node:c,hydration:n,lt:r,context:i})),s}case"text":return new Me(e.value.toString(),this.renderer,n,i);case"element":{let s=new Fe(e.name,this.renderer,n),c=this.renderer.getHydrationContext(s.rendererNode??m());s.children=e.children.map((l)=>this.render({node:l,hydration:c,lt:r,context:i}));for(let[l,a]of Object.entries(e.attributes))a.subscribe((f)=>{s.setAttribute(l,f)}).cascadesFrom(r);for(let[l,a]of Object.entries(e.bindings))this.renderer.bindValue(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.eventHandlers))this.renderer.addEventListener(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.styles))a.subscribe((f)=>{this.renderer.setStyle(s.rendererNode??m(),l,f)}).cascadesFrom(r);let o=[e.use].flat();for(let l of o)l(s.rendererNode??m());return s}case"component":try{var t=(0,ce.default)();t.u(v.changeHookLifetime(r)),t.u(O.setCurrent(i)),t.u(re(`Rendering ${e.impl.name}`));let s=e.impl;if(qe in s&&typeof s[qe]==="string"){let o=this.renderer.implementations?.find((l)=>l.intrinsic===s);if(o)s=o.implementation}let c=s(e.props);return this.render({node:c,hydration:n,lt:r,context:i})}catch(s){t.e=s}finally{t.d()}case"dynamic":{let s=new S;return oe((c,{lifetime:o})=>{let l=this.render({node:c(e.value),hydration:n,lt:o,context:i});s.children=[l]},void 0,r),s}case"list":{new S;let s=new Map,c=new S,o="";return oe((l)=>{let a=l(e.items),f=a.map((g,A)=>e.getKey(g,A));for(let g of s.keys())if(!f.includes(g))(s.get(g)??m()).lifetime.close(),s.delete(g);for(let g of f)if(!s.has(g))try{var p=(0,ce.default)();let A=a[f.indexOf(g)],cn=q(A),Y=new v;p.u(v.changeHookLifetime(Y));let an=this.render({node:e.renderItem(A,f.indexOf(g)),hydration:n,lt:Y,context:i});s.set(g,{node:an,item:cn,lifetime:Y})}catch(A){p.e=A}finally{p.d()}let h=f.join("|||");if(h!==o)o=h,c.children=f.map((g)=>(s.get(g)??m()).node)}),c}case"context":try{var u=(0,ce.default)();let s=i.fork();return u.u(O.setCurrent(s)),s.addContext(e.id,e.value),this.render({node:e.children,hydration:n,lt:r,context:s})}catch(s){u.e=s}finally{u.d()}default:Ce(e,`No rendering implementation for ${JSON.stringify(e)}`)}}},Cn,jn;var F=d(()=>{Le();Z();b();b();En=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),$n=globalThis.clearImmediate??((e)=>{clearTimeout(e)});Nn={};Pe(Nn,{FLElement:()=>Fe,FLFragment:()=>S,FLNode:()=>M,FLPortal:()=>Ge,FLText:()=>Me});S=class extends M{onChildrenChanged(){this.parent?.onChildrenChanged()}},Me=class extends M{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??m(),e)}constructor(e,n,r,i){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(r,i),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},Fe=class extends M{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??m(),e,n)}constructor(e,n,r){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,r)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??m());this.renderer.setChildren(this.rendererNode??m(),e)}},Ge=class extends M{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??m()))}},fe=Te({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function r(){var i=typeof SuppressedError=="function"?SuppressedError:function(c,o){var l=Error();return l.name="SuppressedError",l.error=c,l.suppressed=o,l},t={},u=[];function s(c,o){if(o!=null){if(Object(o)!==o)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(c)var l=o[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(l===void 0&&(l=o[Symbol.dispose||Symbol.for("Symbol.dispose")],c))var a=l;if(typeof l!="function")throw new TypeError("Object is not disposable.");a&&(l=function f(){try{a.call(o)}catch(p){return Promise.reject(p)}}),u.push({v:o,d:l,a:c})}else c&&u.push({d:o,a:c});return o}return{e:t,u:s.bind(null,!1),a:s.bind(null,!0),d(){var c,o=this.e,l=0;function a(){for(;c=u.pop();)try{if(!c.a&&l===1)return l=0,u.push(c),Promise.resolve().then(a);if(c.d){var p=c.d.call(c.v);if(c.a)return l|=2,Promise.resolve(p).then(a,f)}else l|=1}catch(h){return f(h)}if(l===1)return o!==t?Promise.reject(o):Promise.resolve();if(o!==t)throw o}function f(p){return o=o!==t?new i(p,o):p,a()}return a()}}}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),ce=K(fe(),1),Cn=K(fe(),1);jn=K(fe(),1)});function pe(e,n){let r=n.split("/").map((t)=>t.trim()).filter((t)=>t!=="");function i(t,u,s,c){if(t===e.length&&u===r.length)return{matched:!0,params:{...s},spreads:{...c}};if(t===e.length||u>r.length)return{matched:!1};let o=e[t]??m();if(o.type==="static"){if(u>=r.length||r[u]!==o.match)return{matched:!1};return i(t+1,u+1,s,c)}else if(o.type==="slug"){if(u>=r.length)return{matched:!1};let l={...s,[o.name]:r[u]};return i(t+1,u+1,l,c)}else if(o.type==="spread"){for(let l=0;l<=r.length-u;l++){let a={...c,[o.name]:r.slice(u,u+l)},f=i(t+1,u+l,s,a);if(f.matched)return f}return{matched:!1}}return{matched:!1}}return i(0,0,{},{})}var Je=d(()=>{b();F();b()});function x(e,n){let{children:r,...i}=n||{};if(e===k)return{type:"fragment",children:$(r)};if(typeof e==="string")return z(e,i,r);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(r)}};throw new Error(`Invalid JSX type: ${e}`)}var ye;var Be=d(()=>{Z();ye=x});var Xe=d(()=>{Be()});function Tn(){return E((e)=>{return new URL(e(G)).pathname})}function Pn(){if(typeof window==="undefined")return;G.subscribe((e)=>{if(window.location.href!==e)window.history.pushState({},"",e)},{callInitially:!1}),window.addEventListener("popstate",()=>{G.set(window.location.href)}),document.addEventListener("click",(e)=>{let r=e.composedPath().find((i)=>i instanceof HTMLAnchorElement);if(r?.href){let i=new URL(r.href,C(G));if(i.origin!==window.location.origin)return;e.preventDefault(),G.set(i.href)}})}function Ln({pathname:e,props:n,loaders:r}){if("location"in globalThis)Pn();ze();let i=We(),t=e?j(e):Tn(),u=E((l)=>{let a=l(t);return n.routes.find((f)=>pe(f.matcher,a))}),s=E(async(l)=>{let a=l(u)??m(),f=[];for(let p of a.frames)f.push(await(r[p.index]??m())());return f}),c=le(E((l)=>{return i(l(s))})),o=E((l)=>{let a=x(k,{}),f=l(c);if(!f)return x("h1",{children:"loading"});for(let p of f.toReversed())a=x(p,{children:a});return a});return ye("html",{children:[ye("head",{children:[x("link",{rel:"stylesheet",href:"/styles.css"}),x("script",{src:"/entrypoint-client.js",type:"module"})]}),x("body",{children:o})]})}async function Ke({props:e,loaders:n,renderer:r,root:i,pathname:t,lifetime:u=new v,context:s}){e:if("window"in globalThis){let c=t??window.location.pathname,o=e.routes.find((l)=>pe(l.matcher,c));if(!o)break e;for(let l of o.frames)await(n[l.index]??m())()}Ue({context:s,renderer:r,root:i,component:x(Ln,{pathname:t,props:e,loaders:n})}).cascadesFrom(u)}function Ve(e){return async function(n){return await e.impl(n)}}var G;var he=d(()=>{Je();b();F();Xe();b();G=j(typeof window!=="undefined"?window.location.href:"/")});function Mn(e){return{lang:e?.lang??ve?.lang,message:e?.message,abortEarly:e?.abortEarly??ve?.abortEarly,abortPipeEarly:e?.abortPipeEarly??ve?.abortPipeEarly}}function Gn(e){return Fn?.get(e)}function Wn(e){return Un?.get(e)}function Bn(e,n){return Jn?.get(e)?.get(n)}function Xn(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function de(e,n,r,i,t){let u=t&&"input"in t?t.input:r.value,s=t?.expected??e.expects??null,c=t?.received??Xn(u),o={kind:e.kind,type:e.type,input:u,expected:s,received:c,message:`Invalid ${n}: ${s?`Expected ${s} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:t?.path,issues:t?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},l=e.kind==="schema",a=t?.message??e.message??Bn(e.reference,o.lang)??(l?Wn(o.lang):null)??i.message??Gn(o.lang);if(a!==void 0)o.message=typeof a==="function"?a(o):a;if(l)r.typed=!1;if(r.issues)r.issues.push(o);else r.issues=[o]}function Ye(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Mn())}}}function Kn(e,n,r){return typeof e.fallback==="function"?e.fallback(n,r):e.fallback}function Vn(e,n,r){return typeof e.default==="function"?e.default(n,r):e.default}function Q(e){return{kind:"schema",type:"number",reference:Q,expects:"number",async:!1,message:e,get "~standard"(){return Ye(this)},"~run"(n,r){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else de(this,"type",n,r);return n}}}function ge(e,n){return{kind:"schema",type:"object",reference:ge,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return Ye(this)},"~run"(r,i){let t=r.value;if(t&&typeof t==="object"){r.typed=!0,r.value={};for(let u in this.entries){let s=this.entries[u];if(u in t||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){let c=u in t?t[u]:Vn(s),o=s["~run"]({value:c},i);if(o.issues){let l={type:"object",origin:"value",input:t,key:u,value:c};for(let a of o.issues){if(a.path)a.path.unshift(l);else a.path=[l];r.issues?.push(a)}if(!r.issues)r.issues=o.issues;if(i.abortEarly){r.typed=!1;break}}if(!o.typed)r.typed=!1;r.value[u]=o.value}else if(s.fallback!==void 0)r.value[u]=Kn(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"){if(de(this,"key",r,i,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:t,key:u,value:t[u]}]}),i.abortEarly)break}}}else de(this,"type",r,i);return r}}}var ve,Fn,Un,Jn;var en=()=>{};function T(e,n,r,i,t,u){let{children:s,...c}=n||{};if(e===k)return{type:"fragment",children:$(s),...t};if(typeof e==="string")return z(e,c,s,t);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(s)},...t};throw new Error(`Invalid JSX type: ${e}`)}var nn=d(()=>{Z()});var be=d(()=>{nn()});var Vr,rn=function({children:e}){return T(k,{children:[T("title",{children:"Wormhole Example"},void 0,!1,void 0,this),e]},void 0,!0,void 0,this)},tn=function({page:e}){return T(k,{children:[T("h1",{children:["Documentation for ",e.join(", ")]},void 0,!0,void 0,this),T("p",{children:["This is the documentation page for ",e.join(", "),"."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},Zn=function({a:e,b:n}){return e+n},Qn;var ke=d(()=>{en();he();be();Vr=Ve({schema:Qn,impl:Zn,endpoint:"/api/add",method:"GET",isQuery:!0}),Qn=ge({a:Q(),b:Q()})});var sn={};we(sn,{$d_732_888:()=>rn});var un=d(()=>{ke()});var on={};we(on,{$d_1050_1265:()=>tn});var ln=d(()=>{ke()});he();F();b();F();b();function qn(e){return"tagName"in e?e.tagName:"Text"}function Rn(){return{html:"",write(e){this.html+=e},lastType:""}}function He(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function me(e,n=Rn()){let r=qn(e);if(r==="Text"&&n.lastType==="Text")n.write("");if(n.lastType=r,"tagName"in e){n.write("<"),n.write(e.tagName);for(let[i,t]of Object.entries(e.attributes)){if(t===void 0)continue;n.write(` ${i}="${He(t)}"`)}n.write(">");for(let i of e.children)me(i,n);n.write("")}if("content"in e)n.write(He(e.content.toString()));return n.html}function zn(e){return e.split(/(?=[A-Z])/).map((r)=>r.toLowerCase()).join("-")}function Ze(){return{createNode(e,n){return{tagName:e,attributes:{},children:[],parent:void 0}},setAttribute(e,n,r){if(!("tagName"in e))throw new Error("Cannot set attribute on a text node");e.attributes[n]=r},createTextNode(e){return{content:"",parent:void 0}},setTextContent(e,n){if(!("content"in e))throw new Error("Cannot set text content on a non-text node");e.content=n},setChildren(e,n){if(!("children"in e))throw new Error("Cannot set children on a text node");e.children=n;for(let r of n)r.parent=e},getHydrationContext(e){return},addEventListener(e,n,r){return new v},bindValue(e,n,r){return new v},setStyle(e,n,r){if(!("attributes"in e))throw new Error("Cannot set style on a text node");let i=e.attributes.style??"";i+=`${zn(n)}: ${r};`,e.attributes.style=i}}}function Qe(){return{tagName:"html",attributes:{},children:[],parent:void 0,fixedIdent:"document.documentElement"}}var Yn=JSON.parse('{"routes":[{"matcher":[{"type":"static","match":"docs"},{"type":"spread","name":"page"}],"frames":[{"index":0},{"index":1}],"is404":false}]}'),er=[async()=>(await Promise.resolve().then(() => (un(),sn))).$d_732_888,async()=>(await Promise.resolve().then(() => (ln(),on))).$d_1050_1265];async function nr(e){let r=new URL(e.url).pathname,i=Ze(),t=Qe(),u=new v;try{await Ke({props:Yn,loaders:er,renderer:i,root:t,pathname:r,context:{},lifetime:u});let s=me(t);return new Response(s,{status:200,headers:{"Content-Type":"text/html"}})}catch(s){return console.error("Rendering error:",s),new Response("Internal Server Error",{status:500})}finally{u.close()}}export{nr as default}; diff --git a/packages/example-wormhole/.vercel/output/functions/route-index.func/.vc-config.json b/packages/example-wormhole/.vercel/output/functions/route-index.func/.vc-config.json new file mode 100644 index 0000000..bd4af02 --- /dev/null +++ b/packages/example-wormhole/.vercel/output/functions/route-index.func/.vc-config.json @@ -0,0 +1,4 @@ +{ + "runtime": "edge", + "entrypoint": "index.js" +} \ No newline at end of file diff --git a/packages/example-wormhole/.vercel/output/functions/route-index.func/index.js b/packages/example-wormhole/.vercel/output/functions/route-index.func/index.js new file mode 100644 index 0000000..c8092a3 --- /dev/null +++ b/packages/example-wormhole/.vercel/output/functions/route-index.func/index.js @@ -0,0 +1,6 @@ +// @bun +var on=Object.defineProperty;var ln=(e,n)=>{for(var r in n)on(e,r,{get:n[r],enumerable:!0,configurable:!0,set:(i)=>n[r]=()=>i})};var d=(e,n)=>()=>(e&&(n=e(e=0)),n);var cn,ke=(e,n)=>{for(var r in n)cn(e,r,{get:n[r],enumerable:!0})};var we=d(()=>{cn=Object.defineProperty});function xe(e){return typeof e==="object"&&e!==null&&typeof e.then==="function"}function U(e,n){if(e===n)return!0;if(typeof e!==typeof n)return!1;if(Array.isArray(e)!==Array.isArray(n))return!1;if(xe(e)||xe(n))return!1;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let r=0;r="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}function W(e){return e>="0"&&e<="9"}function $e(e){return X(e)||W(e)}function*Ae(e){let n=0,r=()=>e[n]??"",i=()=>e[n++]??"",t=()=>{n++};while(n=e.tokens.length)return null;return e.tokens[e.current++]??null}function J(e){if(e.current>=e.tokens.length)return null;return e.tokens[e.current]??null}function N(e){let n=J(e);if(n!==null)e.current++;return n}function B(e){let n=N(e);if(n===null)throw new Error("Unexpected end of input");if(n[0]==="number")return n[1];if(n[0]==="string")return n[1];if(n[0]==="keyword"){if(n[1]===I.null)return null;if(n[1]===I.undefined)return;if(n[1]===I.true)return!0;if(n[1]===I.false)return!1;throw new Error(`Unexpected keyword: ${n[1]}`)}let r=null;if(n[0]==="identifier")r=n[1],n=N(e);if(n===null)throw new Error("Unexpected end of input (after reading class)");if(n[0]==="symbol"&&n[1]==="LeftParenthesis"){let i={};while(!0){let t=N(e);if(t===null)throw new Error("Unexpected end of input (when trying to read key)");if(t[0]==="symbol"&&t[1]==="RightParenthesis")break;if(t[0]!=="identifier"&&t[0]!=="string")throw new Error(`Expected identifier or string, got ${t[0]}`);let u=N(e);if(u===null||u[0]!=="symbol"||u[1]!=="Equals")throw new Error(`Expected '=', got ${u?u[0]:"end of input"}`);let s=t[1],c=B(e);i[s]=c}if(r!==null){if(r==="date")return new Date(i.unix);if(r==="set")return new Set(i.items);if(r==="map"){let t=new Map;for(let[u,s]of i.entries)t.set(u,s);return t}throw new Error(`Unknown class: ${r}`)}return i}if(n[0]==="symbol"&&n[1]==="LeftSquareBracket"){let i=[];while(!0){if(J(e)?.[0]==="symbol"&&J(e)?.[1]==="RightSquareBracket"){N(e);break}let t=B(e);i.push(t)}return i}}function fn(e){let n=[...Ae(e)],r=Ie(n),i=B(r);if(r.currentt[0]).join(", ")}`);return i}function Se(){return{output:"",indentLevel:0,minified:!1}}function P(e){e.indentLevel++}function L(e){e.indentLevel=Math.max(0,e.indentLevel-1)}function k(e){if(e.minified){y(e," ");return}y(e,` +`),y(e," ".repeat(e.indentLevel))}function y(e,n){e.output+=n}function ne(e){let n=Number.POSITIVE_INFINITY,r="";for(let i of['"',"'","`"]){let t="";t+=i;for(let u of e)if(u===i)t+=`\\${u}`;else if(u==="\\")t+="\\\\";else if(u===` +`)t+="\\n";else if(u==="\t")t+="\\t";else if(u==="\r")t+="\\r";else t+=u;if(t+=i,t.length{we();_e={};ke(_e,{escapeStr:()=>ne,isAlphabetic:()=>X,isAlphanumeric:()=>$e,isNumeric:()=>W,isWhitespace:()=>Ee,keywords:()=>I,lex:()=>Ae,parse:()=>fn,parseContext_create:()=>Ie,parseContext_next:()=>an,parseContext_peek:()=>J,parseContext_read:()=>N,parseContext_readObj:()=>B,serialize:()=>Oe,serializeContext_create:()=>Se,serializeContext_dedent:()=>L,serializeContext_indent:()=>P,serializeContext_newline:()=>k,serializeContext_write:()=>y,serializeContext_writeObject:()=>D,stringify:()=>pn,symbols:()=>ee});I={null:"Null",true:"True",false:"False",undefined:"Undefined"},ee={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};pn=Oe});var mn,ie,vn,De,dn,gn,Ce=(e,n)=>function(){return n||(0,e[De(e)[0]])((n={exports:{}}).exports,n),n.exports},je=(e,n)=>{for(var r in n)ie(e,r,{get:n[r],enumerable:!0})},bn=(e,n,r,i)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var t=De(n),u=0,s=t.length,c;un[o]).bind(null,c),enumerable:!(i=vn(n,c))||i.enumerable})}return e},K=(e,n,r)=>(r=e!=null?mn(dn(e)):{},bn(n||!e||!e.__esModule?ie(r,"default",{value:e,enumerable:!0}):r,e));var Te=d(()=>{mn=Object.create,ie=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,De=Object.getOwnPropertyNames,dn=Object.getPrototypeOf,gn=Object.prototype.hasOwnProperty});function H(){if(v.hookLifetime===null)throw new Error("No hook lifetime available");return v.hookLifetime}function q(e){let n,r=e,i=[];return n&&console.log(`[${n}]: initialized with `,r),{setId(t){n=t},[_](){return r},subscribe(t,u){if(i.push(t),n&&console.trace(`[${n}]: subscribed with `,t),u?.callInitially!==!1)t(r);return new v().onClosed(()=>{i.splice(i.indexOf(t),1),n&&console.log(`[${n}]: unsubscribed `,t)})},set(t){if(n&&console.log(`[${n}]: trying to switch from `,r," -> ",t),!U(r,t)){r=t;for(let u of i)u(r);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}function C(e){return e[_]()}function ue(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=q(e((o)=>{if(!t.includes(o))t.push(o);return o[_]()}));function s(){if(i){let o=new Set(t);u.set(e((p)=>{return o.add(p),p[_]()}));let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.set(e(C))}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)});return{...u}}function oe(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=new v;e((o)=>{if(!t.includes(o))t.push(o);return o[_]()},{lifetime:u});function s(){if(i){let o=new Set(t);u.close(),u=new v().cascadesFrom(r),e((p)=>{return o.add(p),p[_]()},{lifetime:u});let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.close(),u=new v().cascadesFrom(r),e(C,{lifetime:u})}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)})}function R(e){return typeof e==="object"&&e!==null&&_ in e}function se(e){if(R(e))return e;return q(e)}function le(e,n=H()){return ue((r)=>{function i(t){if(R(t))return i(r(t));return t}return i(e)},{dynamic:!0},n)}function $(e){if(e===void 0)return[];return[e].flat().filter((n)=>n!==null&&n!==void 0).map((n)=>typeof n==="string"||typeof n==="number"||typeof n==="boolean"?V(n):R(n)?{type:"dynamic",value:E((r)=>{let i=r(n);return typeof i==="number"||typeof i==="string"||typeof i==="boolean"?V(i):i})}:n)}function V(e,n){return{type:"text",value:e,...n}}function z(e,n,r,i){let t=$(r).map((a)=>{if(typeof a==="string"||typeof a==="number"||typeof a==="boolean")return V(a);return a}),u={},s={},c={},o=[],l={};for(let[a,f]of Object.entries(n))if(f!==void 0)if(a.startsWith("bind:")){let p=a.slice(5);if(!R(f)||!("set"in f))throw new Error(`Binding value for "${p}" must be a writable store.`);s[p]=f}else if(a.startsWith("on:")){let p=a.slice(3);if(typeof f!=="function")throw new Error(`Event handler for "${p}" must be a function.`);c[p]=f}else if(a==="use"){if(typeof f!=="function"&&!Array.isArray(f))throw new Error("Use hook must be a function or an array of functions.");o.push(f)}else if(a==="style"){for(let[p,h]of Object.entries(f))if(h!==void 0)l[p]=se(h)}else u[a]=se(f);return{type:"element",name:e,attributes:u,children:t,bindings:s,eventHandlers:c,use:o,styles:l}}var kn,v,_="@vortex-get-internal",j,E,w;var Z=d(()=>{b();kn=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let r=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=r},[Symbol.dispose](){e.hookLifetime=r}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},v=class extends te({package:"@vortexjs/core",name:"Lifetime"},kn){};j=q,E=ue;w=te({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});function En(){let e=O.current;if(!e)throw new Error("No context scope found, you should have one if you're rendering a component.");return e}function qe(){return En().streaming}function $n(){let e=O.current;if(!e)return null;return e}function An(){let e=$n();if(!e)return null;return e.streaming}function Le({renderer:e,root:n,component:r,context:i}){try{var t=(0,On.default)();t.u(re("Initial page render"));let u=new Sn(e,n),s=new v,c=u.render({node:r,hydration:e.getHydrationContext(n),lt:s,context:i??O.current??new O}),o=new Me(n,e);return o.children=[c],s}catch(u){t.e=u}finally{t.d()}}function Fe(e,n,r){if("renderer"in e)return Le(e);else return Le({renderer:e,root:n,component:r})}function Ge(){let e=An();return(n)=>{let r=j(void 0);async function i(){if(e)try{var t=(0,Nn.default)();t.u(e.markLoading()),r.set(await n)}catch(u){t.e=u}finally{t.d()}else r.set(await n)}return i(),r}}var wn,xn,_n=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)xn(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=wn(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},O=class e{contexts={};streaming=new _n;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,r){this.contexts[n]=r}static current=null;static setCurrent(n){let r=e.current;return e.current=n,{[Symbol.dispose](){e.current=r}}}},Pe="~vortex:intrinsic",In,M=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(r){if(r instanceof S)for(let i of r.children)n(i);else e.push(r)}for(let r of this.children)n(r);return e}},S,Re,ze,Me,fe,ce,Sn=class{constructor(e,n){this.renderer=e,this.root=n}render({node:e,hydration:n,lt:r,context:i}){if(e===void 0||e===null)return new S;if(Array.isArray(e))return this.render({node:{type:"fragment",children:e},hydration:n,lt:r,context:i});switch(e.type){case"fragment":{let s=new S;return s.children=e.children.map((c)=>this.render({node:c,hydration:n,lt:r,context:i})),s}case"text":return new Re(e.value.toString(),this.renderer,n,i);case"element":{let s=new ze(e.name,this.renderer,n),c=this.renderer.getHydrationContext(s.rendererNode??m());s.children=e.children.map((l)=>this.render({node:l,hydration:c,lt:r,context:i}));for(let[l,a]of Object.entries(e.attributes))a.subscribe((f)=>{s.setAttribute(l,f)}).cascadesFrom(r);for(let[l,a]of Object.entries(e.bindings))this.renderer.bindValue(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.eventHandlers))this.renderer.addEventListener(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.styles))a.subscribe((f)=>{this.renderer.setStyle(s.rendererNode??m(),l,f)}).cascadesFrom(r);let o=[e.use].flat();for(let l of o)l(s.rendererNode??m());return s}case"component":try{var t=(0,ce.default)();t.u(v.changeHookLifetime(r)),t.u(O.setCurrent(i)),t.u(re(`Rendering ${e.impl.name}`));let s=e.impl;if(Pe in s&&typeof s[Pe]==="string"){let o=this.renderer.implementations?.find((l)=>l.intrinsic===s);if(o)s=o.implementation}let c=s(e.props);return this.render({node:c,hydration:n,lt:r,context:i})}catch(s){t.e=s}finally{t.d()}case"dynamic":{let s=new S;return oe((c,{lifetime:o})=>{let l=this.render({node:c(e.value),hydration:n,lt:o,context:i});s.children=[l]},void 0,r),s}case"list":{new S;let s=new Map,c=new S,o="";return oe((l)=>{let a=l(e.items),f=a.map((g,A)=>e.getKey(g,A));for(let g of s.keys())if(!f.includes(g))(s.get(g)??m()).lifetime.close(),s.delete(g);for(let g of f)if(!s.has(g))try{var p=(0,ce.default)();let A=a[f.indexOf(g)],sn=q(A),Y=new v;p.u(v.changeHookLifetime(Y));let un=this.render({node:e.renderItem(A,f.indexOf(g)),hydration:n,lt:Y,context:i});s.set(g,{node:un,item:sn,lifetime:Y})}catch(A){p.e=A}finally{p.d()}let h=f.join("|||");if(h!==o)o=h,c.children=f.map((g)=>(s.get(g)??m()).node)}),c}case"context":try{var u=(0,ce.default)();let s=i.fork();return u.u(O.setCurrent(s)),s.addContext(e.id,e.value),this.render({node:e.children,hydration:n,lt:r,context:s})}catch(s){u.e=s}finally{u.d()}default:Ne(e,`No rendering implementation for ${JSON.stringify(e)}`)}}},On,Nn;var F=d(()=>{Te();Z();b();b();wn=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),xn=globalThis.clearImmediate??((e)=>{clearTimeout(e)});In={};je(In,{FLElement:()=>ze,FLFragment:()=>S,FLNode:()=>M,FLPortal:()=>Me,FLText:()=>Re});S=class extends M{onChildrenChanged(){this.parent?.onChildrenChanged()}},Re=class extends M{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??m(),e)}constructor(e,n,r,i){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(r,i),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},ze=class extends M{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??m(),e,n)}constructor(e,n,r){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,r)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??m());this.renderer.setChildren(this.rendererNode??m(),e)}},Me=class extends M{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??m()))}},fe=Ce({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function r(){var i=typeof SuppressedError=="function"?SuppressedError:function(c,o){var l=Error();return l.name="SuppressedError",l.error=c,l.suppressed=o,l},t={},u=[];function s(c,o){if(o!=null){if(Object(o)!==o)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(c)var l=o[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(l===void 0&&(l=o[Symbol.dispose||Symbol.for("Symbol.dispose")],c))var a=l;if(typeof l!="function")throw new TypeError("Object is not disposable.");a&&(l=function f(){try{a.call(o)}catch(p){return Promise.reject(p)}}),u.push({v:o,d:l,a:c})}else c&&u.push({d:o,a:c});return o}return{e:t,u:s.bind(null,!1),a:s.bind(null,!0),d(){var c,o=this.e,l=0;function a(){for(;c=u.pop();)try{if(!c.a&&l===1)return l=0,u.push(c),Promise.resolve().then(a);if(c.d){var p=c.d.call(c.v);if(c.a)return l|=2,Promise.resolve(p).then(a,f)}else l|=1}catch(h){return f(h)}if(l===1)return o!==t?Promise.reject(o):Promise.resolve();if(o!==t)throw o}function f(p){return o=o!==t?new i(p,o):p,a()}return a()}}}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),ce=K(fe(),1),On=K(fe(),1);Nn=K(fe(),1)});function pe(e,n){let r=n.split("/").map((t)=>t.trim()).filter((t)=>t!=="");function i(t,u,s,c){if(t===e.length&&u===r.length)return{matched:!0,params:{...s},spreads:{...c}};if(t===e.length||u>r.length)return{matched:!1};let o=e[t]??m();if(o.type==="static"){if(u>=r.length||r[u]!==o.match)return{matched:!1};return i(t+1,u+1,s,c)}else if(o.type==="slug"){if(u>=r.length)return{matched:!1};let l={...s,[o.name]:r[u]};return i(t+1,u+1,l,c)}else if(o.type==="spread"){for(let l=0;l<=r.length-u;l++){let a={...c,[o.name]:r.slice(u,u+l)},f=i(t+1,u+l,s,a);if(f.matched)return f}return{matched:!1}}return{matched:!1}}return i(0,0,{},{})}var Ue=d(()=>{b();F();b()});function x(e,n){let{children:r,...i}=n||{};if(e===w)return{type:"fragment",children:$(r)};if(typeof e==="string")return z(e,i,r);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(r)}};throw new Error(`Invalid JSX type: ${e}`)}var ye;var We=d(()=>{Z();ye=x});var Je=d(()=>{We()});function Dn(){return E((e)=>{return new URL(e(G)).pathname})}function Cn(){if(typeof window==="undefined")return;G.subscribe((e)=>{if(window.location.href!==e)window.history.pushState({},"",e)},{callInitially:!1}),window.addEventListener("popstate",()=>{G.set(window.location.href)}),document.addEventListener("click",(e)=>{let r=e.composedPath().find((i)=>i instanceof HTMLAnchorElement);if(r?.href){let i=new URL(r.href,C(G));if(i.origin!==window.location.origin)return;e.preventDefault(),G.set(i.href)}})}function jn({pathname:e,props:n,loaders:r}){if("location"in globalThis)Cn();qe();let i=Ge(),t=e?j(e):Dn(),u=E((l)=>{let a=l(t);return n.routes.find((f)=>pe(f.matcher,a))}),s=E(async(l)=>{let a=l(u)??m(),f=[];for(let p of a.frames)f.push(await(r[p.index]??m())());return f}),c=le(E((l)=>{return i(l(s))})),o=E((l)=>{let a=x(w,{}),f=l(c);if(!f)return x("h1",{children:"loading"});for(let p of f.toReversed())a=x(p,{children:a});return a});return ye("html",{children:[ye("head",{children:[x("link",{rel:"stylesheet",href:"/styles.css"}),x("script",{src:"/entrypoint-client.js",type:"module"})]}),x("body",{children:o})]})}async function Be({props:e,loaders:n,renderer:r,root:i,pathname:t,lifetime:u=new v,context:s}){e:if("window"in globalThis){let c=t??window.location.pathname,o=e.routes.find((l)=>pe(l.matcher,c));if(!o)break e;for(let l of o.frames)await(n[l.index]??m())()}Fe({context:s,renderer:r,root:i,component:x(jn,{pathname:t,props:e,loaders:n})}).cascadesFrom(u)}function Xe(e){return async function(n){return await e.impl(n)}}var G;var he=d(()=>{Ue();b();F();Je();b();G=j(typeof window!=="undefined"?window.location.href:"/")});function qn(e){return{lang:e?.lang??ve?.lang,message:e?.message,abortEarly:e?.abortEarly??ve?.abortEarly,abortPipeEarly:e?.abortPipeEarly??ve?.abortPipeEarly}}function zn(e){return Rn?.get(e)}function Fn(e){return Mn?.get(e)}function Un(e,n){return Gn?.get(e)?.get(n)}function Wn(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function de(e,n,r,i,t){let u=t&&"input"in t?t.input:r.value,s=t?.expected??e.expects??null,c=t?.received??Wn(u),o={kind:e.kind,type:e.type,input:u,expected:s,received:c,message:`Invalid ${n}: ${s?`Expected ${s} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:t?.path,issues:t?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},l=e.kind==="schema",a=t?.message??e.message??Un(e.reference,o.lang)??(l?Fn(o.lang):null)??i.message??zn(o.lang);if(a!==void 0)o.message=typeof a==="function"?a(o):a;if(l)r.typed=!1;if(r.issues)r.issues.push(o);else r.issues=[o]}function Ze(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},qn())}}}function Jn(e,n,r){return typeof e.fallback==="function"?e.fallback(n,r):e.fallback}function Bn(e,n,r){return typeof e.default==="function"?e.default(n,r):e.default}function Q(e){return{kind:"schema",type:"number",reference:Q,expects:"number",async:!1,message:e,get "~standard"(){return Ze(this)},"~run"(n,r){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else de(this,"type",n,r);return n}}}function ge(e,n){return{kind:"schema",type:"object",reference:ge,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return Ze(this)},"~run"(r,i){let t=r.value;if(t&&typeof t==="object"){r.typed=!0,r.value={};for(let u in this.entries){let s=this.entries[u];if(u in t||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){let c=u in t?t[u]:Bn(s),o=s["~run"]({value:c},i);if(o.issues){let l={type:"object",origin:"value",input:t,key:u,value:c};for(let a of o.issues){if(a.path)a.path.unshift(l);else a.path=[l];r.issues?.push(a)}if(!r.issues)r.issues=o.issues;if(i.abortEarly){r.typed=!1;break}}if(!o.typed)r.typed=!1;r.value[u]=o.value}else if(s.fallback!==void 0)r.value[u]=Jn(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"){if(de(this,"key",r,i,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:t,key:u,value:t[u]}]}),i.abortEarly)break}}}else de(this,"type",r,i);return r}}}var ve,Rn,Mn,Gn;var Qe=()=>{};function T(e,n,r,i,t,u){let{children:s,...c}=n||{};if(e===w)return{type:"fragment",children:$(s),...t};if(typeof e==="string")return z(e,c,s,t);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(s)},...t};throw new Error(`Invalid JSX type: ${e}`)}var Ye=d(()=>{Z()});var be=d(()=>{Ye()});var Kn,en=function(){return T(w,{children:[T("h1",{class:"text-4xl font-bold",children:["Welcome to Wormhole, ",Object.entries(globalThis).length]},void 0,!0,void 0,this),T("p",{children:["This is an example app, go to the"," ",T("a",{href:"/docs/tada",children:"docs"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T("button",{"on:click":async()=>{console.log(await Kn({a:1,b:2}))},children:"add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},Vn=function({a:e,b:n}){return e+n},Hn;var nn=d(()=>{Qe();he();be();Kn=Xe({schema:Hn,impl:Vn,endpoint:"/api/add",method:"GET",isQuery:!0}),Hn=ge({a:Q(),b:Q()})});var rn={};ln(rn,{$d_109_720:()=>en});var tn=d(()=>{nn()});he();F();b();F();b();function Tn(e){return"tagName"in e?e.tagName:"Text"}function Pn(){return{html:"",write(e){this.html+=e},lastType:""}}function Ke(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function me(e,n=Pn()){let r=Tn(e);if(r==="Text"&&n.lastType==="Text")n.write("");if(n.lastType=r,"tagName"in e){n.write("<"),n.write(e.tagName);for(let[i,t]of Object.entries(e.attributes)){if(t===void 0)continue;n.write(` ${i}="${Ke(t)}"`)}n.write(">");for(let i of e.children)me(i,n);n.write("")}if("content"in e)n.write(Ke(e.content.toString()));return n.html}function Ln(e){return e.split(/(?=[A-Z])/).map((r)=>r.toLowerCase()).join("-")}function Ve(){return{createNode(e,n){return{tagName:e,attributes:{},children:[],parent:void 0}},setAttribute(e,n,r){if(!("tagName"in e))throw new Error("Cannot set attribute on a text node");e.attributes[n]=r},createTextNode(e){return{content:"",parent:void 0}},setTextContent(e,n){if(!("content"in e))throw new Error("Cannot set text content on a non-text node");e.content=n},setChildren(e,n){if(!("children"in e))throw new Error("Cannot set children on a text node");e.children=n;for(let r of n)r.parent=e},getHydrationContext(e){return},addEventListener(e,n,r){return new v},bindValue(e,n,r){return new v},setStyle(e,n,r){if(!("attributes"in e))throw new Error("Cannot set style on a text node");let i=e.attributes.style??"";i+=`${Ln(n)}: ${r};`,e.attributes.style=i}}}function He(){return{tagName:"html",attributes:{},children:[],parent:void 0,fixedIdent:"document.documentElement"}}var Zn=JSON.parse('{"routes":[{"matcher":[],"frames":[{"index":0}],"is404":false}]}'),Qn=[async()=>(await Promise.resolve().then(() => (tn(),rn))).$d_109_720];async function Yn(e){let r=new URL(e.url).pathname,i=Ve(),t=He(),u=new v;try{await Be({props:Zn,loaders:Qn,renderer:i,root:t,pathname:r,context:{},lifetime:u});let s=me(t);return new Response(s,{status:200,headers:{"Content-Type":"text/html"}})}catch(s){return console.error("Rendering error:",s),new Response("Internal Server Error",{status:500})}finally{u.close()}}export{Yn as default}; diff --git a/packages/example-wormhole/.vercel/output/static/client.js b/packages/example-wormhole/.vercel/output/static/client.js new file mode 100644 index 0000000..dc0f6b0 --- /dev/null +++ b/packages/example-wormhole/.vercel/output/static/client.js @@ -0,0 +1 @@ +import{e as o,f as c,g as u,h as a,i as m,m as L}from"./chunk-y10xypd8.js";function f(s){let e={htmlFor:"for",className:"class",tabIndex:"tabindex",ariaDescribedBy:"aria-describedby"};if(s in e)return e[s]??u();return s.split(/(?=[A-Z])/).map((n)=>n.toLowerCase()).join("-")}function d(){function s(e,t,n){if(!e)return null;while(e.unclaimedNodes.length>0){let i=e.unclaimedNodes.shift();if(i&&t(i)&&(!n||n(i)))return i}return null}return{createNode(e,t){let n=e.toLowerCase(),i=s(t,(r)=>r instanceof HTMLElement,(r)=>r.tagName.toLowerCase()===n)??document.createElement(n);for(let r=0;rt instanceof Text)??document.createTextNode("")},setTextContent(e,t){if(e instanceof Text)e.data=t;else if(e instanceof HTMLElement)e.textContent=t},setChildren(e,t){if(e instanceof HTMLElement)e.replaceChildren(...t)},getHydrationContext(e){return{unclaimedNodes:Array.from(e.childNodes)}},addEventListener(e,t,n){let i=new a;if(e instanceof HTMLElement){let r=(l)=>{n(l)};e.addEventListener(t,r),i.onClosed(()=>e.removeEventListener(t,r))}else console.warn(`Cannot add event listener to non-HTMLElement node: ${e}`);return i},bindValue(e,t,n){let i=new a;if(e[t]=m(n),t==="value"){let r=function(){n.set(e[t])};e.addEventListener("input",r),i.onClosed(()=>e.removeEventListener("input",r))}if(t==="checked"){let r=function(){n.set(e[t])};e.addEventListener("change",r),i.onClosed(()=>e.removeEventListener("change",r))}return i},setStyle(e,t,n){if(e instanceof HTMLElement)e.style[t]=n}}}var E=JSON.parse('{"routes":[{"matcher":[],"frames":[{"index":0}],"is404":false},{"matcher":[{"type":"static","match":"docs"},{"type":"spread","name":"page"}],"frames":[{"index":1},{"index":2}],"is404":false},{"matcher":[{"type":"spread","name":"404"}],"frames":[{"index":1},{"index":3}],"is404":true}]}');function T(s){let e=[async()=>(await import("./chunk-cyknm2v7.js")).$d_109_720,async()=>(await import("./chunk-36xsa23c.js")).$d_732_888,async()=>(await import("./chunk-jwed2480.js")).$d_1050_1265,async()=>(await import("./chunk-h4x07z29.js")).$d_902_1009],t=d(),n=document.documentElement;return L({props:E,loaders:e,renderer:t,root:n,pathname:s.pathname,context:s.context,lifetime:s.lifetime??new a})}window.wormhole={};window.wormhole.hydrate=T;document.addEventListener("DOMContentLoaded",()=>{let s=window.location.pathname;T({pathname:s,context:{},lifetime:new a})}); diff --git a/packages/example-wormhole/.vercel/output/static/styles.css b/packages/example-wormhole/.vercel/output/static/styles.css new file mode 100644 index 0000000..d308d57 --- /dev/null +++ b/packages/example-wormhole/.vercel/output/static/styles.css @@ -0,0 +1 @@ +/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties;@layer theme,base,components,utilities;@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--text-4xl:2.25rem;--text-4xl--line-height:calc(2.5/2.25);--font-weight-bold:700;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop,::file-selector-button{box-sizing:border-box;margin:0;padding:0;border:0 solid}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;tab-size:4;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea,::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;border-radius:0;background-color:#0000;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports ( not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px){::placeholder{color:currentColor}@supports (color: color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit,::-webkit-datetime-edit-year-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-meridiem-field{padding-block:0}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]),::file-selector-button{appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}}@property --tw-font-weight{syntax:"*";inherits:false}@layer properties{@supports ((-webkit-hyphens: none) and ( not (margin-trim: inline))) or ((-moz-orient: inline) and ( not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-font-weight:initial}}} diff --git a/packages/wormhole/src/build/adapters/vercel.ts b/packages/wormhole/src/build/adapters/vercel.ts index 6758903..c4ef067 100644 --- a/packages/wormhole/src/build/adapters/vercel.ts +++ b/packages/wormhole/src/build/adapters/vercel.ts @@ -172,7 +172,6 @@ export function VercelAdapter(): VercelAdapter { codegenSource += `import { INTERNAL_entrypoint } from "@vortexjs/wormhole";`; codegenSource += `import { Lifetime } from "@vortexjs/core";`; codegenSource += `import { createHTMLRoot, ssr, printHTML } from "@vortexjs/ssr";`; - codegenSource += `import { ContextScope } from "@vortexjs/core";`; const imports: Export[] = []; @@ -215,7 +214,7 @@ export function VercelAdapter(): VercelAdapter { codegenSource += `const renderer = ssr();`; codegenSource += `const root = createHTMLRoot();`; - codegenSource += `const lifetime = new ContextScope();`; + codegenSource += `const lifetime = new Lifetime();`; codegenSource += `try {`; codegenSource += `await INTERNAL_entrypoint({ props: entrypointProps, @@ -266,7 +265,6 @@ export function VercelAdapter(): VercelAdapter { codegenSource += `import { INTERNAL_entrypoint } from "@vortexjs/wormhole";`; codegenSource += `import { Lifetime } from "@vortexjs/core";`; codegenSource += `import { createHTMLRoot, ssr, printHTML } from "@vortexjs/ssr";`; - codegenSource += `import { ContextScope } from "@vortexjs/core";`; codegenSource += `import {INTERNAL_tryHandleAPI} from "@vortexjs/wormhole";`; const imports: Export[] = []; @@ -344,7 +342,7 @@ export function VercelAdapter(): VercelAdapter { // Handle page routes codegenSource += `const renderer = ssr();`; codegenSource += `const root = createHTMLRoot();`; - codegenSource += `const lifetime = new ContextScope();`; + codegenSource += `const lifetime = new Lifetime();`; codegenSource += `try {`; codegenSource += `await INTERNAL_entrypoint({ props: entrypointProps, @@ -453,6 +451,10 @@ export function VercelAdapter(): VercelAdapter { src: "/client.js", dest: "/static/client.js" }); + routes.push({ + src: "/entrypoint-client.js", + dest: "/static/client.js" + }); routes.push({ src: "/styles.css", dest: "/static/styles.css" From e0f722a79f29f071cb782dc0252354bb5e1b45b1 Mon Sep 17 00:00:00 2001 From: andylovescode Date: Fri, 22 Aug 2025 11:25:37 -0700 Subject: [PATCH 08/15] Vercel: Make CSR work --- packages/example-wormhole/.gitignore | 2 ++ packages/example-wormhole/.vercel/output/config.json | 12 ------------ .../output/functions/api-api/add.func/index.js | 8 ++++---- .../.vercel/output/functions/index.func/index.js | 12 ++++++------ .../output/functions/route-[...404].func/index.js | 2 +- .../functions/route-docs/[...page].func/index.js | 2 +- .../output/functions/route-index.func/index.js | 2 +- .../example-wormhole/.vercel/output/static/client.js | 2 +- packages/example-wormhole/package.json | 3 ++- 9 files changed, 18 insertions(+), 27 deletions(-) diff --git a/packages/example-wormhole/.gitignore b/packages/example-wormhole/.gitignore index e61b97a..d2b9bc7 100644 --- a/packages/example-wormhole/.gitignore +++ b/packages/example-wormhole/.gitignore @@ -33,3 +33,5 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json # Finder (MacOS) folder config .DS_Store .wormhole + +.vercel diff --git a/packages/example-wormhole/.vercel/output/config.json b/packages/example-wormhole/.vercel/output/config.json index b9e121d..8d02274 100644 --- a/packages/example-wormhole/.vercel/output/config.json +++ b/packages/example-wormhole/.vercel/output/config.json @@ -1,18 +1,6 @@ { "version": 3, "routes": [ - { - "src": "/client.js", - "dest": "/static/client.js" - }, - { - "src": "/entrypoint-client.js", - "dest": "/static/client.js" - }, - { - "src": "/styles.css", - "dest": "/static/styles.css" - }, { "src": "/api/add", "dest": "/functions/api-api/add.func", diff --git a/packages/example-wormhole/.vercel/output/functions/api-api/add.func/index.js b/packages/example-wormhole/.vercel/output/functions/api-api/add.func/index.js index d0f2749..5b4ef7f 100644 --- a/packages/example-wormhole/.vercel/output/functions/api-api/add.func/index.js +++ b/packages/example-wormhole/.vercel/output/functions/api-api/add.func/index.js @@ -1,8 +1,8 @@ // @bun -var je=Object.defineProperty;var Z=(e,n)=>{for(var r in n)je(e,r,{get:n[r],enumerable:!0,configurable:!0,set:(s)=>n[r]=()=>s})};var p=(e,n)=>()=>(e&&(n=e(e=0)),n);var Pe,Q=(e,n)=>{for(var r in n)Pe(e,r,{get:n[r],enumerable:!0})};var Y=p(()=>{Pe=Object.defineProperty});function ee(e){return typeof e==="object"&&e!==null&&typeof e.then==="function"}function $(e,n){if(e===n)return!0;if(typeof e!==typeof n)return!1;if(Array.isArray(e)!==Array.isArray(n))return!1;if(ee(e)||ee(n))return!1;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let r=0;r{for(var r in n)je(e,r,{get:n[r],enumerable:!0,configurable:!0,set:(s)=>n[r]=()=>s})};var p=(e,n)=>()=>(e&&(n=e(e=0)),n);var Ce,Q=(e,n)=>{for(var r in n)Ce(e,r,{get:n[r],enumerable:!0})};var Y=p(()=>{Ce=Object.defineProperty});function ee(e){return typeof e==="object"&&e!==null&&typeof e.then==="function"}function $(e,n){if(e===n)return!0;if(typeof e!==typeof n)return!1;if(Array.isArray(e)!==Array.isArray(n))return!1;if(ee(e)||ee(n))return!1;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let r=0;r="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}function A(e){return e>="0"&&e<="9"}function re(e){return O(e)||A(e)}function*te(e){let n=0,r=()=>e[n]??"",s=()=>e[n++]??"",t=()=>{n++};while(n=e.tokens.length)return null;return e.tokens[e.current++]??null}function I(e){if(e.current>=e.tokens.length)return null;return e.tokens[e.current]??null}function k(e){let n=I(e);if(n!==null)e.current++;return n}function D(e){let n=k(e);if(n===null)throw new Error("Unexpected end of input");if(n[0]==="number")return n[1];if(n[0]==="string")return n[1];if(n[0]==="keyword"){if(n[1]===g.null)return null;if(n[1]===g.undefined)return;if(n[1]===g.true)return!0;if(n[1]===g.false)return!1;throw new Error(`Unexpected keyword: ${n[1]}`)}let r=null;if(n[0]==="identifier")r=n[1],n=k(e);if(n===null)throw new Error("Unexpected end of input (after reading class)");if(n[0]==="symbol"&&n[1]==="LeftParenthesis"){let s={};while(!0){let t=k(e);if(t===null)throw new Error("Unexpected end of input (when trying to read key)");if(t[0]==="symbol"&&t[1]==="RightParenthesis")break;if(t[0]!=="identifier"&&t[0]!=="string")throw new Error(`Expected identifier or string, got ${t[0]}`);let i=k(e);if(i===null||i[0]!=="symbol"||i[1]!=="Equals")throw new Error(`Expected '=', got ${i?i[0]:"end of input"}`);let o=t[1],l=D(e);s[o]=l}if(r!==null){if(r==="date")return new Date(s.unix);if(r==="set")return new Set(s.items);if(r==="map"){let t=new Map;for(let[i,o]of s.entries)t.set(i,o);return t}throw new Error(`Unknown class: ${r}`)}return s}if(n[0]==="symbol"&&n[1]==="LeftSquareBracket"){let s=[];while(!0){if(I(e)?.[0]==="symbol"&&I(e)?.[1]==="RightSquareBracket"){k(e);break}let t=D(e);s.push(t)}return s}}function Ne(e){let n=[...te(e)],r=ie(n),s=D(r);if(r.currentt[0]).join(", ")}`);return s}function se(){return{output:"",indentLevel:0,minified:!1}}function w(e){e.indentLevel++}function _(e){e.indentLevel=Math.max(0,e.indentLevel-1)}function h(e){if(e.minified){a(e," ");return}a(e,` +`,t:"\t",r:"\r",b:"\b",f:"\f",v:"\v","\\":"\\"};if(c in f)l+=f[c],t();else if(c===o)l+=o,t();else l+=u}else l+=u}if(r()===o)t();yield["string",l];continue}if(i in L){yield["symbol",L[i]],t();continue}throw new Error(`Unknown character: '${i}' at position ${n}`)}}function ie(e){return{tokens:e,current:0}}function Pe(e){if(e.current>=e.tokens.length)return null;return e.tokens[e.current++]??null}function I(e){if(e.current>=e.tokens.length)return null;return e.tokens[e.current]??null}function k(e){let n=I(e);if(n!==null)e.current++;return n}function S(e){let n=k(e);if(n===null)throw new Error("Unexpected end of input");if(n[0]==="number")return n[1];if(n[0]==="string")return n[1];if(n[0]==="keyword"){if(n[1]===g.null)return null;if(n[1]===g.undefined)return;if(n[1]===g.true)return!0;if(n[1]===g.false)return!1;throw new Error(`Unexpected keyword: ${n[1]}`)}let r=null;if(n[0]==="identifier")r=n[1],n=k(e);if(n===null)throw new Error("Unexpected end of input (after reading class)");if(n[0]==="symbol"&&n[1]==="LeftParenthesis"){let s={};while(!0){let t=k(e);if(t===null)throw new Error("Unexpected end of input (when trying to read key)");if(t[0]==="symbol"&&t[1]==="RightParenthesis")break;if(t[0]!=="identifier"&&t[0]!=="string")throw new Error(`Expected identifier or string, got ${t[0]}`);let i=k(e);if(i===null||i[0]!=="symbol"||i[1]!=="Equals")throw new Error(`Expected '=', got ${i?i[0]:"end of input"}`);let o=t[1],l=S(e);s[o]=l}if(r!==null){if(r==="date")return new Date(s.unix);if(r==="set")return new Set(s.items);if(r==="map"){let t=new Map;for(let[i,o]of s.entries)t.set(i,o);return t}throw new Error(`Unknown class: ${r}`)}return s}if(n[0]==="symbol"&&n[1]==="LeftSquareBracket"){let s=[];while(!0){if(I(e)?.[0]==="symbol"&&I(e)?.[1]==="RightSquareBracket"){k(e);break}let t=S(e);s.push(t)}return s}}function Ne(e){let n=[...te(e)],r=ie(n),s=S(r);if(r.currentt[0]).join(", ")}`);return s}function se(){return{output:"",indentLevel:0,minified:!1}}function w(e){e.indentLevel++}function _(e){e.indentLevel=Math.max(0,e.indentLevel-1)}function h(e){if(e.minified){a(e," ");return}a(e,` `),a(e," ".repeat(e.indentLevel))}function a(e,n){e.output+=n}function q(e){let n=Number.POSITIVE_INFINITY,r="";for(let s of['"',"'","`"]){let t="";t+=s;for(let i of e)if(i===s)t+=`\\${i}`;else if(i==="\\")t+="\\\\";else if(i===` -`)t+="\\n";else if(i==="\t")t+="\\t";else if(i==="\r")t+="\\r";else t+=i;if(t+=s,t.length{Y();S={};Q(S,{escapeStr:()=>q,isAlphabetic:()=>O,isAlphanumeric:()=>re,isNumeric:()=>A,isWhitespace:()=>ne,keywords:()=>g,lex:()=>te,parse:()=>Ne,parseContext_create:()=>ie,parseContext_next:()=>Ce,parseContext_peek:()=>I,parseContext_read:()=>k,parseContext_readObj:()=>D,serialize:()=>ue,serializeContext_create:()=>se,serializeContext_dedent:()=>_,serializeContext_indent:()=>w,serializeContext_newline:()=>h,serializeContext_write:()=>a,serializeContext_writeObject:()=>b,stringify:()=>Te,symbols:()=>L});g={null:"Null",true:"True",false:"False",undefined:"Undefined"},L={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};Te=ue});var Re,z,ze,oe,Me,Fe,le=(e,n)=>function(){return n||(0,e[oe(e)[0]])((n={exports:{}}).exports,n),n.exports},ce=(e,n)=>{for(var r in n)z(e,r,{get:n[r],enumerable:!0})},Ge=(e,n,r,s)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var t=oe(n),i=0,o=t.length,l;in[u]).bind(null,l),enumerable:!(s=ze(n,l))||s.enumerable})}return e},j=(e,n,r)=>(r=e!=null?Re(Me(e)):{},Ge(n||!e||!e.__esModule?z(r,"default",{value:e,enumerable:!0}):r,e));var fe=p(()=>{Re=Object.create,z=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,oe=Object.getOwnPropertyNames,Me=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty});function pe(e){let n,r=e,s=[];return n&&console.log(`[${n}]: initialized with `,r),{setId(t){n=t},[ae](){return r},subscribe(t,i){if(s.push(t),n&&console.trace(`[${n}]: subscribed with `,t),i?.callInitially!==!1)t(r);return new M().onClosed(()=>{s.splice(s.indexOf(t),1),n&&console.log(`[${n}]: unsubscribed `,t)})},set(t){if(n&&console.log(`[${n}]: trying to switch from `,r," -> ",t),!$(r,t)){r=t;for(let i of s)i(r);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}var Ue,M,ae="@vortex-get-internal",P,E;var C=p(()=>{v();Ue=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let r=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=r},[Symbol.dispose](){e.hookLifetime=r}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},M=class extends R({package:"@vortexjs/core",name:"Lifetime"},Ue){};P=pe,E=R({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});var Be,Je,Ke=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)Je(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=Be(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},Ve=class e{contexts={};streaming=new Ke;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,r){this.contexts[n]=r}static current=null;static setCurrent(n){let r=e.current;return e.current=n,{[Symbol.dispose](){e.current=r}}}},He,x=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(r){if(r instanceof de)for(let s of r.children)n(s);else e.push(r)}for(let r of this.children)n(r);return e}},de,Ze,Qe,Ye,F,Ln,qn,Rn;var G=p(()=>{fe();C();v();v();Be=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),Je=globalThis.clearImmediate??((e)=>{clearTimeout(e)}),He={};ce(He,{FLElement:()=>Qe,FLFragment:()=>de,FLNode:()=>x,FLPortal:()=>Ye,FLText:()=>Ze});de=class extends x{onChildrenChanged(){this.parent?.onChildrenChanged()}},Ze=class extends x{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??y(),e)}constructor(e,n,r,s){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(r,s),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},Qe=class extends x{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??y(),e,n)}constructor(e,n,r){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,r)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??y());this.renderer.setChildren(this.rendererNode??y(),e)}},Ye=class extends x{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??y()))}},F=le({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function r(){var s=typeof SuppressedError=="function"?SuppressedError:function(l,u){var c=Error();return c.name="SuppressedError",c.error=l,c.suppressed=u,c},t={},i=[];function o(l,u){if(u!=null){if(Object(u)!==u)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(l)var c=u[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(c===void 0&&(c=u[Symbol.dispose||Symbol.for("Symbol.dispose")],l))var f=c;if(typeof c!="function")throw new TypeError("Object is not disposable.");f&&(c=function m(){try{f.call(u)}catch(d){return Promise.reject(d)}}),i.push({v:u,d:c,a:l})}else l&&i.push({d:u,a:l});return u}return{e:t,u:o.bind(null,!1),a:o.bind(null,!0),d(){var l,u=this.e,c=0;function f(){for(;l=i.pop();)try{if(!l.a&&c===1)return c=0,i.push(l),Promise.resolve().then(f);if(l.d){var d=l.d.call(l.v);if(l.a)return c|=2,Promise.resolve(d).then(f,m)}else c|=1}catch(T){return m(T)}if(c===1)return u!==t?Promise.reject(u):Promise.resolve();if(u!==t)throw u}function m(d){return u=u!==t?new s(d,u):d,f()}return f()}}}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),Ln=j(F(),1),qn=j(F(),1),Rn=j(F(),1)});function ge(e,n){let r=n.split("/").map((t)=>t.trim()).filter((t)=>t!=="");function s(t,i,o,l){if(t===e.length&&i===r.length)return{matched:!0,params:{...o},spreads:{...l}};if(t===e.length||i>r.length)return{matched:!1};let u=e[t]??y();if(u.type==="static"){if(i>=r.length||r[i]!==u.match)return{matched:!1};return s(t+1,i+1,o,l)}else if(u.type==="slug"){if(i>=r.length)return{matched:!1};let c={...o,[u.name]:r[i]};return s(t+1,i+1,c,l)}else if(u.type==="spread"){for(let c=0;c<=r.length-i;c++){let f={...l,[u.name]:r.slice(i,i+c)},m=s(t+1,i+c,o,f);if(m.matched)return m}return{matched:!1}}return{matched:!1}}return s(0,0,{},{})}var ke=p(()=>{v();G();v()});var be=p(()=>{C()});var we=p(()=>{be()});function _e(e){return async function(n){return await e.impl(n)}}async function Ee(e,n,r){let s=new URL(e.url).pathname;for(let t of n){if(!ge(t.matcher,s).matched)continue;if(t.method!==e.method)continue;let i=(r[t.schema]??y())(),o=(r[t.impl]??y())(),l=e.method==="GET"?new URL(e.url).searchParams.get("props")??"":await e.text(),u;try{u=S.parse(l)}catch{return new Response(["Your API request failed.","Why: The request body is not valid SKL"].join(` +`)t+="\\n";else if(i==="\t")t+="\\t";else if(i==="\r")t+="\\r";else t+=i;if(t+=s,t.length{Y();D={};Q(D,{escapeStr:()=>q,isAlphabetic:()=>O,isAlphanumeric:()=>re,isNumeric:()=>A,isWhitespace:()=>ne,keywords:()=>g,lex:()=>te,parse:()=>Ne,parseContext_create:()=>ie,parseContext_next:()=>Pe,parseContext_peek:()=>I,parseContext_read:()=>k,parseContext_readObj:()=>S,serialize:()=>ue,serializeContext_create:()=>se,serializeContext_dedent:()=>_,serializeContext_indent:()=>w,serializeContext_newline:()=>h,serializeContext_write:()=>a,serializeContext_writeObject:()=>b,stringify:()=>Te,symbols:()=>L});g={null:"Null",true:"True",false:"False",undefined:"Undefined"},L={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};Te=ue});var Re,z,ze,oe,Me,Fe,le=(e,n)=>function(){return n||e[oe(e)[0]]((n={exports:{}}).exports,n),n.exports},ce=(e,n)=>{for(var r in n)z(e,r,{get:n[r],enumerable:!0})},Ge=(e,n,r,s)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var t=oe(n),i=0,o=t.length,l;in[u]).bind(null,l),enumerable:!(s=ze(n,l))||s.enumerable})}return e},j=(e,n,r)=>(r=e!=null?Re(Me(e)):{},Ge(n||!e||!e.__esModule?z(r,"default",{value:e,enumerable:!0}):r,e));var fe=p(()=>{Re=Object.create,z=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,oe=Object.getOwnPropertyNames,Me=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty});function pe(e){let n,r=e,s=[];return n&&console.log(`[${n}]: initialized with `,r),{setId(t){n=t},[ae](){return r},subscribe(t,i){if(s.push(t),n&&console.trace(`[${n}]: subscribed with `,t),i?.callInitially!==!1)t(r);return new M().onClosed(()=>{s.splice(s.indexOf(t),1),n&&console.log(`[${n}]: unsubscribed `,t)})},set(t){if(n&&console.log(`[${n}]: trying to switch from `,r," -> ",t),!$(r,t)){r=t;for(let i of s)i(r);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}var Ue,M,ae="@vortex-get-internal",C,x;var P=p(()=>{v();Ue=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let r=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=r},[Symbol.dispose](){e.hookLifetime=r}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},M=class extends R({package:"@vortexjs/core",name:"Lifetime"},Ue){};C=pe,x=R({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});var Be,Je,Ke=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)Je(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=Be(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},Ve=class e{contexts={};streaming=new Ke;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,r){this.contexts[n]=r}static current=null;static setCurrent(n){let r=e.current;return e.current=n,{[Symbol.dispose](){e.current=r}}}},He,E=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(r){if(r instanceof de)for(let s of r.children)n(s);else e.push(r)}for(let r of this.children)n(r);return e}},de,Ze,Qe,Ye,F,Ln,qn,Rn;var G=p(()=>{fe();P();v();v();Be=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),Je=globalThis.clearImmediate??((e)=>{clearTimeout(e)}),He={};ce(He,{FLElement:()=>Qe,FLFragment:()=>de,FLNode:()=>E,FLPortal:()=>Ye,FLText:()=>Ze});de=class extends E{onChildrenChanged(){this.parent?.onChildrenChanged()}},Ze=class extends E{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??y(),e)}constructor(e,n,r,s){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(r,s),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},Qe=class extends E{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??y(),e,n)}constructor(e,n,r){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,r)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??y());this.renderer.setChildren(this.rendererNode??y(),e)}},Ye=class extends E{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??y()))}},F=le({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function r(){var s=typeof SuppressedError=="function"?SuppressedError:function(l,u){var c=Error();return c.name="SuppressedError",c.error=l,c.suppressed=u,c},t={},i=[];function o(l,u){if(u!=null){if(Object(u)!==u)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(l)var c=u[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(c===void 0&&(c=u[Symbol.dispose||Symbol.for("Symbol.dispose")],l))var f=c;if(typeof c!="function")throw new TypeError("Object is not disposable.");f&&(c=function m(){try{f.call(u)}catch(d){return Promise.reject(d)}}),i.push({v:u,d:c,a:l})}else l&&i.push({d:u,a:l});return u}return{e:t,u:o.bind(null,!1),a:o.bind(null,!0),d(){var l,u=this.e,c=0;function f(){for(;l=i.pop();)try{if(!l.a&&c===1)return c=0,i.push(l),Promise.resolve().then(f);if(l.d){var d=l.d.call(l.v);if(l.a)return c|=2,Promise.resolve(d).then(f,m)}else c|=1}catch(T){return m(T)}if(c===1)return u!==t?Promise.reject(u):Promise.resolve();if(u!==t)throw u}function m(d){return u=u!==t?new s(d,u):d,f()}return f()}}}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),Ln=j(F(),1),qn=j(F(),1),Rn=j(F(),1)});function ge(e,n){let r=n.split("/").map((t)=>t.trim()).filter((t)=>t!=="");function s(t,i,o,l){if(t===e.length&&i===r.length)return{matched:!0,params:{...o},spreads:{...l}};if(t===e.length||i>r.length)return{matched:!1};let u=e[t]??y();if(u.type==="static"){if(i>=r.length||r[i]!==u.match)return{matched:!1};return s(t+1,i+1,o,l)}else if(u.type==="slug"){if(i>=r.length)return{matched:!1};let c={...o,[u.name]:r[i]};return s(t+1,i+1,c,l)}else if(u.type==="spread"){for(let c=0;c<=r.length-i;c++){let f={...l,[u.name]:r.slice(i,i+c)},m=s(t+1,i+c,o,f);if(m.matched)return m}return{matched:!1}}return{matched:!1}}return s(0,0,{},{})}var ke=p(()=>{v();G();v()});var be=p(()=>{P()});var we=p(()=>{be()});function _e(e){return async function(n){return await e.impl(n)}}async function xe(e,n,r){let s=new URL(e.url).pathname;for(let t of n){if(!ge(t.matcher,s).matched)continue;if(t.method!==e.method)continue;let i=(r[t.schema]??y())(),o=(r[t.impl]??y())(),l=e.method==="GET"?new URL(e.url).searchParams.get("props")??"":await e.text(),u;try{u=D.parse(l)}catch{return new Response(["Your API request failed.","Why: The request body is not valid SKL"].join(` `),{status:400,statusText:"Invalid SKL"})}let f=await(await i)["~standard"].validate(u);if("issues"in f)return new Response(["Your API request failed.","Why: The request body did not match the expected schema"].join(` -`),{status:400,statusText:"Failed to match against schema"});let m=f.value,T=await(await o)(m);return new Response(S.stringify(T))}}var yr;var U=p(()=>{ke();v();G();we();v();yr=P(typeof window!=="undefined"?window.location.href:"/")});function en(e){return{lang:e?.lang??W?.lang,message:e?.message,abortEarly:e?.abortEarly??W?.abortEarly,abortPipeEarly:e?.abortPipeEarly??W?.abortPipeEarly}}function rn(e){return nn?.get(e)}function sn(e){return tn?.get(e)}function on(e,n){return un?.get(e)?.get(n)}function ln(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function X(e,n,r,s,t){let i=t&&"input"in t?t.input:r.value,o=t?.expected??e.expects??null,l=t?.received??ln(i),u={kind:e.kind,type:e.type,input:i,expected:o,received:l,message:`Invalid ${n}: ${o?`Expected ${o} but r`:"R"}eceived ${l}`,requirement:e.requirement,path:t?.path,issues:t?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},c=e.kind==="schema",f=t?.message??e.message??on(e.reference,u.lang)??(c?sn(u.lang):null)??s.message??rn(u.lang);if(f!==void 0)u.message=typeof f==="function"?f(u):f;if(c)r.typed=!1;if(r.issues)r.issues.push(u);else r.issues=[u]}function xe(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},en())}}}function cn(e,n,r){return typeof e.fallback==="function"?e.fallback(n,r):e.fallback}function fn(e,n,r){return typeof e.default==="function"?e.default(n,r):e.default}function N(e){return{kind:"schema",type:"number",reference:N,expects:"number",async:!1,message:e,get "~standard"(){return xe(this)},"~run"(n,r){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else X(this,"type",n,r);return n}}}function B(e,n){return{kind:"schema",type:"object",reference:B,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return xe(this)},"~run"(r,s){let t=r.value;if(t&&typeof t==="object"){r.typed=!0,r.value={};for(let i in this.entries){let o=this.entries[i];if(i in t||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){let l=i in t?t[i]:fn(o),u=o["~run"]({value:l},s);if(u.issues){let c={type:"object",origin:"value",input:t,key:i,value:l};for(let f of u.issues){if(f.path)f.path.unshift(c);else f.path=[c];r.issues?.push(f)}if(!r.issues)r.issues=u.issues;if(s.abortEarly){r.typed=!1;break}}if(!u.typed)r.typed=!1;r.value[i]=u.value}else if(o.fallback!==void 0)r.value[i]=cn(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"){if(X(this,"key",r,s,{input:void 0,expected:`"${i}"`,path:[{type:"object",origin:"key",input:t,key:i,value:t[i]}]}),s.abortEarly)break}}}else X(this,"type",r,s);return r}}}var W,nn,tn,un;var $e=()=>{};var Ae=p(()=>{C()});var J=p(()=>{Ae()});var wr,K=function({a:e,b:n}){return e+n},V;var H=p(()=>{$e();U();J();wr=_e({schema:V,impl:K,endpoint:"/api/add",method:"GET",isQuery:!0}),V=B({a:N(),b:N()})});var Ie={};Z(Ie,{$d_1395_1435:()=>K});var De=p(()=>{H()});var Se={};Z(Se,{$d_1323_1385:()=>V});var Oe=p(()=>{H()});U();var pn=[{matcher:[{type:"static",match:"api"},{type:"static",match:"add"}],impl:0,schema:1,method:"GET"}],yn=[async()=>(await Promise.resolve().then(() => (De(),Ie))).$d_1395_1435,async()=>(await Promise.resolve().then(() => (Oe(),Se))).$d_1323_1385];async function hn(e){return await Ee(e,pn,yn)||new Response("Not Found",{status:404})}export{hn as default}; +`),{status:400,statusText:"Failed to match against schema"});let m=f.value,T=await(await o)(m);return new Response(D.stringify(T))}}var yr;var U=p(()=>{ke();v();G();we();v();yr=C(typeof window!=="undefined"?window.location.href:"/")});function en(e){return{lang:e?.lang??W?.lang,message:e?.message,abortEarly:e?.abortEarly??W?.abortEarly,abortPipeEarly:e?.abortPipeEarly??W?.abortPipeEarly}}function rn(e){return nn?.get(e)}function sn(e){return tn?.get(e)}function on(e,n){return un?.get(e)?.get(n)}function ln(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function X(e,n,r,s,t){let i=t&&"input"in t?t.input:r.value,o=t?.expected??e.expects??null,l=t?.received??ln(i),u={kind:e.kind,type:e.type,input:i,expected:o,received:l,message:`Invalid ${n}: ${o?`Expected ${o} but r`:"R"}eceived ${l}`,requirement:e.requirement,path:t?.path,issues:t?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},c=e.kind==="schema",f=t?.message??e.message??on(e.reference,u.lang)??(c?sn(u.lang):null)??s.message??rn(u.lang);if(f!==void 0)u.message=typeof f==="function"?f(u):f;if(c)r.typed=!1;if(r.issues)r.issues.push(u);else r.issues=[u]}function Ee(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},en())}}}function cn(e,n,r){return typeof e.fallback==="function"?e.fallback(n,r):e.fallback}function fn(e,n,r){return typeof e.default==="function"?e.default(n,r):e.default}function N(e){return{kind:"schema",type:"number",reference:N,expects:"number",async:!1,message:e,get "~standard"(){return Ee(this)},"~run"(n,r){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else X(this,"type",n,r);return n}}}function B(e,n){return{kind:"schema",type:"object",reference:B,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return Ee(this)},"~run"(r,s){let t=r.value;if(t&&typeof t==="object"){r.typed=!0,r.value={};for(let i in this.entries){let o=this.entries[i];if(i in t||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){let l=i in t?t[i]:fn(o),u=o["~run"]({value:l},s);if(u.issues){let c={type:"object",origin:"value",input:t,key:i,value:l};for(let f of u.issues){if(f.path)f.path.unshift(c);else f.path=[c];r.issues?.push(f)}if(!r.issues)r.issues=u.issues;if(s.abortEarly){r.typed=!1;break}}if(!u.typed)r.typed=!1;r.value[i]=u.value}else if(o.fallback!==void 0)r.value[i]=cn(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"){if(X(this,"key",r,s,{input:void 0,expected:`"${i}"`,path:[{type:"object",origin:"key",input:t,key:i,value:t[i]}]}),s.abortEarly)break}}}else X(this,"type",r,s);return r}}}var W,nn,tn,un;var $e=()=>{};var Ae=p(()=>{P()});var J=p(()=>{Ae()});var wr,K=function({a:e,b:n}){return e+n},V;var H=p(()=>{$e();U();J();wr=_e({schema:V,impl:K,endpoint:"/api/add",method:"GET",isQuery:!0}),V=B({a:N(),b:N()})});var Ie={};Z(Ie,{$d_1395_1435:()=>K});var Se=p(()=>{H()});var De={};Z(De,{$d_1323_1385:()=>V});var Oe=p(()=>{H()});U();var pn=[{matcher:[{type:"static",match:"api"},{type:"static",match:"add"}],impl:0,schema:1,method:"GET"}],yn=[async()=>(await Promise.resolve().then(() => (Se(),Ie))).$d_1395_1435,async()=>(await Promise.resolve().then(() => (Oe(),De))).$d_1323_1385];async function hn(e){return await xe(e,pn,yn)||new Response("Not Found",{status:404})}export{hn as default}; diff --git a/packages/example-wormhole/.vercel/output/functions/index.func/index.js b/packages/example-wormhole/.vercel/output/functions/index.func/index.js index 64250fa..15a03d4 100644 --- a/packages/example-wormhole/.vercel/output/functions/index.func/index.js +++ b/packages/example-wormhole/.vercel/output/functions/index.func/index.js @@ -1,8 +1,8 @@ // @bun -var En=Object.defineProperty;var C=(e,n)=>{for(var t in n)En(e,t,{get:n[t],enumerable:!0,configurable:!0,set:(i)=>n[t]=()=>i})};var v=(e,n)=>()=>(e&&(n=e(e=0)),n);var $n,$e=(e,n)=>{for(var t in n)$n(e,t,{get:n[t],enumerable:!0})};var Ae=v(()=>{$n=Object.defineProperty});function Ie(e){return typeof e==="object"&&e!==null&&typeof e.then==="function"}function J(e,n){if(e===n)return!0;if(typeof e!==typeof n)return!1;if(Array.isArray(e)!==Array.isArray(n))return!1;if(Ie(e)||Ie(n))return!1;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let t=0;t="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}function B(e){return e>="0"&&e<="9"}function Oe(e){return H(e)||B(e)}function*Ne(e){let n=0,t=()=>e[n]??"",i=()=>e[n++]??"",r=()=>{n++};while(n=e.tokens.length)return null;return e.tokens[e.current++]??null}function X(e){if(e.current>=e.tokens.length)return null;return e.tokens[e.current]??null}function j(e){let n=X(e);if(n!==null)e.current++;return n}function K(e){let n=j(e);if(n===null)throw new Error("Unexpected end of input");if(n[0]==="number")return n[1];if(n[0]==="string")return n[1];if(n[0]==="keyword"){if(n[1]===S.null)return null;if(n[1]===S.undefined)return;if(n[1]===S.true)return!0;if(n[1]===S.false)return!1;throw new Error(`Unexpected keyword: ${n[1]}`)}let t=null;if(n[0]==="identifier")t=n[1],n=j(e);if(n===null)throw new Error("Unexpected end of input (after reading class)");if(n[0]==="symbol"&&n[1]==="LeftParenthesis"){let i={};while(!0){let r=j(e);if(r===null)throw new Error("Unexpected end of input (when trying to read key)");if(r[0]==="symbol"&&r[1]==="RightParenthesis")break;if(r[0]!=="identifier"&&r[0]!=="string")throw new Error(`Expected identifier or string, got ${r[0]}`);let u=j(e);if(u===null||u[0]!=="symbol"||u[1]!=="Equals")throw new Error(`Expected '=', got ${u?u[0]:"end of input"}`);let s=r[1],l=K(e);i[s]=l}if(t!==null){if(t==="date")return new Date(i.unix);if(t==="set")return new Set(i.items);if(t==="map"){let r=new Map;for(let[u,s]of i.entries)r.set(u,s);return r}throw new Error(`Unknown class: ${t}`)}return i}if(n[0]==="symbol"&&n[1]==="LeftSquareBracket"){let i=[];while(!0){if(X(e)?.[0]==="symbol"&&X(e)?.[1]==="RightSquareBracket"){j(e);break}let r=K(e);i.push(r)}return i}}function In(e){let n=[...Ne(e)],t=De(n),i=K(t);if(t.currentr[0]).join(", ")}`);return i}function Ce(){return{output:"",indentLevel:0,minified:!1}}function q(e){e.indentLevel++}function R(e){e.indentLevel=Math.max(0,e.indentLevel-1)}function _(e){if(e.minified){h(e," ");return}h(e,` +var En=Object.defineProperty;var D=(e,n)=>{for(var t in n)En(e,t,{get:n[t],enumerable:!0,configurable:!0,set:(i)=>n[t]=()=>i})};var v=(e,n)=>()=>(e&&(n=e(e=0)),n);var $n,$e=(e,n)=>{for(var t in n)$n(e,t,{get:n[t],enumerable:!0})};var Ae=v(()=>{$n=Object.defineProperty});function Ie(e){return typeof e==="object"&&e!==null&&typeof e.then==="function"}function J(e,n){if(e===n)return!0;if(typeof e!==typeof n)return!1;if(Array.isArray(e)!==Array.isArray(n))return!1;if(Ie(e)||Ie(n))return!1;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let t=0;t="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}function B(e){return e>="0"&&e<="9"}function Oe(e){return H(e)||B(e)}function*Ne(e){let n=0,t=()=>e[n]??"",i=()=>e[n++]??"",r=()=>{n++};while(n=e.tokens.length)return null;return e.tokens[e.current++]??null}function X(e){if(e.current>=e.tokens.length)return null;return e.tokens[e.current]??null}function j(e){let n=X(e);if(n!==null)e.current++;return n}function K(e){let n=j(e);if(n===null)throw new Error("Unexpected end of input");if(n[0]==="number")return n[1];if(n[0]==="string")return n[1];if(n[0]==="keyword"){if(n[1]===S.null)return null;if(n[1]===S.undefined)return;if(n[1]===S.true)return!0;if(n[1]===S.false)return!1;throw new Error(`Unexpected keyword: ${n[1]}`)}let t=null;if(n[0]==="identifier")t=n[1],n=j(e);if(n===null)throw new Error("Unexpected end of input (after reading class)");if(n[0]==="symbol"&&n[1]==="LeftParenthesis"){let i={};while(!0){let r=j(e);if(r===null)throw new Error("Unexpected end of input (when trying to read key)");if(r[0]==="symbol"&&r[1]==="RightParenthesis")break;if(r[0]!=="identifier"&&r[0]!=="string")throw new Error(`Expected identifier or string, got ${r[0]}`);let u=j(e);if(u===null||u[0]!=="symbol"||u[1]!=="Equals")throw new Error(`Expected '=', got ${u?u[0]:"end of input"}`);let s=r[1],l=K(e);i[s]=l}if(t!==null){if(t==="date")return new Date(i.unix);if(t==="set")return new Set(i.items);if(t==="map"){let r=new Map;for(let[u,s]of i.entries)r.set(u,s);return r}throw new Error(`Unknown class: ${t}`)}return i}if(n[0]==="symbol"&&n[1]==="LeftSquareBracket"){let i=[];while(!0){if(X(e)?.[0]==="symbol"&&X(e)?.[1]==="RightSquareBracket"){j(e);break}let r=K(e);i.push(r)}return i}}function In(e){let n=[...Ne(e)],t=Ce(n),i=K(t);if(t.currentr[0]).join(", ")}`);return i}function De(){return{output:"",indentLevel:0,minified:!1}}function q(e){e.indentLevel++}function R(e){e.indentLevel=Math.max(0,e.indentLevel-1)}function _(e){if(e.minified){h(e," ");return}h(e,` `),h(e," ".repeat(e.indentLevel))}function h(e,n){e.output+=n}function ue(e){let n=Number.POSITIVE_INFINITY,t="";for(let i of['"',"'","`"]){let r="";r+=i;for(let u of e)if(u===i)r+=`\\${u}`;else if(u==="\\")r+="\\\\";else if(u===` -`)r+="\\n";else if(u==="\t")r+="\\t";else if(u==="\r")r+="\\r";else r+=u;if(r+=i,r.length{Ae();V={};$e(V,{escapeStr:()=>ue,isAlphabetic:()=>H,isAlphanumeric:()=>Oe,isNumeric:()=>B,isWhitespace:()=>Se,keywords:()=>S,lex:()=>Ne,parse:()=>In,parseContext_create:()=>De,parseContext_next:()=>An,parseContext_peek:()=>X,parseContext_read:()=>j,parseContext_readObj:()=>K,serialize:()=>je,serializeContext_create:()=>Ce,serializeContext_dedent:()=>R,serializeContext_indent:()=>q,serializeContext_newline:()=>_,serializeContext_write:()=>h,serializeContext_writeObject:()=>T,stringify:()=>Sn,symbols:()=>se});S={null:"Null",true:"True",false:"False",undefined:"Undefined"},se={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};Sn=je});var Dn,ce,Cn,Pe,jn,Tn,Le=(e,n)=>function(){return n||(0,e[Pe(e)[0]])((n={exports:{}}).exports,n),n.exports},qe=(e,n)=>{for(var t in n)ce(e,t,{get:n[t],enumerable:!0})},Pn=(e,n,t,i)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var r=Pe(n),u=0,s=r.length,l;un[o]).bind(null,l),enumerable:!(i=Cn(n,l))||i.enumerable})}return e},Z=(e,n,t)=>(t=e!=null?Dn(jn(e)):{},Pn(n||!e||!e.__esModule?ce(t,"default",{value:e,enumerable:!0}):t,e));var Re=v(()=>{Dn=Object.create,ce=Object.defineProperty,Cn=Object.getOwnPropertyDescriptor,Pe=Object.getOwnPropertyNames,jn=Object.getPrototypeOf,Tn=Object.prototype.hasOwnProperty});function Y(){if(d.hookLifetime===null)throw new Error("No hook lifetime available");return d.hookLifetime}function z(e){let n,t=e,i=[];return n&&console.log(`[${n}]: initialized with `,t),{setId(r){n=r},[E](){return t},subscribe(r,u){if(i.push(r),n&&console.trace(`[${n}]: subscribed with `,r),u?.callInitially!==!1)r(t);return new d().onClosed(()=>{i.splice(i.indexOf(r),1),n&&console.log(`[${n}]: unsubscribed `,r)})},set(r){if(n&&console.log(`[${n}]: trying to switch from `,t," -> ",r),!J(t,r)){t=r;for(let u of i)u(t);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}function P(e){return e[E]()}function fe(e,n,t=Y()){let i=n?.dynamic??!1,r=[],u=z(e((o)=>{if(!r.includes(o))r.push(o);return o[E]()}));function s(){if(i){let o=new Set(r);u.set(e((p)=>{return o.add(p),p[E]()}));let c=new Set(r),a=c.difference(o);for(let p of a){let y=r.indexOf(p);if(y!==-1)r.splice(y,1),l[y]?.close(),l.splice(y,1)}let f=o.difference(c);for(let p of f){let y=p.subscribe(()=>{s()},{callInitially:!1});r.push(p),l.push(y)}}else u.set(e(P))}let l=r.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(t)});return{...u}}function pe(e,n,t=Y()){let i=n?.dynamic??!1,r=[],u=new d;e((o)=>{if(!r.includes(o))r.push(o);return o[E]()},{lifetime:u});function s(){if(i){let o=new Set(r);u.close(),u=new d().cascadesFrom(t),e((p)=>{return o.add(p),p[E]()},{lifetime:u});let c=new Set(r),a=c.difference(o);for(let p of a){let y=r.indexOf(p);if(y!==-1)r.splice(y,1),l[y]?.close(),l.splice(y,1)}let f=o.difference(c);for(let p of f){let y=p.subscribe(()=>{s()},{callInitially:!1});r.push(p),l.push(y)}}else u.close(),u=new d().cascadesFrom(t),e(P,{lifetime:u})}let l=r.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(t)})}function M(e){return typeof e==="object"&&e!==null&&E in e}function ae(e){if(M(e))return e;return z(e)}function ye(e,n=Y()){return fe((t)=>{function i(r){if(M(r))return i(t(r));return r}return i(e)},{dynamic:!0},n)}function A(e){if(e===void 0)return[];return[e].flat().filter((n)=>n!==null&&n!==void 0).map((n)=>typeof n==="string"||typeof n==="number"||typeof n==="boolean"?Q(n):M(n)?{type:"dynamic",value:$((t)=>{let i=t(n);return typeof i==="number"||typeof i==="string"||typeof i==="boolean"?Q(i):i})}:n)}function Q(e,n){return{type:"text",value:e,...n}}function F(e,n,t,i){let r=A(t).map((a)=>{if(typeof a==="string"||typeof a==="number"||typeof a==="boolean")return Q(a);return a}),u={},s={},l={},o=[],c={};for(let[a,f]of Object.entries(n))if(f!==void 0)if(a.startsWith("bind:")){let p=a.slice(5);if(!M(f)||!("set"in f))throw new Error(`Binding value for "${p}" must be a writable store.`);s[p]=f}else if(a.startsWith("on:")){let p=a.slice(3);if(typeof f!=="function")throw new Error(`Event handler for "${p}" must be a function.`);l[p]=f}else if(a==="use"){if(typeof f!=="function"&&!Array.isArray(f))throw new Error("Use hook must be a function or an array of functions.");o.push(f)}else if(a==="style"){for(let[p,y]of Object.entries(f))if(y!==void 0)c[p]=ae(y)}else u[a]=ae(f);return{type:"element",name:e,attributes:u,children:r,bindings:s,eventHandlers:l,use:o,styles:c}}var Ln,d,E="@vortex-get-internal",L,$,k;var ee=v(()=>{w();Ln=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let t=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=t},[Symbol.dispose](){e.hookLifetime=t}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},d=class extends le({package:"@vortexjs/core",name:"Lifetime"},Ln){};L=z,$=fe;k=le({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});function Mn(){let e=N.current;if(!e)throw new Error("No context scope found, you should have one if you're rendering a component.");return e}function Fe(){return Mn().streaming}function Fn(){let e=N.current;if(!e)return null;return e}function Gn(){let e=Fn();if(!e)return null;return e.streaming}function Me({renderer:e,root:n,component:t,context:i}){try{var r=(0,Jn.default)();r.u(oe("Initial page render"));let u=new Wn(e,n),s=new d,l=u.render({node:t,hydration:e.getHydrationContext(n),lt:s,context:i??N.current??new N}),o=new We(n,e);return o.children=[l],s}catch(u){r.e=u}finally{r.d()}}function Je(e,n,t){if("renderer"in e)return Me(e);else return Me({renderer:e,root:n,component:t})}function Be(){let e=Gn();return(n)=>{let t=L(void 0);async function i(){if(e)try{var r=(0,Bn.default)();r.u(e.markLoading()),t.set(await n)}catch(u){r.e=u}finally{r.d()}else t.set(await n)}return i(),t}}var qn,Rn,zn=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)Rn(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=qn(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},N=class e{contexts={};streaming=new zn;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,t){this.contexts[n]=t}static current=null;static setCurrent(n){let t=e.current;return e.current=n,{[Symbol.dispose](){e.current=t}}}},ze="~vortex:intrinsic",Un,G=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(t){if(t instanceof O)for(let i of t.children)n(i);else e.push(t)}for(let t of this.children)n(t);return e}},O,Ge,Ue,We,ve,he,Wn=class{constructor(e,n){this.renderer=e,this.root=n}render({node:e,hydration:n,lt:t,context:i}){if(e===void 0||e===null)return new O;if(Array.isArray(e))return this.render({node:{type:"fragment",children:e},hydration:n,lt:t,context:i});switch(e.type){case"fragment":{let s=new O;return s.children=e.children.map((l)=>this.render({node:l,hydration:n,lt:t,context:i})),s}case"text":return new Ge(e.value.toString(),this.renderer,n,i);case"element":{let s=new Ue(e.name,this.renderer,n),l=this.renderer.getHydrationContext(s.rendererNode??m());s.children=e.children.map((c)=>this.render({node:c,hydration:l,lt:t,context:i}));for(let[c,a]of Object.entries(e.attributes))a.subscribe((f)=>{s.setAttribute(c,f)}).cascadesFrom(t);for(let[c,a]of Object.entries(e.bindings))this.renderer.bindValue(s.rendererNode??m(),c,a).cascadesFrom(t);for(let[c,a]of Object.entries(e.eventHandlers))this.renderer.addEventListener(s.rendererNode??m(),c,a).cascadesFrom(t);for(let[c,a]of Object.entries(e.styles))a.subscribe((f)=>{this.renderer.setStyle(s.rendererNode??m(),c,f)}).cascadesFrom(t);let o=[e.use].flat();for(let c of o)c(s.rendererNode??m());return s}case"component":try{var r=(0,he.default)();r.u(d.changeHookLifetime(t)),r.u(N.setCurrent(i)),r.u(oe(`Rendering ${e.impl.name}`));let s=e.impl;if(ze in s&&typeof s[ze]==="string"){let o=this.renderer.implementations?.find((c)=>c.intrinsic===s);if(o)s=o.implementation}let l=s(e.props);return this.render({node:l,hydration:n,lt:t,context:i})}catch(s){r.e=s}finally{r.d()}case"dynamic":{let s=new O;return pe((l,{lifetime:o})=>{let c=this.render({node:l(e.value),hydration:n,lt:o,context:i});s.children=[c]},void 0,t),s}case"list":{new O;let s=new Map,l=new O,o="";return pe((c)=>{let a=c(e.items),f=a.map((b,I)=>e.getKey(b,I));for(let b of s.keys())if(!f.includes(b))(s.get(b)??m()).lifetime.close(),s.delete(b);for(let b of f)if(!s.has(b))try{var p=(0,he.default)();let I=a[f.indexOf(b)],_n=z(I),ie=new d;p.u(d.changeHookLifetime(ie));let xn=this.render({node:e.renderItem(I,f.indexOf(b)),hydration:n,lt:ie,context:i});s.set(b,{node:xn,item:_n,lifetime:ie})}catch(I){p.e=I}finally{p.d()}let y=f.join("|||");if(y!==o)o=y,l.children=f.map((b)=>(s.get(b)??m()).node)}),l}case"context":try{var u=(0,he.default)();let s=i.fork();return u.u(N.setCurrent(s)),s.addContext(e.id,e.value),this.render({node:e.children,hydration:n,lt:t,context:s})}catch(s){u.e=s}finally{u.d()}default:Te(e,`No rendering implementation for ${JSON.stringify(e)}`)}}},Jn,Bn;var U=v(()=>{Re();ee();w();w();qn=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),Rn=globalThis.clearImmediate??((e)=>{clearTimeout(e)});Un={};qe(Un,{FLElement:()=>Ue,FLFragment:()=>O,FLNode:()=>G,FLPortal:()=>We,FLText:()=>Ge});O=class extends G{onChildrenChanged(){this.parent?.onChildrenChanged()}},Ge=class extends G{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??m(),e)}constructor(e,n,t,i){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(t,i),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},Ue=class extends G{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??m(),e,n)}constructor(e,n,t){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,t)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??m());this.renderer.setChildren(this.rendererNode??m(),e)}},We=class extends G{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??m()))}},ve=Le({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function t(){var i=typeof SuppressedError=="function"?SuppressedError:function(l,o){var c=Error();return c.name="SuppressedError",c.error=l,c.suppressed=o,c},r={},u=[];function s(l,o){if(o!=null){if(Object(o)!==o)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(l)var c=o[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(c===void 0&&(c=o[Symbol.dispose||Symbol.for("Symbol.dispose")],l))var a=c;if(typeof c!="function")throw new TypeError("Object is not disposable.");a&&(c=function f(){try{a.call(o)}catch(p){return Promise.reject(p)}}),u.push({v:o,d:c,a:l})}else l&&u.push({d:o,a:l});return o}return{e:r,u:s.bind(null,!1),a:s.bind(null,!0),d(){var l,o=this.e,c=0;function a(){for(;l=u.pop();)try{if(!l.a&&c===1)return c=0,u.push(l),Promise.resolve().then(a);if(l.d){var p=l.d.call(l.v);if(l.a)return c|=2,Promise.resolve(p).then(a,f)}else c|=1}catch(y){return f(y)}if(c===1)return o!==r?Promise.reject(o):Promise.resolve();if(o!==r)throw o}function f(p){return o=o!==r?new i(p,o):p,a()}return a()}}}n.exports=t,n.exports.__esModule=!0,n.exports.default=n.exports}}),he=Z(ve(),1),Jn=Z(ve(),1);Bn=Z(ve(),1)});function ne(e,n){let t=n.split("/").map((r)=>r.trim()).filter((r)=>r!=="");function i(r,u,s,l){if(r===e.length&&u===t.length)return{matched:!0,params:{...s},spreads:{...l}};if(r===e.length||u>t.length)return{matched:!1};let o=e[r]??m();if(o.type==="static"){if(u>=t.length||t[u]!==o.match)return{matched:!1};return i(r+1,u+1,s,l)}else if(o.type==="slug"){if(u>=t.length)return{matched:!1};let c={...s,[o.name]:t[u]};return i(r+1,u+1,c,l)}else if(o.type==="spread"){for(let c=0;c<=t.length-u;c++){let a={...l,[o.name]:t.slice(u,u+c)},f=i(r+1,u+c,s,a);if(f.matched)return f}return{matched:!1}}return{matched:!1}}return i(0,0,{},{})}var Xe=v(()=>{w();U();w()});function x(e,n){let{children:t,...i}=n||{};if(e===k)return{type:"fragment",children:A(t)};if(typeof e==="string")return F(e,i,t);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:A(t)}};throw new Error(`Invalid JSX type: ${e}`)}var de;var Ke=v(()=>{ee();de=x});var Ve=v(()=>{Ke()});function Xn(){return $((e)=>{return new URL(e(W)).pathname})}function Kn(){if(typeof window==="undefined")return;W.subscribe((e)=>{if(window.location.href!==e)window.history.pushState({},"",e)},{callInitially:!1}),window.addEventListener("popstate",()=>{W.set(window.location.href)}),document.addEventListener("click",(e)=>{let t=e.composedPath().find((i)=>i instanceof HTMLAnchorElement);if(t?.href){let i=new URL(t.href,P(W));if(i.origin!==window.location.origin)return;e.preventDefault(),W.set(i.href)}})}function Vn({pathname:e,props:n,loaders:t}){if("location"in globalThis)Kn();Fe();let i=Be(),r=e?L(e):Xn(),u=$((c)=>{let a=c(r);return n.routes.find((f)=>ne(f.matcher,a))}),s=$(async(c)=>{let a=c(u)??m(),f=[];for(let p of a.frames)f.push(await(t[p.index]??m())());return f}),l=ye($((c)=>{return i(c(s))})),o=$((c)=>{let a=x(k,{}),f=c(l);if(!f)return x("h1",{children:"loading"});for(let p of f.toReversed())a=x(p,{children:a});return a});return de("html",{children:[de("head",{children:[x("link",{rel:"stylesheet",href:"/styles.css"}),x("script",{src:"/entrypoint-client.js",type:"module"})]}),x("body",{children:o})]})}async function He({props:e,loaders:n,renderer:t,root:i,pathname:r,lifetime:u=new d,context:s}){e:if("window"in globalThis){let l=r??window.location.pathname,o=e.routes.find((c)=>ne(c.matcher,l));if(!o)break e;for(let c of o.frames)await(n[c.index]??m())()}Je({context:s,renderer:t,root:i,component:x(Vn,{pathname:r,props:e,loaders:n})}).cascadesFrom(u)}function Ze(e){return async function(n){return await e.impl(n)}}async function Qe(e,n,t){let i=new URL(e.url).pathname;for(let r of n){if(!ne(r.matcher,i).matched)continue;if(r.method!==e.method)continue;let u=(t[r.schema]??m())(),s=(t[r.impl]??m())(),l=e.method==="GET"?new URL(e.url).searchParams.get("props")??"":await e.text(),o;try{o=V.parse(l)}catch{return new Response(["Your API request failed.","Why: The request body is not valid SKL"].join(` -`),{status:400,statusText:"Invalid SKL"})}let a=await(await u)["~standard"].validate(o);if("issues"in a)return new Response(["Your API request failed.","Why: The request body did not match the expected schema"].join(` -`),{status:400,statusText:"Failed to match against schema"});let f=a.value,y=await(await s)(f);return new Response(V.stringify(y))}}var W;var te=v(()=>{Xe();w();U();Ve();w();W=L(typeof window!=="undefined"?window.location.href:"/")});function Yn(e){return{lang:e?.lang??be?.lang,message:e?.message,abortEarly:e?.abortEarly??be?.abortEarly,abortPipeEarly:e?.abortPipeEarly??be?.abortPipeEarly}}function nt(e){return et?.get(e)}function rt(e){return tt?.get(e)}function st(e,n){return it?.get(e)?.get(n)}function ut(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function ke(e,n,t,i,r){let u=r&&"input"in r?r.input:t.value,s=r?.expected??e.expects??null,l=r?.received??ut(u),o={kind:e.kind,type:e.type,input:u,expected:s,received:l,message:`Invalid ${n}: ${s?`Expected ${s} but r`:"R"}eceived ${l}`,requirement:e.requirement,path:r?.path,issues:r?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},c=e.kind==="schema",a=r?.message??e.message??st(e.reference,o.lang)??(c?rt(o.lang):null)??i.message??nt(o.lang);if(a!==void 0)o.message=typeof a==="function"?a(o):a;if(c)t.typed=!1;if(t.issues)t.issues.push(o);else t.issues=[o]}function tn(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Yn())}}}function ot(e,n,t){return typeof e.fallback==="function"?e.fallback(n,t):e.fallback}function lt(e,n,t){return typeof e.default==="function"?e.default(n,t):e.default}function re(e){return{kind:"schema",type:"number",reference:re,expects:"number",async:!1,message:e,get "~standard"(){return tn(this)},"~run"(n,t){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else ke(this,"type",n,t);return n}}}function we(e,n){return{kind:"schema",type:"object",reference:we,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return tn(this)},"~run"(t,i){let r=t.value;if(r&&typeof r==="object"){t.typed=!0,t.value={};for(let u in this.entries){let s=this.entries[u];if(u in r||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){let l=u in r?r[u]:lt(s),o=s["~run"]({value:l},i);if(o.issues){let c={type:"object",origin:"value",input:r,key:u,value:l};for(let a of o.issues){if(a.path)a.path.unshift(c);else a.path=[c];t.issues?.push(a)}if(!t.issues)t.issues=o.issues;if(i.abortEarly){t.typed=!1;break}}if(!o.typed)t.typed=!1;t.value[u]=o.value}else if(s.fallback!==void 0)t.value[u]=ot(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"){if(ke(this,"key",t,i,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:r,key:u,value:r[u]}]}),i.abortEarly)break}}}else ke(this,"type",t,i);return t}}}var be,et,tt,it;var rn=()=>{};function g(e,n,t,i,r,u){let{children:s,...l}=n||{};if(e===k)return{type:"fragment",children:A(s),...r};if(typeof e==="string")return F(e,l,s,r);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:A(s)},...r};throw new Error(`Invalid JSX type: ${e}`)}var sn=v(()=>{ee()});var _e=v(()=>{sn()});var at,un=function(){return g(k,{children:[g("h1",{class:"text-4xl font-bold",children:["Welcome to Wormhole, ",Object.entries(globalThis).length]},void 0,!0,void 0,this),g("p",{children:["This is an example app, go to the"," ",g("a",{href:"/docs/tada",children:"docs"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),g("button",{"on:click":async()=>{console.log(await at({a:1,b:2}))},children:"add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},on=function({children:e}){return g(k,{children:[g("title",{children:"Wormhole Example"},void 0,!1,void 0,this),e]},void 0,!0,void 0,this)},ln=function(){return g(k,{children:g("h1",{children:"404 not found"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},cn=function({page:e}){return g(k,{children:[g("h1",{children:["Documentation for ",e.join(", ")]},void 0,!0,void 0,this),g("p",{children:["This is the documentation page for ",e.join(", "),"."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},xe=function({a:e,b:n}){return e+n},Ee;var D=v(()=>{rn();te();_e();at=Ze({schema:Ee,impl:xe,endpoint:"/api/add",method:"GET",isQuery:!0}),Ee=we({a:re(),b:re()})});var an={};C(an,{$d_109_720:()=>un});var fn=v(()=>{D()});var pn={};C(pn,{$d_732_888:()=>on});var yn=v(()=>{D()});var hn={};C(hn,{$d_1050_1265:()=>cn});var mn=v(()=>{D()});var vn={};C(vn,{$d_902_1009:()=>ln});var dn=v(()=>{D()});var gn={};C(gn,{$d_1395_1435:()=>xe});var bn=v(()=>{D()});var kn={};C(kn,{$d_1323_1385:()=>Ee});var wn=v(()=>{D()});te();U();w();U();w();function Hn(e){return"tagName"in e?e.tagName:"Text"}function Zn(){return{html:"",write(e){this.html+=e},lastType:""}}function Ye(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function ge(e,n=Zn()){let t=Hn(e);if(t==="Text"&&n.lastType==="Text")n.write("");if(n.lastType=t,"tagName"in e){n.write("<"),n.write(e.tagName);for(let[i,r]of Object.entries(e.attributes)){if(r===void 0)continue;n.write(` ${i}="${Ye(r)}"`)}n.write(">");for(let i of e.children)ge(i,n);n.write("")}if("content"in e)n.write(Ye(e.content.toString()));return n.html}function Qn(e){return e.split(/(?=[A-Z])/).map((t)=>t.toLowerCase()).join("-")}function en(){return{createNode(e,n){return{tagName:e,attributes:{},children:[],parent:void 0}},setAttribute(e,n,t){if(!("tagName"in e))throw new Error("Cannot set attribute on a text node");e.attributes[n]=t},createTextNode(e){return{content:"",parent:void 0}},setTextContent(e,n){if(!("content"in e))throw new Error("Cannot set text content on a non-text node");e.content=n},setChildren(e,n){if(!("children"in e))throw new Error("Cannot set children on a text node");e.children=n;for(let t of n)t.parent=e},getHydrationContext(e){return},addEventListener(e,n,t){return new d},bindValue(e,n,t){return new d},setStyle(e,n,t){if(!("attributes"in e))throw new Error("Cannot set style on a text node");let i=e.attributes.style??"";i+=`${Qn(n)}: ${t};`,e.attributes.style=i}}}function nn(){return{tagName:"html",attributes:{},children:[],parent:void 0,fixedIdent:"document.documentElement"}}te();var ft=JSON.parse('{"routes":[{"matcher":[],"frames":[{"index":0}],"is404":false},{"matcher":[{"type":"static","match":"docs"},{"type":"spread","name":"page"}],"frames":[{"index":1},{"index":2}],"is404":false},{"matcher":[{"type":"spread","name":"404"}],"frames":[{"index":1},{"index":3}],"is404":true}]}'),pt=[async()=>(await Promise.resolve().then(() => (fn(),an))).$d_109_720,async()=>(await Promise.resolve().then(() => (yn(),pn))).$d_732_888,async()=>(await Promise.resolve().then(() => (mn(),hn))).$d_1050_1265,async()=>(await Promise.resolve().then(() => (dn(),vn))).$d_902_1009],yt=[{matcher:[{type:"static",match:"api"},{type:"static",match:"add"}],impl:0,schema:1,method:"GET"}],ht=[async()=>(await Promise.resolve().then(() => (bn(),gn))).$d_1395_1435,async()=>(await Promise.resolve().then(() => (wn(),kn))).$d_1323_1385];async function mt(e){let t=new URL(e.url).pathname,i=await Qe(e,yt,ht);if(i)return i;let r=en(),u=nn(),s=new d;try{await He({props:ft,loaders:pt,renderer:r,root:u,pathname:t,context:{},lifetime:s});let l=ge(u);return new Response(l,{status:200,headers:{"Content-Type":"text/html"}})}catch(l){return console.error("Rendering error:",l),new Response("Internal Server Error",{status:500})}finally{s.close()}}export{mt as default}; +`)r+="\\n";else if(u==="\t")r+="\\t";else if(u==="\r")r+="\\r";else r+=u;if(r+=i,r.length{Ae();V={};$e(V,{escapeStr:()=>ue,isAlphabetic:()=>H,isAlphanumeric:()=>Oe,isNumeric:()=>B,isWhitespace:()=>Se,keywords:()=>S,lex:()=>Ne,parse:()=>In,parseContext_create:()=>Ce,parseContext_next:()=>An,parseContext_peek:()=>X,parseContext_read:()=>j,parseContext_readObj:()=>K,serialize:()=>je,serializeContext_create:()=>De,serializeContext_dedent:()=>R,serializeContext_indent:()=>q,serializeContext_newline:()=>_,serializeContext_write:()=>h,serializeContext_writeObject:()=>T,stringify:()=>Sn,symbols:()=>se});S={null:"Null",true:"True",false:"False",undefined:"Undefined"},se={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};Sn=je});var Cn,ce,Dn,Pe,jn,Tn,Le=(e,n)=>function(){return n||e[Pe(e)[0]]((n={exports:{}}).exports,n),n.exports},qe=(e,n)=>{for(var t in n)ce(e,t,{get:n[t],enumerable:!0})},Pn=(e,n,t,i)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var r=Pe(n),u=0,s=r.length,l;un[o]).bind(null,l),enumerable:!(i=Dn(n,l))||i.enumerable})}return e},Z=(e,n,t)=>(t=e!=null?Cn(jn(e)):{},Pn(n||!e||!e.__esModule?ce(t,"default",{value:e,enumerable:!0}):t,e));var Re=v(()=>{Cn=Object.create,ce=Object.defineProperty,Dn=Object.getOwnPropertyDescriptor,Pe=Object.getOwnPropertyNames,jn=Object.getPrototypeOf,Tn=Object.prototype.hasOwnProperty});function Y(){if(d.hookLifetime===null)throw new Error("No hook lifetime available");return d.hookLifetime}function z(e){let n,t=e,i=[];return n&&console.log(`[${n}]: initialized with `,t),{setId(r){n=r},[E](){return t},subscribe(r,u){if(i.push(r),n&&console.trace(`[${n}]: subscribed with `,r),u?.callInitially!==!1)r(t);return new d().onClosed(()=>{i.splice(i.indexOf(r),1),n&&console.log(`[${n}]: unsubscribed `,r)})},set(r){if(n&&console.log(`[${n}]: trying to switch from `,t," -> ",r),!J(t,r)){t=r;for(let u of i)u(t);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}function P(e){return e[E]()}function ae(e,n,t=Y()){let i=n?.dynamic??!1,r=[],u=z(e((o)=>{if(!r.includes(o))r.push(o);return o[E]()}));function s(){if(i){let o=new Set(r);u.set(e((p)=>{return o.add(p),p[E]()}));let c=new Set(r),f=c.difference(o);for(let p of f){let y=r.indexOf(p);if(y!==-1)r.splice(y,1),l[y]?.close(),l.splice(y,1)}let a=o.difference(c);for(let p of a){let y=p.subscribe(()=>{s()},{callInitially:!1});r.push(p),l.push(y)}}else u.set(e(P))}let l=r.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(t)});return{...u}}function pe(e,n,t=Y()){let i=n?.dynamic??!1,r=[],u=new d;e((o)=>{if(!r.includes(o))r.push(o);return o[E]()},{lifetime:u});function s(){if(i){let o=new Set(r);u.close(),u=new d().cascadesFrom(t),e((p)=>{return o.add(p),p[E]()},{lifetime:u});let c=new Set(r),f=c.difference(o);for(let p of f){let y=r.indexOf(p);if(y!==-1)r.splice(y,1),l[y]?.close(),l.splice(y,1)}let a=o.difference(c);for(let p of a){let y=p.subscribe(()=>{s()},{callInitially:!1});r.push(p),l.push(y)}}else u.close(),u=new d().cascadesFrom(t),e(P,{lifetime:u})}let l=r.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(t)})}function M(e){return typeof e==="object"&&e!==null&&E in e}function fe(e){if(M(e))return e;return z(e)}function ye(e,n=Y()){return ae((t)=>{function i(r){if(M(r))return i(t(r));return r}return i(e)},{dynamic:!0},n)}function A(e){if(e===void 0)return[];return[e].flat().filter((n)=>n!==null&&n!==void 0).map((n)=>typeof n==="string"||typeof n==="number"||typeof n==="boolean"?Q(n):M(n)?{type:"dynamic",value:$((t)=>{let i=t(n);return typeof i==="number"||typeof i==="string"||typeof i==="boolean"?Q(i):i})}:n)}function Q(e,n){return{type:"text",value:e,...n}}function F(e,n,t,i){let r=A(t).map((f)=>{if(typeof f==="string"||typeof f==="number"||typeof f==="boolean")return Q(f);return f}),u={},s={},l={},o=[],c={};for(let[f,a]of Object.entries(n))if(a!==void 0)if(f.startsWith("bind:")){let p=f.slice(5);if(!M(a)||!("set"in a))throw new Error(`Binding value for "${p}" must be a writable store.`);s[p]=a}else if(f.startsWith("on:")){let p=f.slice(3);if(typeof a!=="function")throw new Error(`Event handler for "${p}" must be a function.`);l[p]=a}else if(f==="use"){if(typeof a!=="function"&&!Array.isArray(a))throw new Error("Use hook must be a function or an array of functions.");o.push(a)}else if(f==="style"){for(let[p,y]of Object.entries(a))if(y!==void 0)c[p]=fe(y)}else u[f]=fe(a);return{type:"element",name:e,attributes:u,children:r,bindings:s,eventHandlers:l,use:o,styles:c}}var Ln,d,E="@vortex-get-internal",L,$,k;var ee=v(()=>{w();Ln=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let t=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=t},[Symbol.dispose](){e.hookLifetime=t}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},d=class extends le({package:"@vortexjs/core",name:"Lifetime"},Ln){};L=z,$=ae;k=le({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});function Mn(){let e=N.current;if(!e)throw new Error("No context scope found, you should have one if you're rendering a component.");return e}function Fe(){return Mn().streaming}function Fn(){let e=N.current;if(!e)return null;return e}function Gn(){let e=Fn();if(!e)return null;return e.streaming}function Me({renderer:e,root:n,component:t,context:i}){try{var r=Jn.default();r.u(oe("Initial page render"));let u=new Wn(e,n),s=new d,l=u.render({node:t,hydration:e.getHydrationContext(n),lt:s,context:i??N.current??new N}),o=new We(n,e);return o.children=[l],s}catch(u){r.e=u}finally{r.d()}}function Je(e,n,t){if("renderer"in e)return Me(e);else return Me({renderer:e,root:n,component:t})}function Be(){let e=Gn();return(n)=>{let t=L(void 0);async function i(){if(e)try{var r=Bn.default();r.u(e.markLoading()),t.set(await n)}catch(u){r.e=u}finally{r.d()}else t.set(await n)}return i(),t}}var qn,Rn,zn=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)Rn(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=qn(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},N=class e{contexts={};streaming=new zn;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,t){this.contexts[n]=t}static current=null;static setCurrent(n){let t=e.current;return e.current=n,{[Symbol.dispose](){e.current=t}}}},ze="~vortex:intrinsic",Un,G=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(t){if(t instanceof O)for(let i of t.children)n(i);else e.push(t)}for(let t of this.children)n(t);return e}},O,Ge,Ue,We,ve,he,Wn=class{constructor(e,n){this.renderer=e,this.root=n}render({node:e,hydration:n,lt:t,context:i}){if(e===void 0||e===null)return new O;if(Array.isArray(e))return this.render({node:{type:"fragment",children:e},hydration:n,lt:t,context:i});switch(e.type){case"fragment":{let s=new O;return s.children=e.children.map((l)=>this.render({node:l,hydration:n,lt:t,context:i})),s}case"text":return new Ge(e.value.toString(),this.renderer,n,i);case"element":{let s=new Ue(e.name,this.renderer,n),l=this.renderer.getHydrationContext(s.rendererNode??m());s.children=e.children.map((c)=>this.render({node:c,hydration:l,lt:t,context:i}));for(let[c,f]of Object.entries(e.attributes))f.subscribe((a)=>{s.setAttribute(c,a)}).cascadesFrom(t);for(let[c,f]of Object.entries(e.bindings))this.renderer.bindValue(s.rendererNode??m(),c,f).cascadesFrom(t);for(let[c,f]of Object.entries(e.eventHandlers))this.renderer.addEventListener(s.rendererNode??m(),c,f).cascadesFrom(t);for(let[c,f]of Object.entries(e.styles))f.subscribe((a)=>{this.renderer.setStyle(s.rendererNode??m(),c,a)}).cascadesFrom(t);let o=[e.use].flat();for(let c of o)c(s.rendererNode??m());return s}case"component":try{var r=he.default();r.u(d.changeHookLifetime(t)),r.u(N.setCurrent(i)),r.u(oe(`Rendering ${e.impl.name}`));let s=e.impl;if(ze in s&&typeof s[ze]==="string"){let o=this.renderer.implementations?.find((c)=>c.intrinsic===s);if(o)s=o.implementation}let l=s(e.props);return this.render({node:l,hydration:n,lt:t,context:i})}catch(s){r.e=s}finally{r.d()}case"dynamic":{let s=new O;return pe((l,{lifetime:o})=>{let c=this.render({node:l(e.value),hydration:n,lt:o,context:i});s.children=[c]},void 0,t),s}case"list":{new O;let s=new Map,l=new O,o="";return pe((c)=>{let f=c(e.items),a=f.map((b,I)=>e.getKey(b,I));for(let b of s.keys())if(!a.includes(b))(s.get(b)??m()).lifetime.close(),s.delete(b);for(let b of a)if(!s.has(b))try{var p=he.default();let I=f[a.indexOf(b)],_n=z(I),ie=new d;p.u(d.changeHookLifetime(ie));let xn=this.render({node:e.renderItem(I,a.indexOf(b)),hydration:n,lt:ie,context:i});s.set(b,{node:xn,item:_n,lifetime:ie})}catch(I){p.e=I}finally{p.d()}let y=a.join("|||");if(y!==o)o=y,l.children=a.map((b)=>(s.get(b)??m()).node)}),l}case"context":try{var u=he.default();let s=i.fork();return u.u(N.setCurrent(s)),s.addContext(e.id,e.value),this.render({node:e.children,hydration:n,lt:t,context:s})}catch(s){u.e=s}finally{u.d()}default:Te(e,`No rendering implementation for ${JSON.stringify(e)}`)}}},Jn,Bn;var U=v(()=>{Re();ee();w();w();qn=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),Rn=globalThis.clearImmediate??((e)=>{clearTimeout(e)});Un={};qe(Un,{FLElement:()=>Ue,FLFragment:()=>O,FLNode:()=>G,FLPortal:()=>We,FLText:()=>Ge});O=class extends G{onChildrenChanged(){this.parent?.onChildrenChanged()}},Ge=class extends G{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??m(),e)}constructor(e,n,t,i){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(t,i),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},Ue=class extends G{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??m(),e,n)}constructor(e,n,t){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,t)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??m());this.renderer.setChildren(this.rendererNode??m(),e)}},We=class extends G{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??m()))}},ve=Le({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function t(){var i=typeof SuppressedError=="function"?SuppressedError:function(l,o){var c=Error();return c.name="SuppressedError",c.error=l,c.suppressed=o,c},r={},u=[];function s(l,o){if(o!=null){if(Object(o)!==o)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(l)var c=o[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(c===void 0&&(c=o[Symbol.dispose||Symbol.for("Symbol.dispose")],l))var f=c;if(typeof c!="function")throw new TypeError("Object is not disposable.");f&&(c=function a(){try{f.call(o)}catch(p){return Promise.reject(p)}}),u.push({v:o,d:c,a:l})}else l&&u.push({d:o,a:l});return o}return{e:r,u:s.bind(null,!1),a:s.bind(null,!0),d(){var l,o=this.e,c=0;function f(){for(;l=u.pop();)try{if(!l.a&&c===1)return c=0,u.push(l),Promise.resolve().then(f);if(l.d){var p=l.d.call(l.v);if(l.a)return c|=2,Promise.resolve(p).then(f,a)}else c|=1}catch(y){return a(y)}if(c===1)return o!==r?Promise.reject(o):Promise.resolve();if(o!==r)throw o}function a(p){return o=o!==r?new i(p,o):p,f()}return f()}}}n.exports=t,n.exports.__esModule=!0,n.exports.default=n.exports}}),he=Z(ve(),1),Jn=Z(ve(),1);Bn=Z(ve(),1)});function ne(e,n){let t=n.split("/").map((r)=>r.trim()).filter((r)=>r!=="");function i(r,u,s,l){if(r===e.length&&u===t.length)return{matched:!0,params:{...s},spreads:{...l}};if(r===e.length||u>t.length)return{matched:!1};let o=e[r]??m();if(o.type==="static"){if(u>=t.length||t[u]!==o.match)return{matched:!1};return i(r+1,u+1,s,l)}else if(o.type==="slug"){if(u>=t.length)return{matched:!1};let c={...s,[o.name]:t[u]};return i(r+1,u+1,c,l)}else if(o.type==="spread"){for(let c=0;c<=t.length-u;c++){let f={...l,[o.name]:t.slice(u,u+c)},a=i(r+1,u+c,s,f);if(a.matched)return a}return{matched:!1}}return{matched:!1}}return i(0,0,{},{})}var Xe=v(()=>{w();U();w()});function x(e,n){let{children:t,...i}=n||{};if(e===k)return{type:"fragment",children:A(t)};if(typeof e==="string")return F(e,i,t);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:A(t)}};throw new Error(`Invalid JSX type: ${e}`)}var de;var Ke=v(()=>{ee();de=x});var Ve=v(()=>{Ke()});function Xn(){return $((e)=>{return new URL(e(W)).pathname})}function Kn(){if(typeof window==="undefined")return;W.subscribe((e)=>{if(window.location.href!==e)window.history.pushState({},"",e)},{callInitially:!1}),window.addEventListener("popstate",()=>{W.set(window.location.href)}),document.addEventListener("click",(e)=>{let t=e.composedPath().find((i)=>i instanceof HTMLAnchorElement);if(t?.href){let i=new URL(t.href,P(W));if(i.origin!==window.location.origin)return;e.preventDefault(),W.set(i.href)}})}function Vn({pathname:e,props:n,loaders:t}){if("location"in globalThis)Kn();Fe();let i=Be(),r=e?L(e):Xn(),u=$((c)=>{let f=c(r);return n.routes.find((a)=>ne(a.matcher,f))}),s=$(async(c)=>{let f=c(u)??m(),a=[];for(let p of f.frames)a.push(await(t[p.index]??m())());return a}),l=ye($((c)=>{return i(c(s))})),o=$((c)=>{let f=x(k,{}),a=c(l);if(!a)return x("h1",{children:"loading"});for(let p of a.toReversed())f=x(p,{children:f});return f});return de("html",{children:[de("head",{children:[x("link",{rel:"stylesheet",href:"/styles.css"}),x("script",{src:"/entrypoint-client.js",type:"module"})]}),x("body",{children:o})]})}async function He({props:e,loaders:n,renderer:t,root:i,pathname:r,lifetime:u=new d,context:s}){e:if("window"in globalThis){let l=r??window.location.pathname,o=e.routes.find((c)=>ne(c.matcher,l));if(!o)break e;for(let c of o.frames)await(n[c.index]??m())()}Je({context:s,renderer:t,root:i,component:x(Vn,{pathname:r,props:e,loaders:n})}).cascadesFrom(u)}function Ze(e){return async function(n){return await e.impl(n)}}async function Qe(e,n,t){let i=new URL(e.url).pathname;for(let r of n){if(!ne(r.matcher,i).matched)continue;if(r.method!==e.method)continue;let u=(t[r.schema]??m())(),s=(t[r.impl]??m())(),l=e.method==="GET"?new URL(e.url).searchParams.get("props")??"":await e.text(),o;try{o=V.parse(l)}catch{return new Response(["Your API request failed.","Why: The request body is not valid SKL"].join(` +`),{status:400,statusText:"Invalid SKL"})}let f=await(await u)["~standard"].validate(o);if("issues"in f)return new Response(["Your API request failed.","Why: The request body did not match the expected schema"].join(` +`),{status:400,statusText:"Failed to match against schema"});let a=f.value,y=await(await s)(a);return new Response(V.stringify(y))}}var W;var te=v(()=>{Xe();w();U();Ve();w();W=L(typeof window!=="undefined"?window.location.href:"/")});function Yn(e){return{lang:e?.lang??be?.lang,message:e?.message,abortEarly:e?.abortEarly??be?.abortEarly,abortPipeEarly:e?.abortPipeEarly??be?.abortPipeEarly}}function nt(e){return et?.get(e)}function rt(e){return tt?.get(e)}function st(e,n){return it?.get(e)?.get(n)}function ut(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function ke(e,n,t,i,r){let u=r&&"input"in r?r.input:t.value,s=r?.expected??e.expects??null,l=r?.received??ut(u),o={kind:e.kind,type:e.type,input:u,expected:s,received:l,message:`Invalid ${n}: ${s?`Expected ${s} but r`:"R"}eceived ${l}`,requirement:e.requirement,path:r?.path,issues:r?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},c=e.kind==="schema",f=r?.message??e.message??st(e.reference,o.lang)??(c?rt(o.lang):null)??i.message??nt(o.lang);if(f!==void 0)o.message=typeof f==="function"?f(o):f;if(c)t.typed=!1;if(t.issues)t.issues.push(o);else t.issues=[o]}function tn(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Yn())}}}function ot(e,n,t){return typeof e.fallback==="function"?e.fallback(n,t):e.fallback}function lt(e,n,t){return typeof e.default==="function"?e.default(n,t):e.default}function re(e){return{kind:"schema",type:"number",reference:re,expects:"number",async:!1,message:e,get "~standard"(){return tn(this)},"~run"(n,t){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else ke(this,"type",n,t);return n}}}function we(e,n){return{kind:"schema",type:"object",reference:we,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return tn(this)},"~run"(t,i){let r=t.value;if(r&&typeof r==="object"){t.typed=!0,t.value={};for(let u in this.entries){let s=this.entries[u];if(u in r||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){let l=u in r?r[u]:lt(s),o=s["~run"]({value:l},i);if(o.issues){let c={type:"object",origin:"value",input:r,key:u,value:l};for(let f of o.issues){if(f.path)f.path.unshift(c);else f.path=[c];t.issues?.push(f)}if(!t.issues)t.issues=o.issues;if(i.abortEarly){t.typed=!1;break}}if(!o.typed)t.typed=!1;t.value[u]=o.value}else if(s.fallback!==void 0)t.value[u]=ot(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"){if(ke(this,"key",t,i,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:r,key:u,value:r[u]}]}),i.abortEarly)break}}}else ke(this,"type",t,i);return t}}}var be,et,tt,it;var rn=()=>{};function g(e,n,t,i,r,u){let{children:s,...l}=n||{};if(e===k)return{type:"fragment",children:A(s),...r};if(typeof e==="string")return F(e,l,s,r);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:A(s)},...r};throw new Error(`Invalid JSX type: ${e}`)}var sn=v(()=>{ee()});var _e=v(()=>{sn()});var ft,un=function(){return g(k,{children:[g("h1",{class:"text-4xl font-bold",children:["Welcome to Wormhole, ",Object.entries(globalThis).length]},void 0,!0,void 0,this),g("p",{children:["This is an example app, go to the"," ",g("a",{href:"/docs/tada",children:"docs"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),g("button",{"on:click":async()=>{console.log(await ft({a:1,b:2}))},children:"add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},on=function({children:e}){return g(k,{children:[g("title",{children:"Wormhole Example"},void 0,!1,void 0,this),e]},void 0,!0,void 0,this)},ln=function(){return g(k,{children:g("h1",{children:"404 not found"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},cn=function({page:e}){return g(k,{children:[g("h1",{children:["Documentation for ",e.join(", ")]},void 0,!0,void 0,this),g("p",{children:["This is the documentation page for ",e.join(", "),"."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},xe=function({a:e,b:n}){return e+n},Ee;var C=v(()=>{rn();te();_e();ft=Ze({schema:Ee,impl:xe,endpoint:"/api/add",method:"GET",isQuery:!0}),Ee=we({a:re(),b:re()})});var fn={};D(fn,{$d_109_720:()=>un});var an=v(()=>{C()});var pn={};D(pn,{$d_732_888:()=>on});var yn=v(()=>{C()});var hn={};D(hn,{$d_1050_1265:()=>cn});var mn=v(()=>{C()});var vn={};D(vn,{$d_902_1009:()=>ln});var dn=v(()=>{C()});var gn={};D(gn,{$d_1395_1435:()=>xe});var bn=v(()=>{C()});var kn={};D(kn,{$d_1323_1385:()=>Ee});var wn=v(()=>{C()});te();U();w();U();w();function Hn(e){return"tagName"in e?e.tagName:"Text"}function Zn(){return{html:"",write(e){this.html+=e},lastType:""}}function Ye(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function ge(e,n=Zn()){let t=Hn(e);if(t==="Text"&&n.lastType==="Text")n.write("");if(n.lastType=t,"tagName"in e){n.write("<"),n.write(e.tagName);for(let[i,r]of Object.entries(e.attributes)){if(r===void 0)continue;n.write(` ${i}="${Ye(r)}"`)}n.write(">");for(let i of e.children)ge(i,n);n.write("")}if("content"in e)n.write(Ye(e.content.toString()));return n.html}function Qn(e){return e.split(/(?=[A-Z])/).map((t)=>t.toLowerCase()).join("-")}function en(){return{createNode(e,n){return{tagName:e,attributes:{},children:[],parent:void 0}},setAttribute(e,n,t){if(!("tagName"in e))throw new Error("Cannot set attribute on a text node");e.attributes[n]=t},createTextNode(e){return{content:"",parent:void 0}},setTextContent(e,n){if(!("content"in e))throw new Error("Cannot set text content on a non-text node");e.content=n},setChildren(e,n){if(!("children"in e))throw new Error("Cannot set children on a text node");e.children=n;for(let t of n)t.parent=e},getHydrationContext(e){return},addEventListener(e,n,t){return new d},bindValue(e,n,t){return new d},setStyle(e,n,t){if(!("attributes"in e))throw new Error("Cannot set style on a text node");let i=e.attributes.style??"";i+=`${Qn(n)}: ${t};`,e.attributes.style=i}}}function nn(){return{tagName:"html",attributes:{},children:[],parent:void 0,fixedIdent:"document.documentElement"}}te();var at=JSON.parse('{"routes":[{"matcher":[],"frames":[{"index":0}],"is404":false},{"matcher":[{"type":"static","match":"docs"},{"type":"spread","name":"page"}],"frames":[{"index":1},{"index":2}],"is404":false},{"matcher":[{"type":"spread","name":"404"}],"frames":[{"index":1},{"index":3}],"is404":true}]}'),pt=[async()=>(await Promise.resolve().then(() => (an(),fn))).$d_109_720,async()=>(await Promise.resolve().then(() => (yn(),pn))).$d_732_888,async()=>(await Promise.resolve().then(() => (mn(),hn))).$d_1050_1265,async()=>(await Promise.resolve().then(() => (dn(),vn))).$d_902_1009],yt=[{matcher:[{type:"static",match:"api"},{type:"static",match:"add"}],impl:0,schema:1,method:"GET"}],ht=[async()=>(await Promise.resolve().then(() => (bn(),gn))).$d_1395_1435,async()=>(await Promise.resolve().then(() => (wn(),kn))).$d_1323_1385];async function mt(e){let t=new URL(e.url).pathname,i=await Qe(e,yt,ht);if(i)return i;let r=en(),u=nn(),s=new d;try{await He({props:at,loaders:pt,renderer:r,root:u,pathname:t,context:{},lifetime:s});let l=ge(u);return new Response(l,{status:200,headers:{"Content-Type":"text/html"}})}catch(l){return console.error("Rendering error:",l),new Response("Internal Server Error",{status:500})}finally{s.close()}}export{mt as default}; diff --git a/packages/example-wormhole/.vercel/output/functions/route-[...404].func/index.js b/packages/example-wormhole/.vercel/output/functions/route-[...404].func/index.js index 16974ab..b7f815f 100644 --- a/packages/example-wormhole/.vercel/output/functions/route-[...404].func/index.js +++ b/packages/example-wormhole/.vercel/output/functions/route-[...404].func/index.js @@ -3,4 +3,4 @@ var fn=Object.defineProperty;var we=(e,n)=>{for(var r in n)fn(e,r,{get:n[r],enum `||e==="\r"}function X(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}function W(e){return e>="0"&&e<="9"}function Ie(e){return X(e)||W(e)}function*Se(e){let n=0,r=()=>e[n]??"",i=()=>e[n++]??"",t=()=>{n++};while(n=e.tokens.length)return null;return e.tokens[e.current++]??null}function J(e){if(e.current>=e.tokens.length)return null;return e.tokens[e.current]??null}function N(e){let n=J(e);if(n!==null)e.current++;return n}function B(e){let n=N(e);if(n===null)throw new Error("Unexpected end of input");if(n[0]==="number")return n[1];if(n[0]==="string")return n[1];if(n[0]==="keyword"){if(n[1]===I.null)return null;if(n[1]===I.undefined)return;if(n[1]===I.true)return!0;if(n[1]===I.false)return!1;throw new Error(`Unexpected keyword: ${n[1]}`)}let r=null;if(n[0]==="identifier")r=n[1],n=N(e);if(n===null)throw new Error("Unexpected end of input (after reading class)");if(n[0]==="symbol"&&n[1]==="LeftParenthesis"){let i={};while(!0){let t=N(e);if(t===null)throw new Error("Unexpected end of input (when trying to read key)");if(t[0]==="symbol"&&t[1]==="RightParenthesis")break;if(t[0]!=="identifier"&&t[0]!=="string")throw new Error(`Expected identifier or string, got ${t[0]}`);let u=N(e);if(u===null||u[0]!=="symbol"||u[1]!=="Equals")throw new Error(`Expected '=', got ${u?u[0]:"end of input"}`);let s=t[1],c=B(e);i[s]=c}if(r!==null){if(r==="date")return new Date(i.unix);if(r==="set")return new Set(i.items);if(r==="map"){let t=new Map;for(let[u,s]of i.entries)t.set(u,s);return t}throw new Error(`Unknown class: ${r}`)}return i}if(n[0]==="symbol"&&n[1]==="LeftSquareBracket"){let i=[];while(!0){if(J(e)?.[0]==="symbol"&&J(e)?.[1]==="RightSquareBracket"){N(e);break}let t=B(e);i.push(t)}return i}}function hn(e){let n=[...Se(e)],r=Oe(n),i=B(r);if(r.currentt[0]).join(", ")}`);return i}function Ne(){return{output:"",indentLevel:0,minified:!1}}function T(e){e.indentLevel++}function P(e){e.indentLevel=Math.max(0,e.indentLevel-1)}function w(e){if(e.minified){y(e," ");return}y(e,` `),y(e," ".repeat(e.indentLevel))}function y(e,n){e.output+=n}function ne(e){let n=Number.POSITIVE_INFINITY,r="";for(let i of['"',"'","`"]){let t="";t+=i;for(let u of e)if(u===i)t+=`\\${u}`;else if(u==="\\")t+="\\\\";else if(u===` -`)t+="\\n";else if(u==="\t")t+="\\t";else if(u==="\r")t+="\\r";else t+=u;if(t+=i,t.length{_e();$e={};xe($e,{escapeStr:()=>ne,isAlphabetic:()=>X,isAlphanumeric:()=>Ie,isNumeric:()=>W,isWhitespace:()=>Ae,keywords:()=>I,lex:()=>Se,parse:()=>hn,parseContext_create:()=>Oe,parseContext_next:()=>yn,parseContext_peek:()=>J,parseContext_read:()=>N,parseContext_readObj:()=>B,serialize:()=>De,serializeContext_create:()=>Ne,serializeContext_dedent:()=>P,serializeContext_indent:()=>T,serializeContext_newline:()=>w,serializeContext_write:()=>y,serializeContext_writeObject:()=>D,stringify:()=>mn,symbols:()=>ee});I={null:"Null",true:"True",false:"False",undefined:"Undefined"},ee={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};mn=De});var gn,ie,bn,je,kn,wn,Te=(e,n)=>function(){return n||(0,e[je(e)[0]])((n={exports:{}}).exports,n),n.exports},Pe=(e,n)=>{for(var r in n)ie(e,r,{get:n[r],enumerable:!0})},xn=(e,n,r,i)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var t=je(n),u=0,s=t.length,c;un[o]).bind(null,c),enumerable:!(i=bn(n,c))||i.enumerable})}return e},K=(e,n,r)=>(r=e!=null?gn(kn(e)):{},xn(n||!e||!e.__esModule?ie(r,"default",{value:e,enumerable:!0}):r,e));var Le=d(()=>{gn=Object.create,ie=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,je=Object.getOwnPropertyNames,kn=Object.getPrototypeOf,wn=Object.prototype.hasOwnProperty});function H(){if(v.hookLifetime===null)throw new Error("No hook lifetime available");return v.hookLifetime}function L(e){let n,r=e,i=[];return n&&console.log(`[${n}]: initialized with `,r),{setId(t){n=t},[_](){return r},subscribe(t,u){if(i.push(t),n&&console.trace(`[${n}]: subscribed with `,t),u?.callInitially!==!1)t(r);return new v().onClosed(()=>{i.splice(i.indexOf(t),1),n&&console.log(`[${n}]: unsubscribed `,t)})},set(t){if(n&&console.log(`[${n}]: trying to switch from `,r," -> ",t),!U(r,t)){r=t;for(let u of i)u(r);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}function C(e){return e[_]()}function ue(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=L(e((o)=>{if(!t.includes(o))t.push(o);return o[_]()}));function s(){if(i){let o=new Set(t);u.set(e((p)=>{return o.add(p),p[_]()}));let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.set(e(C))}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)});return{...u}}function oe(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=new v;e((o)=>{if(!t.includes(o))t.push(o);return o[_]()},{lifetime:u});function s(){if(i){let o=new Set(t);u.close(),u=new v().cascadesFrom(r),e((p)=>{return o.add(p),p[_]()},{lifetime:u});let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.close(),u=new v().cascadesFrom(r),e(C,{lifetime:u})}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)})}function R(e){return typeof e==="object"&&e!==null&&_ in e}function se(e){if(R(e))return e;return L(e)}function le(e,n=H()){return ue((r)=>{function i(t){if(R(t))return i(r(t));return t}return i(e)},{dynamic:!0},n)}function $(e){if(e===void 0)return[];return[e].flat().filter((n)=>n!==null&&n!==void 0).map((n)=>typeof n==="string"||typeof n==="number"||typeof n==="boolean"?V(n):R(n)?{type:"dynamic",value:E((r)=>{let i=r(n);return typeof i==="number"||typeof i==="string"||typeof i==="boolean"?V(i):i})}:n)}function V(e,n){return{type:"text",value:e,...n}}function q(e,n,r,i){let t=$(r).map((a)=>{if(typeof a==="string"||typeof a==="number"||typeof a==="boolean")return V(a);return a}),u={},s={},c={},o=[],l={};for(let[a,f]of Object.entries(n))if(f!==void 0)if(a.startsWith("bind:")){let p=a.slice(5);if(!R(f)||!("set"in f))throw new Error(`Binding value for "${p}" must be a writable store.`);s[p]=f}else if(a.startsWith("on:")){let p=a.slice(3);if(typeof f!=="function")throw new Error(`Event handler for "${p}" must be a function.`);c[p]=f}else if(a==="use"){if(typeof f!=="function"&&!Array.isArray(f))throw new Error("Use hook must be a function or an array of functions.");o.push(f)}else if(a==="style"){for(let[p,h]of Object.entries(f))if(h!==void 0)l[p]=se(h)}else u[a]=se(f);return{type:"element",name:e,attributes:u,children:t,bindings:s,eventHandlers:c,use:o,styles:l}}var _n,v,_="@vortex-get-internal",j,E,k;var Z=d(()=>{b();_n=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let r=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=r},[Symbol.dispose](){e.hookLifetime=r}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},v=class extends te({package:"@vortexjs/core",name:"Lifetime"},_n){};j=L,E=ue;k=te({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});function In(){let e=O.current;if(!e)throw new Error("No context scope found, you should have one if you're rendering a component.");return e}function ze(){return In().streaming}function Sn(){let e=O.current;if(!e)return null;return e}function On(){let e=Sn();if(!e)return null;return e.streaming}function qe({renderer:e,root:n,component:r,context:i}){try{var t=(0,Cn.default)();t.u(re("Initial page render"));let u=new Dn(e,n),s=new v,c=u.render({node:r,hydration:e.getHydrationContext(n),lt:s,context:i??O.current??new O}),o=new Ge(n,e);return o.children=[c],s}catch(u){t.e=u}finally{t.d()}}function Ue(e,n,r){if("renderer"in e)return qe(e);else return qe({renderer:e,root:n,component:r})}function We(){let e=On();return(n)=>{let r=j(void 0);async function i(){if(e)try{var t=(0,jn.default)();t.u(e.markLoading()),r.set(await n)}catch(u){t.e=u}finally{t.d()}else r.set(await n)}return i(),r}}var En,$n,An=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)$n(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=En(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},O=class e{contexts={};streaming=new An;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,r){this.contexts[n]=r}static current=null;static setCurrent(n){let r=e.current;return e.current=n,{[Symbol.dispose](){e.current=r}}}},Re="~vortex:intrinsic",Nn,z=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(r){if(r instanceof S)for(let i of r.children)n(i);else e.push(r)}for(let r of this.children)n(r);return e}},S,Me,Fe,Ge,fe,ce,Dn=class{constructor(e,n){this.renderer=e,this.root=n}render({node:e,hydration:n,lt:r,context:i}){if(e===void 0||e===null)return new S;if(Array.isArray(e))return this.render({node:{type:"fragment",children:e},hydration:n,lt:r,context:i});switch(e.type){case"fragment":{let s=new S;return s.children=e.children.map((c)=>this.render({node:c,hydration:n,lt:r,context:i})),s}case"text":return new Me(e.value.toString(),this.renderer,n,i);case"element":{let s=new Fe(e.name,this.renderer,n),c=this.renderer.getHydrationContext(s.rendererNode??m());s.children=e.children.map((l)=>this.render({node:l,hydration:c,lt:r,context:i}));for(let[l,a]of Object.entries(e.attributes))a.subscribe((f)=>{s.setAttribute(l,f)}).cascadesFrom(r);for(let[l,a]of Object.entries(e.bindings))this.renderer.bindValue(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.eventHandlers))this.renderer.addEventListener(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.styles))a.subscribe((f)=>{this.renderer.setStyle(s.rendererNode??m(),l,f)}).cascadesFrom(r);let o=[e.use].flat();for(let l of o)l(s.rendererNode??m());return s}case"component":try{var t=(0,ce.default)();t.u(v.changeHookLifetime(r)),t.u(O.setCurrent(i)),t.u(re(`Rendering ${e.impl.name}`));let s=e.impl;if(Re in s&&typeof s[Re]==="string"){let o=this.renderer.implementations?.find((l)=>l.intrinsic===s);if(o)s=o.implementation}let c=s(e.props);return this.render({node:c,hydration:n,lt:r,context:i})}catch(s){t.e=s}finally{t.d()}case"dynamic":{let s=new S;return oe((c,{lifetime:o})=>{let l=this.render({node:c(e.value),hydration:n,lt:o,context:i});s.children=[l]},void 0,r),s}case"list":{new S;let s=new Map,c=new S,o="";return oe((l)=>{let a=l(e.items),f=a.map((g,A)=>e.getKey(g,A));for(let g of s.keys())if(!f.includes(g))(s.get(g)??m()).lifetime.close(),s.delete(g);for(let g of f)if(!s.has(g))try{var p=(0,ce.default)();let A=a[f.indexOf(g)],cn=L(A),Y=new v;p.u(v.changeHookLifetime(Y));let an=this.render({node:e.renderItem(A,f.indexOf(g)),hydration:n,lt:Y,context:i});s.set(g,{node:an,item:cn,lifetime:Y})}catch(A){p.e=A}finally{p.d()}let h=f.join("|||");if(h!==o)o=h,c.children=f.map((g)=>(s.get(g)??m()).node)}),c}case"context":try{var u=(0,ce.default)();let s=i.fork();return u.u(O.setCurrent(s)),s.addContext(e.id,e.value),this.render({node:e.children,hydration:n,lt:r,context:s})}catch(s){u.e=s}finally{u.d()}default:Ce(e,`No rendering implementation for ${JSON.stringify(e)}`)}}},Cn,jn;var M=d(()=>{Le();Z();b();b();En=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),$n=globalThis.clearImmediate??((e)=>{clearTimeout(e)});Nn={};Pe(Nn,{FLElement:()=>Fe,FLFragment:()=>S,FLNode:()=>z,FLPortal:()=>Ge,FLText:()=>Me});S=class extends z{onChildrenChanged(){this.parent?.onChildrenChanged()}},Me=class extends z{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??m(),e)}constructor(e,n,r,i){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(r,i),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},Fe=class extends z{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??m(),e,n)}constructor(e,n,r){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,r)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??m());this.renderer.setChildren(this.rendererNode??m(),e)}},Ge=class extends z{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??m()))}},fe=Te({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function r(){var i=typeof SuppressedError=="function"?SuppressedError:function(c,o){var l=Error();return l.name="SuppressedError",l.error=c,l.suppressed=o,l},t={},u=[];function s(c,o){if(o!=null){if(Object(o)!==o)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(c)var l=o[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(l===void 0&&(l=o[Symbol.dispose||Symbol.for("Symbol.dispose")],c))var a=l;if(typeof l!="function")throw new TypeError("Object is not disposable.");a&&(l=function f(){try{a.call(o)}catch(p){return Promise.reject(p)}}),u.push({v:o,d:l,a:c})}else c&&u.push({d:o,a:c});return o}return{e:t,u:s.bind(null,!1),a:s.bind(null,!0),d(){var c,o=this.e,l=0;function a(){for(;c=u.pop();)try{if(!c.a&&l===1)return l=0,u.push(c),Promise.resolve().then(a);if(c.d){var p=c.d.call(c.v);if(c.a)return l|=2,Promise.resolve(p).then(a,f)}else l|=1}catch(h){return f(h)}if(l===1)return o!==t?Promise.reject(o):Promise.resolve();if(o!==t)throw o}function f(p){return o=o!==t?new i(p,o):p,a()}return a()}}}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),ce=K(fe(),1),Cn=K(fe(),1);jn=K(fe(),1)});function pe(e,n){let r=n.split("/").map((t)=>t.trim()).filter((t)=>t!=="");function i(t,u,s,c){if(t===e.length&&u===r.length)return{matched:!0,params:{...s},spreads:{...c}};if(t===e.length||u>r.length)return{matched:!1};let o=e[t]??m();if(o.type==="static"){if(u>=r.length||r[u]!==o.match)return{matched:!1};return i(t+1,u+1,s,c)}else if(o.type==="slug"){if(u>=r.length)return{matched:!1};let l={...s,[o.name]:r[u]};return i(t+1,u+1,l,c)}else if(o.type==="spread"){for(let l=0;l<=r.length-u;l++){let a={...c,[o.name]:r.slice(u,u+l)},f=i(t+1,u+l,s,a);if(f.matched)return f}return{matched:!1}}return{matched:!1}}return i(0,0,{},{})}var Je=d(()=>{b();M();b()});function x(e,n){let{children:r,...i}=n||{};if(e===k)return{type:"fragment",children:$(r)};if(typeof e==="string")return q(e,i,r);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(r)}};throw new Error(`Invalid JSX type: ${e}`)}var ye;var Be=d(()=>{Z();ye=x});var Xe=d(()=>{Be()});function Tn(){return E((e)=>{return new URL(e(F)).pathname})}function Pn(){if(typeof window==="undefined")return;F.subscribe((e)=>{if(window.location.href!==e)window.history.pushState({},"",e)},{callInitially:!1}),window.addEventListener("popstate",()=>{F.set(window.location.href)}),document.addEventListener("click",(e)=>{let r=e.composedPath().find((i)=>i instanceof HTMLAnchorElement);if(r?.href){let i=new URL(r.href,C(F));if(i.origin!==window.location.origin)return;e.preventDefault(),F.set(i.href)}})}function Ln({pathname:e,props:n,loaders:r}){if("location"in globalThis)Pn();ze();let i=We(),t=e?j(e):Tn(),u=E((l)=>{let a=l(t);return n.routes.find((f)=>pe(f.matcher,a))}),s=E(async(l)=>{let a=l(u)??m(),f=[];for(let p of a.frames)f.push(await(r[p.index]??m())());return f}),c=le(E((l)=>{return i(l(s))})),o=E((l)=>{let a=x(k,{}),f=l(c);if(!f)return x("h1",{children:"loading"});for(let p of f.toReversed())a=x(p,{children:a});return a});return ye("html",{children:[ye("head",{children:[x("link",{rel:"stylesheet",href:"/styles.css"}),x("script",{src:"/entrypoint-client.js",type:"module"})]}),x("body",{children:o})]})}async function Ke({props:e,loaders:n,renderer:r,root:i,pathname:t,lifetime:u=new v,context:s}){e:if("window"in globalThis){let c=t??window.location.pathname,o=e.routes.find((l)=>pe(l.matcher,c));if(!o)break e;for(let l of o.frames)await(n[l.index]??m())()}Ue({context:s,renderer:r,root:i,component:x(Ln,{pathname:t,props:e,loaders:n})}).cascadesFrom(u)}function Ve(e){return async function(n){return await e.impl(n)}}var F;var he=d(()=>{Je();b();M();Xe();b();F=j(typeof window!=="undefined"?window.location.href:"/")});function Mn(e){return{lang:e?.lang??ve?.lang,message:e?.message,abortEarly:e?.abortEarly??ve?.abortEarly,abortPipeEarly:e?.abortPipeEarly??ve?.abortPipeEarly}}function Gn(e){return Fn?.get(e)}function Wn(e){return Un?.get(e)}function Bn(e,n){return Jn?.get(e)?.get(n)}function Xn(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function de(e,n,r,i,t){let u=t&&"input"in t?t.input:r.value,s=t?.expected??e.expects??null,c=t?.received??Xn(u),o={kind:e.kind,type:e.type,input:u,expected:s,received:c,message:`Invalid ${n}: ${s?`Expected ${s} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:t?.path,issues:t?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},l=e.kind==="schema",a=t?.message??e.message??Bn(e.reference,o.lang)??(l?Wn(o.lang):null)??i.message??Gn(o.lang);if(a!==void 0)o.message=typeof a==="function"?a(o):a;if(l)r.typed=!1;if(r.issues)r.issues.push(o);else r.issues=[o]}function Ye(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Mn())}}}function Kn(e,n,r){return typeof e.fallback==="function"?e.fallback(n,r):e.fallback}function Vn(e,n,r){return typeof e.default==="function"?e.default(n,r):e.default}function Q(e){return{kind:"schema",type:"number",reference:Q,expects:"number",async:!1,message:e,get "~standard"(){return Ye(this)},"~run"(n,r){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else de(this,"type",n,r);return n}}}function ge(e,n){return{kind:"schema",type:"object",reference:ge,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return Ye(this)},"~run"(r,i){let t=r.value;if(t&&typeof t==="object"){r.typed=!0,r.value={};for(let u in this.entries){let s=this.entries[u];if(u in t||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){let c=u in t?t[u]:Vn(s),o=s["~run"]({value:c},i);if(o.issues){let l={type:"object",origin:"value",input:t,key:u,value:c};for(let a of o.issues){if(a.path)a.path.unshift(l);else a.path=[l];r.issues?.push(a)}if(!r.issues)r.issues=o.issues;if(i.abortEarly){r.typed=!1;break}}if(!o.typed)r.typed=!1;r.value[u]=o.value}else if(s.fallback!==void 0)r.value[u]=Kn(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"){if(de(this,"key",r,i,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:t,key:u,value:t[u]}]}),i.abortEarly)break}}}else de(this,"type",r,i);return r}}}var ve,Fn,Un,Jn;var en=()=>{};function G(e,n,r,i,t,u){let{children:s,...c}=n||{};if(e===k)return{type:"fragment",children:$(s),...t};if(typeof e==="string")return q(e,c,s,t);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(s)},...t};throw new Error(`Invalid JSX type: ${e}`)}var nn=d(()=>{Z()});var be=d(()=>{nn()});var Vr,rn=function({children:e}){return G(k,{children:[G("title",{children:"Wormhole Example"},void 0,!1,void 0,this),e]},void 0,!0,void 0,this)},tn=function(){return G(k,{children:G("h1",{children:"404 not found"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},Zn=function({a:e,b:n}){return e+n},Qn;var ke=d(()=>{en();he();be();Vr=Ve({schema:Qn,impl:Zn,endpoint:"/api/add",method:"GET",isQuery:!0}),Qn=ge({a:Q(),b:Q()})});var sn={};we(sn,{$d_732_888:()=>rn});var un=d(()=>{ke()});var on={};we(on,{$d_902_1009:()=>tn});var ln=d(()=>{ke()});he();M();b();M();b();function Rn(e){return"tagName"in e?e.tagName:"Text"}function qn(){return{html:"",write(e){this.html+=e},lastType:""}}function He(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function me(e,n=qn()){let r=Rn(e);if(r==="Text"&&n.lastType==="Text")n.write("");if(n.lastType=r,"tagName"in e){n.write("<"),n.write(e.tagName);for(let[i,t]of Object.entries(e.attributes)){if(t===void 0)continue;n.write(` ${i}="${He(t)}"`)}n.write(">");for(let i of e.children)me(i,n);n.write("")}if("content"in e)n.write(He(e.content.toString()));return n.html}function zn(e){return e.split(/(?=[A-Z])/).map((r)=>r.toLowerCase()).join("-")}function Ze(){return{createNode(e,n){return{tagName:e,attributes:{},children:[],parent:void 0}},setAttribute(e,n,r){if(!("tagName"in e))throw new Error("Cannot set attribute on a text node");e.attributes[n]=r},createTextNode(e){return{content:"",parent:void 0}},setTextContent(e,n){if(!("content"in e))throw new Error("Cannot set text content on a non-text node");e.content=n},setChildren(e,n){if(!("children"in e))throw new Error("Cannot set children on a text node");e.children=n;for(let r of n)r.parent=e},getHydrationContext(e){return},addEventListener(e,n,r){return new v},bindValue(e,n,r){return new v},setStyle(e,n,r){if(!("attributes"in e))throw new Error("Cannot set style on a text node");let i=e.attributes.style??"";i+=`${zn(n)}: ${r};`,e.attributes.style=i}}}function Qe(){return{tagName:"html",attributes:{},children:[],parent:void 0,fixedIdent:"document.documentElement"}}var Yn=JSON.parse('{"routes":[{"matcher":[{"type":"spread","name":"404"}],"frames":[{"index":0},{"index":1}],"is404":true}]}'),er=[async()=>(await Promise.resolve().then(() => (un(),sn))).$d_732_888,async()=>(await Promise.resolve().then(() => (ln(),on))).$d_902_1009];async function nr(e){let r=new URL(e.url).pathname,i=Ze(),t=Qe(),u=new v;try{await Ke({props:Yn,loaders:er,renderer:i,root:t,pathname:r,context:{},lifetime:u});let s=me(t);return new Response(s,{status:200,headers:{"Content-Type":"text/html"}})}catch(s){return console.error("Rendering error:",s),new Response("Internal Server Error",{status:500})}finally{u.close()}}export{nr as default}; +`)t+="\\n";else if(u==="\t")t+="\\t";else if(u==="\r")t+="\\r";else t+=u;if(t+=i,t.length{_e();$e={};xe($e,{escapeStr:()=>ne,isAlphabetic:()=>X,isAlphanumeric:()=>Ie,isNumeric:()=>W,isWhitespace:()=>Ae,keywords:()=>I,lex:()=>Se,parse:()=>hn,parseContext_create:()=>Oe,parseContext_next:()=>yn,parseContext_peek:()=>J,parseContext_read:()=>N,parseContext_readObj:()=>B,serialize:()=>Ce,serializeContext_create:()=>Ne,serializeContext_dedent:()=>P,serializeContext_indent:()=>T,serializeContext_newline:()=>w,serializeContext_write:()=>y,serializeContext_writeObject:()=>C,stringify:()=>mn,symbols:()=>ee});I={null:"Null",true:"True",false:"False",undefined:"Undefined"},ee={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};mn=Ce});var gn,ie,bn,je,kn,wn,Te=(e,n)=>function(){return n||e[je(e)[0]]((n={exports:{}}).exports,n),n.exports},Pe=(e,n)=>{for(var r in n)ie(e,r,{get:n[r],enumerable:!0})},xn=(e,n,r,i)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var t=je(n),u=0,s=t.length,c;un[o]).bind(null,c),enumerable:!(i=bn(n,c))||i.enumerable})}return e},K=(e,n,r)=>(r=e!=null?gn(kn(e)):{},xn(n||!e||!e.__esModule?ie(r,"default",{value:e,enumerable:!0}):r,e));var Le=d(()=>{gn=Object.create,ie=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,je=Object.getOwnPropertyNames,kn=Object.getPrototypeOf,wn=Object.prototype.hasOwnProperty});function H(){if(v.hookLifetime===null)throw new Error("No hook lifetime available");return v.hookLifetime}function L(e){let n,r=e,i=[];return n&&console.log(`[${n}]: initialized with `,r),{setId(t){n=t},[_](){return r},subscribe(t,u){if(i.push(t),n&&console.trace(`[${n}]: subscribed with `,t),u?.callInitially!==!1)t(r);return new v().onClosed(()=>{i.splice(i.indexOf(t),1),n&&console.log(`[${n}]: unsubscribed `,t)})},set(t){if(n&&console.log(`[${n}]: trying to switch from `,r," -> ",t),!U(r,t)){r=t;for(let u of i)u(r);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}function D(e){return e[_]()}function ue(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=L(e((o)=>{if(!t.includes(o))t.push(o);return o[_]()}));function s(){if(i){let o=new Set(t);u.set(e((p)=>{return o.add(p),p[_]()}));let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.set(e(D))}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)});return{...u}}function oe(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=new v;e((o)=>{if(!t.includes(o))t.push(o);return o[_]()},{lifetime:u});function s(){if(i){let o=new Set(t);u.close(),u=new v().cascadesFrom(r),e((p)=>{return o.add(p),p[_]()},{lifetime:u});let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.close(),u=new v().cascadesFrom(r),e(D,{lifetime:u})}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)})}function R(e){return typeof e==="object"&&e!==null&&_ in e}function se(e){if(R(e))return e;return L(e)}function le(e,n=H()){return ue((r)=>{function i(t){if(R(t))return i(r(t));return t}return i(e)},{dynamic:!0},n)}function $(e){if(e===void 0)return[];return[e].flat().filter((n)=>n!==null&&n!==void 0).map((n)=>typeof n==="string"||typeof n==="number"||typeof n==="boolean"?V(n):R(n)?{type:"dynamic",value:E((r)=>{let i=r(n);return typeof i==="number"||typeof i==="string"||typeof i==="boolean"?V(i):i})}:n)}function V(e,n){return{type:"text",value:e,...n}}function q(e,n,r,i){let t=$(r).map((a)=>{if(typeof a==="string"||typeof a==="number"||typeof a==="boolean")return V(a);return a}),u={},s={},c={},o=[],l={};for(let[a,f]of Object.entries(n))if(f!==void 0)if(a.startsWith("bind:")){let p=a.slice(5);if(!R(f)||!("set"in f))throw new Error(`Binding value for "${p}" must be a writable store.`);s[p]=f}else if(a.startsWith("on:")){let p=a.slice(3);if(typeof f!=="function")throw new Error(`Event handler for "${p}" must be a function.`);c[p]=f}else if(a==="use"){if(typeof f!=="function"&&!Array.isArray(f))throw new Error("Use hook must be a function or an array of functions.");o.push(f)}else if(a==="style"){for(let[p,h]of Object.entries(f))if(h!==void 0)l[p]=se(h)}else u[a]=se(f);return{type:"element",name:e,attributes:u,children:t,bindings:s,eventHandlers:c,use:o,styles:l}}var _n,v,_="@vortex-get-internal",j,E,k;var Z=d(()=>{b();_n=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let r=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=r},[Symbol.dispose](){e.hookLifetime=r}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},v=class extends te({package:"@vortexjs/core",name:"Lifetime"},_n){};j=L,E=ue;k=te({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});function In(){let e=O.current;if(!e)throw new Error("No context scope found, you should have one if you're rendering a component.");return e}function ze(){return In().streaming}function Sn(){let e=O.current;if(!e)return null;return e}function On(){let e=Sn();if(!e)return null;return e.streaming}function qe({renderer:e,root:n,component:r,context:i}){try{var t=Dn.default();t.u(re("Initial page render"));let u=new Cn(e,n),s=new v,c=u.render({node:r,hydration:e.getHydrationContext(n),lt:s,context:i??O.current??new O}),o=new Ge(n,e);return o.children=[c],s}catch(u){t.e=u}finally{t.d()}}function Ue(e,n,r){if("renderer"in e)return qe(e);else return qe({renderer:e,root:n,component:r})}function We(){let e=On();return(n)=>{let r=j(void 0);async function i(){if(e)try{var t=jn.default();t.u(e.markLoading()),r.set(await n)}catch(u){t.e=u}finally{t.d()}else r.set(await n)}return i(),r}}var En,$n,An=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)$n(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=En(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},O=class e{contexts={};streaming=new An;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,r){this.contexts[n]=r}static current=null;static setCurrent(n){let r=e.current;return e.current=n,{[Symbol.dispose](){e.current=r}}}},Re="~vortex:intrinsic",Nn,z=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(r){if(r instanceof S)for(let i of r.children)n(i);else e.push(r)}for(let r of this.children)n(r);return e}},S,Me,Fe,Ge,fe,ce,Cn=class{constructor(e,n){this.renderer=e,this.root=n}render({node:e,hydration:n,lt:r,context:i}){if(e===void 0||e===null)return new S;if(Array.isArray(e))return this.render({node:{type:"fragment",children:e},hydration:n,lt:r,context:i});switch(e.type){case"fragment":{let s=new S;return s.children=e.children.map((c)=>this.render({node:c,hydration:n,lt:r,context:i})),s}case"text":return new Me(e.value.toString(),this.renderer,n,i);case"element":{let s=new Fe(e.name,this.renderer,n),c=this.renderer.getHydrationContext(s.rendererNode??m());s.children=e.children.map((l)=>this.render({node:l,hydration:c,lt:r,context:i}));for(let[l,a]of Object.entries(e.attributes))a.subscribe((f)=>{s.setAttribute(l,f)}).cascadesFrom(r);for(let[l,a]of Object.entries(e.bindings))this.renderer.bindValue(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.eventHandlers))this.renderer.addEventListener(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.styles))a.subscribe((f)=>{this.renderer.setStyle(s.rendererNode??m(),l,f)}).cascadesFrom(r);let o=[e.use].flat();for(let l of o)l(s.rendererNode??m());return s}case"component":try{var t=ce.default();t.u(v.changeHookLifetime(r)),t.u(O.setCurrent(i)),t.u(re(`Rendering ${e.impl.name}`));let s=e.impl;if(Re in s&&typeof s[Re]==="string"){let o=this.renderer.implementations?.find((l)=>l.intrinsic===s);if(o)s=o.implementation}let c=s(e.props);return this.render({node:c,hydration:n,lt:r,context:i})}catch(s){t.e=s}finally{t.d()}case"dynamic":{let s=new S;return oe((c,{lifetime:o})=>{let l=this.render({node:c(e.value),hydration:n,lt:o,context:i});s.children=[l]},void 0,r),s}case"list":{new S;let s=new Map,c=new S,o="";return oe((l)=>{let a=l(e.items),f=a.map((g,A)=>e.getKey(g,A));for(let g of s.keys())if(!f.includes(g))(s.get(g)??m()).lifetime.close(),s.delete(g);for(let g of f)if(!s.has(g))try{var p=ce.default();let A=a[f.indexOf(g)],cn=L(A),Y=new v;p.u(v.changeHookLifetime(Y));let an=this.render({node:e.renderItem(A,f.indexOf(g)),hydration:n,lt:Y,context:i});s.set(g,{node:an,item:cn,lifetime:Y})}catch(A){p.e=A}finally{p.d()}let h=f.join("|||");if(h!==o)o=h,c.children=f.map((g)=>(s.get(g)??m()).node)}),c}case"context":try{var u=ce.default();let s=i.fork();return u.u(O.setCurrent(s)),s.addContext(e.id,e.value),this.render({node:e.children,hydration:n,lt:r,context:s})}catch(s){u.e=s}finally{u.d()}default:De(e,`No rendering implementation for ${JSON.stringify(e)}`)}}},Dn,jn;var M=d(()=>{Le();Z();b();b();En=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),$n=globalThis.clearImmediate??((e)=>{clearTimeout(e)});Nn={};Pe(Nn,{FLElement:()=>Fe,FLFragment:()=>S,FLNode:()=>z,FLPortal:()=>Ge,FLText:()=>Me});S=class extends z{onChildrenChanged(){this.parent?.onChildrenChanged()}},Me=class extends z{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??m(),e)}constructor(e,n,r,i){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(r,i),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},Fe=class extends z{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??m(),e,n)}constructor(e,n,r){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,r)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??m());this.renderer.setChildren(this.rendererNode??m(),e)}},Ge=class extends z{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??m()))}},fe=Te({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function r(){var i=typeof SuppressedError=="function"?SuppressedError:function(c,o){var l=Error();return l.name="SuppressedError",l.error=c,l.suppressed=o,l},t={},u=[];function s(c,o){if(o!=null){if(Object(o)!==o)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(c)var l=o[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(l===void 0&&(l=o[Symbol.dispose||Symbol.for("Symbol.dispose")],c))var a=l;if(typeof l!="function")throw new TypeError("Object is not disposable.");a&&(l=function f(){try{a.call(o)}catch(p){return Promise.reject(p)}}),u.push({v:o,d:l,a:c})}else c&&u.push({d:o,a:c});return o}return{e:t,u:s.bind(null,!1),a:s.bind(null,!0),d(){var c,o=this.e,l=0;function a(){for(;c=u.pop();)try{if(!c.a&&l===1)return l=0,u.push(c),Promise.resolve().then(a);if(c.d){var p=c.d.call(c.v);if(c.a)return l|=2,Promise.resolve(p).then(a,f)}else l|=1}catch(h){return f(h)}if(l===1)return o!==t?Promise.reject(o):Promise.resolve();if(o!==t)throw o}function f(p){return o=o!==t?new i(p,o):p,a()}return a()}}}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),ce=K(fe(),1),Dn=K(fe(),1);jn=K(fe(),1)});function pe(e,n){let r=n.split("/").map((t)=>t.trim()).filter((t)=>t!=="");function i(t,u,s,c){if(t===e.length&&u===r.length)return{matched:!0,params:{...s},spreads:{...c}};if(t===e.length||u>r.length)return{matched:!1};let o=e[t]??m();if(o.type==="static"){if(u>=r.length||r[u]!==o.match)return{matched:!1};return i(t+1,u+1,s,c)}else if(o.type==="slug"){if(u>=r.length)return{matched:!1};let l={...s,[o.name]:r[u]};return i(t+1,u+1,l,c)}else if(o.type==="spread"){for(let l=0;l<=r.length-u;l++){let a={...c,[o.name]:r.slice(u,u+l)},f=i(t+1,u+l,s,a);if(f.matched)return f}return{matched:!1}}return{matched:!1}}return i(0,0,{},{})}var Je=d(()=>{b();M();b()});function x(e,n){let{children:r,...i}=n||{};if(e===k)return{type:"fragment",children:$(r)};if(typeof e==="string")return q(e,i,r);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(r)}};throw new Error(`Invalid JSX type: ${e}`)}var ye;var Be=d(()=>{Z();ye=x});var Xe=d(()=>{Be()});function Tn(){return E((e)=>{return new URL(e(F)).pathname})}function Pn(){if(typeof window==="undefined")return;F.subscribe((e)=>{if(window.location.href!==e)window.history.pushState({},"",e)},{callInitially:!1}),window.addEventListener("popstate",()=>{F.set(window.location.href)}),document.addEventListener("click",(e)=>{let r=e.composedPath().find((i)=>i instanceof HTMLAnchorElement);if(r?.href){let i=new URL(r.href,D(F));if(i.origin!==window.location.origin)return;e.preventDefault(),F.set(i.href)}})}function Ln({pathname:e,props:n,loaders:r}){if("location"in globalThis)Pn();ze();let i=We(),t=e?j(e):Tn(),u=E((l)=>{let a=l(t);return n.routes.find((f)=>pe(f.matcher,a))}),s=E(async(l)=>{let a=l(u)??m(),f=[];for(let p of a.frames)f.push(await(r[p.index]??m())());return f}),c=le(E((l)=>{return i(l(s))})),o=E((l)=>{let a=x(k,{}),f=l(c);if(!f)return x("h1",{children:"loading"});for(let p of f.toReversed())a=x(p,{children:a});return a});return ye("html",{children:[ye("head",{children:[x("link",{rel:"stylesheet",href:"/styles.css"}),x("script",{src:"/entrypoint-client.js",type:"module"})]}),x("body",{children:o})]})}async function Ke({props:e,loaders:n,renderer:r,root:i,pathname:t,lifetime:u=new v,context:s}){e:if("window"in globalThis){let c=t??window.location.pathname,o=e.routes.find((l)=>pe(l.matcher,c));if(!o)break e;for(let l of o.frames)await(n[l.index]??m())()}Ue({context:s,renderer:r,root:i,component:x(Ln,{pathname:t,props:e,loaders:n})}).cascadesFrom(u)}function Ve(e){return async function(n){return await e.impl(n)}}var F;var he=d(()=>{Je();b();M();Xe();b();F=j(typeof window!=="undefined"?window.location.href:"/")});function Mn(e){return{lang:e?.lang??ve?.lang,message:e?.message,abortEarly:e?.abortEarly??ve?.abortEarly,abortPipeEarly:e?.abortPipeEarly??ve?.abortPipeEarly}}function Gn(e){return Fn?.get(e)}function Wn(e){return Un?.get(e)}function Bn(e,n){return Jn?.get(e)?.get(n)}function Xn(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function de(e,n,r,i,t){let u=t&&"input"in t?t.input:r.value,s=t?.expected??e.expects??null,c=t?.received??Xn(u),o={kind:e.kind,type:e.type,input:u,expected:s,received:c,message:`Invalid ${n}: ${s?`Expected ${s} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:t?.path,issues:t?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},l=e.kind==="schema",a=t?.message??e.message??Bn(e.reference,o.lang)??(l?Wn(o.lang):null)??i.message??Gn(o.lang);if(a!==void 0)o.message=typeof a==="function"?a(o):a;if(l)r.typed=!1;if(r.issues)r.issues.push(o);else r.issues=[o]}function Ye(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Mn())}}}function Kn(e,n,r){return typeof e.fallback==="function"?e.fallback(n,r):e.fallback}function Vn(e,n,r){return typeof e.default==="function"?e.default(n,r):e.default}function Q(e){return{kind:"schema",type:"number",reference:Q,expects:"number",async:!1,message:e,get "~standard"(){return Ye(this)},"~run"(n,r){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else de(this,"type",n,r);return n}}}function ge(e,n){return{kind:"schema",type:"object",reference:ge,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return Ye(this)},"~run"(r,i){let t=r.value;if(t&&typeof t==="object"){r.typed=!0,r.value={};for(let u in this.entries){let s=this.entries[u];if(u in t||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){let c=u in t?t[u]:Vn(s),o=s["~run"]({value:c},i);if(o.issues){let l={type:"object",origin:"value",input:t,key:u,value:c};for(let a of o.issues){if(a.path)a.path.unshift(l);else a.path=[l];r.issues?.push(a)}if(!r.issues)r.issues=o.issues;if(i.abortEarly){r.typed=!1;break}}if(!o.typed)r.typed=!1;r.value[u]=o.value}else if(s.fallback!==void 0)r.value[u]=Kn(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"){if(de(this,"key",r,i,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:t,key:u,value:t[u]}]}),i.abortEarly)break}}}else de(this,"type",r,i);return r}}}var ve,Fn,Un,Jn;var en=()=>{};function G(e,n,r,i,t,u){let{children:s,...c}=n||{};if(e===k)return{type:"fragment",children:$(s),...t};if(typeof e==="string")return q(e,c,s,t);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(s)},...t};throw new Error(`Invalid JSX type: ${e}`)}var nn=d(()=>{Z()});var be=d(()=>{nn()});var Vr,rn=function({children:e}){return G(k,{children:[G("title",{children:"Wormhole Example"},void 0,!1,void 0,this),e]},void 0,!0,void 0,this)},tn=function(){return G(k,{children:G("h1",{children:"404 not found"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},Zn=function({a:e,b:n}){return e+n},Qn;var ke=d(()=>{en();he();be();Vr=Ve({schema:Qn,impl:Zn,endpoint:"/api/add",method:"GET",isQuery:!0}),Qn=ge({a:Q(),b:Q()})});var sn={};we(sn,{$d_732_888:()=>rn});var un=d(()=>{ke()});var on={};we(on,{$d_902_1009:()=>tn});var ln=d(()=>{ke()});he();M();b();M();b();function Rn(e){return"tagName"in e?e.tagName:"Text"}function qn(){return{html:"",write(e){this.html+=e},lastType:""}}function He(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function me(e,n=qn()){let r=Rn(e);if(r==="Text"&&n.lastType==="Text")n.write("");if(n.lastType=r,"tagName"in e){n.write("<"),n.write(e.tagName);for(let[i,t]of Object.entries(e.attributes)){if(t===void 0)continue;n.write(` ${i}="${He(t)}"`)}n.write(">");for(let i of e.children)me(i,n);n.write("")}if("content"in e)n.write(He(e.content.toString()));return n.html}function zn(e){return e.split(/(?=[A-Z])/).map((r)=>r.toLowerCase()).join("-")}function Ze(){return{createNode(e,n){return{tagName:e,attributes:{},children:[],parent:void 0}},setAttribute(e,n,r){if(!("tagName"in e))throw new Error("Cannot set attribute on a text node");e.attributes[n]=r},createTextNode(e){return{content:"",parent:void 0}},setTextContent(e,n){if(!("content"in e))throw new Error("Cannot set text content on a non-text node");e.content=n},setChildren(e,n){if(!("children"in e))throw new Error("Cannot set children on a text node");e.children=n;for(let r of n)r.parent=e},getHydrationContext(e){return},addEventListener(e,n,r){return new v},bindValue(e,n,r){return new v},setStyle(e,n,r){if(!("attributes"in e))throw new Error("Cannot set style on a text node");let i=e.attributes.style??"";i+=`${zn(n)}: ${r};`,e.attributes.style=i}}}function Qe(){return{tagName:"html",attributes:{},children:[],parent:void 0,fixedIdent:"document.documentElement"}}var Yn=JSON.parse('{"routes":[{"matcher":[{"type":"spread","name":"404"}],"frames":[{"index":0},{"index":1}],"is404":true}]}'),er=[async()=>(await Promise.resolve().then(() => (un(),sn))).$d_732_888,async()=>(await Promise.resolve().then(() => (ln(),on))).$d_902_1009];async function nr(e){let r=new URL(e.url).pathname,i=Ze(),t=Qe(),u=new v;try{await Ke({props:Yn,loaders:er,renderer:i,root:t,pathname:r,context:{},lifetime:u});let s=me(t);return new Response(s,{status:200,headers:{"Content-Type":"text/html"}})}catch(s){return console.error("Rendering error:",s),new Response("Internal Server Error",{status:500})}finally{u.close()}}export{nr as default}; diff --git a/packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/index.js b/packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/index.js index bd76c7c..aaa51fd 100644 --- a/packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/index.js +++ b/packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/index.js @@ -3,4 +3,4 @@ var fn=Object.defineProperty;var we=(e,n)=>{for(var r in n)fn(e,r,{get:n[r],enum `||e==="\r"}function X(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}function W(e){return e>="0"&&e<="9"}function Ie(e){return X(e)||W(e)}function*Se(e){let n=0,r=()=>e[n]??"",i=()=>e[n++]??"",t=()=>{n++};while(n=e.tokens.length)return null;return e.tokens[e.current++]??null}function J(e){if(e.current>=e.tokens.length)return null;return e.tokens[e.current]??null}function N(e){let n=J(e);if(n!==null)e.current++;return n}function B(e){let n=N(e);if(n===null)throw new Error("Unexpected end of input");if(n[0]==="number")return n[1];if(n[0]==="string")return n[1];if(n[0]==="keyword"){if(n[1]===I.null)return null;if(n[1]===I.undefined)return;if(n[1]===I.true)return!0;if(n[1]===I.false)return!1;throw new Error(`Unexpected keyword: ${n[1]}`)}let r=null;if(n[0]==="identifier")r=n[1],n=N(e);if(n===null)throw new Error("Unexpected end of input (after reading class)");if(n[0]==="symbol"&&n[1]==="LeftParenthesis"){let i={};while(!0){let t=N(e);if(t===null)throw new Error("Unexpected end of input (when trying to read key)");if(t[0]==="symbol"&&t[1]==="RightParenthesis")break;if(t[0]!=="identifier"&&t[0]!=="string")throw new Error(`Expected identifier or string, got ${t[0]}`);let u=N(e);if(u===null||u[0]!=="symbol"||u[1]!=="Equals")throw new Error(`Expected '=', got ${u?u[0]:"end of input"}`);let s=t[1],c=B(e);i[s]=c}if(r!==null){if(r==="date")return new Date(i.unix);if(r==="set")return new Set(i.items);if(r==="map"){let t=new Map;for(let[u,s]of i.entries)t.set(u,s);return t}throw new Error(`Unknown class: ${r}`)}return i}if(n[0]==="symbol"&&n[1]==="LeftSquareBracket"){let i=[];while(!0){if(J(e)?.[0]==="symbol"&&J(e)?.[1]==="RightSquareBracket"){N(e);break}let t=B(e);i.push(t)}return i}}function hn(e){let n=[...Se(e)],r=Oe(n),i=B(r);if(r.currentt[0]).join(", ")}`);return i}function Ne(){return{output:"",indentLevel:0,minified:!1}}function P(e){e.indentLevel++}function L(e){e.indentLevel=Math.max(0,e.indentLevel-1)}function w(e){if(e.minified){y(e," ");return}y(e,` `),y(e," ".repeat(e.indentLevel))}function y(e,n){e.output+=n}function ne(e){let n=Number.POSITIVE_INFINITY,r="";for(let i of['"',"'","`"]){let t="";t+=i;for(let u of e)if(u===i)t+=`\\${u}`;else if(u==="\\")t+="\\\\";else if(u===` -`)t+="\\n";else if(u==="\t")t+="\\t";else if(u==="\r")t+="\\r";else t+=u;if(t+=i,t.length{_e();$e={};xe($e,{escapeStr:()=>ne,isAlphabetic:()=>X,isAlphanumeric:()=>Ie,isNumeric:()=>W,isWhitespace:()=>Ae,keywords:()=>I,lex:()=>Se,parse:()=>hn,parseContext_create:()=>Oe,parseContext_next:()=>yn,parseContext_peek:()=>J,parseContext_read:()=>N,parseContext_readObj:()=>B,serialize:()=>De,serializeContext_create:()=>Ne,serializeContext_dedent:()=>L,serializeContext_indent:()=>P,serializeContext_newline:()=>w,serializeContext_write:()=>y,serializeContext_writeObject:()=>D,stringify:()=>mn,symbols:()=>ee});I={null:"Null",true:"True",false:"False",undefined:"Undefined"},ee={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};mn=De});var gn,ie,bn,je,kn,wn,Te=(e,n)=>function(){return n||(0,e[je(e)[0]])((n={exports:{}}).exports,n),n.exports},Pe=(e,n)=>{for(var r in n)ie(e,r,{get:n[r],enumerable:!0})},xn=(e,n,r,i)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var t=je(n),u=0,s=t.length,c;un[o]).bind(null,c),enumerable:!(i=bn(n,c))||i.enumerable})}return e},K=(e,n,r)=>(r=e!=null?gn(kn(e)):{},xn(n||!e||!e.__esModule?ie(r,"default",{value:e,enumerable:!0}):r,e));var Le=d(()=>{gn=Object.create,ie=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,je=Object.getOwnPropertyNames,kn=Object.getPrototypeOf,wn=Object.prototype.hasOwnProperty});function H(){if(v.hookLifetime===null)throw new Error("No hook lifetime available");return v.hookLifetime}function q(e){let n,r=e,i=[];return n&&console.log(`[${n}]: initialized with `,r),{setId(t){n=t},[_](){return r},subscribe(t,u){if(i.push(t),n&&console.trace(`[${n}]: subscribed with `,t),u?.callInitially!==!1)t(r);return new v().onClosed(()=>{i.splice(i.indexOf(t),1),n&&console.log(`[${n}]: unsubscribed `,t)})},set(t){if(n&&console.log(`[${n}]: trying to switch from `,r," -> ",t),!U(r,t)){r=t;for(let u of i)u(r);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}function C(e){return e[_]()}function ue(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=q(e((o)=>{if(!t.includes(o))t.push(o);return o[_]()}));function s(){if(i){let o=new Set(t);u.set(e((p)=>{return o.add(p),p[_]()}));let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.set(e(C))}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)});return{...u}}function oe(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=new v;e((o)=>{if(!t.includes(o))t.push(o);return o[_]()},{lifetime:u});function s(){if(i){let o=new Set(t);u.close(),u=new v().cascadesFrom(r),e((p)=>{return o.add(p),p[_]()},{lifetime:u});let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.close(),u=new v().cascadesFrom(r),e(C,{lifetime:u})}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)})}function R(e){return typeof e==="object"&&e!==null&&_ in e}function se(e){if(R(e))return e;return q(e)}function le(e,n=H()){return ue((r)=>{function i(t){if(R(t))return i(r(t));return t}return i(e)},{dynamic:!0},n)}function $(e){if(e===void 0)return[];return[e].flat().filter((n)=>n!==null&&n!==void 0).map((n)=>typeof n==="string"||typeof n==="number"||typeof n==="boolean"?V(n):R(n)?{type:"dynamic",value:E((r)=>{let i=r(n);return typeof i==="number"||typeof i==="string"||typeof i==="boolean"?V(i):i})}:n)}function V(e,n){return{type:"text",value:e,...n}}function z(e,n,r,i){let t=$(r).map((a)=>{if(typeof a==="string"||typeof a==="number"||typeof a==="boolean")return V(a);return a}),u={},s={},c={},o=[],l={};for(let[a,f]of Object.entries(n))if(f!==void 0)if(a.startsWith("bind:")){let p=a.slice(5);if(!R(f)||!("set"in f))throw new Error(`Binding value for "${p}" must be a writable store.`);s[p]=f}else if(a.startsWith("on:")){let p=a.slice(3);if(typeof f!=="function")throw new Error(`Event handler for "${p}" must be a function.`);c[p]=f}else if(a==="use"){if(typeof f!=="function"&&!Array.isArray(f))throw new Error("Use hook must be a function or an array of functions.");o.push(f)}else if(a==="style"){for(let[p,h]of Object.entries(f))if(h!==void 0)l[p]=se(h)}else u[a]=se(f);return{type:"element",name:e,attributes:u,children:t,bindings:s,eventHandlers:c,use:o,styles:l}}var _n,v,_="@vortex-get-internal",j,E,k;var Z=d(()=>{b();_n=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let r=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=r},[Symbol.dispose](){e.hookLifetime=r}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},v=class extends te({package:"@vortexjs/core",name:"Lifetime"},_n){};j=q,E=ue;k=te({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});function In(){let e=O.current;if(!e)throw new Error("No context scope found, you should have one if you're rendering a component.");return e}function ze(){return In().streaming}function Sn(){let e=O.current;if(!e)return null;return e}function On(){let e=Sn();if(!e)return null;return e.streaming}function Re({renderer:e,root:n,component:r,context:i}){try{var t=(0,Cn.default)();t.u(re("Initial page render"));let u=new Dn(e,n),s=new v,c=u.render({node:r,hydration:e.getHydrationContext(n),lt:s,context:i??O.current??new O}),o=new Ge(n,e);return o.children=[c],s}catch(u){t.e=u}finally{t.d()}}function Ue(e,n,r){if("renderer"in e)return Re(e);else return Re({renderer:e,root:n,component:r})}function We(){let e=On();return(n)=>{let r=j(void 0);async function i(){if(e)try{var t=(0,jn.default)();t.u(e.markLoading()),r.set(await n)}catch(u){t.e=u}finally{t.d()}else r.set(await n)}return i(),r}}var En,$n,An=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)$n(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=En(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},O=class e{contexts={};streaming=new An;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,r){this.contexts[n]=r}static current=null;static setCurrent(n){let r=e.current;return e.current=n,{[Symbol.dispose](){e.current=r}}}},qe="~vortex:intrinsic",Nn,M=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(r){if(r instanceof S)for(let i of r.children)n(i);else e.push(r)}for(let r of this.children)n(r);return e}},S,Me,Fe,Ge,fe,ce,Dn=class{constructor(e,n){this.renderer=e,this.root=n}render({node:e,hydration:n,lt:r,context:i}){if(e===void 0||e===null)return new S;if(Array.isArray(e))return this.render({node:{type:"fragment",children:e},hydration:n,lt:r,context:i});switch(e.type){case"fragment":{let s=new S;return s.children=e.children.map((c)=>this.render({node:c,hydration:n,lt:r,context:i})),s}case"text":return new Me(e.value.toString(),this.renderer,n,i);case"element":{let s=new Fe(e.name,this.renderer,n),c=this.renderer.getHydrationContext(s.rendererNode??m());s.children=e.children.map((l)=>this.render({node:l,hydration:c,lt:r,context:i}));for(let[l,a]of Object.entries(e.attributes))a.subscribe((f)=>{s.setAttribute(l,f)}).cascadesFrom(r);for(let[l,a]of Object.entries(e.bindings))this.renderer.bindValue(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.eventHandlers))this.renderer.addEventListener(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.styles))a.subscribe((f)=>{this.renderer.setStyle(s.rendererNode??m(),l,f)}).cascadesFrom(r);let o=[e.use].flat();for(let l of o)l(s.rendererNode??m());return s}case"component":try{var t=(0,ce.default)();t.u(v.changeHookLifetime(r)),t.u(O.setCurrent(i)),t.u(re(`Rendering ${e.impl.name}`));let s=e.impl;if(qe in s&&typeof s[qe]==="string"){let o=this.renderer.implementations?.find((l)=>l.intrinsic===s);if(o)s=o.implementation}let c=s(e.props);return this.render({node:c,hydration:n,lt:r,context:i})}catch(s){t.e=s}finally{t.d()}case"dynamic":{let s=new S;return oe((c,{lifetime:o})=>{let l=this.render({node:c(e.value),hydration:n,lt:o,context:i});s.children=[l]},void 0,r),s}case"list":{new S;let s=new Map,c=new S,o="";return oe((l)=>{let a=l(e.items),f=a.map((g,A)=>e.getKey(g,A));for(let g of s.keys())if(!f.includes(g))(s.get(g)??m()).lifetime.close(),s.delete(g);for(let g of f)if(!s.has(g))try{var p=(0,ce.default)();let A=a[f.indexOf(g)],cn=q(A),Y=new v;p.u(v.changeHookLifetime(Y));let an=this.render({node:e.renderItem(A,f.indexOf(g)),hydration:n,lt:Y,context:i});s.set(g,{node:an,item:cn,lifetime:Y})}catch(A){p.e=A}finally{p.d()}let h=f.join("|||");if(h!==o)o=h,c.children=f.map((g)=>(s.get(g)??m()).node)}),c}case"context":try{var u=(0,ce.default)();let s=i.fork();return u.u(O.setCurrent(s)),s.addContext(e.id,e.value),this.render({node:e.children,hydration:n,lt:r,context:s})}catch(s){u.e=s}finally{u.d()}default:Ce(e,`No rendering implementation for ${JSON.stringify(e)}`)}}},Cn,jn;var F=d(()=>{Le();Z();b();b();En=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),$n=globalThis.clearImmediate??((e)=>{clearTimeout(e)});Nn={};Pe(Nn,{FLElement:()=>Fe,FLFragment:()=>S,FLNode:()=>M,FLPortal:()=>Ge,FLText:()=>Me});S=class extends M{onChildrenChanged(){this.parent?.onChildrenChanged()}},Me=class extends M{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??m(),e)}constructor(e,n,r,i){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(r,i),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},Fe=class extends M{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??m(),e,n)}constructor(e,n,r){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,r)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??m());this.renderer.setChildren(this.rendererNode??m(),e)}},Ge=class extends M{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??m()))}},fe=Te({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function r(){var i=typeof SuppressedError=="function"?SuppressedError:function(c,o){var l=Error();return l.name="SuppressedError",l.error=c,l.suppressed=o,l},t={},u=[];function s(c,o){if(o!=null){if(Object(o)!==o)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(c)var l=o[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(l===void 0&&(l=o[Symbol.dispose||Symbol.for("Symbol.dispose")],c))var a=l;if(typeof l!="function")throw new TypeError("Object is not disposable.");a&&(l=function f(){try{a.call(o)}catch(p){return Promise.reject(p)}}),u.push({v:o,d:l,a:c})}else c&&u.push({d:o,a:c});return o}return{e:t,u:s.bind(null,!1),a:s.bind(null,!0),d(){var c,o=this.e,l=0;function a(){for(;c=u.pop();)try{if(!c.a&&l===1)return l=0,u.push(c),Promise.resolve().then(a);if(c.d){var p=c.d.call(c.v);if(c.a)return l|=2,Promise.resolve(p).then(a,f)}else l|=1}catch(h){return f(h)}if(l===1)return o!==t?Promise.reject(o):Promise.resolve();if(o!==t)throw o}function f(p){return o=o!==t?new i(p,o):p,a()}return a()}}}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),ce=K(fe(),1),Cn=K(fe(),1);jn=K(fe(),1)});function pe(e,n){let r=n.split("/").map((t)=>t.trim()).filter((t)=>t!=="");function i(t,u,s,c){if(t===e.length&&u===r.length)return{matched:!0,params:{...s},spreads:{...c}};if(t===e.length||u>r.length)return{matched:!1};let o=e[t]??m();if(o.type==="static"){if(u>=r.length||r[u]!==o.match)return{matched:!1};return i(t+1,u+1,s,c)}else if(o.type==="slug"){if(u>=r.length)return{matched:!1};let l={...s,[o.name]:r[u]};return i(t+1,u+1,l,c)}else if(o.type==="spread"){for(let l=0;l<=r.length-u;l++){let a={...c,[o.name]:r.slice(u,u+l)},f=i(t+1,u+l,s,a);if(f.matched)return f}return{matched:!1}}return{matched:!1}}return i(0,0,{},{})}var Je=d(()=>{b();F();b()});function x(e,n){let{children:r,...i}=n||{};if(e===k)return{type:"fragment",children:$(r)};if(typeof e==="string")return z(e,i,r);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(r)}};throw new Error(`Invalid JSX type: ${e}`)}var ye;var Be=d(()=>{Z();ye=x});var Xe=d(()=>{Be()});function Tn(){return E((e)=>{return new URL(e(G)).pathname})}function Pn(){if(typeof window==="undefined")return;G.subscribe((e)=>{if(window.location.href!==e)window.history.pushState({},"",e)},{callInitially:!1}),window.addEventListener("popstate",()=>{G.set(window.location.href)}),document.addEventListener("click",(e)=>{let r=e.composedPath().find((i)=>i instanceof HTMLAnchorElement);if(r?.href){let i=new URL(r.href,C(G));if(i.origin!==window.location.origin)return;e.preventDefault(),G.set(i.href)}})}function Ln({pathname:e,props:n,loaders:r}){if("location"in globalThis)Pn();ze();let i=We(),t=e?j(e):Tn(),u=E((l)=>{let a=l(t);return n.routes.find((f)=>pe(f.matcher,a))}),s=E(async(l)=>{let a=l(u)??m(),f=[];for(let p of a.frames)f.push(await(r[p.index]??m())());return f}),c=le(E((l)=>{return i(l(s))})),o=E((l)=>{let a=x(k,{}),f=l(c);if(!f)return x("h1",{children:"loading"});for(let p of f.toReversed())a=x(p,{children:a});return a});return ye("html",{children:[ye("head",{children:[x("link",{rel:"stylesheet",href:"/styles.css"}),x("script",{src:"/entrypoint-client.js",type:"module"})]}),x("body",{children:o})]})}async function Ke({props:e,loaders:n,renderer:r,root:i,pathname:t,lifetime:u=new v,context:s}){e:if("window"in globalThis){let c=t??window.location.pathname,o=e.routes.find((l)=>pe(l.matcher,c));if(!o)break e;for(let l of o.frames)await(n[l.index]??m())()}Ue({context:s,renderer:r,root:i,component:x(Ln,{pathname:t,props:e,loaders:n})}).cascadesFrom(u)}function Ve(e){return async function(n){return await e.impl(n)}}var G;var he=d(()=>{Je();b();F();Xe();b();G=j(typeof window!=="undefined"?window.location.href:"/")});function Mn(e){return{lang:e?.lang??ve?.lang,message:e?.message,abortEarly:e?.abortEarly??ve?.abortEarly,abortPipeEarly:e?.abortPipeEarly??ve?.abortPipeEarly}}function Gn(e){return Fn?.get(e)}function Wn(e){return Un?.get(e)}function Bn(e,n){return Jn?.get(e)?.get(n)}function Xn(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function de(e,n,r,i,t){let u=t&&"input"in t?t.input:r.value,s=t?.expected??e.expects??null,c=t?.received??Xn(u),o={kind:e.kind,type:e.type,input:u,expected:s,received:c,message:`Invalid ${n}: ${s?`Expected ${s} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:t?.path,issues:t?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},l=e.kind==="schema",a=t?.message??e.message??Bn(e.reference,o.lang)??(l?Wn(o.lang):null)??i.message??Gn(o.lang);if(a!==void 0)o.message=typeof a==="function"?a(o):a;if(l)r.typed=!1;if(r.issues)r.issues.push(o);else r.issues=[o]}function Ye(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Mn())}}}function Kn(e,n,r){return typeof e.fallback==="function"?e.fallback(n,r):e.fallback}function Vn(e,n,r){return typeof e.default==="function"?e.default(n,r):e.default}function Q(e){return{kind:"schema",type:"number",reference:Q,expects:"number",async:!1,message:e,get "~standard"(){return Ye(this)},"~run"(n,r){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else de(this,"type",n,r);return n}}}function ge(e,n){return{kind:"schema",type:"object",reference:ge,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return Ye(this)},"~run"(r,i){let t=r.value;if(t&&typeof t==="object"){r.typed=!0,r.value={};for(let u in this.entries){let s=this.entries[u];if(u in t||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){let c=u in t?t[u]:Vn(s),o=s["~run"]({value:c},i);if(o.issues){let l={type:"object",origin:"value",input:t,key:u,value:c};for(let a of o.issues){if(a.path)a.path.unshift(l);else a.path=[l];r.issues?.push(a)}if(!r.issues)r.issues=o.issues;if(i.abortEarly){r.typed=!1;break}}if(!o.typed)r.typed=!1;r.value[u]=o.value}else if(s.fallback!==void 0)r.value[u]=Kn(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"){if(de(this,"key",r,i,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:t,key:u,value:t[u]}]}),i.abortEarly)break}}}else de(this,"type",r,i);return r}}}var ve,Fn,Un,Jn;var en=()=>{};function T(e,n,r,i,t,u){let{children:s,...c}=n||{};if(e===k)return{type:"fragment",children:$(s),...t};if(typeof e==="string")return z(e,c,s,t);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(s)},...t};throw new Error(`Invalid JSX type: ${e}`)}var nn=d(()=>{Z()});var be=d(()=>{nn()});var Vr,rn=function({children:e}){return T(k,{children:[T("title",{children:"Wormhole Example"},void 0,!1,void 0,this),e]},void 0,!0,void 0,this)},tn=function({page:e}){return T(k,{children:[T("h1",{children:["Documentation for ",e.join(", ")]},void 0,!0,void 0,this),T("p",{children:["This is the documentation page for ",e.join(", "),"."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},Zn=function({a:e,b:n}){return e+n},Qn;var ke=d(()=>{en();he();be();Vr=Ve({schema:Qn,impl:Zn,endpoint:"/api/add",method:"GET",isQuery:!0}),Qn=ge({a:Q(),b:Q()})});var sn={};we(sn,{$d_732_888:()=>rn});var un=d(()=>{ke()});var on={};we(on,{$d_1050_1265:()=>tn});var ln=d(()=>{ke()});he();F();b();F();b();function qn(e){return"tagName"in e?e.tagName:"Text"}function Rn(){return{html:"",write(e){this.html+=e},lastType:""}}function He(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function me(e,n=Rn()){let r=qn(e);if(r==="Text"&&n.lastType==="Text")n.write("");if(n.lastType=r,"tagName"in e){n.write("<"),n.write(e.tagName);for(let[i,t]of Object.entries(e.attributes)){if(t===void 0)continue;n.write(` ${i}="${He(t)}"`)}n.write(">");for(let i of e.children)me(i,n);n.write("")}if("content"in e)n.write(He(e.content.toString()));return n.html}function zn(e){return e.split(/(?=[A-Z])/).map((r)=>r.toLowerCase()).join("-")}function Ze(){return{createNode(e,n){return{tagName:e,attributes:{},children:[],parent:void 0}},setAttribute(e,n,r){if(!("tagName"in e))throw new Error("Cannot set attribute on a text node");e.attributes[n]=r},createTextNode(e){return{content:"",parent:void 0}},setTextContent(e,n){if(!("content"in e))throw new Error("Cannot set text content on a non-text node");e.content=n},setChildren(e,n){if(!("children"in e))throw new Error("Cannot set children on a text node");e.children=n;for(let r of n)r.parent=e},getHydrationContext(e){return},addEventListener(e,n,r){return new v},bindValue(e,n,r){return new v},setStyle(e,n,r){if(!("attributes"in e))throw new Error("Cannot set style on a text node");let i=e.attributes.style??"";i+=`${zn(n)}: ${r};`,e.attributes.style=i}}}function Qe(){return{tagName:"html",attributes:{},children:[],parent:void 0,fixedIdent:"document.documentElement"}}var Yn=JSON.parse('{"routes":[{"matcher":[{"type":"static","match":"docs"},{"type":"spread","name":"page"}],"frames":[{"index":0},{"index":1}],"is404":false}]}'),er=[async()=>(await Promise.resolve().then(() => (un(),sn))).$d_732_888,async()=>(await Promise.resolve().then(() => (ln(),on))).$d_1050_1265];async function nr(e){let r=new URL(e.url).pathname,i=Ze(),t=Qe(),u=new v;try{await Ke({props:Yn,loaders:er,renderer:i,root:t,pathname:r,context:{},lifetime:u});let s=me(t);return new Response(s,{status:200,headers:{"Content-Type":"text/html"}})}catch(s){return console.error("Rendering error:",s),new Response("Internal Server Error",{status:500})}finally{u.close()}}export{nr as default}; +`)t+="\\n";else if(u==="\t")t+="\\t";else if(u==="\r")t+="\\r";else t+=u;if(t+=i,t.length{_e();$e={};xe($e,{escapeStr:()=>ne,isAlphabetic:()=>X,isAlphanumeric:()=>Ie,isNumeric:()=>W,isWhitespace:()=>Ae,keywords:()=>I,lex:()=>Se,parse:()=>hn,parseContext_create:()=>Oe,parseContext_next:()=>yn,parseContext_peek:()=>J,parseContext_read:()=>N,parseContext_readObj:()=>B,serialize:()=>Ce,serializeContext_create:()=>Ne,serializeContext_dedent:()=>L,serializeContext_indent:()=>P,serializeContext_newline:()=>w,serializeContext_write:()=>y,serializeContext_writeObject:()=>C,stringify:()=>mn,symbols:()=>ee});I={null:"Null",true:"True",false:"False",undefined:"Undefined"},ee={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};mn=Ce});var gn,ie,bn,je,kn,wn,Te=(e,n)=>function(){return n||e[je(e)[0]]((n={exports:{}}).exports,n),n.exports},Pe=(e,n)=>{for(var r in n)ie(e,r,{get:n[r],enumerable:!0})},xn=(e,n,r,i)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var t=je(n),u=0,s=t.length,c;un[o]).bind(null,c),enumerable:!(i=bn(n,c))||i.enumerable})}return e},K=(e,n,r)=>(r=e!=null?gn(kn(e)):{},xn(n||!e||!e.__esModule?ie(r,"default",{value:e,enumerable:!0}):r,e));var Le=d(()=>{gn=Object.create,ie=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,je=Object.getOwnPropertyNames,kn=Object.getPrototypeOf,wn=Object.prototype.hasOwnProperty});function H(){if(v.hookLifetime===null)throw new Error("No hook lifetime available");return v.hookLifetime}function q(e){let n,r=e,i=[];return n&&console.log(`[${n}]: initialized with `,r),{setId(t){n=t},[_](){return r},subscribe(t,u){if(i.push(t),n&&console.trace(`[${n}]: subscribed with `,t),u?.callInitially!==!1)t(r);return new v().onClosed(()=>{i.splice(i.indexOf(t),1),n&&console.log(`[${n}]: unsubscribed `,t)})},set(t){if(n&&console.log(`[${n}]: trying to switch from `,r," -> ",t),!U(r,t)){r=t;for(let u of i)u(r);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}function D(e){return e[_]()}function ue(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=q(e((o)=>{if(!t.includes(o))t.push(o);return o[_]()}));function s(){if(i){let o=new Set(t);u.set(e((p)=>{return o.add(p),p[_]()}));let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.set(e(D))}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)});return{...u}}function oe(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=new v;e((o)=>{if(!t.includes(o))t.push(o);return o[_]()},{lifetime:u});function s(){if(i){let o=new Set(t);u.close(),u=new v().cascadesFrom(r),e((p)=>{return o.add(p),p[_]()},{lifetime:u});let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.close(),u=new v().cascadesFrom(r),e(D,{lifetime:u})}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)})}function R(e){return typeof e==="object"&&e!==null&&_ in e}function se(e){if(R(e))return e;return q(e)}function le(e,n=H()){return ue((r)=>{function i(t){if(R(t))return i(r(t));return t}return i(e)},{dynamic:!0},n)}function $(e){if(e===void 0)return[];return[e].flat().filter((n)=>n!==null&&n!==void 0).map((n)=>typeof n==="string"||typeof n==="number"||typeof n==="boolean"?V(n):R(n)?{type:"dynamic",value:E((r)=>{let i=r(n);return typeof i==="number"||typeof i==="string"||typeof i==="boolean"?V(i):i})}:n)}function V(e,n){return{type:"text",value:e,...n}}function z(e,n,r,i){let t=$(r).map((a)=>{if(typeof a==="string"||typeof a==="number"||typeof a==="boolean")return V(a);return a}),u={},s={},c={},o=[],l={};for(let[a,f]of Object.entries(n))if(f!==void 0)if(a.startsWith("bind:")){let p=a.slice(5);if(!R(f)||!("set"in f))throw new Error(`Binding value for "${p}" must be a writable store.`);s[p]=f}else if(a.startsWith("on:")){let p=a.slice(3);if(typeof f!=="function")throw new Error(`Event handler for "${p}" must be a function.`);c[p]=f}else if(a==="use"){if(typeof f!=="function"&&!Array.isArray(f))throw new Error("Use hook must be a function or an array of functions.");o.push(f)}else if(a==="style"){for(let[p,h]of Object.entries(f))if(h!==void 0)l[p]=se(h)}else u[a]=se(f);return{type:"element",name:e,attributes:u,children:t,bindings:s,eventHandlers:c,use:o,styles:l}}var _n,v,_="@vortex-get-internal",j,E,k;var Z=d(()=>{b();_n=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let r=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=r},[Symbol.dispose](){e.hookLifetime=r}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},v=class extends te({package:"@vortexjs/core",name:"Lifetime"},_n){};j=q,E=ue;k=te({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});function In(){let e=O.current;if(!e)throw new Error("No context scope found, you should have one if you're rendering a component.");return e}function ze(){return In().streaming}function Sn(){let e=O.current;if(!e)return null;return e}function On(){let e=Sn();if(!e)return null;return e.streaming}function Re({renderer:e,root:n,component:r,context:i}){try{var t=Dn.default();t.u(re("Initial page render"));let u=new Cn(e,n),s=new v,c=u.render({node:r,hydration:e.getHydrationContext(n),lt:s,context:i??O.current??new O}),o=new Ge(n,e);return o.children=[c],s}catch(u){t.e=u}finally{t.d()}}function Ue(e,n,r){if("renderer"in e)return Re(e);else return Re({renderer:e,root:n,component:r})}function We(){let e=On();return(n)=>{let r=j(void 0);async function i(){if(e)try{var t=jn.default();t.u(e.markLoading()),r.set(await n)}catch(u){t.e=u}finally{t.d()}else r.set(await n)}return i(),r}}var En,$n,An=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)$n(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=En(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},O=class e{contexts={};streaming=new An;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,r){this.contexts[n]=r}static current=null;static setCurrent(n){let r=e.current;return e.current=n,{[Symbol.dispose](){e.current=r}}}},qe="~vortex:intrinsic",Nn,M=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(r){if(r instanceof S)for(let i of r.children)n(i);else e.push(r)}for(let r of this.children)n(r);return e}},S,Me,Fe,Ge,fe,ce,Cn=class{constructor(e,n){this.renderer=e,this.root=n}render({node:e,hydration:n,lt:r,context:i}){if(e===void 0||e===null)return new S;if(Array.isArray(e))return this.render({node:{type:"fragment",children:e},hydration:n,lt:r,context:i});switch(e.type){case"fragment":{let s=new S;return s.children=e.children.map((c)=>this.render({node:c,hydration:n,lt:r,context:i})),s}case"text":return new Me(e.value.toString(),this.renderer,n,i);case"element":{let s=new Fe(e.name,this.renderer,n),c=this.renderer.getHydrationContext(s.rendererNode??m());s.children=e.children.map((l)=>this.render({node:l,hydration:c,lt:r,context:i}));for(let[l,a]of Object.entries(e.attributes))a.subscribe((f)=>{s.setAttribute(l,f)}).cascadesFrom(r);for(let[l,a]of Object.entries(e.bindings))this.renderer.bindValue(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.eventHandlers))this.renderer.addEventListener(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.styles))a.subscribe((f)=>{this.renderer.setStyle(s.rendererNode??m(),l,f)}).cascadesFrom(r);let o=[e.use].flat();for(let l of o)l(s.rendererNode??m());return s}case"component":try{var t=ce.default();t.u(v.changeHookLifetime(r)),t.u(O.setCurrent(i)),t.u(re(`Rendering ${e.impl.name}`));let s=e.impl;if(qe in s&&typeof s[qe]==="string"){let o=this.renderer.implementations?.find((l)=>l.intrinsic===s);if(o)s=o.implementation}let c=s(e.props);return this.render({node:c,hydration:n,lt:r,context:i})}catch(s){t.e=s}finally{t.d()}case"dynamic":{let s=new S;return oe((c,{lifetime:o})=>{let l=this.render({node:c(e.value),hydration:n,lt:o,context:i});s.children=[l]},void 0,r),s}case"list":{new S;let s=new Map,c=new S,o="";return oe((l)=>{let a=l(e.items),f=a.map((g,A)=>e.getKey(g,A));for(let g of s.keys())if(!f.includes(g))(s.get(g)??m()).lifetime.close(),s.delete(g);for(let g of f)if(!s.has(g))try{var p=ce.default();let A=a[f.indexOf(g)],cn=q(A),Y=new v;p.u(v.changeHookLifetime(Y));let an=this.render({node:e.renderItem(A,f.indexOf(g)),hydration:n,lt:Y,context:i});s.set(g,{node:an,item:cn,lifetime:Y})}catch(A){p.e=A}finally{p.d()}let h=f.join("|||");if(h!==o)o=h,c.children=f.map((g)=>(s.get(g)??m()).node)}),c}case"context":try{var u=ce.default();let s=i.fork();return u.u(O.setCurrent(s)),s.addContext(e.id,e.value),this.render({node:e.children,hydration:n,lt:r,context:s})}catch(s){u.e=s}finally{u.d()}default:De(e,`No rendering implementation for ${JSON.stringify(e)}`)}}},Dn,jn;var F=d(()=>{Le();Z();b();b();En=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),$n=globalThis.clearImmediate??((e)=>{clearTimeout(e)});Nn={};Pe(Nn,{FLElement:()=>Fe,FLFragment:()=>S,FLNode:()=>M,FLPortal:()=>Ge,FLText:()=>Me});S=class extends M{onChildrenChanged(){this.parent?.onChildrenChanged()}},Me=class extends M{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??m(),e)}constructor(e,n,r,i){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(r,i),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},Fe=class extends M{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??m(),e,n)}constructor(e,n,r){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,r)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??m());this.renderer.setChildren(this.rendererNode??m(),e)}},Ge=class extends M{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??m()))}},fe=Te({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function r(){var i=typeof SuppressedError=="function"?SuppressedError:function(c,o){var l=Error();return l.name="SuppressedError",l.error=c,l.suppressed=o,l},t={},u=[];function s(c,o){if(o!=null){if(Object(o)!==o)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(c)var l=o[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(l===void 0&&(l=o[Symbol.dispose||Symbol.for("Symbol.dispose")],c))var a=l;if(typeof l!="function")throw new TypeError("Object is not disposable.");a&&(l=function f(){try{a.call(o)}catch(p){return Promise.reject(p)}}),u.push({v:o,d:l,a:c})}else c&&u.push({d:o,a:c});return o}return{e:t,u:s.bind(null,!1),a:s.bind(null,!0),d(){var c,o=this.e,l=0;function a(){for(;c=u.pop();)try{if(!c.a&&l===1)return l=0,u.push(c),Promise.resolve().then(a);if(c.d){var p=c.d.call(c.v);if(c.a)return l|=2,Promise.resolve(p).then(a,f)}else l|=1}catch(h){return f(h)}if(l===1)return o!==t?Promise.reject(o):Promise.resolve();if(o!==t)throw o}function f(p){return o=o!==t?new i(p,o):p,a()}return a()}}}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),ce=K(fe(),1),Dn=K(fe(),1);jn=K(fe(),1)});function pe(e,n){let r=n.split("/").map((t)=>t.trim()).filter((t)=>t!=="");function i(t,u,s,c){if(t===e.length&&u===r.length)return{matched:!0,params:{...s},spreads:{...c}};if(t===e.length||u>r.length)return{matched:!1};let o=e[t]??m();if(o.type==="static"){if(u>=r.length||r[u]!==o.match)return{matched:!1};return i(t+1,u+1,s,c)}else if(o.type==="slug"){if(u>=r.length)return{matched:!1};let l={...s,[o.name]:r[u]};return i(t+1,u+1,l,c)}else if(o.type==="spread"){for(let l=0;l<=r.length-u;l++){let a={...c,[o.name]:r.slice(u,u+l)},f=i(t+1,u+l,s,a);if(f.matched)return f}return{matched:!1}}return{matched:!1}}return i(0,0,{},{})}var Je=d(()=>{b();F();b()});function x(e,n){let{children:r,...i}=n||{};if(e===k)return{type:"fragment",children:$(r)};if(typeof e==="string")return z(e,i,r);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(r)}};throw new Error(`Invalid JSX type: ${e}`)}var ye;var Be=d(()=>{Z();ye=x});var Xe=d(()=>{Be()});function Tn(){return E((e)=>{return new URL(e(G)).pathname})}function Pn(){if(typeof window==="undefined")return;G.subscribe((e)=>{if(window.location.href!==e)window.history.pushState({},"",e)},{callInitially:!1}),window.addEventListener("popstate",()=>{G.set(window.location.href)}),document.addEventListener("click",(e)=>{let r=e.composedPath().find((i)=>i instanceof HTMLAnchorElement);if(r?.href){let i=new URL(r.href,D(G));if(i.origin!==window.location.origin)return;e.preventDefault(),G.set(i.href)}})}function Ln({pathname:e,props:n,loaders:r}){if("location"in globalThis)Pn();ze();let i=We(),t=e?j(e):Tn(),u=E((l)=>{let a=l(t);return n.routes.find((f)=>pe(f.matcher,a))}),s=E(async(l)=>{let a=l(u)??m(),f=[];for(let p of a.frames)f.push(await(r[p.index]??m())());return f}),c=le(E((l)=>{return i(l(s))})),o=E((l)=>{let a=x(k,{}),f=l(c);if(!f)return x("h1",{children:"loading"});for(let p of f.toReversed())a=x(p,{children:a});return a});return ye("html",{children:[ye("head",{children:[x("link",{rel:"stylesheet",href:"/styles.css"}),x("script",{src:"/entrypoint-client.js",type:"module"})]}),x("body",{children:o})]})}async function Ke({props:e,loaders:n,renderer:r,root:i,pathname:t,lifetime:u=new v,context:s}){e:if("window"in globalThis){let c=t??window.location.pathname,o=e.routes.find((l)=>pe(l.matcher,c));if(!o)break e;for(let l of o.frames)await(n[l.index]??m())()}Ue({context:s,renderer:r,root:i,component:x(Ln,{pathname:t,props:e,loaders:n})}).cascadesFrom(u)}function Ve(e){return async function(n){return await e.impl(n)}}var G;var he=d(()=>{Je();b();F();Xe();b();G=j(typeof window!=="undefined"?window.location.href:"/")});function Mn(e){return{lang:e?.lang??ve?.lang,message:e?.message,abortEarly:e?.abortEarly??ve?.abortEarly,abortPipeEarly:e?.abortPipeEarly??ve?.abortPipeEarly}}function Gn(e){return Fn?.get(e)}function Wn(e){return Un?.get(e)}function Bn(e,n){return Jn?.get(e)?.get(n)}function Xn(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function de(e,n,r,i,t){let u=t&&"input"in t?t.input:r.value,s=t?.expected??e.expects??null,c=t?.received??Xn(u),o={kind:e.kind,type:e.type,input:u,expected:s,received:c,message:`Invalid ${n}: ${s?`Expected ${s} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:t?.path,issues:t?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},l=e.kind==="schema",a=t?.message??e.message??Bn(e.reference,o.lang)??(l?Wn(o.lang):null)??i.message??Gn(o.lang);if(a!==void 0)o.message=typeof a==="function"?a(o):a;if(l)r.typed=!1;if(r.issues)r.issues.push(o);else r.issues=[o]}function Ye(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Mn())}}}function Kn(e,n,r){return typeof e.fallback==="function"?e.fallback(n,r):e.fallback}function Vn(e,n,r){return typeof e.default==="function"?e.default(n,r):e.default}function Q(e){return{kind:"schema",type:"number",reference:Q,expects:"number",async:!1,message:e,get "~standard"(){return Ye(this)},"~run"(n,r){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else de(this,"type",n,r);return n}}}function ge(e,n){return{kind:"schema",type:"object",reference:ge,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return Ye(this)},"~run"(r,i){let t=r.value;if(t&&typeof t==="object"){r.typed=!0,r.value={};for(let u in this.entries){let s=this.entries[u];if(u in t||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){let c=u in t?t[u]:Vn(s),o=s["~run"]({value:c},i);if(o.issues){let l={type:"object",origin:"value",input:t,key:u,value:c};for(let a of o.issues){if(a.path)a.path.unshift(l);else a.path=[l];r.issues?.push(a)}if(!r.issues)r.issues=o.issues;if(i.abortEarly){r.typed=!1;break}}if(!o.typed)r.typed=!1;r.value[u]=o.value}else if(s.fallback!==void 0)r.value[u]=Kn(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"){if(de(this,"key",r,i,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:t,key:u,value:t[u]}]}),i.abortEarly)break}}}else de(this,"type",r,i);return r}}}var ve,Fn,Un,Jn;var en=()=>{};function T(e,n,r,i,t,u){let{children:s,...c}=n||{};if(e===k)return{type:"fragment",children:$(s),...t};if(typeof e==="string")return z(e,c,s,t);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(s)},...t};throw new Error(`Invalid JSX type: ${e}`)}var nn=d(()=>{Z()});var be=d(()=>{nn()});var Vr,rn=function({children:e}){return T(k,{children:[T("title",{children:"Wormhole Example"},void 0,!1,void 0,this),e]},void 0,!0,void 0,this)},tn=function({page:e}){return T(k,{children:[T("h1",{children:["Documentation for ",e.join(", ")]},void 0,!0,void 0,this),T("p",{children:["This is the documentation page for ",e.join(", "),"."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},Zn=function({a:e,b:n}){return e+n},Qn;var ke=d(()=>{en();he();be();Vr=Ve({schema:Qn,impl:Zn,endpoint:"/api/add",method:"GET",isQuery:!0}),Qn=ge({a:Q(),b:Q()})});var sn={};we(sn,{$d_732_888:()=>rn});var un=d(()=>{ke()});var on={};we(on,{$d_1050_1265:()=>tn});var ln=d(()=>{ke()});he();F();b();F();b();function qn(e){return"tagName"in e?e.tagName:"Text"}function Rn(){return{html:"",write(e){this.html+=e},lastType:""}}function He(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function me(e,n=Rn()){let r=qn(e);if(r==="Text"&&n.lastType==="Text")n.write("");if(n.lastType=r,"tagName"in e){n.write("<"),n.write(e.tagName);for(let[i,t]of Object.entries(e.attributes)){if(t===void 0)continue;n.write(` ${i}="${He(t)}"`)}n.write(">");for(let i of e.children)me(i,n);n.write("")}if("content"in e)n.write(He(e.content.toString()));return n.html}function zn(e){return e.split(/(?=[A-Z])/).map((r)=>r.toLowerCase()).join("-")}function Ze(){return{createNode(e,n){return{tagName:e,attributes:{},children:[],parent:void 0}},setAttribute(e,n,r){if(!("tagName"in e))throw new Error("Cannot set attribute on a text node");e.attributes[n]=r},createTextNode(e){return{content:"",parent:void 0}},setTextContent(e,n){if(!("content"in e))throw new Error("Cannot set text content on a non-text node");e.content=n},setChildren(e,n){if(!("children"in e))throw new Error("Cannot set children on a text node");e.children=n;for(let r of n)r.parent=e},getHydrationContext(e){return},addEventListener(e,n,r){return new v},bindValue(e,n,r){return new v},setStyle(e,n,r){if(!("attributes"in e))throw new Error("Cannot set style on a text node");let i=e.attributes.style??"";i+=`${zn(n)}: ${r};`,e.attributes.style=i}}}function Qe(){return{tagName:"html",attributes:{},children:[],parent:void 0,fixedIdent:"document.documentElement"}}var Yn=JSON.parse('{"routes":[{"matcher":[{"type":"static","match":"docs"},{"type":"spread","name":"page"}],"frames":[{"index":0},{"index":1}],"is404":false}]}'),er=[async()=>(await Promise.resolve().then(() => (un(),sn))).$d_732_888,async()=>(await Promise.resolve().then(() => (ln(),on))).$d_1050_1265];async function nr(e){let r=new URL(e.url).pathname,i=Ze(),t=Qe(),u=new v;try{await Ke({props:Yn,loaders:er,renderer:i,root:t,pathname:r,context:{},lifetime:u});let s=me(t);return new Response(s,{status:200,headers:{"Content-Type":"text/html"}})}catch(s){return console.error("Rendering error:",s),new Response("Internal Server Error",{status:500})}finally{u.close()}}export{nr as default}; diff --git a/packages/example-wormhole/.vercel/output/functions/route-index.func/index.js b/packages/example-wormhole/.vercel/output/functions/route-index.func/index.js index c8092a3..45a43cb 100644 --- a/packages/example-wormhole/.vercel/output/functions/route-index.func/index.js +++ b/packages/example-wormhole/.vercel/output/functions/route-index.func/index.js @@ -3,4 +3,4 @@ var on=Object.defineProperty;var ln=(e,n)=>{for(var r in n)on(e,r,{get:n[r],enum `||e==="\r"}function X(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}function W(e){return e>="0"&&e<="9"}function $e(e){return X(e)||W(e)}function*Ae(e){let n=0,r=()=>e[n]??"",i=()=>e[n++]??"",t=()=>{n++};while(n=e.tokens.length)return null;return e.tokens[e.current++]??null}function J(e){if(e.current>=e.tokens.length)return null;return e.tokens[e.current]??null}function N(e){let n=J(e);if(n!==null)e.current++;return n}function B(e){let n=N(e);if(n===null)throw new Error("Unexpected end of input");if(n[0]==="number")return n[1];if(n[0]==="string")return n[1];if(n[0]==="keyword"){if(n[1]===I.null)return null;if(n[1]===I.undefined)return;if(n[1]===I.true)return!0;if(n[1]===I.false)return!1;throw new Error(`Unexpected keyword: ${n[1]}`)}let r=null;if(n[0]==="identifier")r=n[1],n=N(e);if(n===null)throw new Error("Unexpected end of input (after reading class)");if(n[0]==="symbol"&&n[1]==="LeftParenthesis"){let i={};while(!0){let t=N(e);if(t===null)throw new Error("Unexpected end of input (when trying to read key)");if(t[0]==="symbol"&&t[1]==="RightParenthesis")break;if(t[0]!=="identifier"&&t[0]!=="string")throw new Error(`Expected identifier or string, got ${t[0]}`);let u=N(e);if(u===null||u[0]!=="symbol"||u[1]!=="Equals")throw new Error(`Expected '=', got ${u?u[0]:"end of input"}`);let s=t[1],c=B(e);i[s]=c}if(r!==null){if(r==="date")return new Date(i.unix);if(r==="set")return new Set(i.items);if(r==="map"){let t=new Map;for(let[u,s]of i.entries)t.set(u,s);return t}throw new Error(`Unknown class: ${r}`)}return i}if(n[0]==="symbol"&&n[1]==="LeftSquareBracket"){let i=[];while(!0){if(J(e)?.[0]==="symbol"&&J(e)?.[1]==="RightSquareBracket"){N(e);break}let t=B(e);i.push(t)}return i}}function fn(e){let n=[...Ae(e)],r=Ie(n),i=B(r);if(r.currentt[0]).join(", ")}`);return i}function Se(){return{output:"",indentLevel:0,minified:!1}}function P(e){e.indentLevel++}function L(e){e.indentLevel=Math.max(0,e.indentLevel-1)}function k(e){if(e.minified){y(e," ");return}y(e,` `),y(e," ".repeat(e.indentLevel))}function y(e,n){e.output+=n}function ne(e){let n=Number.POSITIVE_INFINITY,r="";for(let i of['"',"'","`"]){let t="";t+=i;for(let u of e)if(u===i)t+=`\\${u}`;else if(u==="\\")t+="\\\\";else if(u===` -`)t+="\\n";else if(u==="\t")t+="\\t";else if(u==="\r")t+="\\r";else t+=u;if(t+=i,t.length{we();_e={};ke(_e,{escapeStr:()=>ne,isAlphabetic:()=>X,isAlphanumeric:()=>$e,isNumeric:()=>W,isWhitespace:()=>Ee,keywords:()=>I,lex:()=>Ae,parse:()=>fn,parseContext_create:()=>Ie,parseContext_next:()=>an,parseContext_peek:()=>J,parseContext_read:()=>N,parseContext_readObj:()=>B,serialize:()=>Oe,serializeContext_create:()=>Se,serializeContext_dedent:()=>L,serializeContext_indent:()=>P,serializeContext_newline:()=>k,serializeContext_write:()=>y,serializeContext_writeObject:()=>D,stringify:()=>pn,symbols:()=>ee});I={null:"Null",true:"True",false:"False",undefined:"Undefined"},ee={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};pn=Oe});var mn,ie,vn,De,dn,gn,Ce=(e,n)=>function(){return n||(0,e[De(e)[0]])((n={exports:{}}).exports,n),n.exports},je=(e,n)=>{for(var r in n)ie(e,r,{get:n[r],enumerable:!0})},bn=(e,n,r,i)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var t=De(n),u=0,s=t.length,c;un[o]).bind(null,c),enumerable:!(i=vn(n,c))||i.enumerable})}return e},K=(e,n,r)=>(r=e!=null?mn(dn(e)):{},bn(n||!e||!e.__esModule?ie(r,"default",{value:e,enumerable:!0}):r,e));var Te=d(()=>{mn=Object.create,ie=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,De=Object.getOwnPropertyNames,dn=Object.getPrototypeOf,gn=Object.prototype.hasOwnProperty});function H(){if(v.hookLifetime===null)throw new Error("No hook lifetime available");return v.hookLifetime}function q(e){let n,r=e,i=[];return n&&console.log(`[${n}]: initialized with `,r),{setId(t){n=t},[_](){return r},subscribe(t,u){if(i.push(t),n&&console.trace(`[${n}]: subscribed with `,t),u?.callInitially!==!1)t(r);return new v().onClosed(()=>{i.splice(i.indexOf(t),1),n&&console.log(`[${n}]: unsubscribed `,t)})},set(t){if(n&&console.log(`[${n}]: trying to switch from `,r," -> ",t),!U(r,t)){r=t;for(let u of i)u(r);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}function C(e){return e[_]()}function ue(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=q(e((o)=>{if(!t.includes(o))t.push(o);return o[_]()}));function s(){if(i){let o=new Set(t);u.set(e((p)=>{return o.add(p),p[_]()}));let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.set(e(C))}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)});return{...u}}function oe(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=new v;e((o)=>{if(!t.includes(o))t.push(o);return o[_]()},{lifetime:u});function s(){if(i){let o=new Set(t);u.close(),u=new v().cascadesFrom(r),e((p)=>{return o.add(p),p[_]()},{lifetime:u});let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.close(),u=new v().cascadesFrom(r),e(C,{lifetime:u})}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)})}function R(e){return typeof e==="object"&&e!==null&&_ in e}function se(e){if(R(e))return e;return q(e)}function le(e,n=H()){return ue((r)=>{function i(t){if(R(t))return i(r(t));return t}return i(e)},{dynamic:!0},n)}function $(e){if(e===void 0)return[];return[e].flat().filter((n)=>n!==null&&n!==void 0).map((n)=>typeof n==="string"||typeof n==="number"||typeof n==="boolean"?V(n):R(n)?{type:"dynamic",value:E((r)=>{let i=r(n);return typeof i==="number"||typeof i==="string"||typeof i==="boolean"?V(i):i})}:n)}function V(e,n){return{type:"text",value:e,...n}}function z(e,n,r,i){let t=$(r).map((a)=>{if(typeof a==="string"||typeof a==="number"||typeof a==="boolean")return V(a);return a}),u={},s={},c={},o=[],l={};for(let[a,f]of Object.entries(n))if(f!==void 0)if(a.startsWith("bind:")){let p=a.slice(5);if(!R(f)||!("set"in f))throw new Error(`Binding value for "${p}" must be a writable store.`);s[p]=f}else if(a.startsWith("on:")){let p=a.slice(3);if(typeof f!=="function")throw new Error(`Event handler for "${p}" must be a function.`);c[p]=f}else if(a==="use"){if(typeof f!=="function"&&!Array.isArray(f))throw new Error("Use hook must be a function or an array of functions.");o.push(f)}else if(a==="style"){for(let[p,h]of Object.entries(f))if(h!==void 0)l[p]=se(h)}else u[a]=se(f);return{type:"element",name:e,attributes:u,children:t,bindings:s,eventHandlers:c,use:o,styles:l}}var kn,v,_="@vortex-get-internal",j,E,w;var Z=d(()=>{b();kn=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let r=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=r},[Symbol.dispose](){e.hookLifetime=r}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},v=class extends te({package:"@vortexjs/core",name:"Lifetime"},kn){};j=q,E=ue;w=te({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});function En(){let e=O.current;if(!e)throw new Error("No context scope found, you should have one if you're rendering a component.");return e}function qe(){return En().streaming}function $n(){let e=O.current;if(!e)return null;return e}function An(){let e=$n();if(!e)return null;return e.streaming}function Le({renderer:e,root:n,component:r,context:i}){try{var t=(0,On.default)();t.u(re("Initial page render"));let u=new Sn(e,n),s=new v,c=u.render({node:r,hydration:e.getHydrationContext(n),lt:s,context:i??O.current??new O}),o=new Me(n,e);return o.children=[c],s}catch(u){t.e=u}finally{t.d()}}function Fe(e,n,r){if("renderer"in e)return Le(e);else return Le({renderer:e,root:n,component:r})}function Ge(){let e=An();return(n)=>{let r=j(void 0);async function i(){if(e)try{var t=(0,Nn.default)();t.u(e.markLoading()),r.set(await n)}catch(u){t.e=u}finally{t.d()}else r.set(await n)}return i(),r}}var wn,xn,_n=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)xn(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=wn(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},O=class e{contexts={};streaming=new _n;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,r){this.contexts[n]=r}static current=null;static setCurrent(n){let r=e.current;return e.current=n,{[Symbol.dispose](){e.current=r}}}},Pe="~vortex:intrinsic",In,M=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(r){if(r instanceof S)for(let i of r.children)n(i);else e.push(r)}for(let r of this.children)n(r);return e}},S,Re,ze,Me,fe,ce,Sn=class{constructor(e,n){this.renderer=e,this.root=n}render({node:e,hydration:n,lt:r,context:i}){if(e===void 0||e===null)return new S;if(Array.isArray(e))return this.render({node:{type:"fragment",children:e},hydration:n,lt:r,context:i});switch(e.type){case"fragment":{let s=new S;return s.children=e.children.map((c)=>this.render({node:c,hydration:n,lt:r,context:i})),s}case"text":return new Re(e.value.toString(),this.renderer,n,i);case"element":{let s=new ze(e.name,this.renderer,n),c=this.renderer.getHydrationContext(s.rendererNode??m());s.children=e.children.map((l)=>this.render({node:l,hydration:c,lt:r,context:i}));for(let[l,a]of Object.entries(e.attributes))a.subscribe((f)=>{s.setAttribute(l,f)}).cascadesFrom(r);for(let[l,a]of Object.entries(e.bindings))this.renderer.bindValue(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.eventHandlers))this.renderer.addEventListener(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.styles))a.subscribe((f)=>{this.renderer.setStyle(s.rendererNode??m(),l,f)}).cascadesFrom(r);let o=[e.use].flat();for(let l of o)l(s.rendererNode??m());return s}case"component":try{var t=(0,ce.default)();t.u(v.changeHookLifetime(r)),t.u(O.setCurrent(i)),t.u(re(`Rendering ${e.impl.name}`));let s=e.impl;if(Pe in s&&typeof s[Pe]==="string"){let o=this.renderer.implementations?.find((l)=>l.intrinsic===s);if(o)s=o.implementation}let c=s(e.props);return this.render({node:c,hydration:n,lt:r,context:i})}catch(s){t.e=s}finally{t.d()}case"dynamic":{let s=new S;return oe((c,{lifetime:o})=>{let l=this.render({node:c(e.value),hydration:n,lt:o,context:i});s.children=[l]},void 0,r),s}case"list":{new S;let s=new Map,c=new S,o="";return oe((l)=>{let a=l(e.items),f=a.map((g,A)=>e.getKey(g,A));for(let g of s.keys())if(!f.includes(g))(s.get(g)??m()).lifetime.close(),s.delete(g);for(let g of f)if(!s.has(g))try{var p=(0,ce.default)();let A=a[f.indexOf(g)],sn=q(A),Y=new v;p.u(v.changeHookLifetime(Y));let un=this.render({node:e.renderItem(A,f.indexOf(g)),hydration:n,lt:Y,context:i});s.set(g,{node:un,item:sn,lifetime:Y})}catch(A){p.e=A}finally{p.d()}let h=f.join("|||");if(h!==o)o=h,c.children=f.map((g)=>(s.get(g)??m()).node)}),c}case"context":try{var u=(0,ce.default)();let s=i.fork();return u.u(O.setCurrent(s)),s.addContext(e.id,e.value),this.render({node:e.children,hydration:n,lt:r,context:s})}catch(s){u.e=s}finally{u.d()}default:Ne(e,`No rendering implementation for ${JSON.stringify(e)}`)}}},On,Nn;var F=d(()=>{Te();Z();b();b();wn=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),xn=globalThis.clearImmediate??((e)=>{clearTimeout(e)});In={};je(In,{FLElement:()=>ze,FLFragment:()=>S,FLNode:()=>M,FLPortal:()=>Me,FLText:()=>Re});S=class extends M{onChildrenChanged(){this.parent?.onChildrenChanged()}},Re=class extends M{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??m(),e)}constructor(e,n,r,i){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(r,i),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},ze=class extends M{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??m(),e,n)}constructor(e,n,r){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,r)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??m());this.renderer.setChildren(this.rendererNode??m(),e)}},Me=class extends M{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??m()))}},fe=Ce({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function r(){var i=typeof SuppressedError=="function"?SuppressedError:function(c,o){var l=Error();return l.name="SuppressedError",l.error=c,l.suppressed=o,l},t={},u=[];function s(c,o){if(o!=null){if(Object(o)!==o)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(c)var l=o[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(l===void 0&&(l=o[Symbol.dispose||Symbol.for("Symbol.dispose")],c))var a=l;if(typeof l!="function")throw new TypeError("Object is not disposable.");a&&(l=function f(){try{a.call(o)}catch(p){return Promise.reject(p)}}),u.push({v:o,d:l,a:c})}else c&&u.push({d:o,a:c});return o}return{e:t,u:s.bind(null,!1),a:s.bind(null,!0),d(){var c,o=this.e,l=0;function a(){for(;c=u.pop();)try{if(!c.a&&l===1)return l=0,u.push(c),Promise.resolve().then(a);if(c.d){var p=c.d.call(c.v);if(c.a)return l|=2,Promise.resolve(p).then(a,f)}else l|=1}catch(h){return f(h)}if(l===1)return o!==t?Promise.reject(o):Promise.resolve();if(o!==t)throw o}function f(p){return o=o!==t?new i(p,o):p,a()}return a()}}}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),ce=K(fe(),1),On=K(fe(),1);Nn=K(fe(),1)});function pe(e,n){let r=n.split("/").map((t)=>t.trim()).filter((t)=>t!=="");function i(t,u,s,c){if(t===e.length&&u===r.length)return{matched:!0,params:{...s},spreads:{...c}};if(t===e.length||u>r.length)return{matched:!1};let o=e[t]??m();if(o.type==="static"){if(u>=r.length||r[u]!==o.match)return{matched:!1};return i(t+1,u+1,s,c)}else if(o.type==="slug"){if(u>=r.length)return{matched:!1};let l={...s,[o.name]:r[u]};return i(t+1,u+1,l,c)}else if(o.type==="spread"){for(let l=0;l<=r.length-u;l++){let a={...c,[o.name]:r.slice(u,u+l)},f=i(t+1,u+l,s,a);if(f.matched)return f}return{matched:!1}}return{matched:!1}}return i(0,0,{},{})}var Ue=d(()=>{b();F();b()});function x(e,n){let{children:r,...i}=n||{};if(e===w)return{type:"fragment",children:$(r)};if(typeof e==="string")return z(e,i,r);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(r)}};throw new Error(`Invalid JSX type: ${e}`)}var ye;var We=d(()=>{Z();ye=x});var Je=d(()=>{We()});function Dn(){return E((e)=>{return new URL(e(G)).pathname})}function Cn(){if(typeof window==="undefined")return;G.subscribe((e)=>{if(window.location.href!==e)window.history.pushState({},"",e)},{callInitially:!1}),window.addEventListener("popstate",()=>{G.set(window.location.href)}),document.addEventListener("click",(e)=>{let r=e.composedPath().find((i)=>i instanceof HTMLAnchorElement);if(r?.href){let i=new URL(r.href,C(G));if(i.origin!==window.location.origin)return;e.preventDefault(),G.set(i.href)}})}function jn({pathname:e,props:n,loaders:r}){if("location"in globalThis)Cn();qe();let i=Ge(),t=e?j(e):Dn(),u=E((l)=>{let a=l(t);return n.routes.find((f)=>pe(f.matcher,a))}),s=E(async(l)=>{let a=l(u)??m(),f=[];for(let p of a.frames)f.push(await(r[p.index]??m())());return f}),c=le(E((l)=>{return i(l(s))})),o=E((l)=>{let a=x(w,{}),f=l(c);if(!f)return x("h1",{children:"loading"});for(let p of f.toReversed())a=x(p,{children:a});return a});return ye("html",{children:[ye("head",{children:[x("link",{rel:"stylesheet",href:"/styles.css"}),x("script",{src:"/entrypoint-client.js",type:"module"})]}),x("body",{children:o})]})}async function Be({props:e,loaders:n,renderer:r,root:i,pathname:t,lifetime:u=new v,context:s}){e:if("window"in globalThis){let c=t??window.location.pathname,o=e.routes.find((l)=>pe(l.matcher,c));if(!o)break e;for(let l of o.frames)await(n[l.index]??m())()}Fe({context:s,renderer:r,root:i,component:x(jn,{pathname:t,props:e,loaders:n})}).cascadesFrom(u)}function Xe(e){return async function(n){return await e.impl(n)}}var G;var he=d(()=>{Ue();b();F();Je();b();G=j(typeof window!=="undefined"?window.location.href:"/")});function qn(e){return{lang:e?.lang??ve?.lang,message:e?.message,abortEarly:e?.abortEarly??ve?.abortEarly,abortPipeEarly:e?.abortPipeEarly??ve?.abortPipeEarly}}function zn(e){return Rn?.get(e)}function Fn(e){return Mn?.get(e)}function Un(e,n){return Gn?.get(e)?.get(n)}function Wn(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function de(e,n,r,i,t){let u=t&&"input"in t?t.input:r.value,s=t?.expected??e.expects??null,c=t?.received??Wn(u),o={kind:e.kind,type:e.type,input:u,expected:s,received:c,message:`Invalid ${n}: ${s?`Expected ${s} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:t?.path,issues:t?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},l=e.kind==="schema",a=t?.message??e.message??Un(e.reference,o.lang)??(l?Fn(o.lang):null)??i.message??zn(o.lang);if(a!==void 0)o.message=typeof a==="function"?a(o):a;if(l)r.typed=!1;if(r.issues)r.issues.push(o);else r.issues=[o]}function Ze(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},qn())}}}function Jn(e,n,r){return typeof e.fallback==="function"?e.fallback(n,r):e.fallback}function Bn(e,n,r){return typeof e.default==="function"?e.default(n,r):e.default}function Q(e){return{kind:"schema",type:"number",reference:Q,expects:"number",async:!1,message:e,get "~standard"(){return Ze(this)},"~run"(n,r){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else de(this,"type",n,r);return n}}}function ge(e,n){return{kind:"schema",type:"object",reference:ge,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return Ze(this)},"~run"(r,i){let t=r.value;if(t&&typeof t==="object"){r.typed=!0,r.value={};for(let u in this.entries){let s=this.entries[u];if(u in t||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){let c=u in t?t[u]:Bn(s),o=s["~run"]({value:c},i);if(o.issues){let l={type:"object",origin:"value",input:t,key:u,value:c};for(let a of o.issues){if(a.path)a.path.unshift(l);else a.path=[l];r.issues?.push(a)}if(!r.issues)r.issues=o.issues;if(i.abortEarly){r.typed=!1;break}}if(!o.typed)r.typed=!1;r.value[u]=o.value}else if(s.fallback!==void 0)r.value[u]=Jn(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"){if(de(this,"key",r,i,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:t,key:u,value:t[u]}]}),i.abortEarly)break}}}else de(this,"type",r,i);return r}}}var ve,Rn,Mn,Gn;var Qe=()=>{};function T(e,n,r,i,t,u){let{children:s,...c}=n||{};if(e===w)return{type:"fragment",children:$(s),...t};if(typeof e==="string")return z(e,c,s,t);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(s)},...t};throw new Error(`Invalid JSX type: ${e}`)}var Ye=d(()=>{Z()});var be=d(()=>{Ye()});var Kn,en=function(){return T(w,{children:[T("h1",{class:"text-4xl font-bold",children:["Welcome to Wormhole, ",Object.entries(globalThis).length]},void 0,!0,void 0,this),T("p",{children:["This is an example app, go to the"," ",T("a",{href:"/docs/tada",children:"docs"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T("button",{"on:click":async()=>{console.log(await Kn({a:1,b:2}))},children:"add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},Vn=function({a:e,b:n}){return e+n},Hn;var nn=d(()=>{Qe();he();be();Kn=Xe({schema:Hn,impl:Vn,endpoint:"/api/add",method:"GET",isQuery:!0}),Hn=ge({a:Q(),b:Q()})});var rn={};ln(rn,{$d_109_720:()=>en});var tn=d(()=>{nn()});he();F();b();F();b();function Tn(e){return"tagName"in e?e.tagName:"Text"}function Pn(){return{html:"",write(e){this.html+=e},lastType:""}}function Ke(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function me(e,n=Pn()){let r=Tn(e);if(r==="Text"&&n.lastType==="Text")n.write("");if(n.lastType=r,"tagName"in e){n.write("<"),n.write(e.tagName);for(let[i,t]of Object.entries(e.attributes)){if(t===void 0)continue;n.write(` ${i}="${Ke(t)}"`)}n.write(">");for(let i of e.children)me(i,n);n.write("")}if("content"in e)n.write(Ke(e.content.toString()));return n.html}function Ln(e){return e.split(/(?=[A-Z])/).map((r)=>r.toLowerCase()).join("-")}function Ve(){return{createNode(e,n){return{tagName:e,attributes:{},children:[],parent:void 0}},setAttribute(e,n,r){if(!("tagName"in e))throw new Error("Cannot set attribute on a text node");e.attributes[n]=r},createTextNode(e){return{content:"",parent:void 0}},setTextContent(e,n){if(!("content"in e))throw new Error("Cannot set text content on a non-text node");e.content=n},setChildren(e,n){if(!("children"in e))throw new Error("Cannot set children on a text node");e.children=n;for(let r of n)r.parent=e},getHydrationContext(e){return},addEventListener(e,n,r){return new v},bindValue(e,n,r){return new v},setStyle(e,n,r){if(!("attributes"in e))throw new Error("Cannot set style on a text node");let i=e.attributes.style??"";i+=`${Ln(n)}: ${r};`,e.attributes.style=i}}}function He(){return{tagName:"html",attributes:{},children:[],parent:void 0,fixedIdent:"document.documentElement"}}var Zn=JSON.parse('{"routes":[{"matcher":[],"frames":[{"index":0}],"is404":false}]}'),Qn=[async()=>(await Promise.resolve().then(() => (tn(),rn))).$d_109_720];async function Yn(e){let r=new URL(e.url).pathname,i=Ve(),t=He(),u=new v;try{await Be({props:Zn,loaders:Qn,renderer:i,root:t,pathname:r,context:{},lifetime:u});let s=me(t);return new Response(s,{status:200,headers:{"Content-Type":"text/html"}})}catch(s){return console.error("Rendering error:",s),new Response("Internal Server Error",{status:500})}finally{u.close()}}export{Yn as default}; +`)t+="\\n";else if(u==="\t")t+="\\t";else if(u==="\r")t+="\\r";else t+=u;if(t+=i,t.length{we();_e={};ke(_e,{escapeStr:()=>ne,isAlphabetic:()=>X,isAlphanumeric:()=>$e,isNumeric:()=>W,isWhitespace:()=>Ee,keywords:()=>I,lex:()=>Ae,parse:()=>fn,parseContext_create:()=>Ie,parseContext_next:()=>an,parseContext_peek:()=>J,parseContext_read:()=>N,parseContext_readObj:()=>B,serialize:()=>Oe,serializeContext_create:()=>Se,serializeContext_dedent:()=>L,serializeContext_indent:()=>P,serializeContext_newline:()=>k,serializeContext_write:()=>y,serializeContext_writeObject:()=>C,stringify:()=>pn,symbols:()=>ee});I={null:"Null",true:"True",false:"False",undefined:"Undefined"},ee={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};pn=Oe});var mn,ie,vn,Ce,dn,gn,De=(e,n)=>function(){return n||e[Ce(e)[0]]((n={exports:{}}).exports,n),n.exports},je=(e,n)=>{for(var r in n)ie(e,r,{get:n[r],enumerable:!0})},bn=(e,n,r,i)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var t=Ce(n),u=0,s=t.length,c;un[o]).bind(null,c),enumerable:!(i=vn(n,c))||i.enumerable})}return e},K=(e,n,r)=>(r=e!=null?mn(dn(e)):{},bn(n||!e||!e.__esModule?ie(r,"default",{value:e,enumerable:!0}):r,e));var Te=d(()=>{mn=Object.create,ie=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,Ce=Object.getOwnPropertyNames,dn=Object.getPrototypeOf,gn=Object.prototype.hasOwnProperty});function H(){if(v.hookLifetime===null)throw new Error("No hook lifetime available");return v.hookLifetime}function R(e){let n,r=e,i=[];return n&&console.log(`[${n}]: initialized with `,r),{setId(t){n=t},[_](){return r},subscribe(t,u){if(i.push(t),n&&console.trace(`[${n}]: subscribed with `,t),u?.callInitially!==!1)t(r);return new v().onClosed(()=>{i.splice(i.indexOf(t),1),n&&console.log(`[${n}]: unsubscribed `,t)})},set(t){if(n&&console.log(`[${n}]: trying to switch from `,r," -> ",t),!U(r,t)){r=t;for(let u of i)u(r);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}function D(e){return e[_]()}function ue(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=R(e((o)=>{if(!t.includes(o))t.push(o);return o[_]()}));function s(){if(i){let o=new Set(t);u.set(e((p)=>{return o.add(p),p[_]()}));let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.set(e(D))}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)});return{...u}}function oe(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=new v;e((o)=>{if(!t.includes(o))t.push(o);return o[_]()},{lifetime:u});function s(){if(i){let o=new Set(t);u.close(),u=new v().cascadesFrom(r),e((p)=>{return o.add(p),p[_]()},{lifetime:u});let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.close(),u=new v().cascadesFrom(r),e(D,{lifetime:u})}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)})}function q(e){return typeof e==="object"&&e!==null&&_ in e}function se(e){if(q(e))return e;return R(e)}function le(e,n=H()){return ue((r)=>{function i(t){if(q(t))return i(r(t));return t}return i(e)},{dynamic:!0},n)}function $(e){if(e===void 0)return[];return[e].flat().filter((n)=>n!==null&&n!==void 0).map((n)=>typeof n==="string"||typeof n==="number"||typeof n==="boolean"?V(n):q(n)?{type:"dynamic",value:E((r)=>{let i=r(n);return typeof i==="number"||typeof i==="string"||typeof i==="boolean"?V(i):i})}:n)}function V(e,n){return{type:"text",value:e,...n}}function z(e,n,r,i){let t=$(r).map((a)=>{if(typeof a==="string"||typeof a==="number"||typeof a==="boolean")return V(a);return a}),u={},s={},c={},o=[],l={};for(let[a,f]of Object.entries(n))if(f!==void 0)if(a.startsWith("bind:")){let p=a.slice(5);if(!q(f)||!("set"in f))throw new Error(`Binding value for "${p}" must be a writable store.`);s[p]=f}else if(a.startsWith("on:")){let p=a.slice(3);if(typeof f!=="function")throw new Error(`Event handler for "${p}" must be a function.`);c[p]=f}else if(a==="use"){if(typeof f!=="function"&&!Array.isArray(f))throw new Error("Use hook must be a function or an array of functions.");o.push(f)}else if(a==="style"){for(let[p,h]of Object.entries(f))if(h!==void 0)l[p]=se(h)}else u[a]=se(f);return{type:"element",name:e,attributes:u,children:t,bindings:s,eventHandlers:c,use:o,styles:l}}var kn,v,_="@vortex-get-internal",j,E,w;var Z=d(()=>{b();kn=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let r=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=r},[Symbol.dispose](){e.hookLifetime=r}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},v=class extends te({package:"@vortexjs/core",name:"Lifetime"},kn){};j=R,E=ue;w=te({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});function En(){let e=O.current;if(!e)throw new Error("No context scope found, you should have one if you're rendering a component.");return e}function Re(){return En().streaming}function $n(){let e=O.current;if(!e)return null;return e}function An(){let e=$n();if(!e)return null;return e.streaming}function Le({renderer:e,root:n,component:r,context:i}){try{var t=On.default();t.u(re("Initial page render"));let u=new Sn(e,n),s=new v,c=u.render({node:r,hydration:e.getHydrationContext(n),lt:s,context:i??O.current??new O}),o=new Me(n,e);return o.children=[c],s}catch(u){t.e=u}finally{t.d()}}function Fe(e,n,r){if("renderer"in e)return Le(e);else return Le({renderer:e,root:n,component:r})}function Ge(){let e=An();return(n)=>{let r=j(void 0);async function i(){if(e)try{var t=Nn.default();t.u(e.markLoading()),r.set(await n)}catch(u){t.e=u}finally{t.d()}else r.set(await n)}return i(),r}}var wn,xn,_n=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)xn(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=wn(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},O=class e{contexts={};streaming=new _n;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,r){this.contexts[n]=r}static current=null;static setCurrent(n){let r=e.current;return e.current=n,{[Symbol.dispose](){e.current=r}}}},Pe="~vortex:intrinsic",In,M=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(r){if(r instanceof S)for(let i of r.children)n(i);else e.push(r)}for(let r of this.children)n(r);return e}},S,qe,ze,Me,fe,ce,Sn=class{constructor(e,n){this.renderer=e,this.root=n}render({node:e,hydration:n,lt:r,context:i}){if(e===void 0||e===null)return new S;if(Array.isArray(e))return this.render({node:{type:"fragment",children:e},hydration:n,lt:r,context:i});switch(e.type){case"fragment":{let s=new S;return s.children=e.children.map((c)=>this.render({node:c,hydration:n,lt:r,context:i})),s}case"text":return new qe(e.value.toString(),this.renderer,n,i);case"element":{let s=new ze(e.name,this.renderer,n),c=this.renderer.getHydrationContext(s.rendererNode??m());s.children=e.children.map((l)=>this.render({node:l,hydration:c,lt:r,context:i}));for(let[l,a]of Object.entries(e.attributes))a.subscribe((f)=>{s.setAttribute(l,f)}).cascadesFrom(r);for(let[l,a]of Object.entries(e.bindings))this.renderer.bindValue(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.eventHandlers))this.renderer.addEventListener(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.styles))a.subscribe((f)=>{this.renderer.setStyle(s.rendererNode??m(),l,f)}).cascadesFrom(r);let o=[e.use].flat();for(let l of o)l(s.rendererNode??m());return s}case"component":try{var t=ce.default();t.u(v.changeHookLifetime(r)),t.u(O.setCurrent(i)),t.u(re(`Rendering ${e.impl.name}`));let s=e.impl;if(Pe in s&&typeof s[Pe]==="string"){let o=this.renderer.implementations?.find((l)=>l.intrinsic===s);if(o)s=o.implementation}let c=s(e.props);return this.render({node:c,hydration:n,lt:r,context:i})}catch(s){t.e=s}finally{t.d()}case"dynamic":{let s=new S;return oe((c,{lifetime:o})=>{let l=this.render({node:c(e.value),hydration:n,lt:o,context:i});s.children=[l]},void 0,r),s}case"list":{new S;let s=new Map,c=new S,o="";return oe((l)=>{let a=l(e.items),f=a.map((g,A)=>e.getKey(g,A));for(let g of s.keys())if(!f.includes(g))(s.get(g)??m()).lifetime.close(),s.delete(g);for(let g of f)if(!s.has(g))try{var p=ce.default();let A=a[f.indexOf(g)],sn=R(A),Y=new v;p.u(v.changeHookLifetime(Y));let un=this.render({node:e.renderItem(A,f.indexOf(g)),hydration:n,lt:Y,context:i});s.set(g,{node:un,item:sn,lifetime:Y})}catch(A){p.e=A}finally{p.d()}let h=f.join("|||");if(h!==o)o=h,c.children=f.map((g)=>(s.get(g)??m()).node)}),c}case"context":try{var u=ce.default();let s=i.fork();return u.u(O.setCurrent(s)),s.addContext(e.id,e.value),this.render({node:e.children,hydration:n,lt:r,context:s})}catch(s){u.e=s}finally{u.d()}default:Ne(e,`No rendering implementation for ${JSON.stringify(e)}`)}}},On,Nn;var F=d(()=>{Te();Z();b();b();wn=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),xn=globalThis.clearImmediate??((e)=>{clearTimeout(e)});In={};je(In,{FLElement:()=>ze,FLFragment:()=>S,FLNode:()=>M,FLPortal:()=>Me,FLText:()=>qe});S=class extends M{onChildrenChanged(){this.parent?.onChildrenChanged()}},qe=class extends M{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??m(),e)}constructor(e,n,r,i){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(r,i),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},ze=class extends M{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??m(),e,n)}constructor(e,n,r){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,r)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??m());this.renderer.setChildren(this.rendererNode??m(),e)}},Me=class extends M{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??m()))}},fe=De({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function r(){var i=typeof SuppressedError=="function"?SuppressedError:function(c,o){var l=Error();return l.name="SuppressedError",l.error=c,l.suppressed=o,l},t={},u=[];function s(c,o){if(o!=null){if(Object(o)!==o)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(c)var l=o[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(l===void 0&&(l=o[Symbol.dispose||Symbol.for("Symbol.dispose")],c))var a=l;if(typeof l!="function")throw new TypeError("Object is not disposable.");a&&(l=function f(){try{a.call(o)}catch(p){return Promise.reject(p)}}),u.push({v:o,d:l,a:c})}else c&&u.push({d:o,a:c});return o}return{e:t,u:s.bind(null,!1),a:s.bind(null,!0),d(){var c,o=this.e,l=0;function a(){for(;c=u.pop();)try{if(!c.a&&l===1)return l=0,u.push(c),Promise.resolve().then(a);if(c.d){var p=c.d.call(c.v);if(c.a)return l|=2,Promise.resolve(p).then(a,f)}else l|=1}catch(h){return f(h)}if(l===1)return o!==t?Promise.reject(o):Promise.resolve();if(o!==t)throw o}function f(p){return o=o!==t?new i(p,o):p,a()}return a()}}}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),ce=K(fe(),1),On=K(fe(),1);Nn=K(fe(),1)});function pe(e,n){let r=n.split("/").map((t)=>t.trim()).filter((t)=>t!=="");function i(t,u,s,c){if(t===e.length&&u===r.length)return{matched:!0,params:{...s},spreads:{...c}};if(t===e.length||u>r.length)return{matched:!1};let o=e[t]??m();if(o.type==="static"){if(u>=r.length||r[u]!==o.match)return{matched:!1};return i(t+1,u+1,s,c)}else if(o.type==="slug"){if(u>=r.length)return{matched:!1};let l={...s,[o.name]:r[u]};return i(t+1,u+1,l,c)}else if(o.type==="spread"){for(let l=0;l<=r.length-u;l++){let a={...c,[o.name]:r.slice(u,u+l)},f=i(t+1,u+l,s,a);if(f.matched)return f}return{matched:!1}}return{matched:!1}}return i(0,0,{},{})}var Ue=d(()=>{b();F();b()});function x(e,n){let{children:r,...i}=n||{};if(e===w)return{type:"fragment",children:$(r)};if(typeof e==="string")return z(e,i,r);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(r)}};throw new Error(`Invalid JSX type: ${e}`)}var ye;var We=d(()=>{Z();ye=x});var Je=d(()=>{We()});function Cn(){return E((e)=>{return new URL(e(G)).pathname})}function Dn(){if(typeof window==="undefined")return;G.subscribe((e)=>{if(window.location.href!==e)window.history.pushState({},"",e)},{callInitially:!1}),window.addEventListener("popstate",()=>{G.set(window.location.href)}),document.addEventListener("click",(e)=>{let r=e.composedPath().find((i)=>i instanceof HTMLAnchorElement);if(r?.href){let i=new URL(r.href,D(G));if(i.origin!==window.location.origin)return;e.preventDefault(),G.set(i.href)}})}function jn({pathname:e,props:n,loaders:r}){if("location"in globalThis)Dn();Re();let i=Ge(),t=e?j(e):Cn(),u=E((l)=>{let a=l(t);return n.routes.find((f)=>pe(f.matcher,a))}),s=E(async(l)=>{let a=l(u)??m(),f=[];for(let p of a.frames)f.push(await(r[p.index]??m())());return f}),c=le(E((l)=>{return i(l(s))})),o=E((l)=>{let a=x(w,{}),f=l(c);if(!f)return x("h1",{children:"loading"});for(let p of f.toReversed())a=x(p,{children:a});return a});return ye("html",{children:[ye("head",{children:[x("link",{rel:"stylesheet",href:"/styles.css"}),x("script",{src:"/entrypoint-client.js",type:"module"})]}),x("body",{children:o})]})}async function Be({props:e,loaders:n,renderer:r,root:i,pathname:t,lifetime:u=new v,context:s}){e:if("window"in globalThis){let c=t??window.location.pathname,o=e.routes.find((l)=>pe(l.matcher,c));if(!o)break e;for(let l of o.frames)await(n[l.index]??m())()}Fe({context:s,renderer:r,root:i,component:x(jn,{pathname:t,props:e,loaders:n})}).cascadesFrom(u)}function Xe(e){return async function(n){return await e.impl(n)}}var G;var he=d(()=>{Ue();b();F();Je();b();G=j(typeof window!=="undefined"?window.location.href:"/")});function Rn(e){return{lang:e?.lang??ve?.lang,message:e?.message,abortEarly:e?.abortEarly??ve?.abortEarly,abortPipeEarly:e?.abortPipeEarly??ve?.abortPipeEarly}}function zn(e){return qn?.get(e)}function Fn(e){return Mn?.get(e)}function Un(e,n){return Gn?.get(e)?.get(n)}function Wn(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function de(e,n,r,i,t){let u=t&&"input"in t?t.input:r.value,s=t?.expected??e.expects??null,c=t?.received??Wn(u),o={kind:e.kind,type:e.type,input:u,expected:s,received:c,message:`Invalid ${n}: ${s?`Expected ${s} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:t?.path,issues:t?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},l=e.kind==="schema",a=t?.message??e.message??Un(e.reference,o.lang)??(l?Fn(o.lang):null)??i.message??zn(o.lang);if(a!==void 0)o.message=typeof a==="function"?a(o):a;if(l)r.typed=!1;if(r.issues)r.issues.push(o);else r.issues=[o]}function Ze(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Rn())}}}function Jn(e,n,r){return typeof e.fallback==="function"?e.fallback(n,r):e.fallback}function Bn(e,n,r){return typeof e.default==="function"?e.default(n,r):e.default}function Q(e){return{kind:"schema",type:"number",reference:Q,expects:"number",async:!1,message:e,get "~standard"(){return Ze(this)},"~run"(n,r){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else de(this,"type",n,r);return n}}}function ge(e,n){return{kind:"schema",type:"object",reference:ge,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return Ze(this)},"~run"(r,i){let t=r.value;if(t&&typeof t==="object"){r.typed=!0,r.value={};for(let u in this.entries){let s=this.entries[u];if(u in t||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){let c=u in t?t[u]:Bn(s),o=s["~run"]({value:c},i);if(o.issues){let l={type:"object",origin:"value",input:t,key:u,value:c};for(let a of o.issues){if(a.path)a.path.unshift(l);else a.path=[l];r.issues?.push(a)}if(!r.issues)r.issues=o.issues;if(i.abortEarly){r.typed=!1;break}}if(!o.typed)r.typed=!1;r.value[u]=o.value}else if(s.fallback!==void 0)r.value[u]=Jn(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"){if(de(this,"key",r,i,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:t,key:u,value:t[u]}]}),i.abortEarly)break}}}else de(this,"type",r,i);return r}}}var ve,qn,Mn,Gn;var Qe=()=>{};function T(e,n,r,i,t,u){let{children:s,...c}=n||{};if(e===w)return{type:"fragment",children:$(s),...t};if(typeof e==="string")return z(e,c,s,t);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(s)},...t};throw new Error(`Invalid JSX type: ${e}`)}var Ye=d(()=>{Z()});var be=d(()=>{Ye()});var Kn,en=function(){return T(w,{children:[T("h1",{class:"text-4xl font-bold",children:["Welcome to Wormhole, ",Object.entries(globalThis).length]},void 0,!0,void 0,this),T("p",{children:["This is an example app, go to the"," ",T("a",{href:"/docs/tada",children:"docs"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T("button",{"on:click":async()=>{console.log(await Kn({a:1,b:2}))},children:"add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},Vn=function({a:e,b:n}){return e+n},Hn;var nn=d(()=>{Qe();he();be();Kn=Xe({schema:Hn,impl:Vn,endpoint:"/api/add",method:"GET",isQuery:!0}),Hn=ge({a:Q(),b:Q()})});var rn={};ln(rn,{$d_109_720:()=>en});var tn=d(()=>{nn()});he();F();b();F();b();function Tn(e){return"tagName"in e?e.tagName:"Text"}function Pn(){return{html:"",write(e){this.html+=e},lastType:""}}function Ke(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function me(e,n=Pn()){let r=Tn(e);if(r==="Text"&&n.lastType==="Text")n.write("");if(n.lastType=r,"tagName"in e){n.write("<"),n.write(e.tagName);for(let[i,t]of Object.entries(e.attributes)){if(t===void 0)continue;n.write(` ${i}="${Ke(t)}"`)}n.write(">");for(let i of e.children)me(i,n);n.write("")}if("content"in e)n.write(Ke(e.content.toString()));return n.html}function Ln(e){return e.split(/(?=[A-Z])/).map((r)=>r.toLowerCase()).join("-")}function Ve(){return{createNode(e,n){return{tagName:e,attributes:{},children:[],parent:void 0}},setAttribute(e,n,r){if(!("tagName"in e))throw new Error("Cannot set attribute on a text node");e.attributes[n]=r},createTextNode(e){return{content:"",parent:void 0}},setTextContent(e,n){if(!("content"in e))throw new Error("Cannot set text content on a non-text node");e.content=n},setChildren(e,n){if(!("children"in e))throw new Error("Cannot set children on a text node");e.children=n;for(let r of n)r.parent=e},getHydrationContext(e){return},addEventListener(e,n,r){return new v},bindValue(e,n,r){return new v},setStyle(e,n,r){if(!("attributes"in e))throw new Error("Cannot set style on a text node");let i=e.attributes.style??"";i+=`${Ln(n)}: ${r};`,e.attributes.style=i}}}function He(){return{tagName:"html",attributes:{},children:[],parent:void 0,fixedIdent:"document.documentElement"}}var Zn=JSON.parse('{"routes":[{"matcher":[],"frames":[{"index":0}],"is404":false}]}'),Qn=[async()=>(await Promise.resolve().then(() => (tn(),rn))).$d_109_720];async function Yn(e){let r=new URL(e.url).pathname,i=Ve(),t=He(),u=new v;try{await Be({props:Zn,loaders:Qn,renderer:i,root:t,pathname:r,context:{},lifetime:u});let s=me(t);return new Response(s,{status:200,headers:{"Content-Type":"text/html"}})}catch(s){return console.error("Rendering error:",s),new Response("Internal Server Error",{status:500})}finally{u.close()}}export{Yn as default}; diff --git a/packages/example-wormhole/.vercel/output/static/client.js b/packages/example-wormhole/.vercel/output/static/client.js index dc0f6b0..5e63206 100644 --- a/packages/example-wormhole/.vercel/output/static/client.js +++ b/packages/example-wormhole/.vercel/output/static/client.js @@ -1 +1 @@ -import{e as o,f as c,g as u,h as a,i as m,m as L}from"./chunk-y10xypd8.js";function f(s){let e={htmlFor:"for",className:"class",tabIndex:"tabindex",ariaDescribedBy:"aria-describedby"};if(s in e)return e[s]??u();return s.split(/(?=[A-Z])/).map((n)=>n.toLowerCase()).join("-")}function d(){function s(e,t,n){if(!e)return null;while(e.unclaimedNodes.length>0){let i=e.unclaimedNodes.shift();if(i&&t(i)&&(!n||n(i)))return i}return null}return{createNode(e,t){let n=e.toLowerCase(),i=s(t,(r)=>r instanceof HTMLElement,(r)=>r.tagName.toLowerCase()===n)??document.createElement(n);for(let r=0;rt instanceof Text)??document.createTextNode("")},setTextContent(e,t){if(e instanceof Text)e.data=t;else if(e instanceof HTMLElement)e.textContent=t},setChildren(e,t){if(e instanceof HTMLElement)e.replaceChildren(...t)},getHydrationContext(e){return{unclaimedNodes:Array.from(e.childNodes)}},addEventListener(e,t,n){let i=new a;if(e instanceof HTMLElement){let r=(l)=>{n(l)};e.addEventListener(t,r),i.onClosed(()=>e.removeEventListener(t,r))}else console.warn(`Cannot add event listener to non-HTMLElement node: ${e}`);return i},bindValue(e,t,n){let i=new a;if(e[t]=m(n),t==="value"){let r=function(){n.set(e[t])};e.addEventListener("input",r),i.onClosed(()=>e.removeEventListener("input",r))}if(t==="checked"){let r=function(){n.set(e[t])};e.addEventListener("change",r),i.onClosed(()=>e.removeEventListener("change",r))}return i},setStyle(e,t,n){if(e instanceof HTMLElement)e.style[t]=n}}}var E=JSON.parse('{"routes":[{"matcher":[],"frames":[{"index":0}],"is404":false},{"matcher":[{"type":"static","match":"docs"},{"type":"spread","name":"page"}],"frames":[{"index":1},{"index":2}],"is404":false},{"matcher":[{"type":"spread","name":"404"}],"frames":[{"index":1},{"index":3}],"is404":true}]}');function T(s){let e=[async()=>(await import("./chunk-cyknm2v7.js")).$d_109_720,async()=>(await import("./chunk-36xsa23c.js")).$d_732_888,async()=>(await import("./chunk-jwed2480.js")).$d_1050_1265,async()=>(await import("./chunk-h4x07z29.js")).$d_902_1009],t=d(),n=document.documentElement;return L({props:E,loaders:e,renderer:t,root:n,pathname:s.pathname,context:s.context,lifetime:s.lifetime??new a})}window.wormhole={};window.wormhole.hydrate=T;document.addEventListener("DOMContentLoaded",()=>{let s=window.location.pathname;T({pathname:s,context:{},lifetime:new a})}); +import{e as o,f as l,g as u,h as a,i as m,m as L}from"./chunk-xscfbet7.js";function f(s){let e={htmlFor:"for",className:"class",tabIndex:"tabindex",ariaDescribedBy:"aria-describedby"};if(s in e)return e[s]??u();return s.split(/(?=[A-Z])/).map((n)=>n.toLowerCase()).join("-")}function d(){function s(e,t,n){if(!e)return null;while(e.unclaimedNodes.length>0){let i=e.unclaimedNodes.shift();if(i&&t(i)&&(!n||n(i)))return i}return null}return{createNode(e,t){let n=e.toLowerCase(),i=s(t,(r)=>r instanceof HTMLElement,(r)=>r.tagName.toLowerCase()===n)??document.createElement(n);for(let r=0;rt instanceof Text)??document.createTextNode("")},setTextContent(e,t){if(e instanceof Text)e.data=t;else if(e instanceof HTMLElement)e.textContent=t},setChildren(e,t){if(e instanceof HTMLElement)e.replaceChildren(...t)},getHydrationContext(e){return{unclaimedNodes:Array.from(e.childNodes)}},addEventListener(e,t,n){let i=new a;if(e instanceof HTMLElement){let r=(c)=>{n(c)};e.addEventListener(t,r),i.onClosed(()=>e.removeEventListener(t,r))}else console.warn(`Cannot add event listener to non-HTMLElement node: ${e}`);return i},bindValue(e,t,n){let i=new a;if(e[t]=m(n),t==="value"){let r=function(){n.set(e[t])};e.addEventListener("input",r),i.onClosed(()=>e.removeEventListener("input",r))}if(t==="checked"){let r=function(){n.set(e[t])};e.addEventListener("change",r),i.onClosed(()=>e.removeEventListener("change",r))}return i},setStyle(e,t,n){if(e instanceof HTMLElement)e.style[t]=n}}}var E=JSON.parse('{"routes":[{"matcher":[],"frames":[{"index":0}],"is404":false},{"matcher":[{"type":"static","match":"docs"},{"type":"spread","name":"page"}],"frames":[{"index":1},{"index":2}],"is404":false},{"matcher":[{"type":"spread","name":"404"}],"frames":[{"index":1},{"index":3}],"is404":true}]}');function T(s){let e=[async()=>(await import("./chunk-vftkak7x.js")).$d_109_720,async()=>(await import("./chunk-v4cdhs89.js")).$d_732_888,async()=>(await import("./chunk-wty2rdqp.js")).$d_1050_1265,async()=>(await import("./chunk-x84yccxc.js")).$d_902_1009],t=d(),n=document.documentElement;return L({props:E,loaders:e,renderer:t,root:n,pathname:s.pathname,context:s.context,lifetime:s.lifetime??new a})}window.wormhole={};window.wormhole.hydrate=T;document.addEventListener("DOMContentLoaded",()=>{let s=window.location.pathname;T({pathname:s,context:{},lifetime:new a})}); diff --git a/packages/example-wormhole/package.json b/packages/example-wormhole/package.json index 5932785..2e2412e 100644 --- a/packages/example-wormhole/package.json +++ b/packages/example-wormhole/package.json @@ -15,7 +15,8 @@ "valibot": "catalog:" }, "scripts": { - "dev": "wormhole dev" + "dev": "wormhole dev", + "build": "wormhole build vercel" }, "peerDependencies": { "typescript": "catalog:" From 7f69ab79919b71989853610df0beded691195709 Mon Sep 17 00:00:00 2001 From: andylovescode Date: Fri, 22 Aug 2025 11:26:17 -0700 Subject: [PATCH 09/15] Git: Remove `.vercel` files --- .../.vercel/output/config.json | 28 ------------------- .../api-api/add.func/.vc-config.json | 4 --- .../functions/api-api/add.func/index.js | 8 ------ .../functions/index.func/.vc-config.json | 4 --- .../output/functions/index.func/index.js | 8 ------ .../route-[...404].func/.vc-config.json | 4 --- .../functions/route-[...404].func/index.js | 6 ---- .../route-docs/[...page].func/.vc-config.json | 4 --- .../route-docs/[...page].func/index.js | 6 ---- .../route-index.func/.vc-config.json | 4 --- .../functions/route-index.func/index.js | 6 ---- .../.vercel/output/static/client.js | 1 - .../.vercel/output/static/styles.css | 1 - 13 files changed, 84 deletions(-) delete mode 100644 packages/example-wormhole/.vercel/output/config.json delete mode 100644 packages/example-wormhole/.vercel/output/functions/api-api/add.func/.vc-config.json delete mode 100644 packages/example-wormhole/.vercel/output/functions/api-api/add.func/index.js delete mode 100644 packages/example-wormhole/.vercel/output/functions/index.func/.vc-config.json delete mode 100644 packages/example-wormhole/.vercel/output/functions/index.func/index.js delete mode 100644 packages/example-wormhole/.vercel/output/functions/route-[...404].func/.vc-config.json delete mode 100644 packages/example-wormhole/.vercel/output/functions/route-[...404].func/index.js delete mode 100644 packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/.vc-config.json delete mode 100644 packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/index.js delete mode 100644 packages/example-wormhole/.vercel/output/functions/route-index.func/.vc-config.json delete mode 100644 packages/example-wormhole/.vercel/output/functions/route-index.func/index.js delete mode 100644 packages/example-wormhole/.vercel/output/static/client.js delete mode 100644 packages/example-wormhole/.vercel/output/static/styles.css diff --git a/packages/example-wormhole/.vercel/output/config.json b/packages/example-wormhole/.vercel/output/config.json deleted file mode 100644 index 8d02274..0000000 --- a/packages/example-wormhole/.vercel/output/config.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "version": 3, - "routes": [ - { - "src": "/api/add", - "dest": "/functions/api-api/add.func", - "methods": [ - "GET" - ] - }, - { - "src": "/", - "dest": "/functions/route-index.func" - }, - { - "src": "/docs/*", - "dest": "/functions/route-docs/[...page].func" - }, - { - "src": "/*", - "dest": "/functions/route-[...404].func" - }, - { - "src": "/(.*)", - "dest": "/functions/index.func" - } - ] -} \ No newline at end of file diff --git a/packages/example-wormhole/.vercel/output/functions/api-api/add.func/.vc-config.json b/packages/example-wormhole/.vercel/output/functions/api-api/add.func/.vc-config.json deleted file mode 100644 index bd4af02..0000000 --- a/packages/example-wormhole/.vercel/output/functions/api-api/add.func/.vc-config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "runtime": "edge", - "entrypoint": "index.js" -} \ No newline at end of file diff --git a/packages/example-wormhole/.vercel/output/functions/api-api/add.func/index.js b/packages/example-wormhole/.vercel/output/functions/api-api/add.func/index.js deleted file mode 100644 index 5b4ef7f..0000000 --- a/packages/example-wormhole/.vercel/output/functions/api-api/add.func/index.js +++ /dev/null @@ -1,8 +0,0 @@ -// @bun -var je=Object.defineProperty;var Z=(e,n)=>{for(var r in n)je(e,r,{get:n[r],enumerable:!0,configurable:!0,set:(s)=>n[r]=()=>s})};var p=(e,n)=>()=>(e&&(n=e(e=0)),n);var Ce,Q=(e,n)=>{for(var r in n)Ce(e,r,{get:n[r],enumerable:!0})};var Y=p(()=>{Ce=Object.defineProperty});function ee(e){return typeof e==="object"&&e!==null&&typeof e.then==="function"}function $(e,n){if(e===n)return!0;if(typeof e!==typeof n)return!1;if(Array.isArray(e)!==Array.isArray(n))return!1;if(ee(e)||ee(n))return!1;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let r=0;r="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}function A(e){return e>="0"&&e<="9"}function re(e){return O(e)||A(e)}function*te(e){let n=0,r=()=>e[n]??"",s=()=>e[n++]??"",t=()=>{n++};while(n=e.tokens.length)return null;return e.tokens[e.current++]??null}function I(e){if(e.current>=e.tokens.length)return null;return e.tokens[e.current]??null}function k(e){let n=I(e);if(n!==null)e.current++;return n}function S(e){let n=k(e);if(n===null)throw new Error("Unexpected end of input");if(n[0]==="number")return n[1];if(n[0]==="string")return n[1];if(n[0]==="keyword"){if(n[1]===g.null)return null;if(n[1]===g.undefined)return;if(n[1]===g.true)return!0;if(n[1]===g.false)return!1;throw new Error(`Unexpected keyword: ${n[1]}`)}let r=null;if(n[0]==="identifier")r=n[1],n=k(e);if(n===null)throw new Error("Unexpected end of input (after reading class)");if(n[0]==="symbol"&&n[1]==="LeftParenthesis"){let s={};while(!0){let t=k(e);if(t===null)throw new Error("Unexpected end of input (when trying to read key)");if(t[0]==="symbol"&&t[1]==="RightParenthesis")break;if(t[0]!=="identifier"&&t[0]!=="string")throw new Error(`Expected identifier or string, got ${t[0]}`);let i=k(e);if(i===null||i[0]!=="symbol"||i[1]!=="Equals")throw new Error(`Expected '=', got ${i?i[0]:"end of input"}`);let o=t[1],l=S(e);s[o]=l}if(r!==null){if(r==="date")return new Date(s.unix);if(r==="set")return new Set(s.items);if(r==="map"){let t=new Map;for(let[i,o]of s.entries)t.set(i,o);return t}throw new Error(`Unknown class: ${r}`)}return s}if(n[0]==="symbol"&&n[1]==="LeftSquareBracket"){let s=[];while(!0){if(I(e)?.[0]==="symbol"&&I(e)?.[1]==="RightSquareBracket"){k(e);break}let t=S(e);s.push(t)}return s}}function Ne(e){let n=[...te(e)],r=ie(n),s=S(r);if(r.currentt[0]).join(", ")}`);return s}function se(){return{output:"",indentLevel:0,minified:!1}}function w(e){e.indentLevel++}function _(e){e.indentLevel=Math.max(0,e.indentLevel-1)}function h(e){if(e.minified){a(e," ");return}a(e,` -`),a(e," ".repeat(e.indentLevel))}function a(e,n){e.output+=n}function q(e){let n=Number.POSITIVE_INFINITY,r="";for(let s of['"',"'","`"]){let t="";t+=s;for(let i of e)if(i===s)t+=`\\${i}`;else if(i==="\\")t+="\\\\";else if(i===` -`)t+="\\n";else if(i==="\t")t+="\\t";else if(i==="\r")t+="\\r";else t+=i;if(t+=s,t.length{Y();D={};Q(D,{escapeStr:()=>q,isAlphabetic:()=>O,isAlphanumeric:()=>re,isNumeric:()=>A,isWhitespace:()=>ne,keywords:()=>g,lex:()=>te,parse:()=>Ne,parseContext_create:()=>ie,parseContext_next:()=>Pe,parseContext_peek:()=>I,parseContext_read:()=>k,parseContext_readObj:()=>S,serialize:()=>ue,serializeContext_create:()=>se,serializeContext_dedent:()=>_,serializeContext_indent:()=>w,serializeContext_newline:()=>h,serializeContext_write:()=>a,serializeContext_writeObject:()=>b,stringify:()=>Te,symbols:()=>L});g={null:"Null",true:"True",false:"False",undefined:"Undefined"},L={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};Te=ue});var Re,z,ze,oe,Me,Fe,le=(e,n)=>function(){return n||e[oe(e)[0]]((n={exports:{}}).exports,n),n.exports},ce=(e,n)=>{for(var r in n)z(e,r,{get:n[r],enumerable:!0})},Ge=(e,n,r,s)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var t=oe(n),i=0,o=t.length,l;in[u]).bind(null,l),enumerable:!(s=ze(n,l))||s.enumerable})}return e},j=(e,n,r)=>(r=e!=null?Re(Me(e)):{},Ge(n||!e||!e.__esModule?z(r,"default",{value:e,enumerable:!0}):r,e));var fe=p(()=>{Re=Object.create,z=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,oe=Object.getOwnPropertyNames,Me=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty});function pe(e){let n,r=e,s=[];return n&&console.log(`[${n}]: initialized with `,r),{setId(t){n=t},[ae](){return r},subscribe(t,i){if(s.push(t),n&&console.trace(`[${n}]: subscribed with `,t),i?.callInitially!==!1)t(r);return new M().onClosed(()=>{s.splice(s.indexOf(t),1),n&&console.log(`[${n}]: unsubscribed `,t)})},set(t){if(n&&console.log(`[${n}]: trying to switch from `,r," -> ",t),!$(r,t)){r=t;for(let i of s)i(r);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}var Ue,M,ae="@vortex-get-internal",C,x;var P=p(()=>{v();Ue=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let r=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=r},[Symbol.dispose](){e.hookLifetime=r}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},M=class extends R({package:"@vortexjs/core",name:"Lifetime"},Ue){};C=pe,x=R({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});var Be,Je,Ke=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)Je(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=Be(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},Ve=class e{contexts={};streaming=new Ke;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,r){this.contexts[n]=r}static current=null;static setCurrent(n){let r=e.current;return e.current=n,{[Symbol.dispose](){e.current=r}}}},He,E=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(r){if(r instanceof de)for(let s of r.children)n(s);else e.push(r)}for(let r of this.children)n(r);return e}},de,Ze,Qe,Ye,F,Ln,qn,Rn;var G=p(()=>{fe();P();v();v();Be=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),Je=globalThis.clearImmediate??((e)=>{clearTimeout(e)}),He={};ce(He,{FLElement:()=>Qe,FLFragment:()=>de,FLNode:()=>E,FLPortal:()=>Ye,FLText:()=>Ze});de=class extends E{onChildrenChanged(){this.parent?.onChildrenChanged()}},Ze=class extends E{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??y(),e)}constructor(e,n,r,s){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(r,s),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},Qe=class extends E{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??y(),e,n)}constructor(e,n,r){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,r)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??y());this.renderer.setChildren(this.rendererNode??y(),e)}},Ye=class extends E{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??y()))}},F=le({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function r(){var s=typeof SuppressedError=="function"?SuppressedError:function(l,u){var c=Error();return c.name="SuppressedError",c.error=l,c.suppressed=u,c},t={},i=[];function o(l,u){if(u!=null){if(Object(u)!==u)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(l)var c=u[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(c===void 0&&(c=u[Symbol.dispose||Symbol.for("Symbol.dispose")],l))var f=c;if(typeof c!="function")throw new TypeError("Object is not disposable.");f&&(c=function m(){try{f.call(u)}catch(d){return Promise.reject(d)}}),i.push({v:u,d:c,a:l})}else l&&i.push({d:u,a:l});return u}return{e:t,u:o.bind(null,!1),a:o.bind(null,!0),d(){var l,u=this.e,c=0;function f(){for(;l=i.pop();)try{if(!l.a&&c===1)return c=0,i.push(l),Promise.resolve().then(f);if(l.d){var d=l.d.call(l.v);if(l.a)return c|=2,Promise.resolve(d).then(f,m)}else c|=1}catch(T){return m(T)}if(c===1)return u!==t?Promise.reject(u):Promise.resolve();if(u!==t)throw u}function m(d){return u=u!==t?new s(d,u):d,f()}return f()}}}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),Ln=j(F(),1),qn=j(F(),1),Rn=j(F(),1)});function ge(e,n){let r=n.split("/").map((t)=>t.trim()).filter((t)=>t!=="");function s(t,i,o,l){if(t===e.length&&i===r.length)return{matched:!0,params:{...o},spreads:{...l}};if(t===e.length||i>r.length)return{matched:!1};let u=e[t]??y();if(u.type==="static"){if(i>=r.length||r[i]!==u.match)return{matched:!1};return s(t+1,i+1,o,l)}else if(u.type==="slug"){if(i>=r.length)return{matched:!1};let c={...o,[u.name]:r[i]};return s(t+1,i+1,c,l)}else if(u.type==="spread"){for(let c=0;c<=r.length-i;c++){let f={...l,[u.name]:r.slice(i,i+c)},m=s(t+1,i+c,o,f);if(m.matched)return m}return{matched:!1}}return{matched:!1}}return s(0,0,{},{})}var ke=p(()=>{v();G();v()});var be=p(()=>{P()});var we=p(()=>{be()});function _e(e){return async function(n){return await e.impl(n)}}async function xe(e,n,r){let s=new URL(e.url).pathname;for(let t of n){if(!ge(t.matcher,s).matched)continue;if(t.method!==e.method)continue;let i=(r[t.schema]??y())(),o=(r[t.impl]??y())(),l=e.method==="GET"?new URL(e.url).searchParams.get("props")??"":await e.text(),u;try{u=D.parse(l)}catch{return new Response(["Your API request failed.","Why: The request body is not valid SKL"].join(` -`),{status:400,statusText:"Invalid SKL"})}let f=await(await i)["~standard"].validate(u);if("issues"in f)return new Response(["Your API request failed.","Why: The request body did not match the expected schema"].join(` -`),{status:400,statusText:"Failed to match against schema"});let m=f.value,T=await(await o)(m);return new Response(D.stringify(T))}}var yr;var U=p(()=>{ke();v();G();we();v();yr=C(typeof window!=="undefined"?window.location.href:"/")});function en(e){return{lang:e?.lang??W?.lang,message:e?.message,abortEarly:e?.abortEarly??W?.abortEarly,abortPipeEarly:e?.abortPipeEarly??W?.abortPipeEarly}}function rn(e){return nn?.get(e)}function sn(e){return tn?.get(e)}function on(e,n){return un?.get(e)?.get(n)}function ln(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function X(e,n,r,s,t){let i=t&&"input"in t?t.input:r.value,o=t?.expected??e.expects??null,l=t?.received??ln(i),u={kind:e.kind,type:e.type,input:i,expected:o,received:l,message:`Invalid ${n}: ${o?`Expected ${o} but r`:"R"}eceived ${l}`,requirement:e.requirement,path:t?.path,issues:t?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},c=e.kind==="schema",f=t?.message??e.message??on(e.reference,u.lang)??(c?sn(u.lang):null)??s.message??rn(u.lang);if(f!==void 0)u.message=typeof f==="function"?f(u):f;if(c)r.typed=!1;if(r.issues)r.issues.push(u);else r.issues=[u]}function Ee(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},en())}}}function cn(e,n,r){return typeof e.fallback==="function"?e.fallback(n,r):e.fallback}function fn(e,n,r){return typeof e.default==="function"?e.default(n,r):e.default}function N(e){return{kind:"schema",type:"number",reference:N,expects:"number",async:!1,message:e,get "~standard"(){return Ee(this)},"~run"(n,r){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else X(this,"type",n,r);return n}}}function B(e,n){return{kind:"schema",type:"object",reference:B,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return Ee(this)},"~run"(r,s){let t=r.value;if(t&&typeof t==="object"){r.typed=!0,r.value={};for(let i in this.entries){let o=this.entries[i];if(i in t||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){let l=i in t?t[i]:fn(o),u=o["~run"]({value:l},s);if(u.issues){let c={type:"object",origin:"value",input:t,key:i,value:l};for(let f of u.issues){if(f.path)f.path.unshift(c);else f.path=[c];r.issues?.push(f)}if(!r.issues)r.issues=u.issues;if(s.abortEarly){r.typed=!1;break}}if(!u.typed)r.typed=!1;r.value[i]=u.value}else if(o.fallback!==void 0)r.value[i]=cn(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"){if(X(this,"key",r,s,{input:void 0,expected:`"${i}"`,path:[{type:"object",origin:"key",input:t,key:i,value:t[i]}]}),s.abortEarly)break}}}else X(this,"type",r,s);return r}}}var W,nn,tn,un;var $e=()=>{};var Ae=p(()=>{P()});var J=p(()=>{Ae()});var wr,K=function({a:e,b:n}){return e+n},V;var H=p(()=>{$e();U();J();wr=_e({schema:V,impl:K,endpoint:"/api/add",method:"GET",isQuery:!0}),V=B({a:N(),b:N()})});var Ie={};Z(Ie,{$d_1395_1435:()=>K});var Se=p(()=>{H()});var De={};Z(De,{$d_1323_1385:()=>V});var Oe=p(()=>{H()});U();var pn=[{matcher:[{type:"static",match:"api"},{type:"static",match:"add"}],impl:0,schema:1,method:"GET"}],yn=[async()=>(await Promise.resolve().then(() => (Se(),Ie))).$d_1395_1435,async()=>(await Promise.resolve().then(() => (Oe(),De))).$d_1323_1385];async function hn(e){return await xe(e,pn,yn)||new Response("Not Found",{status:404})}export{hn as default}; diff --git a/packages/example-wormhole/.vercel/output/functions/index.func/.vc-config.json b/packages/example-wormhole/.vercel/output/functions/index.func/.vc-config.json deleted file mode 100644 index bd4af02..0000000 --- a/packages/example-wormhole/.vercel/output/functions/index.func/.vc-config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "runtime": "edge", - "entrypoint": "index.js" -} \ No newline at end of file diff --git a/packages/example-wormhole/.vercel/output/functions/index.func/index.js b/packages/example-wormhole/.vercel/output/functions/index.func/index.js deleted file mode 100644 index 15a03d4..0000000 --- a/packages/example-wormhole/.vercel/output/functions/index.func/index.js +++ /dev/null @@ -1,8 +0,0 @@ -// @bun -var En=Object.defineProperty;var D=(e,n)=>{for(var t in n)En(e,t,{get:n[t],enumerable:!0,configurable:!0,set:(i)=>n[t]=()=>i})};var v=(e,n)=>()=>(e&&(n=e(e=0)),n);var $n,$e=(e,n)=>{for(var t in n)$n(e,t,{get:n[t],enumerable:!0})};var Ae=v(()=>{$n=Object.defineProperty});function Ie(e){return typeof e==="object"&&e!==null&&typeof e.then==="function"}function J(e,n){if(e===n)return!0;if(typeof e!==typeof n)return!1;if(Array.isArray(e)!==Array.isArray(n))return!1;if(Ie(e)||Ie(n))return!1;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let t=0;t="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}function B(e){return e>="0"&&e<="9"}function Oe(e){return H(e)||B(e)}function*Ne(e){let n=0,t=()=>e[n]??"",i=()=>e[n++]??"",r=()=>{n++};while(n=e.tokens.length)return null;return e.tokens[e.current++]??null}function X(e){if(e.current>=e.tokens.length)return null;return e.tokens[e.current]??null}function j(e){let n=X(e);if(n!==null)e.current++;return n}function K(e){let n=j(e);if(n===null)throw new Error("Unexpected end of input");if(n[0]==="number")return n[1];if(n[0]==="string")return n[1];if(n[0]==="keyword"){if(n[1]===S.null)return null;if(n[1]===S.undefined)return;if(n[1]===S.true)return!0;if(n[1]===S.false)return!1;throw new Error(`Unexpected keyword: ${n[1]}`)}let t=null;if(n[0]==="identifier")t=n[1],n=j(e);if(n===null)throw new Error("Unexpected end of input (after reading class)");if(n[0]==="symbol"&&n[1]==="LeftParenthesis"){let i={};while(!0){let r=j(e);if(r===null)throw new Error("Unexpected end of input (when trying to read key)");if(r[0]==="symbol"&&r[1]==="RightParenthesis")break;if(r[0]!=="identifier"&&r[0]!=="string")throw new Error(`Expected identifier or string, got ${r[0]}`);let u=j(e);if(u===null||u[0]!=="symbol"||u[1]!=="Equals")throw new Error(`Expected '=', got ${u?u[0]:"end of input"}`);let s=r[1],l=K(e);i[s]=l}if(t!==null){if(t==="date")return new Date(i.unix);if(t==="set")return new Set(i.items);if(t==="map"){let r=new Map;for(let[u,s]of i.entries)r.set(u,s);return r}throw new Error(`Unknown class: ${t}`)}return i}if(n[0]==="symbol"&&n[1]==="LeftSquareBracket"){let i=[];while(!0){if(X(e)?.[0]==="symbol"&&X(e)?.[1]==="RightSquareBracket"){j(e);break}let r=K(e);i.push(r)}return i}}function In(e){let n=[...Ne(e)],t=Ce(n),i=K(t);if(t.currentr[0]).join(", ")}`);return i}function De(){return{output:"",indentLevel:0,minified:!1}}function q(e){e.indentLevel++}function R(e){e.indentLevel=Math.max(0,e.indentLevel-1)}function _(e){if(e.minified){h(e," ");return}h(e,` -`),h(e," ".repeat(e.indentLevel))}function h(e,n){e.output+=n}function ue(e){let n=Number.POSITIVE_INFINITY,t="";for(let i of['"',"'","`"]){let r="";r+=i;for(let u of e)if(u===i)r+=`\\${u}`;else if(u==="\\")r+="\\\\";else if(u===` -`)r+="\\n";else if(u==="\t")r+="\\t";else if(u==="\r")r+="\\r";else r+=u;if(r+=i,r.length{Ae();V={};$e(V,{escapeStr:()=>ue,isAlphabetic:()=>H,isAlphanumeric:()=>Oe,isNumeric:()=>B,isWhitespace:()=>Se,keywords:()=>S,lex:()=>Ne,parse:()=>In,parseContext_create:()=>Ce,parseContext_next:()=>An,parseContext_peek:()=>X,parseContext_read:()=>j,parseContext_readObj:()=>K,serialize:()=>je,serializeContext_create:()=>De,serializeContext_dedent:()=>R,serializeContext_indent:()=>q,serializeContext_newline:()=>_,serializeContext_write:()=>h,serializeContext_writeObject:()=>T,stringify:()=>Sn,symbols:()=>se});S={null:"Null",true:"True",false:"False",undefined:"Undefined"},se={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};Sn=je});var Cn,ce,Dn,Pe,jn,Tn,Le=(e,n)=>function(){return n||e[Pe(e)[0]]((n={exports:{}}).exports,n),n.exports},qe=(e,n)=>{for(var t in n)ce(e,t,{get:n[t],enumerable:!0})},Pn=(e,n,t,i)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var r=Pe(n),u=0,s=r.length,l;un[o]).bind(null,l),enumerable:!(i=Dn(n,l))||i.enumerable})}return e},Z=(e,n,t)=>(t=e!=null?Cn(jn(e)):{},Pn(n||!e||!e.__esModule?ce(t,"default",{value:e,enumerable:!0}):t,e));var Re=v(()=>{Cn=Object.create,ce=Object.defineProperty,Dn=Object.getOwnPropertyDescriptor,Pe=Object.getOwnPropertyNames,jn=Object.getPrototypeOf,Tn=Object.prototype.hasOwnProperty});function Y(){if(d.hookLifetime===null)throw new Error("No hook lifetime available");return d.hookLifetime}function z(e){let n,t=e,i=[];return n&&console.log(`[${n}]: initialized with `,t),{setId(r){n=r},[E](){return t},subscribe(r,u){if(i.push(r),n&&console.trace(`[${n}]: subscribed with `,r),u?.callInitially!==!1)r(t);return new d().onClosed(()=>{i.splice(i.indexOf(r),1),n&&console.log(`[${n}]: unsubscribed `,r)})},set(r){if(n&&console.log(`[${n}]: trying to switch from `,t," -> ",r),!J(t,r)){t=r;for(let u of i)u(t);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}function P(e){return e[E]()}function ae(e,n,t=Y()){let i=n?.dynamic??!1,r=[],u=z(e((o)=>{if(!r.includes(o))r.push(o);return o[E]()}));function s(){if(i){let o=new Set(r);u.set(e((p)=>{return o.add(p),p[E]()}));let c=new Set(r),f=c.difference(o);for(let p of f){let y=r.indexOf(p);if(y!==-1)r.splice(y,1),l[y]?.close(),l.splice(y,1)}let a=o.difference(c);for(let p of a){let y=p.subscribe(()=>{s()},{callInitially:!1});r.push(p),l.push(y)}}else u.set(e(P))}let l=r.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(t)});return{...u}}function pe(e,n,t=Y()){let i=n?.dynamic??!1,r=[],u=new d;e((o)=>{if(!r.includes(o))r.push(o);return o[E]()},{lifetime:u});function s(){if(i){let o=new Set(r);u.close(),u=new d().cascadesFrom(t),e((p)=>{return o.add(p),p[E]()},{lifetime:u});let c=new Set(r),f=c.difference(o);for(let p of f){let y=r.indexOf(p);if(y!==-1)r.splice(y,1),l[y]?.close(),l.splice(y,1)}let a=o.difference(c);for(let p of a){let y=p.subscribe(()=>{s()},{callInitially:!1});r.push(p),l.push(y)}}else u.close(),u=new d().cascadesFrom(t),e(P,{lifetime:u})}let l=r.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(t)})}function M(e){return typeof e==="object"&&e!==null&&E in e}function fe(e){if(M(e))return e;return z(e)}function ye(e,n=Y()){return ae((t)=>{function i(r){if(M(r))return i(t(r));return r}return i(e)},{dynamic:!0},n)}function A(e){if(e===void 0)return[];return[e].flat().filter((n)=>n!==null&&n!==void 0).map((n)=>typeof n==="string"||typeof n==="number"||typeof n==="boolean"?Q(n):M(n)?{type:"dynamic",value:$((t)=>{let i=t(n);return typeof i==="number"||typeof i==="string"||typeof i==="boolean"?Q(i):i})}:n)}function Q(e,n){return{type:"text",value:e,...n}}function F(e,n,t,i){let r=A(t).map((f)=>{if(typeof f==="string"||typeof f==="number"||typeof f==="boolean")return Q(f);return f}),u={},s={},l={},o=[],c={};for(let[f,a]of Object.entries(n))if(a!==void 0)if(f.startsWith("bind:")){let p=f.slice(5);if(!M(a)||!("set"in a))throw new Error(`Binding value for "${p}" must be a writable store.`);s[p]=a}else if(f.startsWith("on:")){let p=f.slice(3);if(typeof a!=="function")throw new Error(`Event handler for "${p}" must be a function.`);l[p]=a}else if(f==="use"){if(typeof a!=="function"&&!Array.isArray(a))throw new Error("Use hook must be a function or an array of functions.");o.push(a)}else if(f==="style"){for(let[p,y]of Object.entries(a))if(y!==void 0)c[p]=fe(y)}else u[f]=fe(a);return{type:"element",name:e,attributes:u,children:r,bindings:s,eventHandlers:l,use:o,styles:c}}var Ln,d,E="@vortex-get-internal",L,$,k;var ee=v(()=>{w();Ln=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let t=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=t},[Symbol.dispose](){e.hookLifetime=t}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},d=class extends le({package:"@vortexjs/core",name:"Lifetime"},Ln){};L=z,$=ae;k=le({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});function Mn(){let e=N.current;if(!e)throw new Error("No context scope found, you should have one if you're rendering a component.");return e}function Fe(){return Mn().streaming}function Fn(){let e=N.current;if(!e)return null;return e}function Gn(){let e=Fn();if(!e)return null;return e.streaming}function Me({renderer:e,root:n,component:t,context:i}){try{var r=Jn.default();r.u(oe("Initial page render"));let u=new Wn(e,n),s=new d,l=u.render({node:t,hydration:e.getHydrationContext(n),lt:s,context:i??N.current??new N}),o=new We(n,e);return o.children=[l],s}catch(u){r.e=u}finally{r.d()}}function Je(e,n,t){if("renderer"in e)return Me(e);else return Me({renderer:e,root:n,component:t})}function Be(){let e=Gn();return(n)=>{let t=L(void 0);async function i(){if(e)try{var r=Bn.default();r.u(e.markLoading()),t.set(await n)}catch(u){r.e=u}finally{r.d()}else t.set(await n)}return i(),t}}var qn,Rn,zn=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)Rn(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=qn(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},N=class e{contexts={};streaming=new zn;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,t){this.contexts[n]=t}static current=null;static setCurrent(n){let t=e.current;return e.current=n,{[Symbol.dispose](){e.current=t}}}},ze="~vortex:intrinsic",Un,G=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(t){if(t instanceof O)for(let i of t.children)n(i);else e.push(t)}for(let t of this.children)n(t);return e}},O,Ge,Ue,We,ve,he,Wn=class{constructor(e,n){this.renderer=e,this.root=n}render({node:e,hydration:n,lt:t,context:i}){if(e===void 0||e===null)return new O;if(Array.isArray(e))return this.render({node:{type:"fragment",children:e},hydration:n,lt:t,context:i});switch(e.type){case"fragment":{let s=new O;return s.children=e.children.map((l)=>this.render({node:l,hydration:n,lt:t,context:i})),s}case"text":return new Ge(e.value.toString(),this.renderer,n,i);case"element":{let s=new Ue(e.name,this.renderer,n),l=this.renderer.getHydrationContext(s.rendererNode??m());s.children=e.children.map((c)=>this.render({node:c,hydration:l,lt:t,context:i}));for(let[c,f]of Object.entries(e.attributes))f.subscribe((a)=>{s.setAttribute(c,a)}).cascadesFrom(t);for(let[c,f]of Object.entries(e.bindings))this.renderer.bindValue(s.rendererNode??m(),c,f).cascadesFrom(t);for(let[c,f]of Object.entries(e.eventHandlers))this.renderer.addEventListener(s.rendererNode??m(),c,f).cascadesFrom(t);for(let[c,f]of Object.entries(e.styles))f.subscribe((a)=>{this.renderer.setStyle(s.rendererNode??m(),c,a)}).cascadesFrom(t);let o=[e.use].flat();for(let c of o)c(s.rendererNode??m());return s}case"component":try{var r=he.default();r.u(d.changeHookLifetime(t)),r.u(N.setCurrent(i)),r.u(oe(`Rendering ${e.impl.name}`));let s=e.impl;if(ze in s&&typeof s[ze]==="string"){let o=this.renderer.implementations?.find((c)=>c.intrinsic===s);if(o)s=o.implementation}let l=s(e.props);return this.render({node:l,hydration:n,lt:t,context:i})}catch(s){r.e=s}finally{r.d()}case"dynamic":{let s=new O;return pe((l,{lifetime:o})=>{let c=this.render({node:l(e.value),hydration:n,lt:o,context:i});s.children=[c]},void 0,t),s}case"list":{new O;let s=new Map,l=new O,o="";return pe((c)=>{let f=c(e.items),a=f.map((b,I)=>e.getKey(b,I));for(let b of s.keys())if(!a.includes(b))(s.get(b)??m()).lifetime.close(),s.delete(b);for(let b of a)if(!s.has(b))try{var p=he.default();let I=f[a.indexOf(b)],_n=z(I),ie=new d;p.u(d.changeHookLifetime(ie));let xn=this.render({node:e.renderItem(I,a.indexOf(b)),hydration:n,lt:ie,context:i});s.set(b,{node:xn,item:_n,lifetime:ie})}catch(I){p.e=I}finally{p.d()}let y=a.join("|||");if(y!==o)o=y,l.children=a.map((b)=>(s.get(b)??m()).node)}),l}case"context":try{var u=he.default();let s=i.fork();return u.u(N.setCurrent(s)),s.addContext(e.id,e.value),this.render({node:e.children,hydration:n,lt:t,context:s})}catch(s){u.e=s}finally{u.d()}default:Te(e,`No rendering implementation for ${JSON.stringify(e)}`)}}},Jn,Bn;var U=v(()=>{Re();ee();w();w();qn=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),Rn=globalThis.clearImmediate??((e)=>{clearTimeout(e)});Un={};qe(Un,{FLElement:()=>Ue,FLFragment:()=>O,FLNode:()=>G,FLPortal:()=>We,FLText:()=>Ge});O=class extends G{onChildrenChanged(){this.parent?.onChildrenChanged()}},Ge=class extends G{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??m(),e)}constructor(e,n,t,i){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(t,i),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},Ue=class extends G{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??m(),e,n)}constructor(e,n,t){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,t)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??m());this.renderer.setChildren(this.rendererNode??m(),e)}},We=class extends G{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??m()))}},ve=Le({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function t(){var i=typeof SuppressedError=="function"?SuppressedError:function(l,o){var c=Error();return c.name="SuppressedError",c.error=l,c.suppressed=o,c},r={},u=[];function s(l,o){if(o!=null){if(Object(o)!==o)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(l)var c=o[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(c===void 0&&(c=o[Symbol.dispose||Symbol.for("Symbol.dispose")],l))var f=c;if(typeof c!="function")throw new TypeError("Object is not disposable.");f&&(c=function a(){try{f.call(o)}catch(p){return Promise.reject(p)}}),u.push({v:o,d:c,a:l})}else l&&u.push({d:o,a:l});return o}return{e:r,u:s.bind(null,!1),a:s.bind(null,!0),d(){var l,o=this.e,c=0;function f(){for(;l=u.pop();)try{if(!l.a&&c===1)return c=0,u.push(l),Promise.resolve().then(f);if(l.d){var p=l.d.call(l.v);if(l.a)return c|=2,Promise.resolve(p).then(f,a)}else c|=1}catch(y){return a(y)}if(c===1)return o!==r?Promise.reject(o):Promise.resolve();if(o!==r)throw o}function a(p){return o=o!==r?new i(p,o):p,f()}return f()}}}n.exports=t,n.exports.__esModule=!0,n.exports.default=n.exports}}),he=Z(ve(),1),Jn=Z(ve(),1);Bn=Z(ve(),1)});function ne(e,n){let t=n.split("/").map((r)=>r.trim()).filter((r)=>r!=="");function i(r,u,s,l){if(r===e.length&&u===t.length)return{matched:!0,params:{...s},spreads:{...l}};if(r===e.length||u>t.length)return{matched:!1};let o=e[r]??m();if(o.type==="static"){if(u>=t.length||t[u]!==o.match)return{matched:!1};return i(r+1,u+1,s,l)}else if(o.type==="slug"){if(u>=t.length)return{matched:!1};let c={...s,[o.name]:t[u]};return i(r+1,u+1,c,l)}else if(o.type==="spread"){for(let c=0;c<=t.length-u;c++){let f={...l,[o.name]:t.slice(u,u+c)},a=i(r+1,u+c,s,f);if(a.matched)return a}return{matched:!1}}return{matched:!1}}return i(0,0,{},{})}var Xe=v(()=>{w();U();w()});function x(e,n){let{children:t,...i}=n||{};if(e===k)return{type:"fragment",children:A(t)};if(typeof e==="string")return F(e,i,t);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:A(t)}};throw new Error(`Invalid JSX type: ${e}`)}var de;var Ke=v(()=>{ee();de=x});var Ve=v(()=>{Ke()});function Xn(){return $((e)=>{return new URL(e(W)).pathname})}function Kn(){if(typeof window==="undefined")return;W.subscribe((e)=>{if(window.location.href!==e)window.history.pushState({},"",e)},{callInitially:!1}),window.addEventListener("popstate",()=>{W.set(window.location.href)}),document.addEventListener("click",(e)=>{let t=e.composedPath().find((i)=>i instanceof HTMLAnchorElement);if(t?.href){let i=new URL(t.href,P(W));if(i.origin!==window.location.origin)return;e.preventDefault(),W.set(i.href)}})}function Vn({pathname:e,props:n,loaders:t}){if("location"in globalThis)Kn();Fe();let i=Be(),r=e?L(e):Xn(),u=$((c)=>{let f=c(r);return n.routes.find((a)=>ne(a.matcher,f))}),s=$(async(c)=>{let f=c(u)??m(),a=[];for(let p of f.frames)a.push(await(t[p.index]??m())());return a}),l=ye($((c)=>{return i(c(s))})),o=$((c)=>{let f=x(k,{}),a=c(l);if(!a)return x("h1",{children:"loading"});for(let p of a.toReversed())f=x(p,{children:f});return f});return de("html",{children:[de("head",{children:[x("link",{rel:"stylesheet",href:"/styles.css"}),x("script",{src:"/entrypoint-client.js",type:"module"})]}),x("body",{children:o})]})}async function He({props:e,loaders:n,renderer:t,root:i,pathname:r,lifetime:u=new d,context:s}){e:if("window"in globalThis){let l=r??window.location.pathname,o=e.routes.find((c)=>ne(c.matcher,l));if(!o)break e;for(let c of o.frames)await(n[c.index]??m())()}Je({context:s,renderer:t,root:i,component:x(Vn,{pathname:r,props:e,loaders:n})}).cascadesFrom(u)}function Ze(e){return async function(n){return await e.impl(n)}}async function Qe(e,n,t){let i=new URL(e.url).pathname;for(let r of n){if(!ne(r.matcher,i).matched)continue;if(r.method!==e.method)continue;let u=(t[r.schema]??m())(),s=(t[r.impl]??m())(),l=e.method==="GET"?new URL(e.url).searchParams.get("props")??"":await e.text(),o;try{o=V.parse(l)}catch{return new Response(["Your API request failed.","Why: The request body is not valid SKL"].join(` -`),{status:400,statusText:"Invalid SKL"})}let f=await(await u)["~standard"].validate(o);if("issues"in f)return new Response(["Your API request failed.","Why: The request body did not match the expected schema"].join(` -`),{status:400,statusText:"Failed to match against schema"});let a=f.value,y=await(await s)(a);return new Response(V.stringify(y))}}var W;var te=v(()=>{Xe();w();U();Ve();w();W=L(typeof window!=="undefined"?window.location.href:"/")});function Yn(e){return{lang:e?.lang??be?.lang,message:e?.message,abortEarly:e?.abortEarly??be?.abortEarly,abortPipeEarly:e?.abortPipeEarly??be?.abortPipeEarly}}function nt(e){return et?.get(e)}function rt(e){return tt?.get(e)}function st(e,n){return it?.get(e)?.get(n)}function ut(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function ke(e,n,t,i,r){let u=r&&"input"in r?r.input:t.value,s=r?.expected??e.expects??null,l=r?.received??ut(u),o={kind:e.kind,type:e.type,input:u,expected:s,received:l,message:`Invalid ${n}: ${s?`Expected ${s} but r`:"R"}eceived ${l}`,requirement:e.requirement,path:r?.path,issues:r?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},c=e.kind==="schema",f=r?.message??e.message??st(e.reference,o.lang)??(c?rt(o.lang):null)??i.message??nt(o.lang);if(f!==void 0)o.message=typeof f==="function"?f(o):f;if(c)t.typed=!1;if(t.issues)t.issues.push(o);else t.issues=[o]}function tn(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Yn())}}}function ot(e,n,t){return typeof e.fallback==="function"?e.fallback(n,t):e.fallback}function lt(e,n,t){return typeof e.default==="function"?e.default(n,t):e.default}function re(e){return{kind:"schema",type:"number",reference:re,expects:"number",async:!1,message:e,get "~standard"(){return tn(this)},"~run"(n,t){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else ke(this,"type",n,t);return n}}}function we(e,n){return{kind:"schema",type:"object",reference:we,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return tn(this)},"~run"(t,i){let r=t.value;if(r&&typeof r==="object"){t.typed=!0,t.value={};for(let u in this.entries){let s=this.entries[u];if(u in r||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){let l=u in r?r[u]:lt(s),o=s["~run"]({value:l},i);if(o.issues){let c={type:"object",origin:"value",input:r,key:u,value:l};for(let f of o.issues){if(f.path)f.path.unshift(c);else f.path=[c];t.issues?.push(f)}if(!t.issues)t.issues=o.issues;if(i.abortEarly){t.typed=!1;break}}if(!o.typed)t.typed=!1;t.value[u]=o.value}else if(s.fallback!==void 0)t.value[u]=ot(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"){if(ke(this,"key",t,i,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:r,key:u,value:r[u]}]}),i.abortEarly)break}}}else ke(this,"type",t,i);return t}}}var be,et,tt,it;var rn=()=>{};function g(e,n,t,i,r,u){let{children:s,...l}=n||{};if(e===k)return{type:"fragment",children:A(s),...r};if(typeof e==="string")return F(e,l,s,r);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:A(s)},...r};throw new Error(`Invalid JSX type: ${e}`)}var sn=v(()=>{ee()});var _e=v(()=>{sn()});var ft,un=function(){return g(k,{children:[g("h1",{class:"text-4xl font-bold",children:["Welcome to Wormhole, ",Object.entries(globalThis).length]},void 0,!0,void 0,this),g("p",{children:["This is an example app, go to the"," ",g("a",{href:"/docs/tada",children:"docs"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),g("button",{"on:click":async()=>{console.log(await ft({a:1,b:2}))},children:"add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},on=function({children:e}){return g(k,{children:[g("title",{children:"Wormhole Example"},void 0,!1,void 0,this),e]},void 0,!0,void 0,this)},ln=function(){return g(k,{children:g("h1",{children:"404 not found"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},cn=function({page:e}){return g(k,{children:[g("h1",{children:["Documentation for ",e.join(", ")]},void 0,!0,void 0,this),g("p",{children:["This is the documentation page for ",e.join(", "),"."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},xe=function({a:e,b:n}){return e+n},Ee;var C=v(()=>{rn();te();_e();ft=Ze({schema:Ee,impl:xe,endpoint:"/api/add",method:"GET",isQuery:!0}),Ee=we({a:re(),b:re()})});var fn={};D(fn,{$d_109_720:()=>un});var an=v(()=>{C()});var pn={};D(pn,{$d_732_888:()=>on});var yn=v(()=>{C()});var hn={};D(hn,{$d_1050_1265:()=>cn});var mn=v(()=>{C()});var vn={};D(vn,{$d_902_1009:()=>ln});var dn=v(()=>{C()});var gn={};D(gn,{$d_1395_1435:()=>xe});var bn=v(()=>{C()});var kn={};D(kn,{$d_1323_1385:()=>Ee});var wn=v(()=>{C()});te();U();w();U();w();function Hn(e){return"tagName"in e?e.tagName:"Text"}function Zn(){return{html:"",write(e){this.html+=e},lastType:""}}function Ye(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function ge(e,n=Zn()){let t=Hn(e);if(t==="Text"&&n.lastType==="Text")n.write("");if(n.lastType=t,"tagName"in e){n.write("<"),n.write(e.tagName);for(let[i,r]of Object.entries(e.attributes)){if(r===void 0)continue;n.write(` ${i}="${Ye(r)}"`)}n.write(">");for(let i of e.children)ge(i,n);n.write("")}if("content"in e)n.write(Ye(e.content.toString()));return n.html}function Qn(e){return e.split(/(?=[A-Z])/).map((t)=>t.toLowerCase()).join("-")}function en(){return{createNode(e,n){return{tagName:e,attributes:{},children:[],parent:void 0}},setAttribute(e,n,t){if(!("tagName"in e))throw new Error("Cannot set attribute on a text node");e.attributes[n]=t},createTextNode(e){return{content:"",parent:void 0}},setTextContent(e,n){if(!("content"in e))throw new Error("Cannot set text content on a non-text node");e.content=n},setChildren(e,n){if(!("children"in e))throw new Error("Cannot set children on a text node");e.children=n;for(let t of n)t.parent=e},getHydrationContext(e){return},addEventListener(e,n,t){return new d},bindValue(e,n,t){return new d},setStyle(e,n,t){if(!("attributes"in e))throw new Error("Cannot set style on a text node");let i=e.attributes.style??"";i+=`${Qn(n)}: ${t};`,e.attributes.style=i}}}function nn(){return{tagName:"html",attributes:{},children:[],parent:void 0,fixedIdent:"document.documentElement"}}te();var at=JSON.parse('{"routes":[{"matcher":[],"frames":[{"index":0}],"is404":false},{"matcher":[{"type":"static","match":"docs"},{"type":"spread","name":"page"}],"frames":[{"index":1},{"index":2}],"is404":false},{"matcher":[{"type":"spread","name":"404"}],"frames":[{"index":1},{"index":3}],"is404":true}]}'),pt=[async()=>(await Promise.resolve().then(() => (an(),fn))).$d_109_720,async()=>(await Promise.resolve().then(() => (yn(),pn))).$d_732_888,async()=>(await Promise.resolve().then(() => (mn(),hn))).$d_1050_1265,async()=>(await Promise.resolve().then(() => (dn(),vn))).$d_902_1009],yt=[{matcher:[{type:"static",match:"api"},{type:"static",match:"add"}],impl:0,schema:1,method:"GET"}],ht=[async()=>(await Promise.resolve().then(() => (bn(),gn))).$d_1395_1435,async()=>(await Promise.resolve().then(() => (wn(),kn))).$d_1323_1385];async function mt(e){let t=new URL(e.url).pathname,i=await Qe(e,yt,ht);if(i)return i;let r=en(),u=nn(),s=new d;try{await He({props:at,loaders:pt,renderer:r,root:u,pathname:t,context:{},lifetime:s});let l=ge(u);return new Response(l,{status:200,headers:{"Content-Type":"text/html"}})}catch(l){return console.error("Rendering error:",l),new Response("Internal Server Error",{status:500})}finally{s.close()}}export{mt as default}; diff --git a/packages/example-wormhole/.vercel/output/functions/route-[...404].func/.vc-config.json b/packages/example-wormhole/.vercel/output/functions/route-[...404].func/.vc-config.json deleted file mode 100644 index bd4af02..0000000 --- a/packages/example-wormhole/.vercel/output/functions/route-[...404].func/.vc-config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "runtime": "edge", - "entrypoint": "index.js" -} \ No newline at end of file diff --git a/packages/example-wormhole/.vercel/output/functions/route-[...404].func/index.js b/packages/example-wormhole/.vercel/output/functions/route-[...404].func/index.js deleted file mode 100644 index b7f815f..0000000 --- a/packages/example-wormhole/.vercel/output/functions/route-[...404].func/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// @bun -var fn=Object.defineProperty;var we=(e,n)=>{for(var r in n)fn(e,r,{get:n[r],enumerable:!0,configurable:!0,set:(i)=>n[r]=()=>i})};var d=(e,n)=>()=>(e&&(n=e(e=0)),n);var pn,xe=(e,n)=>{for(var r in n)pn(e,r,{get:n[r],enumerable:!0})};var _e=d(()=>{pn=Object.defineProperty});function Ee(e){return typeof e==="object"&&e!==null&&typeof e.then==="function"}function U(e,n){if(e===n)return!0;if(typeof e!==typeof n)return!1;if(Array.isArray(e)!==Array.isArray(n))return!1;if(Ee(e)||Ee(n))return!1;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let r=0;r="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}function W(e){return e>="0"&&e<="9"}function Ie(e){return X(e)||W(e)}function*Se(e){let n=0,r=()=>e[n]??"",i=()=>e[n++]??"",t=()=>{n++};while(n=e.tokens.length)return null;return e.tokens[e.current++]??null}function J(e){if(e.current>=e.tokens.length)return null;return e.tokens[e.current]??null}function N(e){let n=J(e);if(n!==null)e.current++;return n}function B(e){let n=N(e);if(n===null)throw new Error("Unexpected end of input");if(n[0]==="number")return n[1];if(n[0]==="string")return n[1];if(n[0]==="keyword"){if(n[1]===I.null)return null;if(n[1]===I.undefined)return;if(n[1]===I.true)return!0;if(n[1]===I.false)return!1;throw new Error(`Unexpected keyword: ${n[1]}`)}let r=null;if(n[0]==="identifier")r=n[1],n=N(e);if(n===null)throw new Error("Unexpected end of input (after reading class)");if(n[0]==="symbol"&&n[1]==="LeftParenthesis"){let i={};while(!0){let t=N(e);if(t===null)throw new Error("Unexpected end of input (when trying to read key)");if(t[0]==="symbol"&&t[1]==="RightParenthesis")break;if(t[0]!=="identifier"&&t[0]!=="string")throw new Error(`Expected identifier or string, got ${t[0]}`);let u=N(e);if(u===null||u[0]!=="symbol"||u[1]!=="Equals")throw new Error(`Expected '=', got ${u?u[0]:"end of input"}`);let s=t[1],c=B(e);i[s]=c}if(r!==null){if(r==="date")return new Date(i.unix);if(r==="set")return new Set(i.items);if(r==="map"){let t=new Map;for(let[u,s]of i.entries)t.set(u,s);return t}throw new Error(`Unknown class: ${r}`)}return i}if(n[0]==="symbol"&&n[1]==="LeftSquareBracket"){let i=[];while(!0){if(J(e)?.[0]==="symbol"&&J(e)?.[1]==="RightSquareBracket"){N(e);break}let t=B(e);i.push(t)}return i}}function hn(e){let n=[...Se(e)],r=Oe(n),i=B(r);if(r.currentt[0]).join(", ")}`);return i}function Ne(){return{output:"",indentLevel:0,minified:!1}}function T(e){e.indentLevel++}function P(e){e.indentLevel=Math.max(0,e.indentLevel-1)}function w(e){if(e.minified){y(e," ");return}y(e,` -`),y(e," ".repeat(e.indentLevel))}function y(e,n){e.output+=n}function ne(e){let n=Number.POSITIVE_INFINITY,r="";for(let i of['"',"'","`"]){let t="";t+=i;for(let u of e)if(u===i)t+=`\\${u}`;else if(u==="\\")t+="\\\\";else if(u===` -`)t+="\\n";else if(u==="\t")t+="\\t";else if(u==="\r")t+="\\r";else t+=u;if(t+=i,t.length{_e();$e={};xe($e,{escapeStr:()=>ne,isAlphabetic:()=>X,isAlphanumeric:()=>Ie,isNumeric:()=>W,isWhitespace:()=>Ae,keywords:()=>I,lex:()=>Se,parse:()=>hn,parseContext_create:()=>Oe,parseContext_next:()=>yn,parseContext_peek:()=>J,parseContext_read:()=>N,parseContext_readObj:()=>B,serialize:()=>Ce,serializeContext_create:()=>Ne,serializeContext_dedent:()=>P,serializeContext_indent:()=>T,serializeContext_newline:()=>w,serializeContext_write:()=>y,serializeContext_writeObject:()=>C,stringify:()=>mn,symbols:()=>ee});I={null:"Null",true:"True",false:"False",undefined:"Undefined"},ee={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};mn=Ce});var gn,ie,bn,je,kn,wn,Te=(e,n)=>function(){return n||e[je(e)[0]]((n={exports:{}}).exports,n),n.exports},Pe=(e,n)=>{for(var r in n)ie(e,r,{get:n[r],enumerable:!0})},xn=(e,n,r,i)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var t=je(n),u=0,s=t.length,c;un[o]).bind(null,c),enumerable:!(i=bn(n,c))||i.enumerable})}return e},K=(e,n,r)=>(r=e!=null?gn(kn(e)):{},xn(n||!e||!e.__esModule?ie(r,"default",{value:e,enumerable:!0}):r,e));var Le=d(()=>{gn=Object.create,ie=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,je=Object.getOwnPropertyNames,kn=Object.getPrototypeOf,wn=Object.prototype.hasOwnProperty});function H(){if(v.hookLifetime===null)throw new Error("No hook lifetime available");return v.hookLifetime}function L(e){let n,r=e,i=[];return n&&console.log(`[${n}]: initialized with `,r),{setId(t){n=t},[_](){return r},subscribe(t,u){if(i.push(t),n&&console.trace(`[${n}]: subscribed with `,t),u?.callInitially!==!1)t(r);return new v().onClosed(()=>{i.splice(i.indexOf(t),1),n&&console.log(`[${n}]: unsubscribed `,t)})},set(t){if(n&&console.log(`[${n}]: trying to switch from `,r," -> ",t),!U(r,t)){r=t;for(let u of i)u(r);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}function D(e){return e[_]()}function ue(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=L(e((o)=>{if(!t.includes(o))t.push(o);return o[_]()}));function s(){if(i){let o=new Set(t);u.set(e((p)=>{return o.add(p),p[_]()}));let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.set(e(D))}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)});return{...u}}function oe(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=new v;e((o)=>{if(!t.includes(o))t.push(o);return o[_]()},{lifetime:u});function s(){if(i){let o=new Set(t);u.close(),u=new v().cascadesFrom(r),e((p)=>{return o.add(p),p[_]()},{lifetime:u});let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.close(),u=new v().cascadesFrom(r),e(D,{lifetime:u})}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)})}function R(e){return typeof e==="object"&&e!==null&&_ in e}function se(e){if(R(e))return e;return L(e)}function le(e,n=H()){return ue((r)=>{function i(t){if(R(t))return i(r(t));return t}return i(e)},{dynamic:!0},n)}function $(e){if(e===void 0)return[];return[e].flat().filter((n)=>n!==null&&n!==void 0).map((n)=>typeof n==="string"||typeof n==="number"||typeof n==="boolean"?V(n):R(n)?{type:"dynamic",value:E((r)=>{let i=r(n);return typeof i==="number"||typeof i==="string"||typeof i==="boolean"?V(i):i})}:n)}function V(e,n){return{type:"text",value:e,...n}}function q(e,n,r,i){let t=$(r).map((a)=>{if(typeof a==="string"||typeof a==="number"||typeof a==="boolean")return V(a);return a}),u={},s={},c={},o=[],l={};for(let[a,f]of Object.entries(n))if(f!==void 0)if(a.startsWith("bind:")){let p=a.slice(5);if(!R(f)||!("set"in f))throw new Error(`Binding value for "${p}" must be a writable store.`);s[p]=f}else if(a.startsWith("on:")){let p=a.slice(3);if(typeof f!=="function")throw new Error(`Event handler for "${p}" must be a function.`);c[p]=f}else if(a==="use"){if(typeof f!=="function"&&!Array.isArray(f))throw new Error("Use hook must be a function or an array of functions.");o.push(f)}else if(a==="style"){for(let[p,h]of Object.entries(f))if(h!==void 0)l[p]=se(h)}else u[a]=se(f);return{type:"element",name:e,attributes:u,children:t,bindings:s,eventHandlers:c,use:o,styles:l}}var _n,v,_="@vortex-get-internal",j,E,k;var Z=d(()=>{b();_n=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let r=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=r},[Symbol.dispose](){e.hookLifetime=r}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},v=class extends te({package:"@vortexjs/core",name:"Lifetime"},_n){};j=L,E=ue;k=te({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});function In(){let e=O.current;if(!e)throw new Error("No context scope found, you should have one if you're rendering a component.");return e}function ze(){return In().streaming}function Sn(){let e=O.current;if(!e)return null;return e}function On(){let e=Sn();if(!e)return null;return e.streaming}function qe({renderer:e,root:n,component:r,context:i}){try{var t=Dn.default();t.u(re("Initial page render"));let u=new Cn(e,n),s=new v,c=u.render({node:r,hydration:e.getHydrationContext(n),lt:s,context:i??O.current??new O}),o=new Ge(n,e);return o.children=[c],s}catch(u){t.e=u}finally{t.d()}}function Ue(e,n,r){if("renderer"in e)return qe(e);else return qe({renderer:e,root:n,component:r})}function We(){let e=On();return(n)=>{let r=j(void 0);async function i(){if(e)try{var t=jn.default();t.u(e.markLoading()),r.set(await n)}catch(u){t.e=u}finally{t.d()}else r.set(await n)}return i(),r}}var En,$n,An=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)$n(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=En(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},O=class e{contexts={};streaming=new An;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,r){this.contexts[n]=r}static current=null;static setCurrent(n){let r=e.current;return e.current=n,{[Symbol.dispose](){e.current=r}}}},Re="~vortex:intrinsic",Nn,z=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(r){if(r instanceof S)for(let i of r.children)n(i);else e.push(r)}for(let r of this.children)n(r);return e}},S,Me,Fe,Ge,fe,ce,Cn=class{constructor(e,n){this.renderer=e,this.root=n}render({node:e,hydration:n,lt:r,context:i}){if(e===void 0||e===null)return new S;if(Array.isArray(e))return this.render({node:{type:"fragment",children:e},hydration:n,lt:r,context:i});switch(e.type){case"fragment":{let s=new S;return s.children=e.children.map((c)=>this.render({node:c,hydration:n,lt:r,context:i})),s}case"text":return new Me(e.value.toString(),this.renderer,n,i);case"element":{let s=new Fe(e.name,this.renderer,n),c=this.renderer.getHydrationContext(s.rendererNode??m());s.children=e.children.map((l)=>this.render({node:l,hydration:c,lt:r,context:i}));for(let[l,a]of Object.entries(e.attributes))a.subscribe((f)=>{s.setAttribute(l,f)}).cascadesFrom(r);for(let[l,a]of Object.entries(e.bindings))this.renderer.bindValue(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.eventHandlers))this.renderer.addEventListener(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.styles))a.subscribe((f)=>{this.renderer.setStyle(s.rendererNode??m(),l,f)}).cascadesFrom(r);let o=[e.use].flat();for(let l of o)l(s.rendererNode??m());return s}case"component":try{var t=ce.default();t.u(v.changeHookLifetime(r)),t.u(O.setCurrent(i)),t.u(re(`Rendering ${e.impl.name}`));let s=e.impl;if(Re in s&&typeof s[Re]==="string"){let o=this.renderer.implementations?.find((l)=>l.intrinsic===s);if(o)s=o.implementation}let c=s(e.props);return this.render({node:c,hydration:n,lt:r,context:i})}catch(s){t.e=s}finally{t.d()}case"dynamic":{let s=new S;return oe((c,{lifetime:o})=>{let l=this.render({node:c(e.value),hydration:n,lt:o,context:i});s.children=[l]},void 0,r),s}case"list":{new S;let s=new Map,c=new S,o="";return oe((l)=>{let a=l(e.items),f=a.map((g,A)=>e.getKey(g,A));for(let g of s.keys())if(!f.includes(g))(s.get(g)??m()).lifetime.close(),s.delete(g);for(let g of f)if(!s.has(g))try{var p=ce.default();let A=a[f.indexOf(g)],cn=L(A),Y=new v;p.u(v.changeHookLifetime(Y));let an=this.render({node:e.renderItem(A,f.indexOf(g)),hydration:n,lt:Y,context:i});s.set(g,{node:an,item:cn,lifetime:Y})}catch(A){p.e=A}finally{p.d()}let h=f.join("|||");if(h!==o)o=h,c.children=f.map((g)=>(s.get(g)??m()).node)}),c}case"context":try{var u=ce.default();let s=i.fork();return u.u(O.setCurrent(s)),s.addContext(e.id,e.value),this.render({node:e.children,hydration:n,lt:r,context:s})}catch(s){u.e=s}finally{u.d()}default:De(e,`No rendering implementation for ${JSON.stringify(e)}`)}}},Dn,jn;var M=d(()=>{Le();Z();b();b();En=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),$n=globalThis.clearImmediate??((e)=>{clearTimeout(e)});Nn={};Pe(Nn,{FLElement:()=>Fe,FLFragment:()=>S,FLNode:()=>z,FLPortal:()=>Ge,FLText:()=>Me});S=class extends z{onChildrenChanged(){this.parent?.onChildrenChanged()}},Me=class extends z{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??m(),e)}constructor(e,n,r,i){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(r,i),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},Fe=class extends z{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??m(),e,n)}constructor(e,n,r){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,r)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??m());this.renderer.setChildren(this.rendererNode??m(),e)}},Ge=class extends z{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??m()))}},fe=Te({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function r(){var i=typeof SuppressedError=="function"?SuppressedError:function(c,o){var l=Error();return l.name="SuppressedError",l.error=c,l.suppressed=o,l},t={},u=[];function s(c,o){if(o!=null){if(Object(o)!==o)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(c)var l=o[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(l===void 0&&(l=o[Symbol.dispose||Symbol.for("Symbol.dispose")],c))var a=l;if(typeof l!="function")throw new TypeError("Object is not disposable.");a&&(l=function f(){try{a.call(o)}catch(p){return Promise.reject(p)}}),u.push({v:o,d:l,a:c})}else c&&u.push({d:o,a:c});return o}return{e:t,u:s.bind(null,!1),a:s.bind(null,!0),d(){var c,o=this.e,l=0;function a(){for(;c=u.pop();)try{if(!c.a&&l===1)return l=0,u.push(c),Promise.resolve().then(a);if(c.d){var p=c.d.call(c.v);if(c.a)return l|=2,Promise.resolve(p).then(a,f)}else l|=1}catch(h){return f(h)}if(l===1)return o!==t?Promise.reject(o):Promise.resolve();if(o!==t)throw o}function f(p){return o=o!==t?new i(p,o):p,a()}return a()}}}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),ce=K(fe(),1),Dn=K(fe(),1);jn=K(fe(),1)});function pe(e,n){let r=n.split("/").map((t)=>t.trim()).filter((t)=>t!=="");function i(t,u,s,c){if(t===e.length&&u===r.length)return{matched:!0,params:{...s},spreads:{...c}};if(t===e.length||u>r.length)return{matched:!1};let o=e[t]??m();if(o.type==="static"){if(u>=r.length||r[u]!==o.match)return{matched:!1};return i(t+1,u+1,s,c)}else if(o.type==="slug"){if(u>=r.length)return{matched:!1};let l={...s,[o.name]:r[u]};return i(t+1,u+1,l,c)}else if(o.type==="spread"){for(let l=0;l<=r.length-u;l++){let a={...c,[o.name]:r.slice(u,u+l)},f=i(t+1,u+l,s,a);if(f.matched)return f}return{matched:!1}}return{matched:!1}}return i(0,0,{},{})}var Je=d(()=>{b();M();b()});function x(e,n){let{children:r,...i}=n||{};if(e===k)return{type:"fragment",children:$(r)};if(typeof e==="string")return q(e,i,r);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(r)}};throw new Error(`Invalid JSX type: ${e}`)}var ye;var Be=d(()=>{Z();ye=x});var Xe=d(()=>{Be()});function Tn(){return E((e)=>{return new URL(e(F)).pathname})}function Pn(){if(typeof window==="undefined")return;F.subscribe((e)=>{if(window.location.href!==e)window.history.pushState({},"",e)},{callInitially:!1}),window.addEventListener("popstate",()=>{F.set(window.location.href)}),document.addEventListener("click",(e)=>{let r=e.composedPath().find((i)=>i instanceof HTMLAnchorElement);if(r?.href){let i=new URL(r.href,D(F));if(i.origin!==window.location.origin)return;e.preventDefault(),F.set(i.href)}})}function Ln({pathname:e,props:n,loaders:r}){if("location"in globalThis)Pn();ze();let i=We(),t=e?j(e):Tn(),u=E((l)=>{let a=l(t);return n.routes.find((f)=>pe(f.matcher,a))}),s=E(async(l)=>{let a=l(u)??m(),f=[];for(let p of a.frames)f.push(await(r[p.index]??m())());return f}),c=le(E((l)=>{return i(l(s))})),o=E((l)=>{let a=x(k,{}),f=l(c);if(!f)return x("h1",{children:"loading"});for(let p of f.toReversed())a=x(p,{children:a});return a});return ye("html",{children:[ye("head",{children:[x("link",{rel:"stylesheet",href:"/styles.css"}),x("script",{src:"/entrypoint-client.js",type:"module"})]}),x("body",{children:o})]})}async function Ke({props:e,loaders:n,renderer:r,root:i,pathname:t,lifetime:u=new v,context:s}){e:if("window"in globalThis){let c=t??window.location.pathname,o=e.routes.find((l)=>pe(l.matcher,c));if(!o)break e;for(let l of o.frames)await(n[l.index]??m())()}Ue({context:s,renderer:r,root:i,component:x(Ln,{pathname:t,props:e,loaders:n})}).cascadesFrom(u)}function Ve(e){return async function(n){return await e.impl(n)}}var F;var he=d(()=>{Je();b();M();Xe();b();F=j(typeof window!=="undefined"?window.location.href:"/")});function Mn(e){return{lang:e?.lang??ve?.lang,message:e?.message,abortEarly:e?.abortEarly??ve?.abortEarly,abortPipeEarly:e?.abortPipeEarly??ve?.abortPipeEarly}}function Gn(e){return Fn?.get(e)}function Wn(e){return Un?.get(e)}function Bn(e,n){return Jn?.get(e)?.get(n)}function Xn(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function de(e,n,r,i,t){let u=t&&"input"in t?t.input:r.value,s=t?.expected??e.expects??null,c=t?.received??Xn(u),o={kind:e.kind,type:e.type,input:u,expected:s,received:c,message:`Invalid ${n}: ${s?`Expected ${s} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:t?.path,issues:t?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},l=e.kind==="schema",a=t?.message??e.message??Bn(e.reference,o.lang)??(l?Wn(o.lang):null)??i.message??Gn(o.lang);if(a!==void 0)o.message=typeof a==="function"?a(o):a;if(l)r.typed=!1;if(r.issues)r.issues.push(o);else r.issues=[o]}function Ye(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Mn())}}}function Kn(e,n,r){return typeof e.fallback==="function"?e.fallback(n,r):e.fallback}function Vn(e,n,r){return typeof e.default==="function"?e.default(n,r):e.default}function Q(e){return{kind:"schema",type:"number",reference:Q,expects:"number",async:!1,message:e,get "~standard"(){return Ye(this)},"~run"(n,r){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else de(this,"type",n,r);return n}}}function ge(e,n){return{kind:"schema",type:"object",reference:ge,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return Ye(this)},"~run"(r,i){let t=r.value;if(t&&typeof t==="object"){r.typed=!0,r.value={};for(let u in this.entries){let s=this.entries[u];if(u in t||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){let c=u in t?t[u]:Vn(s),o=s["~run"]({value:c},i);if(o.issues){let l={type:"object",origin:"value",input:t,key:u,value:c};for(let a of o.issues){if(a.path)a.path.unshift(l);else a.path=[l];r.issues?.push(a)}if(!r.issues)r.issues=o.issues;if(i.abortEarly){r.typed=!1;break}}if(!o.typed)r.typed=!1;r.value[u]=o.value}else if(s.fallback!==void 0)r.value[u]=Kn(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"){if(de(this,"key",r,i,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:t,key:u,value:t[u]}]}),i.abortEarly)break}}}else de(this,"type",r,i);return r}}}var ve,Fn,Un,Jn;var en=()=>{};function G(e,n,r,i,t,u){let{children:s,...c}=n||{};if(e===k)return{type:"fragment",children:$(s),...t};if(typeof e==="string")return q(e,c,s,t);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(s)},...t};throw new Error(`Invalid JSX type: ${e}`)}var nn=d(()=>{Z()});var be=d(()=>{nn()});var Vr,rn=function({children:e}){return G(k,{children:[G("title",{children:"Wormhole Example"},void 0,!1,void 0,this),e]},void 0,!0,void 0,this)},tn=function(){return G(k,{children:G("h1",{children:"404 not found"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},Zn=function({a:e,b:n}){return e+n},Qn;var ke=d(()=>{en();he();be();Vr=Ve({schema:Qn,impl:Zn,endpoint:"/api/add",method:"GET",isQuery:!0}),Qn=ge({a:Q(),b:Q()})});var sn={};we(sn,{$d_732_888:()=>rn});var un=d(()=>{ke()});var on={};we(on,{$d_902_1009:()=>tn});var ln=d(()=>{ke()});he();M();b();M();b();function Rn(e){return"tagName"in e?e.tagName:"Text"}function qn(){return{html:"",write(e){this.html+=e},lastType:""}}function He(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function me(e,n=qn()){let r=Rn(e);if(r==="Text"&&n.lastType==="Text")n.write("");if(n.lastType=r,"tagName"in e){n.write("<"),n.write(e.tagName);for(let[i,t]of Object.entries(e.attributes)){if(t===void 0)continue;n.write(` ${i}="${He(t)}"`)}n.write(">");for(let i of e.children)me(i,n);n.write("")}if("content"in e)n.write(He(e.content.toString()));return n.html}function zn(e){return e.split(/(?=[A-Z])/).map((r)=>r.toLowerCase()).join("-")}function Ze(){return{createNode(e,n){return{tagName:e,attributes:{},children:[],parent:void 0}},setAttribute(e,n,r){if(!("tagName"in e))throw new Error("Cannot set attribute on a text node");e.attributes[n]=r},createTextNode(e){return{content:"",parent:void 0}},setTextContent(e,n){if(!("content"in e))throw new Error("Cannot set text content on a non-text node");e.content=n},setChildren(e,n){if(!("children"in e))throw new Error("Cannot set children on a text node");e.children=n;for(let r of n)r.parent=e},getHydrationContext(e){return},addEventListener(e,n,r){return new v},bindValue(e,n,r){return new v},setStyle(e,n,r){if(!("attributes"in e))throw new Error("Cannot set style on a text node");let i=e.attributes.style??"";i+=`${zn(n)}: ${r};`,e.attributes.style=i}}}function Qe(){return{tagName:"html",attributes:{},children:[],parent:void 0,fixedIdent:"document.documentElement"}}var Yn=JSON.parse('{"routes":[{"matcher":[{"type":"spread","name":"404"}],"frames":[{"index":0},{"index":1}],"is404":true}]}'),er=[async()=>(await Promise.resolve().then(() => (un(),sn))).$d_732_888,async()=>(await Promise.resolve().then(() => (ln(),on))).$d_902_1009];async function nr(e){let r=new URL(e.url).pathname,i=Ze(),t=Qe(),u=new v;try{await Ke({props:Yn,loaders:er,renderer:i,root:t,pathname:r,context:{},lifetime:u});let s=me(t);return new Response(s,{status:200,headers:{"Content-Type":"text/html"}})}catch(s){return console.error("Rendering error:",s),new Response("Internal Server Error",{status:500})}finally{u.close()}}export{nr as default}; diff --git a/packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/.vc-config.json b/packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/.vc-config.json deleted file mode 100644 index bd4af02..0000000 --- a/packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/.vc-config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "runtime": "edge", - "entrypoint": "index.js" -} \ No newline at end of file diff --git a/packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/index.js b/packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/index.js deleted file mode 100644 index aaa51fd..0000000 --- a/packages/example-wormhole/.vercel/output/functions/route-docs/[...page].func/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// @bun -var fn=Object.defineProperty;var we=(e,n)=>{for(var r in n)fn(e,r,{get:n[r],enumerable:!0,configurable:!0,set:(i)=>n[r]=()=>i})};var d=(e,n)=>()=>(e&&(n=e(e=0)),n);var pn,xe=(e,n)=>{for(var r in n)pn(e,r,{get:n[r],enumerable:!0})};var _e=d(()=>{pn=Object.defineProperty});function Ee(e){return typeof e==="object"&&e!==null&&typeof e.then==="function"}function U(e,n){if(e===n)return!0;if(typeof e!==typeof n)return!1;if(Array.isArray(e)!==Array.isArray(n))return!1;if(Ee(e)||Ee(n))return!1;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let r=0;r="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}function W(e){return e>="0"&&e<="9"}function Ie(e){return X(e)||W(e)}function*Se(e){let n=0,r=()=>e[n]??"",i=()=>e[n++]??"",t=()=>{n++};while(n=e.tokens.length)return null;return e.tokens[e.current++]??null}function J(e){if(e.current>=e.tokens.length)return null;return e.tokens[e.current]??null}function N(e){let n=J(e);if(n!==null)e.current++;return n}function B(e){let n=N(e);if(n===null)throw new Error("Unexpected end of input");if(n[0]==="number")return n[1];if(n[0]==="string")return n[1];if(n[0]==="keyword"){if(n[1]===I.null)return null;if(n[1]===I.undefined)return;if(n[1]===I.true)return!0;if(n[1]===I.false)return!1;throw new Error(`Unexpected keyword: ${n[1]}`)}let r=null;if(n[0]==="identifier")r=n[1],n=N(e);if(n===null)throw new Error("Unexpected end of input (after reading class)");if(n[0]==="symbol"&&n[1]==="LeftParenthesis"){let i={};while(!0){let t=N(e);if(t===null)throw new Error("Unexpected end of input (when trying to read key)");if(t[0]==="symbol"&&t[1]==="RightParenthesis")break;if(t[0]!=="identifier"&&t[0]!=="string")throw new Error(`Expected identifier or string, got ${t[0]}`);let u=N(e);if(u===null||u[0]!=="symbol"||u[1]!=="Equals")throw new Error(`Expected '=', got ${u?u[0]:"end of input"}`);let s=t[1],c=B(e);i[s]=c}if(r!==null){if(r==="date")return new Date(i.unix);if(r==="set")return new Set(i.items);if(r==="map"){let t=new Map;for(let[u,s]of i.entries)t.set(u,s);return t}throw new Error(`Unknown class: ${r}`)}return i}if(n[0]==="symbol"&&n[1]==="LeftSquareBracket"){let i=[];while(!0){if(J(e)?.[0]==="symbol"&&J(e)?.[1]==="RightSquareBracket"){N(e);break}let t=B(e);i.push(t)}return i}}function hn(e){let n=[...Se(e)],r=Oe(n),i=B(r);if(r.currentt[0]).join(", ")}`);return i}function Ne(){return{output:"",indentLevel:0,minified:!1}}function P(e){e.indentLevel++}function L(e){e.indentLevel=Math.max(0,e.indentLevel-1)}function w(e){if(e.minified){y(e," ");return}y(e,` -`),y(e," ".repeat(e.indentLevel))}function y(e,n){e.output+=n}function ne(e){let n=Number.POSITIVE_INFINITY,r="";for(let i of['"',"'","`"]){let t="";t+=i;for(let u of e)if(u===i)t+=`\\${u}`;else if(u==="\\")t+="\\\\";else if(u===` -`)t+="\\n";else if(u==="\t")t+="\\t";else if(u==="\r")t+="\\r";else t+=u;if(t+=i,t.length{_e();$e={};xe($e,{escapeStr:()=>ne,isAlphabetic:()=>X,isAlphanumeric:()=>Ie,isNumeric:()=>W,isWhitespace:()=>Ae,keywords:()=>I,lex:()=>Se,parse:()=>hn,parseContext_create:()=>Oe,parseContext_next:()=>yn,parseContext_peek:()=>J,parseContext_read:()=>N,parseContext_readObj:()=>B,serialize:()=>Ce,serializeContext_create:()=>Ne,serializeContext_dedent:()=>L,serializeContext_indent:()=>P,serializeContext_newline:()=>w,serializeContext_write:()=>y,serializeContext_writeObject:()=>C,stringify:()=>mn,symbols:()=>ee});I={null:"Null",true:"True",false:"False",undefined:"Undefined"},ee={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};mn=Ce});var gn,ie,bn,je,kn,wn,Te=(e,n)=>function(){return n||e[je(e)[0]]((n={exports:{}}).exports,n),n.exports},Pe=(e,n)=>{for(var r in n)ie(e,r,{get:n[r],enumerable:!0})},xn=(e,n,r,i)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var t=je(n),u=0,s=t.length,c;un[o]).bind(null,c),enumerable:!(i=bn(n,c))||i.enumerable})}return e},K=(e,n,r)=>(r=e!=null?gn(kn(e)):{},xn(n||!e||!e.__esModule?ie(r,"default",{value:e,enumerable:!0}):r,e));var Le=d(()=>{gn=Object.create,ie=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,je=Object.getOwnPropertyNames,kn=Object.getPrototypeOf,wn=Object.prototype.hasOwnProperty});function H(){if(v.hookLifetime===null)throw new Error("No hook lifetime available");return v.hookLifetime}function q(e){let n,r=e,i=[];return n&&console.log(`[${n}]: initialized with `,r),{setId(t){n=t},[_](){return r},subscribe(t,u){if(i.push(t),n&&console.trace(`[${n}]: subscribed with `,t),u?.callInitially!==!1)t(r);return new v().onClosed(()=>{i.splice(i.indexOf(t),1),n&&console.log(`[${n}]: unsubscribed `,t)})},set(t){if(n&&console.log(`[${n}]: trying to switch from `,r," -> ",t),!U(r,t)){r=t;for(let u of i)u(r);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}function D(e){return e[_]()}function ue(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=q(e((o)=>{if(!t.includes(o))t.push(o);return o[_]()}));function s(){if(i){let o=new Set(t);u.set(e((p)=>{return o.add(p),p[_]()}));let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.set(e(D))}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)});return{...u}}function oe(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=new v;e((o)=>{if(!t.includes(o))t.push(o);return o[_]()},{lifetime:u});function s(){if(i){let o=new Set(t);u.close(),u=new v().cascadesFrom(r),e((p)=>{return o.add(p),p[_]()},{lifetime:u});let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.close(),u=new v().cascadesFrom(r),e(D,{lifetime:u})}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)})}function R(e){return typeof e==="object"&&e!==null&&_ in e}function se(e){if(R(e))return e;return q(e)}function le(e,n=H()){return ue((r)=>{function i(t){if(R(t))return i(r(t));return t}return i(e)},{dynamic:!0},n)}function $(e){if(e===void 0)return[];return[e].flat().filter((n)=>n!==null&&n!==void 0).map((n)=>typeof n==="string"||typeof n==="number"||typeof n==="boolean"?V(n):R(n)?{type:"dynamic",value:E((r)=>{let i=r(n);return typeof i==="number"||typeof i==="string"||typeof i==="boolean"?V(i):i})}:n)}function V(e,n){return{type:"text",value:e,...n}}function z(e,n,r,i){let t=$(r).map((a)=>{if(typeof a==="string"||typeof a==="number"||typeof a==="boolean")return V(a);return a}),u={},s={},c={},o=[],l={};for(let[a,f]of Object.entries(n))if(f!==void 0)if(a.startsWith("bind:")){let p=a.slice(5);if(!R(f)||!("set"in f))throw new Error(`Binding value for "${p}" must be a writable store.`);s[p]=f}else if(a.startsWith("on:")){let p=a.slice(3);if(typeof f!=="function")throw new Error(`Event handler for "${p}" must be a function.`);c[p]=f}else if(a==="use"){if(typeof f!=="function"&&!Array.isArray(f))throw new Error("Use hook must be a function or an array of functions.");o.push(f)}else if(a==="style"){for(let[p,h]of Object.entries(f))if(h!==void 0)l[p]=se(h)}else u[a]=se(f);return{type:"element",name:e,attributes:u,children:t,bindings:s,eventHandlers:c,use:o,styles:l}}var _n,v,_="@vortex-get-internal",j,E,k;var Z=d(()=>{b();_n=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let r=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=r},[Symbol.dispose](){e.hookLifetime=r}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},v=class extends te({package:"@vortexjs/core",name:"Lifetime"},_n){};j=q,E=ue;k=te({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});function In(){let e=O.current;if(!e)throw new Error("No context scope found, you should have one if you're rendering a component.");return e}function ze(){return In().streaming}function Sn(){let e=O.current;if(!e)return null;return e}function On(){let e=Sn();if(!e)return null;return e.streaming}function Re({renderer:e,root:n,component:r,context:i}){try{var t=Dn.default();t.u(re("Initial page render"));let u=new Cn(e,n),s=new v,c=u.render({node:r,hydration:e.getHydrationContext(n),lt:s,context:i??O.current??new O}),o=new Ge(n,e);return o.children=[c],s}catch(u){t.e=u}finally{t.d()}}function Ue(e,n,r){if("renderer"in e)return Re(e);else return Re({renderer:e,root:n,component:r})}function We(){let e=On();return(n)=>{let r=j(void 0);async function i(){if(e)try{var t=jn.default();t.u(e.markLoading()),r.set(await n)}catch(u){t.e=u}finally{t.d()}else r.set(await n)}return i(),r}}var En,$n,An=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)$n(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=En(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},O=class e{contexts={};streaming=new An;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,r){this.contexts[n]=r}static current=null;static setCurrent(n){let r=e.current;return e.current=n,{[Symbol.dispose](){e.current=r}}}},qe="~vortex:intrinsic",Nn,M=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(r){if(r instanceof S)for(let i of r.children)n(i);else e.push(r)}for(let r of this.children)n(r);return e}},S,Me,Fe,Ge,fe,ce,Cn=class{constructor(e,n){this.renderer=e,this.root=n}render({node:e,hydration:n,lt:r,context:i}){if(e===void 0||e===null)return new S;if(Array.isArray(e))return this.render({node:{type:"fragment",children:e},hydration:n,lt:r,context:i});switch(e.type){case"fragment":{let s=new S;return s.children=e.children.map((c)=>this.render({node:c,hydration:n,lt:r,context:i})),s}case"text":return new Me(e.value.toString(),this.renderer,n,i);case"element":{let s=new Fe(e.name,this.renderer,n),c=this.renderer.getHydrationContext(s.rendererNode??m());s.children=e.children.map((l)=>this.render({node:l,hydration:c,lt:r,context:i}));for(let[l,a]of Object.entries(e.attributes))a.subscribe((f)=>{s.setAttribute(l,f)}).cascadesFrom(r);for(let[l,a]of Object.entries(e.bindings))this.renderer.bindValue(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.eventHandlers))this.renderer.addEventListener(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.styles))a.subscribe((f)=>{this.renderer.setStyle(s.rendererNode??m(),l,f)}).cascadesFrom(r);let o=[e.use].flat();for(let l of o)l(s.rendererNode??m());return s}case"component":try{var t=ce.default();t.u(v.changeHookLifetime(r)),t.u(O.setCurrent(i)),t.u(re(`Rendering ${e.impl.name}`));let s=e.impl;if(qe in s&&typeof s[qe]==="string"){let o=this.renderer.implementations?.find((l)=>l.intrinsic===s);if(o)s=o.implementation}let c=s(e.props);return this.render({node:c,hydration:n,lt:r,context:i})}catch(s){t.e=s}finally{t.d()}case"dynamic":{let s=new S;return oe((c,{lifetime:o})=>{let l=this.render({node:c(e.value),hydration:n,lt:o,context:i});s.children=[l]},void 0,r),s}case"list":{new S;let s=new Map,c=new S,o="";return oe((l)=>{let a=l(e.items),f=a.map((g,A)=>e.getKey(g,A));for(let g of s.keys())if(!f.includes(g))(s.get(g)??m()).lifetime.close(),s.delete(g);for(let g of f)if(!s.has(g))try{var p=ce.default();let A=a[f.indexOf(g)],cn=q(A),Y=new v;p.u(v.changeHookLifetime(Y));let an=this.render({node:e.renderItem(A,f.indexOf(g)),hydration:n,lt:Y,context:i});s.set(g,{node:an,item:cn,lifetime:Y})}catch(A){p.e=A}finally{p.d()}let h=f.join("|||");if(h!==o)o=h,c.children=f.map((g)=>(s.get(g)??m()).node)}),c}case"context":try{var u=ce.default();let s=i.fork();return u.u(O.setCurrent(s)),s.addContext(e.id,e.value),this.render({node:e.children,hydration:n,lt:r,context:s})}catch(s){u.e=s}finally{u.d()}default:De(e,`No rendering implementation for ${JSON.stringify(e)}`)}}},Dn,jn;var F=d(()=>{Le();Z();b();b();En=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),$n=globalThis.clearImmediate??((e)=>{clearTimeout(e)});Nn={};Pe(Nn,{FLElement:()=>Fe,FLFragment:()=>S,FLNode:()=>M,FLPortal:()=>Ge,FLText:()=>Me});S=class extends M{onChildrenChanged(){this.parent?.onChildrenChanged()}},Me=class extends M{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??m(),e)}constructor(e,n,r,i){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(r,i),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},Fe=class extends M{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??m(),e,n)}constructor(e,n,r){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,r)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??m());this.renderer.setChildren(this.rendererNode??m(),e)}},Ge=class extends M{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??m()))}},fe=Te({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function r(){var i=typeof SuppressedError=="function"?SuppressedError:function(c,o){var l=Error();return l.name="SuppressedError",l.error=c,l.suppressed=o,l},t={},u=[];function s(c,o){if(o!=null){if(Object(o)!==o)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(c)var l=o[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(l===void 0&&(l=o[Symbol.dispose||Symbol.for("Symbol.dispose")],c))var a=l;if(typeof l!="function")throw new TypeError("Object is not disposable.");a&&(l=function f(){try{a.call(o)}catch(p){return Promise.reject(p)}}),u.push({v:o,d:l,a:c})}else c&&u.push({d:o,a:c});return o}return{e:t,u:s.bind(null,!1),a:s.bind(null,!0),d(){var c,o=this.e,l=0;function a(){for(;c=u.pop();)try{if(!c.a&&l===1)return l=0,u.push(c),Promise.resolve().then(a);if(c.d){var p=c.d.call(c.v);if(c.a)return l|=2,Promise.resolve(p).then(a,f)}else l|=1}catch(h){return f(h)}if(l===1)return o!==t?Promise.reject(o):Promise.resolve();if(o!==t)throw o}function f(p){return o=o!==t?new i(p,o):p,a()}return a()}}}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),ce=K(fe(),1),Dn=K(fe(),1);jn=K(fe(),1)});function pe(e,n){let r=n.split("/").map((t)=>t.trim()).filter((t)=>t!=="");function i(t,u,s,c){if(t===e.length&&u===r.length)return{matched:!0,params:{...s},spreads:{...c}};if(t===e.length||u>r.length)return{matched:!1};let o=e[t]??m();if(o.type==="static"){if(u>=r.length||r[u]!==o.match)return{matched:!1};return i(t+1,u+1,s,c)}else if(o.type==="slug"){if(u>=r.length)return{matched:!1};let l={...s,[o.name]:r[u]};return i(t+1,u+1,l,c)}else if(o.type==="spread"){for(let l=0;l<=r.length-u;l++){let a={...c,[o.name]:r.slice(u,u+l)},f=i(t+1,u+l,s,a);if(f.matched)return f}return{matched:!1}}return{matched:!1}}return i(0,0,{},{})}var Je=d(()=>{b();F();b()});function x(e,n){let{children:r,...i}=n||{};if(e===k)return{type:"fragment",children:$(r)};if(typeof e==="string")return z(e,i,r);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(r)}};throw new Error(`Invalid JSX type: ${e}`)}var ye;var Be=d(()=>{Z();ye=x});var Xe=d(()=>{Be()});function Tn(){return E((e)=>{return new URL(e(G)).pathname})}function Pn(){if(typeof window==="undefined")return;G.subscribe((e)=>{if(window.location.href!==e)window.history.pushState({},"",e)},{callInitially:!1}),window.addEventListener("popstate",()=>{G.set(window.location.href)}),document.addEventListener("click",(e)=>{let r=e.composedPath().find((i)=>i instanceof HTMLAnchorElement);if(r?.href){let i=new URL(r.href,D(G));if(i.origin!==window.location.origin)return;e.preventDefault(),G.set(i.href)}})}function Ln({pathname:e,props:n,loaders:r}){if("location"in globalThis)Pn();ze();let i=We(),t=e?j(e):Tn(),u=E((l)=>{let a=l(t);return n.routes.find((f)=>pe(f.matcher,a))}),s=E(async(l)=>{let a=l(u)??m(),f=[];for(let p of a.frames)f.push(await(r[p.index]??m())());return f}),c=le(E((l)=>{return i(l(s))})),o=E((l)=>{let a=x(k,{}),f=l(c);if(!f)return x("h1",{children:"loading"});for(let p of f.toReversed())a=x(p,{children:a});return a});return ye("html",{children:[ye("head",{children:[x("link",{rel:"stylesheet",href:"/styles.css"}),x("script",{src:"/entrypoint-client.js",type:"module"})]}),x("body",{children:o})]})}async function Ke({props:e,loaders:n,renderer:r,root:i,pathname:t,lifetime:u=new v,context:s}){e:if("window"in globalThis){let c=t??window.location.pathname,o=e.routes.find((l)=>pe(l.matcher,c));if(!o)break e;for(let l of o.frames)await(n[l.index]??m())()}Ue({context:s,renderer:r,root:i,component:x(Ln,{pathname:t,props:e,loaders:n})}).cascadesFrom(u)}function Ve(e){return async function(n){return await e.impl(n)}}var G;var he=d(()=>{Je();b();F();Xe();b();G=j(typeof window!=="undefined"?window.location.href:"/")});function Mn(e){return{lang:e?.lang??ve?.lang,message:e?.message,abortEarly:e?.abortEarly??ve?.abortEarly,abortPipeEarly:e?.abortPipeEarly??ve?.abortPipeEarly}}function Gn(e){return Fn?.get(e)}function Wn(e){return Un?.get(e)}function Bn(e,n){return Jn?.get(e)?.get(n)}function Xn(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function de(e,n,r,i,t){let u=t&&"input"in t?t.input:r.value,s=t?.expected??e.expects??null,c=t?.received??Xn(u),o={kind:e.kind,type:e.type,input:u,expected:s,received:c,message:`Invalid ${n}: ${s?`Expected ${s} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:t?.path,issues:t?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},l=e.kind==="schema",a=t?.message??e.message??Bn(e.reference,o.lang)??(l?Wn(o.lang):null)??i.message??Gn(o.lang);if(a!==void 0)o.message=typeof a==="function"?a(o):a;if(l)r.typed=!1;if(r.issues)r.issues.push(o);else r.issues=[o]}function Ye(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Mn())}}}function Kn(e,n,r){return typeof e.fallback==="function"?e.fallback(n,r):e.fallback}function Vn(e,n,r){return typeof e.default==="function"?e.default(n,r):e.default}function Q(e){return{kind:"schema",type:"number",reference:Q,expects:"number",async:!1,message:e,get "~standard"(){return Ye(this)},"~run"(n,r){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else de(this,"type",n,r);return n}}}function ge(e,n){return{kind:"schema",type:"object",reference:ge,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return Ye(this)},"~run"(r,i){let t=r.value;if(t&&typeof t==="object"){r.typed=!0,r.value={};for(let u in this.entries){let s=this.entries[u];if(u in t||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){let c=u in t?t[u]:Vn(s),o=s["~run"]({value:c},i);if(o.issues){let l={type:"object",origin:"value",input:t,key:u,value:c};for(let a of o.issues){if(a.path)a.path.unshift(l);else a.path=[l];r.issues?.push(a)}if(!r.issues)r.issues=o.issues;if(i.abortEarly){r.typed=!1;break}}if(!o.typed)r.typed=!1;r.value[u]=o.value}else if(s.fallback!==void 0)r.value[u]=Kn(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"){if(de(this,"key",r,i,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:t,key:u,value:t[u]}]}),i.abortEarly)break}}}else de(this,"type",r,i);return r}}}var ve,Fn,Un,Jn;var en=()=>{};function T(e,n,r,i,t,u){let{children:s,...c}=n||{};if(e===k)return{type:"fragment",children:$(s),...t};if(typeof e==="string")return z(e,c,s,t);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(s)},...t};throw new Error(`Invalid JSX type: ${e}`)}var nn=d(()=>{Z()});var be=d(()=>{nn()});var Vr,rn=function({children:e}){return T(k,{children:[T("title",{children:"Wormhole Example"},void 0,!1,void 0,this),e]},void 0,!0,void 0,this)},tn=function({page:e}){return T(k,{children:[T("h1",{children:["Documentation for ",e.join(", ")]},void 0,!0,void 0,this),T("p",{children:["This is the documentation page for ",e.join(", "),"."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},Zn=function({a:e,b:n}){return e+n},Qn;var ke=d(()=>{en();he();be();Vr=Ve({schema:Qn,impl:Zn,endpoint:"/api/add",method:"GET",isQuery:!0}),Qn=ge({a:Q(),b:Q()})});var sn={};we(sn,{$d_732_888:()=>rn});var un=d(()=>{ke()});var on={};we(on,{$d_1050_1265:()=>tn});var ln=d(()=>{ke()});he();F();b();F();b();function qn(e){return"tagName"in e?e.tagName:"Text"}function Rn(){return{html:"",write(e){this.html+=e},lastType:""}}function He(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function me(e,n=Rn()){let r=qn(e);if(r==="Text"&&n.lastType==="Text")n.write("");if(n.lastType=r,"tagName"in e){n.write("<"),n.write(e.tagName);for(let[i,t]of Object.entries(e.attributes)){if(t===void 0)continue;n.write(` ${i}="${He(t)}"`)}n.write(">");for(let i of e.children)me(i,n);n.write("")}if("content"in e)n.write(He(e.content.toString()));return n.html}function zn(e){return e.split(/(?=[A-Z])/).map((r)=>r.toLowerCase()).join("-")}function Ze(){return{createNode(e,n){return{tagName:e,attributes:{},children:[],parent:void 0}},setAttribute(e,n,r){if(!("tagName"in e))throw new Error("Cannot set attribute on a text node");e.attributes[n]=r},createTextNode(e){return{content:"",parent:void 0}},setTextContent(e,n){if(!("content"in e))throw new Error("Cannot set text content on a non-text node");e.content=n},setChildren(e,n){if(!("children"in e))throw new Error("Cannot set children on a text node");e.children=n;for(let r of n)r.parent=e},getHydrationContext(e){return},addEventListener(e,n,r){return new v},bindValue(e,n,r){return new v},setStyle(e,n,r){if(!("attributes"in e))throw new Error("Cannot set style on a text node");let i=e.attributes.style??"";i+=`${zn(n)}: ${r};`,e.attributes.style=i}}}function Qe(){return{tagName:"html",attributes:{},children:[],parent:void 0,fixedIdent:"document.documentElement"}}var Yn=JSON.parse('{"routes":[{"matcher":[{"type":"static","match":"docs"},{"type":"spread","name":"page"}],"frames":[{"index":0},{"index":1}],"is404":false}]}'),er=[async()=>(await Promise.resolve().then(() => (un(),sn))).$d_732_888,async()=>(await Promise.resolve().then(() => (ln(),on))).$d_1050_1265];async function nr(e){let r=new URL(e.url).pathname,i=Ze(),t=Qe(),u=new v;try{await Ke({props:Yn,loaders:er,renderer:i,root:t,pathname:r,context:{},lifetime:u});let s=me(t);return new Response(s,{status:200,headers:{"Content-Type":"text/html"}})}catch(s){return console.error("Rendering error:",s),new Response("Internal Server Error",{status:500})}finally{u.close()}}export{nr as default}; diff --git a/packages/example-wormhole/.vercel/output/functions/route-index.func/.vc-config.json b/packages/example-wormhole/.vercel/output/functions/route-index.func/.vc-config.json deleted file mode 100644 index bd4af02..0000000 --- a/packages/example-wormhole/.vercel/output/functions/route-index.func/.vc-config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "runtime": "edge", - "entrypoint": "index.js" -} \ No newline at end of file diff --git a/packages/example-wormhole/.vercel/output/functions/route-index.func/index.js b/packages/example-wormhole/.vercel/output/functions/route-index.func/index.js deleted file mode 100644 index 45a43cb..0000000 --- a/packages/example-wormhole/.vercel/output/functions/route-index.func/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// @bun -var on=Object.defineProperty;var ln=(e,n)=>{for(var r in n)on(e,r,{get:n[r],enumerable:!0,configurable:!0,set:(i)=>n[r]=()=>i})};var d=(e,n)=>()=>(e&&(n=e(e=0)),n);var cn,ke=(e,n)=>{for(var r in n)cn(e,r,{get:n[r],enumerable:!0})};var we=d(()=>{cn=Object.defineProperty});function xe(e){return typeof e==="object"&&e!==null&&typeof e.then==="function"}function U(e,n){if(e===n)return!0;if(typeof e!==typeof n)return!1;if(Array.isArray(e)!==Array.isArray(n))return!1;if(xe(e)||xe(n))return!1;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let r=0;r="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}function W(e){return e>="0"&&e<="9"}function $e(e){return X(e)||W(e)}function*Ae(e){let n=0,r=()=>e[n]??"",i=()=>e[n++]??"",t=()=>{n++};while(n=e.tokens.length)return null;return e.tokens[e.current++]??null}function J(e){if(e.current>=e.tokens.length)return null;return e.tokens[e.current]??null}function N(e){let n=J(e);if(n!==null)e.current++;return n}function B(e){let n=N(e);if(n===null)throw new Error("Unexpected end of input");if(n[0]==="number")return n[1];if(n[0]==="string")return n[1];if(n[0]==="keyword"){if(n[1]===I.null)return null;if(n[1]===I.undefined)return;if(n[1]===I.true)return!0;if(n[1]===I.false)return!1;throw new Error(`Unexpected keyword: ${n[1]}`)}let r=null;if(n[0]==="identifier")r=n[1],n=N(e);if(n===null)throw new Error("Unexpected end of input (after reading class)");if(n[0]==="symbol"&&n[1]==="LeftParenthesis"){let i={};while(!0){let t=N(e);if(t===null)throw new Error("Unexpected end of input (when trying to read key)");if(t[0]==="symbol"&&t[1]==="RightParenthesis")break;if(t[0]!=="identifier"&&t[0]!=="string")throw new Error(`Expected identifier or string, got ${t[0]}`);let u=N(e);if(u===null||u[0]!=="symbol"||u[1]!=="Equals")throw new Error(`Expected '=', got ${u?u[0]:"end of input"}`);let s=t[1],c=B(e);i[s]=c}if(r!==null){if(r==="date")return new Date(i.unix);if(r==="set")return new Set(i.items);if(r==="map"){let t=new Map;for(let[u,s]of i.entries)t.set(u,s);return t}throw new Error(`Unknown class: ${r}`)}return i}if(n[0]==="symbol"&&n[1]==="LeftSquareBracket"){let i=[];while(!0){if(J(e)?.[0]==="symbol"&&J(e)?.[1]==="RightSquareBracket"){N(e);break}let t=B(e);i.push(t)}return i}}function fn(e){let n=[...Ae(e)],r=Ie(n),i=B(r);if(r.currentt[0]).join(", ")}`);return i}function Se(){return{output:"",indentLevel:0,minified:!1}}function P(e){e.indentLevel++}function L(e){e.indentLevel=Math.max(0,e.indentLevel-1)}function k(e){if(e.minified){y(e," ");return}y(e,` -`),y(e," ".repeat(e.indentLevel))}function y(e,n){e.output+=n}function ne(e){let n=Number.POSITIVE_INFINITY,r="";for(let i of['"',"'","`"]){let t="";t+=i;for(let u of e)if(u===i)t+=`\\${u}`;else if(u==="\\")t+="\\\\";else if(u===` -`)t+="\\n";else if(u==="\t")t+="\\t";else if(u==="\r")t+="\\r";else t+=u;if(t+=i,t.length{we();_e={};ke(_e,{escapeStr:()=>ne,isAlphabetic:()=>X,isAlphanumeric:()=>$e,isNumeric:()=>W,isWhitespace:()=>Ee,keywords:()=>I,lex:()=>Ae,parse:()=>fn,parseContext_create:()=>Ie,parseContext_next:()=>an,parseContext_peek:()=>J,parseContext_read:()=>N,parseContext_readObj:()=>B,serialize:()=>Oe,serializeContext_create:()=>Se,serializeContext_dedent:()=>L,serializeContext_indent:()=>P,serializeContext_newline:()=>k,serializeContext_write:()=>y,serializeContext_writeObject:()=>C,stringify:()=>pn,symbols:()=>ee});I={null:"Null",true:"True",false:"False",undefined:"Undefined"},ee={"(":"LeftParenthesis",")":"RightParenthesis","[":"LeftSquareBracket","]":"RightSquareBracket","{":"LeftCurlyBracket","}":"RightCurlyBracket",",":"Comma",":":"Colon",";":"Semicolon",".":"Dot","=":"Equals","+":"Plus","-":"Minus","*":"Asterisk","/":"Slash","%":"Percent","!":"ExclamationMark","<":"LeftAngularBracket",">":"RightAngularBracket"};pn=Oe});var mn,ie,vn,Ce,dn,gn,De=(e,n)=>function(){return n||e[Ce(e)[0]]((n={exports:{}}).exports,n),n.exports},je=(e,n)=>{for(var r in n)ie(e,r,{get:n[r],enumerable:!0})},bn=(e,n,r,i)=>{if(n&&typeof n==="object"||typeof n==="function"){for(var t=Ce(n),u=0,s=t.length,c;un[o]).bind(null,c),enumerable:!(i=vn(n,c))||i.enumerable})}return e},K=(e,n,r)=>(r=e!=null?mn(dn(e)):{},bn(n||!e||!e.__esModule?ie(r,"default",{value:e,enumerable:!0}):r,e));var Te=d(()=>{mn=Object.create,ie=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,Ce=Object.getOwnPropertyNames,dn=Object.getPrototypeOf,gn=Object.prototype.hasOwnProperty});function H(){if(v.hookLifetime===null)throw new Error("No hook lifetime available");return v.hookLifetime}function R(e){let n,r=e,i=[];return n&&console.log(`[${n}]: initialized with `,r),{setId(t){n=t},[_](){return r},subscribe(t,u){if(i.push(t),n&&console.trace(`[${n}]: subscribed with `,t),u?.callInitially!==!1)t(r);return new v().onClosed(()=>{i.splice(i.indexOf(t),1),n&&console.log(`[${n}]: unsubscribed `,t)})},set(t){if(n&&console.log(`[${n}]: trying to switch from `,r," -> ",t),!U(r,t)){r=t;for(let u of i)u(r);n&&console.log(`[${n}]: updated`)}else n&&console.log(`[${n}]: no change, value is still the same`)}}}function D(e){return e[_]()}function ue(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=R(e((o)=>{if(!t.includes(o))t.push(o);return o[_]()}));function s(){if(i){let o=new Set(t);u.set(e((p)=>{return o.add(p),p[_]()}));let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.set(e(D))}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)});return{...u}}function oe(e,n,r=H()){let i=n?.dynamic??!1,t=[],u=new v;e((o)=>{if(!t.includes(o))t.push(o);return o[_]()},{lifetime:u});function s(){if(i){let o=new Set(t);u.close(),u=new v().cascadesFrom(r),e((p)=>{return o.add(p),p[_]()},{lifetime:u});let l=new Set(t),a=l.difference(o);for(let p of a){let h=t.indexOf(p);if(h!==-1)t.splice(h,1),c[h]?.close(),c.splice(h,1)}let f=o.difference(l);for(let p of f){let h=p.subscribe(()=>{s()},{callInitially:!1});t.push(p),c.push(h)}}else u.close(),u=new v().cascadesFrom(r),e(D,{lifetime:u})}let c=t.map((o)=>{return o.subscribe(()=>{s()},{callInitially:!1}).cascadesFrom(r)})}function q(e){return typeof e==="object"&&e!==null&&_ in e}function se(e){if(q(e))return e;return R(e)}function le(e,n=H()){return ue((r)=>{function i(t){if(q(t))return i(r(t));return t}return i(e)},{dynamic:!0},n)}function $(e){if(e===void 0)return[];return[e].flat().filter((n)=>n!==null&&n!==void 0).map((n)=>typeof n==="string"||typeof n==="number"||typeof n==="boolean"?V(n):q(n)?{type:"dynamic",value:E((r)=>{let i=r(n);return typeof i==="number"||typeof i==="string"||typeof i==="boolean"?V(i):i})}:n)}function V(e,n){return{type:"text",value:e,...n}}function z(e,n,r,i){let t=$(r).map((a)=>{if(typeof a==="string"||typeof a==="number"||typeof a==="boolean")return V(a);return a}),u={},s={},c={},o=[],l={};for(let[a,f]of Object.entries(n))if(f!==void 0)if(a.startsWith("bind:")){let p=a.slice(5);if(!q(f)||!("set"in f))throw new Error(`Binding value for "${p}" must be a writable store.`);s[p]=f}else if(a.startsWith("on:")){let p=a.slice(3);if(typeof f!=="function")throw new Error(`Event handler for "${p}" must be a function.`);c[p]=f}else if(a==="use"){if(typeof f!=="function"&&!Array.isArray(f))throw new Error("Use hook must be a function or an array of functions.");o.push(f)}else if(a==="style"){for(let[p,h]of Object.entries(f))if(h!==void 0)l[p]=se(h)}else u[a]=se(f);return{type:"element",name:e,attributes:u,children:t,bindings:s,eventHandlers:c,use:o,styles:l}}var kn,v,_="@vortex-get-internal",j,E,w;var Z=d(()=>{b();kn=class e{#e=[];static hookLifetime=null;static changeHookLifetime(n){let r=e.hookLifetime;return e.hookLifetime=n,{reset(){e.hookLifetime=r},[Symbol.dispose](){e.hookLifetime=r}}}close(){for(let n of this.#e)n();this.#e=[]}onClosed(n){return this.#e.push(n),this}cascadesFrom(n){return n.onClosed(()=>{this.close()}),this}[Symbol.dispose]=this.close},v=class extends te({package:"@vortexjs/core",name:"Lifetime"},kn){};j=R,E=ue;w=te({name:"Fragment",package:"@vortexjs/core"},Symbol("Fragment"))});function En(){let e=O.current;if(!e)throw new Error("No context scope found, you should have one if you're rendering a component.");return e}function Re(){return En().streaming}function $n(){let e=O.current;if(!e)return null;return e}function An(){let e=$n();if(!e)return null;return e.streaming}function Le({renderer:e,root:n,component:r,context:i}){try{var t=On.default();t.u(re("Initial page render"));let u=new Sn(e,n),s=new v,c=u.render({node:r,hydration:e.getHydrationContext(n),lt:s,context:i??O.current??new O}),o=new Me(n,e);return o.children=[c],s}catch(u){t.e=u}finally{t.d()}}function Fe(e,n,r){if("renderer"in e)return Le(e);else return Le({renderer:e,root:n,component:r})}function Ge(){let e=An();return(n)=>{let r=j(void 0);async function i(){if(e)try{var t=Nn.default();t.u(e.markLoading()),r.set(await n)}catch(u){t.e=u}finally{t.d()}else r.set(await n)}return i(),r}}var wn,xn,_n=class{updateCallbackImmediate=0;updateCallbacks=new Set;loadingCounter=0;onDoneLoadingCallback=()=>{};onDoneLoading;constructor(){this.onDoneLoading=new Promise((e)=>{this.onDoneLoadingCallback=e})}onUpdate(e){return this.updateCallbacks.add(e),()=>{this.updateCallbacks.delete(e)}}markLoading(){let e=this;return this.loadingCounter++,{[Symbol.dispose](){e.loadingCounter--,e.updated()}}}updated(){if(this.updateCallbackImmediate)xn(this.updateCallbackImmediate);let e=this;this.updateCallbackImmediate=wn(()=>{e.updateCallbackImmediate=0;for(let n of e.updateCallbacks)n();if(e.loadingCounter===0)e.onDoneLoadingCallback()})}},O=class e{contexts={};streaming=new _n;fork(){let n=new e;return n.contexts={...this.contexts},n}addContext(n,r){this.contexts[n]=r}static current=null;static setCurrent(n){let r=e.current;return e.current=n,{[Symbol.dispose](){e.current=r}}}},Pe="~vortex:intrinsic",In,M=class{_children=[];parent=null;rendererNode=null;get children(){return this._children}set children(e){this._children=e;for(let n of e)n.parent=this;this.onChildrenChanged()}get flatChildren(){let e=[];function n(r){if(r instanceof S)for(let i of r.children)n(i);else e.push(r)}for(let r of this.children)n(r);return e}},S,qe,ze,Me,fe,ce,Sn=class{constructor(e,n){this.renderer=e,this.root=n}render({node:e,hydration:n,lt:r,context:i}){if(e===void 0||e===null)return new S;if(Array.isArray(e))return this.render({node:{type:"fragment",children:e},hydration:n,lt:r,context:i});switch(e.type){case"fragment":{let s=new S;return s.children=e.children.map((c)=>this.render({node:c,hydration:n,lt:r,context:i})),s}case"text":return new qe(e.value.toString(),this.renderer,n,i);case"element":{let s=new ze(e.name,this.renderer,n),c=this.renderer.getHydrationContext(s.rendererNode??m());s.children=e.children.map((l)=>this.render({node:l,hydration:c,lt:r,context:i}));for(let[l,a]of Object.entries(e.attributes))a.subscribe((f)=>{s.setAttribute(l,f)}).cascadesFrom(r);for(let[l,a]of Object.entries(e.bindings))this.renderer.bindValue(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.eventHandlers))this.renderer.addEventListener(s.rendererNode??m(),l,a).cascadesFrom(r);for(let[l,a]of Object.entries(e.styles))a.subscribe((f)=>{this.renderer.setStyle(s.rendererNode??m(),l,f)}).cascadesFrom(r);let o=[e.use].flat();for(let l of o)l(s.rendererNode??m());return s}case"component":try{var t=ce.default();t.u(v.changeHookLifetime(r)),t.u(O.setCurrent(i)),t.u(re(`Rendering ${e.impl.name}`));let s=e.impl;if(Pe in s&&typeof s[Pe]==="string"){let o=this.renderer.implementations?.find((l)=>l.intrinsic===s);if(o)s=o.implementation}let c=s(e.props);return this.render({node:c,hydration:n,lt:r,context:i})}catch(s){t.e=s}finally{t.d()}case"dynamic":{let s=new S;return oe((c,{lifetime:o})=>{let l=this.render({node:c(e.value),hydration:n,lt:o,context:i});s.children=[l]},void 0,r),s}case"list":{new S;let s=new Map,c=new S,o="";return oe((l)=>{let a=l(e.items),f=a.map((g,A)=>e.getKey(g,A));for(let g of s.keys())if(!f.includes(g))(s.get(g)??m()).lifetime.close(),s.delete(g);for(let g of f)if(!s.has(g))try{var p=ce.default();let A=a[f.indexOf(g)],sn=R(A),Y=new v;p.u(v.changeHookLifetime(Y));let un=this.render({node:e.renderItem(A,f.indexOf(g)),hydration:n,lt:Y,context:i});s.set(g,{node:un,item:sn,lifetime:Y})}catch(A){p.e=A}finally{p.d()}let h=f.join("|||");if(h!==o)o=h,c.children=f.map((g)=>(s.get(g)??m()).node)}),c}case"context":try{var u=ce.default();let s=i.fork();return u.u(O.setCurrent(s)),s.addContext(e.id,e.value),this.render({node:e.children,hydration:n,lt:r,context:s})}catch(s){u.e=s}finally{u.d()}default:Ne(e,`No rendering implementation for ${JSON.stringify(e)}`)}}},On,Nn;var F=d(()=>{Te();Z();b();b();wn=globalThis.setImmediate??((e,...n)=>{return setTimeout(e,0,...n)}),xn=globalThis.clearImmediate??((e)=>{clearTimeout(e)});In={};je(In,{FLElement:()=>ze,FLFragment:()=>S,FLNode:()=>M,FLPortal:()=>Me,FLText:()=>qe});S=class extends M{onChildrenChanged(){this.parent?.onChildrenChanged()}},qe=class extends M{_text;get text(){return this._text}set text(e){this._text=e,this.renderer.setTextContent(this.rendererNode??m(),e)}constructor(e,n,r,i){super();this.renderer=n,this._text=e,this.rendererNode=n.createTextNode(r,i),n.setTextContent(this.rendererNode,e)}onChildrenChanged(){this.parent?.onChildrenChanged()}},ze=class extends M{setAttribute(e,n){this.renderer.setAttribute(this.rendererNode??m(),e,n)}constructor(e,n,r){super();this.tag=e,this.renderer=n,this.rendererNode=n.createNode(e,r)}onChildrenChanged(){let e=this.flatChildren.map((n)=>n.rendererNode??m());this.renderer.setChildren(this.rendererNode??m(),e)}},Me=class extends M{constructor(e,n){super();this.target=e,this.renderer=n}onChildrenChanged(){this.renderer.setChildren(this.target,this.flatChildren.map((e)=>e.rendererNode??m()))}},fe=De({"../../node_modules/@oxc-project/runtime/src/helpers/usingCtx.js":(e,n)=>{function r(){var i=typeof SuppressedError=="function"?SuppressedError:function(c,o){var l=Error();return l.name="SuppressedError",l.error=c,l.suppressed=o,l},t={},u=[];function s(c,o){if(o!=null){if(Object(o)!==o)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(c)var l=o[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(l===void 0&&(l=o[Symbol.dispose||Symbol.for("Symbol.dispose")],c))var a=l;if(typeof l!="function")throw new TypeError("Object is not disposable.");a&&(l=function f(){try{a.call(o)}catch(p){return Promise.reject(p)}}),u.push({v:o,d:l,a:c})}else c&&u.push({d:o,a:c});return o}return{e:t,u:s.bind(null,!1),a:s.bind(null,!0),d(){var c,o=this.e,l=0;function a(){for(;c=u.pop();)try{if(!c.a&&l===1)return l=0,u.push(c),Promise.resolve().then(a);if(c.d){var p=c.d.call(c.v);if(c.a)return l|=2,Promise.resolve(p).then(a,f)}else l|=1}catch(h){return f(h)}if(l===1)return o!==t?Promise.reject(o):Promise.resolve();if(o!==t)throw o}function f(p){return o=o!==t?new i(p,o):p,a()}return a()}}}n.exports=r,n.exports.__esModule=!0,n.exports.default=n.exports}}),ce=K(fe(),1),On=K(fe(),1);Nn=K(fe(),1)});function pe(e,n){let r=n.split("/").map((t)=>t.trim()).filter((t)=>t!=="");function i(t,u,s,c){if(t===e.length&&u===r.length)return{matched:!0,params:{...s},spreads:{...c}};if(t===e.length||u>r.length)return{matched:!1};let o=e[t]??m();if(o.type==="static"){if(u>=r.length||r[u]!==o.match)return{matched:!1};return i(t+1,u+1,s,c)}else if(o.type==="slug"){if(u>=r.length)return{matched:!1};let l={...s,[o.name]:r[u]};return i(t+1,u+1,l,c)}else if(o.type==="spread"){for(let l=0;l<=r.length-u;l++){let a={...c,[o.name]:r.slice(u,u+l)},f=i(t+1,u+l,s,a);if(f.matched)return f}return{matched:!1}}return{matched:!1}}return i(0,0,{},{})}var Ue=d(()=>{b();F();b()});function x(e,n){let{children:r,...i}=n||{};if(e===w)return{type:"fragment",children:$(r)};if(typeof e==="string")return z(e,i,r);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(r)}};throw new Error(`Invalid JSX type: ${e}`)}var ye;var We=d(()=>{Z();ye=x});var Je=d(()=>{We()});function Cn(){return E((e)=>{return new URL(e(G)).pathname})}function Dn(){if(typeof window==="undefined")return;G.subscribe((e)=>{if(window.location.href!==e)window.history.pushState({},"",e)},{callInitially:!1}),window.addEventListener("popstate",()=>{G.set(window.location.href)}),document.addEventListener("click",(e)=>{let r=e.composedPath().find((i)=>i instanceof HTMLAnchorElement);if(r?.href){let i=new URL(r.href,D(G));if(i.origin!==window.location.origin)return;e.preventDefault(),G.set(i.href)}})}function jn({pathname:e,props:n,loaders:r}){if("location"in globalThis)Dn();Re();let i=Ge(),t=e?j(e):Cn(),u=E((l)=>{let a=l(t);return n.routes.find((f)=>pe(f.matcher,a))}),s=E(async(l)=>{let a=l(u)??m(),f=[];for(let p of a.frames)f.push(await(r[p.index]??m())());return f}),c=le(E((l)=>{return i(l(s))})),o=E((l)=>{let a=x(w,{}),f=l(c);if(!f)return x("h1",{children:"loading"});for(let p of f.toReversed())a=x(p,{children:a});return a});return ye("html",{children:[ye("head",{children:[x("link",{rel:"stylesheet",href:"/styles.css"}),x("script",{src:"/entrypoint-client.js",type:"module"})]}),x("body",{children:o})]})}async function Be({props:e,loaders:n,renderer:r,root:i,pathname:t,lifetime:u=new v,context:s}){e:if("window"in globalThis){let c=t??window.location.pathname,o=e.routes.find((l)=>pe(l.matcher,c));if(!o)break e;for(let l of o.frames)await(n[l.index]??m())()}Fe({context:s,renderer:r,root:i,component:x(jn,{pathname:t,props:e,loaders:n})}).cascadesFrom(u)}function Xe(e){return async function(n){return await e.impl(n)}}var G;var he=d(()=>{Ue();b();F();Je();b();G=j(typeof window!=="undefined"?window.location.href:"/")});function Rn(e){return{lang:e?.lang??ve?.lang,message:e?.message,abortEarly:e?.abortEarly??ve?.abortEarly,abortPipeEarly:e?.abortPipeEarly??ve?.abortPipeEarly}}function zn(e){return qn?.get(e)}function Fn(e){return Mn?.get(e)}function Un(e,n){return Gn?.get(e)?.get(n)}function Wn(e){let n=typeof e;if(n==="string")return`"${e}"`;if(n==="number"||n==="bigint"||n==="boolean")return`${e}`;if(n==="object"||n==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return n}function de(e,n,r,i,t){let u=t&&"input"in t?t.input:r.value,s=t?.expected??e.expects??null,c=t?.received??Wn(u),o={kind:e.kind,type:e.type,input:u,expected:s,received:c,message:`Invalid ${n}: ${s?`Expected ${s} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:t?.path,issues:t?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},l=e.kind==="schema",a=t?.message??e.message??Un(e.reference,o.lang)??(l?Fn(o.lang):null)??i.message??zn(o.lang);if(a!==void 0)o.message=typeof a==="function"?a(o):a;if(l)r.typed=!1;if(r.issues)r.issues.push(o);else r.issues=[o]}function Ze(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Rn())}}}function Jn(e,n,r){return typeof e.fallback==="function"?e.fallback(n,r):e.fallback}function Bn(e,n,r){return typeof e.default==="function"?e.default(n,r):e.default}function Q(e){return{kind:"schema",type:"number",reference:Q,expects:"number",async:!1,message:e,get "~standard"(){return Ze(this)},"~run"(n,r){if(typeof n.value==="number"&&!isNaN(n.value))n.typed=!0;else de(this,"type",n,r);return n}}}function ge(e,n){return{kind:"schema",type:"object",reference:ge,expects:"Object",async:!1,entries:e,message:n,get "~standard"(){return Ze(this)},"~run"(r,i){let t=r.value;if(t&&typeof t==="object"){r.typed=!0,r.value={};for(let u in this.entries){let s=this.entries[u];if(u in t||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){let c=u in t?t[u]:Bn(s),o=s["~run"]({value:c},i);if(o.issues){let l={type:"object",origin:"value",input:t,key:u,value:c};for(let a of o.issues){if(a.path)a.path.unshift(l);else a.path=[l];r.issues?.push(a)}if(!r.issues)r.issues=o.issues;if(i.abortEarly){r.typed=!1;break}}if(!o.typed)r.typed=!1;r.value[u]=o.value}else if(s.fallback!==void 0)r.value[u]=Jn(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"){if(de(this,"key",r,i,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:t,key:u,value:t[u]}]}),i.abortEarly)break}}}else de(this,"type",r,i);return r}}}var ve,qn,Mn,Gn;var Qe=()=>{};function T(e,n,r,i,t,u){let{children:s,...c}=n||{};if(e===w)return{type:"fragment",children:$(s),...t};if(typeof e==="string")return z(e,c,s,t);if(typeof e==="function")return{type:"component",impl:e,props:{...n??{},children:$(s)},...t};throw new Error(`Invalid JSX type: ${e}`)}var Ye=d(()=>{Z()});var be=d(()=>{Ye()});var Kn,en=function(){return T(w,{children:[T("h1",{class:"text-4xl font-bold",children:["Welcome to Wormhole, ",Object.entries(globalThis).length]},void 0,!0,void 0,this),T("p",{children:["This is an example app, go to the"," ",T("a",{href:"/docs/tada",children:"docs"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T("button",{"on:click":async()=>{console.log(await Kn({a:1,b:2}))},children:"add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},Vn=function({a:e,b:n}){return e+n},Hn;var nn=d(()=>{Qe();he();be();Kn=Xe({schema:Hn,impl:Vn,endpoint:"/api/add",method:"GET",isQuery:!0}),Hn=ge({a:Q(),b:Q()})});var rn={};ln(rn,{$d_109_720:()=>en});var tn=d(()=>{nn()});he();F();b();F();b();function Tn(e){return"tagName"in e?e.tagName:"Text"}function Pn(){return{html:"",write(e){this.html+=e},lastType:""}}function Ke(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function me(e,n=Pn()){let r=Tn(e);if(r==="Text"&&n.lastType==="Text")n.write("");if(n.lastType=r,"tagName"in e){n.write("<"),n.write(e.tagName);for(let[i,t]of Object.entries(e.attributes)){if(t===void 0)continue;n.write(` ${i}="${Ke(t)}"`)}n.write(">");for(let i of e.children)me(i,n);n.write("")}if("content"in e)n.write(Ke(e.content.toString()));return n.html}function Ln(e){return e.split(/(?=[A-Z])/).map((r)=>r.toLowerCase()).join("-")}function Ve(){return{createNode(e,n){return{tagName:e,attributes:{},children:[],parent:void 0}},setAttribute(e,n,r){if(!("tagName"in e))throw new Error("Cannot set attribute on a text node");e.attributes[n]=r},createTextNode(e){return{content:"",parent:void 0}},setTextContent(e,n){if(!("content"in e))throw new Error("Cannot set text content on a non-text node");e.content=n},setChildren(e,n){if(!("children"in e))throw new Error("Cannot set children on a text node");e.children=n;for(let r of n)r.parent=e},getHydrationContext(e){return},addEventListener(e,n,r){return new v},bindValue(e,n,r){return new v},setStyle(e,n,r){if(!("attributes"in e))throw new Error("Cannot set style on a text node");let i=e.attributes.style??"";i+=`${Ln(n)}: ${r};`,e.attributes.style=i}}}function He(){return{tagName:"html",attributes:{},children:[],parent:void 0,fixedIdent:"document.documentElement"}}var Zn=JSON.parse('{"routes":[{"matcher":[],"frames":[{"index":0}],"is404":false}]}'),Qn=[async()=>(await Promise.resolve().then(() => (tn(),rn))).$d_109_720];async function Yn(e){let r=new URL(e.url).pathname,i=Ve(),t=He(),u=new v;try{await Be({props:Zn,loaders:Qn,renderer:i,root:t,pathname:r,context:{},lifetime:u});let s=me(t);return new Response(s,{status:200,headers:{"Content-Type":"text/html"}})}catch(s){return console.error("Rendering error:",s),new Response("Internal Server Error",{status:500})}finally{u.close()}}export{Yn as default}; diff --git a/packages/example-wormhole/.vercel/output/static/client.js b/packages/example-wormhole/.vercel/output/static/client.js deleted file mode 100644 index 5e63206..0000000 --- a/packages/example-wormhole/.vercel/output/static/client.js +++ /dev/null @@ -1 +0,0 @@ -import{e as o,f as l,g as u,h as a,i as m,m as L}from"./chunk-xscfbet7.js";function f(s){let e={htmlFor:"for",className:"class",tabIndex:"tabindex",ariaDescribedBy:"aria-describedby"};if(s in e)return e[s]??u();return s.split(/(?=[A-Z])/).map((n)=>n.toLowerCase()).join("-")}function d(){function s(e,t,n){if(!e)return null;while(e.unclaimedNodes.length>0){let i=e.unclaimedNodes.shift();if(i&&t(i)&&(!n||n(i)))return i}return null}return{createNode(e,t){let n=e.toLowerCase(),i=s(t,(r)=>r instanceof HTMLElement,(r)=>r.tagName.toLowerCase()===n)??document.createElement(n);for(let r=0;rt instanceof Text)??document.createTextNode("")},setTextContent(e,t){if(e instanceof Text)e.data=t;else if(e instanceof HTMLElement)e.textContent=t},setChildren(e,t){if(e instanceof HTMLElement)e.replaceChildren(...t)},getHydrationContext(e){return{unclaimedNodes:Array.from(e.childNodes)}},addEventListener(e,t,n){let i=new a;if(e instanceof HTMLElement){let r=(c)=>{n(c)};e.addEventListener(t,r),i.onClosed(()=>e.removeEventListener(t,r))}else console.warn(`Cannot add event listener to non-HTMLElement node: ${e}`);return i},bindValue(e,t,n){let i=new a;if(e[t]=m(n),t==="value"){let r=function(){n.set(e[t])};e.addEventListener("input",r),i.onClosed(()=>e.removeEventListener("input",r))}if(t==="checked"){let r=function(){n.set(e[t])};e.addEventListener("change",r),i.onClosed(()=>e.removeEventListener("change",r))}return i},setStyle(e,t,n){if(e instanceof HTMLElement)e.style[t]=n}}}var E=JSON.parse('{"routes":[{"matcher":[],"frames":[{"index":0}],"is404":false},{"matcher":[{"type":"static","match":"docs"},{"type":"spread","name":"page"}],"frames":[{"index":1},{"index":2}],"is404":false},{"matcher":[{"type":"spread","name":"404"}],"frames":[{"index":1},{"index":3}],"is404":true}]}');function T(s){let e=[async()=>(await import("./chunk-vftkak7x.js")).$d_109_720,async()=>(await import("./chunk-v4cdhs89.js")).$d_732_888,async()=>(await import("./chunk-wty2rdqp.js")).$d_1050_1265,async()=>(await import("./chunk-x84yccxc.js")).$d_902_1009],t=d(),n=document.documentElement;return L({props:E,loaders:e,renderer:t,root:n,pathname:s.pathname,context:s.context,lifetime:s.lifetime??new a})}window.wormhole={};window.wormhole.hydrate=T;document.addEventListener("DOMContentLoaded",()=>{let s=window.location.pathname;T({pathname:s,context:{},lifetime:new a})}); diff --git a/packages/example-wormhole/.vercel/output/static/styles.css b/packages/example-wormhole/.vercel/output/static/styles.css deleted file mode 100644 index d308d57..0000000 --- a/packages/example-wormhole/.vercel/output/static/styles.css +++ /dev/null @@ -1 +0,0 @@ -/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties;@layer theme,base,components,utilities;@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--text-4xl:2.25rem;--text-4xl--line-height:calc(2.5/2.25);--font-weight-bold:700;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop,::file-selector-button{box-sizing:border-box;margin:0;padding:0;border:0 solid}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;tab-size:4;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea,::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;border-radius:0;background-color:#0000;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports ( not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px){::placeholder{color:currentColor}@supports (color: color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit,::-webkit-datetime-edit-year-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-meridiem-field{padding-block:0}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]),::file-selector-button{appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}}@property --tw-font-weight{syntax:"*";inherits:false}@layer properties{@supports ((-webkit-hyphens: none) and ( not (margin-trim: inline))) or ((-moz-orient: inline) and ( not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-font-weight:initial}}} From df3b3459312a4951ff72312bda7207a6c274fcfd Mon Sep 17 00:00:00 2001 From: andylovescode Date: Fri, 22 Aug 2025 11:26:58 -0700 Subject: [PATCH 10/15] Vercel: Make Vercel support work properly --- .gitignore | 1 + .../wormhole/src/build/adapters/vercel.ts | 56 ++++++------------- packages/wormhole/src/build/build.ts | 11 ++-- 3 files changed, 25 insertions(+), 43 deletions(-) diff --git a/.gitignore b/.gitignore index adacbf2..8bddff6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ **/node_modules **/dist **/.turbo +**/.vercel diff --git a/packages/wormhole/src/build/adapters/vercel.ts b/packages/wormhole/src/build/adapters/vercel.ts index c4ef067..967040d 100644 --- a/packages/wormhole/src/build/adapters/vercel.ts +++ b/packages/wormhole/src/build/adapters/vercel.ts @@ -87,25 +87,25 @@ export function VercelAdapter(): VercelAdapter { codegenSource += `window.wormhole = {};`; codegenSource += `window.wormhole.hydrate = main;`; - + // Add client-side hydration initialization codegenSource += `document.addEventListener('DOMContentLoaded', () => {`; codegenSource += `const pathname = window.location.pathname;`; codegenSource += `main({ pathname, context: {}, lifetime: new Lifetime() });`; codegenSource += `});`; - const filename = "client-bundle"; - const path = await build.writeCodegenned(filename, codegenSource); + const path = await build.writeCodegenned("entrypoint-client", codegenSource); const bundled = await build.bundle({ target: "client", inputPaths: { - main: path, + app: path, }, + outdir: join(build.project.projectDir, ".vercel", "output", "static"), dev: false }); - return bundled.outputs.main; + return bundled.outputs.app; }, async buildCSS(build: Build) { @@ -126,12 +126,13 @@ export function VercelAdapter(): VercelAdapter { const bundled = await build.bundle({ target: "client", inputPaths: { - main: cssPath, + app: cssPath, }, + outdir: join(build.project.projectDir, ".vercel", "output", "static"), dev: false }); - return bundled.outputs.main; + return bundled.outputs.app; }, async buildRouteFunction(build: Build, route: BuildRoute) { @@ -144,10 +145,10 @@ export function VercelAdapter(): VercelAdapter { if (route.type === "api") { // API route function codegenSource += `import {INTERNAL_tryHandleAPI} from "@vortexjs/wormhole";`; - + const reexporterName = "proxy-" + Bun.hash(`${route.impl.file}-${route.impl.name}`).toString(36); const implPath = await build.writeCodegenned(reexporterName, `export { ${JSON.stringify(route.impl.name)} } from ${JSON.stringify(route.impl.file)}`); - + const schemaName = "proxy-" + Bun.hash(`${route.schema.file}-${route.schema.name}`).toString(36); const schemaPath = await build.writeCodegenned(schemaName, `export { ${JSON.stringify(route.schema.name)} } from ${JSON.stringify(route.schema.file)}`); @@ -211,7 +212,7 @@ export function VercelAdapter(): VercelAdapter { codegenSource += `export default async function handler(request) {`; codegenSource += `const url = new URL(request.url);`; codegenSource += `const pathname = url.pathname;`; - + codegenSource += `const renderer = ssr();`; codegenSource += `const root = createHTMLRoot();`; codegenSource += `const lifetime = new Lifetime();`; @@ -332,7 +333,7 @@ export function VercelAdapter(): VercelAdapter { codegenSource += `export default async function handler(request) {`; codegenSource += `const url = new URL(request.url);`; codegenSource += `const pathname = url.pathname;`; - + // Handle API routes first codegenSource += `const apiResponse = await INTERNAL_tryHandleAPI(request, apis, apiLoaders);`; codegenSource += `if (apiResponse) {`; @@ -396,15 +397,8 @@ export function VercelAdapter(): VercelAdapter { await mkdir(functionsDir, { recursive: true }); // Build client bundle and CSS - const clientBundlePath = await this.buildClientBundle(build); - const cssBundlePath = await this.buildCSS(build); - - // Copy static assets to static directory - const staticClientPath = join(staticDir, "client.js"); - const staticCssPath = join(staticDir, "styles.css"); - - await Bun.write(staticClientPath, await Bun.file(clientBundlePath).text()); - await Bun.write(staticCssPath, await Bun.file(cssBundlePath).text()); + await this.buildClientBundle(build); + await this.buildCSS(build); // Build individual route functions const routeFunctions: string[] = []; @@ -433,10 +427,10 @@ export function VercelAdapter(): VercelAdapter { const catchAllPath = await this.buildCatchAllFunction(build); const catchAllDir = join(functionsDir, "index.func"); await mkdir(catchAllDir, { recursive: true }); - + const catchAllIndexPath = join(catchAllDir, "index.js"); await Bun.write(catchAllIndexPath, await Bun.file(catchAllPath).text()); - + const catchAllVcConfig = { runtime: "edge", entrypoint: "index.js" @@ -445,26 +439,12 @@ export function VercelAdapter(): VercelAdapter { // Create main config.json const routes = []; - - // Add routes for static assets - routes.push({ - src: "/client.js", - dest: "/static/client.js" - }); - routes.push({ - src: "/entrypoint-client.js", - dest: "/static/client.js" - }); - routes.push({ - src: "/styles.css", - dest: "/static/styles.css" - }); // Add routes for each specific route function for (const route of build.routes) { const routeId = printRoutePath(route.matcher).replace(/\[\.\.\.([^\]]+)\]/g, '[...$1]').replace(/\[([^\]]+)\]/g, '[$1]') || 'index'; const routePath = "/" + printRoutePath(route.matcher).replace(/\[\.\.\.([^\]]+)\]/g, '*').replace(/\[([^\]]+)\]/g, '*'); - + if (route.type === "api") { routes.push({ src: routePath, @@ -501,4 +481,4 @@ export function VercelAdapter(): VercelAdapter { }; } }; -} \ No newline at end of file +} diff --git a/packages/wormhole/src/build/build.ts b/packages/wormhole/src/build/build.ts index 4dbae55..63f2d37 100644 --- a/packages/wormhole/src/build/build.ts +++ b/packages/wormhole/src/build/build.ts @@ -73,11 +73,12 @@ export class Build { analyze = Build_analyze; async bundle( - { inputPaths, target, dev = false, noSplitting = false }: { + { inputPaths, target, dev = false, noSplitting = false, outdir = this.outputPath }: { inputPaths: Record, target: TargetLocation; dev?: boolean; noSplitting?: boolean; + outdir?: string; } ): Promise<{ outputs: Record; @@ -98,7 +99,7 @@ export class Build { plugins: [p], splitting: !noSplitting, entrypoints, - outdir: this.outputPath, + outdir, target: target === "server" ? "bun" : "browser", sourcemap: dev ? "inline" : "none", naming: { @@ -113,14 +114,14 @@ export class Build { const name = basename(entry as string); const fileName = name.slice(0, name.lastIndexOf(".")); const originalExt = extname(entry as string); - + // Use correct extension based on input file type let outputExt = ".js"; // default if (originalExt === ".css") { outputExt = ".css"; } - - const path = join(this.outputPath, fileName + outputExt); + + const path = join(outdir, fileName + outputExt); results[id as Files] = path; } From 83869b56276c4af0b3b1d3a1a6a88bb9aee6afc1 Mon Sep 17 00:00:00 2001 From: andylovescode Date: Sat, 23 Aug 2025 18:37:06 -0700 Subject: [PATCH 11/15] Vercel: Fix vercel builds --- packages/example-wormhole/package.json | 44 +- .../src/features/home/index.tsx | 109 +-- packages/vortex-core/src/context.ts | 3 + .../wormhole/src/build/adapters/vercel.ts | 745 +++++++----------- packages/wormhole/src/dev/dev-server.ts | 271 +++---- packages/wormhole/src/runtime/index.ts | 1 + packages/wormhole/src/runtime/stream.ts | 29 + 7 files changed, 556 insertions(+), 646 deletions(-) create mode 100644 packages/wormhole/src/runtime/stream.ts diff --git a/packages/example-wormhole/package.json b/packages/example-wormhole/package.json index 2e2412e..58b6580 100644 --- a/packages/example-wormhole/package.json +++ b/packages/example-wormhole/package.json @@ -1,24 +1,24 @@ { - "name": "@vortexjs/example-wormhole", - "module": "index.ts", - "type": "module", - "license": "MIT-0", - "private": true, - "devDependencies": { - "@types/bun": "catalog:" - }, - "dependencies": { - "@vortexjs/core": "workspace:*", - "@vortexjs/dom": "workspace:*", - "@vortexjs/wormhole": "workspace:*", - "tailwindcss": "catalog:", - "valibot": "catalog:" - }, - "scripts": { - "dev": "wormhole dev", - "build": "wormhole build vercel" - }, - "peerDependencies": { - "typescript": "catalog:" - } + "name": "@vortexjs/example-wormhole", + "module": "index.ts", + "type": "module", + "license": "MIT-0", + "private": true, + "devDependencies": { + "@types/bun": "catalog:" + }, + "dependencies": { + "@vortexjs/core": "workspace:*", + "@vortexjs/dom": "workspace:*", + "@vortexjs/wormhole": "workspace:*", + "tailwindcss": "catalog:", + "valibot": "catalog:" + }, + "scripts": { + "dev": "wormhole dev", + "vbuild": "wormhole build vercel" + }, + "peerDependencies": { + "typescript": "catalog:" + } } diff --git a/packages/example-wormhole/src/features/home/index.tsx b/packages/example-wormhole/src/features/home/index.tsx index e7715a7..d11861e 100644 --- a/packages/example-wormhole/src/features/home/index.tsx +++ b/packages/example-wormhole/src/features/home/index.tsx @@ -1,62 +1,67 @@ +import { useAwait } from "@vortexjs/core"; import route, { query } from "@vortexjs/wormhole/route"; import * as v from "valibot"; route("/", { - page() { - return ( - <> -

- Welcome to Wormhole, {Object.entries(globalThis).length} -

-

- This is an example app, go to the{" "} - docs -

- - - ); - }, - layout({ children }) { - return ( - <> - Wormhole Example - {children} - - ); - }, - notFound() { - return ( - <> -

404 not found

- - ) - } + page() { + const pause = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)); + const awaited = useAwait(); + + return ( + <> +

+ Welcome to Wormhole, {Object.entries(globalThis).length} +

+

+ This is an example app, go to the{" "} + docs +

+ + + ); + }, + layout({ children }) { + return ( + <> + Wormhole Example + {children} + + ); + }, + notFound() { + return ( + <> +

404 not found

+ + ) + } }); -route("/docs/[...page]", { - page({ page }) { - return ( - <> -

Documentation for {page.join(", ")}

-

This is the documentation page for {page.join(", ")}.

- - ); - }, +route("/docs", { + page({ }) { + const page = "introduction"; + return ( + <> +

Documentation for {page}

+

This is the documentation page for {page}.

+ + ); + }, }); export const add = query("/api/add", { - schema: v.object({ - a: v.number(), - b: v.number() - }), - impl({ a, b }) { - return a + b; - } + schema: v.object({ + a: v.number(), + b: v.number() + }), + impl({ a, b }) { + return a + b; + } }) diff --git a/packages/vortex-core/src/context.ts b/packages/vortex-core/src/context.ts index 233e9a9..0872794 100644 --- a/packages/vortex-core/src/context.ts +++ b/packages/vortex-core/src/context.ts @@ -63,10 +63,12 @@ export class StreamingContext { const self = this; this.loadingCounter++; + console.log("markLoading", this.loadingCounter); return { [Symbol.dispose]() { self.loadingCounter--; + console.log("unmarkLoading", self.loadingCounter); self.updated(); }, }; @@ -88,6 +90,7 @@ export class StreamingContext { } if (self.loadingCounter === 0) { + console.log("done loading"); self.onDoneLoadingCallback(); } }) as unknown as number; diff --git a/packages/wormhole/src/build/adapters/vercel.ts b/packages/wormhole/src/build/adapters/vercel.ts index 967040d..b41ca18 100644 --- a/packages/wormhole/src/build/adapters/vercel.ts +++ b/packages/wormhole/src/build/adapters/vercel.ts @@ -3,77 +3,80 @@ import type { Build, BuildAdapter, TargetLocation, BuildRoute } from "../build"; import type { Export } from "~/local/export"; import { addTask } from "~/cli/statusboard"; import { join, dirname } from "node:path"; -import { mkdir, writeFile } from "node:fs/promises"; -import { printRoutePath } from "../router"; +import { mkdir, rmdir } from "node:fs/promises"; +import { printRoutePath, type RoutePath } from "../router"; export interface VercelAdapterResult { - outputDir: string; - staticDir: string; - functionsDir: string; - configFile: string; + outputDir: string; + staticDir: string; + functionsDir: string; + configFile: string; } export interface VercelAdapter extends BuildAdapter { - buildClientBundle(build: Build): Promise; - buildCSS(build: Build): Promise; - buildRouteFunction(build: Build, route: BuildRoute): Promise; - buildCatchAllFunction(build: Build): Promise; + buildClientBundle(build: Build): Promise; + buildCSS(build: Build): Promise; + buildRouteFunction(build: Build, route: BuildRoute): Promise; +} + +export function getRouteId(matcher: RoutePath) { + return printRoutePath(matcher).replaceAll(/\\|\//gi, "-").replaceAll(" ", "-") || 'index'; } export function VercelAdapter(): VercelAdapter { - return { - async buildClientBundle(build: Build) { - using _task = addTask({ - name: "Building client bundle for Vercel" - }); + return { + async buildClientBundle(build: Build) { + using _task = addTask({ + name: "Building client bundle for Vercel" + }); - let codegenSource = ""; + let codegenSource = ""; - codegenSource += `import { INTERNAL_entrypoint } from "@vortexjs/wormhole";`; - codegenSource += `import { Lifetime } from "@vortexjs/core";`; - codegenSource += `import { html } from "@vortexjs/dom";`; + codegenSource += `import { INTERNAL_entrypoint } from "@vortexjs/wormhole";`; + codegenSource += `import { Lifetime } from "@vortexjs/core";`; + codegenSource += `import { html } from "@vortexjs/dom";`; - const imports: Export[] = []; + const imports: Export[] = []; - function getExportIndex(exp: Export): number { - const index = imports.findIndex(x => x.file === exp.file && x.name === exp.name); - if (index === -1) { - imports.push(exp); - return imports.length - 1; - } - return index; - } + function getExportIndex(exp: Export): number { + const index = imports.findIndex(x => x.file === exp.file && x.name === exp.name); + if (index === -1) { + imports.push(exp); + return imports.length - 1; + } + return index; + } - const entrypointProps: EntrypointProps = { - routes: build.routes.filter(x => x.type === "route").map(x => ({ - matcher: x.matcher, - frames: x.frames.map((frame) => ({ - index: getExportIndex(frame), - })), - is404: x.is404, - })) - }; + const entrypointProps: EntrypointProps = { + routes: build.routes.filter(x => x.type === "route").map(x => ({ + matcher: x.matcher, + frames: x.frames.map((frame) => ({ + index: getExportIndex(frame), + })), + is404: x.is404, + })) + }; - codegenSource += `const entrypointProps = JSON.parse(${JSON.stringify(JSON.stringify(entrypointProps))});`; + codegenSource += `const entrypointProps = JSON.parse(${JSON.stringify(JSON.stringify(entrypointProps))});`; - codegenSource += `function main(props) {`; + codegenSource += `function main(props) {`; - codegenSource += 'const loaders = ['; + codegenSource += 'const loaders = ['; - for (const exp of imports) { - const reexporterName = "proxy-" + Bun.hash(`${exp.file}-${exp.name}`).toString(36); + for (const exp of imports) { + const reexporterName = "proxy-" + Bun.hash(`${exp.file}-${exp.name}`).toString(36); - const path = await build.writeCodegenned(reexporterName, `export { ${JSON.stringify(exp.name)} } from ${JSON.stringify(exp.file)}`); + const path = await build.writeCodegenned(reexporterName, `export { ${JSON.stringify(exp.name)} } from ${JSON.stringify(exp.file)}`); - codegenSource += `(async () => (await import(${JSON.stringify(path)}))[${JSON.stringify(exp.name)}]),`; - } + codegenSource += `(async () => (await import(${JSON.stringify(path)}))[${JSON.stringify(exp.name)}]),`; + } - codegenSource += '];'; + codegenSource += '];'; - codegenSource += `const renderer = html();`; - codegenSource += `const root = document.documentElement;`; + codegenSource += `const renderer = html();`; + codegenSource += `const root = document.documentElement;`; - codegenSource += `return INTERNAL_entrypoint({ + codegenSource += `return INTERNAL_entrypoint({ props: entrypointProps, loaders, renderer, @@ -83,402 +86,266 @@ export function VercelAdapter(): VercelAdapter { lifetime: props.lifetime ?? new Lifetime(), });`; - codegenSource += `}`; - - codegenSource += `window.wormhole = {};`; - codegenSource += `window.wormhole.hydrate = main;`; - - // Add client-side hydration initialization - codegenSource += `document.addEventListener('DOMContentLoaded', () => {`; - codegenSource += `const pathname = window.location.pathname;`; - codegenSource += `main({ pathname, context: {}, lifetime: new Lifetime() });`; - codegenSource += `});`; - - const path = await build.writeCodegenned("entrypoint-client", codegenSource); - - const bundled = await build.bundle({ - target: "client", - inputPaths: { - app: path, - }, - outdir: join(build.project.projectDir, ".vercel", "output", "static"), - dev: false - }); - - return bundled.outputs.app; - }, - - async buildCSS(build: Build) { - using _task = addTask({ - name: "Building CSS for Vercel" - }); + codegenSource += `}`; + + codegenSource += `window.wormhole = {};`; + codegenSource += `window.wormhole.hydrate = main;`; - let codegenCSS = ""; - - const appCSSPath = join(build.project.projectDir, "src", "app.css"); - - if (await Bun.file(appCSSPath).exists()) { - codegenCSS += `@import "${appCSSPath}";`; - } - - const cssPath = await build.writeCodegenned("styles", codegenCSS, "css"); - - const bundled = await build.bundle({ - target: "client", - inputPaths: { - app: cssPath, - }, - outdir: join(build.project.projectDir, ".vercel", "output", "static"), - dev: false - }); - - return bundled.outputs.app; - }, - - async buildRouteFunction(build: Build, route: BuildRoute) { - using _task = addTask({ - name: `Building function for route: ${printRoutePath(route.matcher)}` - }); - - let codegenSource = ""; - - if (route.type === "api") { - // API route function - codegenSource += `import {INTERNAL_tryHandleAPI} from "@vortexjs/wormhole";`; - - const reexporterName = "proxy-" + Bun.hash(`${route.impl.file}-${route.impl.name}`).toString(36); - const implPath = await build.writeCodegenned(reexporterName, `export { ${JSON.stringify(route.impl.name)} } from ${JSON.stringify(route.impl.file)}`); - - const schemaName = "proxy-" + Bun.hash(`${route.schema.file}-${route.schema.name}`).toString(36); - const schemaPath = await build.writeCodegenned(schemaName, `export { ${JSON.stringify(route.schema.name)} } from ${JSON.stringify(route.schema.file)}`); - - codegenSource += `const apis = [{ - matcher: ${JSON.stringify(route.matcher)}, - impl: 0, - schema: 1, - method: ${JSON.stringify(route.method)}, - }];`; - - codegenSource += `const loaders = [`; - codegenSource += `(async () => (await import(${JSON.stringify(implPath)}))[${JSON.stringify(route.impl.name)}]),`; - codegenSource += `(async () => (await import(${JSON.stringify(schemaPath)}))[${JSON.stringify(route.schema.name)}]),`; - codegenSource += `];`; - - codegenSource += `export default async function handler(request) {`; - codegenSource += `const response = await INTERNAL_tryHandleAPI(request, apis, loaders);`; - codegenSource += `return response || new Response("Not Found", { status: 404 });`; - codegenSource += `}`; - } else { - // Page route function - codegenSource += `import { INTERNAL_entrypoint } from "@vortexjs/wormhole";`; - codegenSource += `import { Lifetime } from "@vortexjs/core";`; - codegenSource += `import { createHTMLRoot, ssr, printHTML } from "@vortexjs/ssr";`; - - const imports: Export[] = []; - - function getExportIndex(exp: Export): number { - const index = imports.findIndex(x => x.file === exp.file && x.name === exp.name); - if (index === -1) { - imports.push(exp); - return imports.length - 1; - } - return index; - } - - const entrypointProps: EntrypointProps = { - routes: [{ - matcher: route.matcher, - frames: route.frames.map((frame) => ({ - index: getExportIndex(frame), - })), - is404: route.is404, - }] - }; - - codegenSource += `const entrypointProps = JSON.parse(${JSON.stringify(JSON.stringify(entrypointProps))});`; - - codegenSource += 'const loaders = ['; - - for (const exp of imports) { - const reexporterName = "proxy-" + Bun.hash(`${exp.file}-${exp.name}`).toString(36); - - const path = await build.writeCodegenned(reexporterName, `export { ${JSON.stringify(exp.name)} } from ${JSON.stringify(exp.file)}`); - - codegenSource += `(async () => (await import(${JSON.stringify(path)}))[${JSON.stringify(exp.name)}]),`; - } - - codegenSource += '];'; - - codegenSource += `export default async function handler(request) {`; - codegenSource += `const url = new URL(request.url);`; - codegenSource += `const pathname = url.pathname;`; - - codegenSource += `const renderer = ssr();`; - codegenSource += `const root = createHTMLRoot();`; - codegenSource += `const lifetime = new Lifetime();`; - codegenSource += `try {`; - codegenSource += `await INTERNAL_entrypoint({ + // Add client-side hydration initialization + codegenSource += `document.addEventListener('DOMContentLoaded', () => {`; + codegenSource += `const pathname = window.location.pathname;`; + codegenSource += `main({ pathname, context: {}, lifetime: new Lifetime() });`; + codegenSource += `});`; + + const path = await build.writeCodegenned("entrypoint-client", codegenSource); + + const bundled = await build.bundle({ + target: "client", + inputPaths: { + app: path, + }, + outdir: join(build.project.projectDir, ".vercel", "output", "static"), + dev: false + }); + + return bundled.outputs.app; + }, + + async buildCSS(build: Build) { + using _task = addTask({ + name: "Building CSS for Vercel" + }); + + let codegenCSS = ""; + + const appCSSPath = join(build.project.projectDir, "src", "app.css"); + + if (await Bun.file(appCSSPath).exists()) { + codegenCSS += `@import "${appCSSPath}";`; + } + + const cssPath = await build.writeCodegenned("styles", codegenCSS, "css"); + + const bundled = await build.bundle({ + target: "client", + inputPaths: { + app: cssPath, + }, + outdir: join(build.project.projectDir, ".vercel", "output", "static"), + dev: false + }); + + return bundled.outputs.app; + }, + + async buildRouteFunction(build: Build, route: BuildRoute) { + using _task = addTask({ + name: `Building function for route: ${printRoutePath(route.matcher)}` + }); + + let codegenSource = ""; + + if (route.type === "api") { + // API route function + codegenSource += `import {INTERNAL_tryHandleAPI} from "@vortexjs/wormhole";`; + + codegenSource += `import { ${JSON.stringify(route.schema.name)} as schema } from ${JSON.stringify(route.schema.file)};`; + codegenSource += `import { ${JSON.stringify(route.impl.name)} as impl } from ${JSON.stringify(route.impl.file)};`; + codegenSource += `import { SKL } from "@vortexjs/common";`; + + codegenSource += `export default async function handler(request) {`; + codegenSource += `const text = `; + if (route.method === "GET") { + codegenSource += `new URL(request.url).searchParams.get("props")`; + } else { + codegenSource += `await props.text()`; + } + codegenSource += `;`; + + codegenSource += `if (!text) { return new Response("Missing body", { status: 400 }); }`; + + codegenSource += `let body;`; + codegenSource += `try { body = SKL.parse(text); } catch (e) { return new Response("Invalid SKL", { status: 400 }); }`; + + // check against standard schema + codegenSource += `const parsed = await schema["~standard"].validate(body);`; + + codegenSource += `if ("issues" in parsed && parsed.issues != null && parsed.issues.length > 0) {`; + codegenSource += `return new Response("Request did not match schema", { status: 400 })`; + codegenSource += `}`; + + codegenSource += `try {`; + codegenSource += `const result = await impl(parsed.value);`; + codegenSource += `return new Response(SKL.stringify(result), { status: 200, headers: { "Content-Type": "application/skl" } });`; + codegenSource += `} catch (e) {`; + codegenSource += `console.error(e);`; + codegenSource += `return new Response("Internal Server Error", { status: 500 });`; + codegenSource += `}`; + + codegenSource += `}`; + } else { + // Page route function + codegenSource += `import { INTERNAL_entrypoint, INTERNAL_createStreamUtility } from "@vortexjs/wormhole";`; + codegenSource += `import { Lifetime, ContextScope } from "@vortexjs/core";`; + codegenSource += `import { createHTMLRoot, ssr, printHTML, diffInto } from "@vortexjs/ssr";`; + + const imports: Export[] = []; + + function getExportIndex(exp: Export): number { + const index = imports.findIndex(x => x.file === exp.file && x.name === exp.name); + if (index === -1) { + imports.push(exp); + return imports.length - 1; + } + return index; + } + + const entrypointProps: EntrypointProps = { + routes: [{ + matcher: route.matcher, + frames: route.frames.map((frame) => ({ + index: getExportIndex(frame), + })), + is404: route.is404, + }] + }; + + codegenSource += `const entrypointProps = JSON.parse(${JSON.stringify(JSON.stringify(entrypointProps))});`; + + let idx = 0; + for (const exp of imports) { + const reexporterName = "proxy-" + Bun.hash(`${exp.file}-${exp.name}`).toString(36); + + const path = await build.writeCodegenned(reexporterName, `export { ${JSON.stringify(exp.name)} } from ${JSON.stringify(exp.file)}`); + + codegenSource += `import {${JSON.stringify(exp.name)} as imp${idx}} from ${JSON.stringify(path)};`; + idx++; + } + + codegenSource += 'const loaders = ['; + + idx = 0; + for (const exp of imports) { + codegenSource += `(()=>imp${idx}),`; + idx++; + } + + codegenSource += '];'; + + codegenSource += `export default async function handler(request) {`; + codegenSource += `const url = new URL(request.url);`; + codegenSource += `const pathname = url.pathname;`; + + codegenSource += `const renderer = ssr();`; + codegenSource += `const root = createHTMLRoot();`; + codegenSource += `const lifetime = new Lifetime();`; + codegenSource += `const context = new ContextScope();`; + codegenSource += `await INTERNAL_entrypoint({ props: entrypointProps, loaders, renderer, root, pathname, - context: {}, + context, lifetime, });`; - codegenSource += `const html = printHTML(root);`; - codegenSource += `return new Response(html, {`; - codegenSource += `status: 200,`; - codegenSource += `headers: { 'Content-Type': 'text/html' }`; - codegenSource += `});`; - codegenSource += `} catch (error) {`; - codegenSource += `console.error('Rendering error:', error);`; - codegenSource += `return new Response('Internal Server Error', { status: 500 });`; - codegenSource += `} finally {`; - codegenSource += `lifetime.close();`; - codegenSource += `}`; - codegenSource += `}`; - } - - const routeId = printRoutePath(route.matcher).replace(/\[\.\.\.([^\]]+)\]/g, '[...$1]').replace(/\[([^\]]+)\]/g, '[$1]') || 'index'; - const filename = `function-${route.type}-${routeId}`; - const path = await build.writeCodegenned(filename, codegenSource); - - const bundled = await build.bundle({ - target: "server", - inputPaths: { - main: path, - }, - dev: false, - noSplitting: true - }); - - return bundled.outputs.main; - }, - - async buildCatchAllFunction(build: Build) { - using _task = addTask({ - name: "Building catch-all function for Vercel" - }); - - let codegenSource = ""; - - codegenSource += `import { INTERNAL_entrypoint } from "@vortexjs/wormhole";`; - codegenSource += `import { Lifetime } from "@vortexjs/core";`; - codegenSource += `import { createHTMLRoot, ssr, printHTML } from "@vortexjs/ssr";`; - codegenSource += `import {INTERNAL_tryHandleAPI} from "@vortexjs/wormhole";`; - - const imports: Export[] = []; - const apiImports: Export[] = []; - - function getExportIndex(exp: Export): number { - const index = imports.findIndex(x => x.file === exp.file && x.name === exp.name); - if (index === -1) { - imports.push(exp); - return imports.length - 1; - } - return index; - } - - function getApiExportIndex(exp: Export): number { - const index = apiImports.findIndex(x => x.file === exp.file && x.name === exp.name); - if (index === -1) { - apiImports.push(exp); - return apiImports.length - 1; - } - return index; - } - - const pageRoutes = build.routes.filter(x => x.type === "route"); - const apiRoutes = build.routes.filter(x => x.type === "api"); - - const entrypointProps: EntrypointProps = { - routes: pageRoutes.map(x => ({ - matcher: x.matcher, - frames: x.frames.map((frame) => ({ - index: getExportIndex(frame), - })), - is404: x.is404, - })) - }; - - codegenSource += `const entrypointProps = JSON.parse(${JSON.stringify(JSON.stringify(entrypointProps))});`; - - // Page route loaders - codegenSource += 'const loaders = ['; - for (const exp of imports) { - const reexporterName = "proxy-" + Bun.hash(`${exp.file}-${exp.name}`).toString(36); - const path = await build.writeCodegenned(reexporterName, `export { ${JSON.stringify(exp.name)} } from ${JSON.stringify(exp.file)}`); - codegenSource += `(async () => (await import(${JSON.stringify(path)}))[${JSON.stringify(exp.name)}]),`; - } - codegenSource += '];'; - - // API configuration - codegenSource += `const apis = ${JSON.stringify(apiRoutes.map(x => ({ - matcher: x.matcher, - impl: getApiExportIndex(x.impl), - schema: getApiExportIndex(x.schema), - method: x.method, - })))};`; - - // API loaders - codegenSource += `const apiLoaders = [`; - for (const exp of apiImports) { - const reexporterName = "proxy-" + Bun.hash(`${exp.file}-${exp.name}`).toString(36); - const path = await build.writeCodegenned(reexporterName, `export { ${JSON.stringify(exp.name)} } from ${JSON.stringify(exp.file)}`); - codegenSource += `(async () => (await import(${JSON.stringify(path)}))[${JSON.stringify(exp.name)}]),`; - } - codegenSource += `];`; - - codegenSource += `export default async function handler(request) {`; - codegenSource += `const url = new URL(request.url);`; - codegenSource += `const pathname = url.pathname;`; - - // Handle API routes first - codegenSource += `const apiResponse = await INTERNAL_tryHandleAPI(request, apis, apiLoaders);`; - codegenSource += `if (apiResponse) {`; - codegenSource += `return apiResponse;`; - codegenSource += `}`; - - // Handle page routes - codegenSource += `const renderer = ssr();`; - codegenSource += `const root = createHTMLRoot();`; - codegenSource += `const lifetime = new Lifetime();`; - codegenSource += `try {`; - codegenSource += `await INTERNAL_entrypoint({ - props: entrypointProps, - loaders, - renderer, - root, - pathname, - context: {}, - lifetime, - });`; - codegenSource += `const html = printHTML(root);`; - codegenSource += `return new Response(html, {`; - codegenSource += `status: 200,`; - codegenSource += `headers: { 'Content-Type': 'text/html' }`; - codegenSource += `});`; - codegenSource += `} catch (error) {`; - codegenSource += `console.error('Rendering error:', error);`; - codegenSource += `return new Response('Internal Server Error', { status: 500 });`; - codegenSource += `} finally {`; - codegenSource += `lifetime.close();`; - codegenSource += `}`; - codegenSource += `}`; - - const filename = "catch-all-function"; - const path = await build.writeCodegenned(filename, codegenSource); - - const bundled = await build.bundle({ - target: "server", - inputPaths: { - main: path, - }, - dev: false, - noSplitting: true - }); - - return bundled.outputs.main; - }, - - async run(build) { - using _task = addTask({ - name: "Building for Vercel Build Output API" - }); - - const outputDir = join(build.project.projectDir, ".vercel", "output"); - const staticDir = join(outputDir, "static"); - const functionsDir = join(outputDir, "functions"); - - // Ensure directories exist - await mkdir(outputDir, { recursive: true }); - await mkdir(staticDir, { recursive: true }); - await mkdir(functionsDir, { recursive: true }); - - // Build client bundle and CSS - await this.buildClientBundle(build); - await this.buildCSS(build); - - // Build individual route functions - const routeFunctions: string[] = []; - for (const route of build.routes) { - const functionPath = await this.buildRouteFunction(build, route); - routeFunctions.push(functionPath); - - // Create function directory in Vercel output - const routeId = printRoutePath(route.matcher).replace(/\[\.\.\.([^\]]+)\]/g, '[...$1]').replace(/\[([^\]]+)\]/g, '[$1]') || 'index'; - const functionDir = join(functionsDir, `${route.type}-${routeId}.func`); - await mkdir(functionDir, { recursive: true }); - - // Copy function file - const functionIndexPath = join(functionDir, "index.js"); - await Bun.write(functionIndexPath, await Bun.file(functionPath).text()); - - // Create .vc-config.json for each function - const vcConfig = { - runtime: "edge", - entrypoint: "index.js" - }; - await writeFile(join(functionDir, ".vc-config.json"), JSON.stringify(vcConfig, null, 2)); - } - - // Build catch-all function for unmatched routes - const catchAllPath = await this.buildCatchAllFunction(build); - const catchAllDir = join(functionsDir, "index.func"); - await mkdir(catchAllDir, { recursive: true }); - - const catchAllIndexPath = join(catchAllDir, "index.js"); - await Bun.write(catchAllIndexPath, await Bun.file(catchAllPath).text()); - - const catchAllVcConfig = { - runtime: "edge", - entrypoint: "index.js" - }; - await writeFile(join(catchAllDir, ".vc-config.json"), JSON.stringify(catchAllVcConfig, null, 2)); - - // Create main config.json - const routes = []; - - // Add routes for each specific route function - for (const route of build.routes) { - const routeId = printRoutePath(route.matcher).replace(/\[\.\.\.([^\]]+)\]/g, '[...$1]').replace(/\[([^\]]+)\]/g, '[$1]') || 'index'; - const routePath = "/" + printRoutePath(route.matcher).replace(/\[\.\.\.([^\]]+)\]/g, '*').replace(/\[([^\]]+)\]/g, '*'); - - if (route.type === "api") { - routes.push({ - src: routePath, - dest: `/functions/${route.type}-${routeId}.func`, - methods: [route.method] - }); - } else { - routes.push({ - src: routePath, - dest: `/functions/${route.type}-${routeId}.func` - }); - } - } - - // Add catch-all route last - routes.push({ - src: "/(.*)", - dest: "/functions/index.func" - }); - - const config = { - version: 3, - routes - }; - - const configPath = join(outputDir, "config.json"); - await writeFile(configPath, JSON.stringify(config, null, 2)); - - return { - outputDir, - staticDir, - functionsDir, - configFile: configPath - }; - } - }; + codegenSource += `const streamutil = INTERNAL_createStreamUtility();`; + codegenSource += `const html = printHTML(root);`; + codegenSource += `async function load() {`; + codegenSource += `streamutil.write(html);`; + codegenSource += `let currentSnapshot = structuredClone(root);`; + codegenSource += `context.streaming.updated();`; + codegenSource += `context.streaming.onUpdate(() => {`; + codegenSource += `const codegen = diffInto(currentSnapshot, root);`; + codegenSource += `const code = codegen.getCode();`; + codegenSource += `currentSnapshot = structuredClone(root);`; + codegenSource += "streamutil.write(``);"; + codegenSource += `});`; + codegenSource += `await context.streaming.onDoneLoading;`; + codegenSource += "streamutil.write(``);"; + codegenSource += `streamutil.end();`; + codegenSource += `lifetime.close();`; + codegenSource += `}`; + codegenSource += `load();`; + codegenSource += `return new Response(streamutil.readable.pipeThrough(new TextEncoderStream()), {`; + codegenSource += `status: 200,`; + codegenSource += `headers: { 'Content-Type': 'text/html; charset=utf-8', 'X-Content-Type-Options': 'nosniff', 'Transfer-Encoding': 'chunked', Connection: 'keep-alive', }`; + codegenSource += `});`; + codegenSource += `}`; + } + + const routeId = getRouteId(route.matcher); + const filename = `function-${route.type}-${routeId}`; + const path = await build.writeCodegenned(filename, codegenSource); + + const bundled = await build.bundle({ + target: "server", + inputPaths: { + main: path, + }, + dev: false, + noSplitting: true + }); + + return bundled.outputs.main; + }, + + async run(build) { + using _task = addTask({ + name: "Building for Vercel Build Output API" + }); + + const outputDir = join(build.project.projectDir, ".vercel", "output"); + + await rmdir(outputDir, { recursive: true }).catch(() => { /* ignore */ }); + + const staticDir = join(outputDir, "static"); + const functionsDir = join(outputDir, "functions"); + + // Ensure directories exist + await mkdir(outputDir, { recursive: true }); + await mkdir(staticDir, { recursive: true }); + await mkdir(functionsDir, { recursive: true }); + + // Build client bundle and CSS + await this.buildClientBundle(build); + await this.buildCSS(build); + + // Build individual route functions + const routeFunctions: string[] = []; + for (const route of build.routes) { + const functionPath = await this.buildRouteFunction(build, route); + routeFunctions.push(functionPath); + + // Create function directory in Vercel output + const functionDir = join(functionsDir, `${printRoutePath(route.matcher) || "index"}.func`); + await mkdir(functionDir, { recursive: true }); + + // Copy function file + const functionIndexPath = join(functionDir, "index.js"); + await Bun.write(functionIndexPath, await Bun.file(functionPath).text()); + + // Create .vc-config.json for each function + const vcConfig = { + runtime: "edge", + entrypoint: "index.js" + }; + await Bun.write(join(functionDir, ".vc-config.json"), JSON.stringify(vcConfig, null, 2)); + } + + const config = { + version: 3 + }; + + const configPath = join(outputDir, "config.json"); + await Bun.write(configPath, JSON.stringify(config, null, 2)); + + return { + outputDir, + staticDir, + functionsDir, + configFile: configPath + }; + } + }; } diff --git a/packages/wormhole/src/dev/dev-server.ts b/packages/wormhole/src/dev/dev-server.ts index 2566d90..202c7fb 100644 --- a/packages/wormhole/src/dev/dev-server.ts +++ b/packages/wormhole/src/dev/dev-server.ts @@ -9,170 +9,175 @@ import { watch } from "node:fs"; import type { HTTPMethod } from "~/shared/http-method"; export interface DevServer { - lifetime: Lifetime; - server: Bun.Server; - processRequest(request: Request, tags: RequestTag[]): Promise; - rebuild(): Promise; - buildResult: Promise; - project: Project; + lifetime: Lifetime; + server: Bun.Server; + processRequest(request: Request, tags: RequestTag[]): Promise; + rebuild(): Promise; + buildResult: Promise; + project: Project; } export function DevServer(project: Project): DevServer { - const server = Bun.serve({ - port: 3141, - routes: { - "/*": async (req) => { - return new Response(); - } - }, - development: true - }); - - project.lt.onClosed(server.stop); - - const self: DevServer = { - lifetime: project.lt, - server, - processRequest: DevServer_processRequest, - rebuild: DevServer_rebuild, - buildResult: new Promise(() => { }), - project - } - - server.reload({ - routes: { - "/*": async (req) => { - const tags: RequestTag[] = []; - const response = await self.processRequest(req, tags); - - addLog({ - type: "request", - url: new URL(req.url).pathname, - method: req.method as HTTPMethod, - responseCode: response.status, - tags - }) - - return response; - } - } - }); - - const devServerTask = addTask({ - name: `Development server running @ ${server.url.toString()}` - }); - - project.lt.onClosed(devServerTask[Symbol.dispose]); - - self.rebuild(); - - // Watch sourcedir - const watcher = watch(join(project.projectDir, "src"), { recursive: true }); - - let isWaitingForRebuild = false; - - watcher.on("change", async (eventType, filename) => { - if (isWaitingForRebuild) return; - isWaitingForRebuild = true; - await self.buildResult; - isWaitingForRebuild = false; - self.rebuild(); - }); - - project.lt.onClosed(() => { - watcher.close(); - }); - - return self; + const server = Bun.serve({ + port: 3141, + routes: { + "/*": async (req) => { + return new Response(); + } + }, + development: true + }); + + project.lt.onClosed(server.stop); + + const self: DevServer = { + lifetime: project.lt, + server, + processRequest: DevServer_processRequest, + rebuild: DevServer_rebuild, + buildResult: new Promise(() => { }), + project + } + + server.reload({ + routes: { + "/*": async (req) => { + const tags: RequestTag[] = []; + const response = await self.processRequest(req, tags); + + addLog({ + type: "request", + url: new URL(req.url).pathname, + method: req.method as HTTPMethod, + responseCode: response.status, + tags + }) + + return response; + } + } + }); + + const devServerTask = addTask({ + name: `Development server running @ ${server.url.toString()}` + }); + + project.lt.onClosed(devServerTask[Symbol.dispose]); + + self.rebuild(); + + // Watch sourcedir + const watcher = watch(join(project.projectDir, "src"), { recursive: true }); + + let isWaitingForRebuild = false; + + watcher.on("change", async (eventType, filename) => { + if (isWaitingForRebuild) return; + isWaitingForRebuild = true; + await self.buildResult; + isWaitingForRebuild = false; + self.rebuild(); + }); + + project.lt.onClosed(() => { + watcher.close(); + }); + + return self; } async function DevServer_rebuild(this: DevServer): Promise { - const build = new Build(this.project, DevAdapter()); - this.buildResult = build.run(); - await this.buildResult; + const build = new Build(this.project, DevAdapter()); + this.buildResult = build.run(); + await this.buildResult; } interface ServerEntrypoint { - main(props: { - renderer: Renderer, - root: RendererNode, - pathname: string, - context: ContextScope, - lifetime: Lifetime - }): void; - tryHandleAPI(request: Request): Promise; - isRoute404(pathname: string): boolean; + main(props: { + renderer: Renderer, + root: RendererNode, + pathname: string, + context: ContextScope, + lifetime: Lifetime + }): void; + tryHandleAPI(request: Request): Promise; + isRoute404(pathname: string): boolean; } async function DevServer_processRequest(this: DevServer, request: Request, tags: RequestTag[]): Promise { - const built = await this.buildResult; + const built = await this.buildResult; - const serverPath = built.serverEntry; - const serverEntrypoint = (await import(serverPath + `?v=${Date.now()}`)) as ServerEntrypoint; + const serverPath = built.serverEntry; + const serverEntrypoint = (await import(serverPath + `?v=${Date.now()}`)) as ServerEntrypoint; - // Priority 1: API routes - const apiResponse = await serverEntrypoint.tryHandleAPI(request); + // Priority 1: API routes + const apiResponse = await serverEntrypoint.tryHandleAPI(request); - if (apiResponse !== undefined && apiResponse !== null) { - tags.push("api"); - return apiResponse; - } + if (apiResponse !== undefined && apiResponse !== null) { + tags.push("api"); + return apiResponse; + } - // Priority 2: Static files - const filePath = join(built.outdir, new URL(request.url).pathname); + // Priority 2: Static files + const filePath = join(built.outdir, new URL(request.url).pathname); - if (await Bun.file(filePath).exists()) { - tags.push("static"); - return new Response(Bun.file(filePath)); - } + if (await Bun.file(filePath).exists()) { + tags.push("static"); + return new Response(Bun.file(filePath)); + } - // Priority 3: SSR - const root = createHTMLRoot(); - const renderer = ssr(); + // Priority 3: SSR + const root = createHTMLRoot(); + const renderer = ssr(); - const context = new ContextScope(); + const context = new ContextScope(); - const lifetime = new Lifetime(); + const lifetime = new Lifetime(); - serverEntrypoint.main({ - root, - renderer, - pathname: new URL(request.url).pathname, - context, - lifetime - }); + serverEntrypoint.main({ + root, + renderer, + pathname: new URL(request.url).pathname, + context, + lifetime + }); - const html = printHTML(root); + const html = printHTML(root); - const { readable, writable } = new TransformStream(); - const writer = writable.getWriter(); + const { readable, writable } = new TransformStream(); - writer.write(html); + async function load() { + const writer = writable.getWriter(); - let currentSnapshot = structuredClone(root); + writer.write(html); - context.streaming.onUpdate(() => { - const codegen = diffInto(currentSnapshot, root); + let currentSnapshot = structuredClone(root); - const code = codegen.getCode(); + context.streaming.onUpdate(() => { + const codegen = diffInto(currentSnapshot, root); - currentSnapshot = structuredClone(root); + const code = codegen.getCode(); - writer.write(``); - }); + currentSnapshot = structuredClone(root); - await context.streaming.onDoneLoading; + writer.write(``); + }); - writer.write(``); - writer.close(); - lifetime.close(); + await context.streaming.onDoneLoading; - tags.push("ssr"); + writer.write(``); + writer.close(); + lifetime.close(); + } - return new Response(readable, { - status: serverEntrypoint.isRoute404(new URL(request.url).pathname) ? 404 : 200, - headers: { - 'Content-Type': "text/html" - } - }) + load(); + + tags.push("ssr"); + + return new Response(readable, { + status: serverEntrypoint.isRoute404(new URL(request.url).pathname) ? 404 : 200, + headers: { + 'Content-Type': "text/html" + } + }) } diff --git a/packages/wormhole/src/runtime/index.ts b/packages/wormhole/src/runtime/index.ts index 01b7320..7ce326c 100644 --- a/packages/wormhole/src/runtime/index.ts +++ b/packages/wormhole/src/runtime/index.ts @@ -1,2 +1,3 @@ export * from "~/runtime/entrypoint"; export * from "~/runtime/api"; +export * from "~/runtime/stream"; diff --git a/packages/wormhole/src/runtime/stream.ts b/packages/wormhole/src/runtime/stream.ts new file mode 100644 index 0000000..6d4b1dd --- /dev/null +++ b/packages/wormhole/src/runtime/stream.ts @@ -0,0 +1,29 @@ +export interface StreamUtility { + write(data: string): Promise; + end(): Promise; + readable: ReadableStream; +} + +export function INTERNAL_createStreamUtility(): StreamUtility { + let streamController: ReadableStreamDefaultController; + const readable = new ReadableStream({ + start(controller) { + streamController = controller; + } + }); + return { + write(data: string): Promise { + return new Promise(resolve => { + streamController.enqueue(data); + resolve(); + }); + }, + end(): Promise { + return new Promise(resolve => { + streamController.close(); + resolve(); + }); + }, + readable + }; +} From 7fde27ecb0a1d0bfe16724a9d58e0f50699f0618 Mon Sep 17 00:00:00 2001 From: andy <144629051+andylovescode@users.noreply.github.com> Date: Sat, 23 Aug 2025 18:40:07 -0700 Subject: [PATCH 12/15] Vercel: Fix non-GET API routes Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- packages/wormhole/src/build/adapters/vercel.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/wormhole/src/build/adapters/vercel.ts b/packages/wormhole/src/build/adapters/vercel.ts index b41ca18..2a555d8 100644 --- a/packages/wormhole/src/build/adapters/vercel.ts +++ b/packages/wormhole/src/build/adapters/vercel.ts @@ -154,11 +154,7 @@ export function VercelAdapter(): VercelAdapter { codegenSource += `import { SKL } from "@vortexjs/common";`; codegenSource += `export default async function handler(request) {`; - codegenSource += `const text = `; - if (route.method === "GET") { - codegenSource += `new URL(request.url).searchParams.get("props")`; - } else { - codegenSource += `await props.text()`; + codegenSource += `await request.text()`; } codegenSource += `;`; From 0fb01149682c1d5439f5cb846d39c9ec7d2c8deb Mon Sep 17 00:00:00 2001 From: andylovescode Date: Sat, 23 Aug 2025 18:42:39 -0700 Subject: [PATCH 13/15] Revert "Vercel: Fix non-GET API routes" This reverts commit 7fde27ecb0a1d0bfe16724a9d58e0f50699f0618. --- packages/wormhole/src/build/adapters/vercel.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/wormhole/src/build/adapters/vercel.ts b/packages/wormhole/src/build/adapters/vercel.ts index 2a555d8..b41ca18 100644 --- a/packages/wormhole/src/build/adapters/vercel.ts +++ b/packages/wormhole/src/build/adapters/vercel.ts @@ -154,7 +154,11 @@ export function VercelAdapter(): VercelAdapter { codegenSource += `import { SKL } from "@vortexjs/common";`; codegenSource += `export default async function handler(request) {`; - codegenSource += `await request.text()`; + codegenSource += `const text = `; + if (route.method === "GET") { + codegenSource += `new URL(request.url).searchParams.get("props")`; + } else { + codegenSource += `await props.text()`; } codegenSource += `;`; From 0005c197e4b17b843d61d547b67843d3e6226399 Mon Sep 17 00:00:00 2001 From: andylovescode Date: Sat, 23 Aug 2025 18:43:02 -0700 Subject: [PATCH 14/15] Vercel: Actually fix non-GET API routes --- packages/wormhole/src/build/adapters/vercel.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/wormhole/src/build/adapters/vercel.ts b/packages/wormhole/src/build/adapters/vercel.ts index b41ca18..a694dd5 100644 --- a/packages/wormhole/src/build/adapters/vercel.ts +++ b/packages/wormhole/src/build/adapters/vercel.ts @@ -158,7 +158,7 @@ export function VercelAdapter(): VercelAdapter { if (route.method === "GET") { codegenSource += `new URL(request.url).searchParams.get("props")`; } else { - codegenSource += `await props.text()`; + codegenSource += `await request.text()`; } codegenSource += `;`; From ca0c737b4a983f1e2a6ffa2465eeee534061e3bc Mon Sep 17 00:00:00 2001 From: andylovescode Date: Sat, 23 Aug 2025 18:43:45 -0700 Subject: [PATCH 15/15] Core: Remove unneeded logging --- packages/vortex-core/src/context.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/vortex-core/src/context.ts b/packages/vortex-core/src/context.ts index 0872794..1cc27a3 100644 --- a/packages/vortex-core/src/context.ts +++ b/packages/vortex-core/src/context.ts @@ -42,7 +42,7 @@ export class StreamingContext { private updateCallbackImmediate = 0; private updateCallbacks = new Set<() => void>(); private loadingCounter = 0; - private onDoneLoadingCallback = () => {}; + private onDoneLoadingCallback = () => { }; onDoneLoading: Promise; constructor() { @@ -63,12 +63,10 @@ export class StreamingContext { const self = this; this.loadingCounter++; - console.log("markLoading", this.loadingCounter); return { [Symbol.dispose]() { self.loadingCounter--; - console.log("unmarkLoading", self.loadingCounter); self.updated(); }, }; @@ -90,7 +88,6 @@ export class StreamingContext { } if (self.loadingCounter === 0) { - console.log("done loading"); self.onDoneLoadingCallback(); } }) as unknown as number;