Adding an adapter
Part of Architecture, which is built from ARCHITECTURE.md in the repository, where it is edited.
An adapter reaches the ui through the services. Arrows run from the port towards the code that uses it.
- Define or extend the port in
packages/core/src/ports, with typed errors and anAbortSignalon async calls. - Write the fake in
packages/core/src/fakesand the contract suite inpackages/core/src/contracts. - Write the real adapter in
packages/web/src/adapters, passing the same suite. Helpers that more than one adapter uses (reading media queries, fetching and reading JSON) live inpackages/web/src/adapters/shared. The MapLibre adapter is the exception: it is the packagepackages/adapter-maplibre, which depends oncoreandthemeonly, keeps its event emitter beside it, and runs the same contract suite over a scripted engine. - Register it in
createServices(). An optional port whose data belongs to the host, as the selection and the feature query do, is not built there: list it inHOST_SUPPLIED_PORT_NAMES(packages/core/src/contracts/portRegistry.ts) and the host supplies it. - Read it in the ui through a typed hook (
useSettings,useSearchand so on).