Commit graph

955 commits

Author SHA1 Message Date
Charles Lyding
f2245d1fd5 build: convert build/test scripts to use fast-glob (#53397)
The repository currently has two globbing packages. To minimize the number of packages in
the framework repository, the uses of the `glob` package are being converted
to `fast-glob` which is used by the tooling repository.  The change is mostly mechanical
and in this change the build and test scripts are converted.

PR Close #53397
2023-12-08 14:37:07 -08:00
Matthieu Riegler
e00ae2d07a refactor(core): replace runInContext by runInInjectionContext (#53035)
Saves a few bytes since function names can be mangled.

PR Close #53035
2023-11-20 12:05:00 -08:00
arturovt
29c5416d14 fix(common): remove load on image once it fails to load (#52990)
This commit adds an `error` listener to image elements and removes both
`load` and `error` listeners once the image loads or fails to load. The `load`
listener would never have been removed if the image failed to load.

PR Close #52990
2023-11-20 08:58:06 -08:00
Matthieu Riegler
cf86ae5c3a fix(http): Use the response content-type to set the blob type. (#52840)
When downloading a PDF with the fetch client, the blob had no content. It couldn't be displayed in an iframe. This commit fixes this.

Relate to: https://stackoverflow.com/questions/77470626/possible-bug-in-httpclient-when-using-the-blob-data-type

PR Close #52840
2023-11-13 16:22:20 +00:00
Pawel Kozlowski
6c8776ff71 fix(core): limit rate of markers invocations (#52742)
This PR assures that the performance markers are invoked
only once for a given feature.

Closes #52524

PR Close #52742
2023-11-09 19:58:26 +00:00
Tom Wilkinson
029edea32a refactor(common): Update packages/common/src/navigation/platform_navigation.ts (#52363)
Co-authored-by: Andrew Scott <atscott01@gmail.com>

PR Close #52363
2023-11-09 18:01:33 +00:00
Thomas Wilkinson
27f5eed017 refactor(common): Add fake implementation of PlatformNavigation. (#52363)
This implementation does most, but not all, of the things the native
Navigation API does. Also adds a spec that tests all the currently
supported behaviors.

PR Close #52363
2023-11-09 18:01:33 +00:00
Thomas Wilkinson
77770c6d5b refactor(common): Add a new platform_navigation that provides the Navigation API. (#52363)
This allows using the Navigation API in Angular packages like Router.

PR Close #52363
2023-11-09 18:01:33 +00:00
Matthieu Riegler
291ba38623 fix(http): Don't override the backend when using the InMemoryWebAPI (#52425)
When using `withFetch`,  the `PRIMARY_HTTP_BACKEND` token is set.

The InMemory Backend services will also set that token.

This means that providers order will matter and the latest on the list will be the one instantiated

PR Close #52425
2023-11-08 18:42:20 +00:00
Alan Agius
93d32a9acb fix(core): guard usages of performance.mark (#52505)
While `performance.mark` is available on all supported browsers and node.js version this API is not available in JSDOM which is used by Jest and Cloudflare worker.

This commit, updates the usage to a safer variant.

PR Close #52505
2023-11-03 07:43:36 -07:00
Alex Rickabaugh
de802f0c1a Revert "fix(http): Don't override the backend when using the InMemoryWebAPI (#52425)"
This reverts commit 49b037f811. Reason: it
breaks tests in aio-local.
2023-10-31 16:16:16 -07:00
Alex Castle
f86fb8eb03 fix(common): apply fixed_srcset_width value only to fixed srcsets (#52459)
add logic to NgOptimizedImage to keep fixed_srcset_width from applying to large responsive images, which is incorrect behavior

PR Close #52459
2023-10-31 14:57:19 -07:00
Matthieu Riegler
08f4c5221a build: add missing entries for the api extraction (#52452)
Were missing :

* `@angular/common/http/testing`
* `@angular/platform-browser/animations/async`

PR Close #52452
2023-10-31 14:53:34 -07:00
Alan Agius
19a426d54e build: update node.js engines version to be more explicate about v20 support (#52448)
This commit adds Node.js 20 as explicitly supported version to match the Angular CLI engines.

See: https://github.com/angular/angular-cli/pull/26173

PR Close #52448
2023-10-31 14:18:36 -07:00
Matthieu Riegler
49b037f811 fix(http): Don't override the backend when using the InMemoryWebAPI (#52425)
When using `withFetch`,  the `PRIMARY_HTTP_BACKEND` token is set.

The InMemory Backend services will also set that token.

This means that providers order will matter and the latest on the list will be the one instantiated

PR Close #52425
2023-10-31 13:17:19 -07:00
Alan Agius
df86e37fb3 refactor(common): avoid repetitive globalThis in global locales (#52394)
This changes reduced slightly the bundle size as `global` can be minified unlike direct usage of `globalThis`.

PR Close #52394
2023-10-26 09:37:40 -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
Alvaro Junqueira
56598a16a7 docs: the Component import is not being used (#52323)
PR Close #52323
2023-10-25 09:35:21 -07:00
Alan Agius
d775fa1c24 refactor(common): modernize code in locale file (#52368)
Use `globalThis` global property contains the global this value, which is usually akin to the global object.

PR Close #52368
2023-10-25 09:30:51 -07:00
Alan Agius
c5e30f1d79 perf(http): reduce data transfer when using HTTP caching (#52347)
This commit reduces the property size in the http transfer cache to reduce the page payload.

Before
```html
<script id="ng-state" type="application/json">
{
  "4155228514": {
    "body": "....",
    "headers": {},
    "status": 200,
    "statusText": "OK",
    "url": "http://foo.com/assets/media.json",
    "responseType": "json"
  },
}
</script>
```

Now
```html
<script id="ng-state" type="application/json">
{
  "4155228514": {
    "b": "....",
    "h": {},
    "s": 200,
    "st": "OK",
    "u": "http://foo.com/assets/media.json",
    "rt": "json"
  },
}
</script>
```

PR Close #52347
2023-10-24 14:33:26 -07:00
Alex Castle
e33a0ff3dd docs(common): add preconnect generation to NgOptimizedImage docs (#52248)
add a note on automated preconnect generation to the NgOptimizedImage docs' preconnect section, and add a related FAQ entry.

PR Close #52248
2023-10-24 09:26:06 -07:00
Alan Agius
405ec8c796 fix(platform-server): resolve relative requests URL (#52326)
Prior to this commit relative HTTP requests were not being resolved to absolute even thought the behaviour is documented in https://angular.io/guide/universal#using-absolute-urls-for-http-data-requests-on-the-server.

This caused relative HTTP requests to fail when done on the server because of missing request context. This change is also required to eventually support HTTP requests handled during prerendering (SSG).

Closes #51626

PR Close #52326
2023-10-23 12:02:21 -07:00
Andrew Kushnir
d10f2b29d7 refactor(core): use performance API for hydration-related features (#52288)
This commit adds a standard performance marker that can be viewed in Chrome dev tools and other tooling. See more info at https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark

PR Close #52288
2023-10-23 09:29:36 -07:00
Alex Castle
8fff07cf53 refactor(common): use performance API for NgOptimizedImage feature logging (#52205)
add a standard performance marker that can be viewed in Chrome dev tools and other tooling. See more info
at https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark

PR Close #52205
2023-10-19 09:39:06 -07:00
Kristiyan Kostadinov
c07805612f test(core): clean up unnecessary nesting in old tests (#52239)
A lot of our tests are wrapped in `{}` which serves no purpose, aside from increasing the nesting level and, in some cases, causing confusion. The braces appear to be a leftover from a time when all tests were wrapped in a `function main() {}`. The function declaration was removed in #21053, but the braces remained, presumably because it was easier to search&replace for `function main()`, but not to remove the braces at the same time.

PR Close #52239
2023-10-19 09:26:15 -07:00
Andrew Kushnir
eee5a5a1af docs: promote withFetch and FetchBackend to stable (#52197)
This commit removes the `@developerPreview` annotation from the `withFetch` and `FetchBackend` APIs, promoting them to stable.

PR Close #52197
2023-10-18 18:21:48 +02:00
cexbrayat
b1cb0b395b fix(common): missing space in ngSwitch equality warning (#52180)
This adds a missing space between the sentences of the `===` vs `==` ngSwitch warning.

PR Close #52180
2023-10-12 15:44:46 +02:00
Jeremy Elbourn
fcc000e803 build: add targets for api doc generation (#52034)
This adds `generate_api_docs` targets to all of the packages for which we publish api reference docs. One known issue here is that any type information that comes from another package (e.g. router depending on core) currently resolve to `any` because the other sources are not available in the program. This can be tackled in a follow-up commit.

This commit also updates the install patch for `@angular/build-tools` to use the local version of compiler-cli.

PR Close #52034
2023-10-10 16:18:50 -07:00
Sylvain DEDIEU
da056a1fe2 fix(common): add missing types field for @angular/common/locales of exports in package.json (#52080)
Add a types entry in the packages/common/package.json exports "./locales/*" section

Fixes #52011

PR Close #52080
2023-10-10 14:33:44 -07:00
Pawel Kozlowski
28a5925f53 fix(common): use === operator to match NgSwitch cases (#51504)
This change adjust the equality comparator used by NgSwitch - now it
defaults to === from previously used ==. This change is based on the
following reasoning:
- align behaviour with the built-in switch block);
- improve performance (avoid type coercion);
- enable better type-checking.

BREAKING CHANGE:

the NgSwitch directive now defaults to the === equality operator,
migrating from the previously used ==. NgSwitch expressions and / or
individual condition values need adjusting to this stricter equality
check. The added warning message should help pinpointing NgSwitch
usages where adjustements are needed.

Fixes #33873

PR Close #51504
2023-10-09 10:10:21 -07:00
Alex Castle
048f400efc feat(core): add warnings for oversized images and lazy-lcp (#51846)
Add warnings for two image-related performance problems that apply beyond just apps using NgOptimizedImage.

PR Close #51846
2023-10-06 12:14:32 -07:00
Adrien Crivelli
85843e8212 fix(common): allow to specify only some properties of DatePipeConfig (#51287)
The code already supports `DatePipeConfig` to have only some properties
set, and not all. But the typing disallows it. This aligns the typing
with the code.

PR Close #51287
2023-10-06 12:13:13 -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
Andrew Kushnir
22fa9fe488 docs: recommend enabling fetch support in HttpClient when using SSR (#52056)
PR Close #52056
2023-10-05 16:54:58 -07:00
Andrew Kushnir
760bfdc4bf refactor(http): warn when HttpClient doesn't use fetch during SSR (#52037)
This commit adds a logic to produce a warning in case HttpClient doesn't use fetch during SSR.
It's recommended to use `fetch` for performance and compatibility reasons.

PR Close #52037
2023-10-05 16:52:41 -07:00
Alex Castle
dde3fdabbd feat(common): upgrade warning to logged error for lazy-loaded LCP images using NgOptimizedImage (#52004)
Upgrade the existing warning so it now logs an error instead, when an LCP element is determined to not be usings the `priority` attribute. Error is logged, not thrown.

PR Close #52004
2023-10-04 11:36:01 -07:00
Paul Gschwendtner
7426948ff6 refactor(common): update NgTemplateOutlet to no longer rely on context swapping (#51887)
The context of an embedded view ref at some point was switched from a
getter to an actual assignable property. This is something we reverted
with the previous commit as it introduces additional complexity for our
generated code (in terms of closures capturing the `ctx`).

This change impacted the template outlet code because we actively relied
on swapping out the full context if the user changes it. Previousl,
before we allowed to swap out the context (in v16), we mutated the
initial view context if it didn't change structurally- and in other
cases the view was re-created. We improved this performance aspect with
the changes to allow for the context to be swapped out + actually also
fixed a bug where the initial context object was mutated and the user
could observe this change.

This commit adjusts for context not being replacable- while still
keeping the bugs fixed and preserving the performance wins of not
having to destroy/re-create the view whenever the context changes.

Benchmarks: https://hackmd.io/J0Ci_JzxQ0K1AA1omXhIQQ

PR Close #51887
2023-10-04 08:14:35 -07:00
Matthieu Riegler
85e31465c9 refactor(http): create an InjectionToken for a global HttpBackend (#51999)
`withHttp` provides the new `PRIMARY_HTTP_BACKEND` token with `FetchBackend` to use it globally.

PR Close #51999
2023-10-04 07:26:18 -07:00
Alan Agius
8413b64a6b refactor(core): add whenStable private API (#51807)
Prior to this change `this.isStable.pipe(first((isStable) => isStable)).toPromise()` had to be done in multiple places across the framework and the Angular CLI see https://github.com/angular/angular-cli/pull/25856#discussion_r1328158846. In the majority of cases an Observable based `isStable` API is not needed. This also removes the need for RXJS operator imports.

PR Close #51807
2023-09-27 10:31:56 -07:00
Pawel Kozlowski
8486fa1594 Revert "feat(common): make the warning for lazy-loaded lcp image an error (#51748)" (#51810)
This reverts commit fe2fd7e1a8.

PR Close #51810
2023-09-18 13:35:55 +02:00
Alex Castle
fe2fd7e1a8 feat(common): make the warning for lazy-loaded lcp image an error (#51748)
upgrade the warning for lazy-loaded lcp images when using NgOptimizedImage to an error

BREAKING CHANGE:

Previously when NgOptimizedImage directive detected that an LCP image is lazy-loaded, a console warning was produced. Now the directive throws an error to make it more discoverable in a console. If you receive this error, refer to this guide for additional information: https://angular.io/guide/image-directive#step-4-mark-images-as-priority

PR Close #51748
2023-09-18 10:42:15 +02:00
Alan Agius
59aa0634f4 build: remove support for Node.js v16 (#51755)
BREAKING CHANGE: Node.js v16 support has been removed and the minimum support version has been bumped to 18.13.0.

Node.js v16 is planned to be End-of-Life on 2023-09-11. Angular will stop supporting Node.js v16 in Angular v17. For Node.js release schedule details, please see: https://github.com/nodejs/release#release-schedule

PR Close #51755
2023-09-13 10:49:06 -07:00
Jeremy Mowery
635318fd61 refactor: add readonly to public InjectionToken types (#51407)
This fixes warnings caused by an internal lint rule

refactor: add readonly to public InjectionToken types

PR Close #51407
2023-09-12 12:55:14 -07:00
Kristiyan Kostadinov
52cc7f839b build: align with internal tsconfig options (#51728)
Currently internally Angular has some customized tsconfig files, because we don't align with the tsconfig of the rest of g3. These changes enable `noImplicitReturns` and `noPropertyAccessFromIndexSignature` to align better with the internal config.

PR Close #51728
2023-09-12 11:39:42 -07:00
Joey Perrott
0907f396d5 build: migrate to node 18 (#51609)
Migrate to use node version 18

PR Close #51609
2023-09-01 15:12:43 +00:00
Paul Gschwendtner
86c5e34601 fix(common): remove code duplication between entry-points (#51500)
The common packages were duplicating a little bit of code due
to relative imports between entry-points. This caused bundlers to
inline shared functions twice in both FESM outputs.i

PR Close #51500
2023-08-29 17:55:34 +00:00
Alex Castle
d910bf8a84 fix(common): Allow safeUrl for ngSrc in NgOptimizedImage (#51351)
Allow safeUrl and add transformer to immediately convert ngSrc to string

PR Close #51351
2023-08-17 10:20:35 -07:00
Luis Castro
328b3613b8 docs(common): revert format date_pipe (#51359)
PR Close #51359
2023-08-15 10:06:47 -07:00
Luis Castro
200a264fab docs(common): add new date format example to documentation (#51359)
PR Close #51359
2023-08-15 10:06:47 -07:00