@cratis/showrunner.cue.react 0.0.0-stage → 2.10.0

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.
Files changed (417) hide show
  1. package/.storybook/main.ts +11 -0
  2. package/.storybook/preview.tsx +21 -0
  3. package/Configuration/CueConfiguration.ts +27 -0
  4. package/Configuration/CueProvider.tsx +64 -0
  5. package/Configuration/CueStageBoundary.tsx +37 -0
  6. package/Configuration/index.ts +6 -0
  7. package/Icons.tsx +36 -0
  8. package/Labels/CueLabels.ts +39 -0
  9. package/Labels/defaultCueLabels.ts +23 -0
  10. package/Labels/index.ts +6 -0
  11. package/Labels/resolveLabels.ts +12 -0
  12. package/Markdown/CueMarkdown.tsx +31 -0
  13. package/Markdown/index.ts +5 -0
  14. package/Markdown/safeUrl.ts +29 -0
  15. package/README.md +54 -2
  16. package/Speech/CueSpeech.ts +27 -0
  17. package/Speech/CueSpeechConfiguration.ts +21 -0
  18. package/Speech/HttpSpeechOptions.ts +37 -0
  19. package/Speech/createHttpSpeech.ts +135 -0
  20. package/Speech/index.ts +7 -0
  21. package/Speech/silentSpeech.ts +15 -0
  22. package/Speech/speechClips.ts +66 -0
  23. package/TourAnchor.tsx +162 -0
  24. package/TourAnchorSpace.ts +15 -0
  25. package/TourCallout.ts +22 -0
  26. package/TourCalloutBubble.tsx +38 -0
  27. package/TourCamera.ts +17 -0
  28. package/TourChapter.ts +24 -0
  29. package/TourChapterList.tsx +65 -0
  30. package/TourGesture.ts +30 -0
  31. package/TourOverlayShell.tsx +102 -0
  32. package/TourPointer.tsx +83 -0
  33. package/TourSection.ts +24 -0
  34. package/TourSelfPacedPanel.tsx +26 -0
  35. package/TourStep.ts +40 -0
  36. package/TourSubtitles.tsx +22 -0
  37. package/TourTimelineBar.tsx +127 -0
  38. package/Tours/index.ts +5 -0
  39. package/Tours/useCueTours.ts +63 -0
  40. package/Tours/useTourNudge.ts +37 -0
  41. package/cursorSvg.ts +12 -0
  42. package/dist/cjs/Configuration/CueConfiguration.d.ts +11 -0
  43. package/dist/cjs/Configuration/CueConfiguration.d.ts.map +1 -0
  44. package/dist/cjs/Configuration/CueProvider.d.ts +19 -0
  45. package/dist/cjs/Configuration/CueProvider.d.ts.map +1 -0
  46. package/dist/cjs/Configuration/CueProvider.js +44 -0
  47. package/dist/cjs/Configuration/CueProvider.js.map +1 -0
  48. package/dist/cjs/Configuration/CueStageBoundary.d.ts +14 -0
  49. package/dist/cjs/Configuration/CueStageBoundary.d.ts.map +1 -0
  50. package/dist/cjs/Configuration/CueStageBoundary.js +45 -0
  51. package/dist/cjs/Configuration/CueStageBoundary.js.map +1 -0
  52. package/dist/cjs/Configuration/index.d.ts +4 -0
  53. package/dist/cjs/Configuration/index.d.ts.map +1 -0
  54. package/dist/cjs/Examples/AppShell.d.ts +5 -0
  55. package/dist/cjs/Examples/AppShell.d.ts.map +1 -0
  56. package/dist/cjs/Examples/LocalizedCue.d.ts +5 -0
  57. package/dist/cjs/Examples/LocalizedCue.d.ts.map +1 -0
  58. package/dist/cjs/Examples/OrderDeskTour.d.ts +2 -0
  59. package/dist/cjs/Examples/OrderDeskTour.d.ts.map +1 -0
  60. package/dist/cjs/Examples/OwnStageGuard.d.ts +5 -0
  61. package/dist/cjs/Examples/OwnStageGuard.d.ts.map +1 -0
  62. package/dist/cjs/Examples/OwnVoice.d.ts +3 -0
  63. package/dist/cjs/Examples/OwnVoice.d.ts.map +1 -0
  64. package/dist/cjs/Icons.d.ts +19 -0
  65. package/dist/cjs/Icons.d.ts.map +1 -0
  66. package/dist/cjs/Icons.js +33 -0
  67. package/dist/cjs/Icons.js.map +1 -0
  68. package/dist/cjs/Labels/CueLabels.d.ts +18 -0
  69. package/dist/cjs/Labels/CueLabels.d.ts.map +1 -0
  70. package/dist/cjs/Labels/defaultCueLabels.d.ts +3 -0
  71. package/dist/cjs/Labels/defaultCueLabels.d.ts.map +1 -0
  72. package/dist/cjs/Labels/defaultCueLabels.js +24 -0
  73. package/dist/cjs/Labels/defaultCueLabels.js.map +1 -0
  74. package/dist/cjs/Labels/index.d.ts +4 -0
  75. package/dist/cjs/Labels/index.d.ts.map +1 -0
  76. package/dist/cjs/Labels/resolveLabels.d.ts +3 -0
  77. package/dist/cjs/Labels/resolveLabels.d.ts.map +1 -0
  78. package/dist/cjs/Labels/resolveLabels.js +17 -0
  79. package/dist/cjs/Labels/resolveLabels.js.map +1 -0
  80. package/dist/cjs/Markdown/CueMarkdown.d.ts +6 -0
  81. package/dist/cjs/Markdown/CueMarkdown.d.ts.map +1 -0
  82. package/dist/cjs/Markdown/CueMarkdown.js +34 -0
  83. package/dist/cjs/Markdown/CueMarkdown.js.map +1 -0
  84. package/dist/cjs/Markdown/index.d.ts +3 -0
  85. package/dist/cjs/Markdown/index.d.ts.map +1 -0
  86. package/dist/cjs/Markdown/safeUrl.d.ts +2 -0
  87. package/dist/cjs/Markdown/safeUrl.d.ts.map +1 -0
  88. package/dist/cjs/Markdown/safeUrl.js +34 -0
  89. package/dist/cjs/Markdown/safeUrl.js.map +1 -0
  90. package/dist/cjs/Speech/CueSpeech.d.ts +10 -0
  91. package/dist/cjs/Speech/CueSpeech.d.ts.map +1 -0
  92. package/dist/cjs/Speech/CueSpeechConfiguration.d.ts +6 -0
  93. package/dist/cjs/Speech/CueSpeechConfiguration.d.ts.map +1 -0
  94. package/dist/cjs/Speech/HttpSpeechOptions.d.ts +10 -0
  95. package/dist/cjs/Speech/HttpSpeechOptions.d.ts.map +1 -0
  96. package/dist/cjs/Speech/createHttpSpeech.d.ts +4 -0
  97. package/dist/cjs/Speech/createHttpSpeech.d.ts.map +1 -0
  98. package/dist/cjs/Speech/createHttpSpeech.js +140 -0
  99. package/dist/cjs/Speech/createHttpSpeech.js.map +1 -0
  100. package/dist/cjs/Speech/index.d.ts +5 -0
  101. package/dist/cjs/Speech/index.d.ts.map +1 -0
  102. package/dist/cjs/Speech/silentSpeech.d.ts +3 -0
  103. package/dist/cjs/Speech/silentSpeech.d.ts.map +1 -0
  104. package/dist/cjs/Speech/silentSpeech.js +16 -0
  105. package/dist/cjs/Speech/silentSpeech.js.map +1 -0
  106. package/dist/cjs/Speech/speechClips.d.ts +7 -0
  107. package/dist/cjs/Speech/speechClips.d.ts.map +1 -0
  108. package/dist/cjs/Speech/speechClips.js +60 -0
  109. package/dist/cjs/Speech/speechClips.js.map +1 -0
  110. package/dist/cjs/TourAnchor.d.ts +14 -0
  111. package/dist/cjs/TourAnchor.d.ts.map +1 -0
  112. package/dist/cjs/TourAnchor.js +150 -0
  113. package/dist/cjs/TourAnchor.js.map +1 -0
  114. package/dist/cjs/TourAnchorSpace.d.ts +2 -0
  115. package/dist/cjs/TourAnchorSpace.d.ts.map +1 -0
  116. package/dist/cjs/TourCallout.d.ts +8 -0
  117. package/dist/cjs/TourCallout.d.ts.map +1 -0
  118. package/dist/cjs/TourCalloutBubble.d.ts +9 -0
  119. package/dist/cjs/TourCalloutBubble.d.ts.map +1 -0
  120. package/dist/cjs/TourCalloutBubble.js +27 -0
  121. package/dist/cjs/TourCalloutBubble.js.map +1 -0
  122. package/dist/cjs/TourCamera.d.ts +6 -0
  123. package/dist/cjs/TourCamera.d.ts.map +1 -0
  124. package/dist/cjs/TourChapter.d.ts +8 -0
  125. package/dist/cjs/TourChapter.d.ts.map +1 -0
  126. package/dist/cjs/TourChapterList.d.ts +10 -0
  127. package/dist/cjs/TourChapterList.d.ts.map +1 -0
  128. package/dist/cjs/TourChapterList.js +68 -0
  129. package/dist/cjs/TourChapterList.js.map +1 -0
  130. package/dist/cjs/TourChapterList.stories.d.ts +21 -0
  131. package/dist/cjs/TourChapterList.stories.d.ts.map +1 -0
  132. package/dist/cjs/TourGesture.d.ts +12 -0
  133. package/dist/cjs/TourGesture.d.ts.map +1 -0
  134. package/dist/cjs/TourOverlayShell.d.ts +13 -0
  135. package/dist/cjs/TourOverlayShell.d.ts.map +1 -0
  136. package/dist/cjs/TourOverlayShell.js +77 -0
  137. package/dist/cjs/TourOverlayShell.js.map +1 -0
  138. package/dist/cjs/TourPointer.d.ts +9 -0
  139. package/dist/cjs/TourPointer.d.ts.map +1 -0
  140. package/dist/cjs/TourPointer.js +74 -0
  141. package/dist/cjs/TourPointer.js.map +1 -0
  142. package/dist/cjs/TourSection.d.ts +8 -0
  143. package/dist/cjs/TourSection.d.ts.map +1 -0
  144. package/dist/cjs/TourSelfPacedPanel.d.ts +6 -0
  145. package/dist/cjs/TourSelfPacedPanel.d.ts.map +1 -0
  146. package/dist/cjs/TourSelfPacedPanel.js +27 -0
  147. package/dist/cjs/TourSelfPacedPanel.js.map +1 -0
  148. package/dist/cjs/TourSelfPacedPanel.stories.d.ts +21 -0
  149. package/dist/cjs/TourSelfPacedPanel.stories.d.ts.map +1 -0
  150. package/dist/cjs/TourStep.d.ts +12 -0
  151. package/dist/cjs/TourStep.d.ts.map +1 -0
  152. package/dist/cjs/TourSubtitles.d.ts +5 -0
  153. package/dist/cjs/TourSubtitles.d.ts.map +1 -0
  154. package/dist/cjs/TourSubtitles.js +24 -0
  155. package/dist/cjs/TourSubtitles.js.map +1 -0
  156. package/dist/cjs/TourTimelineBar.d.ts +10 -0
  157. package/dist/cjs/TourTimelineBar.d.ts.map +1 -0
  158. package/dist/cjs/TourTimelineBar.js +134 -0
  159. package/dist/cjs/TourTimelineBar.js.map +1 -0
  160. package/dist/cjs/TourTimelineBar.stories.d.ts +24 -0
  161. package/dist/cjs/TourTimelineBar.stories.d.ts.map +1 -0
  162. package/dist/cjs/Tours/index.d.ts +3 -0
  163. package/dist/cjs/Tours/index.d.ts.map +1 -0
  164. package/dist/cjs/Tours/useCueTours.d.ts +7 -0
  165. package/dist/cjs/Tours/useCueTours.d.ts.map +1 -0
  166. package/dist/cjs/Tours/useCueTours.js +46 -0
  167. package/dist/cjs/Tours/useCueTours.js.map +1 -0
  168. package/dist/cjs/Tours/useTourNudge.d.ts +6 -0
  169. package/dist/cjs/Tours/useTourNudge.d.ts.map +1 -0
  170. package/dist/cjs/Tours/useTourNudge.js +28 -0
  171. package/dist/cjs/Tours/useTourNudge.js.map +1 -0
  172. package/dist/cjs/cursorSvg.d.ts +2 -0
  173. package/dist/cjs/cursorSvg.d.ts.map +1 -0
  174. package/dist/cjs/cursorSvg.js +15 -0
  175. package/dist/cjs/cursorSvg.js.map +1 -0
  176. package/dist/cjs/index.d.ts +41 -0
  177. package/dist/cjs/index.d.ts.map +1 -0
  178. package/dist/cjs/index.js +72 -0
  179. package/dist/cjs/index.js.map +1 -0
  180. package/dist/cjs/package.json +3 -0
  181. package/dist/cjs/tourClock.d.ts +19 -0
  182. package/dist/cjs/tourClock.d.ts.map +1 -0
  183. package/dist/cjs/tourClock.js +107 -0
  184. package/dist/cjs/tourClock.js.map +1 -0
  185. package/dist/cjs/tourGeometry.d.ts +18 -0
  186. package/dist/cjs/tourGeometry.d.ts.map +1 -0
  187. package/dist/cjs/tourGeometry.js +86 -0
  188. package/dist/cjs/tourGeometry.js.map +1 -0
  189. package/dist/cjs/tourSelfPaced.d.ts +12 -0
  190. package/dist/cjs/tourSelfPaced.d.ts.map +1 -0
  191. package/dist/cjs/tourSelfPaced.js +69 -0
  192. package/dist/cjs/tourSelfPaced.js.map +1 -0
  193. package/dist/cjs/tourTimeline.d.ts +40 -0
  194. package/dist/cjs/tourTimeline.d.ts.map +1 -0
  195. package/dist/cjs/tourTimeline.js +168 -0
  196. package/dist/cjs/tourTimeline.js.map +1 -0
  197. package/dist/cjs/useTourPlayback.d.ts +25 -0
  198. package/dist/cjs/useTourPlayback.d.ts.map +1 -0
  199. package/dist/cjs/useTourPlayback.js +245 -0
  200. package/dist/cjs/useTourPlayback.js.map +1 -0
  201. package/dist/esm/Configuration/CueConfiguration.d.ts +11 -0
  202. package/dist/esm/Configuration/CueConfiguration.d.ts.map +1 -0
  203. package/dist/esm/Configuration/CueConfiguration.js +2 -0
  204. package/dist/esm/Configuration/CueConfiguration.js.map +1 -0
  205. package/dist/esm/Configuration/CueProvider.d.ts +19 -0
  206. package/dist/esm/Configuration/CueProvider.d.ts.map +1 -0
  207. package/dist/esm/Configuration/CueProvider.js +41 -0
  208. package/dist/esm/Configuration/CueProvider.js.map +1 -0
  209. package/dist/esm/Configuration/CueStageBoundary.d.ts +14 -0
  210. package/dist/esm/Configuration/CueStageBoundary.d.ts.map +1 -0
  211. package/dist/esm/Configuration/CueStageBoundary.js +43 -0
  212. package/dist/esm/Configuration/CueStageBoundary.js.map +1 -0
  213. package/dist/esm/Configuration/index.d.ts +4 -0
  214. package/dist/esm/Configuration/index.d.ts.map +1 -0
  215. package/dist/esm/Configuration/index.js +4 -0
  216. package/dist/esm/Configuration/index.js.map +1 -0
  217. package/dist/esm/Examples/AppShell.d.ts +5 -0
  218. package/dist/esm/Examples/AppShell.d.ts.map +1 -0
  219. package/dist/esm/Examples/AppShell.js +10 -0
  220. package/dist/esm/Examples/AppShell.js.map +1 -0
  221. package/dist/esm/Examples/LocalizedCue.d.ts +5 -0
  222. package/dist/esm/Examples/LocalizedCue.d.ts.map +1 -0
  223. package/dist/esm/Examples/LocalizedCue.js +11 -0
  224. package/dist/esm/Examples/LocalizedCue.js.map +1 -0
  225. package/dist/esm/Examples/OrderDeskTour.d.ts +2 -0
  226. package/dist/esm/Examples/OrderDeskTour.d.ts.map +1 -0
  227. package/dist/esm/Examples/OrderDeskTour.js +33 -0
  228. package/dist/esm/Examples/OrderDeskTour.js.map +1 -0
  229. package/dist/esm/Examples/OwnStageGuard.d.ts +5 -0
  230. package/dist/esm/Examples/OwnStageGuard.d.ts.map +1 -0
  231. package/dist/esm/Examples/OwnStageGuard.js +17 -0
  232. package/dist/esm/Examples/OwnStageGuard.js.map +1 -0
  233. package/dist/esm/Examples/OwnVoice.d.ts +3 -0
  234. package/dist/esm/Examples/OwnVoice.d.ts.map +1 -0
  235. package/dist/esm/Examples/OwnVoice.js +35 -0
  236. package/dist/esm/Examples/OwnVoice.js.map +1 -0
  237. package/dist/esm/Icons.d.ts +19 -0
  238. package/dist/esm/Icons.d.ts.map +1 -0
  239. package/dist/esm/Icons.js +31 -0
  240. package/dist/esm/Icons.js.map +1 -0
  241. package/dist/esm/Labels/CueLabels.d.ts +18 -0
  242. package/dist/esm/Labels/CueLabels.d.ts.map +1 -0
  243. package/dist/esm/Labels/CueLabels.js +2 -0
  244. package/dist/esm/Labels/CueLabels.js.map +1 -0
  245. package/dist/esm/Labels/defaultCueLabels.d.ts +3 -0
  246. package/dist/esm/Labels/defaultCueLabels.d.ts.map +1 -0
  247. package/dist/esm/Labels/defaultCueLabels.js +22 -0
  248. package/dist/esm/Labels/defaultCueLabels.js.map +1 -0
  249. package/dist/esm/Labels/index.d.ts +4 -0
  250. package/dist/esm/Labels/index.d.ts.map +1 -0
  251. package/dist/esm/Labels/index.js +4 -0
  252. package/dist/esm/Labels/index.js.map +1 -0
  253. package/dist/esm/Labels/resolveLabels.d.ts +3 -0
  254. package/dist/esm/Labels/resolveLabels.d.ts.map +1 -0
  255. package/dist/esm/Labels/resolveLabels.js +15 -0
  256. package/dist/esm/Labels/resolveLabels.js.map +1 -0
  257. package/dist/esm/Markdown/CueMarkdown.d.ts +6 -0
  258. package/dist/esm/Markdown/CueMarkdown.d.ts.map +1 -0
  259. package/dist/esm/Markdown/CueMarkdown.js +32 -0
  260. package/dist/esm/Markdown/CueMarkdown.js.map +1 -0
  261. package/dist/esm/Markdown/index.d.ts +3 -0
  262. package/dist/esm/Markdown/index.d.ts.map +1 -0
  263. package/dist/esm/Markdown/index.js +3 -0
  264. package/dist/esm/Markdown/index.js.map +1 -0
  265. package/dist/esm/Markdown/safeUrl.d.ts +2 -0
  266. package/dist/esm/Markdown/safeUrl.d.ts.map +1 -0
  267. package/dist/esm/Markdown/safeUrl.js +32 -0
  268. package/dist/esm/Markdown/safeUrl.js.map +1 -0
  269. package/dist/esm/Speech/CueSpeech.d.ts +10 -0
  270. package/dist/esm/Speech/CueSpeech.d.ts.map +1 -0
  271. package/dist/esm/Speech/CueSpeech.js +2 -0
  272. package/dist/esm/Speech/CueSpeech.js.map +1 -0
  273. package/dist/esm/Speech/CueSpeechConfiguration.d.ts +6 -0
  274. package/dist/esm/Speech/CueSpeechConfiguration.d.ts.map +1 -0
  275. package/dist/esm/Speech/CueSpeechConfiguration.js +2 -0
  276. package/dist/esm/Speech/CueSpeechConfiguration.js.map +1 -0
  277. package/dist/esm/Speech/HttpSpeechOptions.d.ts +10 -0
  278. package/dist/esm/Speech/HttpSpeechOptions.d.ts.map +1 -0
  279. package/dist/esm/Speech/HttpSpeechOptions.js +2 -0
  280. package/dist/esm/Speech/HttpSpeechOptions.js.map +1 -0
  281. package/dist/esm/Speech/createHttpSpeech.d.ts +4 -0
  282. package/dist/esm/Speech/createHttpSpeech.d.ts.map +1 -0
  283. package/dist/esm/Speech/createHttpSpeech.js +138 -0
  284. package/dist/esm/Speech/createHttpSpeech.js.map +1 -0
  285. package/dist/esm/Speech/index.d.ts +5 -0
  286. package/dist/esm/Speech/index.d.ts.map +1 -0
  287. package/dist/esm/Speech/index.js +5 -0
  288. package/dist/esm/Speech/index.js.map +1 -0
  289. package/dist/esm/Speech/silentSpeech.d.ts +3 -0
  290. package/dist/esm/Speech/silentSpeech.d.ts.map +1 -0
  291. package/dist/esm/Speech/silentSpeech.js +14 -0
  292. package/dist/esm/Speech/silentSpeech.js.map +1 -0
  293. package/dist/esm/Speech/speechClips.d.ts +7 -0
  294. package/dist/esm/Speech/speechClips.d.ts.map +1 -0
  295. package/dist/esm/Speech/speechClips.js +58 -0
  296. package/dist/esm/Speech/speechClips.js.map +1 -0
  297. package/dist/esm/TourAnchor.d.ts +14 -0
  298. package/dist/esm/TourAnchor.d.ts.map +1 -0
  299. package/dist/esm/TourAnchor.js +148 -0
  300. package/dist/esm/TourAnchor.js.map +1 -0
  301. package/dist/esm/TourAnchorSpace.d.ts +2 -0
  302. package/dist/esm/TourAnchorSpace.d.ts.map +1 -0
  303. package/dist/esm/TourAnchorSpace.js +2 -0
  304. package/dist/esm/TourAnchorSpace.js.map +1 -0
  305. package/dist/esm/TourCallout.d.ts +8 -0
  306. package/dist/esm/TourCallout.d.ts.map +1 -0
  307. package/dist/esm/TourCallout.js +2 -0
  308. package/dist/esm/TourCallout.js.map +1 -0
  309. package/dist/esm/TourCalloutBubble.d.ts +9 -0
  310. package/dist/esm/TourCalloutBubble.d.ts.map +1 -0
  311. package/dist/esm/TourCalloutBubble.js +25 -0
  312. package/dist/esm/TourCalloutBubble.js.map +1 -0
  313. package/dist/esm/TourCamera.d.ts +6 -0
  314. package/dist/esm/TourCamera.d.ts.map +1 -0
  315. package/dist/esm/TourCamera.js +2 -0
  316. package/dist/esm/TourCamera.js.map +1 -0
  317. package/dist/esm/TourChapter.d.ts +8 -0
  318. package/dist/esm/TourChapter.d.ts.map +1 -0
  319. package/dist/esm/TourChapter.js +2 -0
  320. package/dist/esm/TourChapter.js.map +1 -0
  321. package/dist/esm/TourChapterList.d.ts +10 -0
  322. package/dist/esm/TourChapterList.d.ts.map +1 -0
  323. package/dist/esm/TourChapterList.js +66 -0
  324. package/dist/esm/TourChapterList.js.map +1 -0
  325. package/dist/esm/TourChapterList.stories.d.ts +21 -0
  326. package/dist/esm/TourChapterList.stories.d.ts.map +1 -0
  327. package/dist/esm/TourChapterList.stories.js +53 -0
  328. package/dist/esm/TourChapterList.stories.js.map +1 -0
  329. package/dist/esm/TourGesture.d.ts +12 -0
  330. package/dist/esm/TourGesture.d.ts.map +1 -0
  331. package/dist/esm/TourGesture.js +2 -0
  332. package/dist/esm/TourGesture.js.map +1 -0
  333. package/dist/esm/TourOverlayShell.d.ts +13 -0
  334. package/dist/esm/TourOverlayShell.d.ts.map +1 -0
  335. package/dist/esm/TourOverlayShell.js +75 -0
  336. package/dist/esm/TourOverlayShell.js.map +1 -0
  337. package/dist/esm/TourPointer.d.ts +9 -0
  338. package/dist/esm/TourPointer.d.ts.map +1 -0
  339. package/dist/esm/TourPointer.js +72 -0
  340. package/dist/esm/TourPointer.js.map +1 -0
  341. package/dist/esm/TourSection.d.ts +8 -0
  342. package/dist/esm/TourSection.d.ts.map +1 -0
  343. package/dist/esm/TourSection.js +2 -0
  344. package/dist/esm/TourSection.js.map +1 -0
  345. package/dist/esm/TourSelfPacedPanel.d.ts +6 -0
  346. package/dist/esm/TourSelfPacedPanel.d.ts.map +1 -0
  347. package/dist/esm/TourSelfPacedPanel.js +25 -0
  348. package/dist/esm/TourSelfPacedPanel.js.map +1 -0
  349. package/dist/esm/TourSelfPacedPanel.stories.d.ts +21 -0
  350. package/dist/esm/TourSelfPacedPanel.stories.d.ts.map +1 -0
  351. package/dist/esm/TourSelfPacedPanel.stories.js +41 -0
  352. package/dist/esm/TourSelfPacedPanel.stories.js.map +1 -0
  353. package/dist/esm/TourStep.d.ts +12 -0
  354. package/dist/esm/TourStep.d.ts.map +1 -0
  355. package/dist/esm/TourStep.js +2 -0
  356. package/dist/esm/TourStep.js.map +1 -0
  357. package/dist/esm/TourSubtitles.d.ts +5 -0
  358. package/dist/esm/TourSubtitles.d.ts.map +1 -0
  359. package/dist/esm/TourSubtitles.js +22 -0
  360. package/dist/esm/TourSubtitles.js.map +1 -0
  361. package/dist/esm/TourTimelineBar.d.ts +10 -0
  362. package/dist/esm/TourTimelineBar.d.ts.map +1 -0
  363. package/dist/esm/TourTimelineBar.js +132 -0
  364. package/dist/esm/TourTimelineBar.js.map +1 -0
  365. package/dist/esm/TourTimelineBar.stories.d.ts +24 -0
  366. package/dist/esm/TourTimelineBar.stories.d.ts.map +1 -0
  367. package/dist/esm/TourTimelineBar.stories.js +62 -0
  368. package/dist/esm/TourTimelineBar.stories.js.map +1 -0
  369. package/dist/esm/Tours/index.d.ts +3 -0
  370. package/dist/esm/Tours/index.d.ts.map +1 -0
  371. package/dist/esm/Tours/index.js +3 -0
  372. package/dist/esm/Tours/index.js.map +1 -0
  373. package/dist/esm/Tours/useCueTours.d.ts +7 -0
  374. package/dist/esm/Tours/useCueTours.d.ts.map +1 -0
  375. package/dist/esm/Tours/useCueTours.js +44 -0
  376. package/dist/esm/Tours/useCueTours.js.map +1 -0
  377. package/dist/esm/Tours/useTourNudge.d.ts +6 -0
  378. package/dist/esm/Tours/useTourNudge.d.ts.map +1 -0
  379. package/dist/esm/Tours/useTourNudge.js +26 -0
  380. package/dist/esm/Tours/useTourNudge.js.map +1 -0
  381. package/dist/esm/cursorSvg.d.ts +2 -0
  382. package/dist/esm/cursorSvg.d.ts.map +1 -0
  383. package/dist/esm/cursorSvg.js +13 -0
  384. package/dist/esm/cursorSvg.js.map +1 -0
  385. package/dist/esm/index.d.ts +41 -0
  386. package/dist/esm/index.d.ts.map +1 -0
  387. package/dist/esm/index.js +24 -0
  388. package/dist/esm/index.js.map +1 -0
  389. package/dist/esm/package.json +3 -0
  390. package/dist/esm/tourClock.d.ts +19 -0
  391. package/dist/esm/tourClock.d.ts.map +1 -0
  392. package/dist/esm/tourClock.js +103 -0
  393. package/dist/esm/tourClock.js.map +1 -0
  394. package/dist/esm/tourGeometry.d.ts +18 -0
  395. package/dist/esm/tourGeometry.d.ts.map +1 -0
  396. package/dist/esm/tourGeometry.js +80 -0
  397. package/dist/esm/tourGeometry.js.map +1 -0
  398. package/dist/esm/tourSelfPaced.d.ts +12 -0
  399. package/dist/esm/tourSelfPaced.d.ts.map +1 -0
  400. package/dist/esm/tourSelfPaced.js +64 -0
  401. package/dist/esm/tourSelfPaced.js.map +1 -0
  402. package/dist/esm/tourTimeline.d.ts +40 -0
  403. package/dist/esm/tourTimeline.d.ts.map +1 -0
  404. package/dist/esm/tourTimeline.js +154 -0
  405. package/dist/esm/tourTimeline.js.map +1 -0
  406. package/dist/esm/useTourPlayback.d.ts +25 -0
  407. package/dist/esm/useTourPlayback.d.ts.map +1 -0
  408. package/dist/esm/useTourPlayback.js +243 -0
  409. package/dist/esm/useTourPlayback.js.map +1 -0
  410. package/index.ts +68 -0
  411. package/package.json +93 -4
  412. package/styles.css +485 -0
  413. package/tourClock.ts +125 -0
  414. package/tourGeometry.ts +95 -0
  415. package/tourSelfPaced.ts +93 -0
  416. package/tourTimeline.ts +237 -0
  417. package/useTourPlayback.ts +291 -0
@@ -0,0 +1,103 @@
1
+ import { stepIndexAtTime, MINIMUM_STEP_MS } from './tourTimeline.js';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ /**
6
+ * The breath between a narration finishing and the clock moving on. Step lengths are estimated from word
7
+ * count, and when the voice finishes ahead of the estimate the remainder would be dead air — the clock
8
+ * skips it after this short beat rather than sitting the estimate out. The same beat separates a line that
9
+ * ran past its estimate from the line that follows it, so held steps release calmly instead of abruptly.
10
+ */ const NARRATION_ADVANCE_BEAT_MS = 700;
11
+ /**
12
+ * How long the clock will wait at a step's end for its line to finish being said. Speech is synthesized and
13
+ * streamed, so a line regularly outlasts its word-count estimate — the clock holds the boundary rather than
14
+ * cutting the voice off mid-sentence. The limit only exists so a voice that never finishes — a stalled
15
+ * stream, a hung request — cannot stall the whole tour with it.
16
+ */ const NARRATION_HOLD_LIMIT_MS = 15000;
17
+ /**
18
+ * Advances the tour's clock by one tick, pacing it against the voice.
19
+ *
20
+ * The clock leads and the voice follows — with two adjustments at the boundary between them. When a line
21
+ * finishes ahead of its step's estimated length, the leftover is dead air: after a short beat the clock
22
+ * skips to the step's end instead of sitting the estimate out. When a line is still being said as its
23
+ * step's estimated length runs out, the clock holds just short of the boundary until the line finishes —
24
+ * crossing it would tear the voice down mid-sentence — released by the same beat, and bounded by
25
+ * {@link NARRATION_HOLD_LIMIT_MS} so a voice that never finishes cannot stall the tour.
26
+ * @param timeline The tour laid out on one clock.
27
+ * @param currentMs Where the clock is before the tick, in milliseconds.
28
+ * @param elapsedMs How much wall-clock time the tick spans, in milliseconds.
29
+ * @param now The wall clock at the moment of the tick, in milliseconds.
30
+ * @param narration What the voice is up to.
31
+ * @returns The {@link TourClockAdvance} the tick lands on.
32
+ */ function advanceTourClock(timeline, currentMs, elapsedMs, now, narration) {
33
+ const next = currentMs + elapsedMs;
34
+ // Hold the boundary while the current step's line is still being said, or has finished but not yet had
35
+ // its breath — the clock parks just short of the step's end so the step stays current and the voice
36
+ // keeps its stage.
37
+ const currentIndex = stepIndexAtTime(timeline, currentMs);
38
+ const currentStep = currentIndex >= 0 ? timeline.steps[currentIndex] : undefined;
39
+ if (currentStep && next >= currentStep.endMs) {
40
+ const stillSpeaking = narration.pendingStepIndex === currentIndex;
41
+ const settling = narration.finished !== null && narration.finished.stepIndex === currentIndex && now - narration.finished.finishedAt < NARRATION_ADVANCE_BEAT_MS;
42
+ if (stillSpeaking || settling) {
43
+ const holdStartedAt = narration.holdStartedAt ?? now;
44
+ if (now - holdStartedAt < NARRATION_HOLD_LIMIT_MS) {
45
+ return {
46
+ timeMs: Math.max(currentMs, currentStep.endMs - 1),
47
+ isPlaying: true,
48
+ holdStartedAt,
49
+ finishedConsumed: false
50
+ };
51
+ }
52
+ }
53
+ }
54
+ // The line has already been said — the rest of the step's estimated length is dead air. After the
55
+ // breath, skip straight to the boundary instead of sitting the estimate out. The minimum play time
56
+ // keeps the pointer's travel and press from being cut short by a line spoken faster than the
57
+ // choreography.
58
+ let finishedConsumed = false;
59
+ const index = stepIndexAtTime(timeline, next);
60
+ const timedStep = index >= 0 ? timeline.steps[index] : undefined;
61
+ const finished = narration.finished;
62
+ if (finished !== null) {
63
+ if (!timedStep || finished.stepIndex !== index) {
64
+ finishedConsumed = true;
65
+ } else {
66
+ const playedEnough = next >= timedStep.startMs + MINIMUM_STEP_MS;
67
+ const breathed = now - finished.finishedAt >= NARRATION_ADVANCE_BEAT_MS;
68
+ if (playedEnough && breathed && next < timedStep.endMs) {
69
+ if (timedStep.endMs >= timeline.durationMs) {
70
+ return {
71
+ timeMs: timeline.durationMs,
72
+ isPlaying: false,
73
+ holdStartedAt: null,
74
+ finishedConsumed: true
75
+ };
76
+ }
77
+ return {
78
+ timeMs: timedStep.endMs,
79
+ isPlaying: true,
80
+ holdStartedAt: null,
81
+ finishedConsumed: true
82
+ };
83
+ }
84
+ }
85
+ }
86
+ if (next < timeline.durationMs) {
87
+ return {
88
+ timeMs: next,
89
+ isPlaying: true,
90
+ holdStartedAt: null,
91
+ finishedConsumed
92
+ };
93
+ }
94
+ return {
95
+ timeMs: timeline.durationMs,
96
+ isPlaying: false,
97
+ holdStartedAt: null,
98
+ finishedConsumed
99
+ };
100
+ }
101
+
102
+ export { NARRATION_ADVANCE_BEAT_MS, NARRATION_HOLD_LIMIT_MS, advanceTourClock };
103
+ //# sourceMappingURL=tourClock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tourClock.js","sources":["../../tourClock.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { MINIMUM_STEP_MS, type TourTimeline, stepIndexAtTime } from './tourTimeline.js';\n\n/**\n * The breath between a narration finishing and the clock moving on. Step lengths are estimated from word\n * count, and when the voice finishes ahead of the estimate the remainder would be dead air — the clock\n * skips it after this short beat rather than sitting the estimate out. The same beat separates a line that\n * ran past its estimate from the line that follows it, so held steps release calmly instead of abruptly.\n */\nexport const NARRATION_ADVANCE_BEAT_MS = 700;\n\n/**\n * How long the clock will wait at a step's end for its line to finish being said. Speech is synthesized and\n * streamed, so a line regularly outlasts its word-count estimate — the clock holds the boundary rather than\n * cutting the voice off mid-sentence. The limit only exists so a voice that never finishes — a stalled\n * stream, a hung request — cannot stall the whole tour with it.\n */\nexport const NARRATION_HOLD_LIMIT_MS = 15000;\n\n/** What the voice is up to, as the clock needs to know it to pace itself. */\nexport interface TourClockNarration {\n /** The step whose line has been handed to the voice and not yet finished, or null when none has. */\n pendingStepIndex: number | null;\n\n /** The step whose line finished being said and when it did, or null when none just has. */\n finished: { stepIndex: number; finishedAt: number } | null;\n\n /** When the clock started holding a boundary for the voice, or null when it is not holding one. */\n holdStartedAt: number | null;\n}\n\n/** Where one tick of the tour's clock lands, and what it did to get there. */\nexport interface TourClockAdvance {\n /** Where the clock is after the tick, in milliseconds. */\n timeMs: number;\n\n /** Whether playback continues — false once the clock has reached the end of the tour. */\n isPlaying: boolean;\n\n /** When the in-progress boundary hold started, carried to the next tick, or null when not holding. */\n holdStartedAt: number | null;\n\n /** Whether the finished-narration marker was consumed by this tick and should be cleared. */\n finishedConsumed: boolean;\n}\n\n/**\n * Advances the tour's clock by one tick, pacing it against the voice.\n *\n * The clock leads and the voice follows — with two adjustments at the boundary between them. When a line\n * finishes ahead of its step's estimated length, the leftover is dead air: after a short beat the clock\n * skips to the step's end instead of sitting the estimate out. When a line is still being said as its\n * step's estimated length runs out, the clock holds just short of the boundary until the line finishes —\n * crossing it would tear the voice down mid-sentence — released by the same beat, and bounded by\n * {@link NARRATION_HOLD_LIMIT_MS} so a voice that never finishes cannot stall the tour.\n * @param timeline The tour laid out on one clock.\n * @param currentMs Where the clock is before the tick, in milliseconds.\n * @param elapsedMs How much wall-clock time the tick spans, in milliseconds.\n * @param now The wall clock at the moment of the tick, in milliseconds.\n * @param narration What the voice is up to.\n * @returns The {@link TourClockAdvance} the tick lands on.\n */\nexport function advanceTourClock(\n timeline: TourTimeline,\n currentMs: number,\n elapsedMs: number,\n now: number,\n narration: TourClockNarration): TourClockAdvance {\n const next = currentMs + elapsedMs;\n\n // Hold the boundary while the current step's line is still being said, or has finished but not yet had\n // its breath — the clock parks just short of the step's end so the step stays current and the voice\n // keeps its stage.\n const currentIndex = stepIndexAtTime(timeline, currentMs);\n const currentStep = currentIndex >= 0 ? timeline.steps[currentIndex] : undefined;\n if (currentStep && next >= currentStep.endMs) {\n const stillSpeaking = narration.pendingStepIndex === currentIndex;\n const settling = narration.finished !== null\n && narration.finished.stepIndex === currentIndex\n && now - narration.finished.finishedAt < NARRATION_ADVANCE_BEAT_MS;\n if (stillSpeaking || settling) {\n const holdStartedAt = narration.holdStartedAt ?? now;\n if (now - holdStartedAt < NARRATION_HOLD_LIMIT_MS) {\n return {\n timeMs: Math.max(currentMs, currentStep.endMs - 1),\n isPlaying: true,\n holdStartedAt,\n finishedConsumed: false,\n };\n }\n }\n }\n\n // The line has already been said — the rest of the step's estimated length is dead air. After the\n // breath, skip straight to the boundary instead of sitting the estimate out. The minimum play time\n // keeps the pointer's travel and press from being cut short by a line spoken faster than the\n // choreography.\n let finishedConsumed = false;\n const index = stepIndexAtTime(timeline, next);\n const timedStep = index >= 0 ? timeline.steps[index] : undefined;\n const finished = narration.finished;\n if (finished !== null) {\n if (!timedStep || finished.stepIndex !== index) {\n finishedConsumed = true;\n } else {\n const playedEnough = next >= timedStep.startMs + MINIMUM_STEP_MS;\n const breathed = now - finished.finishedAt >= NARRATION_ADVANCE_BEAT_MS;\n if (playedEnough && breathed && next < timedStep.endMs) {\n if (timedStep.endMs >= timeline.durationMs) {\n return { timeMs: timeline.durationMs, isPlaying: false, holdStartedAt: null, finishedConsumed: true };\n }\n\n return { timeMs: timedStep.endMs, isPlaying: true, holdStartedAt: null, finishedConsumed: true };\n }\n }\n }\n\n if (next < timeline.durationMs) {\n return { timeMs: next, isPlaying: true, holdStartedAt: null, finishedConsumed };\n }\n\n return { timeMs: timeline.durationMs, isPlaying: false, holdStartedAt: null, finishedConsumed };\n}\n"],"names":["NARRATION_ADVANCE_BEAT_MS","NARRATION_HOLD_LIMIT_MS","advanceTourClock","timeline","currentMs","elapsedMs","now","narration","next","currentIndex","stepIndexAtTime","currentStep","steps","undefined","endMs","stillSpeaking","pendingStepIndex","settling","finished","stepIndex","finishedAt","holdStartedAt","timeMs","Math","max","isPlaying","finishedConsumed","index","timedStep","playedEnough","startMs","MINIMUM_STEP_MS","breathed","durationMs"],"mappings":";;AAAA;AACA;AAIA;;;;;IAMO,MAAMA,yBAAAA,GAA4B;AAEzC;;;;;IAMO,MAAMC,uBAAAA,GAA0B;AA6BvC;;;;;;;;;;;;;;;IAgBO,SAASC,gBAAAA,CACZC,QAAsB,EACtBC,SAAiB,EACjBC,SAAiB,EACjBC,GAAW,EACXC,SAA6B,EAAA;AAC7B,IAAA,MAAMC,OAAOJ,SAAAA,GAAYC,SAAAA;;;;IAKzB,MAAMI,YA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
+ readonly left: 72;
11
+ readonly right: 320;
12
+ readonly bottom: 136;
13
+ };
14
+ export declare function projectToScreen(worldX: number, worldY: number, transform: BoardTransform): ScreenPoint;
15
+ export declare function unobstructedCenter(viewportWidth: number, viewportHeight: number): ScreenPoint;
16
+ export declare function projectEditorPointToScreen(x: number, y: number, viewportWidth: number, viewportHeight: number): ScreenPoint;
17
+ export declare function projectToolbarPointToScreen(x: number, y: number, viewportHeight: number): ScreenPoint;
18
+ //# sourceMappingURL=tourGeometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tourGeometry.d.ts","sourceRoot":"","sources":["../../tourGeometry.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAExB,CAAC,EAAE,MAAM,CAAC;IAGV,CAAC,EAAE,MAAM,CAAC;CACb;AAGD,MAAM,WAAW,cAAc;IAE3B,IAAI,EAAE,MAAM,CAAC;IAGb,GAAG,EAAE,WAAW,CAAC;CACpB;AAUD,eAAO,MAAM,aAAa;;;;CAAiD,CAAC;AAa5E,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,GAAG,WAAW,CAKtG;AAQD,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,WAAW,CAK7F;AAeD,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,WAAW,CAG3H;AAcD,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,WAAW,CAErG"}
@@ -0,0 +1,80 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ /** A point on the screen, relative to the board's own box. */ /**
4
+ * How much of the viewport the tour's own chrome covers on each side, in pixels. The camera compensates by
5
+ * this much so a framed subject centers in the *unobstructed* part of the viewport instead of behind the
6
+ * chapter list or the transport, and the editor showcase centers its panel on the same point. Must be kept in
7
+ * sync with the chrome's stylesheets: the right inset is the chapter list (1rem margin + 19rem wide), the
8
+ * left inset is the tour toolbar's column, and the bottom inset is the subtitles' box (bottom 5.5rem plus its
9
+ * height) over the transport bar.
10
+ */ const CHROME_INSETS = {
11
+ left: 72,
12
+ right: 320,
13
+ bottom: 136
14
+ };
15
+ /**
16
+ * Projects a board coordinate to where it currently sits on screen.
17
+ * @param worldX The horizontal board coordinate.
18
+ * @param worldY The vertical board coordinate.
19
+ * @param transform The board's current pan and zoom.
20
+ * @returns The {@link ScreenPoint} relative to the board's box.
21
+ * @remarks
22
+ * This is the exact inverse of the screen-to-board mapping the canvas uses for collaborator presence, and it
23
+ * is what keeps the tour's pointer and callouts glued to the thing they are pointing at while the camera
24
+ * moves underneath them.
25
+ */ function projectToScreen(worldX, worldY, transform) {
26
+ return {
27
+ x: transform.pan.x + worldX * transform.zoom,
28
+ y: transform.pan.y + worldY * transform.zoom
29
+ };
30
+ }
31
+ /**
32
+ * The point the viewport's unobstructed part centers on — the middle of what the tour's chrome leaves open.
33
+ * @param viewportWidth The viewport's width in pixels.
34
+ * @param viewportHeight The viewport's height in pixels.
35
+ * @returns The {@link ScreenPoint} the camera aims subjects at and the editor showcase centers its panel on.
36
+ */ function unobstructedCenter(viewportWidth, viewportHeight) {
37
+ return {
38
+ x: viewportWidth / 2 - (CHROME_INSETS.right - CHROME_INSETS.left) / 2,
39
+ y: viewportHeight / 2 - CHROME_INSETS.bottom / 2
40
+ };
41
+ }
42
+ /**
43
+ * Projects an editor-space point — an offset from the center of the editor showcase's panel — to the screen.
44
+ * @param x The horizontal offset from the panel's center.
45
+ * @param y The vertical offset from the panel's center.
46
+ * @param viewportWidth The viewport's width in pixels.
47
+ * @param viewportHeight The viewport's height in pixels.
48
+ * @returns The {@link ScreenPoint} relative to the board's box.
49
+ * @remarks
50
+ * The showcase pins its panel on the unobstructed center whatever the viewport size, so offsets from that
51
+ * center are the one coordinate system in which a spot inside the panel — a button, a field, a tab — has the
52
+ * same coordinates on every screen. Measured offsets therefore stay valid everywhere, exactly like the
53
+ * toolbar's fixed screen coordinates.
54
+ */ function projectEditorPointToScreen(x, y, viewportWidth, viewportHeight) {
55
+ const center = unobstructedCenter(viewportWidth, viewportHeight);
56
+ return {
57
+ x: center.x + x,
58
+ y: center.y + y
59
+ };
60
+ }
61
+ /**
62
+ * Projects a toolbar-space point — a fixed offset from the left edge, and a vertical offset from the
63
+ * viewport's center — to the screen.
64
+ * @param x The horizontal offset from the board's left edge.
65
+ * @param y The vertical offset from the viewport's vertical center.
66
+ * @param viewportHeight The viewport's height in pixels.
67
+ * @returns The {@link ScreenPoint} relative to the board's box.
68
+ * @remarks
69
+ * The tour's toolbar centers itself vertically the way the editor's own toolbar does, so a spot on one of
70
+ * its buttons is a fixed distance from the vertical center on every viewport — this is the coordinate system
71
+ * in which those spots keep the same plain numbers everywhere.
72
+ */ function projectToolbarPointToScreen(x, y, viewportHeight) {
73
+ return {
74
+ x,
75
+ y: viewportHeight / 2 + y
76
+ };
77
+ }
78
+
79
+ export { CHROME_INSETS, projectEditorPointToScreen, projectToScreen, projectToolbarPointToScreen, unobstructedCenter };
80
+ //# sourceMappingURL=tourGeometry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tourGeometry.js","sources":["../../tourGeometry.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/** A point on the screen, relative to the board's own box. */\nexport interface ScreenPoint {\n /** The horizontal offset in pixels. */\n x: number;\n\n /** The vertical offset in pixels. */\n y: number;\n}\n\n/** The board's current pan and zoom, as the canvas reports it. */\nexport interface BoardTransform {\n /** The zoom level, where 1 is actual size. */\n zoom: number;\n\n /** The pan offset in pixels. */\n pan: ScreenPoint;\n}\n\n/**\n * How much of the viewport the tour's own chrome covers on each side, in pixels. The camera compensates by\n * this much so a framed subject centers in the *unobstructed* part of the viewport instead of behind the\n * chapter list or the transport, and the editor showcase centers its panel on the same point. Must be kept in\n * sync with the chrome's stylesheets: the right inset is the chapter list (1rem margin + 19rem wide), the\n * left inset is the tour toolbar's column, and the bottom inset is the subtitles' box (bottom 5.5rem plus its\n * height) over the transport bar.\n */\nexport const CHROME_INSETS = { left: 72, right: 320, bottom: 136 } as const;\n\n/**\n * Projects a board coordinate to where it currently sits on screen.\n * @param worldX The horizontal board coordinate.\n * @param worldY The vertical board coordinate.\n * @param transform The board's current pan and zoom.\n * @returns The {@link ScreenPoint} relative to the board's box.\n * @remarks\n * This is the exact inverse of the screen-to-board mapping the canvas uses for collaborator presence, and it\n * is what keeps the tour's pointer and callouts glued to the thing they are pointing at while the camera\n * moves underneath them.\n */\nexport function projectToScreen(worldX: number, worldY: number, transform: BoardTransform): ScreenPoint {\n return {\n x: transform.pan.x + worldX * transform.zoom,\n y: transform.pan.y + worldY * transform.zoom,\n };\n}\n\n/**\n * The point the viewport's unobstructed part centers on — the middle of what the tour's chrome leaves open.\n * @param viewportWidth The viewport's width in pixels.\n * @param viewportHeight The viewport's height in pixels.\n * @returns The {@link ScreenPoint} the camera aims subjects at and the editor showcase centers its panel on.\n */\nexport function unobstructedCenter(viewportWidth: number, viewportHeight: number): ScreenPoint {\n return {\n x: viewportWidth / 2 - (CHROME_INSETS.right - CHROME_INSETS.left) / 2,\n y: viewportHeight / 2 - CHROME_INSETS.bottom / 2,\n };\n}\n\n/**\n * Projects an editor-space point — an offset from the center of the editor showcase's panel — to the screen.\n * @param x The horizontal offset from the panel's center.\n * @param y The vertical offset from the panel's center.\n * @param viewportWidth The viewport's width in pixels.\n * @param viewportHeight The viewport's height in pixels.\n * @returns The {@link ScreenPoint} relative to the board's box.\n * @remarks\n * The showcase pins its panel on the unobstructed center whatever the viewport size, so offsets from that\n * center are the one coordinate system in which a spot inside the panel — a button, a field, a tab — has the\n * same coordinates on every screen. Measured offsets therefore stay valid everywhere, exactly like the\n * toolbar's fixed screen coordinates.\n */\nexport function projectEditorPointToScreen(x: number, y: number, viewportWidth: number, viewportHeight: number): ScreenPoint {\n const center = unobstructedCenter(viewportWidth, viewportHeight);\n return { x: center.x + x, y: center.y + y };\n}\n\n/**\n * Projects a toolbar-space point — a fixed offset from the left edge, and a vertical offset from the\n * viewport's center — to the screen.\n * @param x The horizontal offset from the board's left edge.\n * @param y The vertical offset from the viewport's vertical center.\n * @param viewportHeight The viewport's height in pixels.\n * @returns The {@link ScreenPoint} relative to the board's box.\n * @remarks\n * The tour's toolbar centers itself vertically the way the editor's own toolbar does, so a spot on one of\n * its buttons is a fixed distance from the vertical center on every viewport — this is the coordinate system\n * in which those spots keep the same plain numbers everywhere.\n */\nexport function projectToolbarPointToScreen(x: number, y: number, viewportHeight: number): ScreenPoint {\n return { x, y: viewportHeight / 2 + y };\n}\n"],"names":["CHROME_INSETS","left","right","bottom","projectToScreen","worldX","worldY","transform","x","pan","zoom","y","unobstructedCenter","viewportWidth","viewportHeight","projectEditorPointToScreen","center","projectToolbarPointToScreen"],"mappings":"AAAA;AACA;AAEA;;;;;;;UA0BaA,aAAAA,GAAgB;IAAEC,IAAAA,EAAM,EAAA;IAAIC,KAAAA,EAAO,GAAA;IAAKC,MAAAA,EAAQ;AAAI;AAEjE;;;;;;;;;;AAUC,IACM,SAASC,eAAAA,CAAgBC,MAAc,EAAEC,MAAc,EAAEC,SAAyB,EAAA;IACrF,OAAO;AACHC,QAAAA,CAAAA,EAAGD,UAAUE,GAAG,CAACD,CAAC,GAAGH,MAAAA,GAASE,UAAUG,IAAI;AAC5CC,QAAAA,CAAAA,EAAGJ,UAAUE,GAAG,CAACE,CAAC,GAAGL,MAAAA,GAASC,UAAUG;AAC5C,KAAA;AACJ;AAEA;;;;;AAKC,IACM,SAASE,kBAAAA,CAAmBC,aAAqB,EAAEC,cAAsB,EAAA;IAC5E,OAAO;QACHN,CAAAA,EAAGK,aAAAA,GAAgB,CAAA,GAAKb,CAAAA,aAAAA,CAAcE,KAAK,GAAGF,aAAAA,CAAcC,IAAG,IAAK,CAAA;AACpEU,QAAAA,CAAAA,EAAGG,cAAAA,GAAiB,CAAA,GAAId,aAAAA,CAAcG,MAAM,GAAG;AACnD,KAAA;AACJ;AAEA;;;;;;;;;;;;IAaO,SAASY,0BAAAA,CAA2BP,CAAS,EAAEG,CAAS,EAAEE,aAAqB,EAAEC,cAAsB,EAAA;IAC1G,MAAME,MAAAA,GAASJ,mBAAmBC,aAAAA,EAAeC,cAAAA,CAAAA;IACjD,OAAO;QAAEN,CAAAA,EAAGQ,MAAAA,CAAOR,CAAC,GAAGA,CAAAA;QAAGG,CAAAA,EAAGK,MAAAA,CAAOL,CAAC,GAAGA;AAAE,KAAA;AAC9C;AAEA;;;;;;;;;;;AAWC,IACM,SAASM,2BAAAA,CAA4BT,CAAS,EAAEG,CAAS,EAAEG,cAAsB,EAAA;IACpF,OAAO;AAAEN,QAAAA,CAAAA;AAAGG,QAAAA,CAAAA,EAAGG,iBAAiB,CAAA,GAAIH;AAAE,KAAA;AAC1C;;"}
@@ -0,0 +1,12 @@
1
+ export type TourSelfPacedContent = Readonly<Record<string, string>>;
2
+ export interface TourSelfPacedView {
3
+ isSelfPaced: boolean;
4
+ isMediaPlaybackEnabled: boolean;
5
+ areTimingsShown: boolean;
6
+ markdown: string;
7
+ }
8
+ export declare function hasSelfPacedContent(content: TourSelfPacedContent | undefined): boolean;
9
+ export declare function selfPacedMarkdownFor(content: TourSelfPacedContent | undefined, chapterId: string | undefined): string;
10
+ export declare function selfPacedViewFor(isSelfPaced: boolean, content: TourSelfPacedContent | undefined, chapterId: string | undefined): TourSelfPacedView;
11
+ export declare function resolveTourMedia(markdown: string, mediaUrls: Readonly<Record<string, string>>): string;
12
+ //# sourceMappingURL=tourSelfPaced.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tourSelfPaced.d.ts","sourceRoot":"","sources":["../../tourSelfPaced.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAGpE,MAAM,WAAW,iBAAiB;IAE9B,WAAW,EAAE,OAAO,CAAC;IAGrB,sBAAsB,EAAE,OAAO,CAAC;IAGhC,eAAe,EAAE,OAAO,CAAC;IAGzB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAQD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,SAAS,GAAG,OAAO,CAEtF;AAQD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,oBAAoB,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAIrH;AAYD,wBAAgB,gBAAgB,CAC5B,WAAW,EAAE,OAAO,EACpB,OAAO,EAAE,oBAAoB,GAAG,SAAS,EACzC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,iBAAiB,CAWpD;AAgBD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAMtG"}
@@ -0,0 +1,64 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ /**
4
+ * The markdown walkthroughs a tour offers for reading it self-paced, keyed by chapter id — the same ids the
5
+ * tour's script gives its chapters. A tour without content simply never offers the self-paced switch.
6
+ */ /**
7
+ * Gets whether a tour has any self-paced content to read at all, which is what decides whether the
8
+ * self-paced switch is offered.
9
+ * @param content The tour's content, or undefined when it has none.
10
+ * @returns True when there is at least one chapter's markdown to show.
11
+ */ function hasSelfPacedContent(content) {
12
+ return content !== undefined && Object.keys(content).length > 0;
13
+ }
14
+ /**
15
+ * Gets the markdown to read for a chapter.
16
+ * @param content The tour's content, or undefined when it has none.
17
+ * @param chapterId The chapter being read, or undefined when the tour has no chapters.
18
+ * @returns The chapter's markdown, or an empty string when there is nothing to show for it.
19
+ */ function selfPacedMarkdownFor(content, chapterId) {
20
+ if (content === undefined || chapterId === undefined) return '';
21
+ return content[chapterId] ?? '';
22
+ }
23
+ /**
24
+ * Decides how the tour's chrome behaves for the mode it is in: reading self-paced stops being a media
25
+ * player — the playback controls dim, the chapter timings disappear because there is no clock to time
26
+ * against, and the current chapter's walkthrough is shown — while narrated playback keeps all of it and
27
+ * shows no markdown.
28
+ * @param isSelfPaced Whether the viewer has switched to self-paced reading.
29
+ * @param content The tour's content, or undefined when it has none.
30
+ * @param chapterId The chapter currently reached, or undefined when the tour has no chapters.
31
+ * @returns The {@link TourSelfPacedView} the chrome draws from.
32
+ */ function selfPacedViewFor(isSelfPaced, content, chapterId) {
33
+ // Self-paced mode without anything to read would be a silent, frozen tour — so the mode only ever
34
+ // engages when there is content to show.
35
+ const isReading = isSelfPaced && hasSelfPacedContent(content);
36
+ return {
37
+ isSelfPaced: isReading,
38
+ isMediaPlaybackEnabled: !isReading,
39
+ areTimingsShown: !isReading,
40
+ markdown: isReading ? selfPacedMarkdownFor(content, chapterId) : ''
41
+ };
42
+ }
43
+ // Matches a markdown image (`![alt](url)` or `![alt](url "title")`) and captures the surrounding syntax so
44
+ // only the URL is rewritten — the same shape the release-notes rewriter uses.
45
+ const markdownImagePattern = /(!\[[^\]]*\]\()([^)\s]+)(\s*(?:"[^"]*")?\s*\))/g;
46
+ /**
47
+ * Resolves the media references in a chapter's markdown against the URLs the bundler gave the media files.
48
+ * Content references its screenshots and animations with paths relative to its own folder (`media/name.png`);
49
+ * at runtime those files live wherever the bundler put them, and this maps each reference to that URL. A
50
+ * reference to a file that does not exist (yet) is left untouched, so its alt text still tells the reader
51
+ * what belongs there.
52
+ * @param markdown The chapter's markdown.
53
+ * @param mediaUrls The bundled URL for each media file, keyed by the path the markdown references it with.
54
+ * @returns The markdown with every known media reference resolved.
55
+ */ function resolveTourMedia(markdown, mediaUrls) {
56
+ return markdown.replace(markdownImagePattern, (match, prefix, url, suffix)=>{
57
+ const normalized = url.replace(/^\.\//, '');
58
+ const resolved = mediaUrls[normalized];
59
+ return resolved === undefined ? match : `${prefix}${resolved}${suffix}`;
60
+ });
61
+ }
62
+
63
+ export { hasSelfPacedContent, resolveTourMedia, selfPacedMarkdownFor, selfPacedViewFor };
64
+ //# sourceMappingURL=tourSelfPaced.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tourSelfPaced.js","sources":["../../tourSelfPaced.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * The markdown walkthroughs a tour offers for reading it self-paced, keyed by chapter id — the same ids the\n * tour's script gives its chapters. A tour without content simply never offers the self-paced switch.\n */\nexport type TourSelfPacedContent = Readonly<Record<string, string>>;\n\n/** Everything the tour's chrome needs to draw itself in or out of self-paced reading mode. */\nexport interface TourSelfPacedView {\n /** Whether the tour is being read self-paced rather than played. */\n isSelfPaced: boolean;\n\n /** Whether the media playback controls — play, scrubbing, narration and subtitles — are usable. */\n isMediaPlaybackEnabled: boolean;\n\n /** Whether the chapter list shows where on the clock each chapter starts. */\n areTimingsShown: boolean;\n\n /** The markdown for the chapter being read, or an empty string when the chapter has none. */\n markdown: string;\n}\n\n/**\n * Gets whether a tour has any self-paced content to read at all, which is what decides whether the\n * self-paced switch is offered.\n * @param content The tour's content, or undefined when it has none.\n * @returns True when there is at least one chapter's markdown to show.\n */\nexport function hasSelfPacedContent(content: TourSelfPacedContent | undefined): boolean {\n return content !== undefined && Object.keys(content).length > 0;\n}\n\n/**\n * Gets the markdown to read for a chapter.\n * @param content The tour's content, or undefined when it has none.\n * @param chapterId The chapter being read, or undefined when the tour has no chapters.\n * @returns The chapter's markdown, or an empty string when there is nothing to show for it.\n */\nexport function selfPacedMarkdownFor(content: TourSelfPacedContent | undefined, chapterId: string | undefined): string {\n if (content === undefined || chapterId === undefined) return '';\n\n return content[chapterId] ?? '';\n}\n\n/**\n * Decides how the tour's chrome behaves for the mode it is in: reading self-paced stops being a media\n * player — the playback controls dim, the chapter timings disappear because there is no clock to time\n * against, and the current chapter's walkthrough is shown — while narrated playback keeps all of it and\n * shows no markdown.\n * @param isSelfPaced Whether the viewer has switched to self-paced reading.\n * @param content The tour's content, or undefined when it has none.\n * @param chapterId The chapter currently reached, or undefined when the tour has no chapters.\n * @returns The {@link TourSelfPacedView} the chrome draws from.\n */\nexport function selfPacedViewFor(\n isSelfPaced: boolean,\n content: TourSelfPacedContent | undefined,\n chapterId: string | undefined): TourSelfPacedView {\n // Self-paced mode without anything to read would be a silent, frozen tour — so the mode only ever\n // engages when there is content to show.\n const isReading = isSelfPaced && hasSelfPacedContent(content);\n\n return {\n isSelfPaced: isReading,\n isMediaPlaybackEnabled: !isReading,\n areTimingsShown: !isReading,\n markdown: isReading ? selfPacedMarkdownFor(content, chapterId) : '',\n };\n}\n\n// Matches a markdown image (`![alt](url)` or `![alt](url \"title\")`) and captures the surrounding syntax so\n// only the URL is rewritten — the same shape the release-notes rewriter uses.\nconst markdownImagePattern = /(!\\[[^\\]]*\\]\\()([^)\\s]+)(\\s*(?:\"[^\"]*\")?\\s*\\))/g;\n\n/**\n * Resolves the media references in a chapter's markdown against the URLs the bundler gave the media files.\n * Content references its screenshots and animations with paths relative to its own folder (`media/name.png`);\n * at runtime those files live wherever the bundler put them, and this maps each reference to that URL. A\n * reference to a file that does not exist (yet) is left untouched, so its alt text still tells the reader\n * what belongs there.\n * @param markdown The chapter's markdown.\n * @param mediaUrls The bundled URL for each media file, keyed by the path the markdown references it with.\n * @returns The markdown with every known media reference resolved.\n */\nexport function resolveTourMedia(markdown: string, mediaUrls: Readonly<Record<string, string>>): string {\n return markdown.replace(markdownImagePattern, (match, prefix, url, suffix) => {\n const normalized = (url as string).replace(/^\\.\\//, '');\n const resolved = mediaUrls[normalized];\n return resolved === undefined ? match : `${prefix}${resolved}${suffix}`;\n });\n}\n"],"names":["hasSelfPacedContent","content","undefined","Object","keys","length","selfPacedMarkdownFor","chapterId","selfPacedViewFor","isSelfPaced","isReading","isMediaPlaybackEnabled","areTimingsShown","markdown","markdownImagePattern","resolveTourMedia","mediaUrls","replace","match","prefix","url","suffix","normalized","resolved"],"mappings":"AAAA;AACA;AAEA;;;;;;;;IA2BO,SAASA,mBAAAA,CAAoBC,OAAyC,EAAA;AACzE,IAAA,OAAOA,YAAYC,SAAAA,IAAaC,MAAAA,CAAOC,IAAI,CAACH,OAAAA,CAAAA,CAASI,MAAM,GAAG,CAAA;AAClE;AAEA;;;;;AAKC,IACM,SAASC,oBAAAA,CAAqBL,OAAyC,EAAEM,SAA6B,EAAA;AACzG,IAAA,IAAIN,OAAAA,KAAYC,SAAAA,IAAaK,SAAAA,KAAcL,SAAAA,EAAW,OAAO,EAAA;IAE7D,OAAOD,OAAO,CAACM,SAAAA,CAAU,IAAI,EAAA;AACjC;AAEA;;;;;;;;;AASC,IACM,SAASC,gBAAAA,CACZC,WAAoB,EACpBR,OAAyC,EACzCM,SAA6B,EAAA;;;IAG7B,MAAMG,SAAAA,GAAYD,eAAeT,mBAAAA,CAAoBC,OAAAA,CAAAA;IAErD,OAAO;QACHQ,WAAAA,EAAaC,SAAAA;AACbC,QAAAA,sBAAAA,EAAwB,CAACD,SAAAA;AACzBE,QAAAA,eAAAA,EAAiB,CAACF,SAAAA;QAClBG,QAAAA,EAAUH,SAAAA,GAAYJ,oBAAAA,CAAqBL,OAAAA,EAASM,SAAAA,CAAAA,GAAa;AACrE,KAAA;AACJ;AAEA;AACA;AACA,MAAMO,oBAAAA,GAAuB,iDAAA;AAE7B;;;;;;;;;AASC,IACM,SAASC,gBAAAA,CAAiBF,QAAgB,EAAEG,SAA2C,EAAA;AAC1F,IAAA,OAAOH,SAASI,OAAO,CAACH,sBAAsB,CAACI,KAAAA,EAAOC,QAAQC,GAAAA,EAAKC,MAAAA,GAAAA;AAC/D,QAAA,MAAMC,UAAAA,GAAcF,GAAAA,CAAeH,OAAO,CAAC,OAAA,EAAS,EAAA,CAAA;QACpD,MAAMM,QAAAA,GAAWP,SAAS,CAACM,UAAAA,CAAW;AACtC,QAAA,OAAOC,aAAarB,SAAAA,GAAYgB,KAAAA,GAAQ,CAAA,EAAGC,MAAAA,CAAAA,EAASI,WAAWF,MAAAA,CAAAA,CAAQ;AAC3E,IAAA,CAAA,CAAA;AACJ;;"}
@@ -0,0 +1,40 @@
1
+ import type { TourChapter } from './TourChapter.js';
2
+ import type { TourSection } from './TourSection.js';
3
+ import type { TourStep } from './TourStep.js';
4
+ export declare const MINIMUM_STEP_MS = 2200;
5
+ export declare const RESTART_CHAPTER_WINDOW_MS = 2000;
6
+ export interface TimedTourStep<TStep extends TourStep = TourStep> {
7
+ step: TStep;
8
+ chapterIndex: number;
9
+ startMs: number;
10
+ endMs: number;
11
+ }
12
+ export interface TimedTourChapter<TStep extends TourStep = TourStep> {
13
+ chapter: TourChapter<TStep>;
14
+ sectionIndex: number;
15
+ startMs: number;
16
+ endMs: number;
17
+ }
18
+ export interface TimedTourSection<TStep extends TourStep = TourStep> {
19
+ section: TourSection<TStep>;
20
+ startMs: number;
21
+ endMs: number;
22
+ }
23
+ export interface TourTimeline<TStep extends TourStep = TourStep> {
24
+ steps: TimedTourStep<TStep>[];
25
+ chapters: TimedTourChapter<TStep>[];
26
+ sections: TimedTourSection<TStep>[];
27
+ durationMs: number;
28
+ }
29
+ export declare function narrationDurationMs(narration: string): number;
30
+ export declare function stepDurationMs(step: TourStep): number;
31
+ export declare function buildTourTimeline<TStep extends TourStep>(sections: TourSection<TStep>[]): TourTimeline<TStep>;
32
+ export declare function stepIndexAtTime(timeline: TourTimeline, timeMs: number): number;
33
+ export declare function chapterIndexAtTime(timeline: TourTimeline, timeMs: number): number;
34
+ export declare function sectionIndexAtTime(timeline: TourTimeline, timeMs: number): number;
35
+ export declare function chapterStartMs(timeline: TourTimeline, chapterIndex: number): number;
36
+ export declare function previousChapterTargetMs(timeline: TourTimeline, timeMs: number): number;
37
+ export declare function nextChapterTargetMs(timeline: TourTimeline, timeMs: number): number;
38
+ export declare function narrationsAfter(timeline: TourTimeline, stepIndex: number, count: number): string[];
39
+ export declare function formatTourTime(timeMs: number): string;
40
+ //# sourceMappingURL=tourTimeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tourTimeline.d.ts","sourceRoot":"","sources":["../../tourTimeline.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAS9C,eAAO,MAAM,eAAe,OAAO,CAAC;AAMpC,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAG9C,MAAM,WAAW,aAAa,CAAC,KAAK,SAAS,QAAQ,GAAG,QAAQ;IAE5D,IAAI,EAAE,KAAK,CAAC;IAGZ,YAAY,EAAE,MAAM,CAAC;IAGrB,OAAO,EAAE,MAAM,CAAC;IAGhB,KAAK,EAAE,MAAM,CAAC;CACjB;AAGD,MAAM,WAAW,gBAAgB,CAAC,KAAK,SAAS,QAAQ,GAAG,QAAQ;IAE/D,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IAG5B,YAAY,EAAE,MAAM,CAAC;IAGrB,OAAO,EAAE,MAAM,CAAC;IAGhB,KAAK,EAAE,MAAM,CAAC;CACjB;AAGD,MAAM,WAAW,gBAAgB,CAAC,KAAK,SAAS,QAAQ,GAAG,QAAQ;IAE/D,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IAG5B,OAAO,EAAE,MAAM,CAAC;IAGhB,KAAK,EAAE,MAAM,CAAC;CACjB;AAGD,MAAM,WAAW,YAAY,CAAC,KAAK,SAAS,QAAQ,GAAG,QAAQ;IAE3D,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;I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license information.
3
+ /** Words per minute the narration is assumed to be read at — a calm, unhurried voice-over pace. */ const NARRATION_WORDS_PER_MINUTE = 145;
4
+ /** The breath left at the end of a narrated step before the next one starts. */ const NARRATION_TAIL_MS = 900;
5
+ /** No step is ever shorter than this, however short its line is. */ const MINIMUM_STEP_MS = 2200;
6
+ /** How long a step with nothing to say lasts — a pure camera move. */ const SILENT_STEP_MS = 2500;
7
+ /** How far into a chapter "previous" restarts it rather than going back a chapter, as a video player does. */ const RESTART_CHAPTER_WINDOW_MS = 2000;
8
+ /**
9
+ * Estimates how long a line of narration takes to say.
10
+ * @param narration The line to be spoken.
11
+ * @returns The duration in milliseconds.
12
+ */ function narrationDurationMs(narration) {
13
+ const words = narration.split(/\s+/u).filter((word)=>word.length > 0).length;
14
+ if (words === 0) return SILENT_STEP_MS;
15
+ const spoken = words / NARRATION_WORDS_PER_MINUTE * 60000;
16
+ return Math.max(MINIMUM_STEP_MS, Math.round(spoken + NARRATION_TAIL_MS));
17
+ }
18
+ /**
19
+ * Gets how long a step lasts, preferring the script's own figure when it states one.
20
+ * @param step The step to measure.
21
+ * @returns The duration in milliseconds.
22
+ */ function stepDurationMs(step) {
23
+ return step.durationMs ?? narrationDurationMs(step.narration);
24
+ }
25
+ /**
26
+ * Lays the sections out on a single clock so every part of the player can work in one shared unit of time.
27
+ *
28
+ * The clock stays flat: steps and chapters run straight through every section, and a chapter's index is its
29
+ * position across the whole tour — sections only add headings and spans on top, they never fragment the clock.
30
+ * @param sections The scripted sections, in play order.
31
+ * @returns The {@link TourTimeline}.
32
+ */ function buildTourTimeline(sections) {
33
+ const steps = [];
34
+ const timedChapters = [];
35
+ const timedSections = [];
36
+ let cursor = 0;
37
+ sections.forEach((section, sectionIndex)=>{
38
+ const sectionStart = cursor;
39
+ for (const chapter of section.chapters){
40
+ const chapterStart = cursor;
41
+ const chapterIndex = timedChapters.length;
42
+ for (const step of chapter.steps){
43
+ const endMs = cursor + stepDurationMs(step);
44
+ steps.push({
45
+ step,
46
+ chapterIndex,
47
+ startMs: cursor,
48
+ endMs
49
+ });
50
+ cursor = endMs;
51
+ }
52
+ timedChapters.push({
53
+ chapter,
54
+ sectionIndex,
55
+ startMs: chapterStart,
56
+ endMs: cursor
57
+ });
58
+ }
59
+ timedSections.push({
60
+ section,
61
+ startMs: sectionStart,
62
+ endMs: cursor
63
+ });
64
+ });
65
+ return {
66
+ steps,
67
+ chapters: timedChapters,
68
+ sections: timedSections,
69
+ durationMs: cursor
70
+ };
71
+ }
72
+ /**
73
+ * Gets which step is playing at a point on the clock.
74
+ * @param timeline The timeline to look in.
75
+ * @param timeMs The point on the clock, in milliseconds.
76
+ * @returns The index into {@link TourTimeline.steps}, or -1 when the timeline is empty.
77
+ */ function stepIndexAtTime(timeline, timeMs) {
78
+ if (timeline.steps.length === 0) return -1;
79
+ // The end of the tour belongs to its last step rather than to nothing, so the final line stays on screen
80
+ // when playback finishes instead of the subtitles blanking on the last frame.
81
+ const found = timeline.steps.findIndex((candidate)=>timeMs >= candidate.startMs && timeMs < candidate.endMs);
82
+ if (found >= 0) return found;
83
+ return timeMs < 0 ? 0 : timeline.steps.length - 1;
84
+ }
85
+ /**
86
+ * Gets which chapter is playing at a point on the clock.
87
+ * @param timeline The timeline to look in.
88
+ * @param timeMs The point on the clock, in milliseconds.
89
+ * @returns The index into {@link TourTimeline.chapters}, or -1 when the timeline is empty.
90
+ */ function chapterIndexAtTime(timeline, timeMs) {
91
+ const stepIndex = stepIndexAtTime(timeline, timeMs);
92
+ return stepIndex < 0 ? -1 : timeline.steps[stepIndex].chapterIndex;
93
+ }
94
+ /**
95
+ * Gets which section is playing at a point on the clock.
96
+ * @param timeline The timeline to look in.
97
+ * @param timeMs The point on the clock, in milliseconds.
98
+ * @returns The index into {@link TourTimeline.sections}, or -1 when the timeline is empty.
99
+ */ function sectionIndexAtTime(timeline, timeMs) {
100
+ const chapterIndex = chapterIndexAtTime(timeline, timeMs);
101
+ return chapterIndex < 0 ? -1 : timeline.chapters[chapterIndex].sectionIndex;
102
+ }
103
+ /**
104
+ * Gets where on the clock a chapter begins.
105
+ * @param timeline The timeline to look in.
106
+ * @param chapterIndex The chapter to locate.
107
+ * @returns The point on the clock in milliseconds, or 0 when there is no such chapter.
108
+ */ function chapterStartMs(timeline, chapterIndex) {
109
+ return timeline.chapters[chapterIndex]?.startMs ?? 0;
110
+ }
111
+ /**
112
+ * Gets where "previous chapter" should land from a point on the clock.
113
+ * @param timeline The timeline to look in.
114
+ * @param timeMs The current point on the clock, in milliseconds.
115
+ * @returns The point on the clock to jump to, in milliseconds.
116
+ */ function previousChapterTargetMs(timeline, timeMs) {
117
+ const current = chapterIndexAtTime(timeline, timeMs);
118
+ if (current < 0) return 0;
119
+ // Well into a chapter, "previous" restarts the one being watched — the same thing a video player does,
120
+ // and what someone who missed the start of an explanation actually wants.
121
+ const startOfCurrent = chapterStartMs(timeline, current);
122
+ if (timeMs - startOfCurrent > RESTART_CHAPTER_WINDOW_MS) return startOfCurrent;
123
+ return chapterStartMs(timeline, Math.max(0, current - 1));
124
+ }
125
+ /**
126
+ * Gets where "next chapter" should land from a point on the clock.
127
+ * @param timeline The timeline to look in.
128
+ * @param timeMs The current point on the clock, in milliseconds.
129
+ * @returns The point on the clock to jump to, in milliseconds.
130
+ */ function nextChapterTargetMs(timeline, timeMs) {
131
+ const current = chapterIndexAtTime(timeline, timeMs);
132
+ if (current < 0) return 0;
133
+ if (current >= timeline.chapters.length - 1) return timeline.durationMs;
134
+ return chapterStartMs(timeline, current + 1);
135
+ }
136
+ // The lines still to come after a step that have something to say, in the order they will be needed — what the voice-over is
137
+ // asked for ahead of time so each starts the moment its step does.
138
+ function narrationsAfter(timeline, stepIndex, count) {
139
+ if (stepIndex < 0) return [];
140
+ return timeline.steps.slice(stepIndex + 1, stepIndex + 1 + count).map((timed)=>timed.step.narration).filter((narration)=>narration.length > 0);
141
+ }
142
+ /**
143
+ * Formats a point on the clock the way a video player does.
144
+ * @param timeMs The point on the clock, in milliseconds.
145
+ * @returns The time as `m:ss`.
146
+ */ function formatTourTime(timeMs) {
147
+ const totalSeconds = Math.max(0, Math.floor(timeMs / 1000));
148
+ const minutes = Math.floor(totalSeconds / 60);
149
+ const seconds = totalSeconds % 60;
150
+ return `${minutes}:${seconds.toString().padStart(2, '0')}`;
151
+ }
152
+
153
+ export { MINIMUM_STEP_MS, RESTART_CHAPTER_WINDOW_MS, buildTourTimeline, chapterIndexAtTime, chapterStartMs, formatTourTime, narrationDurationMs, narrationsAfter, nextChapterTargetMs, previousChapterTargetMs, sectionIndexAtTime, stepDurationMs, stepIndexAtTime };
154
+ //# sourceMappingURL=tourTimeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tourTimeline.js","sources":["../../tourTimeline.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { TourChapter } from './TourChapter.js';\nimport type { TourSection } from './TourSection.js';\nimport type { TourStep } from './TourStep.js';\n\n/** Words per minute the narration is assumed to be read at — a calm, unhurried voice-over pace. */\nconst NARRATION_WORDS_PER_MINUTE = 145;\n\n/** The breath left at the end of a narrated step before the next one starts. */\nconst NARRATION_TAIL_MS = 900;\n\n/** No step is ever shorter than this, however short its line is. */\nexport const MINIMUM_STEP_MS = 2200;\n\n/** How long a step with nothing to say lasts — a pure camera move. */\nconst SILENT_STEP_MS = 2500;\n\n/** How far into a chapter \"previous\" restarts it rather than going back a chapter, as a video player does. */\nexport const RESTART_CHAPTER_WINDOW_MS = 2000;\n\n/** A step placed on the tour's clock. */\nexport interface TimedTourStep<TStep extends TourStep = TourStep> {\n /** The step itself. */\n step: TStep;\n\n /** The chapter the step belongs to. */\n chapterIndex: number;\n\n /** When the step starts, in milliseconds from the beginning of the tour. */\n startMs: number;\n\n /** When the step ends, in milliseconds from the beginning of the tour. */\n endMs: number;\n}\n\n/** A chapter placed on the tour's clock. */\nexport interface TimedTourChapter<TStep extends TourStep = TourStep> {\n /** The chapter itself. */\n chapter: TourChapter<TStep>;\n\n /** The section the chapter belongs to. */\n sectionIndex: number;\n\n /** When the chapter starts, in milliseconds from the beginning of the tour. */\n startMs: number;\n\n /** When the chapter ends, in milliseconds from the beginning of the tour. */\n endMs: number;\n}\n\n/** A section placed on the tour's clock. */\nexport interface TimedTourSection<TStep extends TourStep = TourStep> {\n /** The section itself. */\n section: TourSection<TStep>;\n\n /** When the section starts, in milliseconds from the beginning of the tour. */\n startMs: number;\n\n /** When the section ends, in milliseconds from the beginning of the tour. */\n endMs: number;\n}\n\n/** The whole tour laid out on one clock, which is what the progress bar, subtitles and chapter list read. */\nexport interface TourTimeline<TStep extends TourStep = TourStep> {\n /** Every step of every chapter of every section, in play order. */\n steps: TimedTourStep<TStep>[];\n\n /** Every chapter, in play order across all sections. Chapter indices used anywhere in the player index into this list. */\n chapters: TimedTourChapter<TStep>[];\n\n /** Every section, in play order. */\n sections: TimedTourSection<TStep>[];\n\n /** How long the whole tour lasts, in milliseconds. */\n durationMs: number;\n}\n\n/**\n * Estimates how long a line of narration takes to say.\n * @param narration The line to be spoken.\n * @returns The duration in milliseconds.\n */\nexport function narrationDurationMs(narration: string): number {\n const words = narration.split(/\\s+/u).filter(word => word.length > 0).length;\n if (words === 0) return SILENT_STEP_MS;\n\n const spoken = (words / NARRATION_WORDS_PER_MINUTE) * 60000;\n return Math.max(MINIMUM_STEP_MS, Math.round(spoken + NARRATION_TAIL_MS));\n}\n\n/**\n * Gets how long a step lasts, preferring the script's own figure when it states one.\n * @param step The step to measure.\n * @returns The duration in milliseconds.\n */\nexport function stepDurationMs(step: TourStep): number {\n return step.durationMs ?? narrationDurationMs(step.narration);\n}\n\n/**\n * Lays the sections out on a single clock so every part of the player can work in one shared unit of time.\n *\n * The clock stays flat: steps and chapters run straight through every section, and a chapter's index is its\n * position across the whole tour — sections only add headings and spans on top, they never fragment the clock.\n * @param sections The scripted sections, in play order.\n * @returns The {@link TourTimeline}.\n */\nexport function buildTourTimeline<TStep extends TourStep>(sections: TourSection<TStep>[]): TourTimeline<TStep> {\n const steps: TimedTourStep<TStep>[] = [];\n const timedChapters: TimedTourChapter<TStep>[] = [];\n const timedSections: TimedTourSection<TStep>[] = [];\n let cursor = 0;\n\n sections.forEach((section, sectionIndex) => {\n const sectionStart = cursor;\n for (const chapter of section.chapters) {\n const chapterStart = cursor;\n const chapterIndex = timedChapters.length;\n for (const step of chapter.steps) {\n const endMs = cursor + stepDurationMs(step);\n steps.push({ step, chapterIndex, startMs: cursor, endMs });\n cursor = endMs;\n }\n\n timedChapters.push({ chapter, sectionIndex, startMs: chapterStart, endMs: cursor });\n }\n\n timedSections.push({ section, startMs: sectionStart, endMs: cursor });\n });\n\n return { steps, chapters: timedChapters, sections: timedSections, durationMs: cursor };\n}\n\n/**\n * Gets which step is playing at a point on the clock.\n * @param timeline The timeline to look in.\n * @param timeMs The point on the clock, in milliseconds.\n * @returns The index into {@link TourTimeline.steps}, or -1 when the timeline is empty.\n */\nexport function stepIndexAtTime(timeline: TourTimeline, timeMs: number): number {\n if (timeline.steps.length === 0) return -1;\n\n // The end of the tour belongs to its last step rather than to nothing, so the final line stays on screen\n // when playback finishes instead of the subtitles blanking on the last frame.\n const found = timeline.steps.findIndex(candidate => timeMs >= candidate.startMs && timeMs < candidate.endMs);\n if (found >= 0) return found;\n\n return timeMs < 0 ? 0 : timeline.steps.length - 1;\n}\n\n/**\n * Gets which chapter is playing at a point on the clock.\n * @param timeline The timeline to look in.\n * @param timeMs The point on the clock, in milliseconds.\n * @returns The index into {@link TourTimeline.chapters}, or -1 when the timeline is empty.\n */\nexport function chapterIndexAtTime(timeline: TourTimeline, timeMs: number): number {\n const stepIndex = stepIndexAtTime(timeline, timeMs);\n return stepIndex < 0 ? -1 : timeline.steps[stepIndex].chapterIndex;\n}\n\n/**\n * Gets which section is playing at a point on the clock.\n * @param timeline The timeline to look in.\n * @param timeMs The point on the clock, in milliseconds.\n * @returns The index into {@link TourTimeline.sections}, or -1 when the timeline is empty.\n */\nexport function sectionIndexAtTime(timeline: TourTimeline, timeMs: number): number {\n const chapterIndex = chapterIndexAtTime(timeline, timeMs);\n return chapterIndex < 0 ? -1 : timeline.chapters[chapterIndex].sectionIndex;\n}\n\n/**\n * Gets where on the clock a chapter begins.\n * @param timeline The timeline to look in.\n * @param chapterIndex The chapter to locate.\n * @returns The point on the clock in milliseconds, or 0 when there is no such chapter.\n */\nexport function chapterStartMs(timeline: TourTimeline, chapterIndex: number): number {\n return timeline.chapters[chapterIndex]?.startMs ?? 0;\n}\n\n/**\n * Gets where \"previous chapter\" should land from a point on the clock.\n * @param timeline The timeline to look in.\n * @param timeMs The current point on the clock, in milliseconds.\n * @returns The point on the clock to jump to, in milliseconds.\n */\nexport function previousChapterTargetMs(timeline: TourTimeline, timeMs: number): number {\n const current = chapterIndexAtTime(timeline, timeMs);\n if (current < 0) return 0;\n\n // Well into a chapter, \"previous\" restarts the one being watched — the same thing a video player does,\n // and what someone who missed the start of an explanation actually wants.\n const startOfCurrent = chapterStartMs(timeline, current);\n if (timeMs - startOfCurrent > RESTART_CHAPTER_WINDOW_MS) return startOfCurrent;\n\n return chapterStartMs(timeline, Math.max(0, current - 1));\n}\n\n/**\n * Gets where \"next chapter\" should land from a point on the clock.\n * @param timeline The timeline to look in.\n * @param timeMs The current point on the clock, in milliseconds.\n * @returns The point on the clock to jump to, in milliseconds.\n */\nexport function nextChapterTargetMs(timeline: TourTimeline, timeMs: number): number {\n const current = chapterIndexAtTime(timeline, timeMs);\n if (current < 0) return 0;\n if (current >= timeline.chapters.length - 1) return timeline.durationMs;\n\n return chapterStartMs(timeline, current + 1);\n}\n\n// The lines still to come after a step that have something to say, in the order they will be needed — what the voice-over is\n// asked for ahead of time so each starts the moment its step does.\nexport function narrationsAfter(timeline: TourTimeline, stepIndex: number, count: number): string[] {\n if (stepIndex < 0) return [];\n return timeline.steps\n .slice(stepIndex + 1, stepIndex + 1 + count)\n .map(timed => timed.step.narration)\n .filter(narration => narration.length > 0);\n}\n\n/**\n * Formats a point on the clock the way a video player does.\n * @param timeMs The point on the clock, in milliseconds.\n * @returns The time as `m:ss`.\n */\nexport function formatTourTime(timeMs: number): string {\n const totalSeconds = Math.max(0, Math.floor(timeMs / 1000));\n const minutes = Math.floor(totalSeconds / 60);\n const seconds = totalSeconds % 60;\n return `${minutes}:${seconds.toString().padStart(2, '0')}`;\n}\n"],"names":["NARRATION_WORDS_PER_MINUTE","NARRATION_TAIL_MS","MINIMUM_STEP_MS","SILENT_STEP_MS","RESTART_CHAPTER_WINDOW_MS","narrationDurationMs","narration","words","split","filter","word","length","spoken","Math","max","round","stepDurationMs","step","durationMs","buildTourTimeline","sections","steps","timedChapters","timedSections","cursor","forEach","section","sectionIndex","sectionStart","chapter","chapters","chapterStart","chapterIndex","endMs","push","startMs","stepIndexAtTime","timeline","timeMs","found","findIndex","candidate","chapterIndexAtTime","stepIndex","sectionIndexAtTime","chapterStartMs","previousChapterTargetMs","current","startOfCurrent","nextChapterTargetMs","narrationsAfter","count","slice","map","timed","formatTourTime","totalSeconds","floor","minutes","seconds","toString","padStart"],"mappings":"AAAA;AACA;AAMA,oGACA,MAAMA,0BAAAA,GAA6B,GAAA;AAEnC,iFACA,MAAMC,iBAAAA,GAAoB,GAAA;AAE1B,qEACO,MAAMC,eAAAA,GAAkB;AAE/B,uEACA,MAAMC,cAAAA,GAAiB,IAAA;AAEvB,+GACO,MAAMC,yBAAAA,GAA4B;AA2DzC;;;;IAKO,SAASC,mBAAAA,CAAoBC,SAAiB,EAAA;AACjD,IAAA,MAAMC,KAAAA,GAAQD,SAAAA,CAAUE,KAAK,CAAC,MAAA,CAAA,CAAQC,MAAM,CAACC,CAAAA,IAAAA,GAAQA,IAAAA,CAAKC,MAAM,GAAG,GAAGA,MAAM;IAC5E,IAAIJ,KAAAA,KAAU,GAAG,OAAOJ,cAAAA;IAExB,MAAMS,MAAAA,GAAS,KAACL,GAAQP,0BAAAA,GAA8B,KAAA;AACtD,IAAA,OAAOa,KAAKC,GAAG,CAACZ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,GAAaA,SAAAA,CAAUK,MAAM,GAAG,CAAA,CAAA;AAChD;AAEA;;;;IAKO,SAAS4C,cAAAA,CAAejB,MAAc,EAAA;IACzC,MAAMkB,YAAAA,GAAe3C,KAAKC,GAAG,CAAC,GAAGD,IAAAA,CAAK4C,KAAK,CAACnB,MAAAA,GAAS,IAAA,CAAA,CAAA;AACrD,IAAA,MAAMoB,OAAAA,GAAU7C,IAAAA,CAAK4C,KAAK,CAACD,YAAAA,GAAe,EAAA,CAAA;AAC1C,IAAA,MAAMG,UAAUH,YAAAA,GAAe,EAAA;IAC/B,OAAO,CAAA,EAAGE,OAAAA,CAAQ,CAAC,EAAEC,OAAAA,CAAQC,QAAQ,EAAA,CAAGC,QAAQ,CAAC,CAAA,EAAG,GAAA,CAAA,CAAA,CAAM;AAC9D;;"}
@@ -0,0 +1,25 @@
1
+ import type { TourSection } from './TourSection.js';
2
+ import type { TourStep } from './TourStep.js';
3
+ import { type TourTimeline } from './tourTimeline.js';
4
+ export interface TourPlayback<TStep extends TourStep = TourStep> {
5
+ timeline: TourTimeline<TStep>;
6
+ timeMs: number;
7
+ isPlaying: boolean;
8
+ isAudioEnabled: boolean;
9
+ areSubtitlesEnabled: boolean;
10
+ isSpeechAvailable: boolean;
11
+ hasNarrationFailed: boolean;
12
+ step: TStep | undefined;
13
+ chapterIndex: number;
14
+ sectionIndex: number;
15
+ togglePlay(): void;
16
+ pause(): void;
17
+ seekTo(timeMs: number): void;
18
+ goToChapter(chapterIndex: number): void;
19
+ goToPreviousChapter(): void;
20
+ goToNextChapter(): void;
21
+ toggleAudio(): void;
22
+ toggleSubtitles(): void;
23
+ }
24
+ export declare function useTourPlayback<TStep extends TourStep>(sections: TourSection<TStep>[]): TourPlayback<TStep>;
25
+ //# sourceMappingURL=useTourPlayback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTourPlayback.d.ts","sourceRoot":"","sources":["../../useTourPlayback.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EACH,KAAK,YAAY,EASpB,MAAM,mBAAmB,CAAC;AAS3B,MAAM,WAAW,YAAY,CAAC,KAAK,SAAS,QAAQ,GAAG,QAAQ;IAE3D,QAAQ,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IAG9B,MAAM,EAAE,MAAM,CAAC;IAGf,SAAS,EAAE,OAAO,CAAC;IAGnB,cAAc,EAAE,OAAO,CAAC;IAGxB,mBAAmB,EAAE,OAAO,CAAC;IAG7B,iBAAiB,EAAE,OAAO,CAAC;IAG3B,kBAAkB,EAAE,OAAO,CAAC;IAG5B,IAAI,EAAE,KAAK,GAAG,SAAS,CAAC;IAGxB,YAAY,EAAE,MAAM,CAAC;IAGrB,YAAY,EAAE,MAAM,CAAC;IAGrB,UAAU,IAAI,IAAI,CAAC;IAGnB,KAAK,IAAI,IAAI,CAAC;IAGd,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAG7B,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAGxC,mBAAmB,IAAI,IAAI,CAAC;IAG5B,eAAe,IAAI,IAAI,CAAC;IAGxB,WAAW,IAAI,IAAI,CAAC;IAGpB,eAAe,IAAI,IAAI,CAAC;CAC3B;AAgBD,wBAAgB,eAAe,CAAC,KAAK,SAAS,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,CAiM3G"}