Bit.Bswup 9.2.0-pre-02

This is a prerelease version of Bit.Bswup.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Bit.Bswup --version 9.2.0-pre-02                
NuGet\Install-Package Bit.Bswup -Version 9.2.0-pre-02                
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.2.0-pre-02" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Bit.Bswup --version 9.2.0-pre-02                
#r "nuget: Bit.Bswup, 9.2.0-pre-02"                
#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.2.0-pre-02&prerelease

// Install Bit.Bswup as a Cake Tool
#tool nuget:?package=Bit.Bswup&version=9.2.0-pre-02&prerelease                

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.
  • disableHashlessAssetsUpdate: Disables the update of the hash-less assets. By default, the Bswup tries to automatically update all of the hash-less assets (e.g. the external assets) every time an update found for the app.
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.2.1-pre-02 106 1/4/2025
9.2.1-pre-01 129 1/3/2025
9.2.0 116 1/1/2025
9.2.0-pre-04 47 1/1/2025
9.2.0-pre-03 64 12/31/2024
9.2.0-pre-02 123 12/31/2024
9.2.0-pre-01 82 12/30/2024
9.1.2 497 12/24/2024
9.1.2-pre-01 90 12/23/2024
9.1.1 441 12/15/2024
9.1.1-pre-01 81 12/15/2024
9.1.0 126 12/14/2024
9.1.0-pre-13 93 12/13/2024
9.1.0-pre-12 78 12/13/2024
9.1.0-pre-11 78 12/13/2024
9.1.0-pre-10 176 12/10/2024
9.1.0-pre-09 160 12/6/2024
9.1.0-pre-08 239 12/2/2024
9.1.0-pre-07 74 12/2/2024
9.1.0-pre-06 68 12/2/2024
9.1.0-pre-05 144 12/1/2024
9.1.0-pre-04 109 11/29/2024
9.1.0-pre-03 314 11/25/2024
9.1.0-pre-02 157 11/24/2024
9.1.0-pre-01 93 11/23/2024
9.0.1 364 11/20/2024
9.0.0 211 11/18/2024
9.0.0-pre-02 80 11/18/2024
9.0.0-pre-01 205 11/15/2024
8.12.0 453 11/12/2024
8.12.0-pre-15 132 11/11/2024
8.12.0-pre-14 113 11/11/2024
8.12.0-pre-13 135 11/11/2024
8.12.0-pre-12 116 11/10/2024
8.12.0-pre-11 116 11/9/2024
8.12.0-pre-10 247 11/5/2024
8.12.0-pre-09 92 11/5/2024
8.12.0-pre-08 250 11/1/2024
8.12.0-pre-07 279 10/27/2024
8.12.0-pre-06 186 10/24/2024
8.12.0-pre-05 135 10/21/2024
8.12.0-pre-04 122 10/20/2024
8.12.0-pre-03 557 10/6/2024
8.12.0-pre-02 191 10/2/2024
8.12.0-pre-01 102 9/29/2024
8.11.1-pre-04 143 9/27/2024
8.11.1-pre-03 102 9/26/2024
8.11.1-pre-02 257 9/22/2024
8.11.1-pre-01 183 9/19/2024
8.11.0 445 9/16/2024
8.11.0-pre-09 117 9/15/2024
8.11.0-pre-08 141 9/13/2024
8.11.0-pre-07 162 9/10/2024
8.11.0-pre-06 238 9/4/2024
8.11.0-pre-05 120 9/3/2024
8.11.0-pre-04 329 8/22/2024
8.11.0-pre-03 160 8/21/2024
8.11.0-pre-02 162 8/19/2024
8.11.0-pre-01 180 8/16/2024
8.10.0 606 8/8/2024
8.10.0-pre-05 171 8/4/2024
8.10.0-pre-04 92 8/3/2024
8.10.0-pre-03 743 6/26/2024
8.10.0-pre-02 119 6/26/2024
8.10.0-pre-01 108 6/25/2024
8.9.0 1,107 6/9/2024
8.9.0-pre-04 116 6/9/2024
8.9.0-pre-03 165 6/6/2024
8.9.0-pre-02 209 5/31/2024
8.9.0-pre-01 116 5/28/2024
8.8.2-pre-05 136 5/27/2024
8.8.2-pre-04 116 5/26/2024
8.8.2-pre-03 127 5/23/2024
8.8.2-pre-02 286 5/9/2024
8.8.2-pre-01 176 5/1/2024
8.8.1 2,968 4/13/2024
8.8.1-pre-02 93 4/12/2024
8.8.1-pre-01 118 4/12/2024
8.8.0 534 4/1/2024
8.8.0-pre-04 140 3/29/2024
8.8.0-pre-03 259 3/16/2024
8.8.0-pre-02 181 3/10/2024
8.8.0-pre-01 284 2/27/2024
8.7.6 1,753 2/23/2024
8.7.6-pre-08 170 2/23/2024
8.7.6-pre-07 108 2/21/2024
8.7.6-pre-06 115 2/21/2024
8.7.6-pre-05 130 2/18/2024
8.7.6-pre-04 151 2/14/2024
8.7.6-pre-03 106 2/14/2024
8.7.6-pre-02 101 2/14/2024
8.7.6-pre-01 96 2/12/2024
8.7.5 196 2/9/2024
8.7.5-pre-04 126 2/3/2024
8.7.5-pre-03 138 1/29/2024
8.7.5-pre-02 134 1/25/2024
8.7.5-pre-01 103 1/24/2024
8.7.4 365 1/23/2024
8.7.3-pre-02 116 1/22/2024
8.7.3-pre-01 197 1/20/2024
8.7.2 208 1/17/2024
8.7.2-pre-02 101 1/17/2024
8.7.2-pre-01 200 1/11/2024
8.7.1 312 1/9/2024
8.7.0 209 1/8/2024
8.7.0-pre-05 150 1/7/2024
8.7.0-pre-04 170 1/5/2024
8.7.0-pre-03 123 1/4/2024
8.7.0-pre-02 168 12/31/2023
8.7.0-pre-01 117 12/31/2023
8.6.0 208 12/31/2023
8.6.0-pre-03 176 12/25/2023
8.6.0-pre-02 110 12/25/2023
8.6.0-pre-01 198 12/21/2023
8.5.0 253 12/20/2023
8.5.0-pre-02 174 12/16/2023
8.5.0-pre-01 118 12/15/2023
8.4.0 181 12/14/2023
8.4.0-pre-01 122 12/13/2023
8.3.0 163 12/12/2023
8.3.0-pre-03 130 12/11/2023
8.3.0-pre-02 143 12/11/2023
8.3.0-pre-01 132 12/11/2023
8.2.0 344 12/2/2023
8.2.0-pre-05 133 12/2/2023
8.2.0-pre-04 187 12/1/2023
8.2.0-pre-03 146 11/30/2023
8.2.0-pre-02 168 11/29/2023
8.2.0-pre-01 279 11/25/2023
8.1.0 314 11/22/2023
8.1.0-pre-03 131 11/22/2023
8.1.0-pre-02 165 11/20/2023
8.1.0-pre-01 188 11/17/2023
8.0.1 223 11/14/2023
8.0.0-pre-01 139 11/14/2023
7.3.0 135 11/14/2023
7.3.0-pre-01 83 11/14/2023
7.2.0 109 11/14/2023
7.2.0-pre-02 91 11/14/2023
7.2.0-pre-01 141 11/12/2023
7.1.0 190 11/8/2023
7.1.0-pre-05 120 11/7/2023
7.1.0-pre-04 301 11/4/2023
7.1.0-pre-03 374 10/27/2023
7.1.0-pre-02 266 10/23/2023
7.1.0-pre-01 302 10/17/2023
7.0.0 292 10/15/2023
7.0.0-pre-02 87 10/15/2023
7.0.0-pre-01 198 10/13/2023
6.1.0 233 10/13/2023
6.1.0-pre-03 85 10/13/2023
6.1.0-pre-02 100 10/12/2023
6.1.0-pre-01 139 10/11/2023
6.0.0 183 10/9/2023
6.0.0-pre-05 98 10/8/2023
6.0.0-pre-04 109 10/6/2023
6.0.0-pre-03 133 10/2/2023
6.0.0-pre-02 153 9/29/2023
6.0.0-pre-01 113 9/27/2023
5.6.1 404 9/20/2023
5.6.1-pre-01 114 9/20/2023
5.6.0 173 9/20/2023
5.6.0-pre-03 111 9/20/2023
5.6.0-pre-02 217 9/18/2023
5.6.0-pre-01 323 9/14/2023
5.5.0 589 9/2/2023
5.5.0-pre-08 175 9/2/2023
5.5.0-pre-07 181 8/30/2023
5.5.0-pre-06 148 8/29/2023
5.5.0-pre-05 171 8/28/2023
5.5.0-pre-04 139 8/28/2023
5.5.0-pre-03 187 8/27/2023
5.5.0-pre-02 171 8/26/2023
5.5.0-pre-01 161 8/24/2023
5.4.0 278 8/20/2023
5.4.0-pre-05 154 8/20/2023
5.4.0-pre-04 188 8/19/2023
5.4.0-pre-03 153 8/19/2023
5.4.0-pre-02 154 8/19/2023
5.4.0-pre-01 218 8/15/2023
5.3.0 327 8/10/2023
5.3.0-pre-07 151 8/9/2023
5.3.0-pre-06 177 8/8/2023
5.3.0-pre-05 203 8/7/2023
5.3.0-pre-04 196 8/6/2023
5.3.0-pre-03 231 8/1/2023
5.3.0-pre-02 132 8/1/2023
5.3.0-pre-01 157 7/31/2023
5.2.0 287 7/28/2023
5.2.0-pre-05 163 7/27/2023
5.2.0-pre-03 559 7/24/2023
5.2.0-pre-02 168 7/24/2023
5.2.0-pre-01 252 7/10/2023
5.1.0 453 7/5/2023
5.1.0-pre-16 155 7/4/2023
5.1.0-pre-15 197 7/3/2023
5.1.0-pre-14 162 7/3/2023
5.1.0-pre-13 143 7/3/2023
5.1.0-pre-12 163 7/2/2023
5.1.0-pre-11 149 7/2/2023
5.1.0-pre-10 138 7/2/2023
5.1.0-pre-09 223 6/29/2023
5.1.0-pre-08 179 6/27/2023
5.1.0-pre-07 145 6/25/2023
5.1.0-pre-06 157 6/24/2023
5.1.0-pre-04 167 6/24/2023
5.1.0-pre-03 195 6/22/2023
5.1.0-pre-02 231 6/17/2023
5.1.0-pre-01 157 6/16/2023
5.0.0 383 5/29/2023
5.0.0-pre-02 137 5/29/2023
5.0.0-pre-01 167 5/25/2023
4.9.11-pre-02 132 5/25/2023
4.9.11-pre-01 143 5/25/2023
4.9.10 257 5/25/2023
4.9.10-pre-07 133 5/25/2023
4.9.10-pre-06 187 5/16/2023
4.9.10-pre-05 134 5/15/2023
4.9.10-pre-04 182 5/6/2023
4.9.10-pre-03 174 5/2/2023
4.9.10-pre-01 160 4/26/2023
4.9.9 398 4/10/2023
4.9.9-pre-03 148 4/9/2023
4.9.9-pre-02 190 3/29/2023
4.9.9-pre-01 185 3/29/2023
4.9.8-pre-02 255 3/21/2023
4.9.8-pre-01 179 3/20/2023
4.9.7-pre-01 251 3/6/2023
4.9.6 609 2/25/2023
4.9.6-pre-05 221 2/23/2023
4.9.6-pre-04 161 2/23/2023
4.9.6-pre-03 219 2/20/2023
4.9.6-pre-02 187 2/15/2023
4.9.5 592 2/8/2023
4.9.5-pre-03 148 2/8/2023
4.9.5-pre-02 151 2/8/2023
4.9.5-pre-01 154 2/7/2023
4.9.4 434 1/31/2023
4.9.4-pre-02 174 1/31/2023
4.9.4-pre-01 183 1/27/2023
4.9.3-pre-04 208 1/22/2023
4.9.3-pre-03 191 1/20/2023
4.9.3-pre-02 193 1/19/2023
4.9.2-pre-01 221 1/9/2023
4.9.1-pre-02 262 12/26/2022
4.9.1-pre-01 182 12/18/2022
4.9.0-pre-02 249 11/27/2022
4.9.0-pre-01 171 11/22/2022
4.8.0 540 11/15/2022
4.8.0-pre-02 137 11/14/2022
4.8.0-pre-01 174 11/11/2022
4.7.0 377 10/31/2022
4.7.0-pre-04 120 10/31/2022
4.7.0-pre-03 105 10/31/2022
4.7.0-pre-02 165 10/29/2022
4.7.0-pre-01 108 10/27/2022
4.6.0-pre-01 107 10/27/2022
4.5.0-pre-01 206 10/20/2022
4.4.1-pre-01 144 10/20/2022
4.4.0-pre-01 117 10/15/2022
4.3.2-pre-04 109 10/7/2022
4.3.2-pre-03 90 10/6/2022
4.3.2-pre-01 117 9/29/2022
4.3.1 718 9/21/2022
4.3.0 125 9/21/2022
4.2.0-pre-07 134 9/19/2022
4.2.0-pre-05 164 9/18/2022
4.2.0-pre-04 157 9/18/2022
4.2.0-pre-02 242 9/14/2022
4.2.0-pre-01 115 9/12/2022
4.1.0 365 9/8/2022
4.1.0-pre-01 140 9/8/2022
4.0.0 234 9/1/2022
3.1.0-pre-07 109 9/1/2022
3.1.0-pre-06 115 8/30/2022
3.1.0-pre-05 118 8/29/2022
3.1.0-pre-04 130 8/28/2022
3.1.0-pre-03 115 8/27/2022
3.1.0-pre-02 141 8/25/2022
3.1.0-pre-01 141 8/23/2022
3.0.0 256 8/15/2022
3.0.0-pre-09 126 8/15/2022
3.0.0-pre-08 118 8/15/2022
3.0.0-pre-07 141 8/15/2022
3.0.0-pre-06 165 8/14/2022
3.0.0-pre-05 178 8/14/2022
3.0.0-pre-04 281 8/9/2022
3.0.0-pre-03 198 8/8/2022
3.0.0-pre-02 214 8/7/2022
3.0.0-pre-01 347 7/29/2022
2.0.0 599 7/25/2022
2.0.0-pre-14 205 7/24/2022
2.0.0-pre-12 225 7/21/2022
2.0.0-pre-11 169 7/21/2022
2.0.0-pre-10 162 7/20/2022
2.0.0-pre-09 281 7/20/2022
2.0.0-pre-08 308 7/19/2022
2.0.0-pre-07 320 7/19/2022
2.0.0-pre-06 213 7/18/2022
2.0.0-pre-05 299 7/17/2022
2.0.0-pre-04 275 7/14/2022
2.0.0-pre-03 267 7/13/2022
2.0.0-pre-02 257 7/12/2022
2.0.0-pre-01 372 7/8/2022
2.0.0-pre-00 272 7/4/2022
1.0.2 765 7/4/2022
1.0.0 518 7/4/2022