MCPcopy Index your code
hub / github.com/angular/angular-cli / from

Method from

packages/angular/ssr/src/routes/router.ts:48–73  ·  view source on GitHub ↗

* Creates or retrieves a `ServerRouter` instance based on the provided manifest and URL. * * If the manifest contains pre-built routes, a new `ServerRouter` is immediately created. * Otherwise, it builds the router by extracting routes from the Angular configuration * asynchronously. Thi

(manifest: AngularAppManifest, url: URL)

Source from the content-addressed store, hash-verified

46 * @returns A promise resolving to a `ServerRouter` instance.
47 */
48 static from(manifest: AngularAppManifest, url: URL): Promise<ServerRouter> {
49 if (manifest.routes) {
50 const routeTree = RouteTree.fromObject(manifest.routes);
51
52 return Promise.resolve(new ServerRouter(routeTree));
53 }
54
55 // Create and store a new promise for the build process.
56 // This prevents concurrent builds by re-using the same promise.
57 ServerRouter.#extractionPromise ??= extractRoutesAndCreateRouteTree({ url, manifest })
58 .then(({ routeTree, errors }) => {
59 if (errors.length > 0) {
60 throw new Error(
61 'Error(s) occurred while extracting routes:\n' +
62 errors.map((error) => `- ${error}`).join('\n'),
63 );
64 }
65
66 return new ServerRouter(routeTree);
67 })
68 .finally(() => {
69 ServerRouter.#extractionPromise = undefined;
70 });
71
72 return ServerRouter.#extractionPromise;
73 }
74
75 /**
76 * Matches a request URL against the route tree to retrieve route metadata.

Callers 15

getProjectFunction · 0.80
updateBuildTargetFunction · 0.80
btoaMethod · 0.80
runSharedTestsFunction · 0.80
inline-resource.tsFile · 0.80
resolveMethod · 0.80
_entryFunction · 0.80
applyContentTemplateFunction · 0.80
action_spec.tsFile · 0.80
getMethod · 0.80

Calls 3

fromObjectMethod · 0.80
resolveMethod · 0.80

Tested by

no test coverage detected