@angular/platform-server 21.1.0-rc.0 → 21.1.0
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/_server-chunk.mjs +17 -17
- package/fesm2022/init.mjs +1 -1
- package/fesm2022/platform-server.mjs +2 -2
- package/fesm2022/platform-server.mjs.map +1 -1
- package/fesm2022/testing.mjs +5 -5
- package/package.json +5 -5
- package/types/init.d.ts +1 -1
- package/types/platform-server.d.ts +1 -1
- package/types/testing.d.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.1.0
|
|
2
|
+
* @license Angular v21.1.0
|
|
3
3
|
* (c) 2010-2026 Google LLC. https://angular.dev/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -110,7 +110,7 @@ class PlatformState {
|
|
|
110
110
|
}
|
|
111
111
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
112
112
|
minVersion: "12.0.0",
|
|
113
|
-
version: "21.1.0
|
|
113
|
+
version: "21.1.0",
|
|
114
114
|
ngImport: i0,
|
|
115
115
|
type: PlatformState,
|
|
116
116
|
deps: [{
|
|
@@ -120,14 +120,14 @@ class PlatformState {
|
|
|
120
120
|
});
|
|
121
121
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
122
122
|
minVersion: "12.0.0",
|
|
123
|
-
version: "21.1.0
|
|
123
|
+
version: "21.1.0",
|
|
124
124
|
ngImport: i0,
|
|
125
125
|
type: PlatformState
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
128
|
i0.ɵɵngDeclareClassMetadata({
|
|
129
129
|
minVersion: "12.0.0",
|
|
130
|
-
version: "21.1.0
|
|
130
|
+
version: "21.1.0",
|
|
131
131
|
ngImport: i0,
|
|
132
132
|
type: PlatformState,
|
|
133
133
|
decorators: [{
|
|
@@ -164,7 +164,7 @@ class ServerXhr {
|
|
|
164
164
|
}
|
|
165
165
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
166
166
|
minVersion: "12.0.0",
|
|
167
|
-
version: "21.1.0
|
|
167
|
+
version: "21.1.0",
|
|
168
168
|
ngImport: i0,
|
|
169
169
|
type: ServerXhr,
|
|
170
170
|
deps: [],
|
|
@@ -172,14 +172,14 @@ class ServerXhr {
|
|
|
172
172
|
});
|
|
173
173
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
174
174
|
minVersion: "12.0.0",
|
|
175
|
-
version: "21.1.0
|
|
175
|
+
version: "21.1.0",
|
|
176
176
|
ngImport: i0,
|
|
177
177
|
type: ServerXhr
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
180
|
i0.ɵɵngDeclareClassMetadata({
|
|
181
181
|
minVersion: "12.0.0",
|
|
182
|
-
version: "21.1.0
|
|
182
|
+
version: "21.1.0",
|
|
183
183
|
ngImport: i0,
|
|
184
184
|
type: ServerXhr,
|
|
185
185
|
decorators: [{
|
|
@@ -314,7 +314,7 @@ class ServerPlatformLocation {
|
|
|
314
314
|
}
|
|
315
315
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
316
316
|
minVersion: "12.0.0",
|
|
317
|
-
version: "21.1.0
|
|
317
|
+
version: "21.1.0",
|
|
318
318
|
ngImport: i0,
|
|
319
319
|
type: ServerPlatformLocation,
|
|
320
320
|
deps: [],
|
|
@@ -322,14 +322,14 @@ class ServerPlatformLocation {
|
|
|
322
322
|
});
|
|
323
323
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
324
324
|
minVersion: "12.0.0",
|
|
325
|
-
version: "21.1.0
|
|
325
|
+
version: "21.1.0",
|
|
326
326
|
ngImport: i0,
|
|
327
327
|
type: ServerPlatformLocation
|
|
328
328
|
});
|
|
329
329
|
}
|
|
330
330
|
i0.ɵɵngDeclareClassMetadata({
|
|
331
331
|
minVersion: "12.0.0",
|
|
332
|
-
version: "21.1.0
|
|
332
|
+
version: "21.1.0",
|
|
333
333
|
ngImport: i0,
|
|
334
334
|
type: ServerPlatformLocation,
|
|
335
335
|
decorators: [{
|
|
@@ -352,7 +352,7 @@ class ServerEventManagerPlugin extends EventManagerPlugin {
|
|
|
352
352
|
}
|
|
353
353
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
354
354
|
minVersion: "12.0.0",
|
|
355
|
-
version: "21.1.0
|
|
355
|
+
version: "21.1.0",
|
|
356
356
|
ngImport: i0,
|
|
357
357
|
type: ServerEventManagerPlugin,
|
|
358
358
|
deps: [{
|
|
@@ -362,14 +362,14 @@ class ServerEventManagerPlugin extends EventManagerPlugin {
|
|
|
362
362
|
});
|
|
363
363
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
364
364
|
minVersion: "12.0.0",
|
|
365
|
-
version: "21.1.0
|
|
365
|
+
version: "21.1.0",
|
|
366
366
|
ngImport: i0,
|
|
367
367
|
type: ServerEventManagerPlugin
|
|
368
368
|
});
|
|
369
369
|
}
|
|
370
370
|
i0.ɵɵngDeclareClassMetadata({
|
|
371
371
|
minVersion: "12.0.0",
|
|
372
|
-
version: "21.1.0
|
|
372
|
+
version: "21.1.0",
|
|
373
373
|
ngImport: i0,
|
|
374
374
|
type: ServerEventManagerPlugin,
|
|
375
375
|
decorators: [{
|
|
@@ -479,7 +479,7 @@ const PLATFORM_SERVER_PROVIDERS = [TRANSFER_STATE_SERIALIZATION_PROVIDERS, SERVE
|
|
|
479
479
|
class ServerModule {
|
|
480
480
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
481
481
|
minVersion: "12.0.0",
|
|
482
|
-
version: "21.1.0
|
|
482
|
+
version: "21.1.0",
|
|
483
483
|
ngImport: i0,
|
|
484
484
|
type: ServerModule,
|
|
485
485
|
deps: [],
|
|
@@ -487,14 +487,14 @@ class ServerModule {
|
|
|
487
487
|
});
|
|
488
488
|
static ɵmod = i0.ɵɵngDeclareNgModule({
|
|
489
489
|
minVersion: "14.0.0",
|
|
490
|
-
version: "21.1.0
|
|
490
|
+
version: "21.1.0",
|
|
491
491
|
ngImport: i0,
|
|
492
492
|
type: ServerModule,
|
|
493
493
|
exports: [BrowserModule]
|
|
494
494
|
});
|
|
495
495
|
static ɵinj = i0.ɵɵngDeclareInjector({
|
|
496
496
|
minVersion: "12.0.0",
|
|
497
|
-
version: "21.1.0
|
|
497
|
+
version: "21.1.0",
|
|
498
498
|
ngImport: i0,
|
|
499
499
|
type: ServerModule,
|
|
500
500
|
providers: PLATFORM_SERVER_PROVIDERS,
|
|
@@ -503,7 +503,7 @@ class ServerModule {
|
|
|
503
503
|
}
|
|
504
504
|
i0.ɵɵngDeclareClassMetadata({
|
|
505
505
|
minVersion: "12.0.0",
|
|
506
|
-
version: "21.1.0
|
|
506
|
+
version: "21.1.0",
|
|
507
507
|
ngImport: i0,
|
|
508
508
|
type: ServerModule,
|
|
509
509
|
decorators: [{
|
package/fesm2022/init.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.1.0
|
|
2
|
+
* @license Angular v21.1.0
|
|
3
3
|
* (c) 2010-2026 Google LLC. https://angular.dev/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -179,7 +179,7 @@ async function renderApplication(bootstrap, options) {
|
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
const VERSION = /* @__PURE__ */new Version('21.1.0
|
|
182
|
+
const VERSION = /* @__PURE__ */new Version('21.1.0');
|
|
183
183
|
|
|
184
184
|
export { BEFORE_APP_SERIALIZED, INITIAL_CONFIG, PlatformState, VERSION, platformServer, provideServerRendering, renderApplication, renderModule, SERVER_CONTEXT as ɵSERVER_CONTEXT, renderInternal as ɵrenderInternal };
|
|
185
185
|
//# sourceMappingURL=platform-server.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-server.mjs","sources":["../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/platform-server/src/provide_server.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/platform-server/src/utils.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/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 = /* @__PURE__ */ new Version('21.1.0-rc.0');\n"],"names":["provideServerRendering","ngServerMode","globalThis","makeEnvironmentProviders","PLATFORM_SERVER_PROVIDERS","EVENT_DISPATCH_SCRIPT_ID","createServerPlatform","options","extraProviders","platformProviders","measuringLabel","startMeasuring","platform","platformServer","provide","INITIAL_CONFIG","useValue","document","url","stopMeasuring","findEventDispatchScript","doc","getElementById","removeEventDispatchScript","remove","prepareForHydration","platformState","applicationRef","environmentInjector","injector","getDocument","get","IS_HYDRATION_DOM_REUSE_ENABLED","appendSsrContentIntegrityMarker","eventTypesToReplay","annotateForHydration","regular","size","capture","insertEventRecordScript","APP_ID","CSP_NONCE","comment","createComment","SSR_CONTENT_INTEGRITY_MARKER","body","firstChild","insertBefore","append","appendServerContextInfo","serverContext","sanitizeServerContext","SERVER_CONTEXT","DEFAULT_SERVER_CONTEXT","components","forEach","componentRef","renderer","Renderer2","element","location","nativeElement","setAttribute","appId","nonce","eventDispatchScript","replayScriptContents","JSON","stringify","Array","from","replayScript","createScript","after","renderInternal","platformRef","PlatformState","callbacks","BEFORE_APP_SERIALIZED","asyncCallbacks","callback","callbackResult","push","e","console","warn","length","result","Promise","allSettled","status","reason","renderToString","asyncDestroyPlatform","resolve","setTimeout","destroy","InjectionToken","context","replace","renderModule","moduleType","moduleRef","bootstrapModule","ApplicationRef","whenStable","renderApplication","bootstrap","renderAppLabel","bootstrapLabel","_renderLabel","rendered","VERSION","Version"],"mappings":";;;;;;;;;;;;;;SA2BgBA,sBAAsBA,GAAA;AACpC,EAAA,IAAI,OAAOC,YAAY,KAAK,WAAW,EAAE;AACvCC,IAAAA,UAAU,CAAC,cAAc,CAAC,GAAG,IAAI;AACnC;AAEA,EAAA,OAAOC,wBAAwB,CAAC,CAAC,GAAGC,yBAAyB,CAAC,CAAC;AACjE;;ACMO,MAAMC,wBAAwB,GAAG,4BAA4B;AAYpE,SAASC,oBAAoBA,CAACC,OAAwB,EAAA;AACpD,EAAA,MAAMC,cAAc,GAAGD,OAAO,CAACE,iBAAiB,IAAI,EAAE;EACtD,MAAMC,cAAc,GAAG,sBAAsB;EAC7CC,eAAc,CAACD,cAAc,CAAC;AAE9B,EAAA,MAAME,QAAQ,GAAGC,cAAc,CAAC,CAC9B;AAACC,IAAAA,OAAO,EAAEC,cAAc;AAAEC,IAAAA,QAAQ,EAAE;MAACC,QAAQ,EAAEV,OAAO,CAACU,QAAQ;MAAEC,GAAG,EAAEX,OAAO,CAACW;;GAAK,EACnFV,cAAc,CACf,CAAC;EAEFW,cAAa,CAACT,cAAc,CAAC;AAC7B,EAAA,OAAOE,QAAQ;AACjB;AAMA,SAASQ,uBAAuBA,CAACC,GAAa,EAAA;AAC5C,EAAA,OAAOA,G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AAU;IACR,MAAMkE,oBAAoB,CAAClB,WAAW,CAAC;AACzC;AACF;AAgCO,eAAe+B,iBAAiBA,CACrCC,SAAiE,EACjEpG,OAAqF,EAAA;EAErF,MAAMqG,cAAc,GAAG,mBAAmB;EAC1C,MAAMC,cAAc,GAAG,WAAW;EAClC,MAAMC,YAAY,GAAG,SAAS;EAE9BnG,eAAc,CAACiG,cAAc,CAAC;AAC9B,EAAA,MAAMjC,WAAW,GAAGrE,oBAAoB,CAACC,OAAO,CAAC;EACjD,IAAI;IACFI,eAAc,CAACkG,cAAc,CAAC;AAC9B,IAAA,MAAMlF,cAAc,GAAG,MAAMgF,SAAS,CAAC;AAAChC,MAAAA;AAAY,KAAA,CAAC;IACrDxD,cAAa,CAAC0F,cAAc,CAAC;IAE7BlG,eAAc,CAACmG,YAAY,CAAC;IAE5B,MAAMpG,cAAc,GAAG,YAAY;IACnCC,eAAc,CAACD,cAAc,CAAC;AAE9B,IAAA,MAAMiB,cAAc,CAAC8E,UAAU,EAAE;IACjCtF,cAAa,CAACT,cAAc,CAAC;IAE7B,MAAMqG,QAAQ,GAAG,MAAMrC,cAAc,CAACC,WAAW,EAAEhD,cAAc,CAAC;IAClER,cAAa,CAAC2F,YAAY,CAAC;AAC3B,IAAA,OAAOC,QAAQ;AACjB,GAAA,SAAU;IACR,MAAMlB,oBAAoB,CAAClB,WAAW,CAAC;IACvCxD,cAAa,CAACyF,cAAc,CAAC;AAC/B;AACF;;AC7UO,MAAMI,OAAO,kBAAmB,IAAIC,OAAO,CAAC,mBAAmB;;;;"}
|
|
1
|
+
{"version":3,"file":"platform-server.mjs","sources":["../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/platform-server/src/provide_server.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/platform-server/src/utils.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/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 = /* @__PURE__ */ new Version('21.1.0');\n"],"names":["provideServerRendering","ngServerMode","globalThis","makeEnvironmentProviders","PLATFORM_SERVER_PROVIDERS","EVENT_DISPATCH_SCRIPT_ID","createServerPlatform","options","extraProviders","platformProviders","measuringLabel","startMeasuring","platform","platformServer","provide","INITIAL_CONFIG","useValue","document","url","stopMeasuring","findEventDispatchScript","doc","getElementById","removeEventDispatchScript","remove","prepareForHydration","platformState","applicationRef","environmentInjector","injector","getDocument","get","IS_HYDRATION_DOM_REUSE_ENABLED","appendSsrContentIntegrityMarker","eventTypesToReplay","annotateForHydration","regular","size","capture","insertEventRecordScript","APP_ID","CSP_NONCE","comment","createComment","SSR_CONTENT_INTEGRITY_MARKER","body","firstChild","insertBefore","append","appendServerContextInfo","serverContext","sanitizeServerContext","SERVER_CONTEXT","DEFAULT_SERVER_CONTEXT","components","forEach","componentRef","renderer","Renderer2","element","location","nativeElement","setAttribute","appId","nonce","eventDispatchScript","replayScriptContents","JSON","stringify","Array","from","replayScript","createScript","after","renderInternal","platformRef","PlatformState","callbacks","BEFORE_APP_SERIALIZED","asyncCallbacks","callback","callbackResult","push","e","console","warn","length","result","Promise","allSettled","status","reason","renderToString","asyncDestroyPlatform","resolve","setTimeout","destroy","InjectionToken","context","replace","renderModule","moduleType","moduleRef","bootstrapModule","ApplicationRef","whenStable","renderApplication","bootstrap","renderAppLabel","bootstrapLabel","_renderLabel","rendered","VERSION","Version"],"mappings":";;;;;;;;;;;;;;SA2BgBA,sBAAsBA,GAAA;AACpC,EAAA,IAAI,OAAOC,YAAY,KAAK,WAAW,EAAE;AACvCC,IAAAA,UAAU,CAAC,cAAc,CAAC,GAAG,IAAI;AACnC;AAEA,EAAA,OAAOC,wBAAwB,CAAC,CAAC,GAAGC,yBAAyB,CAAC,CAAC;AACjE;;ACMO,MAAMC,wBAAwB,GAAG,4BAA4B;AAYpE,SAASC,oBAAoBA,CAACC,OAAwB,EAAA;AACpD,EAAA,MAAMC,cAAc,GAAGD,OAAO,CAACE,iBAAiB,IAAI,EAAE;EACtD,MAAMC,cAAc,GAAG,sBAAsB;EAC7CC,eAAc,CAACD,cAAc,CAAC;AAE9B,EAAA,MAAME,QAAQ,GAAGC,cAAc,CAAC,CAC9B;AAACC,IAAAA,OAAO,EAAEC,cAAc;AAAEC,IAAAA,QAAQ,EAAE;MAACC,QAAQ,EAAEV,OAAO,CAACU,QAAQ;MAAEC,GAAG,EAAEX,OAAO,CAACW;;GAAK,EACnFV,cAAc,CACf,CAAC;EAEFW,cAAa,CAACT,cAAc,CAAC;AAC7B,EAAA,OAAOE,QAAQ;AACjB;AAMA,SAASQ,uBAAuBA,CAACC,GAAa,EAAA;AAC5C,EAAA,OAAOA,GAAG,CAACC,cAAc,CAACjB,wBAAwB,CAAC;AACrD;AAMA,SAASkB,yBAAyBA,CAACF,GAAa,EAAA;AAC9CD,EAAAA,uBAAuB,CAACC,GAAG,CAAC,EAAEG,MAAM,EAA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mBAAmB;EAC1C,MAAMC,cAAc,GAAG,WAAW;EAClC,MAAMC,YAAY,GAAG,SAAS;EAE9BnG,eAAc,CAACiG,cAAc,CAAC;AAC9B,EAAA,MAAMjC,WAAW,GAAGrE,oBAAoB,CAACC,OAAO,CAAC;EACjD,IAAI;IACFI,eAAc,CAACkG,cAAc,CAAC;AAC9B,IAAA,MAAMlF,cAAc,GAAG,MAAMgF,SAAS,CAAC;AAAChC,MAAAA;AAAY,KAAA,CAAC;IACrDxD,cAAa,CAAC0F,cAAc,CAAC;IAE7BlG,eAAc,CAACmG,YAAY,CAAC;IAE5B,MAAMpG,cAAc,GAAG,YAAY;IACnCC,eAAc,CAACD,cAAc,CAAC;AAE9B,IAAA,MAAMiB,cAAc,CAAC8E,UAAU,EAAE;IACjCtF,cAAa,CAACT,cAAc,CAAC;IAE7B,MAAMqG,QAAQ,GAAG,MAAMrC,cAAc,CAACC,WAAW,EAAEhD,cAAc,CAAC;IAClER,cAAa,CAAC2F,YAAY,CAAC;AAC3B,IAAA,OAAOC,QAAQ;AACjB,GAAA,SAAU;IACR,MAAMlB,oBAAoB,CAAClB,WAAW,CAAC;IACvCxD,cAAa,CAACyF,cAAc,CAAC;AAC/B;AACF;;AC7UO,MAAMI,OAAO,kBAAmB,IAAIC,OAAO,CAAC,mBAAmB;;;;"}
|
package/fesm2022/testing.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.1.0
|
|
2
|
+
* @license Angular v21.1.0
|
|
3
3
|
* (c) 2010-2026 Google LLC. https://angular.dev/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -18,7 +18,7 @@ const platformServerTesting = createPlatformFactory(platformCore, 'serverTesting
|
|
|
18
18
|
class ServerTestingModule {
|
|
19
19
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
20
20
|
minVersion: "12.0.0",
|
|
21
|
-
version: "21.1.0
|
|
21
|
+
version: "21.1.0",
|
|
22
22
|
ngImport: i0,
|
|
23
23
|
type: ServerTestingModule,
|
|
24
24
|
deps: [],
|
|
@@ -26,14 +26,14 @@ class ServerTestingModule {
|
|
|
26
26
|
});
|
|
27
27
|
static ɵmod = i0.ɵɵngDeclareNgModule({
|
|
28
28
|
minVersion: "14.0.0",
|
|
29
|
-
version: "21.1.0
|
|
29
|
+
version: "21.1.0",
|
|
30
30
|
ngImport: i0,
|
|
31
31
|
type: ServerTestingModule,
|
|
32
32
|
exports: [BrowserDynamicTestingModule]
|
|
33
33
|
});
|
|
34
34
|
static ɵinj = i0.ɵɵngDeclareInjector({
|
|
35
35
|
minVersion: "12.0.0",
|
|
36
|
-
version: "21.1.0
|
|
36
|
+
version: "21.1.0",
|
|
37
37
|
ngImport: i0,
|
|
38
38
|
type: ServerTestingModule,
|
|
39
39
|
providers: SERVER_RENDER_PROVIDERS,
|
|
@@ -42,7 +42,7 @@ class ServerTestingModule {
|
|
|
42
42
|
}
|
|
43
43
|
i0.ɵɵngDeclareClassMetadata({
|
|
44
44
|
minVersion: "12.0.0",
|
|
45
|
-
version: "21.1.0
|
|
45
|
+
version: "21.1.0",
|
|
46
46
|
ngImport: i0,
|
|
47
47
|
type: ServerTestingModule,
|
|
48
48
|
decorators: [{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/platform-server",
|
|
3
|
-
"version": "21.1.0
|
|
3
|
+
"version": "21.1.0",
|
|
4
4
|
"description": "Angular - library for using Angular in Node.js",
|
|
5
5
|
"author": "angular",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
|
-
"@angular/common": "21.1.0
|
|
12
|
-
"@angular/compiler": "21.1.0
|
|
13
|
-
"@angular/core": "21.1.0
|
|
14
|
-
"@angular/platform-browser": "21.1.0
|
|
11
|
+
"@angular/common": "21.1.0",
|
|
12
|
+
"@angular/compiler": "21.1.0",
|
|
13
|
+
"@angular/core": "21.1.0",
|
|
14
|
+
"@angular/platform-browser": "21.1.0",
|
|
15
15
|
"rxjs": "^6.5.3 || ^7.4.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
package/types/init.d.ts
CHANGED
package/types/testing.d.ts
CHANGED