Commit graph

29561 commits

Author SHA1 Message Date
Alan Agius
c934a8e72b fix(platform-browser): only add ng-app-id to style on server side (#49465)
This commit fixes an issue where it causes issues in G3 when we add `ng-app-id` on browser apps.

PR Close #49465
2023-03-17 17:26:27 +01:00
Kristiyan Kostadinov
20f718782c build: update to TypeScript 5 final (#49458)
Updates the Framework and AIO to the final version of TypeScript 5.

PR Close #49458
2023-03-17 14:50:05 +01:00
Kristiyan Kostadinov
17e9862653 feat(core): add API to provide CSP nonce for inline stylesheets (#49444)
Angular uses inline styles to insert the styles associated with a component. This violates the strict styles [Content Security Policy](https://web.dev/strict-csp/) which doesn't allow inline styles by default. One way to allow the styles to be applied is to set a `nonce` attribute on them, but because the code for inserting the stylesheets is deep inside the framework, users weren't able to provide it without accessing private APIs.

These changes add a new `CSP_NONCE` injection token that will allow users to provide a nonce, if their app is using CSP. If the token isn't provided, the framework will look for an `ngCspNonce` attribute on the app's root node instead. The latter approach is provided as a convenience for apps that render the `index.html` through a server, e.g. `<app ngCspNonce="{% randomNonceAddedByTheServer %}"></app>`.

This PR addresses adding the nonce to framework-generated styles. There will be follow-up PRs that add support for it in critical CSS tags in the CLI, and in Angular Material.

Fixes #6361.

PR Close #49444
2023-03-17 14:08:21 +01:00
Kristiyan Kostadinov
13dd614cd1 feat(compiler): add support for compile-time required inputs (#49453)
Adds support for marking a directive input as required. During template type checking, the compiler will verify that all required inputs have been specified and will raise a diagnostic if one or more are missing. Some specifics:
* Inputs are marked as required by passing an object literal with a `required: true` property to the `Input` decorator or into the `inputs` array.
* Required inputs imply that the directive can't work without them. This is why there's a new check that enforces that all required inputs of a host directive are exposed on the host.
* Required input diagnostics are reported through the `OutOfBandDiagnosticRecorder`, rather than generating a new structure in the TCB, because it allows us to provide a better error message.
* Currently required inputs are only supported during AOT compilation, because knowing which bindings are present during JIT can be tricky and may lead to increased bundle sizes.

Fixes #37706.

PR Close #49453
2023-03-17 11:49:17 +01:00
Alan Agius
9636910c01 refactor(platform-browser): rename ng-app style attribute to ng-app-id (#49424)
`ng-app` is an AngularJS attribute, see https://docs.angularjs.org/api/ng/directive/ngApp. Using this attribute on a non AngularJS element can cause DI issues in AngularJS when running an AngularJS and Angular application on the same page.

As such, we avoid such problems the Angular `ng-app` attribute is renamed to `ng-app-id`.

PR Close #49424
2023-03-17 10:46:03 +01:00
Alan Agius
9ab9a2a817 refactor(platform-browser): combine DomSharedStylesHost and SharedStylesHost (#49424)
The mentioned 2 classes have been combined since it is no longer required to have a separate `SharedStylesHost` for SSR. This changes also reduces the memory usage footprint as remove 1 Map that stores the CSS strings.

PR Close #49424
2023-03-17 10:46:03 +01:00
Alan Agius
8cf1baee2a refactor(platform-server): remove ServerStylesHost (#49424)
With the recent changes and refactors of `dom_renderer` having a separate `ServerStylesHost` is redundant.

PR Close #49424
2023-03-17 10:46:03 +01:00
Angular Robot
fa023dd41f build: update actions/checkout digest to 24cb908 (#49436)
See associated pull request for more information.

PR Close #49436
2023-03-17 08:38:14 +01:00
Virginia Dooley
ab3f8a3a7a docs: Optimize server interaction - insert updated link. (#49438)
PR Close #49438
2023-03-17 08:36:57 +01:00
Virginia Dooley
66fe827635 docs: Track and show request progress - insert updated link. (#49439)
PR Close #49439
2023-03-17 08:35:44 +01:00
Virginia Dooley
82102c1852 docs: Intercept requests - insert updated link. (#49446)
PR Close #49446
2023-03-17 08:34:15 +01:00
Alex Rickabaugh
e05f5bafab release: cut the v16.0.0-next.3 release 2023-03-16 12:17:26 -07:00
Alex Rickabaugh
e8ed065039 docs: release notes for the v15.2.3 release 2023-03-16 12:11:12 -07:00
Alex Rickabaugh
560b226a43 Revert "feat(compiler): add support for compile-time required inputs (#49304)" (#49449)
This reverts commit 1a6ca68154.

This breaks tests in google3 which might be depending on private APIs. We
need to update these tests before we can land this PR.

PR Close #49449
2023-03-16 10:38:04 -07:00
Angular Robot
92e41e9cb4 build: update actions/cache digest to 940f3d7 (#49377)
See associated pull request for more information.

PR Close #49377
2023-03-15 17:27:21 -07:00
Jessica Janiuk
81e974a99d refactor(core): Handle lost adjacent text nodes during hydration (#49419)
This restores the separation between adjacent text nodes that is lost during server serialization when parsed by the browser. It adds a special comment node just prior to the serialization process that is then restored as a separated node during hydration.

PR Close #49419
2023-03-15 17:25:10 -07:00
Jessica Janiuk
1116c492fa refactor(core): Handle cases of lost empty text nodes during hydration (#49419)
During DOM serialization, empty text nodes are lost when the client parses the DOM. To solve this problem comment nodes are added where the empty nodes are located right before serialization. Those comments then get replaced during hydration with the proper empty text nodes.

PR Close #49419
2023-03-15 17:25:10 -07:00
Alan Agius
67743340a7 test(common): update async pipe tests to fix test errors (#49433)
The below error is displayed during some tests

```js
ERROR: 'Unhandled Promise rejection:', 'Cannot read properties of null (reading 'markForCheck')', '; Zone:', 'ProxyZone', '; Task:', 'Promise.then', '; Value:', TypeError: Cannot read properties of null (reading 'markForCheck')
TypeError: Cannot read properties of null (reading 'markForCheck')
    at AsyncPipe2._updateLatestValue (http://angular-ci.local:9876/base/dist/legacy-test-bundle.spec.js?49174f830d8743d5c8a9551b77550b859b934291:51947:19)
```

This is caused by the fact that `ref` in `AsyncPipe` is initialized with a value of `null` which causes `_updateLatestValue` to fail since it is not expected to be `null`.

This change ensures that a `ref` is always provided and that all subscriptions are disposed off after each test.

PR Close #49433
2023-03-15 17:19:37 -07:00
Virginia Dooley
250f60227f docs: Understanding communicating with http - insert updated links. (#49429)
PR Close #49429
2023-03-15 17:18:53 -07:00
Angular Robot
bf2a5d5e04 build: update io_bazel_rules_sass digest to 3d2ad47 (#49428)
See associated pull request for more information.

PR Close #49428
2023-03-15 17:11:56 -07:00
Alan Agius
cf98777153 test: update tests to remove deprecated withServerTransition (#49422)
This commit removes the usages of `withServerTransition` form tests.

PR Close #49422
2023-03-15 17:08:18 -07:00
Alan Agius
82d6fbb109 refactor(core): generate a static application ID (#49422)
Prior to this change, a random application ID was generated each time which forced users using server rendering to provide an application ID themselves. This was needed to handle rare cases when multiple Angular applications are rendered on the same page.

With this change the application ID is no longer generated randomly and instead it is hard coded.

BREAKING CHANGE:

The `APP_ID` token value is no longer randomly generated. If you are bootstrapping multiple application on the same page you will need to set to provide the `APP_ID` yourself.

```ts
bootstrapApplication(ComponentA, {
  providers: [
   { provide: APP_ID, useValue: 'app-a' },
   // ... other providers ...
  ]
});
```

PR Close #49422
2023-03-15 17:08:17 -07:00
Alan Agius
630af63fae feat(platform-browser): deprecate withServerTransition call (#49422)
This commit deprecated ` BrowserModule.withServerTransition` instead `APP_ID` should be used instead to configure the app id.

DEPRECATED: `BrowserModule.withServerTransition` has been deprecated. `APP_ID` should be used instead to set the application ID.
NB: Unless, you render multiple Angular applications on the same page, setting an application ID is not necessary.

Before:
```ts
imports: [
  BrowserModule.withServerTransition({ appId: 'serverApp' }),
  ...
]
```

After:
```ts
imports: [
  BrowserModule,
  { provide: APP_ID, useValue: 'serverApp' },
  ...
],
```

PR Close #49422
2023-03-15 17:08:17 -07:00
Angular Robot
64067a1df6 build: update eslint dependencies to v5.55.0 (#49421)
See associated pull request for more information.

PR Close #49421
2023-03-15 17:03:49 -07:00
Angular Robot
de0bdeea4c build: update github/codeql-action action to v2.2.6 (#49420)
See associated pull request for more information.

PR Close #49420
2023-03-15 17:01:00 -07:00
Alan Agius
2d7f48cf74 test: fix misconfiguration in tests (#49391)
Currently, tests are tested twice using "production" like configuration. This commit disabled "optimization" for non production builds.

PR Close #49391
2023-03-15 16:59:50 -07:00
Kristiyan Kostadinov
1a6ca68154 feat(compiler): add support for compile-time required inputs (#49304)
Adds support for marking a directive input as required. During template type checking, the compiler will verify that all required inputs have been specified and will raise a diagnostic if one or more are missing. Some specifics:
* Inputs are marked as required by passing an object literal with a `required: true` property to the `Input` decorator or into the `inputs` array.
* Required inputs imply that the directive can't work without them. This is why there's a new check that enforces that all required inputs of a host directive are exposed on the host.
* Required input diagnostics are reported through the `OutOfBandDiagnosticRecorder`, rather than generating a new structure in the TCB, because it allows us to provide a better error message.
* Currently required inputs are only supported during AOT compilation, because knowing which bindings are present during JIT can be tricky and may lead to increased bundle sizes.

Fixes #37706.

PR Close #49304
2023-03-15 16:59:24 -07:00
Andrew Kushnir
22b895a5b1 refactor(core): add hydration logic for view containers (#49382)
This commit implements hydration support for view containers, which should make `*ngIf`, `*ngFor` and other structural directive work with hydration.

The logic also respects the `ngSkipHydration` flag and skips hydration in such cases.

PR Close #49382
2023-03-14 14:22:09 -07:00
Andrew Kushnir
02359f0814 refactor(core): adding a DEHYDRATED_VIEWS field to LContainer (#49382)
This commit adds a new slot to the `LContainer` header to store references to dehydrated views.

PR Close #49382
2023-03-14 14:22:09 -07:00
Andrew Kushnir
a6e38d3ae7 refactor(core): serialize info about views in view containers (#49382)
This commit updates the serialization logic to include information about views from view containers (based on underlying LContainer info). The information is needed during hydration to pick a correct instance of dehydrated view (this logic will be implemented in a followup commit).

PR Close #49382
2023-03-14 14:22:08 -07:00
Andrew Kushnir
a09fa46d4a refactor(core): serialize info about templates used to create embedded views (#49382)
This commit updates the serialization logic to include information about templates that were used to create embedded views. The information is needed during hydration to pick a correct instance of dehydrated view (this logic will be implemented in a followup commit).

PR Close #49382
2023-03-14 14:22:08 -07:00
Andrew Scott
ed110a05f0 docs: remove deprecation notes for removed APIs (#49239)
This commit removes the deprecation notes from the deprecations guide for APIs that have been removed.

PR Close #49239
2023-03-14 10:58:13 -07:00
Andrew Scott
c0b1b7becf fix(router): Remove deprecated ComponentFactoryResolver from APIs (#49239)
BREAKING CHANGE:
`ComponentFactoryResolver` has been removed from Router APIs.
Component factories are not required to create an instance of a component
dynamically. Passing a factory resolver via resolver argument is no longer needed
and code can instead use `ViewContainerRef.createComponent` without the
factory resolver.

PR Close #49239
2023-03-14 10:58:12 -07:00
Esteban Gehring
f07533f371 docs(upgrade): mark lifecycle methods as nodoc (#49416)
PR Close #49416
2023-03-14 09:41:35 -07:00
Esteban Gehring
a240dfce7b docs(common): mark lifecycle methods as nodoc (#49416)
PR Close #49416
2023-03-14 09:41:35 -07:00
Kristiyan Kostadinov
be97c87023 refactor(compiler): required inputs prerequisite refactors (#49333)
Based on the discussion in https://github.com/angular/angular/pull/49304#discussion_r1124732608. Reworks the compiler internals to allow for additional information about inputs to be stored. This is a prerequisite for required inputs.

PR Close #49333
2023-03-14 09:27:49 -07:00
Alex Rickabaugh
0814f20594 feat(core): introduce runInInjectionContext and deprecate prior version (#49396)
With the introduction of `EnvironmentInjector`, we added an operation to run
a function with access to `inject` tokens from that injector. This operation
only worked for `EnvironmentInjector`s and not for element/node injectors.

This commit deprecates `EnvironmentInjector.runInContext` in favor of a
standalone API `runInInjectionContext`, which supports any type of injector.

DEPRECATED: `EnvironmentInjector.runInContext` is now deprecated, with
`runInInjectionContext` functioning as a direct replacement:

```typescript
// Previous method version (deprecated):
envInjector.runInContext(fn);
// New standalone function:
runInInjectionContext(envInjector, fn);
```

PR Close #49396
2023-03-14 09:25:57 -07:00
Angular Robot
3d2351c5f7 build: update io_bazel_rules_sass digest to aa03944 (#49397)
See associated pull request for more information.

PR Close #49397
2023-03-14 09:25:16 -07:00
Alan Agius
b20ee9d47c refactor(core): remove duplicate call to getComponentId (#49390)
`getComponentId` is called twice by mistake.

f7c266c4e6/packages/core/src/render3/definition.ts (L319)

PR Close #49390
2023-03-14 09:23:52 -07:00
Alan Agius
056d68002f feat(platform-server): add provideServerSupport function to provide server capabilities to an application (#49380)
This commit adds the `provideServerSupport()` function that returns the `EnvironmentProviders` needed to setup server rendering without NgModules.

PR Close #49380
2023-03-14 09:23:13 -07:00
Andrew Scott
4e098fa8a7 refactor(core): move Zone providers to a single provider function (#49373)
This commit moves the providers for `NgZone`-based change detection to a
single provider function. This function is currently called by default
in all places where `NgZone` was provided
(`bootstrapApplication`, `bootstrapModule`, and `TestBed`).

When we want to make Angular applications zoneless by default, we
can make a public provider method that has to be used in order to enable
the zone change detection features. When this method is not called,
Angular would use `NoopNgZone` by default and not initialize any
subscriptions to the `NgZone` stability events.

Side note: There are actually two places that `NgZone` is provided for `TestBed`
(providers in `compileTestModule` and `BrowserTestingModule`). This
likely doesn't need to be in both locations.

PR Close #49373
2023-03-14 09:20:53 -07:00
Andrew Scott
67c5272946 refactor(core): Extract microtask subscription and CD scheduling from ApplicationRef (#49373)
This refactor extracts the `NgZone` microtask subscription to a new
"ChangeDetectionScheduler". With this change, `ApplicationRef` not
longer injects `NgZone` directly. In the future, we can update the
providers that depend on `NgZone` to not use zones by default but
instead require a specific-opt in.

PR Close #49373
2023-03-14 09:20:53 -07:00
Andrew Scott
4d3bfcd570 refactor(core): Extract ApplicationRef error handling to a new internal token (#49373)
This extracts the zone-based error handling in `ApplicationRef` to a new
token. This works towards removing `NgZone` as a dependency in
`ApplicationRef`.

PR Close #49373
2023-03-14 09:20:52 -07:00
Andrew Scott
d423101a71 refactor(core): Move ApplicationRef.isStable implementation to a provider (#49373)
`ApplicationRef.isStable` is entirely powered by the state of `NgZone`.
The implementation should be part of `NgZone` code rather than built in
to `ApplicationRef`. In the future, `ApplicationRef.isStable` should
likely be removed in favor of the API living on the `NgZone`
class/interface instead.

PR Close #49373
2023-03-14 09:20:52 -07:00
JiaLiPassion
5a2b6227b3 fix(zone.js): revert Mocha it.skip, describe.skip method patch (#49329)
In the previous commit https://github.com/angular/angular/pull/45047
The `it.skip` and `describe.skip` is wrongly deleted, should keep
the patch for these methods.

PR Close #49329
2023-03-14 09:13:57 -07:00
angular-robot[bot]
daaed8943c
build: update CODE_OF_CONDUCT.md to match the content of angular/.github 2023-03-13 21:07:51 +00:00
Paul Gschwendtner
7dbe328b28 docs: release notes for the v14.3.0 release 2023-03-13 10:59:08 +01:00
Angular Robot
c10962b713 build: update cross-repo angular dependencies (#49388)
See associated pull request for more information.

PR Close #49388
2023-03-13 09:24:13 +00:00
Alan Agius
a50ff60bff build: update cross-repo angular dependencies (#49376)
See associated pull request for more information.

(cherry picked from commit ba630a3c65)

PR Close #49376
2023-03-09 11:32:03 -08:00
Julien Saguet
5e7fc259ea feat(service-worker): add function to provide service worker (#48247)
add function `provideServiceWorker` to register a service worker in standalone applications without using `ServiceWorkerModule.register()`

PR Close #48247
2023-03-09 18:13:50 +00:00