Commit graph

420 commits

Author SHA1 Message Date
Yenya030
5800f17e19 refactor(service-worker): remove unnecessary cast in mock redirect check
Use the typed Response.redirected property directly in the service-worker test mock instead of casting to any.

(cherry picked from commit 57a07d0058)
2026-03-18 10:26:26 -07:00
Yenya030
e19150d2b5 fix(service-worker): preserve redirect policy on reconstructed asset requests
Preserve the redirect mode when rebuilding asset requests in newRequestWithMetadata(). This keeps explicit redirect:error semantics intact across service-worker redirect handling.

Update the worker test mocks to model redirect defaults correctly and add focused regression coverage for redirected lazy assets with redirect:error.

(cherry picked from commit 07abfbcc6c)
2026-03-18 10:26:25 -07:00
Kristiyan Kostadinov
da57d1af73 build: use TypeScript 5.9 for patch builds
Partially rolls back to using TypeScript 5.9 for the builds on the patch branch, because we bundle our TypeScript version with the language service which can introduce unexpected breakages for users.

Note that we still allow users to install TypeScript 6.
2026-03-04 07:59:23 -08:00
Kristiyan Kostadinov
81cabc1477 feat(core): add support for TypeScript 6
Updates the project to support TypeScript 6 and accounts for some of the breakages.
2026-02-17 08:40:38 -08:00
Matthieu Riegler
760910ecf1 Revert "refactor(service-worker): remove zone-based testing utilities"
This reverts commit 12b770d  (on top of the partial revert of #66978)
2026-02-09 15:52:26 -08:00
Matthieu Riegler
4b3b149ba1 refactor(benchpress): remove zone-based testing utilities
Transition to zoneless.
2026-02-09 07:55:12 -08:00
Matthieu Riegler
ec26d38778 refactor(service-worker): remove zone-based testing utilities
Transition to zoneless.
2026-02-09 07:55:12 -08:00
Anuj Chhajed
96b79fc393 refactor(core): correct all typeof ngDevMode comparison patterns introduced by #63875
This change replaces all remaining occurrences of `typeof ngDevMode !== undefined`
with the correct `typeof ngDevMode !== 'undefined'` form. This aligns the codebase
with JavaScript typeof semantics and maintains consistency with other Angular code.
2025-12-08 10:30:01 -08:00
Shuaib Hasan Akib
c7affdfbc9 refactor(common): update examples to align with Angular best practices
Updated examples to use the standalone component approach and the latest
2025-11-19 14:29:49 -08:00
Andrew Scott
4af408afcb Revert "feat(service-worker): notify clients about version failures (#62718)"
This reverts commit 6d011687ec.

issue #63500 reproduces at head on the main branch in the dev app.
Reverting this change along resolves it.

fixes https://github.com/angular/angular/issues/63500
2025-11-11 12:48:45 -08:00
SkyZeroZx
dde18c2303 docs: improve discoverability in service worker documentation 2025-11-11 08:32:14 -08:00
Alan Agius
26fed34e0e
build: format md files
This commit configures prettier to format markdown files.
2025-11-06 10:03:05 -08:00
SkyZeroZx
e63ea3f102 docs: update service worker documentation with additional references (#64353)
PR Close #64353
2025-10-15 10:47:48 -07:00
Matthieu Riegler
c50d659509 refactor(core): protect InjectionToken usage of ngDevMode (#63875)
Since those are top level APIs, `ngDevMode` might not be available at runtime if they're invoked before the variable is set.

fixes #62796

PR Close #63875
2025-09-19 21:27:45 +00:00
Kristiyan Kostadinov
8f59295019 refactor(core): remove unnecessary deps arrays (#63823)
We don't need to use the `deps` array syntax anymore since we have the `inject` function. These changes clean up the relevant usages.

PR Close #63823
2025-09-16 16:51:52 +00:00
Hongxu Xu
1f4c5f72aa refactor(bazel): reduce build deps (#63348)
clean up deps in bazel build scripts

PR Close #63348
2025-08-28 09:16:10 -07:00
Joey Perrott
2fcafb65c5 build: rename defaults2.bzl to defaults.bzl (#63383)
Use defaults.bzl for the common macros

PR Close #63383
2025-08-25 15:45:01 -07:00
Jessica Janiuk
1e3196b0c9 docs: add important service worker note (#63364)
This adds an important note about the service worker to indicate we are not accepting new features.

PR Close #63364
2025-08-25 08:18:31 -07:00
SkyZeroZx
3b214d2040 feat(service-worker): Logs unhandled promise rejections in service worker (#63059)
Adds handling and logging for unhandled promise rejections to improve debugging and prevent silent failures. Updates tests and test harness to verify logging of rejection reasons

PR Close #63059
2025-08-08 11:07:19 -07:00
SkyZeroZx
5220b51e75 feat(service-worker): Adds for type in provideServiceWorker (#62831)
Enables specifying the script type ('classic' or 'module') when registering Service Workers, improving compatibility with ES module features.

PR Close #62831
2025-08-06 15:10:27 +02:00
SkyZeroZx
700225a446 refactor(service-worker): improve localhost detection in scheduleInitialization (#62861)
Replaces ad hoc localhost check with a dedicated method using a regular expression for more reliable detection

PR Close #62861
2025-08-06 15:09:56 +02:00
Joey Perrott
fa8d8b8396 build: migrate all npm packages to use new rules_js based npm_package rule (#62954)
Use a common rule for all npm_packages

PR Close #62954
2025-08-05 19:08:45 +00:00
Joey Perrott
82cc576e6f build: use pnpm as the package manager instead of yarn (#62924)
Use pnpm instead of yarn as the package manager and interaction tool for the repo

PR Close #62924
2025-07-31 22:06:27 +00:00
SkyZeroZx
8255e0cf15 feat(service-worker): add messageerror event handling and logging (#62834)
Add messageerror event handling and logging to Driver class

PR Close #62834
2025-07-31 09:17:43 +00:00
Joey Perrott
cbc258eec8 build: remove ts_project_interop infrastructure (#62908)
Remove the interop macros and final usages

PR Close #62908
2025-07-31 09:12:58 +00:00
arturovt
e576c813c7 refactor(service-worker): align getRegistration() types (#62497)
In this commit, we align the service worker types with those provided by TypeScript. The `ServiceWorkerContainer.getRegistration()` method returns a `Promise<ServiceWorkerRegistration | undefined>`, but we were casting it to `Observable<ServiceWorkerRegistration>`, ignoring the possibility of `undefined`.

This is unsafe, as we should account for the case where the registration is `undefined` and handle it appropriately in the push manager.

PR Close #62497
2025-07-29 17:25:03 +00:00
Joey Perrott
793ff35602 build: move http_server and generate_api_docs into defaults2.bzl (#62878)
Move http_server and generate_api_docs into defaults2.bzl as they are rules_js compliant

PR Close #62878
2025-07-29 16:53:54 +00:00
Joey Perrott
c19d0aef4f build: use ts_config rule from rules_ts only and always load from common location (#62808)
Only use the ts_config rule from rules_ts, and always load the rule from tools/defaults2.bzl

PR Close #62808
2025-07-25 10:08:13 +02:00
SkyZeroZx
6d011687ec feat(service-worker): notify clients about version failures (#62718)
Add client notification when an app version fails, improving error
visibility and debugging capabilities. When a version encounters a
critical error, all clients using that version are now notified
with details about the failure.

- Add notifyClientsAboutVersionFailure method call in versionFailed
- Ensure clients receive VERSION_FAILED events with error details
- Improve service worker error transparency for better debugging

PR Close #62718
2025-07-24 11:30:49 +00:00
SkyZeroZx
b65c3d5e19 feat(service-worker): Improves storage full detection in data caching (#62737)
Adds proactive storage capacity checks using the Storage API
to better handle near-full conditions during data caching.
Replaces previous TODOs with actual usage monitoring and
logging to help prevent cache failures due to quota exhaustion.

PR Close #62737
2025-07-24 09:20:17 +00:00
SkyZeroZx
4ac6171b09 feat(service-worker): Adds support for updateViaCache in provideServiceWorker (#62721)
Enables configuration of the updateViaCache setting for service worker registration, allowing greater control over caching behavior during updates. Extends tests to cover new option and ensures correct propagation in registration logic.

PR Close #62721
2025-07-22 10:18:12 -04:00
Joey Perrott
8bf97d1370 build: remove all usages of the interop_deps attr for ts_project and ng_project (#62732)
Remove all of the usages of interop_deps as attributes in the repo

PR Close #62732
2025-07-21 13:03:09 -04:00
Joey Perrott
23d58777b4 build: migrate to new toolchain usage for api goldens (#62688)
Migrate api golden usage to be based on rules_js toolchain implementation

PR Close #62688
2025-07-17 18:13:42 -04:00
Kristiyan Kostadinov
745ea44394 feat(core): support TypeScript 5.9 (#62541)
Updates the repo to support TypeScript 5.9 and expands the allowed version range.

PR Close #62541
2025-07-14 14:04:58 -07:00
Joey Perrott
15bb25805f build: use esbuild from aspect rules (#62568)
Use the esbuild ruleset from aspect rules instead of via @bazel/esbuild

PR Close #62568
2025-07-10 13:45:15 -07:00
Jessica Janiuk
f9abb552ca Revert "fix(service-worker): update service worker to handle seeking better for videos (#60029)" (#62422)
This reverts commit c663277df6.

PR Close #62422
2025-07-02 07:50:14 +00:00
Joey Perrott
b84859073b build: migrate to use web test runner rules (#62292)
Migrate karma tests throughout the repo to use the new web test runner based rule instead

PR Close #62292
2025-06-26 17:19:10 +00:00
Joey Perrott
3a0cfd544d build: migrate to using new jasmine_test (#62086)
Use the new jasmine_test based on rules_js instead of jasmine_node_test from rules_nodejs

PR Close #62086
2025-06-18 08:27:26 +02:00
Jessica Janiuk
29e892a35e Revert "refactor(service-worker): make SwPush and SwUpdate tree-shakable (#61670)" (#61923)
This reverts commit f8c1b6e779.

PR Close #61923
2025-06-06 07:48:45 -07:00
arturovt
6e1df54799 feat(service-worker): support push subscription changes (#61856)
In this commit, support for `pushsubscriptionchange` events has been added to the service worker Driver.

When the push subscription changes, the Driver now captures the event and broadcasts a `PUSH_SUBSCRIPTION_CHANGE` message to clients. This ensures the application is aware of push events and can react accordingly.

Unfortunately, it's not possible to perform any end-to-end testing of this feature.

The push subscription change event exists in both Blink and Gecko. It is also supported in the latest version of Chrome, which means we can give users the ability to react to this event in order to gather feedback on whether other components might need updates.

PR Close #61856
2025-06-04 14:16:51 -04:00
arturovt
f8c1b6e779 refactor(service-worker): make SwPush and SwUpdate tree-shakable (#61670)
In this commit, we mark the `SwPush` and `SwUpdate` classes as root providers. As a result, they are no longer statically referenced in the `provideServiceWorker` providers list, which previously forced them to be explicitly bundled into the main file. These classes might never be used—some consumers may use the service worker only for prefetching and caching assets.

Practically speaking, even if a user injects the `SwPush` class without calling `provideServiceWorker()`, it would result in a DI error because the communication channel dependency is not available. There is no practical reason to keep these classes as non-root providers or to reference them explicitly.

Currently, some users work around this by using `patch-package` to modify the service worker code and remove these classes from the providers list.

PR Close #61670
2025-06-04 14:15:32 -04:00
Paul Gschwendtner
d081ef9b06 build: replace all ng_package with new rule from rules_angular (#61843)
Replaces all `ng_package` rule with the new rule from `rules_angular`.

PR Close #61843
2025-06-04 09:13:41 +00:00
arturovt
6adf022f0d fix(service-worker): prevent duplicate fetches during concurrent update checks (#61443)
Previously, multiple simultaneous calls to `checkForUpdate()` could result in redundant
fetches and hashing of the update manifest, leading to unnecessary network and CPU usage.

This change introduces a mechanism to track an in-progress update check using a cached
promise (`ongoingCheckForUpdate`). Subsequent calls to `checkForUpdate()` while a check
is in progress will return the same promise instead of triggering a new request.

Once the check completes (successfully or not), the cached promise is cleared,
allowing future update checks to proceed normally.

This improves efficiency and prevents overlapping update logic in applications that
may invoke `checkForUpdate()` from multiple sources (e.g. polling, manual triggers).

PR Close #61443
2025-06-03 15:57:30 -04:00
arturovt
c67dbda8ff feat(service-worker): support notification closes (#61442)
In this commit, support for `notificationclose` events has been added to the service worker Driver.

When a notification is closed (either by user dismissal or programmatically), the Driver now captures the event, extracts the relevant notification options, and broadcasts a `NOTIFICATION_CLOSE` message to clients. This ensures the application is aware of notification lifecycle events and can react accordingly.

PR Close #61442
2025-06-03 15:02:12 -04:00
zachend
c663277df6 fix(service-worker): update service worker to handle seeking better for videos (#60029)
This update ensures that the service worker can handle range requests, allowing video seeking to work correctly when videos are delivered by the service worker.

PR Close #60029
2025-06-03 10:56:06 -04:00
Alan Agius
67a0576598 build: exclude esbuild metadata files from distributable packages (#61636)
Prevents esbuild generated metadata files from being included in build artifacts. This reduces package size and avoids shipping unnecessary internal build data.

PR Close #61636
2025-05-26 08:57:41 +00:00
Alan Agius
6899b27762 build: update all esbuild target to node20 (#61606)
This is the min supported node.js version

PR Close #61606
2025-05-22 13:02:03 -07:00
arturovt
ce916fe08c fix(service-worker): do not register service worker if app is destroyed before it is ready to register (#61101)
In this commit, we check whether the application is destroyed before calling `serviceWorker.register(...)`. We should not register the worker because other resources will not be available.

PR Close #61101
2025-05-22 10:02:39 -07:00
Alan Agius
8f65223bd8 fix(core): update min Node.js support to 20.19, 22.12, and 24.0 (#61499)
This is to match the versions of the Angular CLI.

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

PR Close #61499
2025-05-20 14:15:13 +00:00
Joey Perrott
68d774f49d build: use common macro to define tsconfig for service worker (#61341)
Define the tsconfig for service worker instead of manually including the tsconfig on each target

PR Close #61341
2025-05-14 10:43:25 -07:00