Commit graph

310 commits

Author SHA1 Message Date
Jessica Janiuk
857675fedb refactor(core): this delays removal of stylesheets when the element registry is present (#62943)
When animate.leave is used, stylesheet pruning causes issues. Stylesheets with the appropriate animations get pruned before the animations can run. This will delay the removal in the case that the registry is present.

fixes: #62942

PR Close #62943
2025-08-01 12:54:22 +00:00
Jessica Janiuk
d23c5e4670 refactor(core): Tiny animation optimization (#62896)
This removes one redundant check to reduce code size.

PR Close #62896
2025-07-30 13:56:46 +00:00
Kristiyan Kostadinov
74d99ed379 fix(platform-browser): resolve component resources before bootstrapping in JIT mode (#62758)
Currently if the app has some external resources and it gets bootstrapped in JIT mode, the user will get an error about calling `resolveComponentResources`. These changes add a call to `resolveComponentResources` automatically inside `bootstrapApplication`.

Note that we don't need similar logic for `bootstrapModule`, because it calls into `compileNgModuleFactory` internally which in turn calls `resolveComponentResources`.

PR Close #62758
2025-07-23 11:05:20 -04:00
Jessica Janiuk
882522c1ad refactor(compiler): Tree shake Element Registry (#62682)
This creates a feature to detect usages of animate.leave and only enables the element removal registry when necessary

PR Close #62682
2025-07-23 09:37:16 -04:00
Jessica Janiuk
6b1f4b9e8b feat(core): add enter and leave animation instructions (#62682)
This adds the instructions to support enter and leave animations on nodes.

PR Close #62682
2025-07-23 09:37:16 -04:00
SkyZeroZx
44a203916a refactor(platform-browser): use RuntimeError for hydration feature conflicts (#62414)
Replace generic Error with RuntimeError

PR Close #62414
2025-07-03 08:08:07 +00:00
arturovt
4f89f6ea90 refactor(platform-browser): drop isPlatformServer in SharedStylesHost (#61685)
Replaces `isPlatformServer` with `ngServerMode` in `SharedStylesHost`.

PR Close #61685
2025-06-05 14:53:35 +02:00
arturovt
9a9511ace8 refactor(platform-browser): replace isPlatformServer with ngServerMode (#59496)
In this commit, we switch from using the `isPlatformServer` runtime call to the `ngServerMode`.

Note: constructors haven't been touched in order to prevent any breaking changes for the public API.

PR Close #59496
2025-05-26 11:14:27 +00:00
Joey Perrott
4c72ce408e build: migrate platform-browser and platform-browser-dynamic package to use rules_js (#61623)
Use ts_project and ng_project to build platform-browser and platform-browser-dynamic package

PR Close #61623
2025-05-23 15:14:00 -07:00
Kristiyan Kostadinov
fb65ad157c perf(platform-server): speed up resolution of base (#61392)
The `getBaseHref` method is called several times per request and currently queries through the entire document. We can speed it up by taking advantage of the fact that the `<base>` can only be a direct child of the `<head>` and is usually defined towards the beginning. Below are some benchmarks for a "Hello world" app before and after this change.

### Before:
```
Running 60s test @ http://localhost:4202
100 connections with 10 pipelining factor

┌─────────┬────────┬────────┬────────┬────────┬───────────┬──────────┬─────────┐
│ Stat    │ 2.5%   │ 50%    │ 97.5%  │ 99%    │ Avg       │ Stdev    │ Max     │
├─────────┼────────┼────────┼────────┼────────┼───────────┼──────────┼─────────┤
│ Latency │ 568 ms │ 853 ms │ 901 ms │ 904 ms │ 866.58 ms │ 437.6 ms │ 9915 ms │
└─────────┴────────┴────────┴────────┴────────┴───────────┴──────────┴─────────┘
┌───────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┐
│ Stat      │ 1%      │ 2.5%    │ 50%     │ 97.5%   │ Avg     │ Stdev   │ Min     │
├───────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│ Req/Sec   │ 490     │ 826     │ 1,006   │ 1,643   │ 1,129.3 │ 234.69  │ 490     │
├───────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│ Bytes/Sec │ 10.4 MB │ 17.4 MB │ 21.3 MB │ 34.7 MB │ 23.9 MB │ 4.96 MB │ 10.3 MB │
└───────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┘

Req/Bytes counts sampled once per second.
# of samples: 60

69k requests in 60.04s, 1.43 GB read
90 errors (90 timeouts)
```

### After

```
Running 60s test @ http://localhost:4202
100 connections with 10 pipelining factor

┌─────────┬────────┬────────┬────────┬─────────┬───────────┬───────────┬─────────┐
│ Stat    │ 2.5%   │ 50%    │ 97.5%  │ 99%     │ Avg       │ Stdev     │ Max     │
├─────────┼────────┼────────┼────────┼─────────┼───────────┼───────────┼─────────┤
│ Latency │ 471 ms │ 831 ms │ 889 ms │ 1668 ms │ 835.91 ms │ 467.89 ms │ 9720 ms │
└─────────┴────────┴────────┴────────┴─────────┴───────────┴───────────┴─────────┘
┌───────────┬─────────┬─────────┬─────────┬─────────┬──────────┬────────┬─────────┐
│ Stat      │ 1%      │ 2.5%    │ 50%     │ 97.5%   │ Avg      │ Stdev  │ Min     │
├───────────┼─────────┼─────────┼─────────┼─────────┼──────────┼────────┼─────────┤
│ Req/Sec   │ 390     │ 860     │ 1,145   │ 1,572   │ 1,156.77 │ 222.65 │ 390     │
├───────────┼─────────┼─────────┼─────────┼─────────┼──────────┼────────┼─────────┤
│ Bytes/Sec │ 8.24 MB │ 18.2 MB │ 24.2 MB │ 33.2 MB │ 24.4 MB  │ 4.7 MB │ 8.24 MB │
└───────────┴─────────┴─────────┴─────────┴─────────┴──────────┴────────┴─────────┘

Req/Bytes counts sampled once per second.
# of samples: 60

71k requests in 60.03s, 1.47 GB read
140 errors (140 timeouts)
```

PR Close #61392
2025-05-16 09:03:38 +00:00
Matthieu Riegler
f580318411 docs(docs-infra): Add version of introduction for APIs (#60814)
For new APIs we'll mention since when a particular API is in its current status (experimental, devPreview, stable)

fixes #49668

PR Close #60814
2025-05-02 07:51:33 -07:00
Jessica Janiuk
567522398f feat(core): stabilize incremental hydration api (#60888)
This removes the developer preview label for incremental hydration APIs.

PR Close #60888
2025-04-16 13:00:44 -04:00
Jessica Janiuk
bf8492b871 feat(core): stabilize withI18nSupport() api (#60889)
This stabilizes the `withI18nSupport()` feature of hydration.

PR Close #60889
2025-04-16 12:47:26 -04:00
Kristiyan Kostadinov
c0f41bc505 refactor(platform-browser): remove GenericBrowserDomAdapter (#60760)
The `GenericBrowserDomAdapter` wasn't don't anything so we can drop it and have the `BrowserDomAdapter` extend `DomAdapter` directly.

PR Close #60760
2025-04-08 10:14:54 -07:00
arturovt
1e697f3860 refactor(platform-browser): remove empty deps lists (#60312)
Removes empty `deps` lists in Platform-Browser providers.

PR Close #60312
2025-03-31 18:09:07 +00:00
arturovt
7c971566ad refactor(core): calculate hasHttpTransferCacheOptions later (#60605)
Prior to this commit, `hasHttpTransferCacheOptions` was calculated immediately after the `featuresKind` set was declared, which was always defaulted to `false`.

PR Close #60605
2025-03-28 13:33:57 +00:00
Alan Agius
70bdb88b0c fix(platform-browser): ensure platformBrowserTesting includes platformBrowser providers (#60480)
Previously, `platformBrowserTesting` did not include any `platformBrowser` providers, causing an inconsistency with `platformBrowserDynamicTesting`.

This update resolves the issue by restructuring platform inheritance to ensure proper provider inclusion:

- `platformCore → platformBrowser → platformBrowserTesting`
- `platformBrowser → platformBrowserDynamic → platformBrowserDynamicTesting`

Now, `platformBrowserTesting` correctly inherits from `platformBrowser`, aligning with the expected behavior.

PR Close #60480
2025-03-20 12:33:12 -07:00
Alan Agius
419784f7a0 docs: update provideClientHydration parameter description (#60432)
PR Close #60432
2025-03-18 18:11:47 +01:00
Matthieu Riegler
a980ac9a6a refactor(platform-browser): Deprecate the HammerJS integration (#60257)
The HammerJS integration provided by the framework is deprecated

DEPRECATED: HammerJS support is deprecated and will be removed in a future major version.

PR Close #60257
2025-03-11 09:25:28 -07:00
arturovt
a8ec7bebf2 refactor(platform-browser): drop unsupported event target error message in production (#60016)
Drops unsupported event target error message in production and replaces it with an existing error code.

PR Close #60016
2025-03-05 14:45:50 -08:00
arturovt
a88b00c9e3 refactor(platform-browser): remove redundant DomEventsPlugin dependencies (#59811)
The `DomEventsPlugin` only injects the `DOCUMENT`; the platform ID and `NgZone` are redundant.

PR Close #59811
2025-02-03 13:57:45 -08:00
Alan Agius
6b09716754 fix(platform-browser): prepend baseHref to sourceMappingURL in CSS content (#59730)
Implemented functionality to prepend the baseHref to `sourceMappingURL` in CSS content. Added handling to ensure external sourcemaps are loaded relative to the baseHref. Corrected sourcemap URL behavior when accessing pages with multi-segment URLs (e.g., `/foo/bar`). Ensured that when the baseHref is set to `/`, maps are requested from the correct path (e.g., `http://localhost/comp.css.map` instead of `http://localhost/foo/bar/comp.css.map`).

Closes #59729

PR Close #59730
2025-01-29 08:44:19 -08:00
Kristiyan Kostadinov
2fe54a11f4 fix(platform-browser): roll back HMR fix (#59557)
Rolls back the changes from #59514 because they ended up being breaking in 1P. We can revisit the internal fix in a different way.

Fixes #59558.

PR Close #59557
2025-01-16 12:27:51 +01:00
hawkgs
b9155b5121 docs: set syntax highlighting to the remaining Markdown code examples blocks (#59088)
There are some code blocks that slipped through the initial Regex-es.

Related to #59026

PR Close #59088
2025-01-14 15:14:02 -05:00
Kristiyan Kostadinov
2ca258705f fix(core): destroy renderer when replacing styles during HMR (#59514)
Currently when we swap out the component during HMR, we remove the renderer from the cache, but we never destroy it which means that its styles are still in the DOM. This can cause the old styles to leak into the component after they're replaced. These changes add a `destroy` call to ensure that they're removed.

PR Close #59514
2025-01-14 11:22:06 -05:00
arturovt
17510becb0 refactor(platform-browser): drop BROWSER_MODULE_PROVIDERS_MARKER in production (#59412)
In this commit, we switch from decorators (which also produce redundant metadata, such as in the
`declareFactory` instruction) to the `inject` function to drop the `BROWSER_MODULE_PROVIDERS_MARKER`
token in production. This token is actually provided only in development mode but is still
referenced in the constructor due to the `@Inject(BROWSER_MODULE_PROVIDERS_MARKER)` decorator.

PR Close #59412
2025-01-10 11:47:32 -05:00
arturovt
17234213f6 refactor(platform-browser): remove Console from Hammer gestures (#59409)
Injecting the `Console` is redundant because it directly calls the global `console` object.
There is no reason to reference this class in Hammer gestures, as it is only used in development
mode. We can safely call the `console` object directly.

PR Close #59409
2025-01-09 13:09:51 -05:00
arturovt
f2e293db4e refactor(platform-browser): drop Hammer token names in production (#59438)
In this commit, we drop `HAMMER_GESTURE_CONFIG` and `HAMMER_LOADER` injection token names in production.

PR Close #59438
2025-01-09 12:38:06 -05:00
Dmytro Mezhenskyi
00cc923117 refactor(platform-browser): improve error message for UNEXPECTED_SYNTHETIC_PROPERTY (#58983)
Improve error message by adding instructions for enabling animations using standalone API.

PR Close #58983
2025-01-08 15:56:18 +00:00
Johnson Chu
a6cdbec09f refactor: remove unnecessary TSLint rule flags (#59365)
There are many TSLint rule flags in the source code that have no effect, and they can be safely removed to keep the code clean.

PR Close #59365
2025-01-07 16:06:21 +00:00
Kristiyan Kostadinov
0e23f20c41 fix(platform-browser): styles not replaced during HMR when using animations renderer (#59393)
When we replace a component during HMR, we clear it from the cache of the renderer factory, however when using animations, there's an animation-specific renderer factory that wraps the base DOM one and was preventing the cache from being cleared.

These changes rework the logic that clear the cache to go through a method so we can forward the call to the delegated factory.

PR Close #59393
2025-01-07 15:55:38 +00:00
Kristiyan Kostadinov
c9b8319774 refactor(core): allow tracing service to wrap event listeners (#59134)
Allows the tracing service to wrap event listeners bound by the framework.

PR Close #59134
2024-12-12 14:52:42 -08:00
Kristiyan Kostadinov
d010e11b73 feat(core): add event listener options to renderer (#59092)
Updates the `Renderer2.listen` signature to accept event options, as well as all adjacent types to it.

PR Close #59092
2024-12-10 13:39:47 -08:00
Charles Lyding
52be35118f fix(platform-browser): collect external component styles from server rendering (#59031)
SSR generated component styles used in development environments will add
external styles via link elements to the HTML. However, the runtime would
previously not collect these link elements for reuse with rendered components.
This would result in two copies of the link elements present in the DOM. In
isolation this is not problematic as it is only present in development mode.
Unfortunately, the Vite-based CSS HMR functionality used by the Angular CLI
only updates the first stylesheet it finds and leaves other instances of the
stylesheet in place. This behavior causes the styles to be left in an
inconsistent state. This could be considered a defect within Vite as it should
update all relevant styles to maintain consistency but ideally there should
not be two instances in the Angular SSR case. To avoid the Vite issue, the
runtime will now collect SSR generated external styles and reuse them.

PR Close #59031
2024-12-05 16:12:22 -08:00
hawkgs
0513fbc9fc docs: set syntax highlighting of code examples MD code blocks (#59026)
Set the syntax highlighting based on the code examples' language.

PR Close #59026
2024-12-04 17:30:28 +01:00
Charles Lyding
c22b5accdd fix(platform-browser): correctly add external stylesheets to ShadowDOM components (#58482)
Angular components that use ShadowDOM view encapsulation have an alternate
execution path for adding component styles to the DOM that does not use the
SharedStylesHost that all other view encapsulation modes leverage. To ensure
that ShadowDOM components receive all defined styles, additional logic has been
added to the ShadowDOM specific renderer to also cover external styles.

PR Close #58482
2024-11-05 11:33:17 +01:00
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