@@ -130,11 +130,16 @@ async function renderStxPage(templateName: string, wsUrl: string, req: Request):
130130 const content = await Bun . file ( templatePath ) . text ( )
131131
132132 const context = { __filename : templatePath , __dirname : path . dirname ( templatePath ) }
133- // Skip signals runtime injection for page fragments — the shell provides it
134- const pageConfig = { ...stxConfig , skipSignalsRuntime : true }
135- let pageHtml = await processDirectives ( content , context , templatePath , pageConfig , new Set ( ) )
133+ let pageHtml = await processDirectives ( content , context , templatePath , stxConfig , new Set ( ) )
136134 pageHtml = stripDocumentWrapper ( pageHtml )
137135
136+ // Strip the signals runtime from page fragment — the shell already provides it in <head>
137+ pageHtml = pageHtml . replace ( / < s c r i p t d a t a - s t x - s c o p e d > \( f u n c t i o n \( \) \{ ' u s e s t r i c t ' ; v a r c l o a k S t y l e [ \s \S ] * ?< \/ s c r i p t > / , '' )
138+
139+ // Extract the SFC setup function name so we can bind it to the content wrapper
140+ const setupMatch = pageHtml . match ( / f u n c t i o n ( _ _ s t x _ s e t u p _ \w + ) / )
141+ const pageSetupName = setupMatch ? setupMatch [ 1 ] : null
142+
138143 // SPA navigation — return fragment only
139144 if ( isSpaNavigation ( req ) ) {
140145 return new Response ( pageHtml , {
@@ -163,7 +168,7 @@ async function renderStxPage(templateName: string, wsUrl: string, req: Request):
163168</head>
164169<body class="bg-[#0a0a0f] text-zinc-50 leading-relaxed min-h-screen">
165170${ shell . before }
166- <div data-stx-content>${ pageHtml } </div>
171+ <div data-stx-content${ pageSetupName ? ` data-stx=" ${ pageSetupName } "` : '' } >${ pageHtml } </div>
167172${ shell . after }
168173${ shell . scripts }
169174${ getRouterScriptTag ( ) }
0 commit comments