rari 0.7.4 → 0.7.6

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 (62) hide show
  1. package/dist/cli.mjs +12 -12
  2. package/dist/client.d.mts +1 -1
  3. package/dist/client.mjs +65 -23
  4. package/dist/constants-wQafG3CE.mjs +33 -0
  5. package/dist/image/index.d.mts +1 -1
  6. package/dist/image/index.mjs +171 -1
  7. package/dist/index.d.mts +2 -3
  8. package/dist/index.mjs +5 -5
  9. package/dist/og/index.d.mts +0 -6
  10. package/dist/og/index.mjs +1 -2
  11. package/dist/proxy/runtime-executor.d.mts +26 -1
  12. package/dist/proxy/runtime-executor.mjs +4 -4
  13. package/dist/{railway-DVrZWPOO.mjs → railway-Dqty_DxF.mjs} +5 -5
  14. package/dist/{render-ALOsrnWD.mjs → render-BXSC62Pt.mjs} +5 -5
  15. package/dist/routes-DVpNEEhv.mjs +3 -0
  16. package/dist/{routes-B_KAzmbj.mjs → routes-n_EfMXUa.mjs} +18 -10
  17. package/dist/runtime/actions.mjs +5 -5
  18. package/dist/{runtime-client-C2xNyif4.d.mts → runtime-client-BV3qaQrj.d.mts} +2 -26
  19. package/dist/{runtime-client-B7wmvKD3.mjs → runtime-client-DkgL4Orp.mjs} +7 -7
  20. package/dist/server-build-Chl-ND4C.mjs +3 -0
  21. package/dist/{server-build-y4PwbtX3.mjs → server-build-X1pfRKXQ.mjs} +13 -10
  22. package/dist/{vite-BmkmtVrY.d.mts → vite-BrjcNDVC.d.mts} +2 -1
  23. package/dist/{vite-4h_gIEDe.mjs → vite-BzmOMWUI.mjs} +33 -33
  24. package/dist/vite.d.mts +2 -3
  25. package/dist/vite.mjs +5 -5
  26. package/package.json +26 -27
  27. package/src/cli.ts +6 -6
  28. package/src/deployment/railway.ts +5 -5
  29. package/src/deployment/render.ts +5 -5
  30. package/src/image/index.ts +1 -0
  31. package/src/og/ImageResponse.tsx +0 -7
  32. package/src/platform.ts +4 -4
  33. package/src/proxy/execute-proxy.ts +2 -2
  34. package/src/proxy/executor.ts +4 -4
  35. package/src/proxy/runtime-executor.ts +4 -4
  36. package/src/proxy/vite-plugin.ts +1 -1
  37. package/src/router/ClientRouter.tsx +45 -8
  38. package/src/router/LayoutErrorBoundary.tsx +1 -1
  39. package/src/router/StatePreserver.ts +2 -2
  40. package/src/router/navigation-error-handler.ts +1 -1
  41. package/src/router/navigation-utils.ts +1 -1
  42. package/src/router/props-extractor.ts +12 -34
  43. package/src/router/routes.ts +26 -11
  44. package/src/router/vite-plugin.ts +9 -9
  45. package/src/runtime/AppRouterProvider.tsx +12 -12
  46. package/src/runtime/LoadingErrorBoundary.tsx +2 -2
  47. package/src/runtime/actions.ts +3 -3
  48. package/src/runtime/csrf.ts +2 -2
  49. package/src/runtime/entry-client.js +69 -18
  50. package/src/runtime/react-server-dom-rari-client.js +2 -2
  51. package/src/runtime/rsc-client-runtime.js +18 -18
  52. package/src/runtime-client.ts +4 -4
  53. package/src/vite/hmr-coordinator.ts +2 -2
  54. package/src/vite/hmr-error-handler.ts +1 -1
  55. package/src/vite/index.ts +20 -26
  56. package/src/vite/server-build.ts +14 -9
  57. package/src/vite.ts +2 -1
  58. package/dist/image-CL9iVW32.mjs +0 -204
  59. package/dist/routes-BoXHLBse.mjs +0 -3
  60. package/dist/runtime-executor-NBcG4boA.d.mts +0 -27
  61. package/dist/server-build-Qxg1F-98.mjs +0 -3
  62. package/src/proxy/index.ts +0 -16
package/dist/cli.mjs CHANGED
@@ -28,7 +28,7 @@ function getPlatformInfo() {
28
28
  case "win32":
29
29
  normalizedPlatform = "win32";
30
30
  break;
31
- default: throw new Error(`Unsupported platform: ${platform}. Rari supports Linux, macOS, and Windows.`);
31
+ default: throw new Error(`Unsupported platform: ${platform}. rari supports Linux, macOS, and Windows.`);
32
32
  }
33
33
  let normalizedArch;
34
34
  switch (arch) {
@@ -38,7 +38,7 @@ function getPlatformInfo() {
38
38
  case "arm64":
39
39
  normalizedArch = "arm64";
40
40
  break;
41
- default: throw new Error(`Unsupported architecture: ${arch}. Rari supports x64 and ARM64.`);
41
+ default: throw new Error(`Unsupported architecture: ${arch}. rari supports x64 and ARM64.`);
42
42
  }
43
43
  const packageName = SUPPORTED_PLATFORMS[`${normalizedPlatform}-${normalizedArch}`];
44
44
  if (!packageName) throw new Error(`Unsupported platform combination: ${normalizedPlatform}-${normalizedArch}. Supported platforms: ${Object.keys(SUPPORTED_PLATFORMS).join(", ")}`);
@@ -71,13 +71,13 @@ function getBinaryPath() {
71
71
  if (existsSync(binaryPath)) return binaryPath;
72
72
  throw new Error(`Binary not found at ${binaryPath}`);
73
73
  } catch {
74
- throw new Error(`Failed to locate Rari binary for ${packageName}. Please ensure the platform package is installed: npm install ${packageName}`);
74
+ throw new Error(`Failed to locate rari binary for ${packageName}. Please ensure the platform package is installed: npm install ${packageName}`);
75
75
  }
76
76
  }
77
77
  function getInstallationInstructions() {
78
78
  const { packageName } = getPlatformInfo();
79
79
  return `
80
- To install Rari for your platform, run:
80
+ To install rari for your platform, run:
81
81
 
82
82
  npm install ${packageName}
83
83
 
@@ -152,7 +152,7 @@ async function startRustServer() {
152
152
  try {
153
153
  binaryPath = getBinaryPath();
154
154
  } catch {
155
- logError("Failed to obtain Rari binary");
155
+ logError("Failed to obtain rari binary");
156
156
  logError(getInstallationInstructions());
157
157
  process.exit(1);
158
158
  }
@@ -160,7 +160,7 @@ async function startRustServer() {
160
160
  if (isPlatformEnvironment()) {
161
161
  const platformName = getPlatformName();
162
162
  logInfo(`${platformName} environment detected`);
163
- logInfo(`Starting Rari server for ${platformName} deployment...`);
163
+ logInfo(`Starting rari server for ${platformName} deployment...`);
164
164
  logInfo(`Mode: ${mode}, Host: ${host}, Port: ${port}`);
165
165
  logInfo(`using binary: ${binaryPath}`);
166
166
  }
@@ -186,8 +186,8 @@ async function startRustServer() {
186
186
  process.on("SIGINT", shutdown);
187
187
  process.on("SIGTERM", shutdown);
188
188
  rustServer.on("error", (error) => {
189
- logError(`Failed to start Rari server: ${error.message}`);
190
- if (error.message.includes("ENOENT")) logError("Binary not found. Please ensure Rari is properly installed.");
189
+ logError(`Failed to start rari server: ${error.message}`);
190
+ if (error.message.includes("ENOENT")) logError("Binary not found. Please ensure rari is properly installed.");
191
191
  process.exit(1);
192
192
  });
193
193
  rustServer.on("exit", (code, signal) => {
@@ -206,7 +206,7 @@ async function deployToRailway() {
206
206
  logError(`Already running in ${getPlatformName()} environment. Use "rari start" instead.`);
207
207
  process.exit(1);
208
208
  }
209
- const { createRailwayDeployment } = await import("./railway-DVrZWPOO.mjs");
209
+ const { createRailwayDeployment } = await import("./railway-Dqty_DxF.mjs");
210
210
  await createRailwayDeployment();
211
211
  }
212
212
  async function deployToRender() {
@@ -215,7 +215,7 @@ async function deployToRender() {
215
215
  logError(`Already running in ${getPlatformName()} environment. Use "rari start" instead.`);
216
216
  process.exit(1);
217
217
  }
218
- const { createRenderDeployment } = await import("./render-ALOsrnWD.mjs");
218
+ const { createRenderDeployment } = await import("./render-BXSC62Pt.mjs");
219
219
  await createRenderDeployment();
220
220
  }
221
221
  async function main() {
@@ -224,10 +224,10 @@ async function main() {
224
224
  case "help":
225
225
  case "--help":
226
226
  case "-h":
227
- console.warn(`${colors.bold("Rari CLI")}
227
+ console.warn(`${colors.bold("rari CLI")}
228
228
 
229
229
  ${colors.bold("Usage:")}
230
- ${colors.cyan("rari start")} Start the Rari server
230
+ ${colors.cyan("rari start")} Start the rari server
231
231
  ${colors.cyan("rari deploy railway")} Setup Railway deployment
232
232
  ${colors.cyan("rari deploy render")} Setup Render deployment
233
233
  ${colors.cyan("rari help")} Show this help message
package/dist/client.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as extractMetadata, C as RouteSegment, D as StaticParamsResult, E as ServerPropsResult, M as extractServerPropsWithCache, N as extractStaticParams, O as clearPropsCache, P as hasServerSideDataFetching, T as MetadataResult, _ as GenerateStaticParams, a as LoadingSpinner, b as LoadingEntry, c as createErrorBoundary, d as AppRouteEntry, f as AppRouteManifest, g as GenerateMetadata, h as ErrorProps, i as HttpRuntimeClient, j as extractServerProps, k as clearPropsCacheForComponent, l as createHttpRuntimeClient, m as ErrorEntry, n as DefaultLoading, o as NotFound, p as AppRouteMatch, r as ErrorBoundary, s as RuntimeClient, t as DefaultError, u as createLoadingBoundary, v as LayoutEntry, w as RouteSegmentType, x as NotFoundEntry } from "./runtime-client-C2xNyif4.mjs";
1
+ import { A as extractMetadata, C as RouteSegment, D as StaticParamsResult, E as ServerPropsResult, M as extractServerPropsWithCache, N as extractStaticParams, O as clearPropsCache, P as hasServerSideDataFetching, T as MetadataResult, _ as GenerateStaticParams, a as LoadingSpinner, b as LoadingEntry, c as createErrorBoundary, d as AppRouteEntry, f as AppRouteManifest, g as GenerateMetadata, h as ErrorProps, i as HttpRuntimeClient, j as extractServerProps, k as clearPropsCacheForComponent, l as createHttpRuntimeClient, m as ErrorEntry, n as DefaultLoading, o as NotFound, p as AppRouteMatch, r as ErrorBoundary, s as RuntimeClient, t as DefaultError, u as createLoadingBoundary, v as LayoutEntry, w as RouteSegmentType, x as NotFoundEntry } from "./runtime-client-BV3qaQrj.mjs";
2
2
  import * as React from "react";
3
3
  import { Component, ErrorInfo, ReactNode } from "react";
4
4
  import * as react_jsx_runtime0 from "react/jsx-runtime";
package/dist/client.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as LoadingSpinner, c as createHttpRuntimeClient, d as clearPropsCacheForComponent, f as extractMetadata, g as hasServerSideDataFetching, h as extractStaticParams, i as HttpRuntimeClient, l as createLoadingBoundary, m as extractServerPropsWithCache, n as DefaultLoading, o as NotFound, p as extractServerProps, r as ErrorBoundary, s as createErrorBoundary, t as DefaultError, u as clearPropsCache } from "./runtime-client-B7wmvKD3.mjs";
1
+ import { a as LoadingSpinner, c as createHttpRuntimeClient, d as clearPropsCacheForComponent, f as extractMetadata, g as hasServerSideDataFetching, h as extractStaticParams, i as HttpRuntimeClient, l as createLoadingBoundary, m as extractServerPropsWithCache, n as DefaultLoading, o as NotFound, p as extractServerProps, r as ErrorBoundary, s as createErrorBoundary, t as DefaultError, u as clearPropsCache } from "./runtime-client-DkgL4Orp.mjs";
2
2
  import { Component, useEffect, useRef, useState } from "react";
3
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
4
 
@@ -170,7 +170,7 @@ var NavigationErrorHandler = class {
170
170
  handleError(error, url) {
171
171
  const navError = createNavigationError(error, url);
172
172
  this.options.onError(navError);
173
- console.error("[NavigationErrorHandler]", navError.type, navError.message, {
173
+ console.error("[rari] Navigation:", navError.type, navError.message, {
174
174
  url: navError.url,
175
175
  statusCode: navError.statusCode,
176
176
  retryable: navError.retryable
@@ -222,7 +222,8 @@ function isExternalUrl(url, currentOrigin) {
222
222
  }
223
223
  function extractPathname(url) {
224
224
  try {
225
- return new URL(url, window.location.origin).pathname;
225
+ const urlObj = new URL(url, window.location.origin);
226
+ return urlObj.pathname + urlObj.hash;
226
227
  } catch {
227
228
  return url;
228
229
  }
@@ -653,7 +654,7 @@ var StatePreserver = class {
653
654
  }
654
655
  });
655
656
  } catch (error) {
656
- console.error("Failed to restore scroll positions:", error);
657
+ console.error("[rari] Router: Failed to restore scroll positions:", error);
657
658
  allSucceeded = false;
658
659
  }
659
660
  return allSucceeded;
@@ -683,7 +684,7 @@ var StatePreserver = class {
683
684
  }
684
685
  });
685
686
  } catch (error) {
686
- console.error("Failed to restore form data:", error);
687
+ console.error("[rari] Router: Failed to restore form data:", error);
687
688
  allSucceeded = false;
688
689
  }
689
690
  return allSucceeded;
@@ -821,7 +822,7 @@ function ClientRouter({ children, initialRoute }) {
821
822
  timeout: 1e4,
822
823
  maxRetries: 3,
823
824
  onError: (error) => {
824
- console.error("[ClientRouter] Navigation error:", error);
825
+ console.error("[rari] Router: Navigation error:", error);
825
826
  },
826
827
  onRetry: () => {}
827
828
  }));
@@ -853,11 +854,24 @@ function ClientRouter({ children, initialRoute }) {
853
854
  const processNavigationQueueRef = useRef(null);
854
855
  const navigate = async (href, options = {}) => {
855
856
  if (!href || typeof href !== "string") {
856
- console.error("[ClientRouter] Invalid navigation target:", href);
857
+ console.error("[rari] Router: Invalid navigation target:", href);
858
+ return;
859
+ }
860
+ const [pathWithoutHash, hash] = href.includes("#") ? href.split("#") : [href, ""];
861
+ const targetPath = normalizePath(pathWithoutHash);
862
+ if (targetPath === currentRouteRef.current && !options.replace) {
863
+ if (hash) {
864
+ const element = document.getElementById(hash);
865
+ if (element) {
866
+ element.scrollIntoView({
867
+ behavior: "smooth",
868
+ block: "start"
869
+ });
870
+ window.history.pushState(window.history.state, "", `${targetPath}#${hash}`);
871
+ }
872
+ }
857
873
  return;
858
874
  }
859
- const targetPath = normalizePath(href);
860
- if (targetPath === currentRouteRef.current && !options.replace) return;
861
875
  const existingPending = pendingNavigationsRef.current.get(targetPath);
862
876
  if (existingPending) return existingPending.promise;
863
877
  const routeInfo = await getRouteInfo(targetPath);
@@ -881,8 +895,9 @@ function ClientRouter({ children, initialRoute }) {
881
895
  timestamp: Date.now(),
882
896
  key: historyKey
883
897
  };
884
- if (options.replace) window.history.replaceState(historyState, "", targetPath);
885
- else window.history.pushState(historyState, "", targetPath);
898
+ const urlWithHash = hash ? `${targetPath}#${hash}` : targetPath;
899
+ if (options.replace) window.history.replaceState(historyState, "", urlWithHash);
900
+ else window.history.pushState(historyState, "", urlWithHash);
886
901
  const fetchUrl = (window.location.origin.includes(":5173") ? "http://localhost:3000" : window.location.origin) + targetPath;
887
902
  const response = await fetch(fetchUrl, {
888
903
  headers: { Accept: "text/x-component" },
@@ -891,16 +906,19 @@ function ClientRouter({ children, initialRoute }) {
891
906
  if (!response.ok) throw new Error(`Failed to fetch: ${response.status}`);
892
907
  const finalPath = new URL(response.url).pathname;
893
908
  const actualTargetPath = finalPath !== targetPath ? finalPath : targetPath;
894
- if (finalPath !== targetPath) window.history.replaceState({
895
- route: finalPath,
896
- navigationId,
897
- scrollPosition: {
898
- x: window.scrollX,
899
- y: window.scrollY
900
- },
901
- timestamp: Date.now(),
902
- key: options.historyKey || generateHistoryKey()
903
- }, "", finalPath);
909
+ if (finalPath !== targetPath) {
910
+ const finalUrlWithHash = hash ? `${finalPath}#${hash}` : finalPath;
911
+ window.history.replaceState({
912
+ route: finalPath,
913
+ navigationId,
914
+ scrollPosition: {
915
+ x: window.scrollX,
916
+ y: window.scrollY
917
+ },
918
+ timestamp: Date.now(),
919
+ key: options.historyKey || generateHistoryKey()
920
+ }, "", finalUrlWithHash);
921
+ }
904
922
  if (abortController.signal.aborted) {
905
923
  cleanupAbortedNavigation(actualTargetPath, navigationId);
906
924
  return;
@@ -941,7 +959,7 @@ function ClientRouter({ children, initialRoute }) {
941
959
  isStreaming: true
942
960
  } }));
943
961
  } catch (streamError) {
944
- console.error("[ClientRouter] Streaming error:", streamError);
962
+ console.error("[rari] Router: Streaming error:", streamError);
945
963
  throw streamError;
946
964
  }
947
965
  } else {
@@ -971,6 +989,17 @@ function ClientRouter({ children, initialRoute }) {
971
989
  if (options.historyKey) requestAnimationFrame(() => {
972
990
  statePreserverRef.current.restoreState(actualTargetPath);
973
991
  });
992
+ else if (hash) requestAnimationFrame(() => {
993
+ const scrollToHash = (attempts = 0) => {
994
+ const element = document.getElementById(hash);
995
+ if (element) element.scrollIntoView({
996
+ behavior: "smooth",
997
+ block: "start"
998
+ });
999
+ else if (attempts < 10) setTimeout(() => scrollToHash(attempts + 1), 50);
1000
+ };
1001
+ scrollToHash();
1002
+ });
974
1003
  }
975
1004
  pendingNavigationsRef.current.delete(targetPath);
976
1005
  processNavigationQueueRef.current?.();
@@ -1030,6 +1059,19 @@ function ClientRouter({ children, initialRoute }) {
1030
1059
  const href = anchor.getAttribute("href");
1031
1060
  if (!href) return;
1032
1061
  if (isExternalUrl(href)) return;
1062
+ if (href.startsWith("#")) {
1063
+ event.preventDefault();
1064
+ const hash = href.slice(1);
1065
+ const element = document.getElementById(hash);
1066
+ if (element) {
1067
+ element.scrollIntoView({
1068
+ behavior: "smooth",
1069
+ block: "start"
1070
+ });
1071
+ window.history.pushState(window.history.state, "", href);
1072
+ }
1073
+ return;
1074
+ }
1033
1075
  event.preventDefault();
1034
1076
  debouncedNavigate(extractPathname(href), { replace: false });
1035
1077
  };
@@ -1133,7 +1175,7 @@ var LayoutErrorBoundary = class extends Component {
1133
1175
  };
1134
1176
  }
1135
1177
  componentDidCatch(error, errorInfo) {
1136
- console.error(`[LayoutErrorBoundary] Error in layout "${this.props.layoutPath}":`, error, errorInfo);
1178
+ console.error(`[rari] Layout: Error in layout "${this.props.layoutPath}":`, error, errorInfo);
1137
1179
  if (this.props.onError) this.props.onError(error, errorInfo);
1138
1180
  if (typeof window !== "undefined") window.dispatchEvent(new CustomEvent("rari:layout-error", { detail: {
1139
1181
  layoutPath: this.props.layoutPath,
@@ -0,0 +1,33 @@
1
+ //#region src/image/constants.ts
2
+ const DEFAULT_DEVICE_SIZES = [
3
+ 640,
4
+ 750,
5
+ 828,
6
+ 1080,
7
+ 1200,
8
+ 1920,
9
+ 2048,
10
+ 3840
11
+ ];
12
+ const DEFAULT_IMAGE_SIZES = [
13
+ 16,
14
+ 32,
15
+ 48,
16
+ 64,
17
+ 96,
18
+ 128,
19
+ 256,
20
+ 384
21
+ ];
22
+ const DEFAULT_FORMATS = ["avif"];
23
+ const DEFAULT_QUALITY_LEVELS = [
24
+ 25,
25
+ 50,
26
+ 75,
27
+ 100
28
+ ];
29
+ const DEFAULT_MINIMUM_CACHE_TTL = 60;
30
+ const DEFAULT_MAX_CACHE_SIZE = 100 * 1024 * 1024;
31
+
32
+ //#endregion
33
+ export { DEFAULT_MINIMUM_CACHE_TTL as a, DEFAULT_MAX_CACHE_SIZE as i, DEFAULT_FORMATS as n, DEFAULT_QUALITY_LEVELS as o, DEFAULT_IMAGE_SIZES as r, DEFAULT_DEVICE_SIZES as t };
@@ -63,4 +63,4 @@ declare function Image({
63
63
  decoding
64
64
  }: ImageProps): react_jsx_runtime0.JSX.Element;
65
65
  //#endregion
66
- export { DEFAULT_DEVICE_SIZES, DEFAULT_FORMATS, DEFAULT_IMAGE_SIZES, DEFAULT_MAX_CACHE_SIZE, DEFAULT_MINIMUM_CACHE_TTL, DEFAULT_QUALITY_LEVELS, Image, type ImageProps, type StaticImageData };
66
+ export { DEFAULT_DEVICE_SIZES, DEFAULT_FORMATS, DEFAULT_IMAGE_SIZES, DEFAULT_MAX_CACHE_SIZE, DEFAULT_MINIMUM_CACHE_TTL, DEFAULT_QUALITY_LEVELS, Image, type ImageFormat, type ImageProps, type StaticImageData };
@@ -1,3 +1,173 @@
1
- import { a as DEFAULT_MAX_CACHE_SIZE, i as DEFAULT_IMAGE_SIZES, n as DEFAULT_DEVICE_SIZES, o as DEFAULT_MINIMUM_CACHE_TTL, r as DEFAULT_FORMATS, s as DEFAULT_QUALITY_LEVELS, t as Image } from "../image-CL9iVW32.mjs";
1
+ import { a as DEFAULT_MINIMUM_CACHE_TTL, i as DEFAULT_MAX_CACHE_SIZE, n as DEFAULT_FORMATS, o as DEFAULT_QUALITY_LEVELS, r as DEFAULT_IMAGE_SIZES, t as DEFAULT_DEVICE_SIZES } from "../constants-wQafG3CE.mjs";
2
+ import { useCallback, useEffect, useRef, useState } from "react";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
2
4
 
5
+ //#region src/image/Image.tsx
6
+ function buildImageUrl(src, width, quality, format) {
7
+ const params = new URLSearchParams();
8
+ params.set("url", src);
9
+ params.set("w", width.toString());
10
+ params.set("q", quality.toString());
11
+ if (format) params.set("f", format);
12
+ return `/_rari/image?${params}`;
13
+ }
14
+ function Image({ src, alt, width, height, quality = 75, preload = false, loading = "lazy", placeholder = "empty", blurDataURL, fill = false, sizes, style, className, onLoad, onError, unoptimized = false, loader, overrideSrc, decoding }) {
15
+ const imgSrc = typeof src === "string" ? src : src.src;
16
+ const imgWidth = width || (typeof src !== "string" ? src.width : void 0);
17
+ const imgHeight = height || (typeof src !== "string" ? src.height : void 0);
18
+ const imgBlurDataURL = blurDataURL || (typeof src !== "string" ? src.blurDataURL : void 0);
19
+ const finalSrc = overrideSrc || imgSrc;
20
+ const shouldPreload = preload;
21
+ const imgDecoding = decoding || (preload ? "sync" : "async");
22
+ const [blurComplete, setBlurComplete] = useState(false);
23
+ const [showAltText, setShowAltText] = useState(false);
24
+ const imgRef = useRef(null);
25
+ const onLoadRef = useRef(onLoad);
26
+ const pictureRef = useRef(null);
27
+ useEffect(() => {
28
+ onLoadRef.current = onLoad;
29
+ }, [onLoad]);
30
+ const handleLoad = useCallback((event) => {
31
+ const img = event.currentTarget;
32
+ if (img.src && img.complete) {
33
+ if (placeholder === "blur") setBlurComplete(true);
34
+ if (onLoadRef.current) onLoadRef.current(event);
35
+ }
36
+ }, [placeholder]);
37
+ const handleError = useCallback((event) => {
38
+ setShowAltText(true);
39
+ if (placeholder === "blur") setBlurComplete(true);
40
+ if (onError) onError(event);
41
+ }, [placeholder, onError]);
42
+ useEffect(() => {
43
+ if (shouldPreload) {
44
+ const link = document.createElement("link");
45
+ link.rel = "preload";
46
+ link.as = "image";
47
+ link.href = loader ? loader({
48
+ src: finalSrc,
49
+ width: imgWidth || 1920,
50
+ quality
51
+ }) : unoptimized ? finalSrc : buildImageUrl(finalSrc, imgWidth || 1920, quality);
52
+ if (sizes) link.setAttribute("imagesizes", sizes);
53
+ document.head.appendChild(link);
54
+ return () => {
55
+ document.head.removeChild(link);
56
+ };
57
+ }
58
+ }, [
59
+ shouldPreload,
60
+ finalSrc,
61
+ imgWidth,
62
+ quality,
63
+ sizes,
64
+ loader,
65
+ unoptimized
66
+ ]);
67
+ useEffect(() => {
68
+ if (shouldPreload || unoptimized || loading === "eager") return;
69
+ const img = imgRef.current;
70
+ if (!img) return;
71
+ const observer = new IntersectionObserver((entries) => {
72
+ entries.forEach((entry) => {
73
+ if (entry.isIntersecting) observer.unobserve(img);
74
+ });
75
+ }, { rootMargin: "50px" });
76
+ observer.observe(img);
77
+ return () => {
78
+ observer.disconnect();
79
+ };
80
+ }, [
81
+ shouldPreload,
82
+ unoptimized,
83
+ loading
84
+ ]);
85
+ const imgStyle = {
86
+ ...style,
87
+ ...fill && {
88
+ position: "absolute",
89
+ inset: 0,
90
+ width: "100%",
91
+ height: "100%",
92
+ objectFit: "cover"
93
+ },
94
+ ...placeholder === "blur" && imgBlurDataURL && !blurComplete && {
95
+ backgroundImage: `url(${imgBlurDataURL})`,
96
+ backgroundSize: "cover",
97
+ backgroundPosition: "center",
98
+ filter: "blur(20px)",
99
+ transition: "filter 0.3s ease-out"
100
+ },
101
+ ...placeholder === "blur" && blurComplete && {
102
+ filter: "none",
103
+ transition: "filter 0.3s ease-out"
104
+ }
105
+ };
106
+ if (unoptimized) return /* @__PURE__ */ jsx("img", {
107
+ ref: imgRef,
108
+ src: loader ? loader({
109
+ src: finalSrc,
110
+ width: imgWidth || 1920,
111
+ quality
112
+ }) : finalSrc,
113
+ alt: showAltText ? alt : "",
114
+ width: fill ? void 0 : imgWidth,
115
+ height: fill ? void 0 : imgHeight,
116
+ loading: shouldPreload ? "eager" : loading,
117
+ fetchPriority: shouldPreload ? "high" : "auto",
118
+ decoding: imgDecoding,
119
+ onLoad: handleLoad,
120
+ onError: handleError,
121
+ style: imgStyle,
122
+ className
123
+ });
124
+ const sizesArray = fill ? DEFAULT_IMAGE_SIZES : DEFAULT_DEVICE_SIZES;
125
+ const defaultWidth = imgWidth || 1920;
126
+ const buildSrcSet = (format) => {
127
+ if (loader) return sizesArray.map((w) => `${loader({
128
+ src: finalSrc,
129
+ width: w,
130
+ quality
131
+ })} ${w}w`).join(", ");
132
+ return sizesArray.map((w) => `${buildImageUrl(finalSrc, w, quality, format)} ${w}w`).join(", ");
133
+ };
134
+ const imgElement = /* @__PURE__ */ jsx("img", {
135
+ ref: imgRef,
136
+ src: loader ? loader({
137
+ src: finalSrc,
138
+ width: defaultWidth,
139
+ quality
140
+ }) : buildImageUrl(finalSrc, defaultWidth, quality),
141
+ srcSet: buildSrcSet(),
142
+ sizes,
143
+ alt: showAltText ? alt : "",
144
+ width: fill ? void 0 : imgWidth,
145
+ height: fill ? void 0 : imgHeight,
146
+ loading: shouldPreload ? "eager" : loading,
147
+ fetchPriority: shouldPreload ? "high" : "auto",
148
+ decoding: imgDecoding,
149
+ onLoad: handleLoad,
150
+ onError: handleError,
151
+ style: imgStyle,
152
+ className
153
+ });
154
+ return /* @__PURE__ */ jsxs("picture", {
155
+ ref: pictureRef,
156
+ children: [
157
+ DEFAULT_FORMATS.includes("avif") && /* @__PURE__ */ jsx("source", {
158
+ type: "image/avif",
159
+ srcSet: buildSrcSet("avif"),
160
+ sizes
161
+ }),
162
+ DEFAULT_FORMATS.includes("webp") && /* @__PURE__ */ jsx("source", {
163
+ type: "image/webp",
164
+ srcSet: buildSrcSet("webp"),
165
+ sizes
166
+ }),
167
+ imgElement
168
+ ]
169
+ });
170
+ }
171
+
172
+ //#endregion
3
173
  export { DEFAULT_DEVICE_SIZES, DEFAULT_FORMATS, DEFAULT_IMAGE_SIZES, DEFAULT_MAX_CACHE_SIZE, DEFAULT_MINIMUM_CACHE_TTL, DEFAULT_QUALITY_LEVELS, Image };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- import { A as extractMetadata, C as RouteSegment, D as StaticParamsResult, E as ServerPropsResult, M as extractServerPropsWithCache, N as extractStaticParams, O as clearPropsCache, P as hasServerSideDataFetching, S as PageProps, T as MetadataResult, _ as GenerateStaticParams, b as LoadingEntry, d as AppRouteEntry, f as AppRouteManifest, g as GenerateMetadata, h as ErrorProps, i as HttpRuntimeClient, j as extractServerProps, k as clearPropsCacheForComponent, l as createHttpRuntimeClient, m as ErrorEntry, p as AppRouteMatch, s as RuntimeClient, v as LayoutEntry, w as RouteSegmentType, x as NotFoundEntry, y as LayoutProps } from "./runtime-client-C2xNyif4.mjs";
2
- import { C as ApiRouteHandlers, D as RobotsRule, E as Robots, S as ApiResponse, T as RouteHandler, _ as ProxyResult, a as rari, b as RequestCookies, c as ProxyPluginOptions, d as RariRequest, f as CookieOptions, g as ProxyModule, h as ProxyMatcher, i as defineRariOptions, l as rariProxy, m as ProxyFunction, n as Response, o as rariRouter, p as ProxyConfig, r as defineRariConfig, s as generateAppRouteManifest, t as Request, u as RariResponse, v as RariFetchEvent, w as RouteContext, x as ResponseCookies, y as RariURL } from "./vite-BmkmtVrY.mjs";
3
- import "./runtime-executor-NBcG4boA.mjs";
1
+ import { A as extractMetadata, C as RouteSegment, D as StaticParamsResult, E as ServerPropsResult, M as extractServerPropsWithCache, N as extractStaticParams, O as clearPropsCache, P as hasServerSideDataFetching, S as PageProps, T as MetadataResult, _ as GenerateStaticParams, b as LoadingEntry, d as AppRouteEntry, f as AppRouteManifest, g as GenerateMetadata, h as ErrorProps, i as HttpRuntimeClient, j as extractServerProps, k as clearPropsCacheForComponent, l as createHttpRuntimeClient, m as ErrorEntry, p as AppRouteMatch, s as RuntimeClient, v as LayoutEntry, w as RouteSegmentType, x as NotFoundEntry, y as LayoutProps } from "./runtime-client-BV3qaQrj.mjs";
2
+ import { C as ApiRouteHandlers, D as RobotsRule, E as Robots, S as ApiResponse, T as RouteHandler, _ as ProxyResult, a as rari, b as RequestCookies, c as ProxyPluginOptions, d as RariRequest, f as CookieOptions, g as ProxyModule, h as ProxyMatcher, i as defineRariOptions, l as rariProxy, m as ProxyFunction, n as Response, o as rariRouter, p as ProxyConfig, r as defineRariConfig, s as generateAppRouteManifest, t as Request, u as RariResponse, v as RariFetchEvent, w as RouteContext, x as ResponseCookies, y as RariURL } from "./vite-BrjcNDVC.mjs";
4
3
  export { ApiResponse, ApiRouteHandlers, AppRouteEntry, AppRouteManifest, AppRouteMatch, CookieOptions, ErrorEntry, ErrorProps, GenerateMetadata, GenerateStaticParams, HttpRuntimeClient, LayoutEntry, LayoutProps, LoadingEntry, MetadataResult, NotFoundEntry, PageProps, ProxyConfig, ProxyFunction, ProxyMatcher, ProxyModule, ProxyPluginOptions, ProxyResult, RariFetchEvent, RariRequest, RariResponse, RariURL, Request, RequestCookies, Response, ResponseCookies, type Robots, type RobotsRule, RouteContext, RouteHandler, RouteSegment, RouteSegmentType, RuntimeClient, ServerPropsResult, StaticParamsResult, clearPropsCache, clearPropsCacheForComponent, createHttpRuntimeClient, defineRariConfig, defineRariOptions, extractMetadata, extractServerProps, extractServerPropsWithCache, extractStaticParams, generateAppRouteManifest, hasServerSideDataFetching, rari, rariProxy, rariRouter };
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { a as rariProxy, i as rariRouter, n as defineRariOptions, o as RariResponse, r as rari, s as ApiResponse, t as defineRariConfig } from "./vite-4h_gIEDe.mjs";
1
+ import { a as rariProxy, i as rariRouter, n as defineRariOptions, o as RariResponse, r as rari, s as ApiResponse, t as defineRariConfig } from "./vite-BzmOMWUI.mjs";
2
2
  import { t as RariRequest } from "./RariRequest-DM6Q4JDB.mjs";
3
- import { c as createHttpRuntimeClient, d as clearPropsCacheForComponent, f as extractMetadata, g as hasServerSideDataFetching, h as extractStaticParams, i as HttpRuntimeClient, m as extractServerPropsWithCache, p as extractServerProps, u as clearPropsCache } from "./runtime-client-B7wmvKD3.mjs";
4
- import { t as generateAppRouteManifest } from "./routes-B_KAzmbj.mjs";
5
- import "./image-CL9iVW32.mjs";
6
- import "./server-build-y4PwbtX3.mjs";
3
+ import { c as createHttpRuntimeClient, d as clearPropsCacheForComponent, f as extractMetadata, g as hasServerSideDataFetching, h as extractStaticParams, i as HttpRuntimeClient, m as extractServerPropsWithCache, p as extractServerProps, u as clearPropsCache } from "./runtime-client-DkgL4Orp.mjs";
4
+ import { t as generateAppRouteManifest } from "./routes-n_EfMXUa.mjs";
5
+ import "./constants-wQafG3CE.mjs";
6
+ import "./server-build-X1pfRKXQ.mjs";
7
7
 
8
8
  export { ApiResponse, HttpRuntimeClient, RariRequest, RariResponse, clearPropsCache, clearPropsCacheForComponent, createHttpRuntimeClient, defineRariConfig, defineRariOptions, extractMetadata, extractServerProps, extractServerPropsWithCache, extractStaticParams, generateAppRouteManifest, hasServerSideDataFetching, rari, rariProxy, rariRouter };
@@ -4,12 +4,6 @@ import { ReactElement } from "react";
4
4
  interface ImageResponseOptions {
5
5
  width?: number;
6
6
  height?: number;
7
- fonts?: Array<{
8
- name: string;
9
- data: ArrayBuffer;
10
- weight?: number;
11
- style?: 'normal' | 'italic';
12
- }>;
13
7
  }
14
8
  interface ImageResponseSize {
15
9
  width: number;
package/dist/og/index.mjs CHANGED
@@ -6,8 +6,7 @@ var ImageResponse = class {
6
6
  this.element = element;
7
7
  this.options = {
8
8
  width: options.width || 1200,
9
- height: options.height || 630,
10
- fonts: options.fonts || []
9
+ height: options.height || 630
11
10
  };
12
11
  }
13
12
  toJSON() {
@@ -1,2 +1,27 @@
1
- import { t as initializeProxyExecutor } from "../runtime-executor-NBcG4boA.mjs";
1
+ //#region src/proxy/runtime-executor.d.ts
2
+ interface SimpleRequest {
3
+ url: string;
4
+ method: string;
5
+ headers: Record<string, string>;
6
+ }
7
+ interface SimpleProxyResult {
8
+ continue: boolean;
9
+ redirect?: {
10
+ destination: string;
11
+ permanent: boolean;
12
+ };
13
+ rewrite?: string;
14
+ requestHeaders?: Record<string, string>;
15
+ responseHeaders?: Record<string, string>;
16
+ response?: {
17
+ status: number;
18
+ headers: Record<string, string>;
19
+ body?: string;
20
+ };
21
+ }
22
+ declare global {
23
+ var __rariExecuteProxy: ((request: SimpleRequest) => Promise<SimpleProxyResult>) | undefined;
24
+ }
25
+ declare function initializeProxyExecutor(proxyModulePath: string): Promise<boolean>;
26
+ //#endregion
2
27
  export { initializeProxyExecutor };
@@ -3,7 +3,7 @@ async function initializeProxyExecutor(proxyModulePath) {
3
3
  try {
4
4
  const proxyModule = await import(proxyModulePath);
5
5
  if (!proxyModule || !proxyModule.proxy) {
6
- console.error("[rari:proxy] proxy function not found in module");
6
+ console.error("[rari] Proxy: proxy function not found in module");
7
7
  return false;
8
8
  }
9
9
  const { RariRequest } = await import("../RariRequest-D_4bWdqr.mjs");
@@ -18,7 +18,7 @@ async function initializeProxyExecutor(proxyModulePath) {
18
18
  waitUntilPromises.push(promise);
19
19
  } });
20
20
  if (waitUntilPromises.length > 0) Promise.allSettled(waitUntilPromises).catch((error) => {
21
- console.error("[rari:proxy] waitUntil promise failed:", error);
21
+ console.error("[rari] Proxy: waitUntil promise failed:", error);
22
22
  });
23
23
  if (!result) return { continue: true };
24
24
  const continueHeader = result.headers?.get?.("x-rari-proxy-continue");
@@ -71,13 +71,13 @@ async function initializeProxyExecutor(proxyModulePath) {
71
71
  }
72
72
  return { continue: true };
73
73
  } catch (error) {
74
- console.error("[rari:proxy] Proxy execution error:", error);
74
+ console.error("[rari] Proxy: Proxy execution error:", error);
75
75
  return { continue: true };
76
76
  }
77
77
  };
78
78
  return true;
79
79
  } catch (error) {
80
- console.error("[rari:proxy] Failed to initialize proxy executor:", error);
80
+ console.error("[rari] Proxy: Failed to initialize proxy executor:", error);
81
81
  return false;
82
82
  }
83
83
  }
@@ -126,7 +126,7 @@ tmp/
126
126
  const railwayReadmeSection = `
127
127
  ## 🚂 Deploy to Railway
128
128
 
129
- This Rari application is configured for Railway deployment.
129
+ This rari application is configured for Railway deployment.
130
130
 
131
131
  ### Quick Deploy
132
132
 
@@ -176,9 +176,9 @@ Optional variables you can set:
176
176
  logSuccess("Updated README.md with Railway deployment instructions");
177
177
  }
178
178
  } else {
179
- writeFileSync(readmePath, `# My Rari App
179
+ writeFileSync(readmePath, `# My rari App
180
180
 
181
- A high-performance React Server Components application powered by Rari.
181
+ A high-performance React Server Components application powered by rari.
182
182
  ${railwayReadmeSection}
183
183
  ## Getting Started
184
184
 
@@ -200,12 +200,12 @@ Visit [http://localhost:3000](http://localhost:3000) to see your app.
200
200
  console.warn(` 3. ${colors.cyan("git push origin main")}`);
201
201
  console.warn(` 4. Go to ${colors.cyan("https://railway.app")} and deploy from GitHub`);
202
202
  console.warn("");
203
- logInfo("Your Rari app will automatically:");
203
+ logInfo("Your rari app will automatically:");
204
204
  console.warn(" ✅ Detect Railway environment");
205
205
  console.warn(" ✅ Bind to 0.0.0.0 (Railway requirement)");
206
206
  console.warn(" ✅ Use Railway's PORT environment variable");
207
207
  console.warn(" ✅ Run in production mode");
208
- console.warn(" ✅ Download platform-specific Rari binary");
208
+ console.warn(" ✅ Download platform-specific rari binary");
209
209
  console.warn("");
210
210
  logSuccess("Ready for deployment! 🚀");
211
211
  }