rari 0.5.30 → 0.6.1

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 (80) hide show
  1. package/dist/RariRequest-CCo4Z2pl.mjs +156 -0
  2. package/dist/RariRequest-Cfba2VzK.mjs +3 -0
  3. package/dist/app-routes-BZjZ4Vwn.mjs +3 -0
  4. package/dist/cli.mjs +3 -3
  5. package/dist/client.d.mts +1 -1
  6. package/dist/client.mjs +1 -1
  7. package/dist/index.d.mts +4 -3
  8. package/dist/index.mjs +6 -5
  9. package/dist/mdx.d.mts +10 -0
  10. package/dist/mdx.mjs +78 -0
  11. package/dist/proxy/runtime-executor.d.mts +2 -0
  12. package/dist/proxy/runtime-executor.mjs +86 -0
  13. package/dist/robots-generator-D2SgtWQx.mjs +105 -0
  14. package/dist/{runtime-client-C_igMkq4.d.mts → runtime-client-q41T0L1o.d.mts} +28 -4
  15. package/dist/runtime-executor-Hcop_nAb.d.mts +27 -0
  16. package/dist/server-build-2zPPZQQe.mjs +3 -0
  17. package/dist/{server-build-DCJr3PU7.mjs → server-build-r9ka8T91.mjs} +38 -21
  18. package/dist/vite-B0zfwvJc.d.mts +239 -0
  19. package/dist/{vite-Dwd6mlC3.mjs → vite-MiXviq7b.mjs} +808 -693
  20. package/dist/vite.d.mts +4 -3
  21. package/dist/vite.mjs +6 -5
  22. package/package.json +12 -16
  23. package/src/api-routes.ts +2 -3
  24. package/src/cli.ts +1 -2
  25. package/src/deployment/railway.ts +1 -2
  26. package/src/deployment/render.ts +1 -2
  27. package/src/index.ts +1 -0
  28. package/src/mdx.ts +2 -0
  29. package/src/platform.ts +2 -4
  30. package/src/proxy/RariRequest.ts +206 -0
  31. package/src/proxy/RariResponse.ts +136 -0
  32. package/src/proxy/execute-proxy.ts +143 -0
  33. package/src/proxy/executor.ts +172 -0
  34. package/src/proxy/index.ts +16 -0
  35. package/src/proxy/matcher.ts +151 -0
  36. package/src/proxy/runtime-executor.ts +151 -0
  37. package/src/proxy/types.ts +127 -0
  38. package/src/proxy/vite-plugin.ts +153 -0
  39. package/src/router/ClientRouter.tsx +19 -38
  40. package/src/router/LayoutErrorBoundary.tsx +2 -4
  41. package/src/router/StatePreserver.ts +10 -22
  42. package/src/router/app-routes.ts +9 -16
  43. package/src/router/debounce.ts +5 -10
  44. package/src/router/navigation-utils.ts +10 -20
  45. package/src/router/props-extractor.ts +54 -56
  46. package/src/router/robots-generator.ts +146 -0
  47. package/src/router/route-info-client.ts +3 -6
  48. package/src/router/vite-plugin.ts +16 -36
  49. package/src/runtime/AppRouterProvider.tsx +27 -50
  50. package/src/runtime/actions.ts +6 -8
  51. package/src/runtime/csrf.ts +1 -2
  52. package/src/runtime/entry-client.js +15 -31
  53. package/src/runtime/mdx-client-components.ts +58 -0
  54. package/src/runtime/react-server-dom-rari-client.js +8 -16
  55. package/src/runtime/react-server-dom-shim.d.ts +26 -0
  56. package/src/runtime/react-server-dom-shim.js +3 -6
  57. package/src/runtime/rsc-client-runtime.js +62 -122
  58. package/src/runtime-client.ts +8 -21
  59. package/src/types/metadata-route.ts +14 -0
  60. package/src/vite/hmr-coordinator.ts +4 -9
  61. package/src/vite/hmr-error-handler.ts +2 -4
  62. package/src/vite/hmr-types.d.ts +1 -1
  63. package/src/vite/index.ts +128 -154
  64. package/src/vite/server-build.ts +54 -85
  65. package/src/vite.ts +22 -1
  66. package/dist/app-routes-q03OTf5N.mjs +0 -3
  67. package/dist/hooks/useActionState.d.mts +0 -13
  68. package/dist/hooks/useActionState.mjs +0 -97
  69. package/dist/loading-component-map-BQWkwB_z.mjs +0 -37
  70. package/dist/server-build-HX1-lDRR.mjs +0 -3
  71. package/dist/vite-C0q8SoeH.d.mts +0 -66
  72. package/src/hooks/useActionState.ts +0 -147
  73. package/src/router/loading-component-map.ts +0 -50
  74. package/src/vite/loading-component-bundler.ts +0 -119
  75. /package/dist/{app-routes-KhTu0CFP.mjs → app-routes-DngkPk-T.mjs} +0 -0
  76. /package/dist/{chunk-DFPPfDFE.mjs → chunk-CVb4hTOq.mjs} +0 -0
  77. /package/dist/{platform-DIRVyfTw.mjs → platform-CSErW1jU.mjs} +0 -0
  78. /package/dist/{railway-B8VEi9Qi.mjs → railway-O2zC15UA.mjs} +0 -0
  79. /package/dist/{render-Dz1orMws.mjs → render-0G06nNDC.mjs} +0 -0
  80. /package/dist/{runtime-client-2LnsnJtK.mjs → runtime-client-BnuxQ4y8.mjs} +0 -0
@@ -0,0 +1,156 @@
1
+ //#region src/proxy/RariRequest.ts
2
+ var RequestCookiesImpl = class {
3
+ cookies;
4
+ pendingDeletes;
5
+ pendingSets;
6
+ constructor(cookieHeader) {
7
+ this.cookies = /* @__PURE__ */ new Map();
8
+ this.pendingDeletes = /* @__PURE__ */ new Set();
9
+ this.pendingSets = /* @__PURE__ */ new Map();
10
+ if (cookieHeader) this.parseCookieHeader(cookieHeader);
11
+ }
12
+ parseCookieHeader(header) {
13
+ const pairs = header.split(";").map((pair) => pair.trim());
14
+ for (const pair of pairs) {
15
+ const [name, ...valueParts] = pair.split("=");
16
+ if (name) {
17
+ const value = valueParts.join("=");
18
+ this.cookies.set(name, {
19
+ name,
20
+ value
21
+ });
22
+ }
23
+ }
24
+ }
25
+ get(name) {
26
+ if (this.pendingDeletes.has(name)) return void 0;
27
+ const pending = this.pendingSets.get(name);
28
+ if (pending) return {
29
+ name: pending.name,
30
+ value: pending.value,
31
+ path: pending.options?.path
32
+ };
33
+ return this.cookies.get(name);
34
+ }
35
+ getAll() {
36
+ const result = [];
37
+ this.cookies.forEach((cookie) => {
38
+ if (!this.pendingDeletes.has(cookie.name)) result.push(cookie);
39
+ });
40
+ this.pendingSets.forEach((cookie) => {
41
+ result.push({
42
+ name: cookie.name,
43
+ value: cookie.value,
44
+ path: cookie.options?.path
45
+ });
46
+ });
47
+ return result;
48
+ }
49
+ has(name) {
50
+ if (this.pendingDeletes.has(name)) return false;
51
+ return this.pendingSets.has(name) || this.cookies.has(name);
52
+ }
53
+ delete(name) {
54
+ this.pendingDeletes.add(name);
55
+ this.pendingSets.delete(name);
56
+ }
57
+ set(nameOrOptions, value, options) {
58
+ if (typeof nameOrOptions === "string") {
59
+ this.pendingSets.set(nameOrOptions, {
60
+ name: nameOrOptions,
61
+ value,
62
+ options
63
+ });
64
+ this.pendingDeletes.delete(nameOrOptions);
65
+ } else {
66
+ const { name, value: val, ...opts } = nameOrOptions;
67
+ this.pendingSets.set(name, {
68
+ name,
69
+ value: val,
70
+ options: opts
71
+ });
72
+ this.pendingDeletes.delete(name);
73
+ }
74
+ }
75
+ getPendingChanges() {
76
+ return {
77
+ deletes: Array.from(this.pendingDeletes),
78
+ sets: Array.from(this.pendingSets.values())
79
+ };
80
+ }
81
+ };
82
+ var RariURLImpl = class {
83
+ url;
84
+ constructor(url) {
85
+ this.url = typeof url === "string" ? new URL(url) : url;
86
+ }
87
+ get href() {
88
+ return this.url.href;
89
+ }
90
+ get origin() {
91
+ return this.url.origin;
92
+ }
93
+ get protocol() {
94
+ return this.url.protocol;
95
+ }
96
+ get hostname() {
97
+ return this.url.hostname;
98
+ }
99
+ get port() {
100
+ return this.url.port;
101
+ }
102
+ get pathname() {
103
+ return this.url.pathname;
104
+ }
105
+ set pathname(value) {
106
+ this.url.pathname = value;
107
+ }
108
+ get search() {
109
+ return this.url.search;
110
+ }
111
+ set search(value) {
112
+ this.url.search = value;
113
+ }
114
+ get searchParams() {
115
+ return this.url.searchParams;
116
+ }
117
+ get hash() {
118
+ return this.url.hash;
119
+ }
120
+ set hash(value) {
121
+ this.url.hash = value;
122
+ }
123
+ toString() {
124
+ return this.url.toString();
125
+ }
126
+ };
127
+ var RariRequest = class RariRequest {
128
+ url;
129
+ method;
130
+ headers;
131
+ cookies;
132
+ rariUrl;
133
+ ip;
134
+ geo;
135
+ constructor(input, init) {
136
+ if (input instanceof Request) {
137
+ this.url = input.url;
138
+ this.method = input.method;
139
+ this.headers = new Headers(input.headers);
140
+ } else {
141
+ this.url = typeof input === "string" ? input : input.toString();
142
+ this.method = init?.method || "GET";
143
+ this.headers = new Headers(init?.headers);
144
+ }
145
+ this.rariUrl = new RariURLImpl(this.url);
146
+ this.cookies = new RequestCookiesImpl(this.headers.get("cookie") || void 0);
147
+ this.ip = init?.ip;
148
+ this.geo = init?.geo;
149
+ }
150
+ static fromRequest(request, options) {
151
+ return new RariRequest(request, options);
152
+ }
153
+ };
154
+
155
+ //#endregion
156
+ export { RariRequest as t };
@@ -0,0 +1,3 @@
1
+ import { t as RariRequest } from "./RariRequest-CCo4Z2pl.mjs";
2
+
3
+ export { RariRequest };
@@ -0,0 +1,3 @@
1
+ import { t as generateAppRouteManifest } from "./app-routes-DngkPk-T.mjs";
2
+
3
+ export { generateAppRouteManifest };
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as __require } from "./chunk-DFPPfDFE.mjs";
2
+ import { t as __require } from "./chunk-CVb4hTOq.mjs";
3
3
  import { existsSync } from "node:fs";
4
4
  import { join } from "node:path";
5
5
  import process from "node:process";
@@ -187,7 +187,7 @@ async function deployToRailway() {
187
187
  logError(`Already running in ${getPlatformName()} environment. Use "rari start" instead.`);
188
188
  process.exit(1);
189
189
  }
190
- const { createRailwayDeployment } = await import("./railway-B8VEi9Qi.mjs");
190
+ const { createRailwayDeployment } = await import("./railway-O2zC15UA.mjs");
191
191
  await createRailwayDeployment();
192
192
  }
193
193
  async function deployToRender() {
@@ -196,7 +196,7 @@ async function deployToRender() {
196
196
  logError(`Already running in ${getPlatformName()} environment. Use "rari start" instead.`);
197
197
  process.exit(1);
198
198
  }
199
- const { createRenderDeployment } = await import("./render-Dz1orMws.mjs");
199
+ const { createRenderDeployment } = await import("./render-0G06nNDC.mjs");
200
200
  await createRenderDeployment();
201
201
  }
202
202
  async function main() {
package/dist/client.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as LoadingEntry, C as AppRouteMatch, D as GenerateStaticParams, E as GenerateMetadata, M as PageProps, N as RouteSegment, O as LayoutEntry, P as RouteSegmentType, S as AppRouteManifest, T as ErrorProps, _ as extractServerProps, a as LoadingSpinner, b as hasServerSideDataFetching, c as createErrorBoundary, d as MetadataResult, f as ServerPropsResult, g as extractMetadata, h as clearPropsCacheForComponent, i as HttpRuntimeClient, j as NotFoundEntry, k as LayoutProps, l as createHttpRuntimeClient, m as clearPropsCache, n as DefaultLoading, o as NotFound, p as StaticParamsResult, r as ErrorBoundary, s as RuntimeClient, t as DefaultError, u as createLoadingBoundary, v as extractServerPropsWithCache, w as ErrorEntry, x as AppRouteEntry, y as extractStaticParams } from "./runtime-client-C_igMkq4.mjs";
1
+ import { A as LoadingEntry, C as AppRouteMatch, D as GenerateStaticParams, E as GenerateMetadata, M as PageProps, N as RouteSegment, O as LayoutEntry, P as RouteSegmentType, S as AppRouteManifest, T as ErrorProps, _ as extractServerProps, a as LoadingSpinner, b as hasServerSideDataFetching, c as createErrorBoundary, d as MetadataResult, f as ServerPropsResult, g as extractMetadata, h as clearPropsCacheForComponent, i as HttpRuntimeClient, j as NotFoundEntry, k as LayoutProps, l as createHttpRuntimeClient, m as clearPropsCache, n as DefaultLoading, o as NotFound, p as StaticParamsResult, r as ErrorBoundary, s as RuntimeClient, t as DefaultError, u as createLoadingBoundary, v as extractServerPropsWithCache, w as ErrorEntry, x as AppRouteEntry, y as extractStaticParams } from "./runtime-client-q41T0L1o.mjs";
2
2
  import React, { Component, ErrorInfo, ReactNode } from "react";
3
3
  import * as react_jsx_runtime0 from "react/jsx-runtime";
4
4
 
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-2LnsnJtK.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-BnuxQ4y8.mjs";
2
2
  import React, { Component, useEffect, useRef, useState } from "react";
3
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
4
 
package/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
- import { A as LoadingEntry, C as AppRouteMatch, D as GenerateStaticParams, E as GenerateMetadata, M as PageProps, N as RouteSegment, O as LayoutEntry, P as RouteSegmentType, S as AppRouteManifest, T as ErrorProps, _ as extractServerProps, b as hasServerSideDataFetching, d as MetadataResult, f as ServerPropsResult, g as extractMetadata, h as clearPropsCacheForComponent, i as HttpRuntimeClient, j as NotFoundEntry, k as LayoutProps, l as createHttpRuntimeClient, m as clearPropsCache, p as StaticParamsResult, s as RuntimeClient, v as extractServerPropsWithCache, w as ErrorEntry, x as AppRouteEntry, y as extractStaticParams } from "./runtime-client-C_igMkq4.mjs";
2
- import { a as rari, c as ApiRouteHandlers, d as RouteHandler, i as defineRariOptions, l as RariResponse, n as Response, o as rariRouter, r as defineRariConfig, s as generateAppRouteManifest, t as Request, u as RouteContext } from "./vite-C0q8SoeH.mjs";
3
- export { ApiRouteHandlers, AppRouteEntry, AppRouteManifest, AppRouteMatch, ErrorEntry, ErrorProps, GenerateMetadata, GenerateStaticParams, HttpRuntimeClient, LayoutEntry, LayoutProps, LoadingEntry, MetadataResult, NotFoundEntry, PageProps, RariResponse, Request, Response, RouteContext, RouteHandler, RouteSegment, RouteSegmentType, RuntimeClient, ServerPropsResult, StaticParamsResult, clearPropsCache, clearPropsCacheForComponent, createHttpRuntimeClient, defineRariConfig, defineRariOptions, extractMetadata, extractServerProps, extractServerPropsWithCache, extractStaticParams, generateAppRouteManifest, hasServerSideDataFetching, rari, rariRouter };
1
+ import { A as LoadingEntry, C as AppRouteMatch, D as GenerateStaticParams, E as GenerateMetadata, M as PageProps, N as RouteSegment, O as LayoutEntry, P as RouteSegmentType, S as AppRouteManifest, T as ErrorProps, _ as extractServerProps, b as hasServerSideDataFetching, d as MetadataResult, f as ServerPropsResult, g as extractMetadata, h as clearPropsCacheForComponent, i as HttpRuntimeClient, j as NotFoundEntry, k as LayoutProps, l as createHttpRuntimeClient, m as clearPropsCache, p as StaticParamsResult, s as RuntimeClient, v as extractServerPropsWithCache, w as ErrorEntry, x as AppRouteEntry, y as extractStaticParams } from "./runtime-client-q41T0L1o.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-B0zfwvJc.mjs";
3
+ import "./runtime-executor-Hcop_nAb.mjs";
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,6 +1,7 @@
1
- import { a as RariResponse, i as rariRouter, n as defineRariOptions, r as rari, t as defineRariConfig } from "./vite-Dwd6mlC3.mjs";
2
- import { t as generateAppRouteManifest } from "./app-routes-KhTu0CFP.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-2LnsnJtK.mjs";
4
- import "./server-build-DCJr3PU7.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-MiXviq7b.mjs";
2
+ import { t as RariRequest } from "./RariRequest-CCo4Z2pl.mjs";
3
+ import { t as generateAppRouteManifest } from "./app-routes-DngkPk-T.mjs";
4
+ 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-BnuxQ4y8.mjs";
5
+ import "./server-build-r9ka8T91.mjs";
5
6
 
6
- export { HttpRuntimeClient, RariResponse, clearPropsCache, clearPropsCacheForComponent, createHttpRuntimeClient, defineRariConfig, defineRariOptions, extractMetadata, extractServerProps, extractServerPropsWithCache, extractStaticParams, generateAppRouteManifest, hasServerSideDataFetching, rari, rariRouter };
7
+ export { ApiResponse, HttpRuntimeClient, RariRequest, RariResponse, clearPropsCache, clearPropsCacheForComponent, createHttpRuntimeClient, defineRariConfig, defineRariOptions, extractMetadata, extractServerProps, extractServerPropsWithCache, extractStaticParams, generateAppRouteManifest, hasServerSideDataFetching, rari, rariProxy, rariRouter };
package/dist/mdx.d.mts ADDED
@@ -0,0 +1,10 @@
1
+ //#region src/runtime/mdx-client-components.d.ts
2
+ interface MDXClientComponentConfig {
3
+ component: any;
4
+ id: string;
5
+ exportName?: string;
6
+ }
7
+ declare function createMDXClientReference(component: any, id: string, exportName?: string): any;
8
+ declare function createMDXClientReferences(components: Record<string, MDXClientComponentConfig>): Record<string, any>;
9
+ //#endregion
10
+ export { type MDXClientComponentConfig, createMDXClientReference, createMDXClientReferences };
package/dist/mdx.mjs ADDED
@@ -0,0 +1,78 @@
1
+ //#region src/runtime/react-server-dom-shim.js
2
+ const clientReferenceRegistry = /* @__PURE__ */ new Map();
3
+ let rustBridge = null;
4
+ if (typeof globalThis["~rari"]?.bridge !== "undefined") rustBridge = globalThis["~rari"].bridge;
5
+ function registerClientReference(clientReference, id, exportName) {
6
+ const key = `${id}#${exportName}`;
7
+ clientReferenceRegistry.set(key, {
8
+ id,
9
+ exportName,
10
+ chunks: [id],
11
+ name: exportName,
12
+ async: false
13
+ });
14
+ Object.defineProperty(clientReference, "$$typeof", {
15
+ value: Symbol.for("react.client.reference"),
16
+ enumerable: false
17
+ });
18
+ Object.defineProperty(clientReference, "$$id", {
19
+ value: key,
20
+ enumerable: false
21
+ });
22
+ Object.defineProperty(clientReference, "$$async", {
23
+ value: false,
24
+ enumerable: false
25
+ });
26
+ try {
27
+ if (rustBridge && typeof rustBridge.registerClientReference === "function") rustBridge.registerClientReference(key, id, exportName);
28
+ } catch (error) {
29
+ console.error(error);
30
+ }
31
+ return clientReference;
32
+ }
33
+ const clientComponentRegistry = /* @__PURE__ */ new Map();
34
+ function registerClientComponent(componentFunction, id, exportName) {
35
+ const key = `${id}#${exportName}`;
36
+ clientComponentRegistry.set(key, componentFunction);
37
+ clientReferenceRegistry.set(key, {
38
+ id,
39
+ exportName,
40
+ chunks: [id],
41
+ name: exportName,
42
+ async: false
43
+ });
44
+ }
45
+
46
+ //#endregion
47
+ //#region src/runtime/mdx-client-components.ts
48
+ function createMDXClientReference(component, id, exportName = "default") {
49
+ const key = `${id}#${exportName}`;
50
+ registerClientComponent(component, id, exportName);
51
+ if (typeof globalThis !== "undefined") {
52
+ const globalAny = globalThis;
53
+ if (!globalAny["~clientComponents"]) globalAny["~clientComponents"] = {};
54
+ const componentId = id.replace(/\.[^.]+$/, "").split("/").pop() || exportName;
55
+ const componentEntry = {
56
+ id: exportName === "default" ? componentId : exportName,
57
+ path: id,
58
+ type: "client",
59
+ component,
60
+ registered: true
61
+ };
62
+ globalAny["~clientComponents"][key] = componentEntry;
63
+ globalAny["~clientComponents"][componentId] = componentEntry;
64
+ globalAny["~clientComponents"][id] = componentEntry;
65
+ }
66
+ function clientProxy() {
67
+ throw new Error(`Attempted to call ${exportName}() from the server but ${exportName} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`);
68
+ }
69
+ return registerClientReference(clientProxy, id, exportName);
70
+ }
71
+ function createMDXClientReferences(components) {
72
+ const references = {};
73
+ for (const [name, { component, id, exportName = "default" }] of Object.entries(components)) references[name] = createMDXClientReference(component, id, exportName);
74
+ return references;
75
+ }
76
+
77
+ //#endregion
78
+ export { createMDXClientReference, createMDXClientReferences };
@@ -0,0 +1,2 @@
1
+ import { t as initializeProxyExecutor } from "../runtime-executor-Hcop_nAb.mjs";
2
+ export { initializeProxyExecutor };
@@ -0,0 +1,86 @@
1
+ //#region src/proxy/runtime-executor.ts
2
+ async function initializeProxyExecutor(proxyModulePath) {
3
+ try {
4
+ const proxyModule = await import(proxyModulePath);
5
+ if (!proxyModule || !proxyModule.proxy) {
6
+ console.error("[rari:proxy] proxy function not found in module");
7
+ return false;
8
+ }
9
+ const { RariRequest } = await import("../RariRequest-Cfba2VzK.mjs");
10
+ globalThis.__rariExecuteProxy = async function(simpleRequest) {
11
+ try {
12
+ const rariRequest = new RariRequest(simpleRequest.url, {
13
+ method: simpleRequest.method,
14
+ headers: new Headers(simpleRequest.headers)
15
+ });
16
+ const waitUntilPromises = [];
17
+ const result = await proxyModule.proxy(rariRequest, { waitUntil: (promise) => {
18
+ waitUntilPromises.push(promise);
19
+ } });
20
+ if (waitUntilPromises.length > 0) Promise.allSettled(waitUntilPromises).catch((error) => {
21
+ console.error("[rari:proxy] waitUntil promise failed:", error);
22
+ });
23
+ if (!result) return { continue: true };
24
+ const continueHeader = result.headers?.get?.("x-rari-proxy-continue");
25
+ const rewriteHeader = result.headers?.get?.("x-rari-proxy-rewrite");
26
+ if (rewriteHeader) return {
27
+ continue: false,
28
+ rewrite: rewriteHeader
29
+ };
30
+ const location = result.headers?.get?.("location");
31
+ if (location && result.status >= 300 && result.status < 400) return {
32
+ continue: false,
33
+ redirect: {
34
+ destination: location,
35
+ permanent: result.status === 301 || result.status === 308
36
+ }
37
+ };
38
+ if (continueHeader === "true") {
39
+ const requestHeaders = {};
40
+ const responseHeaders = {};
41
+ if (result.headers?.forEach) result.headers.forEach((value, key) => {
42
+ if (key.startsWith("x-rari-proxy-request-")) {
43
+ const headerName = key.replace("x-rari-proxy-request-", "");
44
+ requestHeaders[headerName] = value;
45
+ } else if (!key.startsWith("x-rari-proxy-")) responseHeaders[key] = value;
46
+ });
47
+ return {
48
+ continue: true,
49
+ requestHeaders: Object.keys(requestHeaders).length > 0 ? requestHeaders : void 0,
50
+ responseHeaders: Object.keys(responseHeaders).length > 0 ? responseHeaders : void 0
51
+ };
52
+ }
53
+ if (result.status) {
54
+ const headers = {};
55
+ if (result.headers?.forEach) result.headers.forEach((value, key) => {
56
+ headers[key] = value;
57
+ });
58
+ let body;
59
+ try {
60
+ if (result.text && typeof result.text === "function") body = await result.text();
61
+ else if (result.body) body = String(result.body);
62
+ } catch {}
63
+ return {
64
+ continue: false,
65
+ response: {
66
+ status: result.status,
67
+ headers,
68
+ body
69
+ }
70
+ };
71
+ }
72
+ return { continue: true };
73
+ } catch (error) {
74
+ console.error("[rari:proxy] Proxy execution error:", error);
75
+ return { continue: true };
76
+ }
77
+ };
78
+ return true;
79
+ } catch (error) {
80
+ console.error("[rari:proxy] Failed to initialize proxy executor:", error);
81
+ return false;
82
+ }
83
+ }
84
+
85
+ //#endregion
86
+ export { initializeProxyExecutor };
@@ -0,0 +1,105 @@
1
+ import { promises } from "node:fs";
2
+ import path from "node:path";
3
+
4
+ //#region src/router/robots-generator.ts
5
+ function generateRobotsTxt(robots) {
6
+ const lines = [];
7
+ const rules = Array.isArray(robots.rules) ? robots.rules : [robots.rules];
8
+ for (const rule of rules) {
9
+ const userAgents = Array.isArray(rule.userAgent) ? rule.userAgent : rule.userAgent ? [rule.userAgent] : ["*"];
10
+ for (const userAgent of userAgents) {
11
+ lines.push(`User-Agent: ${userAgent}`);
12
+ if (rule.allow) {
13
+ const allows = Array.isArray(rule.allow) ? rule.allow : [rule.allow];
14
+ for (const allow of allows) lines.push(`Allow: ${allow}`);
15
+ }
16
+ if (rule.disallow) {
17
+ const disallows = Array.isArray(rule.disallow) ? rule.disallow : [rule.disallow];
18
+ for (const disallow of disallows) lines.push(`Disallow: ${disallow}`);
19
+ }
20
+ if (rule.crawlDelay !== void 0) lines.push(`Crawl-delay: ${rule.crawlDelay}`);
21
+ lines.push("");
22
+ }
23
+ }
24
+ if (robots.host) {
25
+ lines.push(`Host: ${robots.host}`);
26
+ lines.push("");
27
+ }
28
+ if (robots.sitemap) {
29
+ const sitemaps = Array.isArray(robots.sitemap) ? robots.sitemap : [robots.sitemap];
30
+ for (const sitemap of sitemaps) lines.push(`Sitemap: ${sitemap}`);
31
+ }
32
+ return lines.join("\n");
33
+ }
34
+ async function findRobotsFile(appDir, extensions = [
35
+ ".ts",
36
+ ".tsx",
37
+ ".js",
38
+ ".jsx"
39
+ ]) {
40
+ const staticPath = path.join(appDir, "robots.txt");
41
+ try {
42
+ await promises.access(staticPath);
43
+ return {
44
+ type: "static",
45
+ path: staticPath
46
+ };
47
+ } catch {}
48
+ for (const ext of extensions) {
49
+ const dynamicPath = path.join(appDir, `robots${ext}`);
50
+ try {
51
+ await promises.access(dynamicPath);
52
+ return {
53
+ type: "dynamic",
54
+ path: dynamicPath
55
+ };
56
+ } catch {}
57
+ }
58
+ return null;
59
+ }
60
+ async function generateRobotsFile(options) {
61
+ const { appDir, outDir, extensions } = options;
62
+ const robotsFile = await findRobotsFile(appDir, extensions);
63
+ if (!robotsFile) return false;
64
+ const outputPath = path.join(outDir, "robots.txt");
65
+ if (robotsFile.type === "static") {
66
+ await promises.copyFile(robotsFile.path, outputPath);
67
+ return true;
68
+ }
69
+ try {
70
+ const result = await (await import("esbuild")).build({
71
+ entryPoints: [robotsFile.path],
72
+ bundle: true,
73
+ platform: "node",
74
+ format: "esm",
75
+ write: false,
76
+ external: ["rari"],
77
+ target: "node20"
78
+ });
79
+ if (result.outputFiles && result.outputFiles.length > 0) {
80
+ const code = result.outputFiles[0].text;
81
+ const tempFile = path.join(outDir, "_robots_temp.mjs");
82
+ await promises.writeFile(tempFile, code);
83
+ try {
84
+ const module = await import(`file://${tempFile}`);
85
+ const content = generateRobotsTxt(typeof module.default === "function" ? module.default() : module.default);
86
+ await promises.writeFile(outputPath, content);
87
+ await promises.unlink(tempFile);
88
+ return true;
89
+ } catch (execError) {
90
+ console.error("[rari] Failed to execute robots file:", execError);
91
+ try {
92
+ await promises.unlink(tempFile);
93
+ } catch {}
94
+ return false;
95
+ }
96
+ }
97
+ } catch (buildError) {
98
+ console.error("[rari] Failed to build robots file:", buildError);
99
+ return false;
100
+ }
101
+ return false;
102
+ }
103
+
104
+ //#endregion
105
+ export { generateRobotsFile };
@@ -113,7 +113,7 @@ interface MetadataResult {
113
113
  description?: string;
114
114
  url?: string;
115
115
  siteName?: string;
116
- images?: Array<{
116
+ images?: Array<string | {
117
117
  url: string;
118
118
  width?: number;
119
119
  height?: number;
@@ -143,11 +143,35 @@ interface MetadataResult {
143
143
  };
144
144
  };
145
145
  icons?: {
146
- icon?: string | string[];
147
- shortcut?: string | string[];
148
- apple?: string | string[];
146
+ icon?: Array<{
147
+ url: string;
148
+ type?: string;
149
+ sizes?: string;
150
+ rel?: string;
151
+ }> | string | string[];
152
+ apple?: Array<{
153
+ url: string;
154
+ sizes?: string;
155
+ rel?: string;
156
+ }> | string | string[];
157
+ other?: Array<{
158
+ url: string;
159
+ rel?: string;
160
+ type?: string;
161
+ sizes?: string;
162
+ color?: string;
163
+ }>;
149
164
  };
150
165
  manifest?: string;
166
+ themeColor?: string | Array<{
167
+ color: string;
168
+ media?: string;
169
+ }>;
170
+ appleWebApp?: {
171
+ title?: string;
172
+ statusBarStyle?: 'default' | 'black' | 'black-translucent';
173
+ capable?: boolean;
174
+ };
151
175
  viewport?: {
152
176
  width?: string | number;
153
177
  height?: string | number;
@@ -0,0 +1,27 @@
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
27
+ export { initializeProxyExecutor as t };
@@ -0,0 +1,3 @@
1
+ import { n as createServerBuildPlugin, r as scanDirectory, t as ServerComponentBuilder } from "./server-build-r9ka8T91.mjs";
2
+
3
+ export { ServerComponentBuilder, scanDirectory };