@thexjs/core 1.8.3 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/adapter.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { B as BackpressureOptions } from './backpressure-05lHLY5O.js';
2
+
1
3
  /**
2
4
  * The scratch directory that holds the transient (transpiled module / entry
3
5
  * source) files the bundler reads before inlining everything into
@@ -39,6 +41,8 @@ interface AdapterOptions {
39
41
  images?: {
40
42
  remoteHosts?: string[];
41
43
  };
44
+ /** Optional per-process request admission/backpressure. */
45
+ backpressure?: BackpressureOptions | false;
42
46
  /** Client build output dir. Server-mode routes' island bundles are emitted
43
47
  * into `<islandsDir>/_islands/` here so adapters can ship them as static
44
48
  * assets. Undefined skips island bundling (server HTML ships no island
@@ -96,16 +100,18 @@ interface BuildManifest {
96
100
  observability?: AdapterOptions["observability"];
97
101
  /** Remote image proxy options serialized for the generated entry. */
98
102
  images?: AdapterOptions["images"];
103
+ /** Backpressure options serialized for the generated entry. */
104
+ backpressure?: AdapterOptions["backpressure"];
99
105
  }
100
106
 
101
107
  /**
102
- * Serializes runtime config (security / observability / images) into the
103
- * generated entry. Only JSON-serializable values can cross the build
104
- * boundary -- a `security.errorReporter` or `observability.logger` callback
105
- * in `x.config.ts` must not silently vanish, or the deployed function would
106
- * drift from `x start`. Fail the build loudly with the offending keys.
108
+ * Serializes runtime config (security / observability / images / backpressure)
109
+ * into the generated entry. Only JSON-serializable values can cross the build
110
+ * boundary -- a callback in runtime config must not silently vanish, or the
111
+ * deployed function would drift from `x start`. Fail the build loudly with
112
+ * the offending keys.
107
113
  */
108
- declare function serializeRuntimeOptions(label: string, options: Record<string, unknown> | undefined): string;
114
+ declare function serializeRuntimeOptions(label: string, options: object | undefined): string;
109
115
  /**
110
116
  * Emits the source for the adapter render-function entry module.
111
117
  *
@@ -121,7 +127,8 @@ declare function serializeRuntimeOptions(label: string, options: Record<string,
121
127
  * function behaves exactly like the `x start` production server -- health
122
128
  * checks, rate limiting, revalidation, server actions, SSR with
123
129
  * loaders/layouts/middleware, API routes, security headers, the 404 page,
124
- * request logging -- all of it, with no drift between the two.
130
+ * request logging, and configured request backpressure -- all of it, with no
131
+ * drift between the two.
125
132
  *
126
133
  * The returned module exports a `handler` function; the platform adapter
127
134
  * decides its signature (e.g. a Node `(req, res)` bridge for Vercel).
package/dist/adapter.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  scanNotFound,
10
10
  scanPages,
11
11
  scanRoutes
12
- } from "./chunk-3VMZCMAF.js";
12
+ } from "./chunk-ME4ES2PD.js";
13
13
  import "./chunk-OXV2QTWV.js";
14
14
 
15
15
  // src/adapter/bundle.ts
@@ -76,10 +76,12 @@ function generateAdapterEntry(manifest, entryDir) {
76
76
  const securityOpts = serializeRuntimeOptions("security", manifest.security);
77
77
  const observabilityOpts = serializeRuntimeOptions("observability", manifest.observability);
78
78
  const imagesOpts = serializeRuntimeOptions("images", manifest.images);
79
+ const backpressureOpts = manifest.backpressure === void 0 ? "undefined" : manifest.backpressure === false ? "false" : serializeRuntimeOptions("backpressure", manifest.backpressure);
79
80
  lines.push(
80
81
  `const __x_security = ${securityOpts};`,
81
82
  `const __x_observability = ${observabilityOpts};`,
82
83
  `const __x_images = ${imagesOpts};`,
84
+ `const __x_backpressure = ${backpressureOpts};`,
83
85
  ""
84
86
  );
85
87
  const refs = /* @__PURE__ */ new Map();
@@ -148,6 +150,7 @@ function generateAdapterEntry(manifest, entryDir) {
148
150
  " ...(Object.keys(__x_security).length > 0 ? { security: __x_security } : {}),",
149
151
  " ...(Object.keys(__x_observability).length > 0 ? { observability: __x_observability } : {}),",
150
152
  " ...(Object.keys(__x_images).length > 0 ? { images: __x_images } : {}),",
153
+ " ...(__x_backpressure !== undefined ? { backpressure: __x_backpressure } : {}),",
151
154
  " preloaded: {",
152
155
  " routes: __x_preloadedRoutes,",
153
156
  ...manifest.notFound ? [` notFoundComponent: ${manifest.notFound.identifier}.default ?? undefined,`] : [],
@@ -304,7 +307,8 @@ async function resolveBuildManifest(options, scratchDir) {
304
307
  ...existsSync(join2(projectRoot, "public", "styles.css")) ? { stylesheetHref: "/styles.css" } : {},
305
308
  security: options.security,
306
309
  observability: options.observability,
307
- images: options.images
310
+ images: options.images,
311
+ backpressure: options.backpressure
308
312
  };
309
313
  }
310
314
  function allModuleRefs(manifest) {
@@ -0,0 +1,51 @@
1
+ interface BackpressureOptions {
2
+ /** Maximum number of requests allowed to execute concurrently in this process. */
3
+ maxConcurrent: number;
4
+ /** Maximum number of additional requests allowed to wait for a slot. Default: 0. */
5
+ maxQueue?: number;
6
+ /** Retry-After value used by `withBackpressure` when the queue is full. Default: 1 second. */
7
+ retryAfterSeconds?: number;
8
+ }
9
+ interface BackpressureSnapshot {
10
+ active: number;
11
+ queued: number;
12
+ maxConcurrent: number;
13
+ maxQueue: number;
14
+ }
15
+ interface BackpressureLease {
16
+ /** Releases one active slot. Safe to call more than once. */
17
+ release(): void;
18
+ }
19
+ interface BackpressureController {
20
+ /**
21
+ * Waits for an execution slot. Rejects with `BackpressureSaturatedError`
22
+ * when the queue is full, or with the request's abort reason while queued.
23
+ */
24
+ acquire(signal?: AbortSignal): Promise<BackpressureLease>;
25
+ snapshot(): BackpressureSnapshot;
26
+ }
27
+ declare class BackpressureSaturatedError extends Error {
28
+ readonly retryAfterSeconds: number;
29
+ constructor(retryAfterSeconds: number);
30
+ }
31
+ /**
32
+ * Creates one in-process admission controller.
33
+ *
34
+ * This is deliberately separate from rate limiting: rate limiting controls
35
+ * request frequency per identity/window, while this controller bounds the
36
+ * amount of work that may be active or waiting inside one process at a time.
37
+ * Queued requests are promoted FIFO as active leases are released.
38
+ */
39
+ declare function createBackpressureController(options: BackpressureOptions): BackpressureController;
40
+ type BackpressureHandler<TServer = unknown> = (req: Request, server?: TServer) => Response | Promise<Response>;
41
+ /**
42
+ * Wraps a request handler with bounded per-process admission.
43
+ *
44
+ * Saturation is reported as 503 Service Unavailable (not 429): the caller is
45
+ * not being rate-limited; this process has no execution/queue capacity left.
46
+ * Requests aborted while waiting are removed from the queue and their abort
47
+ * reason is re-thrown without invoking the wrapped handler.
48
+ */
49
+ declare function withBackpressure<TServer = unknown>(handler: BackpressureHandler<TServer>, options: BackpressureOptions): BackpressureHandler<TServer>;
50
+
51
+ export { type BackpressureOptions as B, type BackpressureController as a, type BackpressureHandler as b, type BackpressureLease as c, BackpressureSaturatedError as d, type BackpressureSnapshot as e, createBackpressureController as f, withBackpressure as w };
@@ -43,10 +43,72 @@ function findLeakedEnvKeys(code) {
43
43
  }
44
44
  return [...found];
45
45
  }
46
+ var MIN_LEAKED_VALUE_LENGTH = 6;
47
+ var SAFE_ENV_KEYS = /* @__PURE__ */ new Set([
48
+ "NODE_ENV",
49
+ "PWD",
50
+ "OLDPWD",
51
+ "INIT_CWD",
52
+ "HOSTNAME",
53
+ "HOME",
54
+ "USER",
55
+ "USERNAME",
56
+ "SHELL",
57
+ "LANG",
58
+ "LC_ALL",
59
+ "TERM",
60
+ "PATH",
61
+ "TMPDIR",
62
+ "TEMP",
63
+ "TMP",
64
+ // Vercel injects this at build time as a cache-busting salt for
65
+ // content-addressed output (a Unix timestamp, e.g. "1783933175"). It is not
66
+ // a secret, but its short numeric value routinely appears inside bundled
67
+ // code, so the value scan would otherwise fail every Vercel build.
68
+ "VERCEL_HASH_SALT"
69
+ ]);
70
+ var SENSITIVE_KEY_PATTERNS = [
71
+ /SECRET/i,
72
+ /TOKEN/i,
73
+ /PASSWORD/i,
74
+ /PRIVATE/i,
75
+ /CREDENTIAL/i,
76
+ /API_KEY/i,
77
+ /_KEY$/i,
78
+ /AUTH/i,
79
+ /SALT/i,
80
+ /DSN/i,
81
+ /DATABASE_URL/i,
82
+ /CONNECTION_STRING/i
83
+ ];
84
+ var ENV_SCAN_IGNORE_KEY = "THEXJS_ENV_SCAN_IGNORE";
85
+ function isSensitiveEnvKey(key) {
86
+ return SENSITIVE_KEY_PATTERNS.some((re) => re.test(key));
87
+ }
88
+ var MIN_RANDOM_VALUE_LENGTH = 24;
89
+ var RANDOM_LOOKING_VALUE_RE = /^[A-Za-z0-9+/_=-]+$/;
90
+ function looksRandom(value) {
91
+ return value.length >= MIN_RANDOM_VALUE_LENGTH && /[0-9]/.test(value) && RANDOM_LOOKING_VALUE_RE.test(value);
92
+ }
93
+ function findLeakedEnvValues(code, env) {
94
+ const found = /* @__PURE__ */ new Set();
95
+ const ignored = new Set(
96
+ (env[ENV_SCAN_IGNORE_KEY] ?? "").split(",").map((k) => k.trim()).filter(Boolean)
97
+ );
98
+ for (const [key, value] of Object.entries(env)) {
99
+ if (!value || key.startsWith(PUBLIC_ENV_PREFIX) || SAFE_ENV_KEYS.has(key)) continue;
100
+ if (key === ENV_SCAN_IGNORE_KEY || ignored.has(key)) continue;
101
+ if (value.length < MIN_LEAKED_VALUE_LENGTH) continue;
102
+ if (!isSensitiveEnvKey(key) && !looksRandom(value)) continue;
103
+ if (code.includes(value)) found.add(key);
104
+ }
105
+ return [...found];
106
+ }
46
107
  var EnvLeakageError = class extends Error {
47
- constructor(file, keys) {
108
+ constructor(file, keys, kind = "access") {
109
+ const detail = kind === "value" ? "its value was found literally in the bundled output (no process.env.* reference, only a value match) \u2014 track down where this string is embedded and move it out of client-shipped code" : "move this access into a loader, server function, or API route";
48
110
  super(
49
- `[x] server-only environment variable(s) leaked into client bundle "${file}": ${keys.join(", ")}. Only "${PUBLIC_ENV_PREFIX}*" variables may be referenced in client-shipped code \u2014 move this access into a loader, server function, or API route.`
111
+ `[x] server-only environment variable(s) leaked into client bundle "${file}": ${keys.join(", ")}. Only "${PUBLIC_ENV_PREFIX}*" variables may be referenced in client-shipped code \u2014 ${detail}.`
50
112
  );
51
113
  this.file = file;
52
114
  this.keys = keys;
@@ -58,7 +120,13 @@ var EnvLeakageError = class extends Error {
58
120
  function assertNoEnvLeakage(code, file) {
59
121
  const leaked = findLeakedEnvKeys(code);
60
122
  if (leaked.length > 0) {
61
- throw new EnvLeakageError(file, leaked);
123
+ throw new EnvLeakageError(file, leaked, "access");
124
+ }
125
+ }
126
+ function assertNoEnvValueLeakage(code, file, env) {
127
+ const leaked = findLeakedEnvValues(code, env);
128
+ if (leaked.length > 0) {
129
+ throw new EnvLeakageError(file, leaked, "value");
62
130
  }
63
131
  }
64
132
 
@@ -323,10 +391,7 @@ export function href<T extends keyof RouteMap & string>(
323
391
  const isNamedToken = (key: string) => new RegExp(\`(^|/):\${key}(?=/|$)\`).test(path);
324
392
  for (const [key, value] of Object.entries(params)) {
325
393
  if (!isNamedToken(key)) {
326
- const encoded = String(value)
327
- .split("/")
328
- .map(encodeURIComponent)
329
- .join("/");
394
+ const encoded = String(value).split("/").map(encodeURIComponent).join("/");
330
395
  result = result.replace(/\\*/, encoded);
331
396
  }
332
397
  }
@@ -713,6 +778,7 @@ async function buildIslandBundleInMemory(routeFilePath, layoutFilePaths, islandN
713
778
  const result = await Bun.build({
714
779
  entrypoints: [entryPath],
715
780
  target: "browser",
781
+ env: "disable",
716
782
  plugins: [actionsRewritePlugin(actionModules)]
717
783
  });
718
784
  if (!result.success) {
@@ -726,6 +792,7 @@ async function buildIslandBundleInMemory(routeFilePath, layoutFilePaths, islandN
726
792
  if (!built) return wrapIslandBundle(generateFallbackHydration(islandNames));
727
793
  const code = await built.text();
728
794
  assertNoEnvLeakage(code, entryPath);
795
+ assertNoEnvValueLeakage(code, entryPath, process.env);
729
796
  return wrapIslandBundle(code);
730
797
  } catch (err) {
731
798
  if (err instanceof EnvLeakageError) {
@@ -753,6 +820,7 @@ async function bundleRouteIslandsToDisk(routeFilePath, layoutFilePaths, islandNa
753
820
  const result = await Bun.build({
754
821
  entrypoints: [entryPath],
755
822
  target: "browser",
823
+ env: "disable",
756
824
  plugins: [actionsRewritePlugin(actionModules)]
757
825
  });
758
826
  if (result.success) {
@@ -761,6 +829,7 @@ async function bundleRouteIslandsToDisk(routeFilePath, layoutFilePaths, islandNa
761
829
  if (built) {
762
830
  const code = await built.text();
763
831
  assertNoEnvLeakage(code, bundlePath);
832
+ assertNoEnvValueLeakage(code, bundlePath, process.env);
764
833
  writeFileSync3(bundlePath, wrapIslandBundle(code), "utf-8");
765
834
  return [`/_islands/${entryId}/${entryId}.js`];
766
835
  }
package/dist/index.d.ts CHANGED
@@ -1,56 +1,8 @@
1
+ import { B as BackpressureOptions } from './backpressure-05lHLY5O.js';
2
+ export { a as BackpressureController, b as BackpressureHandler, c as BackpressureLease, d as BackpressureSaturatedError, e as BackpressureSnapshot, f as createBackpressureController, w as withBackpressure } from './backpressure-05lHLY5O.js';
1
3
  import * as react from 'react';
2
4
  import { ComponentType, ReactNode, CSSProperties, AnchorHTMLAttributes } from 'react';
3
5
 
4
- interface BackpressureOptions {
5
- /** Maximum number of requests allowed to execute concurrently in this process. */
6
- maxConcurrent: number;
7
- /** Maximum number of additional requests allowed to wait for a slot. Default: 0. */
8
- maxQueue?: number;
9
- /** Retry-After value used by `withBackpressure` when the queue is full. Default: 1 second. */
10
- retryAfterSeconds?: number;
11
- }
12
- interface BackpressureSnapshot {
13
- active: number;
14
- queued: number;
15
- maxConcurrent: number;
16
- maxQueue: number;
17
- }
18
- interface BackpressureLease {
19
- /** Releases one active slot. Safe to call more than once. */
20
- release(): void;
21
- }
22
- interface BackpressureController {
23
- /**
24
- * Waits for an execution slot. Rejects with `BackpressureSaturatedError`
25
- * when the queue is full, or with the request's abort reason while queued.
26
- */
27
- acquire(signal?: AbortSignal): Promise<BackpressureLease>;
28
- snapshot(): BackpressureSnapshot;
29
- }
30
- declare class BackpressureSaturatedError extends Error {
31
- readonly retryAfterSeconds: number;
32
- constructor(retryAfterSeconds: number);
33
- }
34
- /**
35
- * Creates one in-process admission controller.
36
- *
37
- * This is deliberately separate from rate limiting: rate limiting controls
38
- * request frequency per identity/window, while this controller bounds the
39
- * amount of work that may be active or waiting inside one process at a time.
40
- * Queued requests are promoted FIFO as active leases are released.
41
- */
42
- declare function createBackpressureController(options: BackpressureOptions): BackpressureController;
43
- type BackpressureHandler<TServer = unknown> = (req: Request, server?: TServer) => Response | Promise<Response>;
44
- /**
45
- * Wraps a request handler with bounded per-process admission.
46
- *
47
- * Saturation is reported as 503 Service Unavailable (not 429): the caller is
48
- * not being rate-limited; this process has no execution/queue capacity left.
49
- * Requests aborted while waiting are removed from the queue and their abort
50
- * reason is re-thrown without invoking the wrapped handler.
51
- */
52
- declare function withBackpressure<TServer = unknown>(handler: BackpressureHandler<TServer>, options: BackpressureOptions): BackpressureHandler<TServer>;
53
-
54
6
  type RouteMode = "static" | "server";
55
7
  interface BuildOptions {
56
8
  routesDir?: string;
@@ -63,50 +15,15 @@ interface BuildOptions {
63
15
  /**
64
16
  * Absolute path to the project's x.config.ts/js/mjs, if any. When set, the
65
17
  * generated production server entry re-imports it at startup and forwards
66
- * its `security`/`observability` fields into `createApp()` — those fields
67
- * can hold live values (rate-limit key functions, error reporters, health
68
- * checks) that can't be serialized into the generated file directly.
18
+ * its runtime `security`/`observability`/`images`/`backpressure` fields into
19
+ * `createApp()` — those fields can hold live values (rate-limit key
20
+ * functions, error reporters, health checks) that can't be serialized into
21
+ * the generated file directly.
69
22
  */
70
23
  configPath?: string;
71
24
  }
72
25
  declare function build(options: BuildOptions): Promise<void>;
73
26
 
74
- /**
75
- * Inline client-side navigation script.
76
- *
77
- * Embedded directly into every rendered page as a <script> tag (see render.ts).
78
- * Intercepts same-origin <a> clicks, fetches the destination page, and swaps
79
- * the #root element's content in place. Includes hover-prefetch and popstate
80
- * (back/forward) support.
81
- *
82
- * Opt-out attributes on <a> / <Link />:
83
- * - data-no-nav — skip client navigation (full page load)
84
- * - data-no-prefetch — skip hover prefetch (navigation still works)
85
- */
86
- declare global {
87
- interface Window {
88
- __xIslandRoots?: Array<{
89
- unmount(): void;
90
- }>;
91
- }
92
- }
93
- declare const CLIENT_NAV_SCRIPT: string;
94
-
95
- interface Frontmatter {
96
- title?: string;
97
- [key: string]: unknown;
98
- }
99
- interface ContentEntry {
100
- filePath: string;
101
- routePath: string;
102
- slug: string;
103
- frontmatter: Frontmatter;
104
- body: string;
105
- }
106
- declare function scanContent(rootDir: string): ContentEntry[];
107
- declare function escapeHtml(s: string): string;
108
- declare function renderMarkdown(md: string): string;
109
-
110
27
  interface ImageProxyOptions {
111
28
  /** Hostnames allowed to be proxied, e.g. ["stardance.hackclub.com"]. Required — an empty/missing list disables the route (404). */
112
29
  remoteHosts?: string[];
@@ -504,7 +421,7 @@ interface RouteProps {
504
421
  params: Record<string, string>;
505
422
  loaderData?: Record<string, unknown>;
506
423
  }
507
- interface CreateAppOptions {
424
+ interface CreateAppOptions$1 {
508
425
  /** Primary route directory (legacy — mixes pages, api, layouts together). */
509
426
  routesDir?: string;
510
427
  /** Separate directory for page routes (preferred over routesDir when set). */
@@ -611,9 +528,73 @@ interface AppServeOptions {
611
528
  interface RevalidateOptions {
612
529
  revalidate?: number;
613
530
  }
531
+
532
+ /** Public application options, including opt-in per-process backpressure. */
533
+ interface CreateAppOptions extends CreateAppOptions$1 {
534
+ /**
535
+ * Bounds requests admitted into the application request pipeline for this
536
+ * process. `undefined`/`false` keeps the existing unbounded behavior.
537
+ *
538
+ * Liveness/readiness probes, an enabled built-in `/metrics` endpoint, and
539
+ * the development live-reload stream bypass admission so overload cannot
540
+ * make the process look dead or consume a permanent slot with the dev SSE
541
+ * connection.
542
+ */
543
+ backpressure?: BackpressureOptions | false;
544
+ }
545
+ /** Type-safe config helper for x.config.ts. */
614
546
  declare function defineConfig(config: CreateAppOptions): CreateAppOptions;
547
+ /**
548
+ * Creates the normal application and, when configured, places one bounded
549
+ * admission gate in front of its request pipeline.
550
+ *
551
+ * The controller is per `createApp()` call/process. Saturation returns 503 +
552
+ * Retry-After. A client that disconnects while queued is removed without
553
+ * entering the application pipeline or being turned into a false 500.
554
+ *
555
+ * Rate limiting remains the existing inner createApp policy. The two controls
556
+ * keep distinct semantics (429 policy vs 503 process capacity), but if the
557
+ * process is already saturated the outer admission gate can return 503 before
558
+ * the request reaches the inner rate limiter.
559
+ */
615
560
  declare function createApp(options: CreateAppOptions): Promise<AppServeOptions>;
616
561
 
562
+ /**
563
+ * Inline client-side navigation script.
564
+ *
565
+ * Embedded directly into every rendered page as a <script> tag (see render.ts).
566
+ * Intercepts same-origin <a> clicks, fetches the destination page, and swaps
567
+ * the #root element's content in place. Includes hover-prefetch and popstate
568
+ * (back/forward) support.
569
+ *
570
+ * Opt-out attributes on <a> / <Link />:
571
+ * - data-no-nav — skip client navigation (full page load)
572
+ * - data-no-prefetch — skip hover prefetch (navigation still works)
573
+ */
574
+ declare global {
575
+ interface Window {
576
+ __xIslandRoots?: Array<{
577
+ unmount(): void;
578
+ }>;
579
+ }
580
+ }
581
+ declare const CLIENT_NAV_SCRIPT: string;
582
+
583
+ interface Frontmatter {
584
+ title?: string;
585
+ [key: string]: unknown;
586
+ }
587
+ interface ContentEntry {
588
+ filePath: string;
589
+ routePath: string;
590
+ slug: string;
591
+ frontmatter: Frontmatter;
592
+ body: string;
593
+ }
594
+ declare function scanContent(rootDir: string): ContentEntry[];
595
+ declare function escapeHtml(s: string): string;
596
+ declare function renderMarkdown(md: string): string;
597
+
617
598
  declare function renderErrorOverlay(error: unknown): string;
618
599
 
619
600
  interface ImageProps {
@@ -1028,6 +1009,25 @@ declare function enforceRequestBodySize(req: Request, maxBytes: number): Request
1028
1009
  * bundle is a build error, not a warning — secrets like `STRIPE_SECRET_KEY`
1029
1010
  * or `DATABASE_URL` must never round-trip through the bundler into
1030
1011
  * browser-shipped JS.
1012
+ *
1013
+ * Two layers of defense, run together at every client-bundle call site:
1014
+ * - `findLeakedEnvKeys` / `assertNoEnvLeakage`: a static scan for the
1015
+ * *syntax* `process.env.X` (and the `Bun.env` / `import.meta.env`
1016
+ * equivalents) in the bundled output. This is what catches a leak today,
1017
+ * since the pinned Bun toolchain preserves that syntax rather than
1018
+ * inlining it.
1019
+ * - `findLeakedEnvValues`: a scan for the literal serialized *value* of any
1020
+ * non-public env var in the bundled output, regardless of what syntax (if
1021
+ * any) produced it. This exists so a future bundler/config change that
1022
+ * inlines `process.env.X` into a string literal — which would make the
1023
+ * key-scan above match nothing — still gets caught. Restricted to
1024
+ * sensitive-looking names/values (see `isSensitiveEnvKey` / `looksRandom`)
1025
+ * so ordinary values like `VERCEL_ENV=production` don't fail real builds
1026
+ * just because the word "production" also appears somewhere in the
1027
+ * bundle.
1028
+ * Neither catches a value that a build plugin re-encodes (e.g. base64,
1029
+ * concatenation) before it lands in the bundle; that's a known gap, not a
1030
+ * silent one, since both scans run on the final emitted text.
1031
1031
  */
1032
1032
  declare const PUBLIC_ENV_PREFIX = "THEXJS_PUBLIC_";
1033
1033
  /**
@@ -1039,7 +1039,7 @@ declare function findLeakedEnvKeys(code: string): string[];
1039
1039
  declare class EnvLeakageError extends Error {
1040
1040
  readonly file: string;
1041
1041
  readonly keys: string[];
1042
- constructor(file: string, keys: string[]);
1042
+ constructor(file: string, keys: string[], kind?: "access" | "value");
1043
1043
  }
1044
1044
  /** Throws EnvLeakageError if the given bundle source references non-public env vars. */
1045
1045
  declare function assertNoEnvLeakage(code: string, file: string): void;
@@ -1105,4 +1105,4 @@ declare function resetServerFunctions(): void;
1105
1105
  declare function registerServerFunctions(routePath: string, paramNames: string[], fns: Record<string, (...args: unknown[]) => Promise<unknown>>): void;
1106
1106
  declare function getServerFunctionHandler(csrfOptions?: CsrfOptions): (req: Request) => Promise<Response | null>;
1107
1107
 
1108
- export { type AuditEntry, type AuditEvent, type AuditSink, type BackpressureController, type BackpressureHandler, type BackpressureLease, type BackpressureOptions, BackpressureSaturatedError, type BackpressureSnapshot, type BuildOptions, CLIENT_NAV_SCRIPT, type ContentEntry, type CounterSeries, type CreateAppOptions, type CsrfOptions, type CsrfResult, DEFAULT_HISTOGRAM_BUCKETS_MS, DEFAULT_MAX_BODY_SIZE, DefaultNotFound, EnvLeakageError, type ErrorContext, type ErrorReporter, type Frontmatter, type HealthCheck, type HealthCheckOptions, type HistogramSeries, Image, type ImageProps, type ImageProxyOptions, type InMemoryMetricsOptions, type InMemoryMetricsReporter, Island, type IslandEntry, type IslandMode, IslandProvider, type LayoutEntry, Link, type LinkProps, type LoaderArgs, type LoaderReturn, type LogFields, type Logger, type MetricLabels, type MetricsReporter, type MetricsSnapshot, type MiddlewareContext, type MiddlewareEntry, type MiddlewareFn, type MiddlewareNext, type NotFoundEntry, OTEL_ERROR_STATUS_CODE, type OtelMeterLike, type OtelTracerLike, PUBLIC_ENV_PREFIX, type ProcessCrashHandlerOptions, REDACTED, type RateLimitOptions, type RateLimitResult, type RateLimitStore, type ReadinessResult, RequestBodyTooLargeError, type RevalidateOptions, type RouteEntry, type RouteMode, type RouteProps, SRCSET_WIDTHS, type SecurityHeadersOptions, type SentryLike, type TraceSpan, type TracerLike, type TrustedProxyOptions, applySecurityHeaders, assertNoEnvLeakage, audit, auditLoginFailure, auditLoginSuccess, auditLogout, auditPasswordChanged, auditPermissionDenied, auditRoleChanged, auditSessionRevoked, build, buildSecurityHeaders, buildSrcSet, checkCsrf, clientIpFromRequest, combineReporters, composeMiddleware, configureTrustedProxy, createApp, createBackpressureController, createConsoleAuditSink, createHealthCheckHandler, createImageProxyHandler, createInMemoryMetrics, createOtelReporter, createOtlpMetricsReporter, createRateLimiter, createRedisRateLimitStore, createSentryReporter, dbTraceAttributes, defineConfig, enforceRequestBodySize, escapeHtml, findLayoutChain, findLeakedEnvKeys, findMiddlewareChain, generateCsrfToken, generateManifestSource, generateServerFunctionClient, getAuditSink, getErrorReporter, getServerFunctionHandler, getTracer, installProcessCrashHandlers, isSensitiveKey, isTrustedProxy, logger, noopAuditSink, noopMetrics, noopReporter, rateLimitMiddleware, redactString, redactValue, registerServerFunctions, renderErrorOverlay, renderMarkdown, renderPage, renderStaticPage, renderStreamingPage, reportException, requestIdFromRequest, resetServerFunctions, resetTrustedProxy, runWithRequestSpan, scanApiDir, scanContent, scanLayouts, scanLayoutsDir, scanMiddleware, scanNotFound, scanPages, scanRoutes, setAuditSink, setErrorReporter, setImageRemoteHosts, setTracer, tracePhase, tracePhaseSync, traceRequestId, verifyCsrfToken, verifyOrigin, withBackpressure, withCsrfCookie, withRequestLogging, withRequestMetrics, withRequestTracing, writeManifest };
1108
+ export { type AuditEntry, type AuditEvent, type AuditSink, BackpressureOptions, type BuildOptions, CLIENT_NAV_SCRIPT, type ContentEntry, type CounterSeries, type CreateAppOptions, type CsrfOptions, type CsrfResult, DEFAULT_HISTOGRAM_BUCKETS_MS, DEFAULT_MAX_BODY_SIZE, DefaultNotFound, EnvLeakageError, type ErrorContext, type ErrorReporter, type Frontmatter, type HealthCheck, type HealthCheckOptions, type HistogramSeries, Image, type ImageProps, type ImageProxyOptions, type InMemoryMetricsOptions, type InMemoryMetricsReporter, Island, type IslandEntry, type IslandMode, IslandProvider, type LayoutEntry, Link, type LinkProps, type LoaderArgs, type LoaderReturn, type LogFields, type Logger, type MetricLabels, type MetricsReporter, type MetricsSnapshot, type MiddlewareContext, type MiddlewareEntry, type MiddlewareFn, type MiddlewareNext, type NotFoundEntry, OTEL_ERROR_STATUS_CODE, type OtelMeterLike, type OtelTracerLike, PUBLIC_ENV_PREFIX, type ProcessCrashHandlerOptions, REDACTED, type RateLimitOptions, type RateLimitResult, type RateLimitStore, type ReadinessResult, RequestBodyTooLargeError, type RevalidateOptions, type RouteEntry, type RouteMode, type RouteProps, SRCSET_WIDTHS, type SecurityHeadersOptions, type SentryLike, type TraceSpan, type TracerLike, type TrustedProxyOptions, applySecurityHeaders, assertNoEnvLeakage, audit, auditLoginFailure, auditLoginSuccess, auditLogout, auditPasswordChanged, auditPermissionDenied, auditRoleChanged, auditSessionRevoked, build, buildSecurityHeaders, buildSrcSet, checkCsrf, clientIpFromRequest, combineReporters, composeMiddleware, configureTrustedProxy, createApp, createConsoleAuditSink, createHealthCheckHandler, createImageProxyHandler, createInMemoryMetrics, createOtelReporter, createOtlpMetricsReporter, createRateLimiter, createRedisRateLimitStore, createSentryReporter, dbTraceAttributes, defineConfig, enforceRequestBodySize, escapeHtml, findLayoutChain, findLeakedEnvKeys, findMiddlewareChain, generateCsrfToken, generateManifestSource, generateServerFunctionClient, getAuditSink, getErrorReporter, getServerFunctionHandler, getTracer, installProcessCrashHandlers, isSensitiveKey, isTrustedProxy, logger, noopAuditSink, noopMetrics, noopReporter, rateLimitMiddleware, redactString, redactValue, registerServerFunctions, renderErrorOverlay, renderMarkdown, renderPage, renderStaticPage, renderStreamingPage, reportException, requestIdFromRequest, resetServerFunctions, resetTrustedProxy, runWithRequestSpan, scanApiDir, scanContent, scanLayouts, scanLayoutsDir, scanMiddleware, scanNotFound, scanPages, scanRoutes, setAuditSink, setErrorReporter, setImageRemoteHosts, setTracer, tracePhase, tracePhaseSync, traceRequestId, verifyCsrfToken, verifyOrigin, withCsrfCookie, withRequestLogging, withRequestMetrics, withRequestTracing, writeManifest };