Arasaka.NativeShell 1.1.0
Arasaka native app shell
One shell for every web app that ships as an installable app: an Avalonia 12 NativeWebView window (Windows,
Linux) and Android app around the live site, so a web deploy updates every installed app at once. It replaced
five copies of the same code (SimpleSchool, the Arasaka portal, TherapyBridge, collAnon, Timelines) that had drifted
apart; each app now keeps only its description, its icons and its packaging.
| Package | Target | What it holds |
|---|---|---|
Arasaka.NativeShell |
net10.0 |
ShellView (the web view, link policy, page bridge, offline page, saved theme, Back hook), ShellApp (an app's description), the feature switches and their build step |
Arasaka.NativeShell.Desktop |
net10.0 (Linux), net10.0-windows10.0.19041.0 |
DesktopShell.Run: Velopack, single instance with link hand-over, tray, notifications (toast, notify-send), print, save dialog, remembered window bounds, camera and microphone on WebKitGTK, crash log, the NVIDIA renderer switch |
Arasaka.NativeShell.Android |
net10.0-android (API 26+) |
ShellActivity, AndroidShellApp: downloads, print, notifications, camera and microphone grants, photo capture in file fields, the share sheet, App Links, system bars that follow the site, crash log |
Published on nget (https://nget.thepra.dev/v3/index.json, mapped by the Arasaka.* pattern) from a vX.Y.Z tag.
An app's side
The shared project holds one ShellApp; both heads pass it to the package.
public static class TherapyBridgeShell
{
public static readonly ShellApp App = new()
{
Name = "TherapyBridge",
Id = "therapybridge",
Folder = "TherapyBridge",
EnvironmentPrefix = "THERAPYBRIDGE",
Start = new Uri("https://app.therapybridge.online/"),
WindowsFeed = new Uri("https://packages.arasaka.software/download/therapybridge/windows/"),
LatestRelease = new Uri("https://packages.arasaka.software/download/therapybridge/latest.json"),
GetTheApp = new Uri("https://packages.arasaka.software/apps/therapybridge/"),
IconResource = "avares://TherapyBridge/Assets/therapybridge-256.png",
IconFile = "Assets/therapybridge-256.png",
Bar = Color.Parse("#F6F4EF"),
};
}
| Field | Use |
|---|---|
Name |
window title, notifications, texts |
Id |
Linux data folder (~/.local/share/<Id>), lock and socket, WM class |
Folder |
Windows data folder (%LOCALAPPDATA%\<Folder>); defaults to Name |
Downloads |
Android Downloads/<Downloads> and Pictures/<Downloads>; defaults to Folder |
EnvironmentPrefix |
<PREFIX>_SHELL_URL (start page), _SHELL_DEVTOOLS=1, _SHELL_DEBUG_PORT (WebView2) |
Start, AppHosts |
the app's hosts: they stay inside, everything else opens outside |
StayDomains |
other hosts kept inside over https, such as a payment provider |
NotificationsPage |
where a notification without a link opens; defaults to Start |
ReceivesShares |
Android: the app takes what other apps share to it (see "Receiving shares"); off by default |
WindowsFeed |
the Velopack feed |
LatestRelease, GetTheApp |
the update notice on Linux and Android |
IconResource, IconFile |
window and tray icon (avares://), and the file notify-send shows |
Bar, Light, Dark |
the colour before the page sends its own, and the offline page's two palettes |
Wording |
replaces any of the built-in English, Italian and Chinese texts |
- Desktop head:
public static int Main(string[] args) => DesktopShell.Run(TherapyBridgeShell.App, args);plus its icons (AvaloniaResource),app.manifestfor Windows and the nfpm/Velopack packaging.vpk packtakes--skipVeloAppCheck:VelopackApp.Build().Run()runs first thing inDesktopShell.Run, inside this package, where vpk's scan of the app's own assembly cannot see it, so without the flag it refuses to pack. - Android head: a
[Application] AvaloniaAndroidApplication<TApp>whereTApp : AndroidShellAppreturns theShellApp, and aMainActivity : ShellActivitycarrying the[Activity]and App Links[IntentFilter]attributes. ItsAndroidManifest.xmlkeeps onlyINTERNETand the<application>element: the build writes the other permissions from the switches.
Keep the folder names an app already shipped with. The web view keeps the sign-in under them; a new name signs everybody out.
Feature switches
Every feature is on by default. An app turns features off in its release workflow with SHELL_FEATURES
(an environment variable, which MSBuild reads) or -p:ShellFeatures=…:
| Value | Result |
|---|---|
| empty or unset | everything on |
-tray -print |
everything except the tray and printing |
none camera |
only the camera |
| Switch | Effect |
|---|---|
tray |
Desktop: a tray icon (Open, Quit); closing the window hides it. Off: closing quits |
notifications |
The page's notify messages become OS notifications while the window is in the background. Android asks for the permission the first time one is due while the app is in front |
print |
The page's print message prints the page (Windows print dialog, window.print() on Linux, Android's print service) |
camera |
Android: CAMERA and the grant to app pages; Linux: WebKitGTK video capture for app pages. Windows shows WebView2's own prompt either way |
microphone |
The same for audio capture (RECORD_AUDIO) |
update-notice |
Android and Linux: a notification when LatestRelease names a newer version, opening GetTheApp |
The build step writes Arasaka.NativeShell.Features.g.cs into the app: the list as assembly metadata and, on
Android, the permissions it needs. WRITE_EXTERNAL_STORAGE up to API 28 is always there, for saving on Android 8
and 9. Always on, without a switch: downloads, sharing (Android), photo capture in file fields (Android), the
offline page, remembered window bounds, the Windows update toast and the crash log (shell.log in the data folder).
The page bridge
The page detects the shell by typeof window.invokeCSharpAction === "function" and sends JSON messages:
type |
Fields | Effect |
|---|---|---|
saveFile |
name, mime, data (base64) |
Desktop: save dialog in Downloads. Android: Downloads/<Folder> |
print |
prints (switch print) |
|
openWindow / openExternal |
url |
an app page opens inside, anything else in the system browser |
notify |
title, body, url |
OS notification (switch notifications) |
share |
title, text, url |
Android share sheet. The shell also defines navigator.share on Android pages, which WebView lacks |
theme |
color |
window background, system bars and light/dark; remembered for the next start and the offline page |
sharedDone |
id |
Android: the page is finished with the share of that id; the shell forgets it and its files |
retry |
offline page only |
The shell calls the page twice:
- When Back is pressed with no history left, it evaluates
window.appShellBack();truemeans the page handled it (closed a sheet), anything else sends the app to the background. - When something was shared to the app (Android,
ReceivesShares), it setswindow.__shellSharedand callswindow.appShellShared(share), at once when an app page is showing and again after every app-page load until the page answerssharedDone. The script itself checks that the page's host is one of the app's before it hands anything over.
Receiving shares (Android)
An app that sets ReceivesShares = true and declares the share intent filters on its activity receives text, links,
photos and files from the share sheet:
[IntentFilter([Intent.ActionSend], Categories = [Intent.CategoryDefault], DataMimeType = "text/plain")]
[IntentFilter([Intent.ActionSend, Intent.ActionSendMultiple], Categories = [Intent.CategoryDefault], DataMimeType = "image/*")]
- What the page gets is a description, never the bytes:
{ id, text, subject, files: [{ name, mime, size }], more }.textisEXTRA_TEXT(100,000 characters at most),subjectisEXTRA_SUBJECTorEXTRA_TITLE(one line, 300),filesthe first ten streams,morehow many were left out.sizeis-1when the sender did not say. - The files come through a file field. A file input whose
acceptisapplication/x-shell-shared-<id>, with the id of the share the page was given, never opens the system picker: the shell answers at once with the shared files (all of them for amultipleinput, else the first) when the page is an app page and the id is the waiting share's, and with nothing otherwise. The page gets ordinaryFileobjects. Like any file field it needs a tap. Static HTML the page shows (a mail, say) cannot know the id, and every other file input behaves as before. - What is refused:
file://paths (an app could name this app's own private files), content from this app's own providers, and streams the sender did not grant. A share replayed from Recents, or by an activity that was recreated, is ignored. The sender's provider is read off the UI thread, and anything it throws only leaves that file out. An app withoutReceivesSharesreads nothing. - One share waits at a time; a new one replaces it. The files stay readable while the app's activity lives (Android's grant ends with it), so a page should take them when the person acts.
Updates
- Windows: Velopack downloads a new version in the background and shows a toast; a click restarts into it. Otherwise it is applied on the next start.
- Linux: the apt/dnf repository the package adds;
update-noticealso announces it. - Android: F-Droid or Obtainium;
update-noticealso announces it.
Releasing
- Commit on master; CI packs
0.0.0-ci.<commit>and checks the three packages. - Tag
vX.Y.Z: the packages go to nget (no overwrites) and the notes to the Releases tab. - In each app: bump
NativeShellVersion, build, tag itsapp-vX.Y.Z.
To try a change in an app before releasing: dotnet pack the three projects with -p:Version=1.0.0-local.N -o artifacts, then build the app with a NuGet config that maps Arasaka.NativeShell* to that folder
(-p:RestoreConfigFile=…) and -p:NativeShellVersion=1.0.0-local.N. The Android build needs JDK 21
(-p:JavaSdkDirectory=…) and the Android SDK (-p:AndroidSdkDirectory=…).
Showing the top 20 packages that depend on Arasaka.NativeShell.
| Packages | Downloads |
|---|---|
|
Arasaka.NativeShell.Android
The Android head of the Arasaka native app shell: downloads, print, notifications, camera and microphone grants, photo capture in file fields, sharing, App Links and system bars that follow the site, switched per app.
|
6 |
|
Arasaka.NativeShell.Desktop
The Windows and Linux head of the Arasaka native app shell: one window with tray, notifications, print, downloads, Velopack updates, remembered bounds and camera/microphone on WebKitGTK, switched per app.
|
6 |
|
Arasaka.NativeShell.Android
The Android head of the Arasaka native app shell: downloads, print, notifications, camera and microphone grants, photo capture in file fields, sharing, App Links and system bars that follow the site, switched per app.
|
4 |
|
Arasaka.NativeShell.Desktop
The Windows and Linux head of the Arasaka native app shell: one window with tray, notifications, print, downloads, Velopack updates, remembered bounds and camera/microphone on WebKitGTK, switched per app.
|
1 |
.NET 10.0
- Avalonia (>= 12.1.6)
- Avalonia.Controls.WebView (>= 12.1.1)