@fluojs/react 0.1.0 → 0.2.0
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/README.ko.md +629 -16
- package/README.md +644 -25
- package/dist/decorators.d.ts +3 -3
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +10 -4
- package/dist/diagnostics.d.ts +110 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +180 -0
- package/dist/error-representation.d.ts +28 -0
- package/dist/error-representation.d.ts.map +1 -0
- package/dist/error-representation.js +28 -0
- package/dist/experimental/rsc-flight-response.d.ts.map +1 -1
- package/dist/experimental/rsc-flight-response.js +2 -6
- package/dist/experimental/server-functions-server.js +1 -1
- package/dist/experimental/server-functions-types.d.ts +1 -1
- package/dist/experimental/server-functions-types.d.ts.map +1 -1
- package/dist/index.d.ts +16 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/module.d.ts +8 -2
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +31 -8
- package/dist/page-catalog.d.ts +29 -0
- package/dist/page-catalog.d.ts.map +1 -0
- package/dist/page-catalog.js +46 -0
- package/dist/page-metadata.d.ts +58 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +139 -0
- package/dist/page-renderer.d.ts +24 -0
- package/dist/page-renderer.d.ts.map +1 -0
- package/dist/page-renderer.js +18 -0
- package/dist/page-result.d.ts +16 -0
- package/dist/page-result.d.ts.map +1 -0
- package/dist/page-result.js +101 -0
- package/dist/render-diagnostics.d.ts +25 -0
- package/dist/render-diagnostics.d.ts.map +1 -0
- package/dist/render-diagnostics.js +94 -0
- package/dist/render-policy-metadata.d.ts +40 -0
- package/dist/render-policy-metadata.d.ts.map +1 -0
- package/dist/render-policy-metadata.js +136 -0
- package/dist/render-policy.d.ts +87 -0
- package/dist/render-policy.d.ts.map +1 -0
- package/dist/render-policy.js +203 -0
- package/dist/render-stream.d.ts +1 -1
- package/dist/render-stream.d.ts.map +1 -1
- package/dist/render-stream.js +80 -15
- package/dist/render.d.ts +12 -3
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +70 -76
- package/dist/server-entry.d.ts +13 -1
- package/dist/server-entry.d.ts.map +1 -1
- package/dist/server-entry.js +21 -11
- package/dist/typegen-artifact.d.ts +9 -0
- package/dist/typegen-artifact.d.ts.map +1 -0
- package/dist/typegen-artifact.js +116 -0
- package/dist/typegen.d.ts +41 -0
- package/dist/typegen.d.ts.map +1 -0
- package/dist/typegen.js +162 -0
- package/package.json +11 -6
package/dist/decorators.d.ts
CHANGED
|
@@ -56,11 +56,11 @@ export declare function Router(basePath?: string): ClassDecoratorLike;
|
|
|
56
56
|
* `:param` placeholders only. The optional `options` value is metadata for future
|
|
57
57
|
* render integrations; it does not create a React-owned matcher or `routes: []` table.
|
|
58
58
|
*
|
|
59
|
-
* @param path
|
|
60
|
-
* @param options Optional render-facing metadata
|
|
59
|
+
* @param path Relative route path; omission or `undefined` uses `''`, preserving the `@Router(...)` prefix.
|
|
60
|
+
* @param options Optional render-facing metadata. Omission keeps the metadata's `options` property absent.
|
|
61
61
|
* @returns A method decorator that writes HTTP `GET` metadata plus React path metadata.
|
|
62
62
|
*/
|
|
63
|
-
export declare function Path(path
|
|
63
|
+
export declare function Path(path?: string, options?: ReactPathOptions): MethodDecoratorLike;
|
|
64
64
|
/**
|
|
65
65
|
* Reads React router marker metadata from a router class.
|
|
66
66
|
*
|
package/dist/decorators.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;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mB,CAgC/E;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,QAAQ,GAAG,mBAAmB,GAAG,SAAS,CAI7F;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,QAAQ,EACrB,WAAW,EAAE,mBAAmB,GAC/B,iBAAiB,GAAG,SAAS,CAK/B"}
|
package/dist/decorators.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { getStandardMetadataBag } from '@fluojs/core/internal';
|
|
2
|
-
import { Controller, Get } from '@fluojs/http';
|
|
2
|
+
import { Controller, Get } from '@fluojs/http/portable';
|
|
3
|
+
import { defineLegacyRuntimeRouteInspectionMetadata, defineStandardRuntimeRouteInspectionMetadata } from '@fluojs/runtime/internal';
|
|
3
4
|
const reactRouterMetadataKey = Symbol.for('fluo.react.router');
|
|
4
5
|
const reactPathMetadataKey = Symbol.for('fluo.react.path');
|
|
6
|
+
const reactPageInspectionMetadata = Object.freeze({
|
|
7
|
+
kind: 'react-page'
|
|
8
|
+
});
|
|
5
9
|
const legacyRouterMetadataStore = new WeakMap();
|
|
6
10
|
const legacyPathMetadataStore = new WeakMap();
|
|
7
11
|
|
|
@@ -150,21 +154,23 @@ export function Router(basePath = '') {
|
|
|
150
154
|
* `:param` placeholders only. The optional `options` value is metadata for future
|
|
151
155
|
* render integrations; it does not create a React-owned matcher or `routes: []` table.
|
|
152
156
|
*
|
|
153
|
-
* @param path
|
|
154
|
-
* @param options Optional render-facing metadata
|
|
157
|
+
* @param path Relative route path; omission or `undefined` uses `''`, preserving the `@Router(...)` prefix.
|
|
158
|
+
* @param options Optional render-facing metadata. Omission keeps the metadata's `options` property absent.
|
|
155
159
|
* @returns A method decorator that writes HTTP `GET` metadata plus React path metadata.
|
|
156
160
|
*/
|
|
157
|
-
export function Path(path, options) {
|
|
161
|
+
export function Path(path = '', options) {
|
|
158
162
|
const httpDecorator = Get(path);
|
|
159
163
|
const metadata = createReactPathMetadata(path, options);
|
|
160
164
|
const decorator = (valueOrTarget, contextOrPropertyKey, descriptor) => {
|
|
161
165
|
Reflect.apply(httpDecorator, undefined, [valueOrTarget, contextOrPropertyKey, descriptor]);
|
|
162
166
|
if (isStandardMethodDecoratorContext(contextOrPropertyKey)) {
|
|
163
167
|
defineStandardReactPathMetadata(contextOrPropertyKey.metadata, contextOrPropertyKey.name, metadata);
|
|
168
|
+
defineStandardRuntimeRouteInspectionMetadata(contextOrPropertyKey.metadata, contextOrPropertyKey.name, reactPageInspectionMetadata);
|
|
164
169
|
return;
|
|
165
170
|
}
|
|
166
171
|
if (isMetadataPropertyKey(contextOrPropertyKey)) {
|
|
167
172
|
defineLegacyReactPathMetadata(valueOrTarget, contextOrPropertyKey, metadata);
|
|
173
|
+
defineLegacyRuntimeRouteInspectionMetadata(valueOrTarget, contextOrPropertyKey, reactPageInspectionMetadata);
|
|
168
174
|
}
|
|
169
175
|
};
|
|
170
176
|
return decorator;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { FluoError } from '@fluojs/core';
|
|
2
|
+
import type { FrameworkRequest, RequestContext } from '@fluojs/http/portable';
|
|
3
|
+
/** Stable machine-readable phases for the React SSR request lifecycle. */
|
|
4
|
+
export declare const REACT_SSR_DIAGNOSTIC_PHASES: {
|
|
5
|
+
readonly httpPipeline: "http-pipeline";
|
|
6
|
+
readonly postShellRecoverable: "post-shell-recoverable";
|
|
7
|
+
readonly preCommitShell: "pre-commit-shell";
|
|
8
|
+
readonly requestAbort: "request-abort";
|
|
9
|
+
};
|
|
10
|
+
/** Stable machine-readable codes emitted by React SSR diagnostics. */
|
|
11
|
+
export declare const REACT_SSR_DIAGNOSTIC_CODES: {
|
|
12
|
+
readonly httpPipelineFailure: "react-ssr-http-pipeline-failure";
|
|
13
|
+
readonly missingPageRenderer: "react-ssr-missing-page-renderer";
|
|
14
|
+
readonly postShellRecoverableError: "react-ssr-post-shell-recoverable-error";
|
|
15
|
+
readonly preCommitShellFailure: "react-ssr-pre-commit-shell-failure";
|
|
16
|
+
readonly requestAbort: "react-ssr-request-abort";
|
|
17
|
+
};
|
|
18
|
+
/** Machine-readable React SSR lifecycle phase. */
|
|
19
|
+
export type ReactSsrDiagnosticPhase = (typeof REACT_SSR_DIAGNOSTIC_PHASES)[keyof typeof REACT_SSR_DIAGNOSTIC_PHASES];
|
|
20
|
+
/** Machine-readable React SSR diagnostic code. */
|
|
21
|
+
export type ReactSsrDiagnosticCode = (typeof REACT_SSR_DIAGNOSTIC_CODES)[keyof typeof REACT_SSR_DIAGNOSTIC_CODES];
|
|
22
|
+
/** Structured diagnostic emitted while a React page request is processed. */
|
|
23
|
+
export type ReactSsrDiagnostic = {
|
|
24
|
+
/** Stable machine-readable diagnostic code. */
|
|
25
|
+
readonly code: ReactSsrDiagnosticCode;
|
|
26
|
+
/** Original failure reported at this lifecycle boundary. */
|
|
27
|
+
readonly error: unknown;
|
|
28
|
+
/** Stable lifecycle phase associated with the failure. */
|
|
29
|
+
readonly phase: ReactSsrDiagnosticPhase;
|
|
30
|
+
/** Active framework request. */
|
|
31
|
+
readonly request: FrameworkRequest;
|
|
32
|
+
/** Adapter-provided request id, when available. */
|
|
33
|
+
readonly requestId?: string;
|
|
34
|
+
};
|
|
35
|
+
/** Application callback for observing structured React SSR diagnostics. */
|
|
36
|
+
export type ReactSsrDiagnosticHandler = (diagnostic: ReactSsrDiagnostic) => void;
|
|
37
|
+
/** Options for creating a typed React SSR diagnostic error. */
|
|
38
|
+
export type ReactSsrDiagnosticErrorOptions = {
|
|
39
|
+
/** Stable machine-readable diagnostic code. */
|
|
40
|
+
readonly code: ReactSsrDiagnosticCode;
|
|
41
|
+
/** Original failure, when one exists. */
|
|
42
|
+
readonly cause?: unknown;
|
|
43
|
+
/** Stable lifecycle phase associated with the failure. */
|
|
44
|
+
readonly phase: ReactSsrDiagnosticPhase;
|
|
45
|
+
};
|
|
46
|
+
/** Typed React SSR failure carrying stable code and phase metadata. */
|
|
47
|
+
export declare class ReactSsrDiagnosticError extends FluoError {
|
|
48
|
+
/** Stable machine-readable diagnostic code for this failure. */
|
|
49
|
+
readonly code: ReactSsrDiagnosticCode;
|
|
50
|
+
/** Stable lifecycle phase associated with this failure. */
|
|
51
|
+
readonly phase: ReactSsrDiagnosticPhase;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a typed React SSR lifecycle failure.
|
|
54
|
+
*
|
|
55
|
+
* @param message Actionable human-readable failure description.
|
|
56
|
+
* @param options Stable code, phase, and optional original failure.
|
|
57
|
+
*/
|
|
58
|
+
constructor(message: string, options: ReactSsrDiagnosticErrorOptions);
|
|
59
|
+
}
|
|
60
|
+
type ReactSsrDiagnosticMarker = {
|
|
61
|
+
readonly code: ReactSsrDiagnosticCode;
|
|
62
|
+
readonly error: unknown;
|
|
63
|
+
readonly phase: ReactSsrDiagnosticPhase;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Stores the module diagnostic handler on the active request context.
|
|
67
|
+
*
|
|
68
|
+
* @param context Request context that owns the render lifecycle.
|
|
69
|
+
* @param handler Module diagnostic handler, when configured.
|
|
70
|
+
*/
|
|
71
|
+
export declare function bindReactSsrDiagnosticHandler(context: RequestContext, handler: ReactSsrDiagnosticHandler | undefined): void;
|
|
72
|
+
/**
|
|
73
|
+
* Reads the module diagnostic handler from a render request context.
|
|
74
|
+
*
|
|
75
|
+
* @param context Render context that may carry request metadata.
|
|
76
|
+
* @returns The request-local diagnostic handler, when one exists.
|
|
77
|
+
*/
|
|
78
|
+
export declare function readReactSsrDiagnosticHandler(context: object): ReactSsrDiagnosticHandler | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Associates a diagnostic classification with an error without changing its identity.
|
|
81
|
+
*
|
|
82
|
+
* @param context Render context that owns the request-local marker.
|
|
83
|
+
* @param error Original lifecycle failure.
|
|
84
|
+
* @param marker Stable code and phase retained for the request error boundary.
|
|
85
|
+
*/
|
|
86
|
+
export declare function markReactSsrDiagnostic(context: object, error: unknown, marker: ReactSsrDiagnosticMarker): void;
|
|
87
|
+
/**
|
|
88
|
+
* Reads and consumes the diagnostic classification associated with an error.
|
|
89
|
+
*
|
|
90
|
+
* @param context Request context that owns the request-local marker.
|
|
91
|
+
* @param error Original lifecycle failure.
|
|
92
|
+
* @returns The retained classification, when one exists.
|
|
93
|
+
*/
|
|
94
|
+
export declare function readReactSsrDiagnosticMarker(context: object, error: unknown): ReactSsrDiagnosticMarker | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Creates a structured diagnostic snapshot for an SSR lifecycle event.
|
|
97
|
+
*
|
|
98
|
+
* @param diagnostic Diagnostic values observed at the active request boundary.
|
|
99
|
+
* @returns A request-safe diagnostic object.
|
|
100
|
+
*/
|
|
101
|
+
export declare function createReactSsrDiagnostic(diagnostic: ReactSsrDiagnostic): ReactSsrDiagnostic;
|
|
102
|
+
/**
|
|
103
|
+
* Reports an SSR diagnostic without allowing observer failures to replace the request outcome.
|
|
104
|
+
*
|
|
105
|
+
* @param handler Application diagnostic observer, when configured.
|
|
106
|
+
* @param diagnostic Structured lifecycle event to report.
|
|
107
|
+
*/
|
|
108
|
+
export declare function reportReactSsrDiagnostic(handler: ReactSsrDiagnosticHandler | undefined, diagnostic: ReactSsrDiagnostic): void;
|
|
109
|
+
export {};
|
|
110
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE9E,0EAA0E;AAC1E,eAAO,MAAM,2BAA2B;;;;;CAK9B,CAAC;AAEX,sEAAsE;AACtE,eAAO,MAAM,0BAA0B;;;;;;CAM7B,CAAC;AAEX,kDAAkD;AAClD,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,2BA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B,QAAQ,CAAC,KAAK,EAAE,uBAAuB,CAAC;CACzC,CAAC;AA4BF;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,yBAAyB,GAAG,SAAS,GAC7C,IAAI,CAON;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,MAAM,GACd,yBAAyB,GAAG,SAAS,CAYvC;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,wBAAwB,GAC/B,IAAI,CAUN;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,OAAO,GACb,wBAAwB,GAAG,SAAS,CAYtC;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,kBAAkB,GAC7B,kBAAkB,CAQpB;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,yBAAyB,GAAG,SAAS,EAC9C,UAAU,EAAE,kBAAkB,GAC7B,IAAI,CAYN"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { FluoError } from '@fluojs/core';
|
|
2
|
+
/** Stable machine-readable phases for the React SSR request lifecycle. */
|
|
3
|
+
export const REACT_SSR_DIAGNOSTIC_PHASES = {
|
|
4
|
+
httpPipeline: 'http-pipeline',
|
|
5
|
+
postShellRecoverable: 'post-shell-recoverable',
|
|
6
|
+
preCommitShell: 'pre-commit-shell',
|
|
7
|
+
requestAbort: 'request-abort'
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/** Stable machine-readable codes emitted by React SSR diagnostics. */
|
|
11
|
+
export const REACT_SSR_DIAGNOSTIC_CODES = {
|
|
12
|
+
httpPipelineFailure: 'react-ssr-http-pipeline-failure',
|
|
13
|
+
missingPageRenderer: 'react-ssr-missing-page-renderer',
|
|
14
|
+
postShellRecoverableError: 'react-ssr-post-shell-recoverable-error',
|
|
15
|
+
preCommitShellFailure: 'react-ssr-pre-commit-shell-failure',
|
|
16
|
+
requestAbort: 'react-ssr-request-abort'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** Machine-readable React SSR lifecycle phase. */
|
|
20
|
+
|
|
21
|
+
/** Machine-readable React SSR diagnostic code. */
|
|
22
|
+
|
|
23
|
+
/** Structured diagnostic emitted while a React page request is processed. */
|
|
24
|
+
|
|
25
|
+
/** Application callback for observing structured React SSR diagnostics. */
|
|
26
|
+
|
|
27
|
+
/** Options for creating a typed React SSR diagnostic error. */
|
|
28
|
+
|
|
29
|
+
/** Typed React SSR failure carrying stable code and phase metadata. */
|
|
30
|
+
export class ReactSsrDiagnosticError extends FluoError {
|
|
31
|
+
/** Stable machine-readable diagnostic code for this failure. */
|
|
32
|
+
code;
|
|
33
|
+
/** Stable lifecycle phase associated with this failure. */
|
|
34
|
+
phase;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Creates a typed React SSR lifecycle failure.
|
|
38
|
+
*
|
|
39
|
+
* @param message Actionable human-readable failure description.
|
|
40
|
+
* @param options Stable code, phase, and optional original failure.
|
|
41
|
+
*/
|
|
42
|
+
constructor(message, options) {
|
|
43
|
+
super(message, {
|
|
44
|
+
code: options.code,
|
|
45
|
+
...(options.cause === undefined ? {} : {
|
|
46
|
+
cause: options.cause
|
|
47
|
+
}),
|
|
48
|
+
meta: {
|
|
49
|
+
phase: options.phase
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
this.code = options.code;
|
|
53
|
+
this.phase = options.phase;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const diagnosticHandlerKey = Symbol.for('fluo.react.ssrDiagnosticHandler');
|
|
57
|
+
const diagnosticMarkerKey = Symbol.for('fluo.react.ssrDiagnosticMarker');
|
|
58
|
+
class ReactSsrDiagnosticMarkerStore {
|
|
59
|
+
markers = new WeakMap();
|
|
60
|
+
set(error, marker) {
|
|
61
|
+
this.markers.set(error, marker);
|
|
62
|
+
}
|
|
63
|
+
take(error) {
|
|
64
|
+
const marker = this.markers.get(error);
|
|
65
|
+
this.markers.delete(error);
|
|
66
|
+
return marker;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function isDiagnosticMarkerKey(value) {
|
|
70
|
+
return typeof value === 'object' && value !== null || typeof value === 'function';
|
|
71
|
+
}
|
|
72
|
+
function readReactSsrDiagnosticMetadata(context) {
|
|
73
|
+
const metadata = Reflect.get(context, 'metadata');
|
|
74
|
+
return typeof metadata === 'object' && metadata !== null ? metadata : undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Stores the module diagnostic handler on the active request context.
|
|
79
|
+
*
|
|
80
|
+
* @param context Request context that owns the render lifecycle.
|
|
81
|
+
* @param handler Module diagnostic handler, when configured.
|
|
82
|
+
*/
|
|
83
|
+
export function bindReactSsrDiagnosticHandler(context, handler) {
|
|
84
|
+
if (handler === undefined) {
|
|
85
|
+
delete context.metadata[diagnosticHandlerKey];
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
context.metadata[diagnosticHandlerKey] = handler;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Reads the module diagnostic handler from a render request context.
|
|
93
|
+
*
|
|
94
|
+
* @param context Render context that may carry request metadata.
|
|
95
|
+
* @returns The request-local diagnostic handler, when one exists.
|
|
96
|
+
*/
|
|
97
|
+
export function readReactSsrDiagnosticHandler(context) {
|
|
98
|
+
const metadata = readReactSsrDiagnosticMetadata(context);
|
|
99
|
+
if (metadata === undefined) {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
const handler = Reflect.get(metadata, diagnosticHandlerKey);
|
|
103
|
+
if (typeof handler !== 'function') {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
return diagnostic => Reflect.apply(handler, undefined, [diagnostic]);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Associates a diagnostic classification with an error without changing its identity.
|
|
111
|
+
*
|
|
112
|
+
* @param context Render context that owns the request-local marker.
|
|
113
|
+
* @param error Original lifecycle failure.
|
|
114
|
+
* @param marker Stable code and phase retained for the request error boundary.
|
|
115
|
+
*/
|
|
116
|
+
export function markReactSsrDiagnostic(context, error, marker) {
|
|
117
|
+
const metadata = readReactSsrDiagnosticMetadata(context);
|
|
118
|
+
if (metadata !== undefined && isDiagnosticMarkerKey(error)) {
|
|
119
|
+
const state = Reflect.get(metadata, diagnosticMarkerKey);
|
|
120
|
+
const store = state instanceof ReactSsrDiagnosticMarkerStore ? state : new ReactSsrDiagnosticMarkerStore();
|
|
121
|
+
store.set(error, marker);
|
|
122
|
+
Reflect.set(metadata, diagnosticMarkerKey, store);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Reads and consumes the diagnostic classification associated with an error.
|
|
128
|
+
*
|
|
129
|
+
* @param context Request context that owns the request-local marker.
|
|
130
|
+
* @param error Original lifecycle failure.
|
|
131
|
+
* @returns The retained classification, when one exists.
|
|
132
|
+
*/
|
|
133
|
+
export function readReactSsrDiagnosticMarker(context, error) {
|
|
134
|
+
const metadata = readReactSsrDiagnosticMetadata(context);
|
|
135
|
+
if (metadata === undefined || !isDiagnosticMarkerKey(error)) {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
const state = Reflect.get(metadata, diagnosticMarkerKey);
|
|
139
|
+
if (!(state instanceof ReactSsrDiagnosticMarkerStore)) {
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
return state.take(error);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Creates a structured diagnostic snapshot for an SSR lifecycle event.
|
|
147
|
+
*
|
|
148
|
+
* @param diagnostic Diagnostic values observed at the active request boundary.
|
|
149
|
+
* @returns A request-safe diagnostic object.
|
|
150
|
+
*/
|
|
151
|
+
export function createReactSsrDiagnostic(diagnostic) {
|
|
152
|
+
return {
|
|
153
|
+
code: diagnostic.code,
|
|
154
|
+
error: diagnostic.error,
|
|
155
|
+
phase: diagnostic.phase,
|
|
156
|
+
request: diagnostic.request,
|
|
157
|
+
...(diagnostic.requestId === undefined ? {} : {
|
|
158
|
+
requestId: diagnostic.requestId
|
|
159
|
+
})
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Reports an SSR diagnostic without allowing observer failures to replace the request outcome.
|
|
165
|
+
*
|
|
166
|
+
* @param handler Application diagnostic observer, when configured.
|
|
167
|
+
* @param diagnostic Structured lifecycle event to report.
|
|
168
|
+
*/
|
|
169
|
+
export function reportReactSsrDiagnostic(handler, diagnostic) {
|
|
170
|
+
if (handler === undefined) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
handler(diagnostic);
|
|
175
|
+
} catch (error) {
|
|
176
|
+
if (error instanceof Error) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { MaybePromise } from '@fluojs/core';
|
|
2
|
+
import type { HtmlErrorRepresentationProvider, HttpErrorRepresentationContext } from '@fluojs/http/portable';
|
|
3
|
+
import { type ReactReadableStreamRenderer } from './render.js';
|
|
4
|
+
import type { ReactServerEntry } from './server-entry.js';
|
|
5
|
+
/** Application callback that creates one React error document after HTTP classifies the outcome. */
|
|
6
|
+
export type ReactErrorDocumentRenderer = (context: HttpErrorRepresentationContext) => MaybePromise<ReactServerEntry>;
|
|
7
|
+
/** Options for adapting an application React document renderer to the HTTP HTML provider seam. */
|
|
8
|
+
export type ReactErrorRepresentationProviderOptions = {
|
|
9
|
+
/** Optional route/application constraint evaluated by the HTTP dispatcher before rendering. */
|
|
10
|
+
readonly canRender?: HtmlErrorRepresentationProvider['canRender'];
|
|
11
|
+
/** Creates the complete React document for the already-classified HTTP outcome. */
|
|
12
|
+
readonly renderDocument: ReactErrorDocumentRenderer;
|
|
13
|
+
/** Optional Web Streams renderer override used by custom integrations and tests. */
|
|
14
|
+
readonly renderToReadableStream?: ReactReadableStreamRenderer;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Adapts an application-owned React document renderer to HTTP error representation negotiation.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Rendering is fully buffered before the HTTP dispatcher applies status, headers,
|
|
21
|
+
* or commit. `ReactServerEntry.status` and `ReactServerEntry.headers` are ignored,
|
|
22
|
+
* and this helper never performs matching or consults page render policies.
|
|
23
|
+
*
|
|
24
|
+
* @param options Application document renderer and optional availability/rendering hooks.
|
|
25
|
+
* @returns An HTTP HTML provider registered through `errorRepresentation.html`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createReactErrorRepresentationProvider(options: ReactErrorRepresentationProviderOptions): HtmlErrorRepresentationProvider;
|
|
28
|
+
//# sourceMappingURL=error-representation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-representation.d.ts","sourceRoot":"","sources":["../src/error-representation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EACV,+BAA+B,EAC/B,8BAA8B,EAC/B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,KAAK,2BAA2B,EAEjC,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,oGAAoG;AACpG,MAAM,MAAM,0BAA0B,GAAG,CACvC,OAAO,EAAE,8BAA8B,KACpC,YAAY,CAAC,gBAAgB,CAAC,CAAC;AAEpC,kGAAkG;AAClG,MAAM,MAAM,uCAAuC,GAAG;IACpD,+FAA+F;IAC/F,QAAQ,CAAC,SAAS,CAAC,EAAE,+BAA+B,CAAC,WAAW,CAAC,CAAC;IAClE,mFAAmF;IACnF,QAAQ,CAAC,cAAc,EAAE,0BAA0B,CAAC;IACpD,oFAAoF;IACpF,QAAQ,CAAC,sBAAsB,CAAC,EAAE,2BAA2B,CAAC;CAC/D,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,sCAAsC,CACpD,OAAO,EAAE,uCAAuC,GAC/C,+BAA+B,CAUjC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { renderReactServerEntryToBytes } from './render.js';
|
|
2
|
+
|
|
3
|
+
/** Application callback that creates one React error document after HTTP classifies the outcome. */
|
|
4
|
+
|
|
5
|
+
/** Options for adapting an application React document renderer to the HTTP HTML provider seam. */
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Adapts an application-owned React document renderer to HTTP error representation negotiation.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Rendering is fully buffered before the HTTP dispatcher applies status, headers,
|
|
12
|
+
* or commit. `ReactServerEntry.status` and `ReactServerEntry.headers` are ignored,
|
|
13
|
+
* and this helper never performs matching or consults page render policies.
|
|
14
|
+
*
|
|
15
|
+
* @param options Application document renderer and optional availability/rendering hooks.
|
|
16
|
+
* @returns An HTTP HTML provider registered through `errorRepresentation.html`.
|
|
17
|
+
*/
|
|
18
|
+
export function createReactErrorRepresentationProvider(options) {
|
|
19
|
+
return {
|
|
20
|
+
...(options.canRender === undefined ? {} : {
|
|
21
|
+
canRender: options.canRender
|
|
22
|
+
}),
|
|
23
|
+
async render(context) {
|
|
24
|
+
const entry = await options.renderDocument(context);
|
|
25
|
+
return options.renderToReadableStream === undefined ? renderReactServerEntryToBytes(entry, context) : renderReactServerEntryToBytes(entry, context, options.renderToReadableStream);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc-flight-response.d.ts","sourceRoot":"","sources":["../../src/experimental/rsc-flight-response.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rsc-flight-response.d.ts","sourceRoot":"","sources":["../../src/experimental/rsc-flight-response.ts"],"names":[],"mappings":"AAUA,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EAExB,KAAK,0BAA0B,EAChC,MAAM,gBAAgB,CAAC;AAqExB;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,GAAE,0BAA+B,GACvC,mBAAmB,CAWrB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { registerFrameworkResponseWriter } from '@fluojs/http/internal';
|
|
1
2
|
import { collectReadableStream, pipeReadableStream, throwIfReactRequestAborted } from '../render-stream.js';
|
|
2
3
|
import { REACT_RSC_FLIGHT_CONTENT_TYPE } from './rsc-types.js';
|
|
3
|
-
const responseWriterKey = Symbol.for('fluo.http.responseWriter');
|
|
4
4
|
function cloneHeaders(headers) {
|
|
5
5
|
const snapshot = {};
|
|
6
6
|
for (const [name, value] of Object.entries(headers ?? {})) {
|
|
@@ -68,9 +68,5 @@ export function createReactFlightResponse(payload, options = {}) {
|
|
|
68
68
|
status: options.status
|
|
69
69
|
} : {})
|
|
70
70
|
};
|
|
71
|
-
|
|
72
|
-
enumerable: false,
|
|
73
|
-
value: context => writeReactFlightResponse(entry, context)
|
|
74
|
-
});
|
|
75
|
-
return entry;
|
|
71
|
+
return registerFrameworkResponseWriter(entry, context => writeReactFlightResponse(entry, context));
|
|
76
72
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HttpException } from '@fluojs/http';
|
|
1
|
+
import { HttpException } from '@fluojs/http/portable';
|
|
2
2
|
import { createReactServerFunctionRegistryConfiguration } from './server-functions-configuration.js';
|
|
3
3
|
import { ReactServerFunctionConfigurationError } from './server-functions-errors.js';
|
|
4
4
|
import { createReactServerFunctionReferenceSigner } from './server-functions-reference.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MaybePromise } from '@fluojs/core';
|
|
2
|
-
import type { RequestContext } from '@fluojs/http';
|
|
2
|
+
import type { RequestContext } from '@fluojs/http/portable';
|
|
3
3
|
/** Header required on experimental Server Function POST requests to force a non-simple request. */
|
|
4
4
|
export declare const REACT_SERVER_FUNCTION_REQUEST_HEADER = "x-fluo-react-action";
|
|
5
5
|
/** Stable error codes emitted by the experimental Server Function transport boundary. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-functions-types.d.ts","sourceRoot":"","sources":["../../src/experimental/server-functions-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"server-functions-types.d.ts","sourceRoot":"","sources":["../../src/experimental/server-functions-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,mGAAmG;AACnG,eAAO,MAAM,oCAAoC,wBAAwB,CAAC;AAE1E,yFAAyF;AACzF,eAAO,MAAM,iCAAiC;;;;;;;;;;CAUpC,CAAC;AAEX,mFAAmF;AACnF,MAAM,MAAM,4BAA4B,GACtC,CAAC,OAAO,iCAAiC,CAAC,CAAC,MAAM,OAAO,iCAAiC,CAAC,CAAC;AAE7F,8EAA8E;AAC9E,MAAM,MAAM,wBAAwB,GAChC,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,wBAAwB,EAAE,GACnC;IAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,wBAAwB,CAAA;CAAE,CAAC;AAEzD,8EAA8E;AAC9E,MAAM,MAAM,4BAA4B,GAAG;IACzC,4EAA4E;IAC5E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACx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AE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE/F,+EAA+E;AAC/E,MAAM,MAAM,gCAAgC,GAAG;IAC7C,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,EAAE,wBAAwB,CAAC;IACzC,uEAAuE;IACvE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,+DAA+D;IAC/D,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IACxC,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,4BAA4B,CAAC;CAClD,CAAC;AAEF,oGAAoG;AACpG,MAAM,MAAM,yBAAyB,GAAG,CACtC,GAAG,IAAI,EAAE,SAAS,wBAAwB,EAAE,KACzC,OAAO,CAAC,wBAAwB,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
export { Path, Router, getReactPathMetadata, getReactRouterMetadata, } from './decorators.js';
|
|
2
1
|
export type { ReactPathMetadata, ReactPathOptions, ReactRouterMetadata } from './decorators.js';
|
|
3
|
-
export {
|
|
2
|
+
export { getReactPathMetadata, getReactRouterMetadata, Path, Router, } from './decorators.js';
|
|
3
|
+
export type { ReactSsrDiagnostic, ReactSsrDiagnosticCode, ReactSsrDiagnosticErrorOptions, ReactSsrDiagnosticHandler, ReactSsrDiagnosticPhase, } from './diagnostics.js';
|
|
4
|
+
export { REACT_SSR_DIAGNOSTIC_CODES, REACT_SSR_DIAGNOSTIC_PHASES, ReactSsrDiagnosticError, } from './diagnostics.js';
|
|
5
|
+
export type { ReactErrorDocumentRenderer, ReactErrorRepresentationProviderOptions, } from './error-representation.js';
|
|
6
|
+
export { createReactErrorRepresentationProvider } from './error-representation.js';
|
|
4
7
|
export type { ReactModuleOptions } from './module.js';
|
|
8
|
+
export { ReactModule } from './module.js';
|
|
9
|
+
export type { ReactPageCatalogEntry } from './page-catalog.js';
|
|
10
|
+
export { createReactPageCatalog } from './page-catalog.js';
|
|
11
|
+
export type { ReactPageLink, ReactPageMeta, ReactPageMetadata, ReactPageMetadataContext, ReactPageMetadataFactory, } from './page-metadata.js';
|
|
12
|
+
export { createReactPageMetadataElements, PageMetadata, resolveReactPageMetadata, } from './page-metadata.js';
|
|
13
|
+
export type { ReactPageRenderer } from './page-renderer.js';
|
|
14
|
+
export { REACT_PAGE_RENDERER } from './page-renderer.js';
|
|
15
|
+
export type { ReactReadableStream, ReactReadableStreamRenderer, ReactReadableStreamRenderOptions, ReactRenderContext, RenderReactResponseOptions, } from './render.js';
|
|
5
16
|
export { renderReactResponse } from './render.js';
|
|
6
|
-
export type {
|
|
7
|
-
export {
|
|
17
|
+
export type { ReactPageLayout, ReactPageLayoutProps, ReactRenderPolicies, ReactRenderPolicyDiagnosticCode, ReactSuspenseFallback, ReactSuspenseFallbackProps, } from './render-policy.js';
|
|
18
|
+
export { getReactRenderPolicies, PageLayout, REACT_RENDER_POLICY_DIAGNOSTIC_CODES, ReactRenderPolicyConfigurationError, SuspenseFallback, } from './render-policy.js';
|
|
8
19
|
export type { ReactAssetMap, ReactBootstrapAsset, ReactBootstrapScriptDescriptor, ReactRecoverableErrorContext, ReactRecoverableErrorHandler, ReactServerEntry, ReactServerEntryHeaders, ReactServerEntryOptions, } from './server-entry.js';
|
|
20
|
+
export { createReactServerEntry } from './server-entry.js';
|
|
9
21
|
export type { ReactScaffoldPhase } from './types.js';
|
|
10
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAA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ACtB,UAAU,EACV,oCAAoC,EACpC,mCAAmC,EACnC,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,8BAA8B,EAC9B,4BAA4B,EAC5B,4BAA4B,EAC5B,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getReactPathMetadata, getReactRouterMetadata, Path, Router } from './decorators.js';
|
|
2
|
+
export { REACT_SSR_DIAGNOSTIC_CODES, REACT_SSR_DIAGNOSTIC_PHASES, ReactSsrDiagnosticError } from './diagnostics.js';
|
|
3
|
+
export { createReactErrorRepresentationProvider } from './error-representation.js';
|
|
2
4
|
export { ReactModule } from './module.js';
|
|
5
|
+
export { createReactPageCatalog } from './page-catalog.js';
|
|
6
|
+
export { createReactPageMetadataElements, PageMetadata, resolveReactPageMetadata } from './page-metadata.js';
|
|
7
|
+
export { REACT_PAGE_RENDERER } from './page-renderer.js';
|
|
3
8
|
export { renderReactResponse } from './render.js';
|
|
9
|
+
export { getReactRenderPolicies, PageLayout, REACT_RENDER_POLICY_DIAGNOSTIC_CODES, ReactRenderPolicyConfigurationError, SuspenseFallback } from './render-policy.js';
|
|
4
10
|
export { createReactServerEntry } from './server-entry.js';
|
package/dist/module.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type Constructor, type Token } from '@fluojs/core';
|
|
2
2
|
import type { Provider } from '@fluojs/di';
|
|
3
|
-
import type { MiddlewareLike } from '@fluojs/http';
|
|
4
|
-
import { type ModuleType } from '@fluojs/runtime';
|
|
3
|
+
import type { MiddlewareLike } from '@fluojs/http/portable';
|
|
4
|
+
import { type ModuleType } from '@fluojs/runtime/internal';
|
|
5
|
+
import type { ReactSsrDiagnosticHandler } from './diagnostics.js';
|
|
6
|
+
import { type ReactPageRenderer } from './page-renderer.js';
|
|
5
7
|
/**
|
|
6
8
|
* Options for registering React routers through the fluo module graph.
|
|
7
9
|
*/
|
|
@@ -14,8 +16,12 @@ export type ReactModuleOptions = {
|
|
|
14
16
|
readonly imports?: readonly ModuleType[];
|
|
15
17
|
/** Module-level middleware applied by the existing HTTP dispatcher to this module's routes. */
|
|
16
18
|
readonly middleware?: readonly MiddlewareLike[];
|
|
19
|
+
/** Application callback for stable phase-aware React SSR diagnostics. */
|
|
20
|
+
readonly onDiagnostic?: ReactSsrDiagnosticHandler;
|
|
17
21
|
/** Providers local to this dynamic React module and visible to registered routers. */
|
|
18
22
|
readonly providers?: readonly Provider[];
|
|
23
|
+
/** Application callback that composes page elements into existing React server entries. */
|
|
24
|
+
readonly renderPage?: ReactPageRenderer;
|
|
19
25
|
};
|
|
20
26
|
/**
|
|
21
27
|
* Runtime-neutral module facade for registering React routers in fluo applications.
|
package/dist/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAU,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAuC,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAChG,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAuB,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAIjF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,8FAA8F;IAC9F,QAAQ,CAAC,WAAW,EAAE,SAAS,WAAW,EAAE,CAAC;IAC7C,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,KAAK,EAAE,CAAC;IACpC,oFAAoF;IACpF,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACzC,+FAA+F;IAC/F,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAChD,yEAAyE;IACzE,QAAQ,CAAC,YAAY,CAAC,EAAE,yBAAyB,CAAC;IAClD,sFAAsF;IACtF,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;IACzC,2FAA2F;IAC3F,QAAQ,CAAC,UAAU,CAAC,EAAE,iBAAiB,CAAC;CACzC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,qBACa,WAAW;IACtB;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,kBAAkB,GAAG,UAAU;CA2CxD"}
|
package/dist/module.js
CHANGED
|
@@ -5,7 +5,10 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
5
5
|
function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
|
|
6
6
|
function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
|
|
7
7
|
import { Module } from '@fluojs/core';
|
|
8
|
-
import { defineModule } from '@fluojs/runtime';
|
|
8
|
+
import { defineModule } from '@fluojs/runtime/internal';
|
|
9
|
+
import { REACT_PAGE_RENDERER } from './page-renderer.js';
|
|
10
|
+
import { createReactPageResultMiddleware } from './page-result.js';
|
|
11
|
+
import { validateReactRenderPolicyControllers } from './render-policy.js';
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* Options for registering React routers through the fluo module graph.
|
|
@@ -34,19 +37,39 @@ class ReactModule {
|
|
|
34
37
|
*/
|
|
35
38
|
static forRoot(options) {
|
|
36
39
|
class ReactRootModule extends _ReactModule {}
|
|
40
|
+
const pageRendererProvider = options.renderPage === undefined ? undefined : {
|
|
41
|
+
provide: REACT_PAGE_RENDERER,
|
|
42
|
+
useValue: options.renderPage
|
|
43
|
+
};
|
|
44
|
+
const renderPolicyValidatorProvider = {
|
|
45
|
+
provide: Symbol('fluo.react.render-policy-validator'),
|
|
46
|
+
useValue: {
|
|
47
|
+
onModuleInit() {
|
|
48
|
+
validateReactRenderPolicyControllers(options.controllers, options.renderPage !== undefined);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const exports = [...(options.exports ?? []), ...(pageRendererProvider === undefined ? [] : [REACT_PAGE_RENDERER])];
|
|
53
|
+
const providers = [...(options.providers ?? []), renderPolicyValidatorProvider, ...(pageRendererProvider === undefined ? [] : [pageRendererProvider])];
|
|
54
|
+
const middleware = [createReactPageResultMiddleware({
|
|
55
|
+
...(options.onDiagnostic === undefined ? {} : {
|
|
56
|
+
onDiagnostic: options.onDiagnostic
|
|
57
|
+
}),
|
|
58
|
+
...(options.renderPage === undefined ? {} : {
|
|
59
|
+
renderPage: options.renderPage
|
|
60
|
+
})
|
|
61
|
+
}), ...(options.middleware ?? [])];
|
|
37
62
|
const definition = {
|
|
38
63
|
controllers: [...options.controllers],
|
|
39
|
-
...(
|
|
40
|
-
exports
|
|
64
|
+
...(exports.length > 0 ? {
|
|
65
|
+
exports
|
|
41
66
|
} : {}),
|
|
42
67
|
...(options.imports ? {
|
|
43
68
|
imports: [...options.imports]
|
|
44
69
|
} : {}),
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
...(options.providers ? {
|
|
49
|
-
providers: [...options.providers]
|
|
70
|
+
middleware,
|
|
71
|
+
...(providers.length > 0 ? {
|
|
72
|
+
providers
|
|
50
73
|
} : {})
|
|
51
74
|
};
|
|
52
75
|
return defineModule(ReactRootModule, definition);
|