rari 0.6.0 → 0.7.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/RariRequest-D_4bWdqr.mjs +3 -0
- package/dist/cli.mjs +24 -5
- package/dist/client.d.mts +2 -2
- package/dist/client.mjs +2 -2
- package/dist/image/index.d.mts +66 -0
- package/dist/image/index.mjs +3 -0
- package/dist/image-CL9iVW32.mjs +204 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +6 -5
- package/dist/og/index.d.mts +32 -0
- package/dist/og/index.mjs +51 -0
- package/dist/proxy/runtime-executor.d.mts +1 -1
- package/dist/proxy/runtime-executor.mjs +1 -1
- package/dist/{app-routes-DngkPk-T.mjs → routes-B_KAzmbj.mjs} +39 -8
- package/dist/routes-BoXHLBse.mjs +3 -0
- package/dist/runtime/actions.mjs +5 -5
- package/dist/{runtime-client-q41T0L1o.d.mts → runtime-client-BNivvhrD.d.mts} +103 -100
- package/dist/{runtime-client-BnuxQ4y8.mjs → runtime-client-CZzaWbFc.mjs} +6 -52
- package/dist/server-build-D005lG4Y.mjs +3 -0
- package/dist/{server-build-r9ka8T91.mjs → server-build-DadtZ6wc.mjs} +55 -11
- package/dist/{vite-MiXviq7b.mjs → vite-DJhQmKAk.mjs} +106 -42
- package/dist/{vite-B0zfwvJc.d.mts → vite-h7H6RaMX.d.mts} +49 -2
- package/dist/vite.d.mts +3 -3
- package/dist/vite.mjs +6 -5
- package/package.json +19 -11
- package/src/cli.ts +32 -0
- package/src/client.ts +17 -19
- package/src/image/Image.tsx +260 -0
- package/src/image/constants.ts +8 -0
- package/src/image/index.ts +10 -0
- package/src/og/ImageResponse.tsx +84 -0
- package/src/og/index.ts +1 -0
- package/src/router/navigation-types.ts +1 -1
- package/src/router/navigation-utils.ts +1 -1
- package/src/router/route-info-client.ts +1 -1
- package/src/router/{app-routes.ts → routes.ts} +47 -4
- package/src/router/{app-types.ts → types.ts} +9 -0
- package/src/router/vite-plugin.ts +4 -3
- package/src/runtime/AppRouterProvider.tsx +11 -9
- package/src/runtime/actions.ts +3 -3
- package/src/runtime/csrf.ts +2 -2
- package/src/runtime/entry-client.js +11 -3
- package/src/runtime/rsc-client-runtime.js +10 -72
- package/src/runtime-client.ts +6 -95
- package/src/vite/hmr-coordinator.ts +2 -1
- package/src/vite/index.ts +145 -22
- package/src/vite/server-build.ts +106 -9
- package/src/vite.ts +18 -18
- package/dist/RariRequest-Cfba2VzK.mjs +0 -3
- package/dist/app-routes-BZjZ4Vwn.mjs +0 -3
- package/dist/server-build-2zPPZQQe.mjs +0 -3
- /package/dist/{RariRequest-CCo4Z2pl.mjs → RariRequest-DM6Q4JDB.mjs} +0 -0
- /package/dist/{chunk-CVb4hTOq.mjs → chunk-DViRIILg.mjs} +0 -0
- /package/dist/{platform-CSErW1jU.mjs → platform-DMMsF4tD.mjs} +0 -0
- /package/dist/{railway-O2zC15UA.mjs → railway-CZMzY1dm.mjs} +0 -0
- /package/dist/{render-0G06nNDC.mjs → render-ALOsrnWD.mjs} +0 -0
- /package/dist/{robots-generator-D2SgtWQx.mjs → robots-generator-D14uBu7L.mjs} +0 -0
- /package/dist/{runtime-executor-Hcop_nAb.d.mts → runtime-executor-NBcG4boA.d.mts} +0 -0
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as __require } from "./chunk-
|
|
3
|
-
import { existsSync } from "node:fs";
|
|
4
|
-
import { join } from "node:path";
|
|
2
|
+
import { t as __require } from "./chunk-DViRIILg.mjs";
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import { join, resolve } from "node:path";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import { spawn } from "node:child_process";
|
|
7
7
|
import colors from "picocolors";
|
|
@@ -97,6 +97,25 @@ If you continue to have issues, you can also install from source:
|
|
|
97
97
|
|
|
98
98
|
//#endregion
|
|
99
99
|
//#region src/cli.ts
|
|
100
|
+
function loadEnvFile() {
|
|
101
|
+
const envPath = resolve(process.cwd(), ".env");
|
|
102
|
+
if (existsSync(envPath)) {
|
|
103
|
+
const envContent = readFileSync(envPath, "utf-8");
|
|
104
|
+
for (const line of envContent.split("\n")) {
|
|
105
|
+
const trimmed = line.trim();
|
|
106
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
107
|
+
const match = trimmed.match(/^([^=]+)=(.*)$/);
|
|
108
|
+
if (match) {
|
|
109
|
+
const [, key, value] = match;
|
|
110
|
+
const cleanKey = key.trim();
|
|
111
|
+
let cleanValue = value.trim();
|
|
112
|
+
if (cleanValue.startsWith("\"") && cleanValue.endsWith("\"") || cleanValue.startsWith("'") && cleanValue.endsWith("'")) cleanValue = cleanValue.slice(1, -1);
|
|
113
|
+
if (!process.env[cleanKey]) process.env[cleanKey] = cleanValue;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
loadEnvFile();
|
|
100
119
|
const [, , command, ...args] = process.argv;
|
|
101
120
|
function logInfo(message) {
|
|
102
121
|
console.warn(`${colors.blue("info")} ${message}`);
|
|
@@ -187,7 +206,7 @@ async function deployToRailway() {
|
|
|
187
206
|
logError(`Already running in ${getPlatformName()} environment. Use "rari start" instead.`);
|
|
188
207
|
process.exit(1);
|
|
189
208
|
}
|
|
190
|
-
const { createRailwayDeployment } = await import("./railway-
|
|
209
|
+
const { createRailwayDeployment } = await import("./railway-CZMzY1dm.mjs");
|
|
191
210
|
await createRailwayDeployment();
|
|
192
211
|
}
|
|
193
212
|
async function deployToRender() {
|
|
@@ -196,7 +215,7 @@ async function deployToRender() {
|
|
|
196
215
|
logError(`Already running in ${getPlatformName()} environment. Use "rari start" instead.`);
|
|
197
216
|
process.exit(1);
|
|
198
217
|
}
|
|
199
|
-
const { createRenderDeployment } = await import("./render-
|
|
218
|
+
const { createRenderDeployment } = await import("./render-ALOsrnWD.mjs");
|
|
200
219
|
await createRenderDeployment();
|
|
201
220
|
}
|
|
202
221
|
async function main() {
|
package/dist/client.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
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-BNivvhrD.mjs";
|
|
2
2
|
import React, { Component, ErrorInfo, ReactNode } from "react";
|
|
3
3
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
|
|
@@ -131,4 +131,4 @@ declare class StatePreserver {
|
|
|
131
131
|
private restoreFocus;
|
|
132
132
|
}
|
|
133
133
|
//#endregion
|
|
134
|
-
export { type AppRouteEntry, type AppRouteManifest, type AppRouteMatch, ClientRouter, type ClientRouterProps, DefaultError, DefaultLoading, ErrorBoundary, type ErrorEntry, type ErrorProps, type GenerateMetadata, type GenerateStaticParams, HttpRuntimeClient, type LayoutEntry, LayoutErrorBoundary, type
|
|
134
|
+
export { type AppRouteEntry, type AppRouteManifest, type AppRouteMatch, ClientRouter, type ClientRouterProps, DefaultError, DefaultLoading, ErrorBoundary, type ErrorEntry, type ErrorProps, type GenerateMetadata, type GenerateStaticParams, HttpRuntimeClient, type LayoutEntry, LayoutErrorBoundary, type LoadingEntry, LoadingSpinner, type MetadataResult, type NavigationError, NavigationErrorHandler, type NavigationErrorHandlerOptions, NavigationErrorOverlay, type NavigationErrorOverlayProps, type NavigationErrorType, NotFound, type NotFoundEntry, type PreservedState, RouteInfoError, RouteInfoRequest, RouteInfoResponse, type RouteSegment, type RouteSegmentType, type RuntimeClient, type ScrollPosition, type ServerPropsResult, StatePreserver, type StatePreserverConfig, type StaticParamsResult, clearPropsCache, clearPropsCacheForComponent, createErrorBoundary, createHttpRuntimeClient, createLoadingBoundary, extractMetadata, extractServerProps, extractServerPropsWithCache, extractStaticParams, hasServerSideDataFetching };
|
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-
|
|
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-CZzaWbFc.mjs";
|
|
2
2
|
import React, { Component, useEffect, useRef, useState } from "react";
|
|
3
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
|
|
@@ -506,7 +506,7 @@ var RouteInfoCache = class {
|
|
|
506
506
|
}
|
|
507
507
|
async fetchRouteInfo(path) {
|
|
508
508
|
const request = { path };
|
|
509
|
-
const response = await fetch("/
|
|
509
|
+
const response = await fetch("/_rari/route-info", {
|
|
510
510
|
method: "POST",
|
|
511
511
|
headers: { "Content-Type": "application/json" },
|
|
512
512
|
body: JSON.stringify(request)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/image/constants.d.ts
|
|
4
|
+
type ImageFormat = 'avif' | 'webp';
|
|
5
|
+
declare const DEFAULT_DEVICE_SIZES: number[];
|
|
6
|
+
declare const DEFAULT_IMAGE_SIZES: number[];
|
|
7
|
+
declare const DEFAULT_FORMATS: ImageFormat[];
|
|
8
|
+
declare const DEFAULT_QUALITY_LEVELS: number[];
|
|
9
|
+
declare const DEFAULT_MINIMUM_CACHE_TTL = 60;
|
|
10
|
+
declare const DEFAULT_MAX_CACHE_SIZE: number;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/image/Image.d.ts
|
|
13
|
+
interface ImageProps {
|
|
14
|
+
src: string | StaticImageData;
|
|
15
|
+
alt: string;
|
|
16
|
+
width?: number;
|
|
17
|
+
height?: number;
|
|
18
|
+
quality?: number;
|
|
19
|
+
preload?: boolean;
|
|
20
|
+
loading?: 'lazy' | 'eager';
|
|
21
|
+
placeholder?: 'blur' | 'empty';
|
|
22
|
+
blurDataURL?: string;
|
|
23
|
+
fill?: boolean;
|
|
24
|
+
sizes?: string;
|
|
25
|
+
style?: React.CSSProperties;
|
|
26
|
+
className?: string;
|
|
27
|
+
onLoad?: (event: React.SyntheticEvent<HTMLImageElement>) => void;
|
|
28
|
+
onError?: (event: React.SyntheticEvent<HTMLImageElement>) => void;
|
|
29
|
+
unoptimized?: boolean;
|
|
30
|
+
loader?: (props: {
|
|
31
|
+
src: string;
|
|
32
|
+
width: number;
|
|
33
|
+
quality: number;
|
|
34
|
+
}) => string;
|
|
35
|
+
overrideSrc?: string;
|
|
36
|
+
decoding?: 'async' | 'sync' | 'auto';
|
|
37
|
+
}
|
|
38
|
+
interface StaticImageData {
|
|
39
|
+
src: string;
|
|
40
|
+
height: number;
|
|
41
|
+
width: number;
|
|
42
|
+
blurDataURL?: string;
|
|
43
|
+
}
|
|
44
|
+
declare function Image({
|
|
45
|
+
src,
|
|
46
|
+
alt,
|
|
47
|
+
width,
|
|
48
|
+
height,
|
|
49
|
+
quality,
|
|
50
|
+
preload,
|
|
51
|
+
loading,
|
|
52
|
+
placeholder,
|
|
53
|
+
blurDataURL,
|
|
54
|
+
fill,
|
|
55
|
+
sizes,
|
|
56
|
+
style,
|
|
57
|
+
className,
|
|
58
|
+
onLoad,
|
|
59
|
+
onError,
|
|
60
|
+
unoptimized,
|
|
61
|
+
loader,
|
|
62
|
+
overrideSrc,
|
|
63
|
+
decoding
|
|
64
|
+
}: ImageProps): react_jsx_runtime0.JSX.Element;
|
|
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 };
|
|
@@ -0,0 +1,3 @@
|
|
|
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";
|
|
2
|
+
|
|
3
|
+
export { DEFAULT_DEVICE_SIZES, DEFAULT_FORMATS, DEFAULT_IMAGE_SIZES, DEFAULT_MAX_CACHE_SIZE, DEFAULT_MINIMUM_CACHE_TTL, DEFAULT_QUALITY_LEVELS, Image };
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/image/constants.ts
|
|
5
|
+
const DEFAULT_DEVICE_SIZES = [
|
|
6
|
+
640,
|
|
7
|
+
750,
|
|
8
|
+
828,
|
|
9
|
+
1080,
|
|
10
|
+
1200,
|
|
11
|
+
1920,
|
|
12
|
+
2048,
|
|
13
|
+
3840
|
|
14
|
+
];
|
|
15
|
+
const DEFAULT_IMAGE_SIZES = [
|
|
16
|
+
16,
|
|
17
|
+
32,
|
|
18
|
+
48,
|
|
19
|
+
64,
|
|
20
|
+
96,
|
|
21
|
+
128,
|
|
22
|
+
256,
|
|
23
|
+
384
|
|
24
|
+
];
|
|
25
|
+
const DEFAULT_FORMATS = ["avif"];
|
|
26
|
+
const DEFAULT_QUALITY_LEVELS = [
|
|
27
|
+
25,
|
|
28
|
+
50,
|
|
29
|
+
75,
|
|
30
|
+
100
|
|
31
|
+
];
|
|
32
|
+
const DEFAULT_MINIMUM_CACHE_TTL = 60;
|
|
33
|
+
const DEFAULT_MAX_CACHE_SIZE = 100 * 1024 * 1024;
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/image/Image.tsx
|
|
37
|
+
function buildImageUrl(src, width, quality, format) {
|
|
38
|
+
const params = new URLSearchParams();
|
|
39
|
+
params.set("url", src);
|
|
40
|
+
params.set("w", width.toString());
|
|
41
|
+
params.set("q", quality.toString());
|
|
42
|
+
if (format) params.set("f", format);
|
|
43
|
+
return `/_rari/image?${params}`;
|
|
44
|
+
}
|
|
45
|
+
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 }) {
|
|
46
|
+
const imgSrc = typeof src === "string" ? src : src.src;
|
|
47
|
+
const imgWidth = width || (typeof src !== "string" ? src.width : void 0);
|
|
48
|
+
const imgHeight = height || (typeof src !== "string" ? src.height : void 0);
|
|
49
|
+
const imgBlurDataURL = blurDataURL || (typeof src !== "string" ? src.blurDataURL : void 0);
|
|
50
|
+
const finalSrc = overrideSrc || imgSrc;
|
|
51
|
+
const shouldPreload = preload;
|
|
52
|
+
const imgDecoding = decoding || (preload ? "sync" : "async");
|
|
53
|
+
const [blurComplete, setBlurComplete] = useState(false);
|
|
54
|
+
const [showAltText, setShowAltText] = useState(false);
|
|
55
|
+
const imgRef = useRef(null);
|
|
56
|
+
const onLoadRef = useRef(onLoad);
|
|
57
|
+
const pictureRef = useRef(null);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
onLoadRef.current = onLoad;
|
|
60
|
+
}, [onLoad]);
|
|
61
|
+
const handleLoad = useCallback((event) => {
|
|
62
|
+
const img = event.currentTarget;
|
|
63
|
+
if (img.src && img.complete) {
|
|
64
|
+
if (placeholder === "blur") setBlurComplete(true);
|
|
65
|
+
if (onLoadRef.current) onLoadRef.current(event);
|
|
66
|
+
}
|
|
67
|
+
}, [placeholder]);
|
|
68
|
+
const handleError = useCallback((event) => {
|
|
69
|
+
setShowAltText(true);
|
|
70
|
+
if (placeholder === "blur") setBlurComplete(true);
|
|
71
|
+
if (onError) onError(event);
|
|
72
|
+
}, [placeholder, onError]);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (shouldPreload) {
|
|
75
|
+
const link = document.createElement("link");
|
|
76
|
+
link.rel = "preload";
|
|
77
|
+
link.as = "image";
|
|
78
|
+
link.href = loader ? loader({
|
|
79
|
+
src: finalSrc,
|
|
80
|
+
width: imgWidth || 1920,
|
|
81
|
+
quality
|
|
82
|
+
}) : unoptimized ? finalSrc : buildImageUrl(finalSrc, imgWidth || 1920, quality);
|
|
83
|
+
if (sizes) link.setAttribute("imagesizes", sizes);
|
|
84
|
+
document.head.appendChild(link);
|
|
85
|
+
return () => {
|
|
86
|
+
document.head.removeChild(link);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}, [
|
|
90
|
+
shouldPreload,
|
|
91
|
+
finalSrc,
|
|
92
|
+
imgWidth,
|
|
93
|
+
quality,
|
|
94
|
+
sizes,
|
|
95
|
+
loader,
|
|
96
|
+
unoptimized
|
|
97
|
+
]);
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (shouldPreload || unoptimized || loading === "eager") return;
|
|
100
|
+
const img = imgRef.current;
|
|
101
|
+
if (!img) return;
|
|
102
|
+
const observer = new IntersectionObserver((entries) => {
|
|
103
|
+
entries.forEach((entry) => {
|
|
104
|
+
if (entry.isIntersecting) observer.unobserve(img);
|
|
105
|
+
});
|
|
106
|
+
}, { rootMargin: "50px" });
|
|
107
|
+
observer.observe(img);
|
|
108
|
+
return () => {
|
|
109
|
+
observer.disconnect();
|
|
110
|
+
};
|
|
111
|
+
}, [
|
|
112
|
+
shouldPreload,
|
|
113
|
+
unoptimized,
|
|
114
|
+
loading
|
|
115
|
+
]);
|
|
116
|
+
const imgStyle = {
|
|
117
|
+
...style,
|
|
118
|
+
...fill && {
|
|
119
|
+
position: "absolute",
|
|
120
|
+
inset: 0,
|
|
121
|
+
width: "100%",
|
|
122
|
+
height: "100%",
|
|
123
|
+
objectFit: "cover"
|
|
124
|
+
},
|
|
125
|
+
...placeholder === "blur" && imgBlurDataURL && !blurComplete && {
|
|
126
|
+
backgroundImage: `url(${imgBlurDataURL})`,
|
|
127
|
+
backgroundSize: "cover",
|
|
128
|
+
backgroundPosition: "center",
|
|
129
|
+
filter: "blur(20px)",
|
|
130
|
+
transition: "filter 0.3s ease-out"
|
|
131
|
+
},
|
|
132
|
+
...placeholder === "blur" && blurComplete && {
|
|
133
|
+
filter: "none",
|
|
134
|
+
transition: "filter 0.3s ease-out"
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
if (unoptimized) return /* @__PURE__ */ jsx("img", {
|
|
138
|
+
ref: imgRef,
|
|
139
|
+
src: loader ? loader({
|
|
140
|
+
src: finalSrc,
|
|
141
|
+
width: imgWidth || 1920,
|
|
142
|
+
quality
|
|
143
|
+
}) : finalSrc,
|
|
144
|
+
alt: showAltText ? alt : "",
|
|
145
|
+
width: fill ? void 0 : imgWidth,
|
|
146
|
+
height: fill ? void 0 : imgHeight,
|
|
147
|
+
loading: shouldPreload ? "eager" : loading,
|
|
148
|
+
fetchPriority: shouldPreload ? "high" : "auto",
|
|
149
|
+
decoding: imgDecoding,
|
|
150
|
+
onLoad: handleLoad,
|
|
151
|
+
onError: handleError,
|
|
152
|
+
style: imgStyle,
|
|
153
|
+
className
|
|
154
|
+
});
|
|
155
|
+
const sizesArray = fill ? DEFAULT_IMAGE_SIZES : DEFAULT_DEVICE_SIZES;
|
|
156
|
+
const defaultWidth = imgWidth || 1920;
|
|
157
|
+
const buildSrcSet = (format) => {
|
|
158
|
+
if (loader) return sizesArray.map((w) => `${loader({
|
|
159
|
+
src: finalSrc,
|
|
160
|
+
width: w,
|
|
161
|
+
quality
|
|
162
|
+
})} ${w}w`).join(", ");
|
|
163
|
+
return sizesArray.map((w) => `${buildImageUrl(finalSrc, w, quality, format)} ${w}w`).join(", ");
|
|
164
|
+
};
|
|
165
|
+
const imgElement = /* @__PURE__ */ jsx("img", {
|
|
166
|
+
ref: imgRef,
|
|
167
|
+
src: loader ? loader({
|
|
168
|
+
src: finalSrc,
|
|
169
|
+
width: defaultWidth,
|
|
170
|
+
quality
|
|
171
|
+
}) : buildImageUrl(finalSrc, defaultWidth, quality),
|
|
172
|
+
srcSet: buildSrcSet(),
|
|
173
|
+
sizes,
|
|
174
|
+
alt: showAltText ? alt : "",
|
|
175
|
+
width: fill ? void 0 : imgWidth,
|
|
176
|
+
height: fill ? void 0 : imgHeight,
|
|
177
|
+
loading: shouldPreload ? "eager" : loading,
|
|
178
|
+
fetchPriority: shouldPreload ? "high" : "auto",
|
|
179
|
+
decoding: imgDecoding,
|
|
180
|
+
onLoad: handleLoad,
|
|
181
|
+
onError: handleError,
|
|
182
|
+
style: imgStyle,
|
|
183
|
+
className
|
|
184
|
+
});
|
|
185
|
+
return /* @__PURE__ */ jsxs("picture", {
|
|
186
|
+
ref: pictureRef,
|
|
187
|
+
children: [
|
|
188
|
+
DEFAULT_FORMATS.includes("avif") && /* @__PURE__ */ jsx("source", {
|
|
189
|
+
type: "image/avif",
|
|
190
|
+
srcSet: buildSrcSet("avif"),
|
|
191
|
+
sizes
|
|
192
|
+
}),
|
|
193
|
+
DEFAULT_FORMATS.includes("webp") && /* @__PURE__ */ jsx("source", {
|
|
194
|
+
type: "image/webp",
|
|
195
|
+
srcSet: buildSrcSet("webp"),
|
|
196
|
+
sizes
|
|
197
|
+
}),
|
|
198
|
+
imgElement
|
|
199
|
+
]
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
//#endregion
|
|
204
|
+
export { DEFAULT_MAX_CACHE_SIZE as a, DEFAULT_IMAGE_SIZES as i, DEFAULT_DEVICE_SIZES as n, DEFAULT_MINIMUM_CACHE_TTL as o, DEFAULT_FORMATS as r, DEFAULT_QUALITY_LEVELS as s, Image as t };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
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-
|
|
3
|
-
import "./runtime-executor-
|
|
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-BNivvhrD.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-h7H6RaMX.mjs";
|
|
3
|
+
import "./runtime-executor-NBcG4boA.mjs";
|
|
4
4
|
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,7 +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-
|
|
2
|
-
import { t as RariRequest } from "./RariRequest-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import "./
|
|
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-DJhQmKAk.mjs";
|
|
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-CZzaWbFc.mjs";
|
|
4
|
+
import { t as generateAppRouteManifest } from "./routes-B_KAzmbj.mjs";
|
|
5
|
+
import "./image-CL9iVW32.mjs";
|
|
6
|
+
import "./server-build-DadtZ6wc.mjs";
|
|
6
7
|
|
|
7
8
|
export { ApiResponse, HttpRuntimeClient, RariRequest, RariResponse, clearPropsCache, clearPropsCacheForComponent, createHttpRuntimeClient, defineRariConfig, defineRariOptions, extractMetadata, extractServerProps, extractServerPropsWithCache, extractStaticParams, generateAppRouteManifest, hasServerSideDataFetching, rari, rariProxy, rariRouter };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/og/ImageResponse.d.ts
|
|
4
|
+
interface ImageResponseOptions {
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
fonts?: Array<{
|
|
8
|
+
name: string;
|
|
9
|
+
data: ArrayBuffer;
|
|
10
|
+
weight?: number;
|
|
11
|
+
style?: 'normal' | 'italic';
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
interface ImageResponseSize {
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
}
|
|
18
|
+
declare class ImageResponse {
|
|
19
|
+
private element;
|
|
20
|
+
private options;
|
|
21
|
+
constructor(element: ReactElement, options?: ImageResponseOptions);
|
|
22
|
+
toJSON(): {
|
|
23
|
+
type: string;
|
|
24
|
+
element: any;
|
|
25
|
+
options: ImageResponseOptions;
|
|
26
|
+
};
|
|
27
|
+
private serializeElement;
|
|
28
|
+
private serializeChildren;
|
|
29
|
+
private serializeProps;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { ImageResponse, type ImageResponseOptions, type ImageResponseSize };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//#region src/og/ImageResponse.tsx
|
|
2
|
+
var ImageResponse = class {
|
|
3
|
+
element;
|
|
4
|
+
options;
|
|
5
|
+
constructor(element, options = {}) {
|
|
6
|
+
this.element = element;
|
|
7
|
+
this.options = {
|
|
8
|
+
width: options.width || 1200,
|
|
9
|
+
height: options.height || 630,
|
|
10
|
+
fonts: options.fonts || []
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
toJSON() {
|
|
14
|
+
return {
|
|
15
|
+
type: "ImageResponse",
|
|
16
|
+
element: this.serializeElement(this.element),
|
|
17
|
+
options: this.options
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
serializeElement(element) {
|
|
21
|
+
if (typeof element === "string" || typeof element === "number") return {
|
|
22
|
+
type: "text",
|
|
23
|
+
value: String(element)
|
|
24
|
+
};
|
|
25
|
+
if (!element || !element.type) return null;
|
|
26
|
+
const type = typeof element.type === "string" ? element.type : element.type.name || "div";
|
|
27
|
+
const props = element.props || {};
|
|
28
|
+
const children = this.serializeChildren(props.children);
|
|
29
|
+
return {
|
|
30
|
+
type: "element",
|
|
31
|
+
elementType: type,
|
|
32
|
+
props: this.serializeProps(props),
|
|
33
|
+
children
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
serializeChildren(children) {
|
|
37
|
+
if (!children) return [];
|
|
38
|
+
if (Array.isArray(children)) return children.map((child) => this.serializeElement(child)).filter(Boolean);
|
|
39
|
+
const serialized = this.serializeElement(children);
|
|
40
|
+
return serialized ? [serialized] : [];
|
|
41
|
+
}
|
|
42
|
+
serializeProps(props) {
|
|
43
|
+
const { children, ...rest } = props;
|
|
44
|
+
const serialized = {};
|
|
45
|
+
for (const [key, value] of Object.entries(rest)) if (value !== void 0 && value !== null) serialized[key] = value;
|
|
46
|
+
return serialized;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { ImageResponse };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as initializeProxyExecutor } from "../runtime-executor-
|
|
1
|
+
import { t as initializeProxyExecutor } from "../runtime-executor-NBcG4boA.mjs";
|
|
2
2
|
export { initializeProxyExecutor };
|
|
@@ -6,7 +6,7 @@ async function initializeProxyExecutor(proxyModulePath) {
|
|
|
6
6
|
console.error("[rari:proxy] proxy function not found in module");
|
|
7
7
|
return false;
|
|
8
8
|
}
|
|
9
|
-
const { RariRequest } = await import("../RariRequest-
|
|
9
|
+
const { RariRequest } = await import("../RariRequest-D_4bWdqr.mjs");
|
|
10
10
|
globalThis.__rariExecuteProxy = async function(simpleRequest) {
|
|
11
11
|
try {
|
|
12
12
|
const rariRequest = new RariRequest(simpleRequest.url, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { promises } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
|
-
//#region src/router/
|
|
4
|
+
//#region src/router/routes.ts
|
|
5
5
|
const SPECIAL_FILES = {
|
|
6
6
|
PAGE: "page",
|
|
7
7
|
LAYOUT: "layout",
|
|
@@ -10,7 +10,11 @@ const SPECIAL_FILES = {
|
|
|
10
10
|
NOT_FOUND: "not-found",
|
|
11
11
|
TEMPLATE: "template",
|
|
12
12
|
DEFAULT: "default",
|
|
13
|
-
ROUTE: "route"
|
|
13
|
+
ROUTE: "route",
|
|
14
|
+
OG_IMAGE: "opengraph-image",
|
|
15
|
+
TWITTER_IMAGE: "twitter-image",
|
|
16
|
+
ICON: "icon",
|
|
17
|
+
APPLE_ICON: "apple-icon"
|
|
14
18
|
};
|
|
15
19
|
const SEGMENT_PATTERNS = {
|
|
16
20
|
DYNAMIC: /^\[([^\]]+)\]$/,
|
|
@@ -48,13 +52,15 @@ var AppRouteGenerator = class {
|
|
|
48
52
|
const errors = [];
|
|
49
53
|
const notFound = [];
|
|
50
54
|
const apiRoutes = [];
|
|
51
|
-
|
|
55
|
+
const ogImages = [];
|
|
56
|
+
await this.scanDirectory("", routes, layouts, loading, errors, notFound, apiRoutes, ogImages);
|
|
52
57
|
if (this.verbose) {
|
|
53
58
|
console.warn(`[AppRouter] Found ${routes.length} routes`);
|
|
54
59
|
console.warn(`[AppRouter] Found ${layouts.length} layouts`);
|
|
55
60
|
console.warn(`[AppRouter] Found ${loading.length} loading components`);
|
|
56
61
|
console.warn(`[AppRouter] Found ${errors.length} error boundaries`);
|
|
57
62
|
console.warn(`[AppRouter] Found ${apiRoutes.length} API routes`);
|
|
63
|
+
console.warn(`[AppRouter] Found ${ogImages.length} OG images`);
|
|
58
64
|
}
|
|
59
65
|
return {
|
|
60
66
|
routes: this.sortRoutes(routes),
|
|
@@ -63,10 +69,11 @@ var AppRouteGenerator = class {
|
|
|
63
69
|
errors,
|
|
64
70
|
notFound,
|
|
65
71
|
apiRoutes: this.sortApiRoutes(apiRoutes),
|
|
72
|
+
ogImages,
|
|
66
73
|
generated: (/* @__PURE__ */ new Date()).toISOString()
|
|
67
74
|
};
|
|
68
75
|
}
|
|
69
|
-
async scanDirectory(relativePath, routes, layouts, loading, errors, notFound, apiRoutes) {
|
|
76
|
+
async scanDirectory(relativePath, routes, layouts, loading, errors, notFound, apiRoutes, ogImages) {
|
|
70
77
|
const fullPath = path.join(this.appDir, relativePath);
|
|
71
78
|
let entries;
|
|
72
79
|
try {
|
|
@@ -83,13 +90,13 @@ var AppRouteGenerator = class {
|
|
|
83
90
|
if (this.shouldScanDirectory(entry)) dirs.push(entry);
|
|
84
91
|
} else if (stat$1.isFile()) files.push(entry);
|
|
85
92
|
}
|
|
86
|
-
await this.processSpecialFiles(relativePath, files, routes, layouts, loading, errors, notFound, apiRoutes);
|
|
93
|
+
await this.processSpecialFiles(relativePath, files, routes, layouts, loading, errors, notFound, apiRoutes, ogImages);
|
|
87
94
|
for (const dir of dirs) {
|
|
88
95
|
const subPath = relativePath ? path.join(relativePath, dir) : dir;
|
|
89
|
-
await this.scanDirectory(subPath, routes, layouts, loading, errors, notFound, apiRoutes);
|
|
96
|
+
await this.scanDirectory(subPath, routes, layouts, loading, errors, notFound, apiRoutes, ogImages);
|
|
90
97
|
}
|
|
91
98
|
}
|
|
92
|
-
async processSpecialFiles(relativePath, files, routes, layouts, loading, errors, notFound, apiRoutes) {
|
|
99
|
+
async processSpecialFiles(relativePath, files, routes, layouts, loading, errors, notFound, apiRoutes, ogImages) {
|
|
93
100
|
const routePath = this.pathToRoute(relativePath);
|
|
94
101
|
const pageFile = this.findFile(files, SPECIAL_FILES.PAGE);
|
|
95
102
|
if (pageFile) {
|
|
@@ -131,6 +138,31 @@ var AppRouteGenerator = class {
|
|
|
131
138
|
path: routePath,
|
|
132
139
|
filePath: path.join(relativePath, notFoundFile)
|
|
133
140
|
});
|
|
141
|
+
const ogImageFile = this.findFile(files, SPECIAL_FILES.OG_IMAGE);
|
|
142
|
+
if (ogImageFile) {
|
|
143
|
+
const filePath = path.join(relativePath, ogImageFile);
|
|
144
|
+
const fullFilePath = path.join(this.appDir, filePath);
|
|
145
|
+
let width;
|
|
146
|
+
let height;
|
|
147
|
+
let contentType;
|
|
148
|
+
try {
|
|
149
|
+
const content = await promises.readFile(fullFilePath, "utf-8");
|
|
150
|
+
const sizeMatch = content.match(/export\s+const\s+size\s*=\s*\{\s*width\s*:\s*(\d+)\s*,\s*height\s*:\s*(\d+)\s*[,}]/);
|
|
151
|
+
if (sizeMatch) {
|
|
152
|
+
width = Number.parseInt(sizeMatch[1], 10);
|
|
153
|
+
height = Number.parseInt(sizeMatch[2], 10);
|
|
154
|
+
}
|
|
155
|
+
const contentTypeMatch = content.match(/export\s+const\s+contentType\s*=\s*['"]([^'"]+)['"]/);
|
|
156
|
+
if (contentTypeMatch) contentType = contentTypeMatch[1];
|
|
157
|
+
} catch {}
|
|
158
|
+
ogImages.push({
|
|
159
|
+
path: routePath,
|
|
160
|
+
filePath,
|
|
161
|
+
width,
|
|
162
|
+
height,
|
|
163
|
+
contentType
|
|
164
|
+
});
|
|
165
|
+
}
|
|
134
166
|
const routeFile = this.findFile(files, SPECIAL_FILES.ROUTE);
|
|
135
167
|
if (routeFile) {
|
|
136
168
|
const apiRoute = await this.processApiRouteFile(relativePath, routeFile);
|
|
@@ -192,7 +224,6 @@ var AppRouteGenerator = class {
|
|
|
192
224
|
return ![
|
|
193
225
|
"node_modules",
|
|
194
226
|
".git",
|
|
195
|
-
".next",
|
|
196
227
|
"dist",
|
|
197
228
|
"build",
|
|
198
229
|
"__tests__",
|
package/dist/runtime/actions.mjs
CHANGED
|
@@ -7,7 +7,7 @@ function getCsrfToken() {
|
|
|
7
7
|
async function refreshCsrfToken() {
|
|
8
8
|
if (typeof window === "undefined") return false;
|
|
9
9
|
try {
|
|
10
|
-
const response = await fetch("/
|
|
10
|
+
const response = await fetch("/_rari/csrf-token");
|
|
11
11
|
if (!response.ok) {
|
|
12
12
|
console.error("Failed to refresh CSRF token:", response.status);
|
|
13
13
|
return false;
|
|
@@ -41,7 +41,7 @@ async function fetchWithCsrf(url, options = {}) {
|
|
|
41
41
|
...options,
|
|
42
42
|
headers
|
|
43
43
|
});
|
|
44
|
-
if (response.status === 403 && url.includes("/
|
|
44
|
+
if (response.status === 403 && url.includes("/_rari/")) {
|
|
45
45
|
if (await refreshCsrfToken()) {
|
|
46
46
|
const retryToken = getCsrfToken();
|
|
47
47
|
if (retryToken) {
|
|
@@ -80,7 +80,7 @@ function createServerReference(functionName, moduleId, exportName) {
|
|
|
80
80
|
}
|
|
81
81
|
return arg;
|
|
82
82
|
});
|
|
83
|
-
const response = await (typeof window !== "undefined" && window.fetchWithCsrf ? window.fetchWithCsrf : fetch)("/
|
|
83
|
+
const response = await (typeof window !== "undefined" && window.fetchWithCsrf ? window.fetchWithCsrf : fetch)("/_rari/action", {
|
|
84
84
|
method: "POST",
|
|
85
85
|
headers: { "Content-Type": "application/json" },
|
|
86
86
|
body: JSON.stringify({
|
|
@@ -142,7 +142,7 @@ function enhanceFormWithAction(form, action, options = {}) {
|
|
|
142
142
|
}
|
|
143
143
|
function createFormAction(moduleId, exportName, action) {
|
|
144
144
|
return {
|
|
145
|
-
action: "/
|
|
145
|
+
action: "/_rari/form-action",
|
|
146
146
|
enhance: (form, options = {}) => {
|
|
147
147
|
const actionIdInput = document.createElement("input");
|
|
148
148
|
actionIdInput.type = "hidden";
|
|
@@ -167,7 +167,7 @@ function createFormAction(moduleId, exportName, action) {
|
|
|
167
167
|
csrfInput.value = csrfToken;
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
form.action = "/
|
|
170
|
+
form.action = "/_rari/form-action";
|
|
171
171
|
form.method = "POST";
|
|
172
172
|
return enhanceFormWithAction(form, action, options);
|
|
173
173
|
}
|