Skip to content
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
825d8af
apply Bswup improvements #12408
msynk May 31, 2026
c646784
further improvements
msynk Jun 1, 2026
733a05a
resolve review comments
msynk Jun 2, 2026
de9c330
resolve review comments II
msynk Jun 4, 2026
23b29b3
resolve review comments III
msynk Jun 5, 2026
088c6d1
resolve review comments IV
msynk Jun 6, 2026
c161919
Merge branch 'develop' into 12408-bswup-improvements
msynk Jun 6, 2026
8c11506
resovle review comments V
msynk Jun 6, 2026
ea3d330
resolve review comments VI
msynk Jun 6, 2026
a71d04f
remove json serializer
msynk Jun 6, 2026
ddd6829
fix progress component
msynk Jun 6, 2026
9d73fbf
resolve local review findimgs
msynk Jun 14, 2026
6c96a71
Merge branch '12408-bswup-improvements' of https://github.com/msynk/b…
msynk Jun 14, 2026
ce3cd61
Merge branch 'develop' into 12408-bswup-improvements
msynk Jun 16, 2026
5377236
resolve review comments V
msynk Jun 21, 2026
a450c91
Merge branch 'develop' into 12408-bswup-improvements
msynk Jun 21, 2026
d6f1bd1
resolve review comments VI
msynk Jun 22, 2026
bd800d8
resolve review comments VII
msynk Jun 27, 2026
3623e25
Merge branch 'develop' into 12408-bswup-improvements
msynk Jun 27, 2026
754eb63
resolve review comments VIII
msynk Jun 27, 2026
70d385e
fix build issues
msynk Jun 28, 2026
a1ee5c5
resolve review comments IX
msynk Jun 28, 2026
f92cdaa
resolve review comments X
msynk Jun 28, 2026
20addce
resolve review comments XI
msynk Jun 28, 2026
73401e9
fix variable definition issue
msynk Jun 28, 2026
7721833
restructure demo projects
msynk Jun 29, 2026
3e6197a
improve FullDemo
msynk Jun 30, 2026
021176a
Merge branch 'develop' into 12408-bswup-improvements
msynk Jun 30, 2026
571f537
resolve review comments XII
msynk Jul 3, 2026
968fc99
resolve review comments XIII
msynk Jul 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Bswup/Bit.Bswup.Demo/wwwroot/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

self.assetsExclude = [/\.scp\.css$/, /weather\.json$/];
self.caseInsensitiveUrl = true;
self.precachedAssetsInclude = [/favicon\.ico$/, /icon-512\.png$/, /bit-bw-64\.png$/];

self.externalAssets = [
{
"url": "not-found/script.file.js"
}
];
// 'lax' opts into best-effort installs: the demo intentionally references a non-existent
// asset to exercise the progress / error reporting UI. Under the default 'strict' setting
// that would abort the install. See README.md > errorTolerance.
self.errorTolerance = 'lax';

self.importScripts('_content/Bit.Bswup/bit-bswup.sw.js');
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

self.assetsExclude = [/\.scp\.css$/, /weather\.json$/];
self.caseInsensitiveUrl = true;
self.precachedAssetsInclude = [/favicon\.ico$/, /icon-512\.png$/, /bit-bw-64\.png$/];

//self.externalAssets = [
// {
Expand Down
35 changes: 18 additions & 17 deletions src/Bswup/Bit.Bswup/Bit.Bswup.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
<PropertyGroup>
<TargetFrameworks>net10.0;net9.0;net8.0</TargetFrameworks>
<IsTrimmable>true</IsTrimmable>
<ResolveStaticWebAssetsInputsDependsOn Condition="'$(TargetFramework)' == 'net10.0'">
<!-- The single TFM whose build (re)generates the wwwroot JS/CSS from Scripts/Styles via
the node toolchain. Pinned to one TFM so tsc/esbuild run once and parallel inner
builds of the other TFMs don't race writing wwwroot. Computed as the first entry of
TargetFrameworks (rather than a hardcoded literal) so it stays valid if the TFM list
is reordered or net10.0 is dropped. -->
<BswupAssetsBuildTfm>$(TargetFrameworks.Split(';')[0])</BswupAssetsBuildTfm>
<ResolveStaticWebAssetsInputsDependsOn Condition="'$(TargetFramework)' == '$(BswupAssetsBuildTfm)'">
Comment thread
msynk marked this conversation as resolved.
Outdated
BeforeBuildTasks;
$(ResolveStaticWebAssetsInputsDependsOn)
</ResolveStaticWebAssetsInputsDependsOn>
Expand All @@ -21,27 +27,29 @@
<PackageReference Condition="'$(TargetFramework)' == 'net10.0'" Include="Microsoft.AspNetCore.Components.Web" Version="10.0.0" />
</ItemGroup>

<!-- Keep the build inputs (tsconfig + package manifests) out of the published static web
assets while still showing them in the project. -->
<ItemGroup>
<Content Remove="tsconfig.json" />
<None Include="tsconfig.json" />
<Content Remove="package*.json;tsconfig*.json" />
<None Include="package*.json;tsconfig*.json" />
</ItemGroup>

<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>

<Target Name="BeforeBuildTasks" AfterTargets="CoreCompile" Condition="'$(TargetFramework)' == 'net10.0'">
<Target Name="BeforeBuildTasks" AfterTargets="CoreCompile" Condition="'$(TargetFramework)' == '$(BswupAssetsBuildTfm)'">
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
<CallTarget Targets="InstallNodejsDependencies"/>
<CallTarget Targets="BuildJavaScript"/>
<CallTarget Targets="BuildCss"/>
</Target>

<Target Name="InstallNodejsDependencies" Inputs="package.json" Outputs="node_modules\.package-lock.json">
<Target Name="InstallNodejsDependencies" Inputs="package.json;package-lock.json" Outputs="node_modules\.package-lock.json">
<Exec Command="npm install" StandardOutputImportance="high" StandardErrorImportance="high" />
</Target>

<Target Name="BuildJavaScript" Inputs="Scripts/bit-bswup.ts;Scripts/bit-bswup.progress.ts;Scripts/bit-bswup.sw.ts" Outputs="wwwroot/bit-bswup.js;wwwroot/bit-bswup.progress.js;wwwroot/bit-bswup.sw.js">
<Target Name="BuildJavaScript" Inputs="Scripts/bit-bswup.ts;Scripts/bit-bswup.progress.ts;Scripts/bit-bswup.sw.ts;Scripts/bit-bswup.sw-cleanup.ts;tsconfig.json;tsconfig.sw.json" Outputs="wwwroot/bit-bswup.js;wwwroot/bit-bswup.progress.js;wwwroot/bit-bswup.sw.js;wwwroot/bit-bswup.sw-cleanup.js">
<!-- Page scripts (DOM lib) and service-worker scripts (WebWorker lib) are compiled by
separate tsconfigs because the DOM and WebWorker type libraries cannot coexist in
one compilation. Both emit into wwwroot. -->
<Exec Command="node_modules/.bin/tsc" StandardOutputImportance="high" StandardErrorImportance="high" />
<Exec Command="node_modules/.bin/tsc -p tsconfig.sw.json" StandardOutputImportance="high" StandardErrorImportance="high" />
Comment thread
msynk marked this conversation as resolved.
Outdated
<Exec Condition=" '$(Configuration)' == 'Release' " Command="node_modules/.bin/esbuild wwwroot/bit-bswup.js --minify --outfile=wwwroot/bit-bswup.js --allow-overwrite" StandardOutputImportance="high" StandardErrorImportance="high" />
<Exec Condition=" '$(Configuration)' == 'Release' " Command="node_modules/.bin/esbuild wwwroot/bit-bswup.progress.js --minify --outfile=wwwroot/bit-bswup.progress.js --allow-overwrite" StandardOutputImportance="high" StandardErrorImportance="high" />
<Exec Condition=" '$(Configuration)' == 'Release' " Command="node_modules/.bin/esbuild wwwroot/bit-bswup.sw.js --minify --outfile=wwwroot/bit-bswup.sw.js --allow-overwrite" StandardOutputImportance="high" StandardErrorImportance="high" />
Expand All @@ -51,11 +59,4 @@
<Exec Command="node_modules/.bin/esbuild Styles/bit-bswup.progress.css --minify --outfile=wwwroot/bit-bswup.progress.css" StandardOutputImportance="high" StandardErrorImportance="high" />
</Target>

<ItemGroup>
<Content Remove="package*.json" />
<Content Remove="tsconfig.json" />
<None Include="package*json" />
<None Include="tsconfig.json" />
</ItemGroup>

</Project>
42 changes: 36 additions & 6 deletions src/Bswup/Bit.Bswup/BswupProgress.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,54 @@
[Parameter] public string? Handler { get; set; }
}

<div id="bit-bswup">
@if (ChildContent is not null)
@* Configuration is published as data-* attributes and read by bit-bswup.progress.js when it
loads (it self-initializes from these attributes). This deliberately avoids emitting an
inline <script>:
- a strict Content-Security-Policy (e.g. script-src 'self') would block an inline
script - the same CSP the README recommends for hardening the service worker; and
- inline <script> tags added by an interactive Blazor renderer are not executed by the
browser, so the old approach only worked when this component was part of the
statically-rendered host document.
Razor attribute-encodes these values and the script reads them back via getAttribute, so
no value can break out of the attribute into markup or script. Make sure
_content/Bit.Bswup/bit-bswup.progress.js is referenced on the page. *@
<div id="bit-bswup"
style="display: none;"
data-bit-bswup-config="true"
data-bit-bswup-auto-reload="@(AutoReload ? "true" : "false")"
data-bit-bswup-show-logs="@(ShowLogs ? "true" : "false")"
data-bit-bswup-show-assets="@(ShowAssets ? "true" : "false")"
data-bit-bswup-app-container="@AppContainer"
data-bit-bswup-hide-app="@(HideApp ? "true" : "false")"
data-bit-bswup-auto-hide="@(AutoHide ? "true" : "false")"
data-bit-bswup-handler="@Handler">
@if (ChildContent is not null)
{
@ChildContent
}
else
else
{
<div class="bit-bswup-container">
<p class="bit-bswup-title">New version is available</p>
<p class="bit-bswup-description">Downloading updates, please wait...</p>
<div class="bit-bswup-progress">
<div id="bit-bswup-progress-bar" style="width: 0%"></div>
<div id="bit-bswup-progress-bar"
role="progressbar"
aria-label="Update download progress"
aria-valuemin="0"
aria-valuemax="100"
aria-valuenow="0"
style="width: 0%"></div>
</div>
<p id="bit-bswup-percent">0 %</p>
<ul id="bit-bswup-assets" style="display: @(ShowAssets ? "block" : "none");"></ul>
<div id="bit-bswup-error" class="bit-bswup-error" style="display: none;" role="alert">
<p class="bit-bswup-error-title">Update failed to install</p>
<p id="bit-bswup-error-message" class="bit-bswup-error-message"></p>
<pre id="bit-bswup-error-details" class="bit-bswup-error-details"></pre>
<button id="bit-bswup-error-retry" type="button">Retry</button>
Comment thread
msynk marked this conversation as resolved.
</div>
</div>
<button id="bit-bswup-reload">Update ready to install!</button>
}
<img style="display: none" src=""
onerror="BitBswupProgress.start(@(AutoReload ? "true" : "false"), @(ShowLogs ? "true" : "false"), @(ShowAssets ? "true" : "false"), '@(AppContainer)', @(HideApp ? "true" : "false"), @(AutoHide ? "true" : "false"), '@(Handler)')">
</div>
Loading
Loading