@coherent.js/integrations 1.0.0-rc.1
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/LICENSE +21 -0
- package/README.md +37 -0
- package/package.json +99 -0
- package/src/astro/index.js +88 -0
- package/src/express/coherent-express.js +160 -0
- package/src/express/index.js +36 -0
- package/src/fastify/coherent-fastify.js +125 -0
- package/src/fastify/index.js +13 -0
- package/src/koa/coherent-koa.js +124 -0
- package/src/koa/index.js +19 -0
- package/src/nextjs/coherent-nextjs.js +230 -0
- package/src/nextjs/index.js +21 -0
- package/src/remix/index.js +86 -0
- package/src/sveltekit/index.js +121 -0
- package/types/express/index.d.ts +134 -0
- package/types/fastify/index.d.ts +121 -0
- package/types/nextjs/index.d.ts +114 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Type definitions for Coherent.js Express.js Integration
|
|
2
|
+
|
|
3
|
+
import { Request, Response, NextFunction, Application } from 'express';
|
|
4
|
+
import type { CoherentNode } from '@coherent.js/core';
|
|
5
|
+
|
|
6
|
+
export interface CoherentMiddlewareOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Enable performance monitoring for rendered components
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
enablePerformanceMonitoring?: boolean;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* HTML template to wrap rendered components
|
|
15
|
+
* @default '<!DOCTYPE html><html><body>{{content}}</body></html>'
|
|
16
|
+
*/
|
|
17
|
+
template?: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Enable server-side rendering
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
23
|
+
enableSSR?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface CoherentHandlerOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Enable performance monitoring for rendered components
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
enablePerformanceMonitoring?: boolean;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* HTML template to wrap rendered components
|
|
35
|
+
* @default '<!DOCTYPE html><html><body>{{content}}</body></html>'
|
|
36
|
+
*/
|
|
37
|
+
template?: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Enable streaming rendering for large components
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
enableStreaming?: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface SetupCoherentExpressOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Use Coherent.js middleware for all routes
|
|
49
|
+
* @default true
|
|
50
|
+
*/
|
|
51
|
+
useMiddleware?: boolean;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Use Coherent.js view engine
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
useEngine?: boolean;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Name of the view engine
|
|
61
|
+
* @default 'coherent'
|
|
62
|
+
*/
|
|
63
|
+
engineName?: string;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Enable performance monitoring
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
69
|
+
enablePerformanceMonitoring?: boolean;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Static file directory for client-side assets
|
|
73
|
+
* @default 'public'
|
|
74
|
+
*/
|
|
75
|
+
staticDir?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Coherent.js Express middleware
|
|
80
|
+
* Adds Coherent.js rendering capabilities to Express
|
|
81
|
+
* @param options Configuration options
|
|
82
|
+
* @returns Express middleware function
|
|
83
|
+
*/
|
|
84
|
+
export function coherentMiddleware(options?: CoherentMiddlewareOptions): (
|
|
85
|
+
req: Request,
|
|
86
|
+
res: Response,
|
|
87
|
+
next: NextFunction
|
|
88
|
+
) => void;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Create an Express route handler for Coherent.js components
|
|
92
|
+
* @param componentFactory Function that returns a Coherent component
|
|
93
|
+
* @param options Configuration options
|
|
94
|
+
* @returns Express route handler
|
|
95
|
+
*/
|
|
96
|
+
export function createCoherentHandler(
|
|
97
|
+
componentFactory: (req: Request, res: Response, next: NextFunction) => CoherentNode | Promise<CoherentNode>,
|
|
98
|
+
options?: CoherentHandlerOptions
|
|
99
|
+
): (req: Request, res: Response, next: NextFunction) => void;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Enhanced Express engine for Coherent.js views
|
|
103
|
+
* @param filePath Path to the view file
|
|
104
|
+
* @param options Rendering options
|
|
105
|
+
* @param callback Callback function
|
|
106
|
+
*/
|
|
107
|
+
export function enhancedExpressEngine(
|
|
108
|
+
filePath: string,
|
|
109
|
+
options: any,
|
|
110
|
+
callback: (err: Error | null, html?: string) => void
|
|
111
|
+
): void;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Setup Coherent.js with Express app
|
|
115
|
+
* Configures middleware, view engine, and static files
|
|
116
|
+
* @param app Express application instance
|
|
117
|
+
* @param options Configuration options
|
|
118
|
+
*/
|
|
119
|
+
export function setupCoherent(
|
|
120
|
+
app: Application,
|
|
121
|
+
options?: SetupCoherentExpressOptions
|
|
122
|
+
): void;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Default export with all utilities
|
|
126
|
+
*/
|
|
127
|
+
declare const coherentExpress: {
|
|
128
|
+
coherentMiddleware: typeof coherentMiddleware;
|
|
129
|
+
createCoherentHandler: typeof createCoherentHandler;
|
|
130
|
+
enhancedExpressEngine: typeof enhancedExpressEngine;
|
|
131
|
+
setupCoherent: typeof setupCoherent;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export default coherentExpress;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// Type definitions for Coherent.js Fastify Integration
|
|
2
|
+
//
|
|
3
|
+
// Migrated from packages/fastify/src/coherent-fastify.d.ts during
|
|
4
|
+
// Wave 2c (integrations consolidation). Declarations are aligned with the
|
|
5
|
+
// runtime exports of ../../src/fastify/coherent-fastify.js.
|
|
6
|
+
|
|
7
|
+
import { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';
|
|
8
|
+
import type { CoherentNode } from '@coherent.js/core';
|
|
9
|
+
|
|
10
|
+
export interface CoherentFastifyOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Enable performance monitoring for rendered components
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
enablePerformanceMonitoring?: boolean;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* HTML template to wrap rendered components
|
|
19
|
+
* @default '<!DOCTYPE html>\n{{content}}'
|
|
20
|
+
*/
|
|
21
|
+
template?: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Enable server-side rendering
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
enableSSR?: boolean;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Static file directory for client-side assets
|
|
31
|
+
* @default 'public'
|
|
32
|
+
*/
|
|
33
|
+
staticDir?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface CoherentFastifyHandlerOptions {
|
|
37
|
+
/**
|
|
38
|
+
* Enable performance monitoring for rendered components
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
enablePerformanceMonitoring?: boolean;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* HTML template to wrap rendered components
|
|
45
|
+
* @default '<!DOCTYPE html>\n{{content}}'
|
|
46
|
+
*/
|
|
47
|
+
template?: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Enable streaming rendering for large components
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
enableStreaming?: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Fastify plugin for Coherent.js
|
|
58
|
+
* Adds Coherent.js rendering capabilities to Fastify
|
|
59
|
+
* @param fastify Fastify instance
|
|
60
|
+
* @param options Configuration options
|
|
61
|
+
* @param done Callback to signal plugin registration completion
|
|
62
|
+
*/
|
|
63
|
+
export function coherentFastify(
|
|
64
|
+
fastify: FastifyInstance,
|
|
65
|
+
options: CoherentFastifyOptions,
|
|
66
|
+
done: () => void
|
|
67
|
+
): void;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Create a Fastify route handler for Coherent.js components
|
|
71
|
+
* @param componentFactory Function that returns a Coherent component
|
|
72
|
+
* @param options Configuration options
|
|
73
|
+
* @returns Fastify route handler
|
|
74
|
+
*/
|
|
75
|
+
export function createHandler(
|
|
76
|
+
componentFactory: (
|
|
77
|
+
request: FastifyRequest,
|
|
78
|
+
reply: FastifyReply
|
|
79
|
+
) => CoherentNode | Promise<CoherentNode>,
|
|
80
|
+
options?: CoherentFastifyHandlerOptions
|
|
81
|
+
): (request: FastifyRequest, reply: FastifyReply) => Promise<any>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Setup Coherent.js with Fastify instance
|
|
85
|
+
* Configures plugin, static files, and reply extensions
|
|
86
|
+
* @param fastify Fastify instance
|
|
87
|
+
* @param options Configuration options
|
|
88
|
+
*/
|
|
89
|
+
export function setupCoherent(
|
|
90
|
+
fastify: FastifyInstance,
|
|
91
|
+
options?: CoherentFastifyOptions
|
|
92
|
+
): void;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Fastify reply extensions
|
|
96
|
+
*/
|
|
97
|
+
declare module 'fastify' {
|
|
98
|
+
interface FastifyReply {
|
|
99
|
+
/**
|
|
100
|
+
* Check if an object is a valid Coherent component
|
|
101
|
+
* @param obj Object to check
|
|
102
|
+
* @returns True if object is a valid Coherent component
|
|
103
|
+
*/
|
|
104
|
+
isCoherentObject(obj: any): boolean;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Render and send a Coherent component as HTML response
|
|
108
|
+
* @param component Coherent component to render
|
|
109
|
+
* @param options Rendering options
|
|
110
|
+
*/
|
|
111
|
+
coherent(
|
|
112
|
+
component: CoherentNode,
|
|
113
|
+
options?: CoherentFastifyHandlerOptions
|
|
114
|
+
): void;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Default export as Fastify plugin
|
|
120
|
+
*/
|
|
121
|
+
export default coherentFastify;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Type definitions for Coherent.js Next.js Integration
|
|
2
|
+
//
|
|
3
|
+
// Migrated from packages/nextjs/src/coherent-nextjs.d.ts during
|
|
4
|
+
// Wave 2c (integrations consolidation). Declarations are aligned with the
|
|
5
|
+
// runtime exports of ../../src/nextjs/coherent-nextjs.js.
|
|
6
|
+
|
|
7
|
+
import { NextApiRequest, NextApiResponse } from 'next';
|
|
8
|
+
import { ReactNode } from 'react';
|
|
9
|
+
import type { CoherentNode } from '@coherent.js/core';
|
|
10
|
+
|
|
11
|
+
export interface CoherentNextHandlerOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Enable performance monitoring for rendered components
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
enablePerformanceMonitoring?: boolean;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* HTML template to wrap rendered components
|
|
20
|
+
* @default '<!DOCTYPE html>\n{{content}}'
|
|
21
|
+
*/
|
|
22
|
+
template?: string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Enable streaming rendering for large components
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
enableStreaming?: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface CoherentNextComponentOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Enable performance monitoring for rendered components
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
enablePerformanceMonitoring?: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface CoherentNextIntegration {
|
|
40
|
+
createCoherentNextHandler: typeof createCoherentNextHandler;
|
|
41
|
+
createCoherentAppRouterHandler: typeof createCoherentAppRouterHandler;
|
|
42
|
+
createCoherentServerComponent: typeof createCoherentServerComponent;
|
|
43
|
+
createCoherentClientComponent: typeof createCoherentClientComponent;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Create a Next.js API route handler for Coherent.js components
|
|
48
|
+
* @param componentFactory Function that returns a Coherent component
|
|
49
|
+
* @param options Configuration options
|
|
50
|
+
* @returns Next.js API route handler
|
|
51
|
+
*/
|
|
52
|
+
export function createCoherentNextHandler(
|
|
53
|
+
componentFactory: (
|
|
54
|
+
req: NextApiRequest,
|
|
55
|
+
res: NextApiResponse
|
|
56
|
+
) => CoherentNode | Promise<CoherentNode>,
|
|
57
|
+
options?: CoherentNextHandlerOptions
|
|
58
|
+
): (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Create a Next.js App Router route handler for Coherent.js components
|
|
62
|
+
* @param componentFactory Function that returns a Coherent component
|
|
63
|
+
* @param options Configuration options
|
|
64
|
+
* @returns Next.js App Router handler
|
|
65
|
+
*/
|
|
66
|
+
export function createCoherentAppRouterHandler(
|
|
67
|
+
componentFactory: (request: Request) => CoherentNode | Promise<CoherentNode>,
|
|
68
|
+
options?: CoherentNextHandlerOptions
|
|
69
|
+
): (request: Request) => Promise<Response>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Create a Next.js Server Component for Coherent.js
|
|
73
|
+
* @param componentFactory Function that returns a Coherent component
|
|
74
|
+
* @param options Configuration options
|
|
75
|
+
* @returns Next.js Server Component
|
|
76
|
+
*/
|
|
77
|
+
export function createCoherentServerComponent(
|
|
78
|
+
componentFactory: (props: any) => CoherentNode | Promise<CoherentNode>,
|
|
79
|
+
options?: CoherentNextComponentOptions
|
|
80
|
+
): Promise<(props: any) => Promise<ReactNode>>;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Create a Next.js Client Component for Coherent.js with hydration support
|
|
84
|
+
* @param componentFactory Function that returns a Coherent component
|
|
85
|
+
* @param options Configuration options
|
|
86
|
+
* @returns Next.js Client Component
|
|
87
|
+
*/
|
|
88
|
+
export function createCoherentClientComponent(
|
|
89
|
+
componentFactory: (props: any) => CoherentNode,
|
|
90
|
+
options?: CoherentNextComponentOptions
|
|
91
|
+
): Promise<(props: any) => ReactNode>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Create Next.js integration with dependency checking.
|
|
95
|
+
* Verifies Next.js and React are available before returning bound handlers.
|
|
96
|
+
* @param options Default options applied to all returned handlers
|
|
97
|
+
* @returns Object with Next.js integration utilities
|
|
98
|
+
*/
|
|
99
|
+
export function createNextIntegration(
|
|
100
|
+
options?: CoherentNextHandlerOptions & CoherentNextComponentOptions
|
|
101
|
+
): Promise<CoherentNextIntegration>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Default export with all utilities
|
|
105
|
+
*/
|
|
106
|
+
declare const coherentNext: {
|
|
107
|
+
createCoherentNextHandler: typeof createCoherentNextHandler;
|
|
108
|
+
createCoherentAppRouterHandler: typeof createCoherentAppRouterHandler;
|
|
109
|
+
createCoherentServerComponent: typeof createCoherentServerComponent;
|
|
110
|
+
createCoherentClientComponent: typeof createCoherentClientComponent;
|
|
111
|
+
createNextIntegration: typeof createNextIntegration;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export default coherentNext;
|