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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@muzzamil7770/app-update-agent

v1.0.3

Published

Framework-agnostic Angular app version monitor — detects updates, clears cache, unregisters service workers, and reloads with pluggable UI

Readme

@muzzamil7770/app-update-agent

npm version npm downloads license TypeScript Angular GitHub Actions

Detects app version changes, prompts users to update, clears cache, unregisters service workers, and reloads — with a pluggable UI and full Angular support.

npm i @muzzamil7770/app-update-agent

Preview

Update Prompt

The dialog shown to the user when a new version is detected.

Update Prompt


Video Demo

Watch the full update flow — version detection → prompt → cache clear → reload.

💡 If the video doesn't play inline, click here to watch the demo


How It Works

Full Update Flow

flowchart TD
    A([App Starts]) --> B[startMonitoring called]
    B --> C{devMode?}
    C -- Yes, no override --> Z([Monitoring Disabled])
    C -- No / forceInDevMode --> D[Poll /version.json every 60s]
    D --> E{Network Request\nGET /version.json?t=timestamp}
    E -- Fetch fails --> F[Retry up to 3x\nwith 2s delay]
    F -- All retries fail --> D
    E -- Success --> G{Version changed?}
    G -- No change --> D
    G -- Yes --> H[onUpdateDetected hook fired]
    H --> I[Show Update Prompt UI]
    I -- User dismisses --> D
    I -- User confirms --> J[Show Progress UI]
    J --> K[Clear all browser caches]
    K --> L[Unregister Service Workers]
    L --> M[onReload hook fired]
    M --> N([window.location.reload])

Build & Publish Pipeline

flowchart LR
    A([git push to main]) --> B[GitHub Actions triggered]
    B --> C[npm ci — install deps]
    C --> D[npm version patch\nauto bump 1.0.0 → 1.0.1]
    D --> E[git push version bump\nback to main with skip-ci tag]
    E --> F[npm run build\ntsc compiles to dist/]
    F --> G[npm publish --access public]
    G --> H[GitHub Release created]
    H --> I([New version live on npm 🎉])

Network Version Check Internals

sequenceDiagram
    participant App
    participant UpdateEngine
    participant Network as /version.json
    participant UI

    App->>UpdateEngine: startMonitoring()
    loop Every pollInterval (60s)
        UpdateEngine->>Network: GET /version.json?t={timestamp}
        alt fetch succeeds
            Network-->>UpdateEngine: { version: "1.0.5" }
            UpdateEngine->>UpdateEngine: compare with stored version
            alt version changed
                UpdateEngine->>UI: showUpdatePrompt(meta)
                UI-->>UpdateEngine: user confirmed
                UpdateEngine->>UI: showProgress(...)
                UpdateEngine->>App: clearCache + unregisterSW
                UpdateEngine->>App: reload()
            end
        else fetch fails
            UpdateEngine->>UpdateEngine: retry (up to 3x, 2s apart)
        end
    end

Installation

npm i @muzzamil7770/app-update-agent

With SweetAlert2 UI (default):

npm i @muzzamil7770/app-update-agent sweetalert2

Quick Start (Angular)

// app.component.ts
import { AppUpdateService } from '@muzzamil7770/app-update-agent';

constructor(private appUpdate: AppUpdateService) {}

ngOnInit() {
  this.appUpdate.startMonitoring();
}

Zero config needed — defaults match the original behaviour exactly.


Configuration

Configure once globally before startMonitoring() (e.g. in main.ts):

import { AppUpdateService } from '@muzzamil7770/app-update-agent';

AppUpdateService.configure({
  versionUrl:       '/version.json',  // default
  pollInterval:     60_000,           // ms, default
  ui:               'sweetalert',     // 'sweetalert' | 'custom' | 'none'
  devMode:          false,            // set true in dev builds
  forceInDevMode:   false,            // override devMode guard for testing
  retryAttempts:    3,                // fetch retries on failure
  retryDelay:       2000,             // ms between retries
  onUpdateDetected: (meta) => console.log('Update detected:', meta),
  onReload:         ()     => console.log('Reloading…'),
});

Dev Mode Testing

When devMode: true, monitoring is disabled unless:

  • URL contains ?appUpdateTest=1
  • localStorage.app_update_test === '1'
// Browser console
window.simulateAppUpdate();
// Programmatic
await this.appUpdate.manualCheck();

Custom UI

import { AbstractUpdateUI, VersionMeta } from '@muzzamil7770/app-update-agent';

class MyToastUI extends AbstractUpdateUI {
  showUpdatePrompt(meta: VersionMeta, onConfirm: () => void, onDismiss: (meta: VersionMeta) => void) {
    // show your toast/modal
  }
  showProgress(label: string, pct: number) { /* open progress modal */ }
  updateProgress(label: string, pct: number) { /* update progress bar */ }
}

AppUpdateService.setUI(new MyToastUI());

Set ui: 'none' to suppress all UI and handle onUpdateDetected yourself.


Framework-Agnostic Core

import { UpdateEngine, SwalUpdateUI } from '@muzzamil7770/app-update-agent';

const engine = new UpdateEngine(
  { versionUrl: '/version.json', pollInterval: 30_000 },
  new SwalUpdateUI(),
);

engine.start();
engine.stop();
await engine.manualCheck();

API Reference

AppUpdateService (Angular)

| Method | Description | |---|---| | static configure(config) | Set global config before first use | | static setUI(ui) | Inject a custom UI implementation | | startMonitoring() | Begin polling + visibility listener | | manualCheck() | Trigger an immediate version check |

UpdateEngine (Core)

| Method | Description | |---|---| | start() | Begin polling | | stop() | Stop polling and clear interval | | manualCheck() | Trigger an immediate version check |

UpdateAgentConfig

| Option | Type | Default | Description | |---|---|---|---| | versionUrl | string | '/version.json' | URL to fetch version from | | pollInterval | number | 60000 | Polling interval in ms | | ui | 'sweetalert' \| 'custom' \| 'none' | 'sweetalert' | UI mode | | devMode | boolean | false | Disable monitoring in dev | | forceInDevMode | boolean | false | Override devMode guard | | retryAttempts | number | 3 | Fetch retry count | | retryDelay | number | 2000 | Ms between retries | | onUpdateDetected | (meta) => void | — | Hook fired on version change | | onReload | () => void | — | Hook fired before reload |


Links

  • 📦 npm: https://www.npmjs.com/package/@muzzamil7770/app-update-agent
  • 🐙 GitHub: https://github.com/muzzamil7770/app-update-agent
  • 🐛 Issues: https://github.com/muzzamil7770/app-update-agent/issues