rari 0.14.7 → 0.14.8

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rari",
3
3
  "type": "module",
4
- "version": "0.14.7",
4
+ "version": "0.14.8",
5
5
  "description": "Runtime Accelerated Rendering Infrastructure (rari)",
6
6
  "author": "Ryan Skinner",
7
7
  "license": "MIT",
@@ -32,6 +32,10 @@
32
32
  "full-stack",
33
33
  "web-framework"
34
34
  ],
35
+ "sideEffects": [
36
+ "./dist/runtime/entry-client.mjs",
37
+ "./dist/runtime/rsc-client-runtime.mjs"
38
+ ],
35
39
  "exports": {
36
40
  ".": {
37
41
  "browser": "./dist/client.mjs",
@@ -103,20 +107,20 @@
103
107
  "node": ">=22.12.0"
104
108
  },
105
109
  "peerDependencies": {
106
- "react": "^19.2.6",
107
- "react-dom": "^19.2.6"
110
+ "react": "^19.2.7",
111
+ "react-dom": "^19.2.7"
108
112
  },
109
113
  "dependencies": {
110
114
  "lightningcss": "^1.32.0",
111
115
  "rolldown": "^1.1.0"
112
116
  },
113
117
  "optionalDependencies": {
114
- "rari-darwin-arm64": "0.14.7",
115
- "rari-darwin-x64": "0.14.7",
116
- "rari-linux-arm64": "0.14.7",
117
- "rari-linux-x64": "0.14.7",
118
- "rari-win32-arm64": "0.14.7",
119
- "rari-win32-x64": "0.14.7"
118
+ "rari-darwin-arm64": "0.14.8",
119
+ "rari-darwin-x64": "0.14.8",
120
+ "rari-linux-arm64": "0.14.8",
121
+ "rari-linux-x64": "0.14.8",
122
+ "rari-win32-arm64": "0.14.8",
123
+ "rari-win32-x64": "0.14.8"
120
124
  },
121
125
  "devDependencies": {
122
126
  "@types/node": "^25.9.2",
@@ -1,6 +0,0 @@
1
- import*as e from"react";import{Component as t,Suspense as n}from"react";function r(e,t){e&&(e.notFound&&(t.notFound=!0),e.redirect&&(t.redirect=typeof e.redirect==`string`?e.redirect:e.redirect.destination),e.revalidate!==void 0&&(t.revalidate=e.revalidate),e.props&&(t.props={...t.props,...e.props}))}async function i(e,t,n,i){typeof e.getData==`function`&&r(await e.getData({params:t,searchParams:n}),i)}async function a(e,t,n,i){typeof e.getServerSideProps==`function`&&r(await e.getServerSideProps({params:t,searchParams:n}),i)}async function o(e,t,n){typeof e.getStaticProps==`function`&&r(await e.getStaticProps({params:t}),n)}async function s(e,t,n){try{let r=await import(e),s={props:{}};return await i(r,t,n,s),await a(r,t,n,s),await o(r,t,s),s}catch(t){return console.error(`[rari] Router: Failed to extract server props from ${e}:`,t),{props:{}}}}async function c(e,t,n){try{let r=await import(e);if(typeof r.generateMetadata==`function`){let e=await r.generateMetadata({params:t,searchParams:n});if(e&&typeof e==`object`)return e}return r.metadata&&typeof r.metadata==`object`?r.metadata:{}}catch(t){return console.error(`[rari] Router: Failed to extract metadata from ${e}:`,t),{}}}async function l(e){try{let t=await import(e);if(typeof t.generateStaticParams==`function`){let e=await t.generateStaticParams();if(Array.isArray(e))return e}return[]}catch(t){return console.error(`[rari] Router: Failed to extract static params from ${e}:`,t),[]}}async function u(e){try{let t=await import(e);return!!(t.getData||t.getServerSideProps||t.getStaticProps||t.generateMetadata||t.generateStaticParams)}catch{return!1}}const d=new Map;async function f(e,t,n,r=6e4){let i=`${e}:${JSON.stringify(t)}:${JSON.stringify(n)}`,a=d.get(i);if(a&&Date.now()-a.timestamp<r)return a.result;let o=await s(e,t,n);return d.set(i,{result:o,timestamp:Date.now()}),o}function p(){d.clear()}function m(e){for(let t of d.keys())t.startsWith(e)&&d.delete(t)}async function h(e){if(!e.ok){let t;try{t=await e.text()}catch{t=`<unable to read response body>`}let n=t.length>200?`${t.slice(0,200)}...`:t,r=Error(`HTTP ${e.status}: ${e.statusText}`);throw r.status=e.status,r.statusText=e.statusText,r.bodyPreview=n,r}}var g=class{baseUrl;timeout;components=[];initialized=!1;constructor(e={}){let{host:t=`127.0.0.1`,port:n=3e3,timeout:r=3e4,ssl:i=!1}=e,a=i?`https`:`http`;this.baseUrl=`${a}://${t}:${n}`,this.timeout=r}assertInitialized(){if(!this.initialized)throw Error(`Runtime client not initialized. Call initialize() first.`)}async request(e,t={}){let{method:n=`GET`,body:r,headers:i={}}=t,a=`${this.baseUrl}${e}`,o={method:n,headers:{"Content-Type":`application/json`,...i},signal:AbortSignal.timeout(this.timeout)};r&&(n===`POST`||n===`PUT`)&&(o.body=JSON.stringify(r));try{let e=await fetch(a,o);return await h(e),e.headers.get(`content-type`)?.includes(`application/json`)?await e.json():await e.text()}catch(e){if(e instanceof Error){if(e.name===`AbortError`)throw Error(`Request timeout after ${this.timeout}ms`);if(e.message.includes(`ECONNREFUSED`))throw Error(`Failed to connect to rari server at ${this.baseUrl}. Make sure the server is running.`)}throw e}}async initialize(){try{let e=await this.request(`/_rari/health`);if(e.status!==`healthy`)throw Error(`Server is not healthy: ${e.status}`);this.initialized=!0}catch(e){throw Error(`Failed to initialize runtime client: ${e}`)}}async registerComponent(e,t){this.assertInitialized();let n={component_id:e,component_code:t};try{let t=await this.request(`/_rari/register`,{method:`POST`,body:n});if(!t.success)throw Error(`Failed to register component: ${t.error||`Unknown error`}`);this.components.includes(e)||this.components.push(e)}catch(t){throw Error(`Failed to register component ${e}: ${t}`)}}async renderToStreamCallbacks(e,t){this.assertInitialized();let n={component_id:e,props:t?JSON.parse(t):void 0};try{let e=await fetch(`${this.baseUrl}/_rari/stream`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n),signal:AbortSignal.timeout(this.timeout)});return await h(e),e.body}catch(t){throw Error(`Failed to stream component ${e}: ${t}`)}}registerClientComponent(e,t,n){this.queueClientComponentRegistration(e,t,n)}async queueClientComponentRegistration(e,t,n){if(!this.initialized){console.error(`[rari] Runtime: Client not initialized. Client component registration will be delayed.`);return}let r={component_id:e,file_path:t,export_name:n};try{let e=await this.request(`/_rari/register-client`,{method:`POST`,body:r});if(!e.success)throw Error(`Failed to register client component: ${e.error||`Unknown error`}`)}catch(t){console.error(`[rari] Runtime: Failed to register client component ${e}:`,t)}}registerClientReference(e,t,n){this.queueClientComponentRegistration(e,t,n)}listComponents(){return[...this.components]}async shutdown(){try{this.initialized=!1,this.components=[]}catch(e){console.error(`[rari] Runtime: Error during shutdown:`,e)}}async getServerStatus(){return await this.request(`/_rari/status`)}async checkHealth(){return await this.request(`/_rari/health`)}isInitialized(){return this.initialized}getBaseUrl(){return this.baseUrl}};function _(e){return new g(e)}function v({children:t,fallback:r}){return e.createElement(n,{fallback:r},t)}function y(t){return({children:n})=>e.createElement(v,{fallback:t,children:n})}var b=class extends t{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){this.props.onError?.(e,t)}render(){if(this.state.hasError){let t=()=>this.setState({hasError:!1,error:null});return this.props.fallback?this.props.fallback(this.state.error,t):e.createElement(`div`,{style:{padding:`1rem`,border:`1px solid #ef4444`,borderRadius:`0.5rem`,backgroundColor:`#fef2f2`}},[e.createElement(`h2`,{style:{color:`#dc2626`,margin:`0 0 0.5rem 0`}},`Something went wrong`),e.createElement(`p`,{style:{color:`#991b1b`,margin:`0 0 1rem 0`}},this.state.error?.message||`An unexpected error occurred`),e.createElement(`button`,{onClick:t,style:{padding:`0.5rem 1rem`,backgroundColor:`#dc2626`,color:`white`,border:`none`,borderRadius:`0.25rem`,cursor:`pointer`}},`Try again`)])}return this.props.children}};function x({children:t,fallback:n}){return e.createElement(b,{fallback:n},t)}function S(t){return({children:n})=>e.createElement(x,{fallback:t,children:n})}function C(){return e.createElement(`div`,{style:{padding:`2rem`,textAlign:`center`}},[e.createElement(`h1`,{style:{fontSize:`2rem`,margin:`0 0 1rem 0`}},`404 - Page Not Found`),e.createElement(`p`,{style:{color:`#6b7280`,margin:`0 0 1rem 0`}},`The page you're looking for doesn't exist.`),e.createElement(`button`,{onClick:()=>window.history.back(),style:{padding:`0.5rem 1rem`,backgroundColor:`#3b82f6`,color:`white`,border:`none`,borderRadius:`0.25rem`,cursor:`pointer`}},`Go back`)])}function w({size:t=`medium`}){let n={small:`1rem`,medium:`2rem`,large:`3rem`};return e.createElement(`div`,{style:{display:`inline-block`,width:n[t],height:n[t],border:`2px solid #e5e7eb`,borderTop:`2px solid #3b82f6`,borderRadius:`50%`,animation:`spin 1s linear infinite`}})}function T(){return e.createElement(`div`,{style:{display:`flex`,justifyContent:`center`,alignItems:`center`,padding:`2rem`,minHeight:`200px`}},e.createElement(w))}function E({error:t,reset:n}){return e.createElement(`div`,{style:{padding:`2rem`,border:`1px solid #ef4444`,borderRadius:`0.5rem`,backgroundColor:`#fef2f2`,textAlign:`center`}},[e.createElement(`h2`,{style:{color:`#dc2626`,margin:`0 0 1rem 0`}},`Something went wrong`),e.createElement(`p`,{style:{color:`#991b1b`,margin:`0 0 1rem 0`}},t.message||`An unexpected error occurred`),e.createElement(`button`,{onClick:n,style:{padding:`0.5rem 1rem`,backgroundColor:`#dc2626`,color:`white`,border:`none`,borderRadius:`0.25rem`,cursor:`pointer`}},`Try again`)])}if(typeof document<`u`){let e=document.createElement(`style`);e.textContent=`
2
- @keyframes spin {
3
- 0% { transform: rotate(0deg); }
4
- 100% { transform: rotate(360deg); }
5
- }
6
- `,document.head.appendChild(e)}export{u as _,w as a,_ as c,p as d,m as f,l as g,f as h,g as i,y as l,s as m,T as n,C as o,c as p,b as r,S as s,E as t,h as u};
@@ -1,237 +0,0 @@
1
- import * as React from "react";
2
- import { Component, ReactElement, ReactNode } from "react";
3
-
4
- //#region src/router/props-extractor.d.ts
5
- interface ServerSidePropsResult {
6
- props: Record<string, any>;
7
- revalidate?: number;
8
- notFound?: boolean;
9
- redirect?: string;
10
- }
11
- interface MetadataResult {
12
- title?: string | {
13
- default?: string;
14
- template?: string;
15
- absolute?: string;
16
- };
17
- description?: string;
18
- keywords?: string[];
19
- openGraph?: {
20
- title?: string;
21
- description?: string;
22
- url?: string;
23
- siteName?: string;
24
- images?: Array<string | {
25
- url: string;
26
- width?: number;
27
- height?: number;
28
- alt?: string;
29
- }>;
30
- type?: string;
31
- };
32
- twitter?: {
33
- card?: 'summary' | 'summary_large_image' | 'app' | 'player';
34
- site?: string;
35
- creator?: string;
36
- title?: string;
37
- description?: string;
38
- images?: string[];
39
- };
40
- robots?: {
41
- index?: boolean;
42
- follow?: boolean;
43
- nocache?: boolean;
44
- };
45
- icons?: {
46
- icon?: Array<{
47
- url: string;
48
- type?: string;
49
- sizes?: string;
50
- rel?: string;
51
- }> | string | string[];
52
- apple?: Array<{
53
- url: string;
54
- sizes?: string;
55
- rel?: string;
56
- }> | string | string[];
57
- other?: Array<{
58
- url: string;
59
- rel?: string;
60
- type?: string;
61
- sizes?: string;
62
- color?: string;
63
- }>;
64
- };
65
- manifest?: string;
66
- themeColor?: string | Array<{
67
- color: string;
68
- media?: string;
69
- }>;
70
- appleWebApp?: {
71
- title?: string;
72
- statusBarStyle?: 'default' | 'black' | 'black-translucent';
73
- capable?: boolean;
74
- };
75
- viewport?: string;
76
- canonical?: string;
77
- }
78
- type StaticParamsResult = Array<Record<string, string | string[]>>;
79
- declare function extractServerProps(componentPath: string, params: Record<string, string>, searchParams: Record<string, string>): Promise<ServerSidePropsResult>;
80
- declare function extractMetadata(componentPath: string, params: Record<string, string>, searchParams: Record<string, string>): Promise<MetadataResult>;
81
- declare function extractStaticParams(componentPath: string): Promise<StaticParamsResult>;
82
- declare function hasServerSideDataFetching(componentPath: string): Promise<boolean>;
83
- declare function extractServerPropsWithCache(componentPath: string, params: Record<string, string>, searchParams: Record<string, string>, cacheTime?: number): Promise<ServerSidePropsResult>;
84
- declare function clearPropsCache(): void;
85
- declare function clearPropsCacheForComponent(componentPath: string): void;
86
- //#endregion
87
- //#region src/runtime-client.d.ts
88
- interface RuntimeClient {
89
- initialize: () => Promise<void>;
90
- registerComponent: (componentId: string, componentCode: string) => Promise<void>;
91
- renderToStreamCallbacks: (componentId: string, props?: string) => Promise<any>;
92
- registerClientComponent: (componentId: string, filePath: string, exportName: string) => void;
93
- registerClientReference: (referenceId: string, filePath: string, exportName: string) => void;
94
- listComponents: () => string[];
95
- shutdown: () => Promise<void>;
96
- }
97
- interface HealthResponse {
98
- status: string;
99
- timestamp: string;
100
- }
101
- interface StatusResponse {
102
- status: string;
103
- mode: string;
104
- uptime_seconds: number;
105
- request_count: number;
106
- components_registered: number;
107
- memory_usage?: number;
108
- }
109
- declare class HttpRuntimeClient implements RuntimeClient {
110
- private baseUrl;
111
- private timeout;
112
- private components;
113
- private initialized;
114
- constructor(options?: {
115
- host?: string;
116
- port?: number;
117
- timeout?: number;
118
- ssl?: boolean;
119
- });
120
- private assertInitialized;
121
- private request;
122
- initialize(): Promise<void>;
123
- registerComponent(componentId: string, componentCode: string): Promise<void>;
124
- renderToStreamCallbacks(componentId: string, props?: string): Promise<any>;
125
- registerClientComponent(componentId: string, filePath: string, exportName: string): void;
126
- private queueClientComponentRegistration;
127
- registerClientReference(referenceId: string, filePath: string, exportName: string): void;
128
- listComponents(): string[];
129
- shutdown(): Promise<void>;
130
- getServerStatus(): Promise<StatusResponse>;
131
- checkHealth(): Promise<HealthResponse>;
132
- isInitialized(): boolean;
133
- getBaseUrl(): string;
134
- }
135
- declare function createHttpRuntimeClient(options?: {
136
- host?: string;
137
- port?: number;
138
- timeout?: number;
139
- ssl?: boolean;
140
- }): RuntimeClient;
141
- declare function createLoadingBoundary(fallback: ReactElement): ({
142
- children
143
- }: {
144
- children: ReactNode;
145
- }) => React.FunctionComponentElement<{
146
- children: ReactNode;
147
- fallback: ReactElement;
148
- }>;
149
- declare class ErrorBoundary extends Component<{
150
- children: ReactNode;
151
- fallback?: (error: Error, reset: () => void) => ReactElement;
152
- onError?: (error: Error, errorInfo: any) => void;
153
- }, {
154
- hasError: boolean;
155
- error: Error | null;
156
- }> {
157
- constructor(props: any);
158
- static getDerivedStateFromError(error: Error): {
159
- hasError: boolean;
160
- error: Error;
161
- };
162
- componentDidCatch(error: Error, errorInfo: any): void;
163
- render(): ReactNode;
164
- }
165
- declare function createErrorBoundary(fallback?: (error: Error, reset: () => void) => ReactElement): ({
166
- children
167
- }: {
168
- children: ReactNode;
169
- }) => React.FunctionComponentElement<{
170
- children: ReactNode;
171
- fallback?: (error: Error, reset: () => void) => ReactElement;
172
- }>;
173
- declare function NotFound(): React.DetailedReactHTMLElement<{
174
- style: {
175
- padding: string;
176
- textAlign: "center";
177
- };
178
- }, HTMLElement>;
179
- declare function LoadingSpinner({
180
- size
181
- }: {
182
- size?: 'small' | 'medium' | 'large';
183
- }): React.DetailedReactHTMLElement<{
184
- style: {
185
- display: "inline-block";
186
- width: string;
187
- height: string;
188
- border: string;
189
- borderTop: string;
190
- borderRadius: string;
191
- animation: "spin 1s linear infinite";
192
- };
193
- }, HTMLElement>;
194
- declare function DefaultLoading(): React.DetailedReactHTMLElement<{
195
- style: {
196
- display: "flex";
197
- justifyContent: "center";
198
- alignItems: "center";
199
- padding: string;
200
- minHeight: string;
201
- };
202
- }, HTMLElement>;
203
- declare function DefaultError({
204
- error,
205
- reset
206
- }: {
207
- error: Error;
208
- reset: () => void;
209
- }): React.DetailedReactHTMLElement<{
210
- style: {
211
- padding: string;
212
- border: string;
213
- borderRadius: string;
214
- backgroundColor: "#fef2f2";
215
- textAlign: "center";
216
- };
217
- }, HTMLElement>;
218
- //#endregion
219
- //#region src/types/server-config.d.ts
220
- interface ServerCSPConfig {
221
- scriptSrc?: string[];
222
- styleSrc?: string[];
223
- imgSrc?: string[];
224
- fontSrc?: string[];
225
- connectSrc?: string[];
226
- defaultSrc?: string[];
227
- workerSrc?: string[];
228
- }
229
- interface ServerCacheControlConfig {
230
- routes: Record<string, string>;
231
- }
232
- interface ServerConfig {
233
- csp?: ServerCSPConfig;
234
- cacheControl?: ServerCacheControlConfig;
235
- }
236
- //#endregion
237
- export { hasServerSideDataFetching as C, extractStaticParams as S, clearPropsCache as _, DefaultLoading as a, extractServerProps as b, LoadingSpinner as c, createErrorBoundary as d, createHttpRuntimeClient as f, StaticParamsResult as g, ServerSidePropsResult as h, DefaultError as i, NotFound as l, MetadataResult as m, ServerCacheControlConfig as n, ErrorBoundary as o, createLoadingBoundary as p, ServerConfig as r, HttpRuntimeClient as s, ServerCSPConfig as t, RuntimeClient as u, clearPropsCacheForComponent as v, extractServerPropsWithCache as x, extractMetadata as y };