frontend-app-api: expose bootstrap app state

Expose the prepared bootstrap tree together with subscription-based phase updates so createApp can render from app state directly instead of forcing rerenders through a sign-in callback.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
This commit is contained in:
Patrik Oldsberg
2026-03-12 22:39:25 +01:00
parent 72dd26a3a6
commit 89f83827c9
3 changed files with 11 additions and 15 deletions
+9 -13
View File
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { JSX, lazy, ReactNode, Suspense, useReducer } from 'react';
import { JSX, lazy, ReactNode, Suspense, useSyncExternalStore } from 'react';
import {
ConfigApi,
coreExtensionData,
@@ -149,21 +149,17 @@ export function createApp(options?: CreateAppOptions): {
function PreparedAppRoot(props: {
preparedApp: PreparedSpecializedApp;
}): JSX.Element {
const signIn = props.preparedApp.getSignIn();
const SignIn = signIn.Component;
const [, triggerRerender] = useReducer((count: number) => count + 1, 0);
const bootstrapApp = props.preparedApp.getBootstrapApp();
const finalizedApp: FinalizedSpecializedApp | undefined =
props.preparedApp.tryFinalize();
useSyncExternalStore(
props.preparedApp.subscribe,
props.preparedApp.getFinalizedApp,
);
if (!finalizedApp) {
return (
<SignIn
onReady={() => {
triggerRerender();
}}
/>
);
return bootstrapApp.tree.root.instance!.getData(
coreExtensionData.reactElement,
)!;
}
const errorPage = maybeCreateErrorPage(finalizedApp);