@twick/timeline 0.14.2 → 0.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -6,13 +6,19 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
6
6
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
7
 
8
8
  const PLAYER_STATE = {
9
+ /** Player is refreshing/reloading content */
9
10
  REFRESH: "Refresh",
11
+ /** Player is actively playing content */
10
12
  PLAYING: "Playing",
13
+ /** Player is paused */
11
14
  PAUSED: "Paused"
12
15
  };
13
16
  const CAPTION_STYLE = {
17
+ /** Highlights background of each word */
14
18
  WORD_BG_HIGHLIGHT: "highlight_bg",
19
+ /** Animates text word by word */
15
20
  WORD_BY_WORD: "word_by_word",
21
+ /** Animates text word by word with background highlighting */
16
22
  WORD_BY_WORD_WITH_BG: "word_by_word_with_bg"
17
23
  };
18
24
  const CAPTION_STYLE_OPTIONS = {
@@ -30,34 +36,54 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30
36
  }
31
37
  };
32
38
  const CAPTION_FONT = {
39
+ /** Font size in pixels */
33
40
  size: 40
34
41
  };
35
42
  const CAPTION_COLOR = {
43
+ /** Text color in hex format */
36
44
  text: "#ffffff",
45
+ /** Highlight color in hex format */
37
46
  highlight: "#ff4081",
47
+ /** Background color in hex format */
38
48
  bgColor: "#8C52FF"
39
49
  };
40
50
  const WORDS_PER_PHRASE = 4;
41
51
  const TIMELINE_ACTION = {
52
+ /** No action being performed */
42
53
  NONE: "none",
54
+ /** Setting the player state (play/pause) */
43
55
  SET_PLAYER_STATE: "setPlayerState",
56
+ /** Updating player data */
44
57
  UPDATE_PLAYER_DATA: "updatePlayerData",
58
+ /** Player has been updated */
45
59
  ON_PLAYER_UPDATED: "onPlayerUpdated"
46
60
  };
47
61
  const TIMELINE_ELEMENT_TYPE = {
62
+ /** Video element type */
48
63
  VIDEO: "video",
64
+ /** Caption element type */
49
65
  CAPTION: "caption",
66
+ /** Image element type */
50
67
  IMAGE: "image",
68
+ /** Audio element type */
51
69
  AUDIO: "audio",
70
+ /** Text element type */
52
71
  TEXT: "text",
72
+ /** Rectangle element type */
53
73
  RECT: "rect",
74
+ /** Circle element type */
54
75
  CIRCLE: "circle",
76
+ /** Icon element type */
55
77
  ICON: "icon"
56
78
  };
57
79
  const PROCESS_STATE = {
80
+ /** Process is idle */
58
81
  IDLE: "Idle",
82
+ /** Process is currently running */
59
83
  PROCESSING: "Processing",
84
+ /** Process has completed successfully */
60
85
  COMPLETED: "Completed",
86
+ /** Process has failed */
61
87
  FAILED: "Failed"
62
88
  };
63
89
  const imageDimensionsCache = {};
@@ -1684,6 +1710,18 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1684
1710
  }
1685
1711
  }
1686
1712
  class Track {
1713
+ /**
1714
+ * Creates a new Track instance.
1715
+ *
1716
+ * @param name - The display name for the track
1717
+ * @param id - Optional unique identifier (auto-generated if not provided)
1718
+ *
1719
+ * @example
1720
+ * ```js
1721
+ * const track = new Track("My Video Track");
1722
+ * const trackWithId = new Track("Audio Track", "audio-track-1");
1723
+ * ```
1724
+ */
1687
1725
  constructor(name, id) {
1688
1726
  __publicField(this, "id");
1689
1727
  __publicField(this, "name");
@@ -1697,66 +1735,210 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1697
1735
  this.validator = new ElementValidator();
1698
1736
  }
1699
1737
  /**
1700
- * Create a friend instance for explicit access to protected methods
1701
- * This implements the Friend Class Pattern
1702
- * @returns TrackFriend instance
1738
+ * Creates a friend instance for explicit access to protected methods.
1739
+ * This implements the Friend Class Pattern to allow controlled access
1740
+ * to protected methods while maintaining encapsulation.
1741
+ *
1742
+ * @returns TrackFriend instance that can access protected methods
1743
+ *
1744
+ * @example
1745
+ * ```js
1746
+ * const track = new Track("My Track");
1747
+ * const friend = track.createFriend();
1748
+ *
1749
+ * // Use friend to add elements
1750
+ * const element = new VideoElement({ src: "video.mp4", start: 0, end: 10 });
1751
+ * friend.addElement(element);
1752
+ * ```
1703
1753
  */
1704
1754
  createFriend() {
1705
1755
  return new TrackFriend(this);
1706
1756
  }
1707
1757
  /**
1708
- * Friend method to add element (called by TrackFriend)
1709
- * @param element The element to add
1710
- * @param skipValidation If true, skips validation
1758
+ * Friend method to add element (called by TrackFriend).
1759
+ * Provides controlled access to the protected addElement method.
1760
+ *
1761
+ * @param element - The element to add to the track
1762
+ * @param skipValidation - If true, skips validation (use with caution)
1711
1763
  * @returns true if element was added successfully
1764
+ *
1765
+ * @example
1766
+ * ```js
1767
+ * const track = new Track("My Track");
1768
+ * const friend = track.createFriend();
1769
+ * const element = new VideoElement({ src: "video.mp4", start: 0, end: 10 });
1770
+ *
1771
+ * const success = track.addElementViaFriend(element);
1772
+ * // success = true if element was added successfully
1773
+ * ```
1712
1774
  */
1713
1775
  addElementViaFriend(element, skipValidation = false) {
1714
1776
  return this.addElement(element, skipValidation);
1715
1777
  }
1716
1778
  /**
1717
- * Friend method to remove element (called by TrackFriend)
1718
- * @param element The element to remove
1779
+ * Friend method to remove element (called by TrackFriend).
1780
+ * Provides controlled access to the protected removeElement method.
1781
+ *
1782
+ * @param element - The element to remove from the track
1783
+ *
1784
+ * @example
1785
+ * ```js
1786
+ * const track = new Track("My Track");
1787
+ * const element = new VideoElement({ src: "video.mp4", start: 0, end: 10 });
1788
+ *
1789
+ * track.removeElementViaFriend(element);
1790
+ * // Element is removed from the track
1791
+ * ```
1719
1792
  */
1720
1793
  removeElementViaFriend(element) {
1721
1794
  this.removeElement(element);
1722
1795
  }
1723
1796
  /**
1724
- * Friend method to update element (called by TrackFriend)
1725
- * @param element The element to update
1797
+ * Friend method to update element (called by TrackFriend).
1798
+ * Provides controlled access to the protected updateElement method.
1799
+ *
1800
+ * @param element - The updated element to replace the existing one
1726
1801
  * @returns true if element was updated successfully
1802
+ *
1803
+ * @example
1804
+ * ```js
1805
+ * const track = new Track("My Track");
1806
+ * const element = new VideoElement({ src: "video.mp4", start: 0, end: 10 });
1807
+ *
1808
+ * // Update the element
1809
+ * element.setEnd(15);
1810
+ * const success = track.updateElementViaFriend(element);
1811
+ * // success = true if element was updated successfully
1812
+ * ```
1727
1813
  */
1728
1814
  updateElementViaFriend(element) {
1729
1815
  return this.updateElement(element);
1730
1816
  }
1817
+ /**
1818
+ * Gets the unique identifier of the track.
1819
+ *
1820
+ * @returns The track's unique ID string
1821
+ *
1822
+ * @example
1823
+ * ```js
1824
+ * const track = new Track("My Track", "track-123");
1825
+ * const id = track.getId(); // "track-123"
1826
+ * ```
1827
+ */
1731
1828
  getId() {
1732
1829
  return this.id;
1733
1830
  }
1831
+ /**
1832
+ * Gets the display name of the track.
1833
+ *
1834
+ * @returns The track's display name
1835
+ *
1836
+ * @example
1837
+ * ```js
1838
+ * const track = new Track("Video Track");
1839
+ * const name = track.getName(); // "Video Track"
1840
+ * ```
1841
+ */
1734
1842
  getName() {
1735
1843
  return this.name;
1736
1844
  }
1845
+ /**
1846
+ * Gets the type of the track.
1847
+ *
1848
+ * @returns The track's type string
1849
+ *
1850
+ * @example
1851
+ * ```js
1852
+ * const track = new Track("My Track");
1853
+ * const type = track.getType(); // "element"
1854
+ * ```
1855
+ */
1737
1856
  getType() {
1738
1857
  return this.type;
1739
1858
  }
1859
+ /**
1860
+ * Gets a read-only array of all elements in the track.
1861
+ * Returns a copy of the elements array to prevent external modification.
1862
+ *
1863
+ * @returns Read-only array of track elements
1864
+ *
1865
+ * @example
1866
+ * ```js
1867
+ * const track = new Track("My Track");
1868
+ * const elements = track.getElements();
1869
+ * // elements is a read-only array of TrackElement instances
1870
+ *
1871
+ * elements.forEach(element => {
1872
+ * console.log(`Element: ${element.getId()}, Duration: ${element.getEnd() - element.getStart()}`);
1873
+ * });
1874
+ * ```
1875
+ */
1740
1876
  getElements() {
1741
1877
  return [...this.elements];
1742
1878
  }
1743
1879
  /**
1744
- * Validates an element
1745
- * @param element The element to validate
1880
+ * Validates a single element using the track's validator.
1881
+ * Checks if the element meets all validation requirements.
1882
+ *
1883
+ * @param element - The element to validate
1746
1884
  * @returns true if valid, throws ValidationError if invalid
1885
+ *
1886
+ * @example
1887
+ * ```js
1888
+ * const track = new Track("My Track");
1889
+ * const element = new VideoElement({ src: "video.mp4", start: 0, end: 10 });
1890
+ *
1891
+ * try {
1892
+ * const isValid = track.validateElement(element);
1893
+ * console.log('Element is valid:', isValid);
1894
+ * } catch (error) {
1895
+ * if (error instanceof ValidationError) {
1896
+ * console.log('Validation failed:', error.errors);
1897
+ * }
1898
+ * }
1899
+ * ```
1747
1900
  */
1748
1901
  validateElement(element) {
1749
1902
  return element.accept(this.validator);
1750
1903
  }
1904
+ /**
1905
+ * Gets the total duration of the track.
1906
+ * Calculates the duration based on the end time of the last element.
1907
+ *
1908
+ * @returns The total duration of the track in seconds
1909
+ *
1910
+ * @example
1911
+ * ```js
1912
+ * const track = new Track("My Track");
1913
+ * const duration = track.getTrackDuration(); // 0 if no elements
1914
+ *
1915
+ * // After adding elements
1916
+ * const element = new VideoElement({ src: "video.mp4", start: 0, end: 30 });
1917
+ * track.createFriend().addElement(element);
1918
+ * const newDuration = track.getTrackDuration(); // 30
1919
+ * ```
1920
+ */
1751
1921
  getTrackDuration() {
1752
1922
  var _a;
1753
1923
  return ((_a = this.elements) == null ? void 0 : _a.length) ? this.elements[this.elements.length - 1].getEnd() : 0;
1754
1924
  }
1755
1925
  /**
1756
- * Adds an element to the track with validation
1757
- * @param element The element to add
1758
- * @param skipValidation If true, skips validation (use with caution)
1926
+ * Adds an element to the track with validation.
1927
+ * Protected method that should be accessed through TrackFriend.
1928
+ *
1929
+ * @param element - The element to add to the track
1930
+ * @param skipValidation - If true, skips validation (use with caution)
1759
1931
  * @returns true if element was added successfully, throws ValidationError if validation fails
1932
+ *
1933
+ * @example
1934
+ * ```js
1935
+ * const track = new Track("My Track");
1936
+ * const element = new VideoElement({ src: "video.mp4", start: 0, end: 10 });
1937
+ *
1938
+ * // Use friend to access this protected method
1939
+ * const friend = track.createFriend();
1940
+ * const success = friend.addElement(element);
1941
+ * ```
1760
1942
  */
1761
1943
  addElement(element, skipValidation = false) {
1762
1944
  element.setTrackId(this.id);
@@ -1778,6 +1960,22 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1778
1960
  }
1779
1961
  return false;
1780
1962
  }
1963
+ /**
1964
+ * Removes an element from the track.
1965
+ * Protected method that should be accessed through TrackFriend.
1966
+ *
1967
+ * @param element - The element to remove from the track
1968
+ *
1969
+ * @example
1970
+ * ```js
1971
+ * const track = new Track("My Track");
1972
+ * const element = new VideoElement({ src: "video.mp4", start: 0, end: 10 });
1973
+ *
1974
+ * // Use friend to access this protected method
1975
+ * const friend = track.createFriend();
1976
+ * friend.removeElement(element);
1977
+ * ```
1978
+ */
1781
1979
  removeElement(element) {
1782
1980
  const index2 = this.elements.findIndex((e2) => e2.getId() === element.getId());
1783
1981
  if (index2 !== -1) {
@@ -1785,9 +1983,22 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1785
1983
  }
1786
1984
  }
1787
1985
  /**
1788
- * Updates an element in the track with validation
1789
- * @param element The element to update
1986
+ * Updates an element in the track with validation.
1987
+ * Protected method that should be accessed through TrackFriend.
1988
+ *
1989
+ * @param element - The updated element to replace the existing one
1790
1990
  * @returns true if element was updated successfully, throws ValidationError if validation fails
1991
+ *
1992
+ * @example
1993
+ * ```js
1994
+ * const track = new Track("My Track");
1995
+ * const element = new VideoElement({ src: "video.mp4", start: 0, end: 10 });
1996
+ *
1997
+ * // Use friend to access this protected method
1998
+ * const friend = track.createFriend();
1999
+ * element.setEnd(15);
2000
+ * const success = friend.updateElement(element);
2001
+ * ```
1791
2002
  */
1792
2003
  updateElement(element) {
1793
2004
  try {
@@ -1809,14 +2020,55 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1809
2020
  }
1810
2021
  return false;
1811
2022
  }
2023
+ /**
2024
+ * Finds an element in the track by its ID.
2025
+ *
2026
+ * @param id - The unique identifier of the element to find
2027
+ * @returns The found element or undefined if not found
2028
+ *
2029
+ * @example
2030
+ * ```js
2031
+ * const track = new Track("My Track");
2032
+ * const element = new VideoElement({ src: "video.mp4", start: 0, end: 10 });
2033
+ * track.createFriend().addElement(element);
2034
+ *
2035
+ * const foundElement = track.getElementById(element.getId());
2036
+ * // foundElement is the same element instance
2037
+ * ```
2038
+ */
1812
2039
  getElementById(id) {
1813
2040
  const element = this.elements.find((e2) => e2.getId() === id);
1814
2041
  if (!element) return void 0;
1815
2042
  return element;
1816
2043
  }
1817
2044
  /**
1818
- * Validates all elements in the track and returns combined result and per-element status
2045
+ * Validates all elements in the track and returns combined result and per-element status.
2046
+ * Provides detailed validation information for each element including errors and warnings.
2047
+ *
1819
2048
  * @returns Object with overall isValid and array of per-element validation results
2049
+ *
2050
+ * @example
2051
+ * ```js
2052
+ * const track = new Track("My Track");
2053
+ * const element1 = new VideoElement({ src: "video.mp4", start: 0, end: 10 });
2054
+ * const element2 = new TextElement({ text: "Hello", start: 5, end: 15 });
2055
+ *
2056
+ * track.createFriend().addElement(element1);
2057
+ * track.createFriend().addElement(element2);
2058
+ *
2059
+ * const validation = track.validateAllElements();
2060
+ * console.log('Overall valid:', validation.isValid);
2061
+ *
2062
+ * validation.results.forEach(result => {
2063
+ * console.log(`Element ${result.element.getId()}: ${result.isValid ? 'Valid' : 'Invalid'}`);
2064
+ * if (result.errors) {
2065
+ * console.log('Errors:', result.errors);
2066
+ * }
2067
+ * if (result.warnings) {
2068
+ * console.log('Warnings:', result.warnings);
2069
+ * }
2070
+ * });
2071
+ * ```
1820
2072
  */
1821
2073
  validateAllElements() {
1822
2074
  let validResult = true;
@@ -1846,6 +2098,30 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1846
2098
  });
1847
2099
  return { isValid: validResult, results };
1848
2100
  }
2101
+ /**
2102
+ * Serializes the track and all its elements to JSON format.
2103
+ * Converts the track structure to a format that can be stored or transmitted.
2104
+ *
2105
+ * @returns TrackJSON object representing the track and its elements
2106
+ *
2107
+ * @example
2108
+ * ```js
2109
+ * const track = new Track("My Track");
2110
+ * const element = new VideoElement({ src: "video.mp4", start: 0, end: 10 });
2111
+ * track.createFriend().addElement(element);
2112
+ *
2113
+ * const trackData = track.serialize();
2114
+ * // trackData = {
2115
+ * // id: "t-abc123",
2116
+ * // name: "My Track",
2117
+ * // type: "element",
2118
+ * // elements: [{ ... }]
2119
+ * // }
2120
+ *
2121
+ * // Save to localStorage
2122
+ * localStorage.setItem('track-data', JSON.stringify(trackData));
2123
+ * ```
2124
+ */
1849
2125
  serialize() {
1850
2126
  const serializer = new ElementSerializer();
1851
2127
  return {
@@ -1857,6 +2133,35 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1857
2133
  )
1858
2134
  };
1859
2135
  }
2136
+ /**
2137
+ * Creates a Track instance from JSON data.
2138
+ * Static factory method for deserializing track data.
2139
+ *
2140
+ * @param json - JSON object containing track data
2141
+ * @returns New Track instance with loaded data
2142
+ *
2143
+ * @example
2144
+ * ```js
2145
+ * const trackData = {
2146
+ * id: "t-abc123",
2147
+ * name: "My Track",
2148
+ * type: "element",
2149
+ * elements: [
2150
+ * {
2151
+ * id: "e-def456",
2152
+ * type: "video",
2153
+ * src: "video.mp4",
2154
+ * start: 0,
2155
+ * end: 10
2156
+ * }
2157
+ * ]
2158
+ * };
2159
+ *
2160
+ * const track = Track.fromJSON(trackData);
2161
+ * console.log(track.getName()); // "My Track"
2162
+ * console.log(track.getElements().length); // 1
2163
+ * ```
2164
+ */
1860
2165
  static fromJSON(json) {
1861
2166
  const track = new Track(json.name, json.id);
1862
2167
  track.type = json.type;
@@ -1936,12 +2241,37 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1936
2241
  let TimelineContextStore = _TimelineContextStore;
1937
2242
  const timelineContextStore = TimelineContextStore.getInstance();
1938
2243
  class ElementAdder {
2244
+ /**
2245
+ * Creates a new ElementAdder instance for the specified track.
2246
+ *
2247
+ * @param track - The track to add elements to
2248
+ *
2249
+ * @example
2250
+ * ```js
2251
+ * const adder = new ElementAdder(track);
2252
+ * const success = await adder.visitVideoElement(videoElement);
2253
+ * ```
2254
+ */
1939
2255
  constructor(track) {
1940
2256
  __publicField(this, "track");
1941
2257
  __publicField(this, "trackFriend");
1942
2258
  this.track = track;
1943
2259
  this.trackFriend = track.createFriend();
1944
2260
  }
2261
+ /**
2262
+ * Adds a video element to the track.
2263
+ * Updates video metadata and calculates appropriate start/end times
2264
+ * based on existing track elements.
2265
+ *
2266
+ * @param element - The video element to add
2267
+ * @returns Promise resolving to true if element was added successfully
2268
+ *
2269
+ * @example
2270
+ * ```js
2271
+ * const success = await adder.visitVideoElement(videoElement);
2272
+ * // success = true if element was added successfully
2273
+ * ```
2274
+ */
1945
2275
  async visitVideoElement(element) {
1946
2276
  await element.updateVideoMeta();
1947
2277
  const elements = this.track.getElements();
@@ -1954,6 +2284,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1954
2284
  }
1955
2285
  return this.trackFriend.addElement(element);
1956
2286
  }
2287
+ /**
2288
+ * Adds an audio element to the track.
2289
+ * Updates audio metadata and calculates appropriate start/end times
2290
+ * based on existing track elements.
2291
+ *
2292
+ * @param element - The audio element to add
2293
+ * @returns Promise resolving to true if element was added successfully
2294
+ *
2295
+ * @example
2296
+ * ```js
2297
+ * const success = await adder.visitAudioElement(audioElement);
2298
+ * // success = true if element was added successfully
2299
+ * ```
2300
+ */
1957
2301
  async visitAudioElement(element) {
1958
2302
  await element.updateAudioMeta();
1959
2303
  const elements = this.track.getElements();
@@ -1966,6 +2310,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1966
2310
  }
1967
2311
  return this.trackFriend.addElement(element);
1968
2312
  }
2313
+ /**
2314
+ * Adds an image element to the track.
2315
+ * Updates image metadata and calculates appropriate start/end times
2316
+ * based on existing track elements.
2317
+ *
2318
+ * @param element - The image element to add
2319
+ * @returns Promise resolving to true if element was added successfully
2320
+ *
2321
+ * @example
2322
+ * ```js
2323
+ * const success = await adder.visitImageElement(imageElement);
2324
+ * // success = true if element was added successfully
2325
+ * ```
2326
+ */
1969
2327
  async visitImageElement(element) {
1970
2328
  await element.updateImageMeta();
1971
2329
  const elements = this.track.getElements();
@@ -1978,6 +2336,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1978
2336
  }
1979
2337
  return this.trackFriend.addElement(element);
1980
2338
  }
2339
+ /**
2340
+ * Adds a text element to the track.
2341
+ * Calculates appropriate start/end times based on existing track elements.
2342
+ *
2343
+ * @param element - The text element to add
2344
+ * @returns Promise resolving to true if element was added successfully
2345
+ *
2346
+ * @example
2347
+ * ```js
2348
+ * const success = await adder.visitTextElement(textElement);
2349
+ * // success = true if element was added successfully
2350
+ * ```
2351
+ */
1981
2352
  async visitTextElement(element) {
1982
2353
  const elements = this.track.getElements();
1983
2354
  const lastEndtime = (elements == null ? void 0 : elements.length) ? elements[elements.length - 1].getEnd() : 0;
@@ -1989,6 +2360,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1989
2360
  }
1990
2361
  return this.trackFriend.addElement(element);
1991
2362
  }
2363
+ /**
2364
+ * Adds a caption element to the track.
2365
+ * Calculates appropriate start/end times based on existing track elements.
2366
+ *
2367
+ * @param element - The caption element to add
2368
+ * @returns Promise resolving to true if element was added successfully
2369
+ *
2370
+ * @example
2371
+ * ```js
2372
+ * const success = await adder.visitCaptionElement(captionElement);
2373
+ * // success = true if element was added successfully
2374
+ * ```
2375
+ */
1992
2376
  async visitCaptionElement(element) {
1993
2377
  const elements = this.track.getElements();
1994
2378
  const lastEndtime = (elements == null ? void 0 : elements.length) ? elements[elements.length - 1].getEnd() : 0;
@@ -2000,6 +2384,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2000
2384
  }
2001
2385
  return this.trackFriend.addElement(element);
2002
2386
  }
2387
+ /**
2388
+ * Adds an icon element to the track.
2389
+ * Calculates appropriate start/end times based on existing track elements.
2390
+ *
2391
+ * @param element - The icon element to add
2392
+ * @returns Promise resolving to true if element was added successfully
2393
+ *
2394
+ * @example
2395
+ * ```js
2396
+ * const success = await adder.visitIconElement(iconElement);
2397
+ * // success = true if element was added successfully
2398
+ * ```
2399
+ */
2003
2400
  async visitIconElement(element) {
2004
2401
  const elements = this.track.getElements();
2005
2402
  const lastEndtime = (elements == null ? void 0 : elements.length) ? elements[elements.length - 1].getEnd() : 0;
@@ -2011,6 +2408,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2011
2408
  }
2012
2409
  return this.trackFriend.addElement(element);
2013
2410
  }
2411
+ /**
2412
+ * Adds a circle element to the track.
2413
+ * Calculates appropriate start/end times based on existing track elements.
2414
+ *
2415
+ * @param element - The circle element to add
2416
+ * @returns Promise resolving to true if element was added successfully
2417
+ *
2418
+ * @example
2419
+ * ```js
2420
+ * const success = await adder.visitCircleElement(circleElement);
2421
+ * // success = true if element was added successfully
2422
+ * ```
2423
+ */
2014
2424
  async visitCircleElement(element) {
2015
2425
  const elements = this.track.getElements();
2016
2426
  const lastEndtime = (elements == null ? void 0 : elements.length) ? elements[elements.length - 1].getEnd() : 0;
@@ -2022,6 +2432,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2022
2432
  }
2023
2433
  return this.trackFriend.addElement(element);
2024
2434
  }
2435
+ /**
2436
+ * Adds a rectangle element to the track.
2437
+ * Calculates appropriate start/end times based on existing track elements.
2438
+ *
2439
+ * @param element - The rectangle element to add
2440
+ * @returns Promise resolving to true if element was added successfully
2441
+ *
2442
+ * @example
2443
+ * ```js
2444
+ * const success = await adder.visitRectElement(rectElement);
2445
+ * // success = true if element was added successfully
2446
+ * ```
2447
+ */
2025
2448
  async visitRectElement(element) {
2026
2449
  const elements = this.track.getElements();
2027
2450
  const lastEndtime = (elements == null ? void 0 : elements.length) ? elements[elements.length - 1].getEnd() : 0;