All files / app model.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 0/0
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50                    3x               3x             3x                               3x                
import { Schema } from 'effect'
import { defineTaggedUnion } from 'foldkit/schema'
 
import { Camera, LatLon, Viewport } from '../core/domain'
import * as CameraRequest from '../map/cameraRequest'
import * as Copy from '../submodels/copy'
import * as GoTo from '../submodels/goTo'
import * as Settings from '../submodels/settings'
 
/** Whether MapLibre is running. It fails without WebGL, or when the first style cannot load. */
export const MapState = defineTaggedUnion({
  Loading: {},
  Ready: {},
  Failed: { reason: Schema.String },
})
export type MapState = typeof MapState.Type
 
/** OffMap keeps the last point, so the readout can show it greyed out after the cursor leaves. */
export const CursorState = defineTaggedUnion({
  Idle: {},
  OnMap: { point: LatLon.LatLon },
  OffMap: { point: LatLon.LatLon },
})
export type CursorState = typeof CursorState.Type
 
export const Model = Schema.Struct({
  mapState: MapState,
  /** Where the map looks. The map reports each move, and a time-travel replay sets it back. */
  maybeCamera: Schema.Option(Camera.Camera),
  /** The last animated move asked of the map: search and "Find my location" fly to the result. */
  maybeCameraRequest: Schema.Option(CameraRequest.CameraRequest),
  cursor: CursorState,
  maybeCue: Schema.Option(LatLon.LatLon),
  settings: Settings.Model,
  goTo: GoTo.Model,
  copy: Copy.Model,
  layout: Viewport.Layout,
  pointer: Viewport.Pointer,
})
export type Model = typeof Model.Type
 
export const Flags = Schema.Struct({
  maybeSavedSettings: Schema.Option(Settings.Values),
  maybeCueQuery: Schema.Option(Schema.String),
  maybeCamera: Schema.Option(Camera.Camera),
  layout: Viewport.Layout,
  pointer: Viewport.Pointer,
})
export type Flags = typeof Flags.Type