Commit graph

274 commits

Author SHA1 Message Date
Brandon Roberts
48620ad21f docs(platform-browser): update usage notes for incremental hydration (#58339)
PR Close #58339
2024-10-24 16:39:26 -07:00
Jessica Janiuk
69fc5ae922 feat(core): Add incremental hydration public api (#58249)
This exposes the public api to utilize incremental hydration.

PR Close #58249
2024-10-22 09:37:31 -07:00
Jessica Janiuk
95449302e9 refactor(core): add incremental hydration infrastructure (#58193)
This adds the bulk of the infrastructure to support
incremental hydration.

PR Close #58193
2024-10-21 12:05:06 -07:00
TupiC
b542f15204 docs: removed typos of withHttpTransferCacheOptions description (#58244)
Removed two typos in the withHttpTransferCacheOptions function description.

- Corrected spelling of "whether"
- Changed spelling from "a an" to "an"
PR Close #58244
2024-10-18 10:14:09 +00:00
Alan Agius
5c61f46409 refactor(platform-browser): remove deprecated BrowserModule.withServerTransition method (#58062)
BREAKING CHANGE: The deprecated `BrowserModule.withServerTransition` method has been removed. Please use the `APP_ID` DI token to set the application id instead.

PR Close #58062
2024-10-07 08:23:53 -07:00
Charles Lyding
2545743ad1 refactor(core): support external runtime styles via a component feature (#57922)
The shared style host now has the capability to add component styles as
link elements with external style references. This is currently unused
within the runtime but is an enabling feature for upcoming features such
as automatic component style HMR and development server deferred
stylesheet processing. Instead of inline style content that is then
added to a `style` element for each host node, a `link` element with a
stylesheet `rel` attribute and a `href` attribute can now be created.
The development server must be configured to provide the relevant
component stylesheet upon request. The Angular CLI development server
will provide this functionality once this capability is enabled.
Since the primary use of this capability is development mode and will
not be used for production code, server (SSR) style reuse is currently
not yet implemented but may be implemented in the future.

A component feature is used to provide the DOM renderer access to any
external styles that were emitted at compile time. When external styles
are present, the `getExternalStyles` function will be present on the
runtime component metadata object. The DOM render will use this function
to access and encapsulate the external style URLs as required by the
component.

PR Close #57922
2024-09-30 13:25:12 -07:00
Charles Lyding
ea5442637c refactor(platform-browser): further reduce runtime code size of shared style host (#57951)
The `SharedStylesHost` class has been refactored to further reduce
the runtime code size. SSR generated component styles are now added directly
into the usage records to avoid the need for additional data structures and
lookups when adding a component style. The code reduction in a prerelease
newly generated Angular CLI application for production is ~190 bytes.

Before:
```
Initial chunk files   | Names         |  Raw size | Estimated transfer size
main-3X2VHGTM.js      | main          | 208.26 kB |                56.30 kB
polyfills-FFHMD2TL.js | polyfills     |  34.52 kB |                11.28 kB
styles-5INURTSO.css   | styles        |   0 bytes |                 0 bytes

                      | Initial total | 242.78 kB |                67.58 kB
```

After:
```
Initial chunk files   | Names         |  Raw size | Estimated transfer size
main-MGOZ6Q4F.js      | main          | 208.07 kB |                56.26 kB
polyfills-FFHMD2TL.js | polyfills     |  34.52 kB |                11.28 kB
styles-5INURTSO.css   | styles        |   0 bytes |                 0 bytes

                      | Initial total | 242.59 kB |                67.54 kB
```

PR Close #57951
2024-09-26 14:28:00 -07:00
Thomas Nguyen
5f356fc092 refactor(core): Remove global event delegation code. (#57893)
This is no longer needed since we are no longer experimenting with it.

PR Close #57893
2024-09-26 14:18:17 -07:00
Joey Perrott
9dbe6fc18b refactor: update license text to point to angular.dev (#57901)
Update license text to point to angular.dev instead of angular.io

PR Close #57901
2024-09-24 15:33:00 +02:00
Andrew Kushnir
b124e50ea3 refactor(core): avoid producing zone-related warnings during hydration when in zoneless mode (#57911)
This commit updates hydration code to avoid logging "unsupported configuration" warnings when in zoneless mode.

PR Close #57911
2024-09-24 12:52:40 +02:00
Charles Lyding
7b2fda16b1 refactor(platform-browser): reduce runtime code size of shared style host (#57834)
The `SharedStylesHost` class has been refactored to both reduce the runtime
code size and also modernize some of the code structures. The class is also
adjusted to better support reuse via subclassing or other reuses in the future.
Additional comments have been added to improve readability as well.
The code reduction in a prerelease newly generated Angular CLI application
for production is ~410 bytes.

Before:
```
Initial chunk files   | Names         |  Raw size | Estimated transfer size
main-GOQKBZBZ.js      | main          | 208.67 kB |                56.41 kB
polyfills-FFHMD2TL.js | polyfills     |  34.52 kB |                11.28 kB
styles-5INURTSO.css   | styles        |   0 bytes |                 0 bytes

                      | Initial total | 243.19 kB |                67.69 kB
```

After:
```
Initial chunk files   | Names         |  Raw size | Estimated transfer size
main-CRTDDKPH.js      | main          | 208.26 kB |                56.32 kB
polyfills-FFHMD2TL.js | polyfills     |  34.52 kB |                11.28 kB
styles-5INURTSO.css   | styles        |   0 bytes |                 0 bytes

                      | Initial total | 242.78 kB |                67.61 kB
```

PR Close #57834
2024-09-23 14:22:58 +02:00
Andrew Kushnir
6b239535e8 docs: declare Event Replay feature as stable (#57895)
This commit drops the `@developerPreview` annotation from the `withEventReplay()` function, which effectively makes the Event Replay feature stable.

PR Close #57895
2024-09-23 11:41:52 +02:00
Andrew Kushnir
0bbbd78482 docs: add withEventReplay and withI18nSupport links to provideClientHydration docs (#57382)
PR Close #57382
2024-08-15 16:10:27 -04:00
Kristiyan Kostadinov
513a4fe05e refactor(core): replace usages of removeChild (#57203)
These changes replace most usages of `removeChild` with `remove`. The latter has the advantage of not having to look up the `parentNode` and ensure that the child being removed actually belongs to the specific parent.

The refactor should be fairly safe since all the browsers we cover support `remove`. [Something similar was done in Components](https://github.com/angular/components/pull/23592) some time ago and there haven't been any bug reports as a result.

PR Close #57203
2024-08-07 16:46:09 +00:00
Bouguima, Walid
03553c485d docs: broken HammerLoader reference fix (#55836)
*Fixing broken documentation reference to HammerLoader in HammerLoaderInjectionToken page

PR Close #55836
2024-07-30 16:56:33 +00:00
Thomas Nguyen
40fb81fd0e refactor(core): Add global event delegation provider (#56247)
This replaces all addEventListener calls with a stashing function,
and installs an event listener on the document body to retrieve
the stashed function;

PR Close #56247
2024-06-27 14:24:47 +00:00
Thomas Nguyen
0e23ed716e docs: Add documentation for event replay (#55802)
PR Close #55802
2024-05-17 10:10:06 -07:00
Matthieu Riegler
e5331107fd fix(platform-browser): Use the right namespace for mathML. (#55622)
Prior to this change, MathML element were created with the wrong namespace resulting in regular DOM `Element`.

This commit fixes this.

Related to #55608 (but doesn't fix it entirely).

PR Close #55622
2024-05-03 08:07:31 -07:00
Alan Agius
cba336d4f1 refactor(platform-browser): remove deprecated transfer state APIs (#55474)
BREAKING CHANGE: Deprecated `StateKey`, `TransferState` and `makeStateKey` have been removed from `@angular/platform-browser`, use the same APIs from `@angular/core`.

PR Close #55474
2024-04-23 13:05:38 -07:00
Joey Perrott
b1dffa4abe refactor: migrate platform-* to prettier formatting (#55423)
Migrate formatting to prettier for platform-* from clang-format

PR Close #55423
2024-04-19 13:49:24 -07:00
Thomas Nguyen
a730f09ae9 feat(core): Add a public API to establish events to be replayed and an attribute to mark an element with an event handler. (#55356)
These will be consumed by the event-dispatch contract to replay events. The contract and the dispatcher inclusion will be in followups.

PR Close #55356
2024-04-19 13:12:21 -07:00
Matthieu Riegler
457d02cca3 docs: Use new Urls to drop the docs url mapper (#55043)
PR Close #55043
2024-04-09 12:23:09 -07:00
Gerald Monaco
45ae7a6b60 feat(platform-browser): add withI18nSupport() in developer preview (#55130)
Expose withI18nSupport() as a hydration feature to enable i18n hydration

PR Close #55130
2024-04-03 15:27:24 +00:00
Matthieu Riegler
f523415203 docs: drop glossary links (#55044)
PR Close #55044
2024-03-28 13:02:50 -07:00
Matthieu Riegler
7800a3c9f5 refactor(core): remove InjectionToken descriptions in optimized builds. (#53747)
We started guarding the `InjectionToken` descriptions with `ngDevMode`. Let's generalize that accross the FW.

PR Close #53747
2024-01-26 19:12:41 +00:00
Matthieu Riegler
8a1f1c075a refactor(platform-browser): remove non necessary factories (#52439)
Let's keep the code a simple as necessary

PR Close #52439
2024-01-26 17:26:51 +00:00
Matthieu Riegler
983968dc68 refactor(platform-browser): remove the depency on window for the AngularProfiler. (#52440)
`performance` and `console` are both available on NodeJS, we can replace `window` with `globalThis`.

PR Close #52440
2024-01-26 17:24:40 +00:00
Andrew Scott
c2dd703d2f refactor(core): Remove internal-only testability features (#53767)
This commit removes the testability features that are internal only.
This simplifies the implementation of testability which will need
updates to support zoneless. Those updates will be easier to manage if
the Testability implementation is simpler.
While protractor is indeed officially EOL, we will still need to do some
updates to support teams migrating to zoneless that have protractor
tests.

As far as protractor's own use of `whenStable`, it does not read the
internal only methods either:
https://github.com/angular/protractor/blob/master/lib/clientsidescripts.js
Anything else depending on these values are not following the defined public API
contract.

PR Close #53767
2024-01-09 14:46:46 -08:00
Vincent
fdb9cb7a5b fix(platform-browser): Get correct base path when using "." as base href when serving from the file:// protocol. (#53547)
Using http://a as the base URL returns / instead of the actual base path when using the file:// protocol. Using document.baseURI addresses this.

Fixes #53546

PR Close #53547
2023-12-13 09:26:56 -08:00
Kristiyan Kostadinov
162d940b72 refactor(platform-browser): clean up legacy way of getting a relative path (#53097)
Currently the way we extract the pathname of a URL is by creating an anchor node, assigning the URL to its `href` and reading the `pathname`. This is inefficient and it triggers an internal security check that doesn't allow the `href` attribute to be set which ends up blocking https://github.com/angular/components/pull/28155.

These changes switch to using the browser's built-in URL parsing instead.

PR Close #53097
2023-11-27 10:59:53 +01:00
Matthieu Riegler
5ee11a74ec fix(animations): prevent the AsyncAnimationRenderer from calling the delegate when there is no element. (#52570)
This happens when `issueAnimationCommand` is invoked

fixes #52538

PR Close #52570
2023-11-13 16:29:18 +00:00
Alan Agius
cb8a741f14 docs: update SSR doc to reflect version 17 (#52398)
Changes to SSR doc

PR Close #52398
2023-10-26 12:30:59 -07:00
Andrea Canciani
fc9ba3978c refactor: fix a number of typos throughout the codebase (#52249)
Fix some typos such as `boostrap`, `propery` and more, both in
documentation and in code (comments, identifiers).

PR Close #52249
2023-10-25 16:51:24 -07:00
Jan Kuehle
ebbc7a27e8 refactor: change public const enums to enums (#51670)
Angular recently gained a local compilation mode (see commit
345dd6d81a). This is intended to be used
with the TypeScript compiler option isolatedModules, which bans imports
of const enums.

This changes all const enums tagged with @publicApi to regular enums.

Fixes #46240

PR Close #51670
2023-10-25 10:39:18 -07:00
Andrew Kushnir
941e65b2a0 docs: promote provideClientHydration and related symbols to stable (#52197)
This commit removes the `@developerPreview` annotation from the `provideClientHydration` function and related symbols, promoting them to stable.

PR Close #52197
2023-10-18 18:21:48 +02:00
Alan Agius
1640743b18 Revert "perf(platform-browser): disable styles of removed components instead of removing (#51808)" (#52238)
This reverts commit 65786b2b96 due to an oberved perf regression in Pantheon.

See: http://b/303667704

PR Close #52238
2023-10-18 11:34:21 +02:00
Alan Agius
7466004543 perf(platform-browser): only append style element on creation (#52237)
Prior to this change the style element was appended to host element multiple times. Whilst the actual element was not added multiple to the DOM multiple times. This causes a performance regression and it caused repainting.

This can be observed in the below benchmark.

```js
(() => {
  const time = (name, fn) => {
    const t = performance.now();
    fn();
    console.log(name, performance.now() - t);
  }

  const s = document.createElement("style");
  s.textContent = "@layer x{} @font-face { font-family: foo; }";

  time("append and enable", () => {
    document.head.append(s);
    s.disabled = false;
  });
  time("compute body color", () => {
    getComputedStyle(document.body).color;
  });
  time("compute body layout", () => {
    document.body.offsetTop;
  });
  time("append and disable", () => {
    document.head.append(s);
    s.disabled = false;
  });
  time("compute body color", () => {
    getComputedStyle(document.body).color;
  });
  time("compute body layout", () => {
    document.body.offsetTop;
  });
})();
```

Output
```
append and enable 0.20000000298023224
compute body color 0.7999999970197678
compute body layout 2.899999998509884
append and disable 0.10000000149011612
compute body color 0.7000000029802322
compute body layout 2.2999999970197678
```

When commenting the 2nd `document.head.append(s);`, the results are slightly different and we can see that calling `getComputedStyle` does not incur any performance impact this is a result of no repainting.

```
append and enable 0.10000000149011612
compute body color 0.7999999970197678
compute body layout 3.1999999955296516
append and disable 0.10000000149011612
compute body color 0
compute body layout 0
```

Pantheon benchmarks: http://docs/spreadsheets/d/1iLRLGCmVYZHuVRdI7dO_WM7wnQ1DvkS-tJzi-0-u1KY?resourcekey=0-kwtrf0nbAhcPqAGdqbdz4g#gid=0

PR Close #52237
2023-10-17 11:18:01 +02:00
Matthieu Riegler
75d610d420 fix(platform-browser): set animation properties when using async animations. (#52087)
Animations properties set on the default renderer weren't set on the animation renderer once it was loaded. This commit fixes this.

PR Close #52087
2023-10-10 11:59:13 -07:00
Andrew Kushnir
dbc14eb41d refactor(platform-browser): remove withNoDomReuse function (#52057)
This commit removes the `withNoDomReuse` function to minimize public API. The `withNoDomReuse` function used to disable DOM reuse, which is the main feature of the `provideClientHydration()`.

The `withNoDomReuse()` function was in the "developer preview" mode, so the removal happens without prior deprecation.

BREAKING CHANGE:

The `withNoDomReuse()` function was removed from the public API. If you need to disable hydration, you can exclude the `provideClientHydration()` call from provider list in your application (which would disable hydration features for the entire application) or use `ngSkipHydration` attribute to disable hydration for particular components. See this guide for additional information: https://angular.io/guide/hydration#how-to-skip-hydration-for-particular-components.

PR Close #52057
2023-10-09 13:36:16 -07:00
Matthieu Riegler
7dde42a5df feat(http): allow customization of the HttpTransferCache. (#52029)
`provideClientHydration()` accepts new `HydrationFeature` : `HttpTransferCacheOptions`.

`withHttpTransferCacheOptions` accepts an option object:
* `includeHeaders` : list of headers entries to keep in the cache with the request
* `filter` a callback to determine if a request should be cached
* `includePostRequests`: to include POST requests in the allowed methods

Implements some of the features requested in #50117

PR Close #52029
2023-10-06 12:12:47 -07:00
Matt Lewis
65786b2b96 fix(platform-browser): prevent duplicate stylesheets from being created (#52019)
Fixes a bug with REMOVE_STYLES_ON_COMPONENT_DESTROY when a component is destroyed and re-created, its previous stylesheets will not be re-used and instead a new stylesheet will still be created each time.

PR Close #52019
2023-10-05 14:06:56 -07:00
Matthieu Riegler
e753278faa feat(animations): Add the possibility of lazy loading animations code. (#50738)
`provideLazyLoadedAnimations()` returns providers which allow the lazy loading of the animation module.

Lazy loading of the animation code can shave off up to 16KB gzipped of the main bundle.

PR Close #50738
2023-09-29 10:49:39 -07:00
Alan Agius
3c0577f991 perf(platform-browser): disable styles of removed components instead of removing (#51808)
This commit changes the behaviour of `REMOVE_STYLES_ON_COMPONENT_DESTROY`.

Now, `style` nodes are disabled instead of removed from DOM. This causes the same runtime behaviour but avoids recomputations when the stylesheet is re-added when the component is re-created. https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/css/css_style_sheet.h;l=266;drc=31fb07c05718d671d96c227855bfe97af9e3fb20

NB: This changes is being done following some performance bottlenecks observed in Phanteon and their own recommendations.

Context:
http://chat/room/AAAAxKxTk40/jaP6Lj6fhmQ/jaP6Lj6fhmQ
https://crbug.com/1444522
http://b/289992821

PR Close #51808
2023-09-22 09:48:35 -07:00
Matthieu Riegler
8ad21ccfb8 docs: Add info about hydration caching. (#51648)
The docs was missing an important information about caching. Only GET/HEAD requests are cached until `isStable`

PR Close #51648
2023-09-06 15:31:36 +00:00
Alan Agius
c340d6e044 feat(platform-browser): enable removal of styles on component destroy by default (#51571)
This change aligns the settings between G3 and P3 as `REMOVE_STYLES_ON_COMPONENT_DESTROY_DEFAULT` is already set to `true` internally.

BREAKING CHANGE: `REMOVE_STYLES_ON_COMPONENT_DESTROY` default value is now `true`. This causes CSS of components to be removed from the DOM when destroyed. You retain the previous behaviour by providing the `REMOVE_STYLES_ON_COMPONENT_DESTROY` injection token.

```ts
import {REMOVE_STYLES_ON_COMPONENT_DESTROY} from '@angular/platform-browser';
...
providers: [{
  provide: REMOVE_STYLES_ON_COMPONENT_DESTROY,
  useValue: false,
}]
```

PR Close #51571
2023-08-30 14:42:02 +00:00
Matthieu Riegler
c5daa6ce77 feat(platform-browser): expose EventManagerPlugin in the public API. (#49969)
The exposed type of the `EVENT_MANAGER_PLUGINS` token should be in the public API.

PR Close #49969
2023-08-29 16:40:06 +00:00
Matthieu Riegler
e6503930f1 docs: fix see also links. (#51379)
These were all the @see with no links.

PR Close #51379
2023-08-17 10:18:33 -07:00
Matthieu Riegler
0a38dc3c26 refactor(core): throw an error when hydration marker is missing from DOM (#51170)
non-destructive hydration expects the DOM tree to have the same structure in both places.
With this commit, the app will throw an error if comments are stripped out by the http server (eg by some CDNs).

fixes #51160

PR Close #51170
2023-08-04 11:31:49 -04:00
Alan Agius
f1b629961f perf(platform-browser): do not remove renderer from cache when REMOVE_STYLES_ON_COMPONENT_DESTROY is enabled. (#51005)
Removing the renderer from cache is not needed when `REMOVE_STYLES_ON_COMPONENT_DESTROY` is enabled. This change retains the behaviour of keeping the renderer cached for the entire lifecycle of the application the same way it is done when `REMOVE_STYLES_ON_COMPONENT_DESTROY` is disabled.

This seems to have be causing an increase in scripting. See: http://b/290666638

PR Close #51005
2023-07-11 10:11:51 -07:00
Matthieu Riegler
0522f1b353 docs: Add a doc for NG5014 (#50567)
Short explanation this help fix the `Root node not found` error

PR Close #50567
2023-06-27 15:57:23 -07:00