Commit graph

823 commits

Author SHA1 Message Date
Paul Gschwendtner
c9415e4d75 build: ensure bootstrap transitive runfiles are made available (#48521)
Since we generate a `.mjs` file as entry-point for jasmine tests,
a couple of issues prevented the transitive dependencies from
bootstrap targets to be brought in (causing resolution errors):

1. The `_files` (previously `_esm2015`) targets are no longer needed,
   and they also miss all the information on runfiles.
2. The aspect for computing linker mappings does not respect the
   `bootstrap` attribute from the `spec_entrypoint` so we manually
   add the extract ESM output targets (this rule works with the aspect
   and forwards linker mappings).

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
20551503fa build: replace _es2015 shorthand with more flexible _files suffix (#48521)
For every `ts_library` target we expose a shorthand that grants
access to the JS files because `DefaultInfo` of a ts library
only exposes the `.d.ts` files.

We rename this away from `es2015` since in practice it's a much
higher target these days. Additionally we no longer use the devmode
output but rather use the prodmode output which has the explicit
`.mjs` output- compatible with ESM.

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
0e1cbecc2c build: refactor generate-locales-tool to ESM (#48521)
The `generate-locales-tool` now needs to run as ESM because we changed
the `ts_library` rule. This commit accounts for the ESM syntax but
removing CJS code parts like `require.main === module`.

Also imports using `require` need to be changed to their ESM
equivalents.

PR Close #48521
2022-12-19 19:50:40 +00:00
Andrew Scott
fe50813664 feat(common): Add BrowserPlatformLocation to the public API (#48488)
`PlatformLocation` is already part of the public API so developers can
create their own. This means that developers would already be able to
access the existing `BrowserPlatformLocation` at runtime by injecting
it. The motivation for adding `BrowserPlatformLocation` to the public
API is because of those facts, but driven more by the fact that we are
looking to include `MockPlatformLocation` by default in TestBed.
Developers would need a way to revert back to the current behavior for
some tests that rely directly on browser interaction.

PR Close #48488
2022-12-14 09:54:28 -08:00
Jessica Janiuk
e0d62cb734 Revert "fix(common): Update Location to get a normalized URL valid in case a represented URL starts with the substring equals APP_BASE_HREF" (#48461)
This reverts commit ae0efb6a09.

PR Close #48461
2022-12-12 16:18:46 -08:00
Bob Watson
a6d953e145 docs: move tour of heroes tutorial to a subdirectory (#48162)
This commit prepares the documentation directories for future tutorials organized by directory.

Also, it moves the Angular Libraries topic from the Tutorials section to Developer Guides in TOC

PR Close #48162
2022-12-12 12:07:46 -08:00
Konstantin Kharitonov
d87285c363 fix(common): Update Location to get a normalized URL valid in case a represented URL starts with the substring equals APP_BASE_HREF (#48394)
```ts
@NgModule({
  imports: [RouterModule.forRoot([{path: '/enigma', component: EnigmaComponent}])],
  providers: [{provide: APP_BASE_HREF, useValue: '/en'}]
})
export class AppModule {}
```

Navigating to `/enigma` will redirect to `/en/igma` not to `/en/enigma` as it expects

Fixes: #45744

PR Close #48394
2022-12-12 09:37:35 -08:00
Andrew Scott
dcfbe22434 docs(common): Add note to location about investigating base href handling (#48422)
There have been/are several bugs related to base href handling in
Angular (#45744, #48175, #19296).
These all stem from the attempted custom handling of base href
in the `Location` class. This logic does not really make an attempt
to be fully compliant with the spec.

PR Close #48422
2022-12-09 12:38:59 -08:00
Andrew Kushnir
83f694752a refactor(router): use RegExp to check if a URL is absolute (#48406)
Previously, this check looked like this: `/^(https?:)?\/\//.test(baseHref)`,
but that resulted in syntactically incorrect code after Closure Compiler minification.
This was likely caused by a bug in Closure Compiler, but for now, the check is rewritten
to use `new RegExp` instead.

PR Close #48406
2022-12-08 15:06:16 -08:00
Konstantin Kharitonov
f8ecc194e9 fix(common): Update Location to support base href containing origin (#48327)
In case `APP_BASE_HREF` is set including `origin` the further usage of it might cause failure

e.g.
If an app is placed on `https://example.com` and bundles are on `https://cdn-example.com` you have to set `APP_BASE_HREF` up as `https://example.com/` and build the app with `--base-href` as `https://cdn-example.com/` but it does not work because of the bug

Fixes #48175

PR Close #48327
2022-12-07 09:18:00 -08:00
Alan Agius
ffbc9679e4 refactor(common): remove unused setDOM (#48357)
Remove unused `setDOM` method is unused.

PR Close #48357
2022-12-05 14:35:08 -08:00
Alex Castle
8e52ca2714 fix(common): Don't generate srcsets with very large sources (#47997)
Fix an issue where users could inadvertently generate very large source images in ngOptimizedImage

PR Close #47997
2022-12-05 12:12:13 -08:00
Rokas Brazdžionis
ae712ef6dd docs: update date pipe default timezone injection token reference (#48274)
replace deprecated `DATE_PIPE_DEFAULT_TIMEZONE` with `DATE_PIPE_DEFAULT_OPTIONS`
PR Close #48274
2022-11-29 09:40:28 -08:00
Joey Perrott
303bb4d27c build: reformat BUILD files (#48181)
Reformat BUILD file usage of globs.

PR Close #48181
2022-11-22 21:22:34 +00:00
Derek Cormier
f37dd0fc96 build(bazel): create AIO example playgrounds for manual testing
After the bazel migration, AIO examples are no longer fully formed in
the source tree.
2022-11-22 13:51:16 -07:00
Derek Cormier
b4c40c5d55 build(bazel): merge aio/tools/defaults.bzl and tools/defaults.bzl
Detect the correct workspace for the source maps dep.
2022-11-22 13:51:16 -07:00
Derek Cormier
bc1e93d639 build(bazel): refactor aio example e2es to fix windows performance
Use the same config flag to enable local vs npm deps as aio.
2022-11-22 13:51:16 -07:00
Derek Cormier
22a317de3d build(bazel): stamp targets to build, test, and serve aio against
first party deps

Architect is not compatible with disabling the rules_nodejs linker so
these targets must use npm_link to link first party deps
2022-11-22 13:51:16 -07:00
Derek Cormier
7a134cf41a build(bazel): incrementally run aio example e2e tests
Replaces the workflow where all example e2es are run at once
2022-11-22 13:51:16 -07:00
Derek Cormier
431c562815 build(bazel): add bazel targets for aio doc generation
This is an incremental step to produce dgeni output with bazel. The
generated outputs are not yet used by other targets.
2022-11-22 13:51:16 -07:00
Nebojsa Cvetkovic
1976e37475 fix(router): restore 'history.state' on popstate even if navigationId missing (#48033)
If `history.pushState()` or `history.replaceState()` were called manually without including the `navigationId` field the state was being incorrectly discarded - that logic was for maintaining the original behavior of `NavigationStart.restoredState`.

Improves on #28176, fully fixes #28108, see also #28954

PR Close #48033
2022-11-21 13:46:17 -08:00
Andrew Scott
b0a62bea47 fix(common): Fix MockPlatformLocation events and missing onPopState implementation (#48113)
The MockPlatformLocation forward, back, and historyGo methods should trigger a popstate event.
Additionally, these events should just be synchronous since that's what the majority of the major
browsers do. Lastly, onPopState should be implemented the same way as onHashChange.

PR Close #48113
2022-11-21 13:45:05 -08:00
ced
804b85554c fix(common): export the IMAGE_CONFIG token (#48051)
The token introduced in 4fde292bb5 was not exported publicly.

PR Close #48051
2022-11-14 19:27:17 +00:00
Andrew Kushnir
d6dc6b6349 test(common): add e2e tests for the fill mode checks in the NgOptimizedImage directive (#48036)
This commit adds extra e2e tests for the fill mode checks in the NgOptimizedImage directive to make
sure a warning is logged in a console.

PR Close #48036
2022-11-14 09:20:40 -08:00
Alex Castle
8b39c38940 fix(common): Warn on fill ngOptimizedImage without height (#48036)
Add a warning if a fill-mode image is rendered without height. This is a common occurence if the user doesn't properly set the 'position' attribute of the parent element.

PR Close #48036
2022-11-14 09:20:40 -08:00
Alex Castle
1d1e33e8d0 fix(common): Add fetchpriority to ngOptimizedImage preloads (#48010)
Add fetchpriority='high' to ngOptimizedImage preloads to so their priority matches the priority of the image element itself

PR Close #48010
2022-11-10 17:36:39 +00:00
Alex Rickabaugh
febf29dd51 fix(http): rename withLegacyInterceptors to withInterceptorsFromDi (#47901)
This rename reflects what the function actually does. Although the intention
is still not to have two different interceptor mechanisms, that is now
communicated in the docs for the function instead of in its name.

Fixes #47764

PR Close #47901
2022-11-03 17:54:03 -07:00
Alex Rickabaugh
cf6c819489 docs(http): add public API tags and jsdoc for provideHttpClient (#47901)
This commit adds documentation and API tagging for `provideHttpClient` and
the `with*` feature functions.

PR Close #47901
2022-11-03 17:54:03 -07:00
Andrew Kushnir
ec43991665 refactor(common): improve the NgOptimizedImage error message related to changing inputs (#47926)
This commit updates the error message thrown by the NgOptimizedImage directive, when it detects a situation
when inputs change after initial rendering.

The list of inputs was also updated to include all inputs added recently.

PR Close #47926
2022-11-03 17:50:22 -07:00
Alex Castle
6b9b472f6a fix(common): Don't warn about image distortion is fill mode is enabled (#47824)
The image distortion warning (when rendered aspect ratio is noticeably different than intrinsic) doesn't make sense with fill mode, where the user may want the image to stretch, crop or letterbox.

PR Close #47824
2022-10-20 16:50:02 -07:00
Andrew Kushnir
177c55686d docs: exclude lifecycle hooks of the NgOptimizedImage from docs (#47814)
This commit adds the `@nodoc` annotations to the lifecycle hooks of the `NgOptimizedImage` directive to exclude them from the docs.

PR Close #47814
2022-10-19 23:08:52 +02:00
Andrew Kushnir
fc07efdd2b fix(docs-infra): display "developer preview" label on class members (#47814)
This commit adds the "developer preview" label for class properties and methods.

PR Close #47814
2022-10-19 23:08:52 +02:00
Alex Castle
38ec1565ad fix(common): don't generate srcset if noopImageLoader is used (#47804)
Do not generate a srcset if the loader being used is the default noopImageLoader. This loader does not take width into account, so it does not make sense to use it with srcsets.

PR Close #47804
2022-10-19 23:08:01 +02:00
Andrew Kushnir
b136e9eea6 docs: declare NgOptimizedImage APIs as stable (#47794)
In v14.2, we've introduced a new directive to help developers to configure images for better performance. The directive was initially released in the "developer preview" mode. We've collected the feedback, made several improvements and we are happy to announce that the NgOptimizedImage APIs are promoted to stable!

This commit updates vast majority of APIs to drop the `@developerPreview` label, which effectively documents them as stable.

There are few APIs though that retained the `@developerPreview` annotations:
- the `IMAGE_CONFIG` token
- the `ImageConfig` type
- the `fill` @Input of the directive

We plan to collect some additional feedback for the mentioned APIs and drop the `@developerPreview` annotation after that.

PR Close #47794
2022-10-19 20:13:12 +02:00
Kara Erickson
b31091b222 docs(common): update image directive docs (#47796)
This is a small commit to:
- clarify that loaders aren't mandatory
- remove outdated preconnect option from docs
- clarify how width/height should be set for fixed size images
- minor structural changes for clarity

PR Close #47796
2022-10-19 15:25:14 +02:00
Kara Erickson
1ebc0fad0e fix(common): update size error to mention 'fill' mode (#47797)
The current error that is thrown when the "width" or
"height" attributes is missing doesn't mention that
"fill" mode is another option. This commit updates
the error with that option.

PR Close #47797
2022-10-19 15:23:38 +02:00
Andrew Kushnir
bdd4d14db9 refactor(common): drop deprecated selector from the NgOptimizedImage directive (#47798)
This commit updates the NgOptimizedImage directive to:
- drop a deprecated selector (the `rawSrc` one)
- drop corresponding input getter

The `rawSrc` was replaced by the `ngSrc` one during the developer preview phase.

PR Close #47798
2022-10-19 15:23:03 +02:00
Kara Erickson
ce5880f93f fix(common): warn if using supported CDN but not built-in loader (#47330)
This commit adds a missing warning if the image directive
detects that you're hosting your image on one of our
supported image CDNs but you're not using the built-in loader
for it. This excludes applications that are using a custom
loader.

PR Close #47330
2022-10-19 15:21:51 +02:00
Andrew Kushnir
0d65e1de2c docs: declare Standalone APIs as stable (#47754)
In v14, we've introduced core concepts to allow Components, Directives and Pipes to configure their dependencies
 without the need to use NgModules and without the need to be declared in an NgModule. The concepts and initial
set of APIs were marked as "developer preview" to allow developers to use these APIs and share the feedback.

Since v14, we've been reviewing the entire API surface of the framework and either updating existing APIs to support standalone or creating new APIs that allowed to use Router, HttpClient and other abstractions without NgMod
ules.

Based on the mentioned work to review and stabilize APIs and also based on the positive feedback from the commun
ity, we are happy to announce that the Standalone APIs are promoted to stable!

This commit updates vast majority of standalone-related APIs to drop the `@developerPreview` label, which effect
ively documents then as stable.

Two APIs that retained the `@developerPreview` annotations are:
- withRequestsMadeViaParent (from `@angular/common/http`)
- renderApplication (from `@angular/platform-server`)

We plan to collect some additional feedback for the mentioned APIs and drop the `@developerPreview` annotation b
efore the next major release.

Co-Authored-By: Alex Rickabaugh <alx@alxandria.net>
Co-Authored-By: Andrew Scott <atscott@google.com>
Co-Authored-By: Dylan Hunn <dylhunn@gmail.com>
Co-Authored-By: Jessica Janiuk <jessicajaniuk@google.com>
Co-Authored-By: JoostK <joost.koehoorn@gmail.com>
Co-Authored-By: Kristiyan Kostadinov <crisbeto@abv.bg>
Co-Authored-By: Pawel Kozlowski <pkozlowski.opensource@gmail.com>

PR Close #47754
2022-10-17 12:15:20 +02:00
Andrew Kushnir
ddbc4931e6 refactor(common): make provideHttpClient return EnvironmentProviders (#47758)
This commit updates the `provideHttpClient` function to return the `EnvironmentProviders` instead of a regular `Provider[]`, to make sure that the `provideHttpClient` can only be used where an environment is being setup.

PR Close #47758
2022-10-13 16:44:59 +00:00
Alex Castle
9483343ebf feat(common): Add fill mode to NgOptimizedImage (#47738)
Add a new boolean attribute to NgOptimizedImage called `fill` which does the following:
* Removes the requirement for height and width
* Adds inline styling to cause the image to fill its containing element
* Adds a default `sizes` value of `100vw` which will cause the image to have a responsive srcset automatically generated

PR Close #47738
2022-10-12 15:56:56 +00:00
Alan Agius
1b9fd46d14 feat(core): add support for Node.js version 18 (#47730)
This change aligns with the supported Node.js versions of the Angular CLI.
See: https://github.com/angular/angular-cli/pull/24026

BREAKING CHANGE: Angular no longer supports Node.js versions `14.[15-19].x` and `16.[10-12].x`. Current supported versions of Node.js are `14.20.x`, `16.13.x` and `18.10.x`.

PR Close #47730
2022-10-11 17:21:19 +00:00
jaybell
75e6297f09 feat(common): add <link> preload tag on server for priority img (#47343)
This commit adds a logic that generates preload tags for priority images, when rendering happens on the server (e.g. Angular Universal).

PR Close #47343
2022-10-10 20:48:10 +00:00
Andrew Kushnir
c0c7efaf7c feat(common): add provideLocationMocks() function to provide Location mocks (#47674)
This commit adds the `provideLocationMocks()` function that returns mocks for the `Location` and `LocationStrategy` classes. This function can be used in tests to configure an environment where it's possible to fire simulated location events (helpful when testing Router configuration).

PR Close #47674
2022-10-10 19:42:11 +00:00
Alex Castle
4fde292bb5 feat(common): Add automatic srcset generation to ngOptimizedImage (#47547)
Add a feature to automatically generate the srcset attribute for images using the NgOptimizedImage directive. Uses the 'sizes' attribute to determine the appropriate srcset to generate.

PR Close #47547
2022-10-10 16:21:08 +00:00
Matthias Weiß
bdb5371033 feat(common): add injection token for default DatePipe configuration (#47157)
This commit introduces a new `DATE_PIPE_DEFAULT_OPTIONS` token, which
can be used to configure default DatePipe options, such as date
format and timezone.

DEPRECATED:

The `DATE_PIPE_DEFAULT_TIMEZONE` token is now deprecated in favor
of the `DATE_PIPE_DEFAULT_OPTIONS` token, which accepts an object
as a value and the timezone can be defined as a field (called `timezone`)
on that object.

PR Close #47157
2022-10-07 09:16:00 -07:00
Alex Rickabaugh
ea16a98dfe fix(http): better handle unexpected undefined XSRF tokens (#47683)
`HttpXsrfTokenExtractor` allows returning `string|null` for an XSRF token,
and the interceptor checked if the returned token is `null`. However, some
implementations return `undefined` instead (behind an `any`) type, which
caused the interceptor to crash when trying to set an `undefined` value for
the header.

This commit makes the XSRF interceptor a little more resilient against such
broken implementations of the `HttpXsrfTokenExtractor` interface.

PR Close #47683
2022-10-06 16:41:06 -07:00
Alex Rickabaugh
c09c1bb033 docs(http): fix copy-paste error in HttpClientJsonpModule docs (#47502)
This commit deletes a sentence from the `HttpClientJsonpModule` docs which
was accidentally copy-pasted from the docs for another symbol.

PR Close #47502
2022-10-06 19:02:46 +00:00
Alex Rickabaugh
3ba99e286a feat(http): allow for child HttpClients to request via parents (#47502)
Ordinarily, providing `HttpClient` (either via `provideHttpClient` or the
`HttpClientModule`) creates an entirely separate HTTP context. Requests made
via that client are not passed through the interceptor chains that are
configured in a parent injector, for this example.

This commit introduces a new option for `provideHttpClient` called
`withRequestsMadeViaParent()`. When this option is passed, requests made in
the child context flow through any injectors, etc. and are then handed off
to the parent context.

This addresses a longstanding issue with interceptors where it's not
possible to extend the set of interceptors in a child context without
repeating all of the interceptors from the parent.

PR Close #47502
2022-10-06 19:02:46 +00:00
Alex Rickabaugh
62c7a7a16e feat(http): introduce functional interceptors (#47502)
This commit introduces a new feature for `provideHttpClient` called
`withInterceptors`. This feature exposes and configures the new concept of
functional interceptors.

Functional interceptors use functions instead of classes to implement an
HTTP interceptor. Such interceptor functions have access to the DI context
from the `EnvironmentInjector` in which they're configured via the
`inject()` function. Otherwise, functional interceptors are identical in
capability to the existing interceptor system.

PR Close #47502
2022-10-06 19:02:46 +00:00