@nestjs-ssr/react 0.3.3 → 0.3.5

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/etc/react.api.md CHANGED
@@ -1,262 +1,250 @@
1
- ## API Report File for "@nestjs-ssr/react"
2
-
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
-
5
- ```ts
6
- import { CallHandler } from '@nestjs/common';
7
- import { ComponentType } from 'react';
8
- import { DynamicModule } from '@nestjs/common';
9
- import { ExecutionContext } from '@nestjs/common';
10
- import { NestInterceptor } from '@nestjs/common';
11
- import { Observable } from 'rxjs';
12
- import { default as React_2 } from 'react';
13
- import * as react_jsx_runtime from 'react/jsx-runtime';
14
- import { ReactNode } from 'react';
15
- import { Reflector } from '@nestjs/core';
16
- import { Response as Response_2 } from 'express';
17
- import { ViteDevServer } from 'vite';
18
-
19
- // Warning: (ae-forgotten-export) The symbol "ErrorPageDevelopmentProps" needs to be exported by the entry point index.d.ts
20
- //
21
- // @public
22
- export function ErrorPageDevelopment({
23
- error,
24
- viewPath,
25
- phase,
26
- }: ErrorPageDevelopmentProps): react_jsx_runtime.JSX.Element;
27
-
28
- // @public
29
- export function ErrorPageProduction(): react_jsx_runtime.JSX.Element;
30
-
31
- // @public
32
- export interface HeadData {
33
- bodyAttributes?: Record<string, string>;
34
- canonical?: string;
35
- description?: string;
36
- htmlAttributes?: Record<string, string>;
37
- jsonLd?: Array<Record<string, any>>;
38
- keywords?: string;
39
- links?: Array<{
40
- rel: string;
41
- href: string;
42
- as?: string;
43
- type?: string;
44
- crossorigin?: string;
45
- [key: string]: any;
46
- }>;
47
- meta?: Array<{
48
- name?: string;
49
- property?: string;
50
- content: string;
51
- [key: string]: any;
52
- }>;
53
- ogDescription?: string;
54
- ogImage?: string;
55
- ogTitle?: string;
56
- scripts?: Array<{
57
- src?: string;
58
- async?: boolean;
59
- defer?: boolean;
60
- type?: string;
61
- innerHTML?: string;
62
- [key: string]: any;
63
- }>;
64
- title?: string;
65
- }
66
-
67
- // @public
68
- export function Layout(
69
- layout: LayoutComponent<any>,
70
- options?: LayoutDecoratorOptions,
71
- ): ClassDecorator;
72
-
73
- // @public
74
- export type LayoutComponent<TProps = {}> = ComponentType<LayoutProps<TProps>>;
75
-
76
- // @public
77
- export interface LayoutDecoratorOptions {
78
- props?: Record<string, any>;
79
- skipRoot?: boolean;
80
- }
81
-
82
- // @public
83
- export interface LayoutProps<TProps = {}> {
84
- children: ReactNode;
85
- context?: RenderContext;
86
- head?: HeadData;
87
- layoutProps?: TProps;
88
- }
89
-
90
- // @public
91
- export interface PageComponentWithLayout<TPageProps = {}, TLayoutProps = {}> {
92
- (props: TPageProps): ReactNode;
93
- layout?: LayoutComponent<TLayoutProps>;
94
- layoutProps?: TLayoutProps;
95
- }
96
-
97
- // @public
98
- export type PageProps<TProps = {}> = TProps & {
99
- head?: HeadData;
100
- context: RenderContext;
101
- };
102
-
103
- // Warning: (ae-forgotten-export) The symbol "RenderReturnType" needs to be exported by the entry point index.d.ts
104
- // Warning: (ae-forgotten-export) The symbol "ExtractComponentData" needs to be exported by the entry point index.d.ts
105
- //
106
- // @public
107
- export function Render<T extends React_2.ComponentType<any>>(
108
- component: T,
109
- options?: RenderOptions,
110
- ): <
111
- TMethod extends (
112
- ...args: any[]
113
- ) =>
114
- | RenderReturnType<ExtractComponentData<T>>
115
- | Promise<RenderReturnType<ExtractComponentData<T>>>,
116
- >(
117
- target: any,
118
- propertyKey: string | symbol,
119
- descriptor: TypedPropertyDescriptor<TMethod>,
120
- ) => TypedPropertyDescriptor<TMethod> | void;
121
-
122
- // @public
123
- export interface RenderConfig {
124
- defaultHead?: HeadData;
125
- // Warning: (ae-forgotten-export) The symbol "ErrorPageDevelopmentProps$1" needs to be exported by the entry point index.d.ts
126
- errorPageDevelopment?: ComponentType<ErrorPageDevelopmentProps$1>;
127
- errorPageProduction?: ComponentType;
128
- mode?: SSRMode;
129
- template?: string;
130
- timeout?: number;
131
- // Warning: (ae-forgotten-export) The symbol "ViteConfig" needs to be exported by the entry point index.d.ts
132
- vite?: ViteConfig;
133
- }
134
-
135
- // @public
136
- export interface RenderContext {
137
- // (undocumented)
138
- [key: string]: any;
139
- // (undocumented)
140
- acceptLanguage?: string;
141
- // (undocumented)
142
- cookies?: Record<string, string>;
143
- // (undocumented)
144
- headers?: Record<string, string>;
145
- // (undocumented)
146
- method: string;
147
- // (undocumented)
148
- params: Record<string, string>;
149
- // (undocumented)
150
- path: string;
151
- // (undocumented)
152
- query: Record<string, string | string[]>;
153
- // (undocumented)
154
- referer?: string;
155
- // (undocumented)
156
- url: string;
157
- // (undocumented)
158
- userAgent?: string;
159
- }
160
-
161
- // @public (undocumented)
162
- export class RenderInterceptor implements NestInterceptor {
163
- constructor(reflector: Reflector, renderService: RenderService);
164
- // (undocumented)
165
- intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
166
- }
167
-
168
- // @public (undocumented)
169
- export class RenderModule {
170
- static register(config?: RenderConfig): DynamicModule;
171
- static registerAsync(options: {
172
- imports?: any[];
173
- inject?: any[];
174
- useFactory: (...args: any[]) => Promise<RenderConfig> | RenderConfig;
175
- }): DynamicModule;
176
- }
177
-
178
- // @public
179
- export interface RenderOptions {
180
- layout?: LayoutComponent<any> | false | null;
181
- layoutProps?: Record<string, any>;
182
- }
183
-
184
- // @public
185
- export interface RenderResponse<T = any> {
186
- head?: HeadData;
187
- layoutProps?: Record<string, any>;
188
- props: T;
189
- }
190
-
191
- // @public (undocumented)
192
- export class RenderService {
193
- constructor(
194
- templateParser: TemplateParserService,
195
- streamingErrorHandler: StreamingErrorHandler,
196
- ssrMode?: SSRMode,
197
- defaultHead?: HeadData | undefined,
198
- customTemplate?: string,
199
- );
200
- getRootLayout(): Promise<any | null>;
201
- render(
202
- viewComponent: any,
203
- data?: any,
204
- res?: Response_2,
205
- head?: HeadData,
206
- ): Promise<string | void>;
207
- // (undocumented)
208
- setViteServer(vite: ViteDevServer): void;
209
- }
210
-
211
- // @public
212
- export type SSRMode = 'string' | 'stream';
213
-
214
- // @public
215
- export class StreamingErrorHandler {
216
- constructor(
217
- errorPageDevelopment?:
218
- | ComponentType<ErrorPageDevelopmentProps$1>
219
- | undefined,
220
- errorPageProduction?: ComponentType | undefined,
221
- );
222
- handleShellError(
223
- error: Error,
224
- res: Response_2,
225
- viewPath: string,
226
- isDevelopment: boolean,
227
- ): void;
228
- handleStreamError(error: Error, viewPath: string): void;
229
- }
230
-
231
- // @public
232
- export class TemplateParserService {
233
- buildHeadTags(head?: HeadData): string;
234
- buildInlineScripts(
235
- data: any,
236
- context: any,
237
- componentName: string,
238
- layouts?: Array<{
239
- layout: any;
240
- props?: any;
241
- }>,
242
- ): string;
243
- getClientScriptTag(isDevelopment: boolean, manifest?: any): string;
244
- getStylesheetTags(isDevelopment: boolean, manifest?: any): string;
245
- // Warning: (ae-forgotten-export) The symbol "TemplateParts" needs to be exported by the entry point index.d.ts
246
- parseTemplate(html: string): TemplateParts;
247
- }
248
-
249
- // @public
250
- export function usePageContext(): RenderContext;
251
-
252
- // @public
253
- export function useParams(): Record<string, string>;
254
-
255
- // @public
256
- export function useQuery(): Record<string, string | string[]>;
257
-
258
- // @public
259
- export function useUserAgent(): string | undefined;
260
-
261
- // (No @packageDocumentation comment for this package)
262
- ```
1
+ ## API Report File for "@nestjs-ssr/react"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import { CallHandler } from '@nestjs/common';
8
+ import { ComponentType } from 'react';
9
+ import { DynamicModule } from '@nestjs/common';
10
+ import { ExecutionContext } from '@nestjs/common';
11
+ import { NestInterceptor } from '@nestjs/common';
12
+ import { Observable } from 'rxjs';
13
+ import { default as React_2 } from 'react';
14
+ import * as react_jsx_runtime from 'react/jsx-runtime';
15
+ import { ReactNode } from 'react';
16
+ import { Reflector } from '@nestjs/core';
17
+ import { Response as Response_2 } from 'express';
18
+ import { ViteDevServer } from 'vite';
19
+
20
+ // @public
21
+ export function createSSRHooks<T extends RenderContext = RenderContext>(): {
22
+ usePageContext: () => T;
23
+ useParams: () => Record<string, string>;
24
+ useQuery: () => Record<string, string | string[]>;
25
+ useRequest: () => T;
26
+ useHeaders: () => Record<string, string>;
27
+ useHeader: (name: string) => string | undefined;
28
+ useCookies: () => Record<string, string>;
29
+ useCookie: (name: string) => string | undefined;
30
+ };
31
+
32
+ // Warning: (ae-forgotten-export) The symbol "ErrorPageDevelopmentProps" needs to be exported by the entry point index.d.ts
33
+ //
34
+ // @public
35
+ export function ErrorPageDevelopment({ error, viewPath, phase, }: ErrorPageDevelopmentProps): react_jsx_runtime.JSX.Element;
36
+
37
+ // @public
38
+ export function ErrorPageProduction(): react_jsx_runtime.JSX.Element;
39
+
40
+ // @public
41
+ export interface HeadData {
42
+ bodyAttributes?: Record<string, string>;
43
+ canonical?: string;
44
+ description?: string;
45
+ htmlAttributes?: Record<string, string>;
46
+ jsonLd?: Array<Record<string, any>>;
47
+ keywords?: string;
48
+ links?: Array<{
49
+ rel: string;
50
+ href: string;
51
+ as?: string;
52
+ type?: string;
53
+ crossorigin?: string;
54
+ [key: string]: any;
55
+ }>;
56
+ meta?: Array<{
57
+ name?: string;
58
+ property?: string;
59
+ content: string;
60
+ [key: string]: any;
61
+ }>;
62
+ ogDescription?: string;
63
+ ogImage?: string;
64
+ ogTitle?: string;
65
+ scripts?: Array<{
66
+ src?: string;
67
+ async?: boolean;
68
+ defer?: boolean;
69
+ type?: string;
70
+ innerHTML?: string;
71
+ [key: string]: any;
72
+ }>;
73
+ title?: string;
74
+ }
75
+
76
+ // @public
77
+ export function Layout(layout: LayoutComponent<any>, options?: LayoutDecoratorOptions): ClassDecorator;
78
+
79
+ // @public
80
+ export type LayoutComponent<TProps = {}> = ComponentType<LayoutProps<TProps>>;
81
+
82
+ // @public
83
+ export interface LayoutDecoratorOptions {
84
+ props?: Record<string, any>;
85
+ skipRoot?: boolean;
86
+ }
87
+
88
+ // @public
89
+ export interface LayoutProps<TProps = {}> {
90
+ children: ReactNode;
91
+ context?: RenderContext;
92
+ head?: HeadData;
93
+ layoutProps?: TProps;
94
+ }
95
+
96
+ // @public
97
+ export interface PageComponentWithLayout<TPageProps = {}, TLayoutProps = {}> {
98
+ (props: TPageProps): ReactNode;
99
+ layout?: LayoutComponent<TLayoutProps>;
100
+ layoutProps?: TLayoutProps;
101
+ }
102
+
103
+ // @public
104
+ export function PageContextProvider({ context: initialContext, children, isSegment, }: {
105
+ context: RenderContext;
106
+ children: React_2.ReactNode;
107
+ isSegment?: boolean;
108
+ }): react_jsx_runtime.JSX.Element;
109
+
110
+ // @public
111
+ export type PageProps<TProps = {}> = TProps & {
112
+ head?: HeadData;
113
+ };
114
+
115
+ // Warning: (ae-forgotten-export) The symbol "RenderReturnType" needs to be exported by the entry point index.d.ts
116
+ // Warning: (ae-forgotten-export) The symbol "ExtractComponentData" needs to be exported by the entry point index.d.ts
117
+ //
118
+ // @public
119
+ export function Render<T extends React_2.ComponentType<any>>(component: T, options?: RenderOptions): <TMethod extends (...args: any[]) => RenderReturnType<ExtractComponentData<T>> | Promise<RenderReturnType<ExtractComponentData<T>>>>(target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<TMethod>) => TypedPropertyDescriptor<TMethod> | void;
120
+
121
+ // @public
122
+ export interface RenderConfig {
123
+ allowedCookies?: string[];
124
+ allowedHeaders?: string[];
125
+ defaultHead?: HeadData;
126
+ // Warning: (ae-forgotten-export) The symbol "ErrorPageDevelopmentProps$1" needs to be exported by the entry point index.d.ts
127
+ errorPageDevelopment?: ComponentType<ErrorPageDevelopmentProps$1>;
128
+ errorPageProduction?: ComponentType;
129
+ mode?: SSRMode;
130
+ template?: string;
131
+ timeout?: number;
132
+ // Warning: (ae-forgotten-export) The symbol "ViteConfig" needs to be exported by the entry point index.d.ts
133
+ vite?: ViteConfig;
134
+ }
135
+
136
+ // @public
137
+ export interface RenderContext {
138
+ // (undocumented)
139
+ method: string;
140
+ // (undocumented)
141
+ params: Record<string, string>;
142
+ // (undocumented)
143
+ path: string;
144
+ // (undocumented)
145
+ query: Record<string, string | string[]>;
146
+ // (undocumented)
147
+ url: string;
148
+ }
149
+
150
+ // @public (undocumented)
151
+ export class RenderInterceptor implements NestInterceptor {
152
+ constructor(reflector: Reflector, renderService: RenderService, allowedHeaders?: string[] | undefined, allowedCookies?: string[] | undefined);
153
+ // (undocumented)
154
+ intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
155
+ }
156
+
157
+ // @public (undocumented)
158
+ export class RenderModule {
159
+ static forRoot(config?: RenderConfig): DynamicModule;
160
+ static forRootAsync(options: {
161
+ imports?: any[];
162
+ inject?: any[];
163
+ useFactory: (...args: any[]) => Promise<RenderConfig> | RenderConfig;
164
+ }): DynamicModule;
165
+ // @deprecated (undocumented)
166
+ static register(config?: RenderConfig): DynamicModule;
167
+ // @deprecated (undocumented)
168
+ static registerAsync(options: {
169
+ imports?: any[];
170
+ inject?: any[];
171
+ useFactory: (...args: any[]) => Promise<RenderConfig> | RenderConfig;
172
+ }): DynamicModule;
173
+ }
174
+
175
+ // @public
176
+ export interface RenderOptions {
177
+ layout?: LayoutComponent<any> | false | null;
178
+ layoutProps?: Record<string, any>;
179
+ }
180
+
181
+ // @public
182
+ export interface RenderResponse<T = any> {
183
+ head?: HeadData;
184
+ layoutProps?: Record<string, any>;
185
+ props: T;
186
+ }
187
+
188
+ // @public
189
+ export class RenderService {
190
+ // Warning: (ae-forgotten-export) The symbol "StringRenderer" needs to be exported by the entry point index.d.ts
191
+ // Warning: (ae-forgotten-export) The symbol "StreamRenderer" needs to be exported by the entry point index.d.ts
192
+ constructor(stringRenderer: StringRenderer, streamRenderer: StreamRenderer, ssrMode?: SSRMode, defaultHead?: HeadData | undefined, customTemplate?: string);
193
+ getRootLayout(): Promise<any | null>;
194
+ render(viewComponent: any, data?: any, res?: Response_2, head?: HeadData): Promise<string | void>;
195
+ // Warning: (ae-forgotten-export) The symbol "SegmentResponse" needs to be exported by the entry point index.d.ts
196
+ renderSegment(viewComponent: any, data: any, swapTarget: string, head?: HeadData): Promise<SegmentResponse>;
197
+ // (undocumented)
198
+ setViteServer(vite: ViteDevServer): void;
199
+ }
200
+
201
+ // @public
202
+ export type SSRMode = 'string' | 'stream';
203
+
204
+ // @public
205
+ export class StreamingErrorHandler {
206
+ constructor(errorPageDevelopment?: ComponentType<ErrorPageDevelopmentProps$1> | undefined, errorPageProduction?: ComponentType | undefined);
207
+ handleShellError(error: Error, res: Response_2, viewPath: string, isDevelopment: boolean): void;
208
+ handleStreamError(error: Error, viewPath: string): void;
209
+ }
210
+
211
+ // @public
212
+ export class TemplateParserService {
213
+ buildHeadTags(head?: HeadData): string;
214
+ buildInlineScripts(data: any, context: any, componentName: string, layouts?: Array<{
215
+ layout: any;
216
+ props?: any;
217
+ }>): string;
218
+ getClientScriptTag(isDevelopment: boolean, manifest?: any): string;
219
+ getStylesheetTags(isDevelopment: boolean, manifest?: any): string;
220
+ // Warning: (ae-forgotten-export) The symbol "TemplateParts" needs to be exported by the entry point index.d.ts
221
+ parseTemplate(html: string): TemplateParts;
222
+ }
223
+
224
+ // @public (undocumented)
225
+ export const useCookie: (name: string) => string | undefined;
226
+
227
+ // @public (undocumented)
228
+ export const useCookies: () => Record<string, string>;
229
+
230
+ // @public (undocumented)
231
+ export const useHeader: (name: string) => string | undefined;
232
+
233
+ // @public (undocumented)
234
+ export const useHeaders: () => Record<string, string>;
235
+
236
+ // @public (undocumented)
237
+ export const usePageContext: () => RenderContext;
238
+
239
+ // @public (undocumented)
240
+ export const useParams: () => Record<string, string>;
241
+
242
+ // @public (undocumented)
243
+ export const useQuery: () => Record<string, string | string[]>;
244
+
245
+ // @public (undocumented)
246
+ export const useRequest: () => RenderContext;
247
+
248
+ // (No @packageDocumentation comment for this package)
249
+
250
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs-ssr/react",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "React SSR for NestJS that respects Clean Architecture. Proper DI, SOLID principles, clear separation of concerns.",
5
5
  "keywords": [
6
6
  "nestjs",