Hector Dearman | 916c761 | 2018-07-09 15:42:22 +0100 | [diff] [blame] | 1 | // Copyright (C) 2018 The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
Deepanjan Roy | 75b46a9 | 2018-07-24 09:11:29 -0400 | [diff] [blame] | 15 | /** |
| 16 | * A plain js object, holding objects of type |Class| keyed by string id. |
| 17 | * We use this instead of using |Map| object since it is simpler and faster to |
| 18 | * serialize for use in postMessage. |
| 19 | */ |
| 20 | export interface ObjectById<Class extends{id: string}> { [id: string]: Class; } |
| 21 | |
| 22 | export interface State { |
| 23 | i: number; |
| 24 | tracks: ObjectById<TrackState>; |
| 25 | } |
| 26 | |
| 27 | export interface TrackState { |
| 28 | id: string; |
| 29 | type: string; |
| 30 | height: number; |
Hector Dearman | c62a5e3 | 2018-07-27 12:54:44 +0100 | [diff] [blame^] | 31 | kind: string; |
Deepanjan Roy | 75b46a9 | 2018-07-24 09:11:29 -0400 | [diff] [blame] | 32 | } |
Hector Dearman | 916c761 | 2018-07-09 15:42:22 +0100 | [diff] [blame] | 33 | |
| 34 | export function createEmptyState(): State { |
| 35 | return { |
| 36 | i: 0, |
Deepanjan Roy | 75b46a9 | 2018-07-24 09:11:29 -0400 | [diff] [blame] | 37 | tracks: {}, |
Hector Dearman | 916c761 | 2018-07-09 15:42:22 +0100 | [diff] [blame] | 38 | }; |
| 39 | } |