Bit.Bswup 9.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Bit.Bswup --version 9.1.0                
NuGet\Install-Package Bit.Bswup -Version 9.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bit.Bswup" Version="9.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Bit.Bswup --version 9.1.0                
#r "nuget: Bit.Bswup, 9.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Bit.Bswup as a Cake Addin
#addin nuget:?package=Bit.Bswup&version=9.1.0

// Install Bit.Bswup as a Cake Tool
#tool nuget:?package=Bit.Bswup&version=9.1.0                

bit Blazor Service-Worker Update Progress (bit Bswup)

To use the bit Bswup, please follow these steps:

  1. Install the Bit.Bswup nuget package:
dotnet add package Bit.Bswup
  1. Enable static file caching. You can follow the below code in the Startup.cs file:
app.UseStaticFiles(new StaticFileOptions
{
    OnPrepareResponse = ctx =>
    {
        if (env.IsDevelopment() is false)
        {
            // https://bitplatform.dev/templates/cache-mechanism
            ctx.Context.Response.GetTypedHeaders().CacheControl = new()
            {
                MaxAge = TimeSpan.FromDays(7),
                Public = true
            };
        }
    }
});
  1. In the default document (index.html, _Host.cshtml, or _Layout.cshtml), add autostart="false" to the script tag for the Blazor script:
<script src="_framework/blazor.webassembly.js" autostart="false"></script>
  1. Also In the default document (index.html, _Host.cshtml, or _Layout.cshtml), add the bit-bswup.js script tag after the Blazor script tag with needed options:
<script src="_content/Bit.Bswup/bit-bswup.js"
        scope="/"
        log="verbose"
        sw="service-worker.js"
        handler="bitBswupHandler"></script>
  • scope: The scope of the service-worker (read more).
  • log: The log level of the Bswup logger. available options are: info, verbose, debug, and error. (not implemented yet)
  • sw: The file path of the service-worker file.
  • handler: The name of the handler function for the service-worker events.

You can remove any of these attributes, and use the default values mentioned above.

  1. Add a handler function like the below code to handle multiple events of the Bswup, or you can follow the full sample code which is provided in the Demo projects of this repo.
const appEl = document.getElementById('app');
const bswupEl = document.getElementById('bit-bswup');
const progressBar = document.getElementById('bit-bswup-progress-bar');
const reloadButton = document.getElementById('bit-bswup-reload');

function bitBswupHandler(type, data) {
    switch (type)
    {
        case BswupMessage.updateFound: return console.log('an update found.');

        case BswupMessage.stateChanged: return console.log('state has changed to:', data.currentTarget.state);

        case BswupMessage.activate: return console.log('new version activated:', data.version);

        case BswupMessage.downloadStarted: 
            appEl.style.display = 'none';
            bswupEl.style.display = 'block';
            return console.log('downloading assets started:', data?.version);

        case BswupMessage.downloadProgress:
            progressBar.style.width = `${percent}%`;
            return console.log('asset downloaded:', data);

        case BswupMessage.downloadFinished:
            if (data.firstInstall) {
                data.reload().then(() => {
                    appEl.style.display = 'block';
                    bswupEl.style.display = 'none';
                });
            } else {
                reloadButton.style.display = 'block';
                reloadButton.onclick = data.reload;
            }
            return console.log('downloading assets finished.');

        case BswupMessage.updateReady:
            reloadButton.style.display = 'block';
            reloadButton.onclick = data.reload;
            return console.log('new update ready.');
    }
}
  1. Configure additional settings in the service-worker file like the following code:
self.assetsInclude = [/\data.db$/];
self.assetsExclude = [/\.scp\.css$/, /weather\.json$/];
self.defaultUrl = '/';
self.prohibitedUrls = [/\/admin\//];
self.serverHandledUrls = [/\/api\//];
self.serverRenderedUrls = [/\/privacy$/];
self.externalAssets = [
    {
        "url": "/"
    },
    {
        "url": "https://www.googletagmanager.com/gtag/js?id=G-G123456789"
    }
];
self.assetsUrl = '/service-worker-assets.js';
self.noPrerenderQuery = 'no-prerender=true';

self.caseInsensitiveUrl = true;
self.ignoreDefaultInclude = true;
self.ignoreDefaultExclude = true;
self.isPassive = true;
self.disablePassiveFirstBoot = true;
self.enableIntegrityCheck = true;
self.enableDiagnostics = true;
self.enableFetchDiagnostics = true;

self.importScripts('_content/Bit.Bswup/bit-bswup.sw.js');

The most important line here is the last line which is the only mandatory config in this file that imports the Bswup service-worker file:

self.importScripts('_content/Bit.Bswup/bit-bswup.sw.js');

The other settings are:

  • assetsInclude: The list of file names from the assets list to include when the Bswup tries to store them in the cache storage (regex supported).
  • assetsExclude: The list of file names from the assets list to exclude when the Bswup tries to store them in the cache storage (regex supported).
  • externalAssets: The list of external assets to cache that are not included in the auto-generated assets file. For example, if you're not using index.html (like _host.cshtml), then you should add { "url": "/" }.
  • defaultUrl: The default page URL. Use / when using _Host.cshtml.
  • assetsUrl: The file path of the service-worker assets file generated at compile time (the default file name is service-worker-assets.js).
  • prohibitedUrls: The list of file names that should not be accessed (regex supported).
  • caseInsensitiveUrl: Enables the case insensitivity in the URL checking of the cache process.
  • serverHandledUrls: The list of URLs that do not enter the service-worker offline process and will be handled only by server (regex supported). such as /api, /swagger, ...
  • serverRenderedUrls: The list of URLs that should be rendered by the server and not client while navigating (regex supported). such as /about.html, /privacy, ...
  • noPrerenderQuery: The query string attached to the default document request to disable the prerendering from the server so an unwanted prerendered result not be cached.
  • ignoreDefaultInclude: Ignores the default asset includes array which is provided by the Bswup itself which is like this:
    [/\.dll$/, /\.pdb$/, /\.wasm/, /\.html/, /\.js$/, /\.json$/, /\.css$/, /\.woff$/, /\.png$/, /\.jpe?g$/, /\.gif$/, /\.ico$/, /\.blat$/, /\.dat$/, /\.svg$/, /\.woff2$/, /\.ttf$/, /\.webp$/]
    
  • ignoreDefaultExclude: Ignores the default asset excludes array which is provided by the Bswup itself which is like this:
    [/^_content\/Bit\.Bswup\/bit-bswup\.sw\.js$/, /^service-worker\.js$/]
    
  • isPassive: Enables the Bswup's passive mode. In this mode, the assets won't be cached in advance but rather upon initial request.
  • disablePassiveFirstBoot: Disables downloading the Blazor's boot files in first time of Passive mode.
  • enableIntegrityCheck: Enables the default integrity check available in browsers by setting the integrity attribute of the request object created in the service-worker to fetch the assets.
  • errorTolerance: Determines how the Bswup should handle the errors while downloading assets. Possible values are: strict, lax, config.
  • enableDiagnostics: Enables diagnostics by pushing service-worker logs to the browser console.
  • enableFetchDiagnostics: Enables fetch event diagnostics by pushing service-worker fetch event logs to the browser console.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on Bit.Bswup:

Repository Stars
bitfoundation/bitplatform
Build all of your apps using what you already know and love ❤️
functionland/fx-files
You want to literally own your files? This is something won't happen on traditional cloud services in a lifetime. And this is something is going to happen in a glance with "Fx Files" app from now on. It is a file manager which stores everything on Fula blockchain network of Bloxes.
Version Downloads Last updated
9.1.2 145 12/24/2024
9.1.2-pre-01 85 12/23/2024
9.1.1 426 12/15/2024
9.1.1-pre-01 77 12/15/2024
9.1.0 118 12/14/2024
9.1.0-pre-13 89 12/13/2024
9.1.0-pre-12 74 12/13/2024
9.1.0-pre-11 73 12/13/2024
9.1.0-pre-10 171 12/10/2024
9.1.0-pre-09 155 12/6/2024
9.1.0-pre-08 234 12/2/2024
9.1.0-pre-07 67 12/2/2024
9.1.0-pre-06 62 12/2/2024
9.1.0-pre-05 140 12/1/2024
9.1.0-pre-04 105 11/29/2024
9.1.0-pre-03 295 11/25/2024
9.1.0-pre-02 153 11/24/2024
9.1.0-pre-01 88 11/23/2024
9.0.1 356 11/20/2024
9.0.0 207 11/18/2024
9.0.0-pre-02 76 11/18/2024
9.0.0-pre-01 201 11/15/2024
8.12.0 448 11/12/2024
8.12.0-pre-15 125 11/11/2024
8.12.0-pre-14 108 11/11/2024
8.12.0-pre-13 130 11/11/2024
8.12.0-pre-12 111 11/10/2024
8.12.0-pre-11 111 11/9/2024
8.12.0-pre-10 243 11/5/2024
8.12.0-pre-09 88 11/5/2024
8.12.0-pre-08 244 11/1/2024
8.12.0-pre-07 273 10/27/2024
8.12.0-pre-06 183 10/24/2024
8.12.0-pre-05 132 10/21/2024
8.12.0-pre-04 119 10/20/2024
8.12.0-pre-03 552 10/6/2024
8.12.0-pre-02 190 10/2/2024
8.12.0-pre-01 101 9/29/2024
8.11.1-pre-04 142 9/27/2024
8.11.1-pre-03 99 9/26/2024
8.11.1-pre-02 254 9/22/2024
8.11.1-pre-01 182 9/19/2024
8.11.0 444 9/16/2024
8.11.0-pre-09 116 9/15/2024
8.11.0-pre-08 140 9/13/2024
8.11.0-pre-07 161 9/10/2024
8.11.0-pre-06 235 9/4/2024
8.11.0-pre-05 119 9/3/2024
8.11.0-pre-04 328 8/22/2024
8.11.0-pre-03 159 8/21/2024
8.11.0-pre-02 161 8/19/2024
8.11.0-pre-01 179 8/16/2024
8.10.0 593 8/8/2024
8.10.0-pre-05 168 8/4/2024
8.10.0-pre-04 89 8/3/2024
8.10.0-pre-03 742 6/26/2024
8.10.0-pre-02 118 6/26/2024
8.10.0-pre-01 107 6/25/2024
8.9.0 1,089 6/9/2024
8.9.0-pre-04 115 6/9/2024
8.9.0-pre-03 164 6/6/2024
8.9.0-pre-02 208 5/31/2024
8.9.0-pre-01 115 5/28/2024
8.8.2-pre-05 135 5/27/2024
8.8.2-pre-04 115 5/26/2024
8.8.2-pre-03 126 5/23/2024
8.8.2-pre-02 285 5/9/2024
8.8.2-pre-01 175 5/1/2024
8.8.1 2,911 4/13/2024
8.8.1-pre-02 92 4/12/2024
8.8.1-pre-01 117 4/12/2024
8.8.0 533 4/1/2024
8.8.0-pre-04 139 3/29/2024
8.8.0-pre-03 258 3/16/2024
8.8.0-pre-02 180 3/10/2024
8.8.0-pre-01 283 2/27/2024
8.7.6 1,751 2/23/2024
8.7.6-pre-08 169 2/23/2024
8.7.6-pre-07 107 2/21/2024
8.7.6-pre-06 114 2/21/2024
8.7.6-pre-05 129 2/18/2024
8.7.6-pre-04 146 2/14/2024
8.7.6-pre-03 101 2/14/2024
8.7.6-pre-02 96 2/14/2024
8.7.6-pre-01 95 2/12/2024
8.7.5 195 2/9/2024
8.7.5-pre-04 125 2/3/2024
8.7.5-pre-03 137 1/29/2024
8.7.5-pre-02 133 1/25/2024
8.7.5-pre-01 102 1/24/2024
8.7.4 364 1/23/2024
8.7.3-pre-02 115 1/22/2024
8.7.3-pre-01 196 1/20/2024
8.7.2 207 1/17/2024
8.7.2-pre-02 100 1/17/2024
8.7.2-pre-01 199 1/11/2024
8.7.1 311 1/9/2024
8.7.0 208 1/8/2024
8.7.0-pre-05 149 1/7/2024
8.7.0-pre-04 169 1/5/2024
8.7.0-pre-03 122 1/4/2024
8.7.0-pre-02 167 12/31/2023
8.7.0-pre-01 116 12/31/2023
8.6.0 207 12/31/2023
8.6.0-pre-03 175 12/25/2023
8.6.0-pre-02 109 12/25/2023
8.6.0-pre-01 197 12/21/2023
8.5.0 252 12/20/2023
8.5.0-pre-02 173 12/16/2023
8.5.0-pre-01 117 12/15/2023
8.4.0 180 12/14/2023
8.4.0-pre-01 121 12/13/2023
8.3.0 162 12/12/2023
8.3.0-pre-03 129 12/11/2023
8.3.0-pre-02 142 12/11/2023
8.3.0-pre-01 131 12/11/2023
8.2.0 342 12/2/2023
8.2.0-pre-05 132 12/2/2023
8.2.0-pre-04 186 12/1/2023
8.2.0-pre-03 145 11/30/2023
8.2.0-pre-02 167 11/29/2023
8.2.0-pre-01 276 11/25/2023
8.1.0 311 11/22/2023
8.1.0-pre-03 130 11/22/2023
8.1.0-pre-02 162 11/20/2023
8.1.0-pre-01 187 11/17/2023
8.0.1 220 11/14/2023
8.0.0-pre-01 138 11/14/2023
7.3.0 134 11/14/2023
7.3.0-pre-01 82 11/14/2023
7.2.0 108 11/14/2023
7.2.0-pre-02 90 11/14/2023
7.2.0-pre-01 140 11/12/2023
7.1.0 187 11/8/2023
7.1.0-pre-05 119 11/7/2023
7.1.0-pre-04 300 11/4/2023
7.1.0-pre-03 373 10/27/2023
7.1.0-pre-02 263 10/23/2023
7.1.0-pre-01 301 10/17/2023
7.0.0 289 10/15/2023
7.0.0-pre-02 84 10/15/2023
7.0.0-pre-01 197 10/13/2023
6.1.0 232 10/13/2023
6.1.0-pre-03 84 10/13/2023
6.1.0-pre-02 99 10/12/2023
6.1.0-pre-01 138 10/11/2023
6.0.0 179 10/9/2023
6.0.0-pre-05 97 10/8/2023
6.0.0-pre-04 108 10/6/2023
6.0.0-pre-03 132 10/2/2023
6.0.0-pre-02 152 9/29/2023
6.0.0-pre-01 110 9/27/2023
5.6.1 403 9/20/2023
5.6.1-pre-01 113 9/20/2023
5.6.0 172 9/20/2023
5.6.0-pre-03 110 9/20/2023
5.6.0-pre-02 216 9/18/2023
5.6.0-pre-01 322 9/14/2023
5.5.0 588 9/2/2023
5.5.0-pre-08 174 9/2/2023
5.5.0-pre-07 180 8/30/2023
5.5.0-pre-06 145 8/29/2023
5.5.0-pre-05 168 8/28/2023
5.5.0-pre-04 138 8/28/2023
5.5.0-pre-03 184 8/27/2023
5.5.0-pre-02 170 8/26/2023
5.5.0-pre-01 158 8/24/2023
5.4.0 277 8/20/2023
5.4.0-pre-05 153 8/20/2023
5.4.0-pre-04 187 8/19/2023
5.4.0-pre-03 152 8/19/2023
5.4.0-pre-02 153 8/19/2023
5.4.0-pre-01 215 8/15/2023
5.3.0 326 8/10/2023
5.3.0-pre-07 150 8/9/2023
5.3.0-pre-06 176 8/8/2023
5.3.0-pre-05 202 8/7/2023
5.3.0-pre-04 195 8/6/2023
5.3.0-pre-03 230 8/1/2023
5.3.0-pre-02 131 8/1/2023
5.3.0-pre-01 156 7/31/2023
5.2.0 286 7/28/2023
5.2.0-pre-05 162 7/27/2023
5.2.0-pre-03 558 7/24/2023
5.2.0-pre-02 167 7/24/2023
5.2.0-pre-01 251 7/10/2023
5.1.0 452 7/5/2023
5.1.0-pre-16 152 7/4/2023
5.1.0-pre-15 196 7/3/2023
5.1.0-pre-14 161 7/3/2023
5.1.0-pre-13 142 7/3/2023
5.1.0-pre-12 162 7/2/2023
5.1.0-pre-11 148 7/2/2023
5.1.0-pre-10 135 7/2/2023
5.1.0-pre-09 222 6/29/2023
5.1.0-pre-08 178 6/27/2023
5.1.0-pre-07 144 6/25/2023
5.1.0-pre-06 156 6/24/2023
5.1.0-pre-04 166 6/24/2023
5.1.0-pre-03 194 6/22/2023
5.1.0-pre-02 230 6/17/2023
5.1.0-pre-01 156 6/16/2023
5.0.0 382 5/29/2023
5.0.0-pre-02 136 5/29/2023
5.0.0-pre-01 164 5/25/2023
4.9.11-pre-02 131 5/25/2023
4.9.11-pre-01 142 5/25/2023
4.9.10 256 5/25/2023
4.9.10-pre-07 130 5/25/2023
4.9.10-pre-06 186 5/16/2023
4.9.10-pre-05 133 5/15/2023
4.9.10-pre-04 181 5/6/2023
4.9.10-pre-03 173 5/2/2023
4.9.10-pre-01 159 4/26/2023
4.9.9 397 4/10/2023
4.9.9-pre-03 147 4/9/2023
4.9.9-pre-02 189 3/29/2023
4.9.9-pre-01 184 3/29/2023
4.9.8-pre-02 254 3/21/2023
4.9.8-pre-01 178 3/20/2023
4.9.7-pre-01 250 3/6/2023
4.9.6 608 2/25/2023
4.9.6-pre-05 220 2/23/2023
4.9.6-pre-04 160 2/23/2023
4.9.6-pre-03 218 2/20/2023
4.9.6-pre-02 186 2/15/2023
4.9.5 591 2/8/2023
4.9.5-pre-03 145 2/8/2023
4.9.5-pre-02 148 2/8/2023
4.9.5-pre-01 151 2/7/2023
4.9.4 432 1/31/2023
4.9.4-pre-02 173 1/31/2023
4.9.4-pre-01 182 1/27/2023
4.9.3-pre-04 207 1/22/2023
4.9.3-pre-03 190 1/20/2023
4.9.3-pre-02 192 1/19/2023
4.9.2-pre-01 218 1/9/2023
4.9.1-pre-02 261 12/26/2022
4.9.1-pre-01 181 12/18/2022
4.9.0-pre-02 246 11/27/2022
4.9.0-pre-01 170 11/22/2022
4.8.0 529 11/15/2022
4.8.0-pre-02 136 11/14/2022
4.8.0-pre-01 173 11/11/2022
4.7.0 372 10/31/2022
4.7.0-pre-04 119 10/31/2022
4.7.0-pre-03 102 10/31/2022
4.7.0-pre-02 164 10/29/2022
4.7.0-pre-01 107 10/27/2022
4.6.0-pre-01 106 10/27/2022
4.5.0-pre-01 205 10/20/2022
4.4.1-pre-01 143 10/20/2022
4.4.0-pre-01 114 10/15/2022
4.3.2-pre-04 106 10/7/2022
4.3.2-pre-03 89 10/6/2022
4.3.2-pre-01 116 9/29/2022
4.3.1 717 9/21/2022
4.3.0 124 9/21/2022
4.2.0-pre-07 133 9/19/2022
4.2.0-pre-05 163 9/18/2022
4.2.0-pre-04 156 9/18/2022
4.2.0-pre-02 241 9/14/2022
4.2.0-pre-01 114 9/12/2022
4.1.0 364 9/8/2022
4.1.0-pre-01 139 9/8/2022
4.0.0 233 9/1/2022
3.1.0-pre-07 108 9/1/2022
3.1.0-pre-06 114 8/30/2022
3.1.0-pre-05 117 8/29/2022
3.1.0-pre-04 129 8/28/2022
3.1.0-pre-03 114 8/27/2022
3.1.0-pre-02 140 8/25/2022
3.1.0-pre-01 140 8/23/2022
3.0.0 255 8/15/2022
3.0.0-pre-09 125 8/15/2022
3.0.0-pre-08 117 8/15/2022
3.0.0-pre-07 140 8/15/2022
3.0.0-pre-06 164 8/14/2022
3.0.0-pre-05 177 8/14/2022
3.0.0-pre-04 280 8/9/2022
3.0.0-pre-03 197 8/8/2022
3.0.0-pre-02 213 8/7/2022
3.0.0-pre-01 346 7/29/2022
2.0.0 598 7/25/2022
2.0.0-pre-14 204 7/24/2022
2.0.0-pre-12 224 7/21/2022
2.0.0-pre-11 168 7/21/2022
2.0.0-pre-10 161 7/20/2022
2.0.0-pre-09 280 7/20/2022
2.0.0-pre-08 307 7/19/2022
2.0.0-pre-07 319 7/19/2022
2.0.0-pre-06 212 7/18/2022
2.0.0-pre-05 298 7/17/2022
2.0.0-pre-04 274 7/14/2022
2.0.0-pre-03 266 7/13/2022
2.0.0-pre-02 256 7/12/2022
2.0.0-pre-01 371 7/8/2022
2.0.0-pre-00 271 7/4/2022
1.0.2 764 7/4/2022
1.0.0 515 7/4/2022