@angular/platform-server 21.0.0-next.2 → 21.0.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/init.mjs +1 -1
- package/fesm2022/init.mjs.map +1 -1
- package/fesm2022/platform-server.mjs +17 -7
- package/fesm2022/platform-server.mjs.map +1 -1
- package/fesm2022/server.mjs +37 -39
- package/fesm2022/server.mjs.map +1 -1
- package/fesm2022/testing.mjs +5 -5
- package/fesm2022/testing.mjs.map +1 -1
- package/index.d.ts +24 -7
- package/init/index.d.ts +1 -1
- package/package.json +5 -5
- package/testing/index.d.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.0.0-next.
|
|
2
|
+
* @license Angular v21.0.0-next.4
|
|
3
3
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -249,14 +249,24 @@ async function renderModule(moduleType, options) {
|
|
|
249
249
|
}
|
|
250
250
|
/**
|
|
251
251
|
* Bootstraps an instance of an Angular application and renders it to a string.
|
|
252
|
-
|
|
252
|
+
*
|
|
253
|
+
* @usageNotes
|
|
254
|
+
*
|
|
253
255
|
* ```ts
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
+
* import { BootstrapContext, bootstrapApplication } from '@angular/platform-browser';
|
|
257
|
+
* import { renderApplication } from '@angular/platform-server';
|
|
258
|
+
* import { ApplicationConfig } from '@angular/core';
|
|
259
|
+
* import { AppComponent } from './app.component';
|
|
260
|
+
*
|
|
261
|
+
* const appConfig: ApplicationConfig = { providers: [...] };
|
|
262
|
+
* const bootstrap = (context: BootstrapContext) =>
|
|
263
|
+
* bootstrapApplication(AppComponent, config, context);
|
|
264
|
+
* const output = await renderApplication(bootstrap);
|
|
256
265
|
* ```
|
|
257
266
|
*
|
|
258
267
|
* @param bootstrap A method that when invoked returns a promise that returns an `ApplicationRef`
|
|
259
|
-
* instance once resolved.
|
|
268
|
+
* instance once resolved. The method is invoked with an `Injector` instance that
|
|
269
|
+
* provides access to the platform-level dependency injection context.
|
|
260
270
|
* @param options Additional configuration for the render operation:
|
|
261
271
|
* - `document` - the document of the page to render, either as an HTML string or
|
|
262
272
|
* as a reference to the `document` instance.
|
|
@@ -275,7 +285,7 @@ async function renderApplication(bootstrap, options) {
|
|
|
275
285
|
const platformRef = createServerPlatform(options);
|
|
276
286
|
try {
|
|
277
287
|
_startMeasuring(bootstrapLabel);
|
|
278
|
-
const applicationRef = await bootstrap();
|
|
288
|
+
const applicationRef = await bootstrap({ platformRef });
|
|
279
289
|
_stopMeasuring(bootstrapLabel);
|
|
280
290
|
_startMeasuring(_renderLabel);
|
|
281
291
|
const measuringLabel = 'whenStable';
|
|
@@ -301,7 +311,7 @@ async function renderApplication(bootstrap, options) {
|
|
|
301
311
|
/**
|
|
302
312
|
* @publicApi
|
|
303
313
|
*/
|
|
304
|
-
const VERSION = new Version('21.0.0-next.
|
|
314
|
+
const VERSION = new Version('21.0.0-next.4');
|
|
305
315
|
|
|
306
316
|
export { BEFORE_APP_SERIALIZED, INITIAL_CONFIG, PlatformState, VERSION, platformServer, provideServerRendering, renderApplication, renderModule, SERVER_CONTEXT as ɵSERVER_CONTEXT, renderInternal as ɵrenderInternal };
|
|
307
317
|
//# sourceMappingURL=platform-server.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-server.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/packages/platform-server/src/provide_server.ts","../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/packages/platform-server/src/utils.ts","../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/packages/platform-server/src/version.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {EnvironmentProviders, makeEnvironmentProviders} from '@angular/core';\n\nimport {PLATFORM_SERVER_PROVIDERS} from './server';\n\n/**\n * Sets up providers necessary to enable server rendering functionality for the application.\n *\n * @usageNotes\n *\n * Basic example of how you can add server support to your application:\n * ```ts\n * bootstrapApplication(AppComponent, {\n * providers: [provideServerRendering()]\n * });\n * ```\n *\n * @publicApi\n * @returns A set of providers to setup the server.\n */\nexport function provideServerRendering(): EnvironmentProviders {\n if (typeof ngServerMode === 'undefined') {\n globalThis['ngServerMode'] = true;\n }\n\n return makeEnvironmentProviders([...PLATFORM_SERVER_PROVIDERS]);\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n APP_ID,\n ApplicationRef,\n CSP_NONCE,\n InjectionToken,\n PlatformRef,\n Provider,\n Renderer2,\n StaticProvider,\n Type,\n ɵannotateForHydration as annotateForHydration,\n ɵIS_HYDRATION_DOM_REUSE_ENABLED as IS_HYDRATION_DOM_REUSE_ENABLED,\n ɵSSR_CONTENT_INTEGRITY_MARKER as SSR_CONTENT_INTEGRITY_MARKER,\n ɵstartMeasuring as startMeasuring,\n ɵstopMeasuring as stopMeasuring,\n} from '@angular/core';\n\nimport {PlatformState} from './platform_state';\nimport {platformServer} from './server';\nimport {BEFORE_APP_SERIALIZED, INITIAL_CONFIG} from './tokens';\nimport {createScript} from './transfer_state';\n\n/**\n * Event dispatch (JSAction) script is inlined into the HTML by the build\n * process to avoid extra blocking request on a page. The script looks like this:\n * ```html\n * <script type=\"text/javascript\" id=\"ng-event-dispatch-contract\">...</script>\n * ```\n * This const represents the \"id\" attribute value.\n */\nexport const EVENT_DISPATCH_SCRIPT_ID = 'ng-event-dispatch-contract';\n\ninterface PlatformOptions {\n document?: string | Document;\n url?: string;\n platformProviders?: Provider[];\n}\n\n/**\n * Creates an instance of a server platform (with or without JIT compiler support\n * depending on the `ngJitMode` global const value), using provided options.\n */\nfunction createServerPlatform(options: PlatformOptions): PlatformRef {\n const extraProviders = options.platformProviders ?? [];\n const measuringLabel = 'createServerPlatform';\n startMeasuring(measuringLabel);\n\n const platform = platformServer([\n {provide: INITIAL_CONFIG, useValue: {document: options.document, url: options.url}},\n extraProviders,\n ]);\n\n stopMeasuring(measuringLabel);\n return platform;\n}\n\n/**\n * Finds and returns inlined event dispatch script if it exists.\n * See the `EVENT_DISPATCH_SCRIPT_ID` const docs for additional info.\n */\nfunction findEventDispatchScript(doc: Document) {\n return doc.getElementById(EVENT_DISPATCH_SCRIPT_ID);\n}\n\n/**\n * Removes inlined event dispatch script if it exists.\n * See the `EVENT_DISPATCH_SCRIPT_ID` const docs for additional info.\n */\nfunction removeEventDispatchScript(doc: Document) {\n findEventDispatchScript(doc)?.remove();\n}\n\n/**\n * Annotate nodes for hydration and remove event dispatch script when not needed.\n */\nfunction prepareForHydration(platformState: PlatformState, applicationRef: ApplicationRef): void {\n const measuringLabel = 'prepareForHydration';\n startMeasuring(measuringLabel);\n const environmentInjector = applicationRef.injector;\n const doc = platformState.getDocument();\n\n if (!environmentInjector.get(IS_HYDRATION_DOM_REUSE_ENABLED, false)) {\n // Hydration is diabled, remove inlined event dispatch script.\n // (which was injected by the build process) from the HTML.\n removeEventDispatchScript(doc);\n\n return;\n }\n\n appendSsrContentIntegrityMarker(doc);\n\n const eventTypesToReplay = annotateForHydration(applicationRef, doc);\n if (eventTypesToReplay.regular.size || eventTypesToReplay.capture.size) {\n insertEventRecordScript(\n environmentInjector.get(APP_ID),\n doc,\n eventTypesToReplay,\n environmentInjector.get(CSP_NONCE, null),\n );\n } else {\n // No events to replay, we should remove inlined event dispatch script\n // (which was injected by the build process) from the HTML.\n removeEventDispatchScript(doc);\n }\n stopMeasuring(measuringLabel);\n}\n\n/**\n * Creates a marker comment node and append it into the `<body>`.\n * Some CDNs have mechanisms to remove all comment node from HTML.\n * This behaviour breaks hydration, so we'll detect on the client side if this\n * marker comment is still available or else throw an error\n */\nfunction appendSsrContentIntegrityMarker(doc: Document) {\n // Adding a ng hydration marker comment\n const comment = doc.createComment(SSR_CONTENT_INTEGRITY_MARKER);\n doc.body.firstChild\n ? doc.body.insertBefore(comment, doc.body.firstChild)\n : doc.body.append(comment);\n}\n\n/**\n * Adds the `ng-server-context` attribute to host elements of all bootstrapped components\n * within a given application.\n */\nfunction appendServerContextInfo(applicationRef: ApplicationRef) {\n const injector = applicationRef.injector;\n let serverContext = sanitizeServerContext(injector.get(SERVER_CONTEXT, DEFAULT_SERVER_CONTEXT));\n applicationRef.components.forEach((componentRef) => {\n const renderer = componentRef.injector.get(Renderer2);\n const element = componentRef.location.nativeElement;\n if (element) {\n renderer.setAttribute(element, 'ng-server-context', serverContext);\n }\n });\n}\n\nfunction insertEventRecordScript(\n appId: string,\n doc: Document,\n eventTypesToReplay: {regular: Set<string>; capture: Set<string>},\n nonce: string | null,\n): void {\n const measuringLabel = 'insertEventRecordScript';\n startMeasuring(measuringLabel);\n const {regular, capture} = eventTypesToReplay;\n const eventDispatchScript = findEventDispatchScript(doc);\n\n // Note: this is only true when build with the CLI tooling, which inserts the script in the HTML\n if (eventDispatchScript) {\n // This is defined in packages/core/primitives/event-dispatch/contract_binary.ts\n const replayScriptContents =\n `window.__jsaction_bootstrap(` +\n `document.body,` +\n `\"${appId}\",` +\n `${JSON.stringify(Array.from(regular))},` +\n `${JSON.stringify(Array.from(capture))}` +\n `);`;\n\n const replayScript = createScript(doc, replayScriptContents, nonce);\n\n // Insert replay script right after inlined event dispatch script, since it\n // relies on `__jsaction_bootstrap` to be defined in the global scope.\n eventDispatchScript.after(replayScript);\n }\n stopMeasuring(measuringLabel);\n}\n\n/**\n * Renders an Angular application to a string.\n *\n * @private\n *\n * @param platformRef - Reference to the Angular platform.\n * @param applicationRef - Reference to the Angular application.\n * @returns A promise that resolves to the rendered string.\n */\nexport async function renderInternal(\n platformRef: PlatformRef,\n applicationRef: ApplicationRef,\n): Promise<string> {\n const platformState = platformRef.injector.get(PlatformState);\n prepareForHydration(platformState, applicationRef);\n appendServerContextInfo(applicationRef);\n\n // Run any BEFORE_APP_SERIALIZED callbacks just before rendering to string.\n const environmentInjector = applicationRef.injector;\n const callbacks = environmentInjector.get(BEFORE_APP_SERIALIZED, null);\n if (callbacks) {\n const asyncCallbacks: Promise<void>[] = [];\n for (const callback of callbacks) {\n try {\n const callbackResult = callback();\n if (callbackResult) {\n asyncCallbacks.push(callbackResult);\n }\n } catch (e) {\n // Ignore exceptions.\n console.warn('Ignoring BEFORE_APP_SERIALIZED Exception: ', e);\n }\n }\n\n if (asyncCallbacks.length) {\n for (const result of await Promise.allSettled(asyncCallbacks)) {\n if (result.status === 'rejected') {\n console.warn('Ignoring BEFORE_APP_SERIALIZED Exception: ', result.reason);\n }\n }\n }\n }\n\n return platformState.renderToString();\n}\n\n/**\n * Destroy the application in a macrotask, this allows pending promises to be settled and errors\n * to be surfaced to the users.\n */\nfunction asyncDestroyPlatform(platformRef: PlatformRef): Promise<void> {\n return new Promise<void>((resolve) => {\n setTimeout(() => {\n platformRef.destroy();\n resolve();\n }, 0);\n });\n}\n\n/**\n * Specifies the value that should be used if no server context value has been provided.\n */\nconst DEFAULT_SERVER_CONTEXT = 'other';\n\n/**\n * An internal token that allows providing extra information about the server context\n * (e.g. whether SSR or SSG was used). The value is a string and characters other\n * than [a-zA-Z0-9\\-] are removed. See the default value in `DEFAULT_SERVER_CONTEXT` const.\n */\nexport const SERVER_CONTEXT = new InjectionToken<string>('SERVER_CONTEXT');\n\n/**\n * Sanitizes provided server context:\n * - removes all characters other than a-z, A-Z, 0-9 and `-`\n * - returns `other` if nothing is provided or the string is empty after sanitization\n */\nfunction sanitizeServerContext(serverContext: string): string {\n const context = serverContext.replace(/[^a-zA-Z0-9\\-]/g, '');\n return context.length > 0 ? context : DEFAULT_SERVER_CONTEXT;\n}\n\n/**\n * Bootstraps an application using provided NgModule and serializes the page content to string.\n *\n * @param moduleType A reference to an NgModule that should be used for bootstrap.\n * @param options Additional configuration for the render operation:\n * - `document` - the document of the page to render, either as an HTML string or\n * as a reference to the `document` instance.\n * - `url` - the URL for the current render request.\n * - `extraProviders` - set of platform level providers for the current render request.\n *\n * @publicApi\n */\nexport async function renderModule<T>(\n moduleType: Type<T>,\n options: {document?: string | Document; url?: string; extraProviders?: StaticProvider[]},\n): Promise<string> {\n const {document, url, extraProviders: platformProviders} = options;\n const platformRef = createServerPlatform({document, url, platformProviders});\n try {\n const moduleRef = await platformRef.bootstrapModule(moduleType);\n const applicationRef = moduleRef.injector.get(ApplicationRef);\n\n const measuringLabel = 'whenStable';\n startMeasuring(measuringLabel);\n // Block until application is stable.\n await applicationRef.whenStable();\n stopMeasuring(measuringLabel);\n\n return await renderInternal(platformRef, applicationRef);\n } finally {\n await asyncDestroyPlatform(platformRef);\n }\n}\n\n/**\n * Bootstraps an instance of an Angular application and renders it to a string.\n\n * ```ts\n * const bootstrap = () => bootstrapApplication(RootComponent, appConfig);\n * const output: string = await renderApplication(bootstrap);\n * ```\n *\n * @param bootstrap A method that when invoked returns a promise that returns an `ApplicationRef`\n * instance once resolved.\n * @param options Additional configuration for the render operation:\n * - `document` - the document of the page to render, either as an HTML string or\n * as a reference to the `document` instance.\n * - `url` - the URL for the current render request.\n * - `platformProviders` - the platform level providers for the current render request.\n *\n * @returns A Promise, that returns serialized (to a string) rendered page, once resolved.\n *\n * @publicApi\n */\nexport async function renderApplication<T>(\n bootstrap: () => Promise<ApplicationRef>,\n options: {document?: string | Document; url?: string; platformProviders?: Provider[]},\n): Promise<string> {\n const renderAppLabel = 'renderApplication';\n const bootstrapLabel = 'bootstrap';\n const _renderLabel = '_render';\n\n startMeasuring(renderAppLabel);\n const platformRef = createServerPlatform(options);\n try {\n startMeasuring(bootstrapLabel);\n const applicationRef = await bootstrap();\n stopMeasuring(bootstrapLabel);\n\n startMeasuring(_renderLabel);\n\n const measuringLabel = 'whenStable';\n startMeasuring(measuringLabel);\n // Block until application is stable.\n await applicationRef.whenStable();\n stopMeasuring(measuringLabel);\n\n const rendered = await renderInternal(platformRef, applicationRef);\n stopMeasuring(_renderLabel);\n return rendered;\n } finally {\n await asyncDestroyPlatform(platformRef);\n stopMeasuring(renderAppLabel);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of the platform-server package.\n */\n\nimport {Version} from '@angular/core';\n\n/**\n * @publicApi\n */\nexport const VERSION = new Version('21.0.0-next.2');\n"],"names":["startMeasuring","stopMeasuring","IS_HYDRATION_DOM_REUSE_ENABLED","annotateForHydration","SSR_CONTENT_INTEGRITY_MARKER"],"mappings":";;;;;;;;;;;;;;AAYA;;;;;;;;;;;;;;AAcG;SACa,sBAAsB,GAAA;AACpC,IAAA,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE;AACvC,QAAA,UAAU,CAAC,cAAc,CAAC,GAAG,IAAI;;AAGnC,IAAA,OAAO,wBAAwB,CAAC,CAAC,GAAG,yBAAyB,CAAC,CAAC;AACjE;;ACHA;;;;;;;AAOG;AACI,MAAM,wBAAwB,GAAG,4BAA4B;AAQpE;;;AAGG;AACH,SAAS,oBAAoB,CAAC,OAAwB,EAAA;AACpD,IAAA,MAAM,cAAc,GAAG,OAAO,CAAC,iBAAiB,IAAI,EAAE;IACtD,MAAM,cAAc,GAAG,sBAAsB;IAC7CA,eAAc,CAAC,cAAc,CAAC;IAE9B,MAAM,QAAQ,GAAG,cAAc,CAAC;AAC9B,QAAA,EAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAC,EAAC;QACnF,cAAc;AACf,KAAA,CAAC;IAEFC,cAAa,CAAC,cAAc,CAAC;AAC7B,IAAA,OAAO,QAAQ;AACjB;AAEA;;;AAGG;AACH,SAAS,uBAAuB,CAAC,GAAa,EAAA;A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AG,mBAAmB;IAC1C,MAAM,cAAc,GAAG,WAAW;IAClC,MAAM,YAAY,GAAG,SAAS;IAE9BD,eAAc,CAAC,cAAc,CAAC;AAC9B,IAAA,MAAM,WAAW,GAAG,oBAAoB,CAAC,OAAO,CAAC;AACjD,IAAA,IAAI;QACFA,eAAc,CAAC,cAAc,CAAC;AAC9B,QAAA,MAAM,cAAc,GAAG,MAAM,SAAS,EAAE;QACxCC,cAAa,CAAC,cAAc,CAAC;QAE7BD,eAAc,CAAC,YAAY,CAAC;QAE5B,MAAM,cAAc,GAAG,YAAY;QACnCA,eAAc,CAAC,cAAc,CAAC;;AAE9B,QAAA,MAAM,cAAc,CAAC,UAAU,EAAE;QACjCC,cAAa,CAAC,cAAc,CAAC;QAE7B,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,WAAW,EAAE,cAAc,CAAC;QAClEA,cAAa,CAAC,YAAY,CAAC;AAC3B,QAAA,OAAO,QAAQ;;YACP;AACR,QAAA,MAAM,oBAAoB,CAAC,WAAW,CAAC;QACvCA,cAAa,CAAC,cAAc,CAAC;;AAEjC;;AC7UA;;;;AAIG;AAIH;;AAEG;MACU,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB;;;;"}
|
|
1
|
+
{"version":3,"file":"platform-server.mjs","sources":["../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/packages/platform-server/src/provide_server.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/packages/platform-server/src/utils.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/packages/platform-server/src/version.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {EnvironmentProviders, makeEnvironmentProviders} from '@angular/core';\n\nimport {PLATFORM_SERVER_PROVIDERS} from './server';\n\n/**\n * Sets up providers necessary to enable server rendering functionality for the application.\n *\n * @usageNotes\n *\n * Basic example of how you can add server support to your application:\n * ```ts\n * bootstrapApplication(AppComponent, {\n * providers: [provideServerRendering()]\n * });\n * ```\n *\n * @publicApi\n * @returns A set of providers to setup the server.\n */\nexport function provideServerRendering(): EnvironmentProviders {\n if (typeof ngServerMode === 'undefined') {\n globalThis['ngServerMode'] = true;\n }\n\n return makeEnvironmentProviders([...PLATFORM_SERVER_PROVIDERS]);\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n APP_ID,\n ApplicationRef,\n CSP_NONCE,\n InjectionToken,\n PlatformRef,\n Provider,\n Renderer2,\n StaticProvider,\n Type,\n ɵannotateForHydration as annotateForHydration,\n ɵIS_HYDRATION_DOM_REUSE_ENABLED as IS_HYDRATION_DOM_REUSE_ENABLED,\n ɵSSR_CONTENT_INTEGRITY_MARKER as SSR_CONTENT_INTEGRITY_MARKER,\n ɵstartMeasuring as startMeasuring,\n ɵstopMeasuring as stopMeasuring,\n} from '@angular/core';\nimport {BootstrapContext} from '@angular/platform-browser';\n\nimport {platformServer} from './server';\nimport {PlatformState} from './platform_state';\nimport {BEFORE_APP_SERIALIZED, INITIAL_CONFIG} from './tokens';\nimport {createScript} from './transfer_state';\n\n/**\n * Event dispatch (JSAction) script is inlined into the HTML by the build\n * process to avoid extra blocking request on a page. The script looks like this:\n * ```html\n * <script type=\"text/javascript\" id=\"ng-event-dispatch-contract\">...</script>\n * ```\n * This const represents the \"id\" attribute value.\n */\nexport const EVENT_DISPATCH_SCRIPT_ID = 'ng-event-dispatch-contract';\n\ninterface PlatformOptions {\n document?: string | Document;\n url?: string;\n platformProviders?: Provider[];\n}\n\n/**\n * Creates an instance of a server platform (with or without JIT compiler support\n * depending on the `ngJitMode` global const value), using provided options.\n */\nfunction createServerPlatform(options: PlatformOptions): PlatformRef {\n const extraProviders = options.platformProviders ?? [];\n const measuringLabel = 'createServerPlatform';\n startMeasuring(measuringLabel);\n\n const platform = platformServer([\n {provide: INITIAL_CONFIG, useValue: {document: options.document, url: options.url}},\n extraProviders,\n ]);\n\n stopMeasuring(measuringLabel);\n return platform;\n}\n\n/**\n * Finds and returns inlined event dispatch script if it exists.\n * See the `EVENT_DISPATCH_SCRIPT_ID` const docs for additional info.\n */\nfunction findEventDispatchScript(doc: Document) {\n return doc.getElementById(EVENT_DISPATCH_SCRIPT_ID);\n}\n\n/**\n * Removes inlined event dispatch script if it exists.\n * See the `EVENT_DISPATCH_SCRIPT_ID` const docs for additional info.\n */\nfunction removeEventDispatchScript(doc: Document) {\n findEventDispatchScript(doc)?.remove();\n}\n\n/**\n * Annotate nodes for hydration and remove event dispatch script when not needed.\n */\nfunction prepareForHydration(platformState: PlatformState, applicationRef: ApplicationRef): void {\n const measuringLabel = 'prepareForHydration';\n startMeasuring(measuringLabel);\n const environmentInjector = applicationRef.injector;\n const doc = platformState.getDocument();\n\n if (!environmentInjector.get(IS_HYDRATION_DOM_REUSE_ENABLED, false)) {\n // Hydration is diabled, remove inlined event dispatch script.\n // (which was injected by the build process) from the HTML.\n removeEventDispatchScript(doc);\n\n return;\n }\n\n appendSsrContentIntegrityMarker(doc);\n\n const eventTypesToReplay = annotateForHydration(applicationRef, doc);\n if (eventTypesToReplay.regular.size || eventTypesToReplay.capture.size) {\n insertEventRecordScript(\n environmentInjector.get(APP_ID),\n doc,\n eventTypesToReplay,\n environmentInjector.get(CSP_NONCE, null),\n );\n } else {\n // No events to replay, we should remove inlined event dispatch script\n // (which was injected by the build process) from the HTML.\n removeEventDispatchScript(doc);\n }\n stopMeasuring(measuringLabel);\n}\n\n/**\n * Creates a marker comment node and append it into the `<body>`.\n * Some CDNs have mechanisms to remove all comment node from HTML.\n * This behaviour breaks hydration, so we'll detect on the client side if this\n * marker comment is still available or else throw an error\n */\nfunction appendSsrContentIntegrityMarker(doc: Document) {\n // Adding a ng hydration marker comment\n const comment = doc.createComment(SSR_CONTENT_INTEGRITY_MARKER);\n doc.body.firstChild\n ? doc.body.insertBefore(comment, doc.body.firstChild)\n : doc.body.append(comment);\n}\n\n/**\n * Adds the `ng-server-context` attribute to host elements of all bootstrapped components\n * within a given application.\n */\nfunction appendServerContextInfo(applicationRef: ApplicationRef) {\n const injector = applicationRef.injector;\n let serverContext = sanitizeServerContext(injector.get(SERVER_CONTEXT, DEFAULT_SERVER_CONTEXT));\n applicationRef.components.forEach((componentRef) => {\n const renderer = componentRef.injector.get(Renderer2);\n const element = componentRef.location.nativeElement;\n if (element) {\n renderer.setAttribute(element, 'ng-server-context', serverContext);\n }\n });\n}\n\nfunction insertEventRecordScript(\n appId: string,\n doc: Document,\n eventTypesToReplay: {regular: Set<string>; capture: Set<string>},\n nonce: string | null,\n): void {\n const measuringLabel = 'insertEventRecordScript';\n startMeasuring(measuringLabel);\n const {regular, capture} = eventTypesToReplay;\n const eventDispatchScript = findEventDispatchScript(doc);\n\n // Note: this is only true when build with the CLI tooling, which inserts the script in the HTML\n if (eventDispatchScript) {\n // This is defined in packages/core/primitives/event-dispatch/contract_binary.ts\n const replayScriptContents =\n `window.__jsaction_bootstrap(` +\n `document.body,` +\n `\"${appId}\",` +\n `${JSON.stringify(Array.from(regular))},` +\n `${JSON.stringify(Array.from(capture))}` +\n `);`;\n\n const replayScript = createScript(doc, replayScriptContents, nonce);\n\n // Insert replay script right after inlined event dispatch script, since it\n // relies on `__jsaction_bootstrap` to be defined in the global scope.\n eventDispatchScript.after(replayScript);\n }\n stopMeasuring(measuringLabel);\n}\n\n/**\n * Renders an Angular application to a string.\n *\n * @private\n *\n * @param platformRef - Reference to the Angular platform.\n * @param applicationRef - Reference to the Angular application.\n * @returns A promise that resolves to the rendered string.\n */\nexport async function renderInternal(\n platformRef: PlatformRef,\n applicationRef: ApplicationRef,\n): Promise<string> {\n const platformState = platformRef.injector.get(PlatformState);\n prepareForHydration(platformState, applicationRef);\n appendServerContextInfo(applicationRef);\n\n // Run any BEFORE_APP_SERIALIZED callbacks just before rendering to string.\n const environmentInjector = applicationRef.injector;\n const callbacks = environmentInjector.get(BEFORE_APP_SERIALIZED, null);\n if (callbacks) {\n const asyncCallbacks: Promise<void>[] = [];\n for (const callback of callbacks) {\n try {\n const callbackResult = callback();\n if (callbackResult) {\n asyncCallbacks.push(callbackResult);\n }\n } catch (e) {\n // Ignore exceptions.\n console.warn('Ignoring BEFORE_APP_SERIALIZED Exception: ', e);\n }\n }\n\n if (asyncCallbacks.length) {\n for (const result of await Promise.allSettled(asyncCallbacks)) {\n if (result.status === 'rejected') {\n console.warn('Ignoring BEFORE_APP_SERIALIZED Exception: ', result.reason);\n }\n }\n }\n }\n\n return platformState.renderToString();\n}\n\n/**\n * Destroy the application in a macrotask, this allows pending promises to be settled and errors\n * to be surfaced to the users.\n */\nfunction asyncDestroyPlatform(platformRef: PlatformRef): Promise<void> {\n return new Promise<void>((resolve) => {\n setTimeout(() => {\n platformRef.destroy();\n resolve();\n }, 0);\n });\n}\n\n/**\n * Specifies the value that should be used if no server context value has been provided.\n */\nconst DEFAULT_SERVER_CONTEXT = 'other';\n\n/**\n * An internal token that allows providing extra information about the server context\n * (e.g. whether SSR or SSG was used). The value is a string and characters other\n * than [a-zA-Z0-9\\-] are removed. See the default value in `DEFAULT_SERVER_CONTEXT` const.\n */\nexport const SERVER_CONTEXT = new InjectionToken<string>('SERVER_CONTEXT');\n\n/**\n * Sanitizes provided server context:\n * - removes all characters other than a-z, A-Z, 0-9 and `-`\n * - returns `other` if nothing is provided or the string is empty after sanitization\n */\nfunction sanitizeServerContext(serverContext: string): string {\n const context = serverContext.replace(/[^a-zA-Z0-9\\-]/g, '');\n return context.length > 0 ? context : DEFAULT_SERVER_CONTEXT;\n}\n\n/**\n * Bootstraps an application using provided NgModule and serializes the page content to string.\n *\n * @param moduleType A reference to an NgModule that should be used for bootstrap.\n * @param options Additional configuration for the render operation:\n * - `document` - the document of the page to render, either as an HTML string or\n * as a reference to the `document` instance.\n * - `url` - the URL for the current render request.\n * - `extraProviders` - set of platform level providers for the current render request.\n *\n * @publicApi\n */\nexport async function renderModule<T>(\n moduleType: Type<T>,\n options: {document?: string | Document; url?: string; extraProviders?: StaticProvider[]},\n): Promise<string> {\n const {document, url, extraProviders: platformProviders} = options;\n const platformRef = createServerPlatform({document, url, platformProviders});\n try {\n const moduleRef = await platformRef.bootstrapModule(moduleType);\n const applicationRef = moduleRef.injector.get(ApplicationRef);\n\n const measuringLabel = 'whenStable';\n startMeasuring(measuringLabel);\n // Block until application is stable.\n await applicationRef.whenStable();\n stopMeasuring(measuringLabel);\n\n return await renderInternal(platformRef, applicationRef);\n } finally {\n await asyncDestroyPlatform(platformRef);\n }\n}\n\n/**\n * Bootstraps an instance of an Angular application and renders it to a string.\n *\n * @usageNotes\n *\n * ```ts\n * import { BootstrapContext, bootstrapApplication } from '@angular/platform-browser';\n * import { renderApplication } from '@angular/platform-server';\n * import { ApplicationConfig } from '@angular/core';\n * import { AppComponent } from './app.component';\n *\n * const appConfig: ApplicationConfig = { providers: [...] };\n * const bootstrap = (context: BootstrapContext) =>\n * bootstrapApplication(AppComponent, config, context);\n * const output = await renderApplication(bootstrap);\n * ```\n *\n * @param bootstrap A method that when invoked returns a promise that returns an `ApplicationRef`\n * instance once resolved. The method is invoked with an `Injector` instance that\n * provides access to the platform-level dependency injection context.\n * @param options Additional configuration for the render operation:\n * - `document` - the document of the page to render, either as an HTML string or\n * as a reference to the `document` instance.\n * - `url` - the URL for the current render request.\n * - `platformProviders` - the platform level providers for the current render request.\n *\n * @returns A Promise, that returns serialized (to a string) rendered page, once resolved.\n *\n * @publicApi\n */\nexport async function renderApplication(\n bootstrap: (context: BootstrapContext) => Promise<ApplicationRef>,\n options: {document?: string | Document; url?: string; platformProviders?: Provider[]},\n): Promise<string> {\n const renderAppLabel = 'renderApplication';\n const bootstrapLabel = 'bootstrap';\n const _renderLabel = '_render';\n\n startMeasuring(renderAppLabel);\n const platformRef = createServerPlatform(options);\n try {\n startMeasuring(bootstrapLabel);\n const applicationRef = await bootstrap({platformRef});\n stopMeasuring(bootstrapLabel);\n\n startMeasuring(_renderLabel);\n\n const measuringLabel = 'whenStable';\n startMeasuring(measuringLabel);\n // Block until application is stable.\n await applicationRef.whenStable();\n stopMeasuring(measuringLabel);\n\n const rendered = await renderInternal(platformRef, applicationRef);\n stopMeasuring(_renderLabel);\n return rendered;\n } finally {\n await asyncDestroyPlatform(platformRef);\n stopMeasuring(renderAppLabel);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of the platform-server package.\n */\n\nimport {Version} from '@angular/core';\n\n/**\n * @publicApi\n */\nexport const VERSION = new Version('21.0.0-next.4');\n"],"names":["startMeasuring","stopMeasuring","IS_HYDRATION_DOM_REUSE_ENABLED","annotateForHydration","SSR_CONTENT_INTEGRITY_MARKER"],"mappings":";;;;;;;;;;;;;;AAYA;;;;;;;;;;;;;;AAcG;SACa,sBAAsB,GAAA;AACpC,IAAA,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE;AACvC,QAAA,UAAU,CAAC,cAAc,CAAC,GAAG,IAAI;;AAGnC,IAAA,OAAO,wBAAwB,CAAC,CAAC,GAAG,yBAAyB,CAAC,CAAC;AACjE;;ACFA;;;;;;;AAOG;AACI,MAAM,wBAAwB,GAAG,4BAA4B;AAQpE;;;AAGG;AACH,SAAS,oBAAoB,CAAC,OAAwB,EAAA;AACpD,IAAA,MAAM,cAAc,GAAG,OAAO,CAAC,iBAAiB,IAAI,EAAE;IACtD,MAAM,cAAc,GAAG,sBAAsB;IAC7CA,eAAc,CAAC,cAAc,CAAC;IAE9B,MAAM,QAAQ,GAAG,cAAc,CAAC;AAC9B,QAAA,EAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAC,EAAC;QACnF,cAAc;AAC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AC,WAAW,CAAC;;AAE3C;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;AACI,eAAe,iBAAiB,CACrC,SAAiE,EACjE,OAAqF,EAAA;IAErF,MAAM,cAAc,GAAG,mBAAmB;IAC1C,MAAM,cAAc,GAAG,WAAW;IAClC,MAAM,YAAY,GAAG,SAAS;IAE9BD,eAAc,CAAC,cAAc,CAAC;AAC9B,IAAA,MAAM,WAAW,GAAG,oBAAoB,CAAC,OAAO,CAAC;AACjD,IAAA,IAAI;QACFA,eAAc,CAAC,cAAc,CAAC;QAC9B,MAAM,cAAc,GAAG,MAAM,SAAS,CAAC,EAAC,WAAW,EAAC,CAAC;QACrDC,cAAa,CAAC,cAAc,CAAC;QAE7BD,eAAc,CAAC,YAAY,CAAC;QAE5B,MAAM,cAAc,GAAG,YAAY;QACnCA,eAAc,CAAC,cAAc,CAAC;;AAE9B,QAAA,MAAM,cAAc,CAAC,UAAU,EAAE;QACjCC,cAAa,CAAC,cAAc,CAAC;QAE7B,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,WAAW,EAAE,cAAc,CAAC;QAClEA,cAAa,CAAC,YAAY,CAAC;AAC3B,QAAA,OAAO,QAAQ;;YACP;AACR,QAAA,MAAM,oBAAoB,CAAC,WAAW,CAAC;QACvCA,cAAa,CAAC,cAAc,CAAC;;AAEjC;;ACxVA;;;;AAIG;AAIH;;AAEG;MACU,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB;;;;"}
|
package/fesm2022/server.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.0.0-next.
|
|
2
|
+
* @license Angular v21.0.0-next.4
|
|
3
3
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { ɵsetRootDomAdapter as _setRootDomAdapter, DOCUMENT, XhrFactory, PlatformLocation, ɵgetDOM as _getDOM, ɵPLATFORM_SERVER_ID as _PLATFORM_SERVER_ID, ViewportScroller, ɵNullViewportScroller as _NullViewportScroller } from '@angular/common';
|
|
8
8
|
import * as i0 from '@angular/core';
|
|
9
|
-
import { InjectionToken, inject, Injector, ɵstartMeasuring as _startMeasuring, ɵstopMeasuring as _stopMeasuring, Injectable, Inject,
|
|
9
|
+
import { InjectionToken, inject, Injector, ɵstartMeasuring as _startMeasuring, ɵstopMeasuring as _stopMeasuring, Injectable, Inject, APP_ID, TransferState, PLATFORM_ID, PLATFORM_INITIALIZER, NgModule, ɵsetDocument as _setDocument, createPlatformFactory, platformCore, Testability, ɵTESTABILITY as _TESTABILITY } from '@angular/core';
|
|
10
10
|
import { ɵBrowserDomAdapter as _BrowserDomAdapter, EventManagerPlugin, EVENT_MANAGER_PLUGINS, BrowserModule } from '@angular/platform-browser';
|
|
11
11
|
import { ɵHTTP_ROOT_INTERCEPTOR_FNS as _HTTP_ROOT_INTERCEPTOR_FNS } from '@angular/common/http';
|
|
12
12
|
import { Subject } from 'rxjs';
|
|
@@ -17207,10 +17207,10 @@ class PlatformState {
|
|
|
17207
17207
|
getDocument() {
|
|
17208
17208
|
return this._doc;
|
|
17209
17209
|
}
|
|
17210
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
17211
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
17210
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0-next.4", ngImport: i0, type: PlatformState, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
17211
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.0-next.4", ngImport: i0, type: PlatformState });
|
|
17212
17212
|
}
|
|
17213
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
17213
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0-next.4", ngImport: i0, type: PlatformState, decorators: [{
|
|
17214
17214
|
type: Injectable
|
|
17215
17215
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
17216
17216
|
type: Inject,
|
|
@@ -17239,10 +17239,10 @@ class ServerXhr {
|
|
|
17239
17239
|
}
|
|
17240
17240
|
return new impl.XMLHttpRequest();
|
|
17241
17241
|
}
|
|
17242
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
17243
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
17242
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0-next.4", ngImport: i0, type: ServerXhr, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
17243
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.0-next.4", ngImport: i0, type: ServerXhr });
|
|
17244
17244
|
}
|
|
17245
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
17245
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0-next.4", ngImport: i0, type: ServerXhr, decorators: [{
|
|
17246
17246
|
type: Injectable
|
|
17247
17247
|
}] });
|
|
17248
17248
|
function relativeUrlsTransformerInterceptorFn(request, next) {
|
|
@@ -17286,7 +17286,6 @@ function parseUrl(urlStr) {
|
|
|
17286
17286
|
* but not the state stack.
|
|
17287
17287
|
*/
|
|
17288
17288
|
class ServerPlatformLocation {
|
|
17289
|
-
_doc;
|
|
17290
17289
|
href = '/';
|
|
17291
17290
|
hostname = '/';
|
|
17292
17291
|
protocol = '/';
|
|
@@ -17295,9 +17294,9 @@ class ServerPlatformLocation {
|
|
|
17295
17294
|
search = '';
|
|
17296
17295
|
hash = '';
|
|
17297
17296
|
_hashUpdate = new Subject();
|
|
17298
|
-
|
|
17299
|
-
|
|
17300
|
-
const config =
|
|
17297
|
+
_doc = inject(DOCUMENT);
|
|
17298
|
+
constructor() {
|
|
17299
|
+
const config = inject(INITIAL_CONFIG, { optional: true });
|
|
17301
17300
|
if (!config) {
|
|
17302
17301
|
return;
|
|
17303
17302
|
}
|
|
@@ -17309,7 +17308,7 @@ class ServerPlatformLocation {
|
|
|
17309
17308
|
this.pathname = url.pathname;
|
|
17310
17309
|
this.search = url.search;
|
|
17311
17310
|
this.hash = url.hash;
|
|
17312
|
-
this.href = _doc.location.href;
|
|
17311
|
+
this.href = this._doc.location.href;
|
|
17313
17312
|
}
|
|
17314
17313
|
}
|
|
17315
17314
|
getBaseHrefFromDOM() {
|
|
@@ -17361,20 +17360,12 @@ class ServerPlatformLocation {
|
|
|
17361
17360
|
getState() {
|
|
17362
17361
|
return undefined;
|
|
17363
17362
|
}
|
|
17364
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
17365
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
17363
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0-next.4", ngImport: i0, type: ServerPlatformLocation, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
17364
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.0-next.4", ngImport: i0, type: ServerPlatformLocation });
|
|
17366
17365
|
}
|
|
17367
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
17366
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0-next.4", ngImport: i0, type: ServerPlatformLocation, decorators: [{
|
|
17368
17367
|
type: Injectable
|
|
17369
|
-
}], ctorParameters: () => [
|
|
17370
|
-
type: Inject,
|
|
17371
|
-
args: [DOCUMENT]
|
|
17372
|
-
}] }, { type: undefined, decorators: [{
|
|
17373
|
-
type: Optional
|
|
17374
|
-
}, {
|
|
17375
|
-
type: Inject,
|
|
17376
|
-
args: [INITIAL_CONFIG]
|
|
17377
|
-
}] }] });
|
|
17368
|
+
}], ctorParameters: () => [] });
|
|
17378
17369
|
|
|
17379
17370
|
class ServerEventManagerPlugin extends EventManagerPlugin {
|
|
17380
17371
|
doc;
|
|
@@ -17389,10 +17380,10 @@ class ServerEventManagerPlugin extends EventManagerPlugin {
|
|
|
17389
17380
|
addEventListener(element, eventName, handler, options) {
|
|
17390
17381
|
return _getDOM().onAndCancel(element, eventName, handler, options);
|
|
17391
17382
|
}
|
|
17392
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
17393
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
17383
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0-next.4", ngImport: i0, type: ServerEventManagerPlugin, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
17384
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.0-next.4", ngImport: i0, type: ServerEventManagerPlugin });
|
|
17394
17385
|
}
|
|
17395
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
17386
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0-next.4", ngImport: i0, type: ServerEventManagerPlugin, decorators: [{
|
|
17396
17387
|
type: Injectable
|
|
17397
17388
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
17398
17389
|
type: Inject,
|
|
@@ -17467,19 +17458,18 @@ function serializeTransferStateFactory() {
|
|
|
17467
17458
|
}
|
|
17468
17459
|
|
|
17469
17460
|
const INTERNAL_SERVER_PLATFORM_PROVIDERS = [
|
|
17470
|
-
{ provide: DOCUMENT, useFactory: _document
|
|
17461
|
+
{ provide: DOCUMENT, useFactory: _document },
|
|
17471
17462
|
{ provide: PLATFORM_ID, useValue: _PLATFORM_SERVER_ID },
|
|
17472
|
-
{ provide: PLATFORM_INITIALIZER, useFactory: initDominoAdapter, multi: true
|
|
17463
|
+
{ provide: PLATFORM_INITIALIZER, useFactory: initDominoAdapter, multi: true },
|
|
17473
17464
|
{
|
|
17474
17465
|
provide: PlatformLocation,
|
|
17475
17466
|
useClass: ServerPlatformLocation,
|
|
17476
|
-
deps: [
|
|
17467
|
+
deps: [],
|
|
17477
17468
|
},
|
|
17478
17469
|
{ provide: PlatformState, deps: [DOCUMENT] },
|
|
17479
|
-
// Add special provider that allows multiple instances of platformServer* to be created.
|
|
17480
|
-
{ provide: _ALLOW_MULTIPLE_PLATFORMS, useValue: true },
|
|
17481
17470
|
];
|
|
17482
|
-
function initDominoAdapter(
|
|
17471
|
+
function initDominoAdapter() {
|
|
17472
|
+
const injector = inject(Injector);
|
|
17483
17473
|
const _enableDomEmulation = enableDomEmulation(injector);
|
|
17484
17474
|
return () => {
|
|
17485
17475
|
if (_enableDomEmulation) {
|
|
@@ -17507,18 +17497,19 @@ const PLATFORM_SERVER_PROVIDERS = [
|
|
|
17507
17497
|
* @publicApi
|
|
17508
17498
|
*/
|
|
17509
17499
|
class ServerModule {
|
|
17510
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
17511
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
17512
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
17500
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0-next.4", ngImport: i0, type: ServerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
17501
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.0.0-next.4", ngImport: i0, type: ServerModule, exports: [BrowserModule] });
|
|
17502
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.0.0-next.4", ngImport: i0, type: ServerModule, providers: PLATFORM_SERVER_PROVIDERS, imports: [BrowserModule] });
|
|
17513
17503
|
}
|
|
17514
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
17504
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0-next.4", ngImport: i0, type: ServerModule, decorators: [{
|
|
17515
17505
|
type: NgModule,
|
|
17516
17506
|
args: [{
|
|
17517
17507
|
exports: [BrowserModule],
|
|
17518
17508
|
providers: PLATFORM_SERVER_PROVIDERS,
|
|
17519
17509
|
}]
|
|
17520
17510
|
}] });
|
|
17521
|
-
function _document(
|
|
17511
|
+
function _document() {
|
|
17512
|
+
const injector = inject(Injector);
|
|
17522
17513
|
const config = injector.get(INITIAL_CONFIG, null);
|
|
17523
17514
|
const _enableDomEmulation = enableDomEmulation(injector);
|
|
17524
17515
|
let document;
|
|
@@ -17538,6 +17529,13 @@ function _document(injector) {
|
|
|
17538
17529
|
return document;
|
|
17539
17530
|
}
|
|
17540
17531
|
/**
|
|
17532
|
+
* Creates a server-side instance of an Angular platform.
|
|
17533
|
+
*
|
|
17534
|
+
* This platform should be used when performing server-side rendering of an Angular application.
|
|
17535
|
+
* Standalone applications can be bootstrapped on the server using the `bootstrapApplication`
|
|
17536
|
+
* function from `@angular/platform-browser`. When using `bootstrapApplication`, the `platformServer`
|
|
17537
|
+
* should be created first and passed to the bootstrap function using the `BootstrapContext`.
|
|
17538
|
+
*
|
|
17541
17539
|
* @publicApi
|
|
17542
17540
|
*/
|
|
17543
17541
|
function platformServer(extraProviders) {
|