MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / sanitizeViewportState

Function sanitizeViewportState

packages/client/src/app/uiState.ts:263–280  ·  view source on GitHub ↗
(
  state: PersistedViewportState | undefined,
)

Source from the content-addressed store, hash-verified

261}
262
263function sanitizeViewportState(
264 state: PersistedViewportState | undefined,
265): PersistedViewportState | null {
266 if (!state) {
267 return null;
268 }
269
270 return {
271 pan: isPoint(state.pan) ? state.pan : DEFAULT_VIEWPORT_STATE.pan,
272 rotationQuarterTurns: Number.isFinite(state.rotationQuarterTurns)
273 ? state.rotationQuarterTurns
274 : DEFAULT_VIEWPORT_STATE.rotationQuarterTurns,
275 viewMode: isViewMode(state.viewMode)
276 ? state.viewMode
277 : DEFAULT_VIEWPORT_STATE.viewMode,
278 zoom: state.zoom == null || Number.isFinite(state.zoom) ? state.zoom : null,
279 };
280}
281
282function isPoint(value: unknown): value is Point {
283 return Boolean(

Callers 1

sanitizePersistedUiStateFunction · 0.85

Calls 2

isPointFunction · 0.85
isViewModeFunction · 0.85

Tested by

no test coverage detected