791 Commits

Author SHA1 Message Date
Andrew Scott a9a7e9fb00 refactor(router): Remove files no longer in use (#48500)
These files exist to support internal patches that are no longer needed

PR Close #48500
2023-01-05 14:42:27 -08:00
Paul Gschwendtner cca335dc40 refactor: update packages/router tests to be compatible with ESM (#48538)
The ESM js files need to be referenced, and the router tests rely
on `async/await` with change detection- so a special rule is required
that downlevels `async/await` to generators (similar to the Angular CLI)

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner 5915c7dcfb build: ensure bootstrap transitive runfiles are made available (#48538)
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 #48538
2022-12-19 20:12:35 +00:00
Paul Gschwendtner ff80ced26e build: replace _es2015 shorthand with more flexible _files suffix (#48538)
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 #48538
2022-12-19 20:12:34 +00:00
Andrew Scott 9291bd950f refactor(router): Add opt-in provider for upcoming router change (#47988)
This commit adds a swappable provider for an upcoming change to the
implementation of `Router#createUrlTree`. This will be a breaking change
and is planned to be included in V16.

PR Close #47988
2022-12-13 16:57:46 -08:00
Andrew Scott a3fbc2730a docs(router): Update ROUTES docs to not point to provideRoutes (#48417)
provideRoutes is deprecated in favor of the ROUTES token directly
for complex situations where it's necessary.

fixes #48411

PR Close #48417
2022-12-12 09:36:39 -08:00
Andrew Scott 06c34cd99a refactor(router): Remove assignExtraOptionsToRouter helper function (#48313)
This commit removes the unnecessary `assignExtraOptionsToRouter` helper
function. This helper is not necessary because the options can be
retrieved from DI and assigned during the construction on the Router.

PR Close #48313
2022-12-05 12:01:57 -08:00
Andrew Scott 58e55495f2 refactor(router): Eliminate constructor parameters in Router class (#48313)
The Router constructor and `setupRouter` factory mainly exist as a
legacy configuration. Since the Router's creation, the style in Angular
has evolved quite a bit. This commit eliminates and cleans up some
unnecessary comlicated code paths related to the router
constructor/factory.

Note that there are edits to the `setupTestingRouter` that could be seen
as breaking. However, it is not for several reasons:

1. The function is documented as a factory function. If used as
   documented, the parameters should match what's available in DI
2. The function is totally unused by the Router itself and is not used
   in g3 either. I believe it was made publicApi by an error when
   updating documentation annotations long ago.

PR Close #48313
2022-12-05 12:01:57 -08:00
Andrew Scott 2a445923ee refactor(router): Remove DeprecatedLoadChildren (#48292)
This option has already been removed from availability externally. Internally, the last use has been removed
for the type on Route.loadChildren. More testing will be necessary to verify nothing relies on the other
code paths.

PR Close #48292
2022-11-30 08:29:11 -08:00
Andrew Scott 82756e8a5f refactor(router): Move navigationId handling to the transition manager (#48257)
The navigationId is really just a count of how many navigations have been
processed through the navigation pipeline. This tracking should be
done as part of the navigation transition handler

PR Close #48257
2022-11-29 14:55:53 -08:00
Andrew Scott 60af2d091c refactor(router): Move transition subject into transition handler (#48257)
The navigation transitions subject belongs in the navigation transitions handler
rather than the Router.

PR Close #48257
2022-11-29 14:55:53 -08:00
Andrew Scott 92066f162d refactor(router): directly inject internal properties from DI (#48257)
Rather than accessing router internal properties that are available in DI,
this commit directly injects those dependencies in the navigation transition
handler. Note that there are several other items that _should_ be injectable
in DI (like the TitleStrategy) but because those are part of the Router public
interface and writeable(!), they might be changed during runtime. We
have to get these other items from the Router for now...

PR Close #48257
2022-11-29 14:55:53 -08:00
Andrew Scott 0a36f4fbc8 refactor(router): Get EnvironmentInjector directly in transition handler (#48257)
Remove the NgModuleRef from the internal interface of the Router. This
was only used to get the injector (equivalent to EnvironmentInjector).
Instead, the navigation transition handler can directly inject the
EnvironmentInjector

PR Close #48257
2022-11-29 14:55:53 -08:00
Andrew Scott 8e46fb5676 refactor(router): Move configLoader to transition handler (#48257)
The ConfigLoader is only used as part of the navigation transition.
Moving the loader there completes the removal of event triggering in
the router code. This all now lives in the transition handler (plus
the router scroller, but let's ignore that...).

PR Close #48257
2022-11-29 14:55:53 -08:00
Andrew Scott f36cf49330 refactor(router): Move events subject to transition class (#48257)
The events observable is part of the lifecycle of a navigation. This should
be contained in the NavigationTransitions class rather than the Router.
This Subject is re-exported by the router as an observable to maintain
the public API

PR Close #48257
2022-11-29 14:55:52 -08:00
Andrew Scott 2409dd6530 refactor(router): remove malformedUriHandler from interface passed to transitions (#48257)
The malformedUriHandler is not used during the navigation transition and can be removed form the interface

PR Close #48257
2022-11-29 14:55:52 -08:00
Andrew Scott a192dea677 Revert "refactor(router): remove malformedUriHandler from interface passed to transitions (#48257)" (#48270)
This reverts commit c20a7eeba6.

PR Close #48270
2022-11-28 16:58:53 -08:00
Andrew Scott d29cbe885c Revert "refactor(router): Move events subject to transition class (#48257)" (#48270)
This reverts commit f88559eb48.

PR Close #48270
2022-11-28 16:58:53 -08:00
Andrew Scott 1eef647236 Revert "refactor(router): Move configLoader to transition handler (#48257)" (#48270)
This reverts commit 8c8ded8d31.

PR Close #48270
2022-11-28 16:58:53 -08:00
Andrew Scott 9745fac73f Revert "refactor(router): Get EnvironmentInjector directly in transition handler (#48257)" (#48270)
This reverts commit 03519968c0.

PR Close #48270
2022-11-28 16:58:52 -08:00
Andrew Scott 7032bf0780 Revert "refactor(router): directly inject internal properties from DI (#48257)" (#48270)
This reverts commit ce38759f54.

PR Close #48270
2022-11-28 16:58:52 -08:00
Andrew Scott 88aec875c0 Revert "refactor(router): Move transition subject into transition handler (#48257)" (#48270)
This reverts commit 0d88348430.

PR Close #48270
2022-11-28 16:58:52 -08:00
Andrew Scott f2d20d5c50 Revert "refactor(router): Move navigationId handling to the transition manager (#48257)" (#48270)
This reverts commit ea114a0034.

PR Close #48270
2022-11-28 16:58:52 -08:00
Matthieu Riegler aa920aa89a refactor(router): remove non-null assertions (#48244)
As part of #24571, removing non-null assertions (where appropriate)

PR Close #48244
2022-11-28 13:07:59 -08:00
Andrew Scott ea114a0034 refactor(router): Move navigationId handling to the transition manager (#48257)
The navigationId is really just a count of how many navigations have been
processed through the navigation pipeline. This tracking should be
done as part of the navigation transition handler

PR Close #48257
2022-11-28 11:54:43 -08:00
Andrew Scott 0d88348430 refactor(router): Move transition subject into transition handler (#48257)
The navigation transitions subject belongs in the navigation transitions handler
rather than the Router.

PR Close #48257
2022-11-28 11:54:43 -08:00
Andrew Scott ce38759f54 refactor(router): directly inject internal properties from DI (#48257)
Rather than accessing router internal properties that are available in DI,
this commit directly injects those dependencies in the navigation transition
handler. Note that there are several other items that _should_ be injectable
in DI (like the TitleStrategy) but because those are part of the Router public
interface and writeable(!), they might be changed during runtime. We
have to get these other items from the Router for now...

PR Close #48257
2022-11-28 11:54:43 -08:00
Andrew Scott 03519968c0 refactor(router): Get EnvironmentInjector directly in transition handler (#48257)
Remove the NgModuleRef from the internal interface of the Router. This
was only used to get the injector (equivalent to EnvironmentInjector).
Instead, the navigation transition handler can directly inject the
EnvironmentInjector

PR Close #48257
2022-11-28 11:54:43 -08:00
Andrew Scott 8c8ded8d31 refactor(router): Move configLoader to transition handler (#48257)
The ConfigLoader is only used as part of the navigation transition.
Moving the loader there completes the removal of event triggering in
the router code. This all now lives in the transition handler (plus
the router scroller, but let's ignore that...).

PR Close #48257
2022-11-28 11:54:43 -08:00
Andrew Scott f88559eb48 refactor(router): Move events subject to transition class (#48257)
The events observable is part of the lifecycle of a navigation. This should
be contained in the NavigationTransitions class rather than the Router.
This Subject is re-exported by the router as an observable to maintain
the public API

PR Close #48257
2022-11-28 11:54:43 -08:00
Andrew Scott c20a7eeba6 refactor(router): remove malformedUriHandler from interface passed to transitions (#48257)
The malformedUriHandler is not used during the navigation transition and can be removed form the interface

PR Close #48257
2022-11-28 11:54:43 -08:00
Andrew Scott 621013af2a refactor(router): move lastSuccesfulNavigation to navigation transitions (#48257)
lastSuccessfulNavigation is only used in the transition so it does not need to live in Router

PR Close #48257
2022-11-28 11:54:43 -08:00
Andrew Scott dc23ad4978 refactor(router): extract navigation transition code to a new file (#48187)
This commit extracts the Router's navigation "transitions" to a separate
file. The goal here is twofold:

- Separate the Router's logic into more manageable chunks. Rather than
  having to always edit a 1000+ line file, this separates different
  pieces into smaller, more focused files
- More importantly, this sets the groundwork for separating the Router
  state from the individual navigation transition. That is, it would be
  good for the rxjs pipeline to _not_ modify the Router state but only
  keep track of its own intermediate stages and emit outwards during
  important events. The Router can subscribe to those events and make
  updates to its state. This would theoretically allow us to swap those
  implementations independently. That is, the Router's state management
  can be changed without changing the transition handling and
  vice-versa.

PR Close #48187
2022-11-22 18:58:38 -08:00
Joey Perrott 8600b3077d build: reformat BUILD files
Reformat BUILD file usage of globs.
2022-11-22 13:51:19 -07:00
Derek Cormier 500acfcf98 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:19 -07:00
Derek Cormier 8d24a91c6a 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:19 -07:00
Derek Cormier a36034a135 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:19 -07:00
Derek Cormier 12855f3805 build(bazel): incrementally run aio example e2e tests
Replaces the workflow where all example e2es are run at once
2022-11-22 13:51:19 -07:00
Derek Cormier c9478f78a2 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:19 -07:00
Andrew Scott ebcca47402 refactor(router): Update RouterOutlet to not read internal route property (#48112)
The `RouterOutlet` currently reads the `_futureSnapshot` of the Route.
However, by the time `activateWith` is called, this value is the same as
`snapshot` (https://github.com/angular/angular/blob/414b1b2d5ffe8eac33749bf472af7eafcf248dba/packages/router/src/operators/activate_routes.ts#L163-L205).

This change will make it easier for developers to fork the `RouterOutlet`
implementation if necessary without needing to modify any code.

PR Close #48112
2022-11-22 11:37:38 -08:00
Andrew Scott 11d916dcfd refactor(router): Remove unnecessary logic in enabledBlocking option (#48064)
The `initNavigated` flag is not necessary. The way `enabledBlocking`
works is by blocking any navigations from finishing until the
application has bootstrapped. The bootstrap is unblocked as soon as we
hit the `afterPreactivation` step. After that point,
`afterPreactivation` is always unblocked because the `bootstrapDone`
Subject is completed/stopped. There is no need for an additional
variable to track this information.

PR Close #48064
2022-11-22 11:36:14 -08:00
Andrew Scott d50fa6b79e test(router): Update flaky tests to consistently pass (#48176)
This commit makes several updates to the bootstrap tests of the Router.
The change that made the real difference was providing
`MockPlatformLocation`. Other changes include:

* using `async/await` instead of `done`
* not providing APP_BASE_HREF (recent router refactors made this unnecessary)
* using some functional guards to simplify some tests

PR Close #48176
2022-11-22 11:33:19 -08:00
Nebojsa Cvetkovic fa5528fb5f 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 890feb9332 Revert "refactor(router): Remove promise catch and re-reject (#48067)" (#48135)
This reverts commit 07c9396824. This
change caused test failures (both unit and integration). Though the code
looks like it should be a no-op update, it's possible it affecting
something to do with microtasks, zoneJS, and change detection. More
investigation would need to be done into the exact nature of the
failures.

PR Close #48135
2022-11-21 09:24:00 -08:00
Andrew Scott a04c5387e5 Revert "Revert "refactor(router): Simplify router defaults by making the defaults Injectable" (#48121)" (#48135)
This reverts commit 57d9296802. The
original commit was not problematic and was mistakenly reverted.

PR Close #48135
2022-11-21 09:24:00 -08:00
Dylan Hunn e73f5e0cd8 Revert "refactor(router): Simplify router defaults by making the defaults Injectable" (#48121)
This reverts commit 18033d5ed2.

PR Close #48121
2022-11-18 12:16:17 -08:00
Andrew Scott 9baefd085f fix(router): Ensure renavigating in component init works with enabledBlocking (#48063)
The way to complete the `Subject` in a way that is able to be read on
the subject properties itself is to call `unsubscribe`:
https://github.com/ReactiveX/rxjs/blob/afac3d574323333572987e043adcd0f8d4cff546/src/internal/Subject.ts#L101-L104
This sets the `closed` property to `true` whereas `complete` does not.

fixes #48052

PR Close #48063
2022-11-17 11:01:14 -08:00
Andrew Scott 02b9d435d1 docs(router): Further document rawUrlTree (#48108)
Further document the rawUrlTree and how it's used internally in the Router.

PR Close #48108
2022-11-17 11:00:27 -08:00
Matthieu Riegler e4309d57d8 fix(router): correct type of nextState parameter in canDeactivate (#48038)
Correct type of nextState parameter in canDeactivate guard to indicate it's never undefined

Fixes #47153

PR Close #48038
2022-11-17 09:35:03 -08:00
Andrew Scott 371871a077 refactor(router): Simplify router defaults by making the defaults Injectable (#48022)
The router has several default strategy implementations that are either
assigned via `new XStrategy()` property assignements or via the factory
function for the `Router` itself. These can be simplified by providing
the default implementation in the strategy `Injectable`. Custom
implementations can still override the defaults by specifying them in
the `providers` list.

Notably, this change also makes the `UrlHandlingStrategy` and
`RouteReuseStrategy` defaults injectable via DI rather than having to
indirectly grab them by going through the `Router` instance and
accessing the properties.

PR Close #48022
2022-11-17 09:25:40 -08:00