Skip to content

Commit cfdece8

Browse files
committed
fix: embedded first launch
1 parent 4356bb4 commit cfdece8

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

packages/angular/src/lib/application.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -835,12 +835,29 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
835835
}
836836
};
837837

838+
// First (cold) launch entry point. Embedded apps are already running inside a
839+
// host UIApplication, so the native app loop must NOT be (re)started via
840+
// Application.run() with no entry — that routes through runAsEmbeddedApp() ->
841+
// createRootView() before Angular has bootstrapped a root, and since the
842+
// launch listener is intentionally not registered in embedded mode, it throws
843+
// "Main entry is missing. App cannot be started." Instead bootstrap Angular
844+
// directly; setRootView() then calls Application.run({ create }) with a real
845+
// entry once the root view exists. Non-embedded apps still need
846+
// Application.run() to drive UIApplicationMain/launch handling.
847+
const runFirstLaunch = () => {
848+
if (currentOptions.embedded) {
849+
bootstrapRoot('applaunch');
850+
} else {
851+
Application.run();
852+
}
853+
};
854+
838855
if (isWebpackHot) {
839856
// Webpack-specific HMR handling
840857
import.meta['webpackHot'].decline();
841858

842859
if (!Application.hasLaunched()) {
843-
Application.run();
860+
runFirstLaunch();
844861
return;
845862
}
846863
bootstrapRoot('hotreload');
@@ -853,16 +870,12 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
853870
// which will call __reboot_ng_modules__ when needed
854871

855872
if (!Application.hasLaunched()) {
856-
Application.run();
873+
runFirstLaunch();
857874
return;
858875
}
859876
bootstrapRoot('hotreload');
860877
return;
861878
}
862879

863-
if (currentOptions.embedded) {
864-
bootstrapRoot('applaunch');
865-
} else {
866-
Application.run();
867-
}
880+
runFirstLaunch();
868881
}

0 commit comments

Comments
 (0)