Commit graph

1100 commits

Author SHA1 Message Date
arturovt
3602c536e4 refactor(common): drop error messages in production (#60242)
Drops more error messages in production.

PR Close #60242
2025-03-10 10:04:03 -07:00
Alan Agius
45f899a272 refactor: replace fast-glob usage with tinyglobby (#60264)
Usage of the `fast-glob` package has been replaced with the `tinyglobby` package. The change reduces the number of transitive dependencies related to these packages from 17 to 2 while also maintaining equivalent functionality. This was also changed in the Angular CLI packages.

PR Close #60264
2025-03-07 10:57:23 -08:00
Matthieu Riegler
2668bd96b9 refactor(http): Make sur to pass context & transferCache from httpResource to the underlying request. (#60228)
Prior to this change, both were accepted as argument but never passed to the client.

PR Close #60228
2025-03-06 07:59:06 -08:00
arturovt
0f3fa5a2af refactor(common): drop ngIf assert template error in production (#59705)
This commit removes the `assertTemplate` error message in production.

PR Close #59705
2025-03-05 14:42:18 -08:00
cexbrayat
92250493ff fix(common): support equality function in httpResource (#60026)
The `equal` option was not passed to the underlying resource.

PR Close #60026
2025-03-05 14:41:15 -08:00
Samuel Perez
6dd8cce155 docs: fix all brokens links on the API pages (#59162)
This PR fix is for the broken links on the API
pages mentioned in issue #57591.

PR Close #59162
2025-03-04 20:07:23 +00:00
Matthieu Riegler
bb14fe86e3 refactor(http): add context property to httpResource (#60188)
This was an oversight, `context` can be supported out of the box.

PR Close #60188
2025-03-04 19:57:21 +00:00
Andrew Scott
739cadae62 fix(common): Handle errors in async pipe subscriptions (#60057)
`AsyncPipe` would previously promise rejections unhandled and
subscription errors uncaught. This is more or less fine in a Zone-based
application because errors inside the Angular Zone are caught be the
Zone's error trap and reported to `ErrorHandler`. However, in zoneless
applications, these errors are never caught or reported by the FW and
can reach the node process in SSR and cause it to shut down.

BREAKING CHANGE: `AsyncPipe` now directly catches unhandled errors in
subscriptions and promises and reports them to the application's
`ErrorHandler`. For Zone-based applications, these errors would have
been caught by ZoneJS and reported to `ErrorHandler` so the result is
generally the same. The change to the exact mechanism for reporting can
result in differences in test environments that will require test
updates.

PR Close #60057
2025-03-04 17:35:01 +00:00
arturovt
36b60a9705 fix(common): clean up onUrlChange listener when root scope is destroyed (#60004)
This cleans up the `onUrlChange` listener once the root scope is destroyed.

PR Close #60004
2025-03-03 17:14:33 +00:00
Matthieu Riegler
919c4521ec refactor(http): rename map to parse on HttpResourceOptions (#60112)
This reflects more the feature intended for this callback.

PR Close #60112
2025-02-26 11:52:43 -05:00
Kristiyan Kostadinov
07338c0aeb fix(common): make types for HttpClient more readable (#59901)
`HttpClient` has a lot of overloads to achieve proper type checking, however each overload is also very long which makes it hard to read on adev. These changes replace the object literal types with `Record` to make them a bit more concise.

PR Close #59901
2025-02-25 13:01:09 -05:00
Stephen Hicks
74cceba587 feat(common): throw error for suspicious date patterns (#59798)
Adjusts the date pipe and formatDate function to detect suspicious usages of the week-numbering year formatter without including the week number, as this is often confused for the calendar year and likely to result in incorrect results near New Years, meaning that those issues aren't typically caught during development. This commit starts throwing a development-only error to reveal this issue right away.

BREAKING CHANGE:

Using the `Y` formatter (week-numbering year) without also including `w` (week number) is now detected as suspicious date pattern, as `y` is typically intended.

PR Close #59798
2025-02-24 17:15:03 -05:00
Andrew Scott
8657a0e4cc refactor(core): Add fake navigation to primitives for code sharing (#59857)
This moves the `FakeNavigation` implementation to the primitives folder
so its implementation can be shared with Wiz. This class was initially
copied directly from the Wiz implementation, with some small modifications.
There will still need to be some work done to align the implementations
and fix anything internally that needs adjusting.

PR Close #59857
2025-02-19 20:09:10 +00:00
arturovt
40dc99da9c refactor(common): inline supports check in slice pipe (#59684)
The refactored version improves the original code by removing the `supports` method from the prototype and inlining the logic directly into the `transform` method. This reduces indirection and simplifies the class, especially since `supports` is not reused elsewhere. ESBuild can directly inline the condition into the `if` statement by removing the variable: `if (!("string" == typeof e || Array.isArray(e))) throw i(s, e);`.

PR Close #59684
2025-02-19 15:22:49 +00:00
arturovt
967488247e refactor(common): simplify stripTrailingSlash (#59746)
The new version of the function is smaller, eliminating extra bytes. The refactor improves both code size and readability while optimizing the implementation. Benchmark results for the old and new implementations are as follows:

```
stripTrailingSlash_old x 15,446,602 ops/sec ±0.89% (66 runs sampled)
stripTrailingSlash_new x 19,694,523 ops/sec ±1.10% (61 runs sampled)
```

Thus, the new implementation is both smaller and faster.

PR Close #59746
2025-02-19 15:20:53 +00:00
arturovt
7bd4be0fa5 fix(common): clean up urlChanges subscribers when root scope is destroyed (#59703)
In this commit, the `urlChanges` subject is completed to release all active observers when the root scope is destroyed. Previously, subscribing to the `urlChanges` subject caused the subscriber to capture `this`, resulting in a memory leak after the root scope was destroyed.

PR Close #59703
2025-02-18 15:40:19 +00:00
Alex Rickabaugh
3e39da593a feat(common): introduce experimental httpResource (#59876)
`httpResource` is a new frontend to the `HttpClient` infrastructure. It
declares a dependency on an HTTP endpoint. The request to be made can be
reactive, updating in response to signals for the URL, method, or otherwise.
The response is returned as an instance of `HttpResource`, a
`WritableResource` with some additional signals which represent parts of the
HTTP response metadata (status, headers, etc).

PR Close #59876
2025-02-14 18:40:37 +00:00
arturovt
f34aeaeaad refactor(common): remove redundant transferCacheInterceptorFn dependencies (#59819)
The `transferCacheInterceptorFn` injects dependencies in itself; the `TransferCache` and cache options are redundant in the `deps` list.

PR Close #59819
2025-02-13 15:11:19 +00:00
arturovt
b7dd0483d0 refactor(common): drop error messages in production (#59545)
Switches to using `RuntimeError` and drops error messages in production by replacing it with an error code.

PR Close #59545
2025-01-28 09:39:42 +01:00
arturovt
762e56e210 refactor(common): drop platform check in PreconnectLinkChecker (#59714)
Replaces platform check within the `PreconnectLinkChecker` with the `ngServerMode` global.

PR Close #59714
2025-01-27 17:22:43 +01:00
arturovt
10cdf0afae refactor(common): tree-shake PreloadLinkCreator for client bundles (#59431)
In this commit, we tree-shake the `PreloadLinkCreator` for client bundles because it's targeting only server code. We use the pending tasks service to contribute to app stability by waiting for the module to load.

PR Close #59431
2025-01-24 17:17:58 +01:00
arturovt
d634ca7633 refactor(common): simplify joinWithSlash (#59484)
The new version is 2x smaller in the reduced code size; as thus this eliminates extra bytes. Refactors `joinWithSlash` function to reduce code size and improve readability. Added checks to handle leading and trailing slashes more concisely and provided comments for clarity.

PR Close #59484
2025-01-24 17:16:11 +01:00
arturovt
edb8407d4f refactor(common): simplify null/undefined check in keyvalue pipe (#59696)
In this commit, we remove the separate `a === undefined` and `a === null` checks and replace them with `a == null`. Using `a == null` is better and more concise because it checks for both `null` and `undefined` in a single operation. The loose equality `==` is specifically designed to treat `null` and `undefined` as equivalent. This change only reduces some bytes in the code and simplifies it, with no performance impact, as modern JavaScript engines handle `a == null` efficiently. Additionally, comments have been added for clarification.

PR Close #59696
2025-01-24 12:45:04 +01:00
arturovt
6fc180b3ff refactor(common): prevent duplicating Accept header name (#59546)
Drops some bytes by moving `Accept` into a variable, which is then minified to something like `var a="Accept"` and reused in all the places.

PR Close #59546
2025-01-23 14:21:51 -08:00
arturovt
2e138e644c refactor(common): prevent duplicating Content-Type header (#59518)
Drops some bytes by moving `Content-Type` into a variable, which is then minified to something like `var b="Content-Type"` and reused in all the places.

PR Close #59518
2025-01-15 12:22:29 -08:00
arturovt
3b3040d32a refactor(common): drop error message in production (#59471)
Switches to using `RuntimeError` and drops the error message in production by replacing it with an error code.

PR Close #59471
2025-01-15 12:28:29 -05:00
Matthieu Riegler
d797c5cb94 docs: update class & style binding recommendation (#59240)
This commit introduces an update to the official recommendations when it comes to class & styles bindings.

`[class]` & `[style]` bindings are now recommended for basic uses cases.

`[ngClass]` and `[ngStyle]` allow more advanced bindings (like space separated keys) or keys with units (for `ngStyle`) which are not supported by the native bindings. They still require the dedicated directives.

PR Close #59240
2025-01-15 12:27:12 -05:00
Andrew Kushnir
eadf6a35bb Revert "refactor: initialize headers map directly in HttpHeaders class (#59268)" (#59523)
This reverts commit e15226a444.

PR Close #59523
2025-01-14 17:48:34 -05: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
arturovt
bc77f44802 refactor(common): tree-shake lcpObserver in NgOptimizedImage (#59481)
Prior to this commit, the `this.lcpObserver?.updateImage` expression was still preserved in the production code because it wasn't wrapped with `ngDevMode`. The observer is injected only in development mode. Additionally, we moved the logic from `ngOnDestroy` to avoid having an empty method in production.

PR Close #59481
2025-01-14 14:54:16 -05:00
arturovt
1ff5cd6906 refactor(common): tree-shake transfer cache interceptor stuff (#59439)
In this commit, we replace `isPlatformServer` runtime call with the `ngServerMode` in the `transferCacheInterceptorFn` in order to make the functionality tree-shakable between client and server bundles.

PR Close #59439
2025-01-14 14:40:05 -05:00
RafaelJCamara
e15226a444 refactor: initialize headers map directly in HttpHeaders class (#59268)
Improved the initialization of the headers map to enhance performance
and code readability.

No breaking changes.

PR Close #59268
2025-01-14 10:50:15 -05:00
arturovt
5d6358168a refactor(common): prevent duplicating Accept header (#59467)
In this commit, we extract content types into a variable to eliminate extra bytes, as these values are duplicated in multiple places.

PR Close #59467
2025-01-13 12:38:46 -05:00
arturovt
4491704fba refactor(common): drop enums by changing to const enum (#59468)
Note: this enums are not a part of the public API.

Prior to this commit, the compiler produced:

```js
var DateType;
(function (DateType) {
    DateType[DateType["FullYear"] = 0] = "FullYear";
    DateType[DateType["Month"] = 1] = "Month";
    DateType[DateType["Date"] = 2] = "Date";
    DateType[DateType["Hours"] = 3] = "Hours";
    DateType[DateType["Minutes"] = 4] = "Minutes";
    DateType[DateType["Seconds"] = 5] = "Seconds";
    DateType[DateType["FractionalSeconds"] = 6] = "FractionalSeconds";
    DateType[DateType["Day"] = 7] = "Day";
})(DateType || (DateType = {}));
```

With these changes, we allow objects to be dropped entirely and inlined.

PR Close #59468
2025-01-13 11:14:27 -05:00
arturovt
d51d67b725 refactor(common): prevent duplicating X-Request-URL (#59420)
The `X-Request-URL` string is duplicated in multiple places. It is worth moving it to a shared constant that would be minified to something like `const a = "X-Request-URL"` and referenced in all the used places.

PR Close #59420
2025-01-09 18:18:24 -05:00
arturovt
e194573d0d refactor(common): tree-shake fetch backend (#59418)
This commit updates the code of the HTTP code to make the `FetchBackend` class tree-shakable. The class is only needed with `withFetch()` is called and it should not be included into bundles that do not use that feature.

PR Close #59418
2025-01-09 13:05:56 -05:00
arturovt
83bd63fa7c refactor(common): drop NullViewportScroller for client bundles (#59440)
In this commit, we replace the `isPlatformBrowser` runtime call with the `ngServerMode` in order to drop the `NullViewportScroller` for client bundles.

PR Close #59440
2025-01-09 12:33:04 -05:00
arturovt
dd1d69b2e2 refactor(common): drop PRELOADED_IMAGES name in production (#59425)
In this commit, we drop the `PRELOADED_IMAGES` injection token name in production.

PR Close #59425
2025-01-08 16:12:02 +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
Jamie Rees
cb685d8571 refactor(common): update the NgOptimizedImage message to use @if instead of *ngIf (#59131)
This commit updates an error message to mention `@if` rather than the `*ngIf` directive.
PR Close #59131
2024-12-12 14:51:43 -08:00
Alan Agius
24e317cb15 refactor: replace ɵPendingTasks with ɵPendingTasksInternal (#59138)
This commits remove usage of the old export.

PR Close #59138
2024-12-10 13:45:07 -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
Matthieu Riegler
0034ce5583 refactor(http): Don't log fetch warning in tests. (#59049)
Prior to this commit, we were logging the `NOT_USING_FETCH_BACKEND_IN_SSR` error when `provideHttpTestingClient` and `PLATFORM_ID` were provided.

fixes #59028

PR Close #59049
2024-12-05 16:12:55 -08:00
hawkgs
b8b6c8c77a refactor(docs-infra): convert code-example-s that have only region param to @example-s (#59004)
Replace all <code-example>-s within TS files that contain only a path and a region with JSDoc @example-s.

PR Close #59004
2024-12-04 18:05:59 +01: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
Sheik Althaf
9658dd1fe3 refactor(common): remove standalone: true (#58949)
Removed the standalone true flag from common packages.

PR Close #58949
2024-12-04 12:41:51 +01:00
hawkgs
8d6ea5bae3 docs: fix missing alert block styles in the API reference (#59020)
Substitute legacy alert classes with the new ones.

PR Close #59020
2024-12-04 11:02:42 +01:00
Andrew Kushnir
7f6f5f95ea refactor(core): use ApplicationRef.whenStable instead of a custom util function (#58834)
This commit removes a custom `whenStable` util in favor of standard `ApplicationRef.whenStable` API.

There is also an important different between the custom `whenStable` function and `ApplicationRef.whenStable` implementation: the `whenStable` was caching the "stable" promise on per-ApplicationRef basis, which resulted in unexpected behavior with zoneless, when some code ended up getting a stale resolved promise, when an application was not stable yet, this causing order of operations issues. This commit also has an extra test that covers that case.

PR Close #58834
2024-11-25 15:25:10 +00:00
Kristiyan Kostadinov
e4c50b3bea feat(common): expose component instance in NgComponentOutlet (#58698)
Exposes the current instance of the component in the `NgComponentOutlet` directive.

PR Close #58698
2024-11-20 08:08:21 -08:00
Alan Agius
fee9db18a9 refactor: add @__PURE__ next to @pureOrBreakMyCode for improved bundler compatibility (#58297)
Added the `@__PURE__` annotation alongside `@pureOrBreakMyCode` to improve compatibility with third-party bundlers. This refactor follows optimization best practices, ensuring broader support across different tools, as `@pureOrBreakMyCode` was only supported by Closure Compiler.

PR Close #58297
2024-10-28 12:26:05 -07:00