@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
package/styles.css ADDED
@@ -0,0 +1,485 @@
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
+ /*
5
+ * The styles of the Cue components. Import once, after the Cratis Components stylesheets:
6
+ * @import '@cratis/showrunner.cue.react/styles';
7
+ * Every color comes from the --cratis-* tokens, so the Cratis Components theme and dark mode apply. The tour's layer
8
+ * sits below the application's own top bar by --cue-viewport-top (0 unless the application sets it) and above the
9
+ * application at --cue-z-index (9999 unless it sets another).
10
+ */
11
+
12
+ /* TourOverlayShell */
13
+
14
+ /* The layer fills the viewport below --cue-viewport-top, and sits above the application at --cue-z-index. */
15
+ .cue-overlay {
16
+ position: fixed;
17
+ inset: 0;
18
+ top: var(--cue-viewport-top, 0px);
19
+ z-index: var(--cue-z-index, 9999);
20
+ background: var(--cratis-surface-ground);
21
+ }
22
+
23
+ /* TourChapterList */
24
+
25
+ .cue-chapters {
26
+ position: absolute;
27
+ top: 1rem;
28
+ right: 1rem;
29
+ bottom: 7.5rem;
30
+ z-index: 40;
31
+ display: flex;
32
+ flex-direction: column;
33
+ width: 19rem;
34
+ padding: 1rem;
35
+ border: 1px solid var(--cratis-surface-border);
36
+ border-radius: 0.75rem;
37
+ background: color-mix(in srgb, var(--cratis-surface-card) 88%, transparent);
38
+ backdrop-filter: blur(8px);
39
+ overflow: hidden;
40
+ }
41
+
42
+ .cue-chapters__heading {
43
+ margin: 0 0 0.75rem;
44
+ color: var(--cratis-text-color-secondary);
45
+ font-size: 0.75rem;
46
+ font-weight: 600;
47
+ letter-spacing: 0.08em;
48
+ text-transform: uppercase;
49
+ }
50
+
51
+ .cue-chapters__sections {
52
+ display: flex;
53
+ flex-direction: column;
54
+ gap: 0.75rem;
55
+ overflow-y: auto;
56
+ }
57
+
58
+ .cue-chapters__section-title {
59
+ margin: 0 0 0.35rem;
60
+ padding: 0 0.6rem;
61
+ color: var(--cratis-primary-color);
62
+ font-size: 0.7rem;
63
+ font-weight: 700;
64
+ letter-spacing: 0.1em;
65
+ text-transform: uppercase;
66
+ }
67
+
68
+ .cue-chapters__list {
69
+ display: flex;
70
+ flex-direction: column;
71
+ gap: 0.25rem;
72
+ margin: 0;
73
+ padding: 0;
74
+ list-style: none;
75
+ }
76
+
77
+ .cue-chapters__item {
78
+ display: flex;
79
+ gap: 0.6rem;
80
+ width: 100%;
81
+ padding: 0.5rem 0.6rem;
82
+ border: none;
83
+ border-radius: 0.5rem;
84
+ background: transparent;
85
+ color: var(--cratis-text-color);
86
+ text-align: left;
87
+ cursor: pointer;
88
+ }
89
+
90
+ .cue-chapters__item:hover {
91
+ background: var(--cratis-surface-hover);
92
+ }
93
+
94
+ .cue-chapters__item--current {
95
+ background: var(--cratis-highlight-bg);
96
+ }
97
+
98
+ .cue-chapters__time {
99
+ flex: 0 0 auto;
100
+ padding-top: 0.05rem;
101
+ color: var(--cratis-text-color-secondary);
102
+ font-size: 0.75rem;
103
+ font-variant-numeric: tabular-nums;
104
+ }
105
+
106
+ .cue-chapters__text {
107
+ display: flex;
108
+ flex-direction: column;
109
+ gap: 0.15rem;
110
+ min-width: 0;
111
+ }
112
+
113
+ .cue-chapters__title {
114
+ font-size: 0.9rem;
115
+ font-weight: 600;
116
+ }
117
+
118
+ .cue-chapters__summary {
119
+ color: var(--cratis-text-color-secondary);
120
+ font-size: 0.78rem;
121
+ line-height: 1.3;
122
+ }
123
+
124
+ /* TourSubtitles */
125
+
126
+ .cue-subtitles {
127
+ position: absolute;
128
+ bottom: 5.5rem;
129
+ left: 50%;
130
+ z-index: 40;
131
+ transform: translateX(-50%);
132
+ max-width: min(46rem, calc(100% - 24rem));
133
+ padding: 0.65rem 1.1rem;
134
+ border-radius: 0.6rem;
135
+ background: color-mix(in srgb, var(--cratis-surface-card) 78%, transparent);
136
+ pointer-events: none;
137
+ }
138
+
139
+ .cue-subtitles__line {
140
+ margin: 0;
141
+ color: var(--cratis-surface-0);
142
+ font-size: 1.05rem;
143
+ line-height: 1.45;
144
+ text-align: center;
145
+ text-wrap: balance;
146
+ }
147
+
148
+ /* TourTimelineBar */
149
+
150
+ .cue-transport {
151
+ position: absolute;
152
+ right: 1rem;
153
+ bottom: 1rem;
154
+ left: 1rem;
155
+ z-index: 40;
156
+ display: flex;
157
+ gap: 0.5rem;
158
+ align-items: center;
159
+ padding: 0.6rem 1rem;
160
+ border: 1px solid var(--cratis-surface-border);
161
+ border-radius: 0.75rem;
162
+ background: color-mix(in srgb, var(--cratis-surface-card) 88%, transparent);
163
+ backdrop-filter: blur(8px);
164
+ }
165
+
166
+ .cue-transport__button {
167
+ display: inline-flex;
168
+ align-items: center;
169
+ justify-content: center;
170
+ width: 2.25rem;
171
+ height: 2.25rem;
172
+ border: none;
173
+ border-radius: 50%;
174
+ background: transparent;
175
+ color: var(--cratis-text-color);
176
+ cursor: pointer;
177
+ }
178
+
179
+ .cue-transport__button:hover:not(:disabled) {
180
+ background: var(--cratis-surface-hover);
181
+ }
182
+
183
+ .cue-transport__button:disabled {
184
+ cursor: default;
185
+ opacity: 0.4;
186
+ }
187
+
188
+ .cue-transport__button--primary {
189
+ background: var(--cratis-primary-color);
190
+ color: var(--cratis-primary-color-text);
191
+ }
192
+
193
+ .cue-transport__button--primary:hover:not(:disabled) {
194
+ background: var(--cratis-primary-color);
195
+ filter: brightness(1.1);
196
+ }
197
+
198
+ .cue-transport__button--off {
199
+ color: var(--cratis-text-color-secondary);
200
+ }
201
+
202
+ /* The self-paced switch while reading — held on, the way an active tool presents itself. */
203
+ .cue-transport__button--active {
204
+ background: var(--cratis-highlight-bg);
205
+ color: var(--cratis-primary-color);
206
+ }
207
+
208
+ /* Reading self-paced: the clock and its track are informational at best, so they recede along with the
209
+ disabled media buttons; chapter skipping keeps its full presence as the way to move through the tour. */
210
+ .cue-transport--self-paced .cue-transport__track,
211
+ .cue-transport--self-paced .cue-transport__time {
212
+ opacity: 0.4;
213
+ }
214
+
215
+ /* The voice-over failed and the tour is carrying on with subtitles — a quiet heads-up on the switch that
216
+ retries it, not an alarm. */
217
+ .cue-transport__button--warning {
218
+ color: var(--cratis-orange-500);
219
+ }
220
+
221
+ .cue-transport__time {
222
+ color: var(--cratis-text-color-secondary);
223
+ font-size: 0.8rem;
224
+ font-variant-numeric: tabular-nums;
225
+ }
226
+
227
+ .cue-transport__track {
228
+ position: relative;
229
+ flex: 1 1 auto;
230
+ height: 0.35rem;
231
+ border-radius: 0.2rem;
232
+ background: var(--cratis-surface-border);
233
+ }
234
+
235
+ .cue-transport__elapsed {
236
+ position: absolute;
237
+ top: 0;
238
+ left: 0;
239
+ height: 100%;
240
+ border-radius: 0.2rem;
241
+ background: var(--cratis-primary-color);
242
+ pointer-events: none;
243
+ }
244
+
245
+ /* The real input carries the interaction and keyboard support; the bar above is what is actually seen. */
246
+ .cue-transport__scrubber {
247
+ position: absolute;
248
+ top: -0.6rem;
249
+ left: 0;
250
+ width: 100%;
251
+ height: 1.5rem;
252
+ margin: 0;
253
+ opacity: 0;
254
+ cursor: pointer;
255
+ }
256
+
257
+ /* TourSelfPacedPanel */
258
+
259
+ /* Docked to the left of the chapter list: its 19rem width plus its 1rem inset and a 1.5rem gap. Same visual
260
+ language as the list and the transport, so the three read as one set of chrome. */
261
+ .cue-self-paced {
262
+ position: absolute;
263
+ top: 1rem;
264
+ right: 21.5rem;
265
+ bottom: 7.5rem;
266
+ z-index: 40;
267
+ display: flex;
268
+ flex-direction: column;
269
+ width: min(34rem, calc(100vw - 26rem));
270
+ padding: 1rem 1.25rem;
271
+ border: 1px solid var(--cratis-surface-border);
272
+ border-radius: 0.75rem;
273
+ background: color-mix(in srgb, var(--cratis-surface-card) 92%, transparent);
274
+ backdrop-filter: blur(8px);
275
+ overflow: hidden;
276
+ }
277
+
278
+ .cue-self-paced__title {
279
+ margin: 0 0 0.75rem;
280
+ color: var(--cratis-text-color);
281
+ font-size: 1.05rem;
282
+ font-weight: 600;
283
+ }
284
+
285
+ .cue-self-paced__content {
286
+ min-height: 0;
287
+ overflow-y: auto;
288
+ }
289
+
290
+ /* The chapter's text sits on the panel's translucent card, at the chrome's slightly smaller type size. */
291
+ .cue-markdown {
292
+ color: var(--cratis-text-color);
293
+ font-size: 0.9rem;
294
+ line-height: 1.55;
295
+ overflow-wrap: anywhere;
296
+ }
297
+
298
+ .cue-markdown h2,
299
+ .cue-markdown h3 {
300
+ margin: 1.25rem 0 0.5rem;
301
+ font-size: 1rem;
302
+ font-weight: 600;
303
+ }
304
+
305
+ .cue-markdown p,
306
+ .cue-markdown ul,
307
+ .cue-markdown ol {
308
+ margin: 0 0 0.75rem;
309
+ }
310
+
311
+ .cue-markdown ul,
312
+ .cue-markdown ol {
313
+ padding-left: 1.25rem;
314
+ }
315
+
316
+ .cue-markdown a {
317
+ color: var(--cratis-primary-color);
318
+ }
319
+
320
+ .cue-markdown code {
321
+ padding: 0.1rem 0.3rem;
322
+ border-radius: 0.25rem;
323
+ background: var(--cratis-surface-hover);
324
+ font-size: 0.85em;
325
+ }
326
+
327
+ .cue-markdown pre {
328
+ margin: 0 0 0.75rem;
329
+ padding: 0.75rem;
330
+ border-radius: 0.5rem;
331
+ background: var(--cratis-surface-ground);
332
+ overflow-x: auto;
333
+ }
334
+
335
+ .cue-markdown pre code {
336
+ padding: 0;
337
+ background: transparent;
338
+ }
339
+
340
+ .cue-markdown img {
341
+ max-width: 100%;
342
+ border: 1px solid var(--cratis-surface-border);
343
+ border-radius: 0.5rem;
344
+ }
345
+
346
+ /* TourCalloutBubble */
347
+
348
+ .cue-callout {
349
+ pointer-events: none;
350
+ z-index: 29;
351
+ }
352
+
353
+ .cue-callout__bubble {
354
+ position: relative;
355
+ transform: translate(-50%, -100%);
356
+ max-width: 18rem;
357
+ padding: 0.5rem 0.85rem;
358
+ border: 1px solid var(--cratis-primary-color);
359
+ border-radius: 0.6rem;
360
+ background: var(--cratis-surface-card);
361
+ color: var(--cratis-text-color);
362
+ font-size: 0.9rem;
363
+ line-height: 1.3;
364
+ white-space: normal;
365
+ box-shadow: 0 6px 18px rgb(0 0 0 / 35%);
366
+ animation: cue-callout-appear 320ms ease-out;
367
+ }
368
+
369
+ .cue-callout__bubble::after {
370
+ content: '';
371
+ position: absolute;
372
+ bottom: -0.4rem;
373
+ left: 50%;
374
+ width: 0.7rem;
375
+ height: 0.7rem;
376
+ transform: translateX(-50%) rotate(45deg);
377
+ border-right: 1px solid var(--cratis-primary-color);
378
+ border-bottom: 1px solid var(--cratis-primary-color);
379
+ background: var(--cratis-surface-card);
380
+ }
381
+
382
+ @keyframes cue-callout-appear {
383
+ 0% {
384
+ opacity: 0;
385
+ transform: translate(-50%, calc(-100% + 0.5rem));
386
+ }
387
+
388
+ 100% {
389
+ opacity: 1;
390
+ transform: translate(-50%, -100%);
391
+ }
392
+ }
393
+
394
+ /* TourPointer */
395
+
396
+ /* The travel between the places the cursor stops is eased in the anchor's own per-frame writes rather than
397
+ by a CSS transition — a transition on `transform` would fight the anchor, which writes the same property
398
+ every frame. Only the press scale below animates through CSS. */
399
+ .cue-pointer {
400
+ pointer-events: none;
401
+ z-index: 30;
402
+ }
403
+
404
+ /* The press zooms the cursor down toward its own tip and springs back with a slight overshoot — both on
405
+ deliberate bezier curves so the click reads as a gesture, not a snap. The transform origin is the arrow's
406
+ tip, which is the exact point the anchor pins, so pressing never shifts what is being pressed. */
407
+ .cue-pointer__cursor {
408
+ position: relative;
409
+ width: 20px;
410
+ height: 24px;
411
+ transform-origin: 2px 2px;
412
+ transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
413
+ }
414
+
415
+ .cue-pointer__cursor--pressing {
416
+ transform: scale(0.78);
417
+ transition: transform 160ms cubic-bezier(0.16, 0.84, 0.3, 1);
418
+ }
419
+
420
+ /* The cursor drawing, offset so the SVG's arrow tip lands exactly on the anchored point. The white fill and
421
+ black outline are intentionally theme-independent — that is what makes a cursor readable on any background,
422
+ in either theme. */
423
+ .cue-pointer__arrow {
424
+ position: absolute;
425
+ top: -1px;
426
+ left: -1.5px;
427
+ display: block;
428
+ filter: drop-shadow(0 1px 2px rgb(0 0 0 / 45%));
429
+ }
430
+
431
+ .cue-pointer__arrow svg {
432
+ display: block;
433
+ }
434
+
435
+ /* The press ripple, centered on the arrow's tip — the point being clicked. */
436
+ .cue-pointer__ripple {
437
+ position: absolute;
438
+ top: -1.2rem;
439
+ left: -1.2rem;
440
+ width: 2.4rem;
441
+ height: 2.4rem;
442
+ border-radius: 50%;
443
+ background: var(--cratis-primary-color);
444
+ opacity: 0;
445
+ }
446
+
447
+ .cue-pointer__cursor--pressing .cue-pointer__ripple {
448
+ animation: cue-pointer-press 520ms ease-out;
449
+ }
450
+
451
+ @keyframes cue-pointer-press {
452
+ 0% {
453
+ opacity: 0.55;
454
+ transform: scale(0.35);
455
+ }
456
+
457
+ 100% {
458
+ opacity: 0;
459
+ transform: scale(1.4);
460
+ }
461
+ }
462
+
463
+ @media (prefers-reduced-motion: reduce) {
464
+ .cue-pointer__cursor {
465
+ transition: none;
466
+ }
467
+
468
+ .cue-pointer__cursor--pressing .cue-pointer__ripple {
469
+ animation: none;
470
+ }
471
+ }
472
+
473
+ /* CueStageBoundary */
474
+
475
+ .cue-stage-failed {
476
+ position: absolute;
477
+ top: 50%;
478
+ left: 50%;
479
+ display: flex;
480
+ flex-direction: column;
481
+ align-items: center;
482
+ gap: 0.75rem;
483
+ transform: translate(-50%, -50%);
484
+ color: var(--cratis-text-color);
485
+ }
package/tourClock.ts ADDED
@@ -0,0 +1,125 @@
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
+ import { MINIMUM_STEP_MS, type TourTimeline, stepIndexAtTime } from './tourTimeline.js';
5
+
6
+ /**
7
+ * The breath between a narration finishing and the clock moving on. Step lengths are estimated from word
8
+ * count, and when the voice finishes ahead of the estimate the remainder would be dead air — the clock
9
+ * skips it after this short beat rather than sitting the estimate out. The same beat separates a line that
10
+ * ran past its estimate from the line that follows it, so held steps release calmly instead of abruptly.
11
+ */
12
+ export const NARRATION_ADVANCE_BEAT_MS = 700;
13
+
14
+ /**
15
+ * How long the clock will wait at a step's end for its line to finish being said. Speech is synthesized and
16
+ * streamed, so a line regularly outlasts its word-count estimate — the clock holds the boundary rather than
17
+ * cutting the voice off mid-sentence. The limit only exists so a voice that never finishes — a stalled
18
+ * stream, a hung request — cannot stall the whole tour with it.
19
+ */
20
+ export const NARRATION_HOLD_LIMIT_MS = 15000;
21
+
22
+ /** What the voice is up to, as the clock needs to know it to pace itself. */
23
+ export interface TourClockNarration {
24
+ /** The step whose line has been handed to the voice and not yet finished, or null when none has. */
25
+ pendingStepIndex: number | null;
26
+
27
+ /** The step whose line finished being said and when it did, or null when none just has. */
28
+ finished: { stepIndex: number; finishedAt: number } | null;
29
+
30
+ /** When the clock started holding a boundary for the voice, or null when it is not holding one. */
31
+ holdStartedAt: number | null;
32
+ }
33
+
34
+ /** Where one tick of the tour's clock lands, and what it did to get there. */
35
+ export interface TourClockAdvance {
36
+ /** Where the clock is after the tick, in milliseconds. */
37
+ timeMs: number;
38
+
39
+ /** Whether playback continues — false once the clock has reached the end of the tour. */
40
+ isPlaying: boolean;
41
+
42
+ /** When the in-progress boundary hold started, carried to the next tick, or null when not holding. */
43
+ holdStartedAt: number | null;
44
+
45
+ /** Whether the finished-narration marker was consumed by this tick and should be cleared. */
46
+ finishedConsumed: boolean;
47
+ }
48
+
49
+ /**
50
+ * Advances the tour's clock by one tick, pacing it against the voice.
51
+ *
52
+ * The clock leads and the voice follows — with two adjustments at the boundary between them. When a line
53
+ * finishes ahead of its step's estimated length, the leftover is dead air: after a short beat the clock
54
+ * skips to the step's end instead of sitting the estimate out. When a line is still being said as its
55
+ * step's estimated length runs out, the clock holds just short of the boundary until the line finishes —
56
+ * crossing it would tear the voice down mid-sentence — released by the same beat, and bounded by
57
+ * {@link NARRATION_HOLD_LIMIT_MS} so a voice that never finishes cannot stall the tour.
58
+ * @param timeline The tour laid out on one clock.
59
+ * @param currentMs Where the clock is before the tick, in milliseconds.
60
+ * @param elapsedMs How much wall-clock time the tick spans, in milliseconds.
61
+ * @param now The wall clock at the moment of the tick, in milliseconds.
62
+ * @param narration What the voice is up to.
63
+ * @returns The {@link TourClockAdvance} the tick lands on.
64
+ */
65
+ export function advanceTourClock(
66
+ timeline: TourTimeline,
67
+ currentMs: number,
68
+ elapsedMs: number,
69
+ now: number,
70
+ narration: TourClockNarration): TourClockAdvance {
71
+ const next = currentMs + elapsedMs;
72
+
73
+ // Hold the boundary while the current step's line is still being said, or has finished but not yet had
74
+ // its breath — the clock parks just short of the step's end so the step stays current and the voice
75
+ // keeps its stage.
76
+ const currentIndex = stepIndexAtTime(timeline, currentMs);
77
+ const currentStep = currentIndex >= 0 ? timeline.steps[currentIndex] : undefined;
78
+ if (currentStep && next >= currentStep.endMs) {
79
+ const stillSpeaking = narration.pendingStepIndex === currentIndex;
80
+ const settling = narration.finished !== null
81
+ && narration.finished.stepIndex === currentIndex
82
+ && now - narration.finished.finishedAt < NARRATION_ADVANCE_BEAT_MS;
83
+ if (stillSpeaking || settling) {
84
+ const holdStartedAt = narration.holdStartedAt ?? now;
85
+ if (now - holdStartedAt < NARRATION_HOLD_LIMIT_MS) {
86
+ return {
87
+ timeMs: Math.max(currentMs, currentStep.endMs - 1),
88
+ isPlaying: true,
89
+ holdStartedAt,
90
+ finishedConsumed: false,
91
+ };
92
+ }
93
+ }
94
+ }
95
+
96
+ // The line has already been said — the rest of the step's estimated length is dead air. After the
97
+ // breath, skip straight to the boundary instead of sitting the estimate out. The minimum play time
98
+ // keeps the pointer's travel and press from being cut short by a line spoken faster than the
99
+ // choreography.
100
+ let finishedConsumed = false;
101
+ const index = stepIndexAtTime(timeline, next);
102
+ const timedStep = index >= 0 ? timeline.steps[index] : undefined;
103
+ const finished = narration.finished;
104
+ if (finished !== null) {
105
+ if (!timedStep || finished.stepIndex !== index) {
106
+ finishedConsumed = true;
107
+ } else {
108
+ const playedEnough = next >= timedStep.startMs + MINIMUM_STEP_MS;
109
+ const breathed = now - finished.finishedAt >= NARRATION_ADVANCE_BEAT_MS;
110
+ if (playedEnough && breathed && next < timedStep.endMs) {
111
+ if (timedStep.endMs >= timeline.durationMs) {
112
+ return { timeMs: timeline.durationMs, isPlaying: false, holdStartedAt: null, finishedConsumed: true };
113
+ }
114
+
115
+ return { timeMs: timedStep.endMs, isPlaying: true, holdStartedAt: null, finishedConsumed: true };
116
+ }
117
+ }
118
+ }
119
+
120
+ if (next < timeline.durationMs) {
121
+ return { timeMs: next, isPlaying: true, holdStartedAt: null, finishedConsumed };
122
+ }
123
+
124
+ return { timeMs: timeline.durationMs, isPlaying: false, holdStartedAt: null, finishedConsumed };
125
+ }
@@ -0,0 +1,95 @@
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
+ /** A point on the screen, relative to the board's own box. */
5
+ export interface ScreenPoint {
6
+ /** The horizontal offset in pixels. */
7
+ x: number;
8
+
9
+ /** The vertical offset in pixels. */
10
+ y: number;
11
+ }
12
+
13
+ /** The board's current pan and zoom, as the canvas reports it. */
14
+ export interface BoardTransform {
15
+ /** The zoom level, where 1 is actual size. */
16
+ zoom: number;
17
+
18
+ /** The pan offset in pixels. */
19
+ pan: ScreenPoint;
20
+ }
21
+
22
+ /**
23
+ * How much of the viewport the tour's own chrome covers on each side, in pixels. The camera compensates by
24
+ * this much so a framed subject centers in the *unobstructed* part of the viewport instead of behind the
25
+ * chapter list or the transport, and the editor showcase centers its panel on the same point. Must be kept in
26
+ * sync with the chrome's stylesheets: the right inset is the chapter list (1rem margin + 19rem wide), the
27
+ * left inset is the tour toolbar's column, and the bottom inset is the subtitles' box (bottom 5.5rem plus its
28
+ * height) over the transport bar.
29
+ */
30
+ export const CHROME_INSETS = { left: 72, right: 320, bottom: 136 } as const;
31
+
32
+ /**
33
+ * Projects a board coordinate to where it currently sits on screen.
34
+ * @param worldX The horizontal board coordinate.
35
+ * @param worldY The vertical board coordinate.
36
+ * @param transform The board's current pan and zoom.
37
+ * @returns The {@link ScreenPoint} relative to the board's box.
38
+ * @remarks
39
+ * This is the exact inverse of the screen-to-board mapping the canvas uses for collaborator presence, and it
40
+ * is what keeps the tour's pointer and callouts glued to the thing they are pointing at while the camera
41
+ * moves underneath them.
42
+ */
43
+ export function projectToScreen(worldX: number, worldY: number, transform: BoardTransform): ScreenPoint {
44
+ return {
45
+ x: transform.pan.x + worldX * transform.zoom,
46
+ y: transform.pan.y + worldY * transform.zoom,
47
+ };
48
+ }
49
+
50
+ /**
51
+ * The point the viewport's unobstructed part centers on — the middle of what the tour's chrome leaves open.
52
+ * @param viewportWidth The viewport's width in pixels.
53
+ * @param viewportHeight The viewport's height in pixels.
54
+ * @returns The {@link ScreenPoint} the camera aims subjects at and the editor showcase centers its panel on.
55
+ */
56
+ export function unobstructedCenter(viewportWidth: number, viewportHeight: number): ScreenPoint {
57
+ return {
58
+ x: viewportWidth / 2 - (CHROME_INSETS.right - CHROME_INSETS.left) / 2,
59
+ y: viewportHeight / 2 - CHROME_INSETS.bottom / 2,
60
+ };
61
+ }
62
+
63
+ /**
64
+ * Projects an editor-space point — an offset from the center of the editor showcase's panel — to the screen.
65
+ * @param x The horizontal offset from the panel's center.
66
+ * @param y The vertical offset from the panel's center.
67
+ * @param viewportWidth The viewport's width in pixels.
68
+ * @param viewportHeight The viewport's height in pixels.
69
+ * @returns The {@link ScreenPoint} relative to the board's box.
70
+ * @remarks
71
+ * The showcase pins its panel on the unobstructed center whatever the viewport size, so offsets from that
72
+ * center are the one coordinate system in which a spot inside the panel — a button, a field, a tab — has the
73
+ * same coordinates on every screen. Measured offsets therefore stay valid everywhere, exactly like the
74
+ * toolbar's fixed screen coordinates.
75
+ */
76
+ export function projectEditorPointToScreen(x: number, y: number, viewportWidth: number, viewportHeight: number): ScreenPoint {
77
+ const center = unobstructedCenter(viewportWidth, viewportHeight);
78
+ return { x: center.x + x, y: center.y + y };
79
+ }
80
+
81
+ /**
82
+ * Projects a toolbar-space point — a fixed offset from the left edge, and a vertical offset from the
83
+ * viewport's center — to the screen.
84
+ * @param x The horizontal offset from the board's left edge.
85
+ * @param y The vertical offset from the viewport's vertical center.
86
+ * @param viewportHeight The viewport's height in pixels.
87
+ * @returns The {@link ScreenPoint} relative to the board's box.
88
+ * @remarks
89
+ * The tour's toolbar centers itself vertically the way the editor's own toolbar does, so a spot on one of
90
+ * its buttons is a fixed distance from the vertical center on every viewport — this is the coordinate system
91
+ * in which those spots keep the same plain numbers everywhere.
92
+ */
93
+ export function projectToolbarPointToScreen(x: number, y: number, viewportHeight: number): ScreenPoint {
94
+ return { x, y: viewportHeight / 2 + y };
95
+ }