Skip to main content

Class: HatTokenMap

core/HatTokenMap.HatTokenMap

Maps from (hatStyle, character) pairs to tokens

Constructors

constructor

new HatTokenMap(graph)

Parameters

NameType
graphGraph

Defined in

core/HatTokenMap.ts:35

Properties

activeMap

Private activeMap: IndividualHatMap

This is the active map the changes every time we reallocate hats. It is liable to change in the middle of a phrase.

Defined in

core/HatTokenMap.ts:22


hatAllocator

Private hatAllocator: HatAllocator

Defined in

core/HatTokenMap.ts:33


lastSignalVersion

Private lastSignalVersion: null | string = null

Defined in

core/HatTokenMap.ts:32


prePhraseMapSnapshot

Private Optional prePhraseMapSnapshot: IndividualHatMap

This is a snapshot of the hat map that remains stable over the course of a phrase. Ranges will be updated to account for changes to the document, but a hat with the same color and shape will refer to the same logical range.

Defined in

core/HatTokenMap.ts:29


prePhraseMapsSnapshotTimestamp

Private prePhraseMapsSnapshotTimestamp: null | bigint = null

Defined in

core/HatTokenMap.ts:30

Methods

allocateHats

allocateHats(oldTokenHats?): Promise<void>

Allocate hats to the visible tokens.

Parameters

NameTypeDescription
oldTokenHats?TokenHat[]If supplied, pretend that this allocation was the previous allocation when trying to maintain stable hats. This parameter is used for testing.

Returns

Promise<void>

Defined in

core/HatTokenMap.ts:57


dispose

dispose(): void

Returns

void

Defined in

core/HatTokenMap.ts:115


getActiveMap

Private getActiveMap(): Promise<IndividualHatMap>

Returns

Promise<IndividualHatMap>

Defined in

core/HatTokenMap.ts:61


getReadableMap

getReadableMap(usePrePhraseSnapshot): Promise<ReadOnlyHatMap>

Returns a transient, read-only hat map for use during the course of a single command.

Please do not hold onto this copy beyond the lifetime of a single command, because it will get stale.

Parameters

NameTypeDescription
usePrePhraseSnapshotbooleanWhether to use pre-phrase snapshot

Returns

Promise<ReadOnlyHatMap>

A readable snapshot of the map

Defined in

core/HatTokenMap.ts:78


init

init(): Promise<void>

Returns

Promise<void>

Defined in

core/HatTokenMap.ts:46


maybeTakePrePhraseSnapshot

Private maybeTakePrePhraseSnapshot(): Promise<void>

Returns

Promise<void>

Defined in

core/HatTokenMap.ts:123


takePrePhraseSnapshot

Private takePrePhraseSnapshot(): void

Returns

void

Defined in

core/HatTokenMap.ts:140