# Services

Everything the ui may use from outside itself. The composition root builds
one of these from real adapters (or fakes, in tests) and provides it through
React context. Components never import an adapter, and reach a browser service only through a port.

This is an interface exported by `@mapcairn/core`, checked against version 0.2.0.

## Signature

```ts
import type { Services } from "@mapcairn/core";
 
interface Services
```

## Properties

### basemaps

```ts
readonly basemaps?: BasemapCatalogue;
```

The basemaps the host offers, with their default. Optional: without it
the ui offers the built-in basemaps. A host adds a provider whose terms
it, and not the SDK, accepts by building a catalogue that includes it.

### clipboard

```ts
readonly clipboard: ClipboardPort;
```

Copies text, such as a link.

### createMapAdapter

```ts
readonly createMapAdapter: MapAdapterFactory;
```

Makes the map adapter the map view mounts.

### featureQuery

```ts
readonly featureQuery?: FeatureQuery;
```

Finds the features inside a drawn shape, for the host that offers
selection by shape. Optional: a host that supplies none offers no such
action, and the ui must not require it. The reference host's
`createServices()` builds none.

### fileOpener

```ts
readonly fileOpener?: FileOpener;
```

Asks the person for a file, such as shapes to import, and reads it in the
browser. Optional: a host that supplies none gets no import, and the ui
must not require it.

### fileSaver

```ts
readonly fileSaver: FileSaver;
```

Offers a file the ui built, such as exported shapes, as a download.

### languages

```ts
readonly languages?: LanguageCatalogue;
```

The languages the host offers, with the default and a loader for each.
Optional: without it the ui speaks only `messages`, follows no language
setting and shows no language switcher. The reference host offers one
language until it ships a translation.

### layers

```ts
readonly layers: LayerCatalogue;
```

The data layers on offer, and whether they have loaded. A host with fixed
layers supplies a static catalogue, one that loads them supplies a
runtime catalogue, and one with none supplies `emptyLayerCatalogue`.

### layerSource

```ts
readonly layerSource: LayerSource;
```

Loads any feed layer's features and details, reading everything from its definition.

### location

```ts
readonly location: LocationProvider;
```

Finds the device's position.

### messages

```ts
readonly messages: MessageCatalogue;
```

Formats every piece of user-facing text for the active language.

### preferences

```ts
readonly preferences: DevicePreferences;
```

Reports the device's preferences, such as reduced motion.

### routing

```ts
readonly routing?: RoutingProvider;
```

Finds routes and travel-time areas. Optional: MapCairn ships no provider, so
a host that supplies none gets no routing, and the ui must not require it.

### search

```ts
readonly search: SearchProvider;
```

Finds places by name.

### selection

```ts
readonly selection?: FeatureSelection;
```

The set of features the person has selected, kept wherever the host
likes. Optional: a host that supplies none offers no selection, and the
ui must not require it. The reference host's `createServices()` builds
none, so the host that wants selection supplies a store.

### settings

```ts
readonly settings: SettingsStore;
```

Remembers settings between visits.

### suggestions

```ts
readonly suggestions?: SuggestionProvider;
```

Suggests places while the person types. Optional: a host that supplies
none gets no suggestions and keeps submit-only search, and the ui must not
require it. Everything typed is sent to the provider, so the host's
privacy text must say so.

### theme

```ts
readonly theme: ThemeSource;
```

Reads the system colour scheme and applies the theme shown.

### url

```ts
readonly url: UrlState;
```

Reads and writes the shareable state in the address.

## See also

- [`BasemapCatalogue`](https://docs.mapcairn.com/api/core/BasemapCatalogue.md)
- [`ClipboardPort`](https://docs.mapcairn.com/api/core/ClipboardPort.md)
- [`MapAdapterFactory`](https://docs.mapcairn.com/api/core/MapAdapterFactory.md)
- [`FeatureQuery`](https://docs.mapcairn.com/api/core/FeatureQuery.md)
- [`FileOpener`](https://docs.mapcairn.com/api/core/FileOpener.md)
- [`FileSaver`](https://docs.mapcairn.com/api/core/FileSaver.md)
- [`LanguageCatalogue`](https://docs.mapcairn.com/api/core/LanguageCatalogue.md)
- [`LayerCatalogue`](https://docs.mapcairn.com/api/core/LayerCatalogue.md)
- [`LayerSource`](https://docs.mapcairn.com/api/core/LayerSource.md)
- [`LocationProvider`](https://docs.mapcairn.com/api/core/LocationProvider.md)
- [`MessageCatalogue`](https://docs.mapcairn.com/api/core/MessageCatalogue.md)
- [`DevicePreferences`](https://docs.mapcairn.com/api/core/DevicePreferences.md)
- [`RoutingProvider`](https://docs.mapcairn.com/api/core/RoutingProvider.md)
- [`SearchProvider`](https://docs.mapcairn.com/api/core/SearchProvider.md)
- [`FeatureSelection`](https://docs.mapcairn.com/api/core/FeatureSelection.md)
- [`SettingsStore`](https://docs.mapcairn.com/api/core/SettingsStore.md)
- [`SuggestionProvider`](https://docs.mapcairn.com/api/core/SuggestionProvider.md)
- [`ThemeSource`](https://docs.mapcairn.com/api/core/ThemeSource.md)
- [`UrlState`](https://docs.mapcairn.com/api/core/UrlState.md)

Source: [packages/core/src/ports/services.ts:26](https://github.com/MapCairn/mapcairn/blob/main/packages/core/src/ports/services.ts#L26)
