@angular/platform-server 17.0.0-rc.0 → 17.0.0-rc.2

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.
@@ -1,17 +1,16 @@
1
1
  /**
2
- * @license Angular v17.0.0-rc.0
2
+ * @license Angular v17.0.0-rc.2
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
7
- import { ɵsetRootDomAdapter, DOCUMENT, XhrFactory, ɵgetDOM, ɵPLATFORM_SERVER_ID, PlatformLocation, ViewportScroller, ɵNullViewportScroller } from '@angular/common';
7
+ import { ɵsetRootDomAdapter, DOCUMENT, PlatformLocation, XhrFactory, ɵgetDOM, ɵPLATFORM_SERVER_ID, ViewportScroller, ɵNullViewportScroller } from '@angular/common';
8
8
  import * as i0 from '@angular/core';
9
- import { Injectable, Inject, InjectionToken, Optional, APP_ID, TransferState, NgModule, Injector, PLATFORM_ID, PLATFORM_INITIALIZER, ɵALLOW_MULTIPLE_PLATFORMS, Testability, ɵTESTABILITY, ɵsetDocument, createPlatformFactory, platformCore, makeEnvironmentProviders, ɵSSR_CONTENT_INTEGRITY_MARKER, ɵENABLED_SSR_FEATURES, Renderer2, ɵwhenStable, ɵIS_HYDRATION_DOM_REUSE_ENABLED, ɵannotateForHydration, ApplicationRef, Version } from '@angular/core';
9
+ import { Injectable, Inject, inject, InjectionToken, Optional, APP_ID, TransferState, NgModule, Injector, PLATFORM_ID, PLATFORM_INITIALIZER, ɵALLOW_MULTIPLE_PLATFORMS, Testability, ɵTESTABILITY, ɵsetDocument, createPlatformFactory, platformCore, makeEnvironmentProviders, ɵSSR_CONTENT_INTEGRITY_MARKER, Renderer2, ɵwhenStable, ɵIS_HYDRATION_DOM_REUSE_ENABLED, ɵannotateForHydration, ApplicationRef, Version } from '@angular/core';
10
10
  import { ɵBrowserDomAdapter, EventManagerPlugin, EVENT_MANAGER_PLUGINS, BrowserModule } from '@angular/platform-browser';
11
11
  import { NoopAnimationsModule, provideNoopAnimations } from '@angular/platform-browser/animations';
12
- import { HttpClientModule } from '@angular/common/http';
12
+ import { ɵHTTP_ROOT_INTERCEPTOR_FNS, HttpClientModule } from '@angular/common/http';
13
13
  import { Subject } from 'rxjs';
14
- import * as url from 'url';
15
14
 
16
15
  var __getOwnPropNames = Object.getOwnPropertyNames;
17
16
  var __commonJS = (cb, mod) => function __require() {
@@ -291,7 +290,7 @@ var require_DOMException = __commonJS({
291
290
  // external/npm/node_modules/domino/lib/config.js
292
291
  var require_config = __commonJS({
293
292
  "external/npm/node_modules/domino/lib/config.js"(exports) {
294
- exports.isApiWritable = !global.__domino_frozen__;
293
+ exports.isApiWritable = !globalThis.__domino_frozen__;
295
294
  }
296
295
  });
297
296
 
@@ -3713,8 +3712,9 @@ var require_Element = __commonJS({
3713
3712
  return this.element._attrsByLName[this.element._attrKeys[n]];
3714
3713
  } }
3715
3714
  });
3716
- if (global.Symbol && global.Symbol.iterator) {
3717
- AttributesArray.prototype[global.Symbol.iterator] = function() {
3715
+ var _a;
3716
+ if ((_a = globalThis.Symbol) == null ? void 0 : _a.iterator) {
3717
+ AttributesArray.prototype[globalThis.Symbol.iterator] = function() {
3718
3718
  var i = 0, n = this.length, self = this;
3719
3719
  return {
3720
3720
  next: function() {
@@ -16116,8 +16116,9 @@ var domino = require_lib();
16116
16116
 
16117
16117
  function setDomTypes() {
16118
16118
  // Make all Domino types available in the global env.
16119
- Object.assign(global, domino.impl);
16120
- global['KeyboardEvent'] = domino.impl.Event;
16119
+ // NB: Any changes here should also be done in `packages/platform-server/init/src/shims.ts`.
16120
+ Object.assign(globalThis, domino.impl);
16121
+ globalThis['KeyboardEvent'] = domino.impl.Event;
16121
16122
  }
16122
16123
  /**
16123
16124
  * Parses a document string to a Document object.
@@ -16215,10 +16216,10 @@ class PlatformState {
16215
16216
  getDocument() {
16216
16217
  return this._doc;
16217
16218
  }
16218
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: PlatformState, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
16219
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: PlatformState }); }
16219
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.2", ngImport: i0, type: PlatformState, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
16220
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.2", ngImport: i0, type: PlatformState }); }
16220
16221
  }
16221
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: PlatformState, decorators: [{
16222
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.2", ngImport: i0, type: PlatformState, decorators: [{
16222
16223
  type: Injectable
16223
16224
  }], ctorParameters: () => [{ type: undefined, decorators: [{
16224
16225
  type: Inject,
@@ -16243,14 +16244,34 @@ class ServerXhr {
16243
16244
  }
16244
16245
  return new impl.XMLHttpRequest();
16245
16246
  }
16246
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ServerXhr, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
16247
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ServerXhr }); }
16247
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.2", ngImport: i0, type: ServerXhr, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
16248
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.2", ngImport: i0, type: ServerXhr }); }
16248
16249
  }
16249
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ServerXhr, decorators: [{
16250
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.2", ngImport: i0, type: ServerXhr, decorators: [{
16250
16251
  type: Injectable
16251
16252
  }] });
16253
+ function relativeUrlsTransformerInterceptorFn(request, next) {
16254
+ const platformLocation = inject(PlatformLocation);
16255
+ const { href, protocol, hostname, port } = platformLocation;
16256
+ if (!protocol.startsWith('http')) {
16257
+ return next(request);
16258
+ }
16259
+ let urlPrefix = `${protocol}//${hostname}`;
16260
+ if (port) {
16261
+ urlPrefix += `:${port}`;
16262
+ }
16263
+ const baseHref = platformLocation.getBaseHrefFromDOM() || href;
16264
+ const baseUrl = new URL(baseHref, urlPrefix);
16265
+ const newUrl = new URL(request.url, baseUrl).toString();
16266
+ return next(request.clone({ url: newUrl }));
16267
+ }
16252
16268
  const SERVER_HTTP_PROVIDERS = [
16253
16269
  { provide: XhrFactory, useClass: ServerXhr },
16270
+ {
16271
+ provide: ɵHTTP_ROOT_INTERCEPTOR_FNS,
16272
+ useValue: relativeUrlsTransformerInterceptorFn,
16273
+ multi: true,
16274
+ },
16254
16275
  ];
16255
16276
 
16256
16277
  /**
@@ -16267,15 +16288,31 @@ const INITIAL_CONFIG = new InjectionToken('Server.INITIAL_CONFIG');
16267
16288
  */
16268
16289
  const BEFORE_APP_SERIALIZED = new InjectionToken('Server.RENDER_MODULE_HOOK');
16269
16290
 
16291
+ const RESOLVE_PROTOCOL = 'resolve:';
16270
16292
  function parseUrl(urlStr) {
16271
- const parsedUrl = url.parse(urlStr);
16293
+ let { hostname, protocol, port, pathname, search, hash } = new URL(urlStr, RESOLVE_PROTOCOL + '//');
16294
+ /**
16295
+ * TODO(alanagius): Remove the below in version 18.
16296
+ * The following are done to maintain the same behaviour as `url.parse`.
16297
+ * The main differences are;
16298
+ * - `pathname` is always suffixed with a `/`.
16299
+ * - `port` is empty when `http:` protocol and port in url is `80`
16300
+ * - `port` is empty when `https:` protocol and port in url is `443`
16301
+ */
16302
+ if (protocol !== RESOLVE_PROTOCOL && port === '' && /\:(80|443)/.test(urlStr)) {
16303
+ port = protocol === 'http:' ? '80' : '443';
16304
+ }
16305
+ if (protocol === RESOLVE_PROTOCOL && urlStr.charAt(0) !== '/') {
16306
+ pathname = pathname.slice(1); // Remove leading slash.
16307
+ }
16308
+ // END TODO
16272
16309
  return {
16273
- hostname: parsedUrl.hostname || '',
16274
- protocol: parsedUrl.protocol || '',
16275
- port: parsedUrl.port || '',
16276
- pathname: parsedUrl.pathname || '',
16277
- search: parsedUrl.search || '',
16278
- hash: parsedUrl.hash || '',
16310
+ hostname,
16311
+ protocol: protocol === RESOLVE_PROTOCOL ? '' : protocol,
16312
+ port,
16313
+ pathname,
16314
+ search,
16315
+ hash,
16279
16316
  };
16280
16317
  }
16281
16318
  /**
@@ -16361,10 +16398,10 @@ class ServerPlatformLocation {
16361
16398
  getState() {
16362
16399
  return undefined;
16363
16400
  }
16364
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ServerPlatformLocation, deps: [{ token: DOCUMENT }, { token: INITIAL_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
16365
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ServerPlatformLocation }); }
16401
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.2", ngImport: i0, type: ServerPlatformLocation, deps: [{ token: DOCUMENT }, { token: INITIAL_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
16402
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.2", ngImport: i0, type: ServerPlatformLocation }); }
16366
16403
  }
16367
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ServerPlatformLocation, decorators: [{
16404
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.2", ngImport: i0, type: ServerPlatformLocation, decorators: [{
16368
16405
  type: Injectable
16369
16406
  }], ctorParameters: () => [{ type: undefined, decorators: [{
16370
16407
  type: Inject,
@@ -16388,10 +16425,10 @@ class ServerEventManagerPlugin extends EventManagerPlugin {
16388
16425
  addEventListener(element, eventName, handler) {
16389
16426
  return ɵgetDOM().onAndCancel(element, eventName, handler);
16390
16427
  }
16391
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ServerEventManagerPlugin, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
16392
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ServerEventManagerPlugin }); }
16428
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.2", ngImport: i0, type: ServerEventManagerPlugin, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
16429
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.2", ngImport: i0, type: ServerEventManagerPlugin }); }
16393
16430
  }
16394
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ServerEventManagerPlugin, decorators: [{
16431
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.2", ngImport: i0, type: ServerEventManagerPlugin, decorators: [{
16395
16432
  type: Injectable
16396
16433
  }], ctorParameters: () => [{ type: undefined, decorators: [{
16397
16434
  type: Inject,
@@ -16436,11 +16473,11 @@ function serializeTransferStateFactory(doc, appId, transferStore) {
16436
16473
  * this module.
16437
16474
  */
16438
16475
  class ServerTransferStateModule {
16439
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ServerTransferStateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
16440
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ServerTransferStateModule }); }
16441
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ServerTransferStateModule }); }
16476
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.2", ngImport: i0, type: ServerTransferStateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
16477
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.0-rc.2", ngImport: i0, type: ServerTransferStateModule }); }
16478
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.0-rc.2", ngImport: i0, type: ServerTransferStateModule }); }
16442
16479
  }
16443
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ServerTransferStateModule, decorators: [{
16480
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.2", ngImport: i0, type: ServerTransferStateModule, decorators: [{
16444
16481
  type: NgModule,
16445
16482
  args: [{}]
16446
16483
  }] });
@@ -16479,11 +16516,11 @@ const PLATFORM_SERVER_PROVIDERS = [
16479
16516
  * @publicApi
16480
16517
  */
16481
16518
  class ServerModule {
16482
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ServerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
16483
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ServerModule, imports: [HttpClientModule, NoopAnimationsModule], exports: [BrowserModule] }); }
16484
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ServerModule, providers: PLATFORM_SERVER_PROVIDERS, imports: [HttpClientModule, NoopAnimationsModule, BrowserModule] }); }
16519
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.2", ngImport: i0, type: ServerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
16520
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.0-rc.2", ngImport: i0, type: ServerModule, imports: [HttpClientModule, NoopAnimationsModule], exports: [BrowserModule] }); }
16521
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.0-rc.2", ngImport: i0, type: ServerModule, providers: PLATFORM_SERVER_PROVIDERS, imports: [HttpClientModule, NoopAnimationsModule, BrowserModule] }); }
16485
16522
  }
16486
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ServerModule, decorators: [{
16523
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.2", ngImport: i0, type: ServerModule, decorators: [{
16487
16524
  type: NgModule,
16488
16525
  args: [{
16489
16526
  exports: [BrowserModule],
@@ -16571,11 +16608,6 @@ function appendSsrContentIntegrityMarker(doc) {
16571
16608
  function appendServerContextInfo(applicationRef) {
16572
16609
  const injector = applicationRef.injector;
16573
16610
  let serverContext = sanitizeServerContext(injector.get(SERVER_CONTEXT, DEFAULT_SERVER_CONTEXT));
16574
- const features = injector.get(ɵENABLED_SSR_FEATURES);
16575
- if (features.size > 0) {
16576
- // Append features information into the server context value.
16577
- serverContext += `|${Array.from(features).join(',')}`;
16578
- }
16579
16611
  applicationRef.components.forEach(componentRef => {
16580
16612
  const renderer = componentRef.injector.get(Renderer2);
16581
16613
  const element = componentRef.location.nativeElement;
@@ -16702,7 +16734,7 @@ async function renderApplication(bootstrap, options) {
16702
16734
  /**
16703
16735
  * @publicApi
16704
16736
  */
16705
- const VERSION = new Version('17.0.0-rc.0');
16737
+ const VERSION = new Version('17.0.0-rc.2');
16706
16738
 
16707
16739
  /// <reference types="node" />
16708
16740
  // This file only reexports content of the `src` folder. Keep it that way.
@@ -16713,5 +16745,5 @@ const VERSION = new Version('17.0.0-rc.0');
16713
16745
  * Generated bundle index. Do not edit.
16714
16746
  */
16715
16747
 
16716
- export { BEFORE_APP_SERIALIZED, INITIAL_CONFIG, PlatformState, ServerModule, ServerTransferStateModule, VERSION, platformDynamicServer, platformServer, provideServerRendering, renderApplication, renderModule, INTERNAL_SERVER_PLATFORM_PROVIDERS as ɵINTERNAL_SERVER_PLATFORM_PROVIDERS, SERVER_CONTEXT as ɵSERVER_CONTEXT, SERVER_RENDER_PROVIDERS as ɵSERVER_RENDER_PROVIDERS, setDomTypes as ɵsetDomTypes };
16748
+ export { BEFORE_APP_SERIALIZED, INITIAL_CONFIG, PlatformState, ServerModule, ServerTransferStateModule, VERSION, platformDynamicServer, platformServer, provideServerRendering, renderApplication, renderModule, INTERNAL_SERVER_PLATFORM_PROVIDERS as ɵINTERNAL_SERVER_PLATFORM_PROVIDERS, SERVER_CONTEXT as ɵSERVER_CONTEXT, SERVER_RENDER_PROVIDERS as ɵSERVER_RENDER_PROVIDERS };
16717
16749
  //# sourceMappingURL=platform-server.mjs.map