@teyik0/furin 0.4.0-alpha.2 → 0.5.0-alpha.2

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.
Files changed (129) hide show
  1. package/dist/build/compile-entry.d.ts +2 -1
  2. package/dist/build/compile-entry.ts +17 -13
  3. package/dist/build/elysia-aot.d.ts +9 -0
  4. package/dist/build/entry-template.d.ts +5 -1
  5. package/dist/build/entry-template.ts +27 -6
  6. package/dist/build/index.js +969 -528
  7. package/dist/build/private-server-sourcemaps.d.ts +2 -0
  8. package/dist/build/server-app-entry.d.ts +12 -0
  9. package/dist/build/types.d.ts +2 -0
  10. package/dist/cache.d.ts +1 -0
  11. package/dist/cache.js +185 -0
  12. package/dist/cli/index.js +983 -541
  13. package/dist/client/document.d.ts +2 -0
  14. package/dist/client/internal/runtime-types.d.ts +8 -1
  15. package/dist/client/link.js +232 -11
  16. package/dist/client/sync.d.ts +1 -0
  17. package/dist/client.js +11 -0
  18. package/dist/config.d.ts +28 -22
  19. package/dist/config.js +25 -2
  20. package/dist/define-route.d.ts +273 -1009
  21. package/dist/furin.d.ts +20 -5
  22. package/dist/furin.js +6431 -5457
  23. package/dist/plugin/routes.d.ts +6 -0
  24. package/dist/rsc-client.js +9 -1
  25. package/dist/rsc.js +19 -7
  26. package/dist/server/assets/production.d.ts +3 -0
  27. package/dist/server/auto-invalidate/plugin.d.ts +8 -24
  28. package/dist/server/auto-invalidate/runtime.d.ts +2 -2
  29. package/dist/server/browser-events/shutdown.d.ts +3 -0
  30. package/dist/server/cache/invalidation.d.ts +1 -1
  31. package/dist/server/cache/page-cache-state.d.ts +5 -0
  32. package/dist/server/cache/page-cache.d.ts +53 -0
  33. package/dist/server/cache/redis/index.d.ts +41 -0
  34. package/dist/server/cache/redis/index.js +451 -0
  35. package/dist/server/cache/redis/scripts.d.ts +6 -0
  36. package/dist/server/context-logger.d.ts +2 -2
  37. package/dist/server/dev/plugin.d.ts +1 -0
  38. package/dist/server/dev/runtime.production.d.ts +1 -0
  39. package/dist/server/dev-page-plugin.d.ts +7 -0
  40. package/dist/server/evlog.d.ts +14 -0
  41. package/dist/server/internal.d.ts +6 -0
  42. package/dist/server/internal.js +2539 -0
  43. package/dist/server/production-server.d.ts +13 -0
  44. package/dist/server/production-server.js +2906 -0
  45. package/dist/server/render/not-found.d.ts +1 -1
  46. package/dist/server/render/ssg.d.ts +5 -0
  47. package/dist/server/render/static-params.d.ts +4 -0
  48. package/dist/server/router/defined-route.d.ts +1 -1
  49. package/dist/server/router/hmr.d.ts +6 -0
  50. package/dist/server/router/hmr.production.d.ts +5 -0
  51. package/dist/server/router/plugin.d.ts +5 -1
  52. package/dist/server/router/schemas.d.ts +1 -0
  53. package/dist/server/sync/index.js +798 -117
  54. package/dist/server/sync/plugin.d.ts +31 -158
  55. package/dist/server/sync/stream.d.ts +38 -49
  56. package/dist/shared/elysia-contract.d.ts +8 -14
  57. package/dist/shared/production-build.d.ts +2 -0
  58. package/package.json +19 -8
  59. package/src/adapter/README.md +9 -2
  60. package/src/adapter/bun.ts +146 -41
  61. package/src/adapter/package.ts +6 -2
  62. package/src/adapter/runtime-build.ts +11 -4
  63. package/src/adapter/static.ts +8 -6
  64. package/src/adapter/vercel.ts +64 -31
  65. package/src/build/client.ts +18 -1
  66. package/src/build/compile-entry.ts +17 -13
  67. package/src/build/elysia-aot.ts +102 -0
  68. package/src/build/entry-template.ts +27 -6
  69. package/src/build/hydrate.ts +5 -1
  70. package/src/build/index.ts +5 -5
  71. package/src/build/private-server-sourcemaps.ts +20 -0
  72. package/src/build/production-instrumentation.ts +2 -2
  73. package/src/build/server-app-entry.ts +61 -0
  74. package/src/build/shared.ts +3 -1
  75. package/src/build/ssg-cache.ts +5 -10
  76. package/src/build/types.ts +2 -0
  77. package/src/build/virtual-entry.ts +5 -4
  78. package/src/cache.ts +12 -0
  79. package/src/cli/config.ts +3 -3
  80. package/src/cli/index.ts +6 -2
  81. package/src/client/document.tsx +19 -0
  82. package/src/client/internal/runtime-types.ts +10 -1
  83. package/src/client/sync.ts +1 -0
  84. package/src/config.ts +33 -4
  85. package/src/define-route.ts +266 -128
  86. package/src/furin.ts +168 -154
  87. package/src/plugin/route-config-autofix.ts +11 -2
  88. package/src/plugin/routes.ts +85 -29
  89. package/src/rsc/codec.ts +11 -6
  90. package/src/rsc/render-error.ts +3 -1
  91. package/src/server/assets/production.ts +99 -0
  92. package/src/server/auto-invalidate/plugin.ts +4 -4
  93. package/src/server/auto-invalidate/runtime.ts +74 -42
  94. package/src/server/browser-events/plugin.ts +13 -1
  95. package/src/server/browser-events/shutdown.ts +32 -0
  96. package/src/server/cache/invalidation.ts +61 -20
  97. package/src/server/cache/page-cache-state.ts +22 -0
  98. package/src/server/cache/page-cache.ts +300 -0
  99. package/src/server/cache/redis/index.ts +367 -0
  100. package/src/server/cache/redis/scripts.ts +200 -0
  101. package/src/server/context-logger.ts +5 -5
  102. package/src/server/dev/plugin.ts +10 -1
  103. package/src/server/dev/runtime.production.ts +4 -0
  104. package/src/server/dev-page-plugin.ts +54 -10
  105. package/src/server/evlog.ts +106 -0
  106. package/src/server/internal.ts +7 -0
  107. package/src/server/production-server.ts +135 -0
  108. package/src/server/render/document.tsx +7 -1
  109. package/src/server/render/isr.ts +480 -132
  110. package/src/server/render/loaders.ts +18 -12
  111. package/src/server/render/not-found.ts +4 -4
  112. package/src/server/render/ppr-document.ts +2 -2
  113. package/src/server/render/ppr-route.ts +193 -7
  114. package/src/server/render/ssg.ts +148 -4
  115. package/src/server/render/ssr.ts +6 -7
  116. package/src/server/render/static-params.ts +174 -0
  117. package/src/server/render/template.ts +5 -1
  118. package/src/server/router/defined-route.ts +2 -1
  119. package/src/server/router/discovery.ts +3 -1
  120. package/src/server/router/hmr.production.ts +11 -0
  121. package/src/server/router/hmr.ts +85 -76
  122. package/src/server/router/plugin.ts +118 -50
  123. package/src/server/router/schema-merge.ts +10 -3
  124. package/src/server/router/schemas.ts +174 -61
  125. package/src/server/sync/plugin.ts +14 -10
  126. package/src/server/sync/response.ts +3 -3
  127. package/src/server/sync/stream.ts +43 -2
  128. package/src/shared/elysia-contract.ts +23 -25
  129. package/src/shared/production-build.ts +20 -0
@@ -3,6 +3,7 @@ import type { HeadOptions } from "../client.ts";
3
3
  export interface DocumentAssets {
4
4
  buildId: string | undefined;
5
5
  entryModule: string | undefined;
6
+ extensionErrorFilterScript?: string;
6
7
  faviconHref: string | undefined;
7
8
  frameworkModules: readonly string[];
8
9
  staticMode: boolean;
@@ -12,6 +13,7 @@ export interface DocumentState {
12
13
  assets: DocumentAssets;
13
14
  dataJson: string | undefined;
14
15
  head: HeadOptions | undefined;
16
+ routeFrames?: string;
15
17
  syncJson: string | undefined;
16
18
  }
17
19
  export declare function DocumentProvider({ children, value, }: {
@@ -3,6 +3,12 @@ import type { HeadOptions, RenderingMode } from "../../client.ts";
3
3
  import type { RequestLoaderContext } from "../../define-route.ts";
4
4
  export type RuntimeData = Record<string, unknown>;
5
5
  type Awaitable<T> = Promise<T> | T;
6
+ export interface RuntimeParams {
7
+ [key: string]: string;
8
+ }
9
+ export type RuntimeStaticParams = (context: RuntimeData & {
10
+ params: RuntimeParams;
11
+ }) => Awaitable<readonly RuntimeParams[]>;
6
12
  export interface RuntimeRoute {
7
13
  __type: "FURIN_ROUTE";
8
14
  layout?: React.FC<RuntimeData & {
@@ -16,6 +22,7 @@ export interface RuntimeRoute {
16
22
  requestLoader?: (ctx: RequestLoaderContext) => Awaitable<object>;
17
23
  revalidate?: number;
18
24
  sourcePath?: string;
25
+ staticParams?: RuntimeStaticParams;
19
26
  tags?: string[];
20
27
  }
21
28
  export interface RuntimePage {
@@ -26,7 +33,7 @@ export interface RuntimePage {
26
33
  loader?: (ctx: RuntimeData) => Awaitable<RuntimeData>;
27
34
  mode?: RenderingMode;
28
35
  revalidate?: number;
29
- staticParams?: () => Awaitable<Record<string, string>[]>;
36
+ staticParams?: RuntimeStaticParams;
30
37
  tags?: string[];
31
38
  }
32
39
  export {};
@@ -709,6 +709,10 @@ function HeadContent() {
709
709
  }
710
710
  return /* @__PURE__ */ jsxDEV2(Fragment, {
711
711
  children: [
712
+ state.assets.extensionErrorFilterScript === undefined ? null : /* @__PURE__ */ jsxDEV2("script", {
713
+ dangerouslySetInnerHTML: { __html: state.assets.extensionErrorFilterScript },
714
+ "data-furin-extension-error-filter": ""
715
+ }, undefined, false, undefined, this),
712
716
  /* @__PURE__ */ jsxDEV2("meta", {
713
717
  charSet: "utf-8",
714
718
  "data-furin-head": ""
@@ -766,6 +770,13 @@ function Scripts() {
766
770
  id: "__FURIN_DATA__",
767
771
  type: "application/json"
768
772
  }, undefined, false, undefined, this),
773
+ state.routeFrames === undefined ? null : /* @__PURE__ */ jsxDEV2("template", {
774
+ dangerouslySetInnerHTML: {
775
+ __html: state.routeFrames.replaceAll("&", "&amp;").replaceAll("<", "&lt;")
776
+ },
777
+ "data-furin-document-state": "",
778
+ id: "__FURIN_ROUTE_FRAMES__"
779
+ }, undefined, false, undefined, this),
769
780
  /* @__PURE__ */ jsxDEV2("script", {
770
781
  dangerouslySetInnerHTML: { __html: serializeJson(state.head ?? {}) },
771
782
  "data-furin-scripts": "",
@@ -1037,12 +1048,15 @@ function useNavigate() {
1037
1048
  return router.navigate(href, opts);
1038
1049
  }, [router]);
1039
1050
  }
1040
- // ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/utils.mjs
1051
+ // ../../node_modules/.bun/evlog@2.29.0+6594568e47c8e14b/node_modules/evlog/dist/utils.mjs
1041
1052
  function formatDuration(ms) {
1042
1053
  if (ms < 1000)
1043
1054
  return `${Math.round(ms)}ms`;
1044
1055
  return `${(ms / 1000).toFixed(2)}s`;
1045
1056
  }
1057
+ function isServer() {
1058
+ return typeof window === "undefined";
1059
+ }
1046
1060
  function isBrowser() {
1047
1061
  if (typeof window === "undefined")
1048
1062
  return false;
@@ -1161,7 +1175,7 @@ function isoNow() {
1161
1175
  return `${_isoCachedPrefix}.${String(now % 1000).padStart(3, "0")}Z`;
1162
1176
  }
1163
1177
 
1164
- // ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/redact-C7FmdhwI.mjs
1178
+ // ../../node_modules/.bun/evlog@2.29.0+6594568e47c8e14b/node_modules/evlog/dist/redact-C7FmdhwI.mjs
1165
1179
  var DEFAULT_REPLACEMENT = "[REDACTED]";
1166
1180
  function normalizeRedactPathPattern(pattern) {
1167
1181
  if (!pattern.includes("*") && !pattern.includes("."))
@@ -1464,7 +1478,7 @@ function applyMaskers(value, maskers) {
1464
1478
  return result;
1465
1479
  }
1466
1480
 
1467
- // ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/globalRegistry-Bh3bIGwA.mjs
1481
+ // ../../node_modules/.bun/evlog@2.29.0+6594568e47c8e14b/node_modules/evlog/dist/globalRegistry-Bh3bIGwA.mjs
1468
1482
  function logPluginError(name, hook, err) {
1469
1483
  console.error(`[evlog/${name}] ${hook} failed:`, err);
1470
1484
  }
@@ -1622,7 +1636,7 @@ function getRegistry() {
1622
1636
  }
1623
1637
  var globalConfig = getRegistry().config;
1624
1638
 
1625
- // ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/pretty-error-DTIHxnBN.mjs
1639
+ // ../../node_modules/.bun/evlog@2.29.0+6594568e47c8e14b/node_modules/evlog/dist/pretty-error-D8rlWNL1.mjs
1626
1640
  var snippetReader = null;
1627
1641
  var PRETTY_ERROR_TREE_SPACER = "__EVLOG_TREE_SPACER__";
1628
1642
  function pushTreeSpacer(children) {
@@ -1721,6 +1735,17 @@ function formatDisplayPath(file, cwd) {
1721
1735
  return decoded.slice(srcIdx + 1);
1722
1736
  return decoded;
1723
1737
  }
1738
+ function compactStackForStorage(stack, maxFrames = 5) {
1739
+ if (!stack)
1740
+ return;
1741
+ const head = stack.split(`
1742
+ `)[0] ?? "";
1743
+ const useful = parseStackFrames(stack).filter((f) => f.file && f.line && f.isApp && !isInternalErrorFrame(f)).slice(0, maxFrames);
1744
+ if (useful.length === 0)
1745
+ return stack;
1746
+ return [head, ...useful.map((f) => f.raw)].join(`
1747
+ `);
1748
+ }
1724
1749
  function parseStackFrames(stack) {
1725
1750
  if (!stack)
1726
1751
  return [];
@@ -1844,7 +1869,7 @@ function formatGuidanceLine(label, text, labelColor) {
1844
1869
  let remaining = text.trim();
1845
1870
  let first = true;
1846
1871
  while (remaining.length > 0) {
1847
- const budget = first ? Math.max(24, GUIDANCE_WRAP_WIDTH - prefix.length) : Math.max(24, GUIDANCE_WRAP_WIDTH - 5);
1872
+ const budget = first ? Math.max(24, GUIDANCE_WRAP_WIDTH - prefix.length) : Math.max(24, 71);
1848
1873
  if (remaining.length <= budget) {
1849
1874
  lines.push(first ? `${prefix}${remaining}` : `${GUIDANCE_CONTINUATION}${remaining}`);
1850
1875
  break;
@@ -1912,7 +1937,7 @@ function buildErrorEntries(error, options = {}) {
1912
1937
  }];
1913
1938
  }
1914
1939
 
1915
- // ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/dev-terminal-Brarc6vc.mjs
1940
+ // ../../node_modules/.bun/evlog@2.29.0+6594568e47c8e14b/node_modules/evlog/dist/dev-terminal-Brarc6vc.mjs
1916
1941
  var DEV_PRESETS = {
1917
1942
  evlog: {
1918
1943
  frameworkOverlay: false,
@@ -1961,7 +1986,7 @@ function resolveDevTerminal(input = {}) {
1961
1986
  };
1962
1987
  }
1963
1988
 
1964
- // ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/wideEventChannel-BUDW48oP.mjs
1989
+ // ../../node_modules/.bun/evlog@2.29.0+6594568e47c8e14b/node_modules/evlog/dist/wideEventChannel-BUDW48oP.mjs
1965
1990
  var publisher = null;
1966
1991
  function publishWideEvent(event) {
1967
1992
  if (!publisher)
@@ -1973,7 +1998,117 @@ function publishWideEvent(event) {
1973
1998
  }
1974
1999
  }
1975
2000
 
1976
- // ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/audit-CW8wdQDm.mjs
2001
+ // ../../node_modules/.bun/evlog@2.29.0+6594568e47c8e14b/node_modules/evlog/dist/error-brand-D0-DCPvr.mjs
2002
+ var evlogErrorBrand = Symbol.for("evlog.error.brand");
2003
+ function isEvlogError(error) {
2004
+ return typeof error === "object" && error !== null && error[evlogErrorBrand] === true;
2005
+ }
2006
+
2007
+ // ../../node_modules/.bun/evlog@2.29.0+6594568e47c8e14b/node_modules/evlog/dist/error.mjs
2008
+ var evlogErrorInternalKey = Symbol.for("evlog.error.internal");
2009
+ var evlogErrorDataKey = Symbol.for("evlog.error.data");
2010
+ var EvlogError = class EvlogError extends Error {
2011
+ static isEvlogError(error) {
2012
+ return isEvlogError(error);
2013
+ }
2014
+ code;
2015
+ status;
2016
+ why;
2017
+ fix;
2018
+ link;
2019
+ get internal() {
2020
+ return this[evlogErrorInternalKey];
2021
+ }
2022
+ constructor(options) {
2023
+ const opts = typeof options === "string" ? { message: options } : options;
2024
+ super(opts.message, { cause: opts.cause });
2025
+ this.name = "EvlogError";
2026
+ this.code = opts.code;
2027
+ this.status = opts.status ?? 500;
2028
+ this.why = opts.why;
2029
+ this.fix = opts.fix;
2030
+ this.link = opts.link;
2031
+ if (opts.internal !== undefined)
2032
+ Object.defineProperty(this, evlogErrorInternalKey, {
2033
+ value: opts.internal,
2034
+ enumerable: false,
2035
+ writable: false,
2036
+ configurable: true
2037
+ });
2038
+ if (opts.data !== undefined)
2039
+ Object.defineProperty(this, evlogErrorDataKey, {
2040
+ value: opts.data,
2041
+ enumerable: false,
2042
+ writable: false,
2043
+ configurable: true
2044
+ });
2045
+ if (Error.captureStackTrace)
2046
+ Error.captureStackTrace(this, EvlogError);
2047
+ }
2048
+ get statusText() {
2049
+ return this.message;
2050
+ }
2051
+ get statusCode() {
2052
+ return this.status;
2053
+ }
2054
+ get statusMessage() {
2055
+ return this.message;
2056
+ }
2057
+ get data() {
2058
+ const extra = this[evlogErrorDataKey];
2059
+ if (!extra && !this.code && !this.why && !this.fix && !this.link)
2060
+ return;
2061
+ return {
2062
+ ...extra,
2063
+ ...this.code !== undefined && { code: this.code },
2064
+ ...this.why !== undefined && { why: this.why },
2065
+ ...this.fix !== undefined && { fix: this.fix },
2066
+ ...this.link !== undefined && { link: this.link }
2067
+ };
2068
+ }
2069
+ toString() {
2070
+ const useColors = isServer();
2071
+ const red = useColors ? colors.red : "";
2072
+ const yellow = useColors ? colors.yellow : "";
2073
+ const cyan = useColors ? colors.cyan : "";
2074
+ const dim = useColors ? colors.dim : "";
2075
+ const reset = useColors ? colors.reset : "";
2076
+ const bold = useColors ? colors.bold : "";
2077
+ const lines = [];
2078
+ lines.push(`${red}${bold}Error:${reset} ${this.message}`);
2079
+ if (this.code)
2080
+ lines.push(`${dim}Code:${reset} ${this.code}`);
2081
+ if (this.why)
2082
+ lines.push(`${yellow}Why:${reset} ${this.why}`);
2083
+ if (this.fix)
2084
+ lines.push(`${cyan}Fix:${reset} ${this.fix}`);
2085
+ if (this.link)
2086
+ lines.push(`${dim}More info:${reset} ${this.link}`);
2087
+ if (this.cause)
2088
+ lines.push(`${dim}Caused by:${reset} ${this.cause.message}`);
2089
+ return lines.join(`
2090
+ `);
2091
+ }
2092
+ toJSON() {
2093
+ const { data } = this;
2094
+ return {
2095
+ name: this.name,
2096
+ message: this.message,
2097
+ status: this.status,
2098
+ ...data && { data },
2099
+ ...this.cause instanceof Error && { cause: {
2100
+ name: this.cause.name,
2101
+ message: this.cause.message
2102
+ } }
2103
+ };
2104
+ }
2105
+ };
2106
+ Object.defineProperty(EvlogError.prototype, evlogErrorBrand, {
2107
+ value: true,
2108
+ enumerable: false
2109
+ });
2110
+
2111
+ // ../../node_modules/.bun/evlog@2.29.0+6594568e47c8e14b/node_modules/evlog/dist/audit-C8euLMvu.mjs
1977
2112
  var nativeStdoutWrite = typeof process !== "undefined" && typeof process.stdout?.write === "function" ? process.stdout.write.bind(process.stdout) : undefined;
1978
2113
  function writePrettyStdout(text) {
1979
2114
  (globalThis.__evlogNativeStdoutWrite ?? nativeStdoutWrite)?.(text);
@@ -2056,13 +2191,14 @@ function emitWideEvent(level, event, options = {}) {
2056
2191
  formatted = redactEvent(formatted, state.redact);
2057
2192
  markGloballyRedacted(formatted);
2058
2193
  }
2059
- if (!state.silent)
2194
+ if (!state.silent) {
2060
2195
  if (state.pretty)
2061
2196
  prettyPrintWideEvent(formatted);
2062
2197
  else if (state.stringify)
2063
2198
  console[getConsoleMethod(level)](JSON.stringify(formatted));
2064
2199
  else
2065
2200
  console[getConsoleMethod(level)](formatted);
2201
+ }
2066
2202
  if (!deferDrain) {
2067
2203
  publishWideEvent(formatted);
2068
2204
  const drainPromises = [];
@@ -2113,11 +2249,12 @@ function formatValue(value) {
2113
2249
  if (isPlainObject$1(value)) {
2114
2250
  const pairs = [];
2115
2251
  for (const [k, v] of Object.entries(value))
2116
- if (v !== undefined && v !== null)
2252
+ if (v !== undefined && v !== null) {
2117
2253
  if (typeof v === "object")
2118
2254
  pairs.push(`${k}=${JSON.stringify(v)}`);
2119
2255
  else
2120
2256
  pairs.push(`${k}=${v}`);
2257
+ }
2121
2258
  return pairs.join(" ");
2122
2259
  }
2123
2260
  return String(value);
@@ -2172,6 +2309,22 @@ function asToolCallArray(value) {
2172
2309
  return;
2173
2310
  return value.every(isToolCallEntry) ? value : undefined;
2174
2311
  }
2312
+ var CAPTURED_LINE_MAX_LENGTH = 160;
2313
+ var CAPTURED_MAX_LINES = 8;
2314
+ function asCapturedLines(value) {
2315
+ if (typeof value !== "string" || value.length === 0)
2316
+ return;
2317
+ const lines = value.split(`
2318
+ `).map((line) => {
2319
+ return line.length > CAPTURED_LINE_MAX_LENGTH ? `${line.slice(0, CAPTURED_LINE_MAX_LENGTH)}\u2026` : line;
2320
+ });
2321
+ if (lines.length > CAPTURED_MAX_LINES) {
2322
+ lines.length = CAPTURED_MAX_LINES;
2323
+ lines.push(`+${value.split(`
2324
+ `).length - CAPTURED_MAX_LINES} more lines (full text in the event)`);
2325
+ }
2326
+ return lines;
2327
+ }
2175
2328
  function buildAIEntries(ai) {
2176
2329
  const entries = [];
2177
2330
  const headerParts = [];
@@ -2266,7 +2419,7 @@ function buildAIEntries(ai) {
2266
2419
  value: "",
2267
2420
  children
2268
2421
  });
2269
- } else if (toolCalls?.length)
2422
+ } else if (toolCalls?.length) {
2270
2423
  if (toolCallEntries?.length) {
2271
2424
  const children = toolCallEntries.map((tc) => {
2272
2425
  const inputStr = serializeToolInput(tc.input);
@@ -2286,6 +2439,7 @@ function buildAIEntries(ai) {
2286
2439
  value: names.join(", ")
2287
2440
  });
2288
2441
  }
2442
+ }
2289
2443
  const stepsUsage = Array.isArray(ai.stepsUsage) ? ai.stepsUsage.filter(isPlainObject$1) : undefined;
2290
2444
  if (stepsUsage?.length) {
2291
2445
  const firstModel = stepsUsage[0]?.model;
@@ -2307,6 +2461,20 @@ function buildAIEntries(ai) {
2307
2461
  key: "ai.steps",
2308
2462
  value: String(steps)
2309
2463
  });
2464
+ const promptLines = asCapturedLines(ai.prompt);
2465
+ if (promptLines)
2466
+ entries.push({
2467
+ key: "ai.prompt",
2468
+ value: "",
2469
+ children: promptLines
2470
+ });
2471
+ const outputLines = asCapturedLines(ai.output);
2472
+ if (outputLines)
2473
+ entries.push({
2474
+ key: "ai.output",
2475
+ value: "",
2476
+ children: outputLines
2477
+ });
2310
2478
  const embedding = isPlainObject$1(ai.embedding) ? ai.embedding : undefined;
2311
2479
  if (embedding) {
2312
2480
  const parts = [];
@@ -2457,10 +2625,63 @@ function prettyPrintWideEvent(event) {
2457
2625
  if (!browser && lines.length > 0)
2458
2626
  flushPrettyLines(lines);
2459
2627
  }
2628
+ function removeErrorCycles(value, ancestors) {
2629
+ if (value === null || typeof value !== "object")
2630
+ return value;
2631
+ if (ancestors.has(value))
2632
+ return "[Circular]";
2633
+ ancestors.add(value);
2634
+ let changed = false;
2635
+ const visit = (item) => {
2636
+ const result = removeErrorCycles(item, ancestors);
2637
+ if (!Object.is(result, item))
2638
+ changed = true;
2639
+ return result;
2640
+ };
2641
+ const copy = Array.isArray(value) ? value.map(visit) : Object.fromEntries(Object.entries(value).map(([key, item]) => [key, visit(item)]));
2642
+ ancestors.delete(value);
2643
+ return changed ? copy : value;
2644
+ }
2645
+ function serializeError(err) {
2646
+ const errorObj = {
2647
+ name: err.name,
2648
+ message: err.message,
2649
+ stack: isDev() ? compactStackForStorage(err.stack) : err.stack
2650
+ };
2651
+ const errRecord = err;
2652
+ const ancestors = new WeakSet([err]);
2653
+ for (const k of [
2654
+ "code",
2655
+ "status",
2656
+ "statusText",
2657
+ "statusCode",
2658
+ "statusMessage",
2659
+ "data",
2660
+ "cause",
2661
+ "internal"
2662
+ ])
2663
+ if (k in err)
2664
+ errorObj[k] = removeErrorCycles(errRecord[k], ancestors);
2665
+ if (EvlogError.isEvlogError(err)) {
2666
+ if (err.code)
2667
+ errorObj.code = err.code;
2668
+ if (err.why)
2669
+ errorObj.why = err.why;
2670
+ if (err.fix)
2671
+ errorObj.fix = err.fix;
2672
+ if (err.link)
2673
+ errorObj.link = err.link;
2674
+ if (err.status)
2675
+ errorObj.status = err.status;
2676
+ }
2677
+ return errorObj;
2678
+ }
2460
2679
  function createLogMethod(level) {
2461
2680
  return function logMethod(tagOrEvent, message) {
2462
2681
  if (typeof tagOrEvent === "string" && message !== undefined)
2463
2682
  emitTaggedLog(level, tagOrEvent, message);
2683
+ else if (tagOrEvent instanceof Error)
2684
+ emitWideEvent(level, { error: serializeError(tagOrEvent) });
2464
2685
  else if (typeof tagOrEvent === "object")
2465
2686
  emitWideEvent(level, tagOrEvent);
2466
2687
  else
@@ -1,5 +1,6 @@
1
1
  export interface SyncMutationHeaders {
2
2
  "Idempotency-Key": string;
3
+ [header: string]: string;
3
4
  }
4
5
  export interface SyncMutationOptions {
5
6
  headers: SyncMutationHeaders;
package/dist/client.js CHANGED
@@ -64,6 +64,10 @@ function HeadContent() {
64
64
  }
65
65
  return /* @__PURE__ */ jsxDEV(Fragment, {
66
66
  children: [
67
+ state.assets.extensionErrorFilterScript === undefined ? null : /* @__PURE__ */ jsxDEV("script", {
68
+ dangerouslySetInnerHTML: { __html: state.assets.extensionErrorFilterScript },
69
+ "data-furin-extension-error-filter": ""
70
+ }, undefined, false, undefined, this),
67
71
  /* @__PURE__ */ jsxDEV("meta", {
68
72
  charSet: "utf-8",
69
73
  "data-furin-head": ""
@@ -121,6 +125,13 @@ function Scripts() {
121
125
  id: "__FURIN_DATA__",
122
126
  type: "application/json"
123
127
  }, undefined, false, undefined, this),
128
+ state.routeFrames === undefined ? null : /* @__PURE__ */ jsxDEV("template", {
129
+ dangerouslySetInnerHTML: {
130
+ __html: state.routeFrames.replaceAll("&", "&amp;").replaceAll("<", "&lt;")
131
+ },
132
+ "data-furin-document-state": "",
133
+ id: "__FURIN_ROUTE_FRAMES__"
134
+ }, undefined, false, undefined, this),
124
135
  /* @__PURE__ */ jsxDEV("script", {
125
136
  dangerouslySetInnerHTML: { __html: serializeJson(state.head ?? {}) },
126
137
  "data-furin-scripts": "",
package/dist/config.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import type { BunPlugin } from "bun";
2
- export declare const BUILD_TARGETS: readonly ["bun", "node", "vercel", "cloudflare", "static", "package"];
2
+ import type { Static } from "typebox";
3
+ export declare const BUILD_TARGETS: readonly ["bun", "vercel", "static", "package"];
3
4
  export type BuildTarget = (typeof BUILD_TARGETS)[number];
5
+ declare const VERCEL_REGIONS: readonly ["arn1", "bom1", "cdg1", "cle1", "cpt1", "dub1", "dxb1", "fra1", "gru1", "hkg1", "hnd1", "iad1", "icn1", "kix1", "lhr1", "pdx1", "sfo1", "sin1", "syd1", "yul1"];
6
+ export type VercelRegion = (typeof VERCEL_REGIONS)[number];
4
7
  /**
5
8
  * Configuration for the `static` build target.
6
9
  * Produces a fully pre-rendered directory deployable to any static host
@@ -28,20 +31,20 @@ export interface StaticExportConfig {
28
31
  }
29
32
  export interface VercelDeploymentConfig {
30
33
  /** Vercel compute regions, such as "cdg1" or "iad1". */
31
- regions?: string[];
34
+ regions?: VercelRegion[];
32
35
  }
33
- export declare const configSchema: import("@sinclair/typebox").TObject<{
36
+ export declare const configSchema: import("typebox").TObject<{
34
37
  /**
35
38
  * Multi-instance builds: one entry per mounted furin app. Overrides
36
39
  * `pagesDir` and server-entry auto-detection. `prefix` must match the
37
40
  * `furin({ prefix })` the app is mounted with (`""`/absent = root).
38
41
  */
39
- apps: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
40
- pagesDir: import("@sinclair/typebox").TString;
41
- prefix: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
42
+ apps: import("typebox").TOptional<import("typebox").TArray<import("typebox").TObject<{
43
+ pagesDir: import("typebox").TString;
44
+ prefix: import("typebox").TOptional<import("typebox").TString>;
42
45
  }>>>;
43
- bun: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
44
- compile: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"server">, import("@sinclair/typebox").TLiteral<"embed">]>>;
46
+ bun: import("typebox").TOptional<import("typebox").TObject<{
47
+ compile: import("typebox").TOptional<import("typebox").TUnion<[import("typebox").TLiteral<"server">, import("typebox").TLiteral<"embed">]>>;
45
48
  }>>;
46
49
  /**
47
50
  * Initialize the browser HTTP log drain in the hydration entry. Off by
@@ -49,35 +52,38 @@ export declare const configSchema: import("@sinclair/typebox").TObject<{
49
52
  * events at `/_furin/ingest`. Server-side logging is unaffected (configured
50
53
  * via the `furin({ logger })` plugin option).
51
54
  */
52
- clientLogging: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
55
+ clientLogging: import("typebox").TOptional<import("typebox").TBoolean>;
53
56
  /**
54
57
  * Package barrels Bun should parse on demand in production client bundles.
55
58
  * Packages declaring `sideEffects: false` are optimized automatically.
56
59
  */
57
- optimizeImports: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
58
- pagesDir: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
60
+ optimizeImports: import("typebox").TOptional<import("typebox").TArray<import("typebox").TString>>;
61
+ pagesDir: import("typebox").TOptional<import("typebox").TString>;
59
62
  /**
60
63
  * Enable Bun's native Rust React Compiler for production client bundles.
61
64
  * Enabled by default.
62
65
  */
63
- reactCompiler: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
64
- rootDir: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
65
- serverEntry: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
66
- static: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
67
- basePath: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
68
- onSSR: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"error">, import("@sinclair/typebox").TLiteral<"skip">]>>;
69
- outDir: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
66
+ reactCompiler: import("typebox").TOptional<import("typebox").TBoolean>;
67
+ rootDir: import("typebox").TOptional<import("typebox").TString>;
68
+ serverEntry: import("typebox").TOptional<import("typebox").TString>;
69
+ /** Emit private server source maps for error-tool uploads. Off by default. */
70
+ serverSourceMaps: import("typebox").TOptional<import("typebox").TBoolean>;
71
+ static: import("typebox").TOptional<import("typebox").TObject<{
72
+ basePath: import("typebox").TOptional<import("typebox").TString>;
73
+ onSSR: import("typebox").TOptional<import("typebox").TUnion<[import("typebox").TLiteral<"error">, import("typebox").TLiteral<"skip">]>>;
74
+ outDir: import("typebox").TOptional<import("typebox").TString>;
70
75
  }>>;
71
- targets: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"bun" | "cloudflare" | "node" | "package" | "static" | "vercel">[]>>>;
72
- vercel: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
73
- regions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
76
+ targets: import("typebox").TOptional<import("typebox").TArray<import("typebox").TUnion<import("typebox").TLiteral<"bun" | "package" | "static" | "vercel">[]>>>;
77
+ vercel: import("typebox").TOptional<import("typebox").TObject<{
78
+ regions: import("typebox").TOptional<import("typebox").TArray<import("typebox").TEnum<["arn1", "bom1", "cdg1", "cle1", "cpt1", "dub1", "dxb1", "fra1", "gru1", "hkg1", "hnd1", "iad1", "icn1", "kix1", "lhr1", "pdx1", "sfo1", "sin1", "syd1", "yul1"]>>>;
74
79
  }>>;
75
80
  }>;
76
81
  export type FurinPlugin = BunPlugin & {
77
82
  buildOnly?: boolean;
78
83
  };
79
- export type FurinConfig = (typeof configSchema)["static"] & {
84
+ export type FurinConfig = Static<typeof configSchema> & {
80
85
  plugins?: FurinPlugin[];
81
86
  static?: StaticExportConfig;
82
87
  };
83
88
  export declare function defineConfig(config: FurinConfig): FurinConfig;
89
+ export {};
package/dist/config.js CHANGED
@@ -1,7 +1,29 @@
1
1
  // @bun
2
2
  // src/config.ts
3
3
  import { t } from "elysia";
4
- var BUILD_TARGETS = ["bun", "node", "vercel", "cloudflare", "static", "package"];
4
+ var BUILD_TARGETS = ["bun", "vercel", "static", "package"];
5
+ var VERCEL_REGIONS = [
6
+ "arn1",
7
+ "bom1",
8
+ "cdg1",
9
+ "cle1",
10
+ "cpt1",
11
+ "dub1",
12
+ "dxb1",
13
+ "fra1",
14
+ "gru1",
15
+ "hkg1",
16
+ "hnd1",
17
+ "iad1",
18
+ "icn1",
19
+ "kix1",
20
+ "lhr1",
21
+ "pdx1",
22
+ "sfo1",
23
+ "sin1",
24
+ "syd1",
25
+ "yul1"
26
+ ];
5
27
  var buildTargetSchema = t.Union(BUILD_TARGETS.map((v) => t.Literal(v)));
6
28
  var compileTargetSchema = t.Union([t.Literal("server"), t.Literal("embed")]);
7
29
  var configSchema = t.Object({
@@ -18,6 +40,7 @@ var configSchema = t.Object({
18
40
  reactCompiler: t.Optional(t.Boolean()),
19
41
  rootDir: t.Optional(t.String()),
20
42
  serverEntry: t.Optional(t.String()),
43
+ serverSourceMaps: t.Optional(t.Boolean()),
21
44
  static: t.Optional(t.Object({
22
45
  basePath: t.Optional(t.String()),
23
46
  onSSR: t.Optional(t.Union([t.Literal("error"), t.Literal("skip")])),
@@ -25,7 +48,7 @@ var configSchema = t.Object({
25
48
  })),
26
49
  targets: t.Optional(t.Array(buildTargetSchema)),
27
50
  vercel: t.Optional(t.Object({
28
- regions: t.Optional(t.Array(t.String({ pattern: "^[a-z]{3}[1-9][0-9]*$" }), {
51
+ regions: t.Optional(t.Array(t.Enum(VERCEL_REGIONS), {
29
52
  minItems: 1,
30
53
  uniqueItems: true
31
54
  }))