File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
packages/fastify-renderer/src/node Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ export interface FastifyRendererOptions {
22
22
hooks ?: ( FastifyRendererHook | ( ( ) => FastifyRendererHook ) ) [ ]
23
23
}
24
24
25
+ export type RegisteredRenderable = symbol
26
+
25
27
export class FastifyRendererPlugin {
26
28
renderer : Renderer
27
29
devMode : boolean
@@ -34,6 +36,7 @@ export class FastifyRendererPlugin {
34
36
clientManifest ?: ViteClientManifest
35
37
serverEntrypointManifest ?: ServerEntrypointManifest
36
38
routes : RenderableRoute [ ] = [ ]
39
+ registeredComponents : Record < RegisteredRenderable , RenderableRoute > = { }
37
40
38
41
constructor ( incomingOptions : FastifyRendererOptions ) {
39
42
this . devMode = incomingOptions . devMode ?? process . env . NODE_ENV != 'production'
@@ -105,7 +108,13 @@ export class FastifyRendererPlugin {
105
108
}
106
109
}
107
110
108
- registerRoute ( options : RenderableRoute ) {
111
+ registerRoute ( options : RenderableRoute ) : RegisteredRenderable {
112
+ // If the component is not already registered, we register it and return a unique symbol for it
113
+ const symbol = Symbol ( options . renderable )
114
+ this . registeredComponents [ symbol ] = options
115
+
109
116
this . routes . push ( options )
117
+
118
+ return symbol
110
119
}
111
120
}
You can’t perform that action at this time.
0 commit comments