@nestjs-ssr/react 0.1.4 → 0.1.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.
- package/dist/{index-C7qZ7BPg.d.mts → index-Bpzo1KfR.d.mts} +3 -2
- package/dist/{index-C7qZ7BPg.d.ts → index-Bpzo1KfR.d.ts} +3 -2
- package/dist/index.d.mts +31 -22
- package/dist/index.d.ts +31 -22
- package/dist/index.js +72 -7049
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -7021
- package/dist/index.mjs.map +1 -1
- package/dist/render/index.d.mts +1 -1
- package/dist/render/index.d.ts +1 -1
- package/dist/render/index.js +56 -29
- package/dist/render/index.js.map +1 -1
- package/dist/render/index.mjs +56 -29
- package/dist/render/index.mjs.map +1 -1
- package/dist/templates/entry-client.tsx +16 -4
- package/dist/templates/entry-server.tsx +4 -8
- package/package.json +1 -1
- package/src/global.d.ts +2 -10
- package/src/templates/entry-client.tsx +16 -4
- package/src/templates/entry-server.tsx +4 -8
- package/dist/vite/index.d.mts +0 -11
- package/dist/vite/index.d.ts +0 -11
- package/dist/vite/index.js +0 -7022
- package/dist/vite/index.js.map +0 -1
- package/dist/vite/index.mjs +0 -6997
- package/dist/vite/index.mjs.map +0 -1
|
@@ -295,7 +295,7 @@ declare class TemplateParserService {
|
|
|
295
295
|
* This library handles all edge cases including escaping dangerous characters,
|
|
296
296
|
* functions, dates, regexes, and prevents prototype pollution.
|
|
297
297
|
*/
|
|
298
|
-
buildInlineScripts(data: any, context: any,
|
|
298
|
+
buildInlineScripts(data: any, context: any, componentName: string): string;
|
|
299
299
|
/**
|
|
300
300
|
* Get client script tag for hydration
|
|
301
301
|
*
|
|
@@ -368,12 +368,13 @@ declare class RenderService {
|
|
|
368
368
|
private isDevelopment;
|
|
369
369
|
private ssrMode;
|
|
370
370
|
private readonly entryServerPath;
|
|
371
|
+
private readonly entryClientPath;
|
|
371
372
|
constructor(templateParser: TemplateParserService, streamingErrorHandler: StreamingErrorHandler, ssrMode?: SSRMode, defaultHead?: HeadData | undefined);
|
|
372
373
|
setViteServer(vite: ViteDevServer): void;
|
|
373
374
|
/**
|
|
374
375
|
* Main render method that routes to string or stream mode
|
|
375
376
|
*/
|
|
376
|
-
render(
|
|
377
|
+
render(viewComponent: any, data?: any, res?: Response, head?: HeadData): Promise<string | void>;
|
|
377
378
|
/**
|
|
378
379
|
* Merge default head with page-specific head
|
|
379
380
|
* Page-specific head values override defaults
|
|
@@ -295,7 +295,7 @@ declare class TemplateParserService {
|
|
|
295
295
|
* This library handles all edge cases including escaping dangerous characters,
|
|
296
296
|
* functions, dates, regexes, and prevents prototype pollution.
|
|
297
297
|
*/
|
|
298
|
-
buildInlineScripts(data: any, context: any,
|
|
298
|
+
buildInlineScripts(data: any, context: any, componentName: string): string;
|
|
299
299
|
/**
|
|
300
300
|
* Get client script tag for hydration
|
|
301
301
|
*
|
|
@@ -368,12 +368,13 @@ declare class RenderService {
|
|
|
368
368
|
private isDevelopment;
|
|
369
369
|
private ssrMode;
|
|
370
370
|
private readonly entryServerPath;
|
|
371
|
+
private readonly entryClientPath;
|
|
371
372
|
constructor(templateParser: TemplateParserService, streamingErrorHandler: StreamingErrorHandler, ssrMode?: SSRMode, defaultHead?: HeadData | undefined);
|
|
372
373
|
setViteServer(vite: ViteDevServer): void;
|
|
373
374
|
/**
|
|
374
375
|
* Main render method that routes to string or stream mode
|
|
375
376
|
*/
|
|
376
|
-
render(
|
|
377
|
+
render(viewComponent: any, data?: any, res?: Response, head?: HeadData): Promise<string | void>;
|
|
377
378
|
/**
|
|
378
379
|
* Merge default head with page-specific head
|
|
379
380
|
* Page-specific head values override defaults
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { H as HeadData } from './index-
|
|
2
|
-
export { E as ErrorPageDevelopment, f as ErrorPageProduction, c as RenderConfig, b as RenderInterceptor, R as RenderModule, e as RenderResponse, a as RenderService, d as SSRMode, S as StreamingErrorHandler, T as TemplateParserService } from './index-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import 'react';
|
|
1
|
+
import { H as HeadData } from './index-Bpzo1KfR.mjs';
|
|
2
|
+
export { E as ErrorPageDevelopment, f as ErrorPageProduction, c as RenderConfig, b as RenderInterceptor, R as RenderModule, e as RenderResponse, a as RenderService, d as SSRMode, S as StreamingErrorHandler, T as TemplateParserService } from './index-Bpzo1KfR.mjs';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import '@nestjs/common';
|
|
6
5
|
import 'vite';
|
|
7
6
|
import 'express';
|
|
8
7
|
import '@nestjs/core';
|
|
@@ -122,39 +121,49 @@ type PageProps<TProps = {}> = TProps & {
|
|
|
122
121
|
};
|
|
123
122
|
|
|
124
123
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
124
|
+
* Extract the data type T from PageProps<T>.
|
|
125
|
+
* PageProps<T> = T & { head?, context }, so we extract T by removing those keys.
|
|
127
126
|
*/
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
type ExtractPagePropsData<P> = P extends PageProps<infer T> ? T : P extends {
|
|
128
|
+
head?: any;
|
|
129
|
+
context: any;
|
|
130
|
+
} ? Omit<P, 'head' | 'context'> : P;
|
|
130
131
|
/**
|
|
131
|
-
*
|
|
132
|
-
* This is populated via module augmentation from the generated view registry.
|
|
132
|
+
* Extract controller return type from a React component's props.
|
|
133
133
|
*/
|
|
134
|
-
type
|
|
134
|
+
type ExtractComponentData<T> = T extends React.ComponentType<infer P> ? ExtractPagePropsData<P> : never;
|
|
135
135
|
/**
|
|
136
136
|
* Decorator to render a React component as the response.
|
|
137
|
-
* Provides IDE autocomplete and type checking for view paths.
|
|
138
137
|
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
138
|
+
* Import the component directly for Cmd+Click navigation in your IDE.
|
|
139
|
+
* TypeScript automatically validates your controller returns the correct props.
|
|
141
140
|
*
|
|
142
|
-
* @param
|
|
141
|
+
* @param component - The React component to render
|
|
143
142
|
*
|
|
144
143
|
* @example
|
|
145
144
|
* ```typescript
|
|
145
|
+
* // Your view component (views/home.tsx)
|
|
146
|
+
* export interface HomeProps {
|
|
147
|
+
* message: string;
|
|
148
|
+
* }
|
|
149
|
+
* export default function Home(props: PageProps<HomeProps>) { ... }
|
|
150
|
+
*
|
|
151
|
+
* // Your controller - Cmd+Click on Home navigates to the view file!
|
|
152
|
+
* import Home from './views/home';
|
|
153
|
+
*
|
|
146
154
|
* @Get()
|
|
147
|
-
* @Render(
|
|
148
|
-
*
|
|
149
|
-
* return {
|
|
155
|
+
* @Render(Home) // Type-safe! Wrong props = build error
|
|
156
|
+
* getHome() {
|
|
157
|
+
* return { message: 'Hello' }; // ✅ Correct
|
|
158
|
+
* // return { wrong: 'prop' }; // ❌ Type error!
|
|
150
159
|
* }
|
|
151
160
|
* ```
|
|
152
161
|
*/
|
|
153
|
-
declare
|
|
162
|
+
declare function Render<T extends React.ComponentType<any>>(component: T): <TMethod extends (...args: any[]) => ExtractComponentData<T> | Promise<ExtractComponentData<T>>>(target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<TMethod>) => TypedPropertyDescriptor<TMethod> | void;
|
|
154
163
|
/**
|
|
155
164
|
* @deprecated Use `Render` instead. This alias will be removed in a future version.
|
|
156
165
|
*/
|
|
157
|
-
declare const ReactRender:
|
|
166
|
+
declare const ReactRender: typeof Render;
|
|
158
167
|
|
|
159
168
|
/**
|
|
160
169
|
* Hook to access the full page context.
|
|
@@ -217,4 +226,4 @@ declare function useQuery(): Record<string, string | string[]>;
|
|
|
217
226
|
*/
|
|
218
227
|
declare function useUserAgent(): string | undefined;
|
|
219
228
|
|
|
220
|
-
export { HeadData, type PageProps, ReactRender, Render, type RenderContext,
|
|
229
|
+
export { HeadData, type PageProps, ReactRender, Render, type RenderContext, usePageContext, useParams, useQuery, useUserAgent };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { H as HeadData } from './index-
|
|
2
|
-
export { E as ErrorPageDevelopment, f as ErrorPageProduction, c as RenderConfig, b as RenderInterceptor, R as RenderModule, e as RenderResponse, a as RenderService, d as SSRMode, S as StreamingErrorHandler, T as TemplateParserService } from './index-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import 'react';
|
|
1
|
+
import { H as HeadData } from './index-Bpzo1KfR.js';
|
|
2
|
+
export { E as ErrorPageDevelopment, f as ErrorPageProduction, c as RenderConfig, b as RenderInterceptor, R as RenderModule, e as RenderResponse, a as RenderService, d as SSRMode, S as StreamingErrorHandler, T as TemplateParserService } from './index-Bpzo1KfR.js';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import '@nestjs/common';
|
|
6
5
|
import 'vite';
|
|
7
6
|
import 'express';
|
|
8
7
|
import '@nestjs/core';
|
|
@@ -122,39 +121,49 @@ type PageProps<TProps = {}> = TProps & {
|
|
|
122
121
|
};
|
|
123
122
|
|
|
124
123
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
124
|
+
* Extract the data type T from PageProps<T>.
|
|
125
|
+
* PageProps<T> = T & { head?, context }, so we extract T by removing those keys.
|
|
127
126
|
*/
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
type ExtractPagePropsData<P> = P extends PageProps<infer T> ? T : P extends {
|
|
128
|
+
head?: any;
|
|
129
|
+
context: any;
|
|
130
|
+
} ? Omit<P, 'head' | 'context'> : P;
|
|
130
131
|
/**
|
|
131
|
-
*
|
|
132
|
-
* This is populated via module augmentation from the generated view registry.
|
|
132
|
+
* Extract controller return type from a React component's props.
|
|
133
133
|
*/
|
|
134
|
-
type
|
|
134
|
+
type ExtractComponentData<T> = T extends React.ComponentType<infer P> ? ExtractPagePropsData<P> : never;
|
|
135
135
|
/**
|
|
136
136
|
* Decorator to render a React component as the response.
|
|
137
|
-
* Provides IDE autocomplete and type checking for view paths.
|
|
138
137
|
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
138
|
+
* Import the component directly for Cmd+Click navigation in your IDE.
|
|
139
|
+
* TypeScript automatically validates your controller returns the correct props.
|
|
141
140
|
*
|
|
142
|
-
* @param
|
|
141
|
+
* @param component - The React component to render
|
|
143
142
|
*
|
|
144
143
|
* @example
|
|
145
144
|
* ```typescript
|
|
145
|
+
* // Your view component (views/home.tsx)
|
|
146
|
+
* export interface HomeProps {
|
|
147
|
+
* message: string;
|
|
148
|
+
* }
|
|
149
|
+
* export default function Home(props: PageProps<HomeProps>) { ... }
|
|
150
|
+
*
|
|
151
|
+
* // Your controller - Cmd+Click on Home navigates to the view file!
|
|
152
|
+
* import Home from './views/home';
|
|
153
|
+
*
|
|
146
154
|
* @Get()
|
|
147
|
-
* @Render(
|
|
148
|
-
*
|
|
149
|
-
* return {
|
|
155
|
+
* @Render(Home) // Type-safe! Wrong props = build error
|
|
156
|
+
* getHome() {
|
|
157
|
+
* return { message: 'Hello' }; // ✅ Correct
|
|
158
|
+
* // return { wrong: 'prop' }; // ❌ Type error!
|
|
150
159
|
* }
|
|
151
160
|
* ```
|
|
152
161
|
*/
|
|
153
|
-
declare
|
|
162
|
+
declare function Render<T extends React.ComponentType<any>>(component: T): <TMethod extends (...args: any[]) => ExtractComponentData<T> | Promise<ExtractComponentData<T>>>(target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<TMethod>) => TypedPropertyDescriptor<TMethod> | void;
|
|
154
163
|
/**
|
|
155
164
|
* @deprecated Use `Render` instead. This alias will be removed in a future version.
|
|
156
165
|
*/
|
|
157
|
-
declare const ReactRender:
|
|
166
|
+
declare const ReactRender: typeof Render;
|
|
158
167
|
|
|
159
168
|
/**
|
|
160
169
|
* Hook to access the full page context.
|
|
@@ -217,4 +226,4 @@ declare function useQuery(): Record<string, string | string[]>;
|
|
|
217
226
|
*/
|
|
218
227
|
declare function useUserAgent(): string | undefined;
|
|
219
228
|
|
|
220
|
-
export { HeadData, type PageProps, ReactRender, Render, type RenderContext,
|
|
229
|
+
export { HeadData, type PageProps, ReactRender, Render, type RenderContext, usePageContext, useParams, useQuery, useUserAgent };
|