lovable-ssr 0.1.11 → 0.1.12

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.
@@ -17,23 +17,23 @@ export function AppRoutes() {
17
17
  const routeKey = matchedRoute ? buildRouteKey(matchedRoute.path, params.routeParams, params.searchParams) : '';
18
18
  const { data, setData } = useRouteData();
19
19
  const currentData = routeKey ? data[routeKey] : undefined;
20
- const getServerData = matchedRoute?.Component?.getServerData;
20
+ const getData = matchedRoute?.Component?.getData;
21
21
  useEffect(() => {
22
- if (!routeKey || !getServerData || currentData !== undefined)
22
+ if (!routeKey || !getData || currentData !== undefined)
23
23
  return;
24
- getServerData(params)
24
+ getData(params)
25
25
  .then((d) => setData(routeKey, d))
26
26
  .catch((e) => {
27
- console.error('Client getServerData failed:', e);
27
+ console.error('Client getData failed:', e);
28
28
  setData(routeKey, {});
29
29
  });
30
- }, [routeKey, getServerData, params, currentData, setData]);
30
+ }, [routeKey, getData, params, currentData, setData]);
31
31
  return (_jsx(Routes, { children: routes.map((route) => {
32
32
  const isMatched = matchedRoute === route;
33
- const getServerDataForRoute = route.Component.getServerData;
33
+ const getDataForRoute = route.Component.getData;
34
34
  let element;
35
35
  if (isMatched) {
36
- if (typeof getServerDataForRoute === 'function') {
36
+ if (typeof getDataForRoute === 'function') {
37
37
  element =
38
38
  currentData !== undefined ? (_jsx(route.Component, { ...currentData })) : null;
39
39
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import './globals.js';
2
- export type { RouteConfig, ComponentWithGetServerData } from './types.js';
2
+ export type { RouteConfig, ComponentWithGetData } from './types.js';
3
3
  export { registerRoutes, getRoutes } from './registry.js';
4
4
  export { BrowserRouteDataProvider } from './components/BrowserRouteDataProvider.js';
5
5
  export { default as RouterService } from './router/RouterService.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AACtB,YAAY,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACpF,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EACL,MAAM,EACN,KAAK,YAAY,EACjB,KAAK,aAAa,GACnB,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AACtB,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACpF,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EACL,MAAM,EACN,KAAK,YAAY,EACjB,KAAK,aAAa,GACnB,MAAM,iBAAiB,CAAC"}
@@ -8,7 +8,7 @@ export interface RenderOptions {
8
8
  }
9
9
  /**
10
10
  * Renders the app for a single URL. Called once per request with that request's URL.
11
- * getServerData is invoked only for the route that matches this URL (never for all routes).
11
+ * getData is invoked only for the route that matches this URL (never for all routes).
12
12
  */
13
13
  export declare function render(url: string, options?: RenderOptions): Promise<RenderResult>;
14
14
  //# sourceMappingURL=render.d.ts.map
@@ -6,7 +6,7 @@ import { RouteDataProvider } from '../router/RouteDataContext.js';
6
6
  import { AppRoutes } from '../components/AppRoutes.js';
7
7
  /**
8
8
  * Renders the app for a single URL. Called once per request with that request's URL.
9
- * getServerData is invoked only for the route that matches this URL (never for all routes).
9
+ * getData is invoked only for the route that matches this URL (never for all routes).
10
10
  */
11
11
  export async function render(url, options) {
12
12
  const fullUrl = new URL(url, 'http://localhost');
@@ -19,13 +19,13 @@ export async function render(url, options) {
19
19
  const searchParams = matchedRoute ? RouterService.searchParams(fullUrl.search) : {};
20
20
  params.searchParams = searchParams;
21
21
  let preloadedData = { is_success: true };
22
- const getServerData = matchedRoute?.Component?.getServerData;
23
- if (typeof getServerData === 'function') {
22
+ const getData = matchedRoute?.Component?.getData;
23
+ if (typeof getData === 'function') {
24
24
  try {
25
- preloadedData = await getServerData(params);
25
+ preloadedData = await getData(params);
26
26
  }
27
27
  catch (e) {
28
- console.error(`SSR getServerData failed for ${matchedRoute?.path}:`, e);
28
+ console.error(`SSR getData failed for ${matchedRoute?.path}:`, e);
29
29
  preloadedData = { ...preloadedData, is_success: false };
30
30
  }
31
31
  }
package/dist/types.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import type React from 'react';
2
- export type ComponentWithGetServerData = React.ComponentType<any> & {
3
- getServerData?: (params?: Record<'routeParams' | 'searchParams', Record<string, string>>) => Promise<Record<string, unknown>>;
2
+ export type ComponentWithGetData = React.ComponentType<any> & {
3
+ getData?: (params?: Record<'routeParams' | 'searchParams', Record<string, string>>) => Promise<Record<string, unknown>>;
4
4
  };
5
5
  export type RouteConfig = {
6
6
  path: string;
7
- Component: ComponentWithGetServerData;
7
+ Component: ComponentWithGetData;
8
8
  isSSR: boolean;
9
9
  };
10
10
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,MAAM,0BAA0B,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG;IAClE,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,aAAa,GAAG,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC/H,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,0BAA0B,CAAC;IACtC,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG;IAC5D,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,aAAa,GAAG,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACzH,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,oBAAoB,CAAC;IAChC,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lovable-ssr",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "SSR and route data engine for Lovable projects",
5
5
  "keywords": [
6
6
  "ssr",
@@ -8,7 +8,7 @@
8
8
  "vite",
9
9
  "express",
10
10
  "lovable",
11
- "getServerData",
11
+ "getData",
12
12
  "route-registry",
13
13
  "server-side-rendering"
14
14
  ],