Plan ยท area

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 pluginFlotillaMilestone
identityThe session's pubkey, and Profiles for the profileNoneM1
themeNoneMaps activeTheme and flTheme tokens to NAP-THEME colors and fontsM1
relay, outbox readsNetwork and Router, with scopeFilters and scopeRelays applied, and sig removedNoneM1
relay, outbox publishA template writer with setRoom and forceRoutes, signed by the session's signerPublishBuilder with withDelay and the undo toastM2
storageThe protocol and quota, over a storage interfaceThe backend in app/core/storage, keyed by napplet address, user and spaceM2
contextThe session's context string: the relay URL, or url'h in a roomNoneM2
intentCatalog lookups and deliveriesFlotilla pages as handlers, through navigateM2
uploadNoneuploadFile to the space's Blossom serverM4
notifyNoneA badge on the app's menu itemM5

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.

sketchts
const host = app.use(Napplets).host({
policies: [refuseOutsideScope, allowInstalled(spaceApps), askOncePerKind(grants)],
ask: askNappletUser,
storage: nappletStorage,
extra: {theme: themeHandler, intent: intentHandler},
})

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:

  • registerSync loads each joined space's app list and the manifests it names
  • registerRetention keeps manifests and app lists
  • registerActivity counts 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#

DataSourceKept in
ManifestsRelays, through the repositoryThe repository, with retention
App listsEach space relay, signed by the relay or a space adminThe repository, with retention
Verified artifactsBlossom, through resolveCache Storage, by hash
GrantsThe user's answersFlotilla's storage, local to the device
Napplet storageNappletsFlotilla's storage, local to the device
Disabled appsThe userFlotilla's storage, local to the device

Grants and disabled apps stay on the device that recorded them.

Work#

ItemWhereMilestone
A writer for an arbitrary event template in @welshman/domainwelshmanM1
Napplets plugin with the identity and read handlerswelshmanM1
registerNapplets, ENABLE_NAPPLETS and the deferred importFlotillaM1
Theme mappingFlotillaM1
Publish handler and PublishBuilder integration with undobothM2
Storage backend and grant persistenceFlotillaM2
Policies: allowInstalled, refuseOutsideScope, askOncePerKindFlotillaM2
App list reader and deriveSpaceAppsFlotillaM2
Intent handlers for profile, note and room pagesFlotillaM2
Activity registration for installed kindsFlotillaM3