Glue
The glue connects @welshman/napplet to a running app. A Napplets plugin in @welshman/app implements the domain handlers with welshman's own plugins, and app/tools/napplets in Flotilla adds Flotilla's policies, storage, theme and pages. Any welshman app gets the first half.
Where each piece lives#
The welshman half knows about relays, routing, signing and profiles, but nothing about spaces, admins or UI. The Flotilla half knows about spaces and admins, and it asks the user through a function that a flow supplies, because tools never open dialogs.
| Domain | @welshman/app Napplets plugin | Flotilla | Milestone |
|---|---|---|---|
| identity | The session's pubkey, and Profiles for the profile | None | M1 |
| theme | None | Maps activeTheme and flTheme tokens to NAP-THEME colors and fonts | M1 |
| relay, outbox reads | Network and Router, with scopeFilters and scopeRelays applied, and sig removed | None | M1 |
| relay, outbox publish | A template writer with setRoom and forceRoutes, signed by the session's signer | PublishBuilder with withDelay and the undo toast | M2 |
| storage | The protocol and quota, over a storage interface | The backend in app/core/storage, keyed by napplet address, user and space | M2 |
| context | The session's context string: the relay URL, or url'h in a room | None | M2 |
| intent | Catalog lookups and deliveries | Flotilla pages as handlers, through navigate | M2 |
| upload | None | uploadFile to the space's Blossom server | M4 |
| notify | None | A badge on the app's menu item | M5 |
The welshman plugin#
app.use(Napplets) builds a host from the app's other plugins. A caller passes in the policies, the ask function, and the handlers that only it can provide.
Reads go through Network and Router after scopeFilters and scopeRelays. Events lose sig on the way out. Publishing builds a writer from the napplet's template. The writer's setRoom adds the room tag, and forceRoutes limits relays to the scope, so the scope rules use welshman's own routing instead of a parallel path.
The writer can also call setClient with the napplet's name and address, so events record which app produced them.
Flotilla's half#
- src/app
- tools/napplets
- index.tsregisterNapplets and exports
- host.tsbuilds the host with Flotilla's policies
- policies.tsallowInstalled, refuseOutsideScope, askOncePerKind
- apps.tsapp list reader and deriveSpaceApps
- grants.tsgrants keyed by address, hash and scope
- storage.tsstorage backend
- theme.tstheme tokens for NAP-THEME
- intents.tsFlotilla pages as intent handlers
- components/flows
- napplets.tsask, open, faults and the undo toast
- core
- env.tsENABLE_NAPPLETS
- index.tscalls registerNapplets
- scripts
- startup.mjsdefers @welshman/napplet and tools/napplets/host.ts
tools/napplets reads app lists and grants and supplies policies. It is a tool, not an area, because content types, pinned apps and rooms in areas/spaces all use it, and so do cards and links outside spaces. components/flows/napplets.ts supplies ask and maps faults and publishes to dialogs and toasts.
registerNapplets uses the hooks other modules use:
registerSyncloads each joined space's app list and the manifests it namesregisterRetentionkeeps manifests and app listsregisterActivitycounts unread content of installed kinds, so napplet content types get unread dots like native ones
The host loads with a dynamic import, as the call engine does. scripts/startup.mjs lists it, so the root layout never reaches it through static imports. Manifest cards only need the reader from @welshman/domain, so they work without the host.
Data#
| Data | Source | Kept in |
|---|---|---|
| Manifests | Relays, through the repository | The repository, with retention |
| App lists | Each space relay, signed by the relay or a space admin | The repository, with retention |
| Verified artifacts | Blossom, through resolve | Cache Storage, by hash |
| Grants | The user's answers | Flotilla's storage, local to the device |
| Napplet storage | Napplets | Flotilla's storage, local to the device |
| Disabled apps | The user | Flotilla's storage, local to the device |
Grants and disabled apps stay on the device that recorded them.
Work#
| Item | Where | Milestone |
|---|---|---|
| A writer for an arbitrary event template in @welshman/domain | welshman | M1 |
| Napplets plugin with the identity and read handlers | welshman | M1 |
| registerNapplets, ENABLE_NAPPLETS and the deferred import | Flotilla | M1 |
| Theme mapping | Flotilla | M1 |
| Publish handler and PublishBuilder integration with undo | both | M2 |
| Storage backend and grant persistence | Flotilla | M2 |
| Policies: allowInstalled, refuseOutsideScope, askOncePerKind | Flotilla | M2 |
| App list reader and deriveSpaceApps | Flotilla | M2 |
| Intent handlers for profile, note and room pages | Flotilla | M2 |
| Activity registration for installed kinds | Flotilla | M3 |