npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hug/ngx-app-updater

v2.0.3

Published

Notify about Angular application's update

Downloads

22

Readme

This library is a wrapper around the official @angular/service-worker library with extra functionalities.

It adds Progressive Web App supports and updates notifications to an Angular project.

Getting started

To set up or update an Angular project with this library use the Angular CLI's schematic commands:

Installation

ng add @hug/ngx-app-updater

The ng add command will ask you the following questions:

  1. Allow user to cancel an update: whether a user can choose to cancel an update or not

And will also perform the following actions:

  • Imports and registers the service worker in the application.
  • Provide and initialize the library.
  • Adds icons and screenshots files to support the installed PWA.
  • Adds a manifest.webmanifest file.
  • Adds a ngsw-config.json file.
  • Updates the index.html to links the manifest and adds theme-color and noscript tags.

Update

ng update @hug/ngx-app-updater

Features

🚀 Progressive Web App

  • Adds caching and offline behaviors through ngsw-config.json file.
  • Adds icons and screenshots files to support the installed PWA.
  • Adds a manifest.webmanifest file.
  • Updates the index.html to links the manifest and adds theme-color and noscript tags.

📣 Notification

When a new version of your application is deployed, this library will trigger a user notification to inform them that updates are available.

This is particularly useful to ensure that users who rarely close or refresh their web browsers are always running the latest version.

They can choose to update immediately, delay the update until a later time, or be forced to update.

By default, updates are checked every minute, and users are prompted about updates every day.

Usage

Have a look at the Options section to discover what can be customized.

TIP: in case @angular/material is installed, the dialog will be themed accordingly.

TIP: you can provide your own dialog, following this example and using the dialogOptions.component option.

4️⃣0️⃣4️⃣ Not found page

If a new route is to be released in a new version of your application, users that are still using an old version of the application will not be able to access that url on a first try.

To mitigate this behavior, this library provides a 404 page that you could use to notify a user about a potential update.

Users will then be able to relaunch their application, apply the update and be presented with the new route.

Usage

Have a look at the Options section to discover what can be customized.

TIP: in case @angular/material is installed, this page will be themed accordingly.

TIP: you can design your own 404 page following this example.

import { Routes } from '@angular/router';
import { HomePage } from './home.component';

export const routes: Routes = [
  { path: '', component: HomePage },
  {
    path: '**',
    pathMatch: 'full',
    loadComponent: () => import('@hug/ngx-app-updater/not-found').then(m => m.NgxAppUpdaterNotFoundPage)
  }
];

Options

You shouldn't have to configure anything else but in case you wanted to, you can still do it.

The behavior of the library can be configured either in:

  • main.ts (if the app is a standalone Angular application)

    bootstrapApplication(AppComponent, {
      providers: [
        provideAppUpdater(options?: NgxAppUpdaterOptions)
      ]
    });
  • app.module.ts (if the app is not a standalone Angular application)

    @NgModule({
      imports: [
        NgxAppUpdaterModule.forRoot(options?: NgxAppUpdaterOptions)
      ]
    })
    export class AppModule { }

Development

See the developer docs.

Contributing

> Want to Help?

Want to file a bug, contribute some code or improve documentation? Excellent!

But please read up first on the guidelines for contributing, and learn about submission process, coding rules and more.

> Code of Conduct

Please read and follow the Code of Conduct, and help us keep this project open and inclusive.

Credits

Copyright (C) 2021 HUG - Hôpitaux Universitaires Genève

love@hug