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

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,15 @@
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 type { CueSpeech } from './CueSpeech.js';
5
+
6
+ /** The voice a tour has when its application gives it none: there is no service, so nothing is said. */
7
+ export const silentSpeech: CueSpeech = {
8
+ isAvailable: false,
9
+ isPreparing: false,
10
+ isSpeaking: false,
11
+ hasError: false,
12
+ speak: () => Promise.resolve(),
13
+ prefetch: () => undefined,
14
+ stop: () => undefined
15
+ };
@@ -0,0 +1,66 @@
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 type { HttpSpeechOptions } from './HttpSpeechOptions.js';
5
+
6
+ const DEFAULT_CACHE_SIZE = 24;
7
+
8
+ /** The audio of the lines a tour speaks, asked for once each. */
9
+ export interface SpeechClips {
10
+ /** Gets the audio of a line, asking the service for it unless it already has it or is already asking. */
11
+ obtain(text: string): Promise<Blob>;
12
+
13
+ /** Starts asking for the audio of a line, without waiting for it. */
14
+ prefetch(text: string): void;
15
+ }
16
+
17
+ /**
18
+ * Creates the clips of a speech service.
19
+ * @param options Where the audio comes from.
20
+ * @returns The {@link SpeechClips}.
21
+ * @remarks
22
+ * A line that failed is forgotten, so asking for it again asks the service again. The oldest lines are dropped once the
23
+ * cache is full.
24
+ */
25
+ export function createSpeechClips(options: HttpSpeechOptions): SpeechClips {
26
+ const clips = new Map<string, Promise<Blob>>();
27
+ const limit = options.cacheSize ?? DEFAULT_CACHE_SIZE;
28
+
29
+ const request = async (text: string): Promise<Blob> => {
30
+ const send = options.fetch ?? fetch;
31
+ const response = await send(options.speakUrl, {
32
+ method: 'POST',
33
+ credentials: options.credentials ?? 'include',
34
+ headers: { 'Content-Type': 'application/json', ...options.headers },
35
+ body: JSON.stringify(options.body ? options.body(text) : { text })
36
+ });
37
+ if (!response.ok) {
38
+ throw new Error(`The speech service answered ${response.status}.`);
39
+ }
40
+ return response.blob();
41
+ };
42
+
43
+ const obtain = (text: string): Promise<Blob> => {
44
+ const known = clips.get(text);
45
+ if (known) {
46
+ return known;
47
+ }
48
+
49
+ const clip = request(text);
50
+ clips.set(text, clip);
51
+ clip.catch(() => {
52
+ if (clips.get(text) === clip) {
53
+ clips.delete(text);
54
+ }
55
+ });
56
+ while (clips.size > limit) {
57
+ clips.delete(clips.keys().next().value as string);
58
+ }
59
+ return clip;
60
+ };
61
+
62
+ return {
63
+ obtain,
64
+ prefetch: text => { obtain(text).catch(() => undefined); }
65
+ };
66
+ }
package/TourAnchor.tsx ADDED
@@ -0,0 +1,162 @@
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 React, { useEffect, useLayoutEffect, useRef } from 'react';
5
+ import { canvasTransformActivity, createSelfSuspendingFrameLoop, type SelfSuspendingFrameLoop } from '@cratis/components/Canvas';
6
+ import type { TourAnchorSpace } from './TourAnchorSpace.js';
7
+ import { type BoardTransform, type ScreenPoint, projectEditorPointToScreen, projectToScreen, projectToolbarPointToScreen } from './tourGeometry.js';
8
+
9
+ /**
10
+ * Where a target currently sits on screen, whatever space it is expressed in. Editor-space targets project
11
+ * against the live viewport size, so the anchor keeps sitting on its spot in the panel through a resize.
12
+ */
13
+ function projectTarget(target: { x: number; y: number; space: TourAnchorSpace }, transform: BoardTransform): ScreenPoint {
14
+ switch (target.space) {
15
+ case 'world': return projectToScreen(target.x, target.y, transform);
16
+ case 'editor': return projectEditorPointToScreen(target.x, target.y, window.innerWidth, window.innerHeight);
17
+ case 'toolbar': return projectToolbarPointToScreen(target.x, target.y, window.innerHeight);
18
+ case 'screen': return { x: target.x, y: target.y };
19
+ }
20
+ }
21
+
22
+ // How close, in screen pixels, a glide has to get before it counts as arrived and the loop suspends.
23
+ const GLIDE_SETTLE_DISTANCE = 0.5;
24
+
25
+ export interface TourAnchorProps {
26
+ /** The horizontal coordinate to sit at, in the anchor's space. */
27
+ x: number;
28
+
29
+ /** The vertical coordinate to sit at, in the anchor's space. */
30
+ y: number;
31
+
32
+ /** The space the coordinates are expressed in. Board coordinates when omitted. */
33
+ space?: TourAnchorSpace;
34
+
35
+ /** The board's live pan and zoom. */
36
+ transformRef: React.RefObject<BoardTransform>;
37
+
38
+ /**
39
+ * How long to take travelling to where the target currently is on screen. Left out, the anchor is simply
40
+ * placed there every frame — which is what a label wants, where gliding would only look like the label
41
+ * had come loose from the board.
42
+ */
43
+ glideMs?: number;
44
+
45
+ /** A class applied to the anchored element. */
46
+ className?: string;
47
+
48
+ /** What to draw at that place. */
49
+ children: React.ReactNode;
50
+ }
51
+
52
+ /**
53
+ * Holds its children at a place on the board — or on the tour's own chrome — and, when asked, takes its time
54
+ * getting to a new one.
55
+ *
56
+ * The travel is eased in screen space, against where the target currently sits on screen, rather than in
57
+ * board space. This is what keeps the pointer's movement its own: while the camera pans, a board-space glide
58
+ * would compose with the camera and sweep the pointer across the screen, whereas the screen-space easing lets
59
+ * it drift calmly after its target no matter what the camera is doing underneath.
60
+ *
61
+ * The position is written straight to the DOM on every animation frame rather than held in React state: the
62
+ * camera glides for the best part of a second on every step, and re-rendering the tour's overlay at frame
63
+ * rate for the whole of it would compete with the board's own per-frame transform writes.
64
+ */
65
+ export const TourAnchor = ({ x, y, space = 'world', transformRef, glideMs = 0, className, children }: TourAnchorProps) => {
66
+ const anchorRef = useRef<HTMLDivElement>(null);
67
+ const targetRef = useRef({ x, y, space });
68
+ const currentRef = useRef<{ x: number; y: number } | null>(null);
69
+ targetRef.current = { x, y, space };
70
+
71
+ // The follower below only places the element from the first animation frame on — without this, the
72
+ // element would be visible at the board's top-left corner for the frames before that, which is exactly
73
+ // where a freshly appeared callout was seen flashing. Place it where it belongs before the first paint.
74
+ useLayoutEffect(() => {
75
+ const anchor = anchorRef.current;
76
+ if (!anchor) return;
77
+
78
+ const target = targetRef.current;
79
+ const onScreen = projectTarget(target, transformRef.current);
80
+ currentRef.current = onScreen;
81
+ anchor.style.transform = `translate3d(${onScreen.x}px, ${onScreen.y}px, 0)`;
82
+ // Mount-only by design: every later placement belongs to the follower.
83
+ }, []);
84
+
85
+ // The follower runs as a self-suspending loop rather than a permanent per-frame one: it glides while there is travel left, then stops, and wakes again whenever
86
+ // the camera applies a transform frame, the window resizes (editor/toolbar spaces project against
87
+ // the viewport), or the target itself moves to a new spot.
88
+ const previousRef = useRef(performance.now());
89
+ const step = (now: number): boolean => {
90
+ const elapsed = now - previousRef.current;
91
+ previousRef.current = now;
92
+
93
+ const target = targetRef.current;
94
+ const onScreen = projectTarget(target, transformRef.current);
95
+
96
+ // Exponential easing toward the target's current screen position, so the travel is smooth at any
97
+ // frame rate and settles rather than arriving abruptly. The first placement is not traveled to —
98
+ // there is nowhere to have come from.
99
+ const current = currentRef.current;
100
+ let traveling = false;
101
+ if (current === null || glideMs <= 0) {
102
+ currentRef.current = onScreen;
103
+ } else {
104
+ const factor = 1 - Math.exp(-elapsed / (glideMs / 3));
105
+ const next = {
106
+ x: current.x + (onScreen.x - current.x) * factor,
107
+ y: current.y + (onScreen.y - current.y) * factor,
108
+ };
109
+ // Within a hair of the target the glide has visually arrived — rest exactly on it so the
110
+ // loop can suspend instead of easing asymptotically forever.
111
+ traveling = Math.abs(next.x - onScreen.x) >= GLIDE_SETTLE_DISTANCE || Math.abs(next.y - onScreen.y) >= GLIDE_SETTLE_DISTANCE;
112
+ currentRef.current = traveling ? next : onScreen;
113
+ }
114
+
115
+ const anchor = anchorRef.current;
116
+ if (anchor) {
117
+ anchor.style.transform = `translate3d(${currentRef.current.x}px, ${currentRef.current.y}px, 0)`;
118
+ }
119
+
120
+ return traveling;
121
+ };
122
+ const stepRef = useRef(step);
123
+ stepRef.current = step;
124
+
125
+ const loopRef = useRef<SelfSuspendingFrameLoop | null>(null);
126
+ loopRef.current ??= createSelfSuspendingFrameLoop(now => stepRef.current(now));
127
+ const loop = loopRef.current;
128
+
129
+ useEffect(() => {
130
+ const wake = () => {
131
+ // A suspended loop's elapsed time restarts at its wake — measured from the frame it last
132
+ // ran, the first glide step after a pause would leap most of the way in one jump.
133
+ if (!loop.isRunning) {
134
+ previousRef.current = performance.now();
135
+ }
136
+ loop.wake();
137
+ };
138
+
139
+ wake();
140
+ const unsubscribe = canvasTransformActivity.subscribe(wake);
141
+ window.addEventListener('resize', wake);
142
+ return () => {
143
+ unsubscribe();
144
+ window.removeEventListener('resize', wake);
145
+ loop.stop();
146
+ };
147
+ }, [loop]);
148
+
149
+ // A new target (or glide behavior) has to restart a suspended glide.
150
+ useEffect(() => {
151
+ if (!loop.isRunning) {
152
+ previousRef.current = performance.now();
153
+ }
154
+ loop.wake();
155
+ }, [loop, x, y, space, glideMs]);
156
+
157
+ return (
158
+ <div ref={anchorRef} className={className} style={{ position: 'absolute', top: 0, left: 0, willChange: 'transform' }}>
159
+ {children}
160
+ </div>
161
+ );
162
+ };
@@ -0,0 +1,15 @@
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
+ * Which coordinate space a tour anchor's point is expressed in.
6
+ *
7
+ * - `world` — board coordinates; the point stays glued to the board content as the camera moves.
8
+ * - `screen` — pixels from the top-left of the board's box; the point ignores the camera entirely.
9
+ * Used for the tour's own chrome, such as the toolbar, which is not part of the board.
10
+ * - `editor` — pixels from the center of the editor showcase's panel; the point sits on the same spot inside
11
+ * the panel on every viewport, because the panel itself is pinned on the unobstructed center.
12
+ * - `toolbar` — pixels from the board's left edge across, and from the viewport's vertical center down; the
13
+ * point sits on the same spot of the vertically-centered toolbar rail on every viewport.
14
+ */
15
+ export type TourAnchorSpace = 'world' | 'screen' | 'editor' | 'toolbar';
package/TourCallout.ts ADDED
@@ -0,0 +1,22 @@
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 type { TourAnchorSpace } from './TourAnchorSpace.js';
5
+
6
+ /**
7
+ * A short label the tour pins to a place on the board while a step plays, to name what the narration is
8
+ * talking about.
9
+ */
10
+ export interface TourCallout {
11
+ /** The horizontal coordinate to pin the callout to, in the callout's space. */
12
+ x: number;
13
+
14
+ /** The vertical coordinate to pin the callout to, in the callout's space. */
15
+ y: number;
16
+
17
+ /** The text to show. */
18
+ text: string;
19
+
20
+ /** The space the coordinates are expressed in. Board coordinates when omitted. */
21
+ space?: TourAnchorSpace;
22
+ }
@@ -0,0 +1,38 @@
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 React from 'react';
5
+ import type { BoardTransform } from './tourGeometry.js';
6
+ import type { TourCallout } from './TourCallout.js';
7
+ import { TourAnchor } from './TourAnchor.js';
8
+
9
+ export interface TourCalloutBubbleProps {
10
+ /** The callout to show, or undefined when the step has nothing to point out. */
11
+ callout: TourCallout | undefined;
12
+
13
+ /** The board's live pan and zoom. */
14
+ transformRef: React.RefObject<BoardTransform>;
15
+ }
16
+
17
+ /**
18
+ * Names the thing the narration is talking about, pinned just above it on the board with its caret pointing
19
+ * down at it. The script is responsible for anchoring callouts above their subjects — the bubble always
20
+ * renders upward from its anchor.
21
+ */
22
+ export const TourCalloutBubble = ({ callout, transformRef }: TourCalloutBubbleProps) => {
23
+ if (!callout) return null;
24
+
25
+ return (
26
+ <TourAnchor
27
+ // Keyed by its text so a new callout fades in as itself rather than the previous one's words
28
+ // being swapped out underneath a bubble that never moved.
29
+ key={callout.text}
30
+ x={callout.x}
31
+ y={callout.y}
32
+ space={callout.space}
33
+ transformRef={transformRef}
34
+ className='cue-callout'>
35
+ <div className='cue-callout__bubble'>{callout.text}</div>
36
+ </TourAnchor>
37
+ );
38
+ };
package/TourCamera.ts ADDED
@@ -0,0 +1,17 @@
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
+ * Where the tour points the camera for a step, in board (world) coordinates so it stays correct whatever the
6
+ * viewport size is.
7
+ */
8
+ export interface TourCamera {
9
+ /** The horizontal board coordinate to bring to the center of the viewport. */
10
+ x: number;
11
+
12
+ /** The vertical board coordinate to bring to the center of the viewport. */
13
+ y: number;
14
+
15
+ /** The zoom level to settle on, where 1 is actual size. */
16
+ zoom: number;
17
+ }
package/TourChapter.ts ADDED
@@ -0,0 +1,24 @@
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 type { TourStep } from './TourStep.js';
5
+
6
+ /**
7
+ * A named section of the tour, listed in the sidebar and jumpable from the timeline.
8
+ *
9
+ * Generic over the step type so a tour whose steps carry surface-specific extras keeps its script fully
10
+ * typed; the player itself only reads the {@link TourStep} base.
11
+ */
12
+ export interface TourChapter<TStep extends TourStep = TourStep> {
13
+ /** A stable identifier, used as the React key and for jumping to the chapter. */
14
+ id: string;
15
+
16
+ /** The title shown in the chapter list. */
17
+ title: string;
18
+
19
+ /** One line explaining what the chapter covers, shown under the title. */
20
+ summary: string;
21
+
22
+ /** The beats the chapter plays through, in order. */
23
+ steps: TStep[];
24
+ }
@@ -0,0 +1,65 @@
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 { useCueConfiguration } from './Configuration/CueProvider.js';
5
+ import type { TimedTourChapter, TimedTourSection } from './tourTimeline.js';
6
+ import { formatTourTime } from './tourTimeline.js';
7
+
8
+ export interface TourChapterListProps {
9
+ /** The sections, already placed on the tour's clock. */
10
+ sections: TimedTourSection[];
11
+
12
+ /** The chapters across all sections in play order, already placed on the tour's clock. */
13
+ chapters: TimedTourChapter[];
14
+
15
+ /** Which chapter is playing, as an index into {@link chapters}. */
16
+ currentChapterIndex: number;
17
+
18
+ /** Jumps to the start of a chapter, by its index into {@link chapters}. */
19
+ onSelectChapter: (chapterIndex: number) => void;
20
+
21
+ /**
22
+ * Whether to show where on the clock each chapter starts. On by default; self-paced reading switches it
23
+ * off, because there is no clock to time against when nobody is playing.
24
+ */
25
+ showTimings?: boolean;
26
+ }
27
+
28
+ /**
29
+ * The tour's table of contents: the sections as headings, their chapters under them, where the viewer is in
30
+ * it all, and a way to skip straight to any part of it. Chapter indices stay global across sections — the
31
+ * clock is flat, sections only group the listing.
32
+ */
33
+ export const TourChapterList = ({ sections, chapters, currentChapterIndex, onSelectChapter, showTimings = true }: TourChapterListProps) => {
34
+ const { labels } = useCueConfiguration();
35
+ return (
36
+ <aside className='cue-chapters'>
37
+ <h2 className='cue-chapters__heading'>{labels.chapters}</h2>
38
+ <div className='cue-chapters__sections'>
39
+ {sections.map((timedSection, sectionIndex) => (
40
+ <section key={timedSection.section.id}>
41
+ <h3 className='cue-chapters__section-title'>{timedSection.section.title}</h3>
42
+ <ol className='cue-chapters__list'>
43
+ {chapters.map((timed, chapterIndex) => ({ timed, chapterIndex }))
44
+ .filter(({ timed }) => timed.sectionIndex === sectionIndex)
45
+ .map(({ timed, chapterIndex }) => (
46
+ <li key={timed.chapter.id}>
47
+ <button
48
+ type='button'
49
+ className={`cue-chapters__item${chapterIndex === currentChapterIndex ? ' cue-chapters__item--current' : ''}`}
50
+ onClick={() => onSelectChapter(chapterIndex)}>
51
+ {showTimings && <span className='cue-chapters__time'>{formatTourTime(timed.startMs)}</span>}
52
+ <span className='cue-chapters__text'>
53
+ <span className='cue-chapters__title'>{timed.chapter.title}</span>
54
+ <span className='cue-chapters__summary'>{timed.chapter.summary}</span>
55
+ </span>
56
+ </button>
57
+ </li>
58
+ ))}
59
+ </ol>
60
+ </section>
61
+ ))}
62
+ </div>
63
+ </aside>
64
+ );
65
+ };
package/TourGesture.ts ADDED
@@ -0,0 +1,30 @@
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 type { TourAnchorSpace } from './TourAnchorSpace.js';
5
+
6
+ /**
7
+ * Where the tour's pointer goes for a step, and whether it presses when it gets there. Board (world)
8
+ * coordinates by default, so the pointer stays aimed at the thing it is pointing at while the camera moves;
9
+ * screen coordinates for the tour's own chrome, such as the toolbar.
10
+ */
11
+ export interface TourGesture {
12
+ /** The horizontal coordinate to move the pointer to, in the gesture's space. */
13
+ x: number;
14
+
15
+ /** The vertical coordinate to move the pointer to, in the gesture's space. */
16
+ y: number;
17
+
18
+ /** Whether the pointer presses once it arrives. */
19
+ clicks: boolean;
20
+
21
+ /**
22
+ * Where a drag ends, in the gesture's space. When set, the pointer travels to the gesture's point,
23
+ * presses and holds, glides to this point while held, and releases there — how the tour demonstrates
24
+ * dragging something, such as a connection from one module to another.
25
+ */
26
+ dragTo?: { x: number; y: number };
27
+
28
+ /** The space the coordinates are expressed in. Board coordinates when omitted. */
29
+ space?: TourAnchorSpace;
30
+ }
@@ -0,0 +1,102 @@
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 React, { useEffect, useState } from 'react';
5
+ import { useCueConfiguration } from './Configuration/CueProvider.js';
6
+ import type { TourSection } from './TourSection.js';
7
+ import type { TourStep } from './TourStep.js';
8
+ import { TourChapterList } from './TourChapterList.js';
9
+ import { TourSelfPacedPanel } from './TourSelfPacedPanel.js';
10
+ import { TourSubtitles } from './TourSubtitles.js';
11
+ import { TourTimelineBar } from './TourTimelineBar.js';
12
+ import { type TourSelfPacedContent, hasSelfPacedContent, selfPacedViewFor } from './tourSelfPaced.js';
13
+ import { type TourPlayback, useTourPlayback } from './useTourPlayback.js';
14
+
15
+ export interface TourOverlayShellProps<TStep extends TourStep = TourStep> {
16
+ /** The scripted sections the tour plays, in order. */
17
+ sections: TourSection<TStep>[];
18
+
19
+ /**
20
+ * The written walkthrough of each chapter, keyed by chapter id, for anyone who would rather read the
21
+ * tour at their own pace than listen to it. Omitted, the self-paced switch is not offered.
22
+ */
23
+ selfPacedContent?: TourSelfPacedContent;
24
+
25
+ /** Closes the tour and hands the surface back. */
26
+ onClose: () => void;
27
+
28
+ /**
29
+ * Renders the tour's stage — the surface the tour drives, such as a board rendered read-only — from the
30
+ * live playback. Called on every playback render; a stage that is expensive to build should read what it
31
+ * needs from the playback inside its own memoized component rather than rebuilding here.
32
+ */
33
+ children: (playback: TourPlayback<TStep>) => React.ReactNode;
34
+ }
35
+
36
+ /**
37
+ * The chrome every guided tour shares: the full-screen layer, the chapter list, the subtitles, the transport
38
+ * with its stop button, and the playback clock driving them all — parameterized by the tour's script and the
39
+ * stage it plays on. There is deliberately no header: a pill in the corner sat on top of whatever the tour
40
+ * was showing there, and everything it offered lives in the transport.
41
+ *
42
+ * The shell owns playback so a tour only brings its script and its stage. Escape stops the tour, exactly
43
+ * like the transport's stop button.
44
+ *
45
+ * A tour that also brings written chapters can be switched into self-paced reading from the transport: the
46
+ * clock and narration stop, the media controls dim, the chapter timings disappear, and the current chapter's
47
+ * walkthrough shows beside the chapter list — with the chapters themselves as the way to move around.
48
+ */
49
+ export const TourOverlayShell = <TStep extends TourStep = TourStep>({ sections, selfPacedContent, onClose, children }: TourOverlayShellProps<TStep>) => {
50
+ const playback = useTourPlayback(sections);
51
+ const { stageBoundary: StageBoundary } = useCueConfiguration();
52
+ const [isSelfPaced, setIsSelfPaced] = useState(false);
53
+ const currentChapter = playback.timeline.chapters[playback.chapterIndex]?.chapter;
54
+ const selfPaced = selfPacedViewFor(isSelfPaced, selfPacedContent, currentChapter?.id);
55
+
56
+ // Reading is silent: entering self-paced mode stops the clock, and the narration with it. Returning to
57
+ // narrated playback stays paused right where the reader is, until they press play themselves.
58
+ const handleToggleSelfPaced = () => {
59
+ if (!isSelfPaced) playback.pause();
60
+ setIsSelfPaced(!isSelfPaced);
61
+ };
62
+
63
+ useEffect(() => {
64
+ const closeOnEscape = (event: KeyboardEvent) => {
65
+ if (event.key === 'Escape') onClose();
66
+ };
67
+
68
+ window.addEventListener('keydown', closeOnEscape);
69
+ return () => window.removeEventListener('keydown', closeOnEscape);
70
+ }, [onClose]);
71
+
72
+ return (
73
+ <div className='cue-overlay'>
74
+ {/* The stage is guarded on its own: a tour that cannot draw its board reports it, and the transport and chapter
75
+ list stay up so the viewer can still stop it, pick another chapter or try again. */}
76
+ <StageBoundary>
77
+ {children(playback)}
78
+ </StageBoundary>
79
+
80
+ {selfPaced.isSelfPaced && currentChapter && (
81
+ <TourSelfPacedPanel title={currentChapter.title} markdown={selfPaced.markdown} />
82
+ )}
83
+
84
+ <TourChapterList
85
+ sections={playback.timeline.sections}
86
+ chapters={playback.timeline.chapters}
87
+ currentChapterIndex={playback.chapterIndex}
88
+ onSelectChapter={playback.goToChapter}
89
+ showTimings={selfPaced.areTimingsShown}
90
+ />
91
+
92
+ {!selfPaced.isSelfPaced && playback.areSubtitlesEnabled && <TourSubtitles narration={playback.step?.narration ?? ''} />}
93
+
94
+ <TourTimelineBar
95
+ playback={playback}
96
+ onStop={onClose}
97
+ isSelfPaced={selfPaced.isSelfPaced}
98
+ onToggleSelfPaced={hasSelfPacedContent(selfPacedContent) ? handleToggleSelfPaced : undefined}
99
+ />
100
+ </div>
101
+ );
102
+ };
@@ -0,0 +1,83 @@
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 React, { useEffect, useState } from 'react';
5
+ import type { BoardTransform } from './tourGeometry.js';
6
+ import type { TourGesture } from './TourGesture.js';
7
+ import { TourAnchor } from './TourAnchor.js';
8
+ import { cursorSvg } from './cursorSvg.js';
9
+
10
+ /** How long the press ripple lasts. Must match the animation duration in the stylesheet. */
11
+ const PRESS_MS = 520;
12
+
13
+ /** How long the cursor takes to travel to whatever the narration has moved on to. */
14
+ const TRAVEL_MS = 850;
15
+
16
+ /** The pause between pressing down and starting to drag, so the press registers as its own beat. */
17
+ const DRAG_GRIP_MS = 250;
18
+
19
+ /** How long the held glide of a drag lasts before the pointer releases at its destination. */
20
+ const DRAG_MS = 1100;
21
+
22
+ export interface TourPointerProps {
23
+ /** Where the pointer is going, or undefined before the tour has pointed at anything. */
24
+ gesture: TourGesture | undefined;
25
+
26
+ /** The board's live pan and zoom. */
27
+ transformRef: React.RefObject<BoardTransform>;
28
+ }
29
+
30
+ /**
31
+ * The tour's stand-in for a mouse: an operating-system-style arrow cursor — white with a black outline, so it
32
+ * reads on any background — that glides to whatever the narration is talking about and presses when the
33
+ * script says it does. The SVG's arrow tip sits exactly on the anchored point, and the press scales the
34
+ * cursor down toward that tip, so what is being pressed never shifts.
35
+ */
36
+ export const TourPointer = ({ gesture, transformRef }: TourPointerProps) => {
37
+ const [isPressing, setIsPressing] = useState(false);
38
+ const [dragPosition, setDragPosition] = useState<{ x: number; y: number } | null>(null);
39
+
40
+ useEffect(() => {
41
+ setDragPosition(null);
42
+
43
+ if (gesture?.dragTo) {
44
+ // A drag is press-and-hold: the cursor arrives, grips, glides to the destination while held,
45
+ // and releases there — the same rhythm a real hand would have.
46
+ const destination = gesture.dragTo;
47
+ setIsPressing(false);
48
+ const timers = [
49
+ setTimeout(() => setIsPressing(true), TRAVEL_MS),
50
+ setTimeout(() => setDragPosition(destination), TRAVEL_MS + DRAG_GRIP_MS),
51
+ setTimeout(() => setIsPressing(false), TRAVEL_MS + DRAG_GRIP_MS + DRAG_MS),
52
+ ];
53
+ return () => timers.forEach(clearTimeout);
54
+ }
55
+
56
+ if (!gesture?.clicks) return;
57
+
58
+ // The press lands once the cursor has arrived rather than the moment the step begins, so it reads as
59
+ // the pointer pressing the thing it traveled to. Restarting the class rather than leaving it on is
60
+ // what makes two presses in a row read as two presses instead of one long one.
61
+ setIsPressing(false);
62
+ const start = setTimeout(() => setIsPressing(true), TRAVEL_MS);
63
+ const end = setTimeout(() => setIsPressing(false), TRAVEL_MS + PRESS_MS);
64
+ return () => { clearTimeout(start); clearTimeout(end); };
65
+ }, [gesture]);
66
+
67
+ if (!gesture) return null;
68
+
69
+ return (
70
+ <TourAnchor
71
+ x={dragPosition?.x ?? gesture.x}
72
+ y={dragPosition?.y ?? gesture.y}
73
+ space={gesture.space}
74
+ transformRef={transformRef}
75
+ glideMs={TRAVEL_MS}
76
+ className='cue-pointer'>
77
+ <div className={`cue-pointer__cursor${isPressing ? ' cue-pointer__cursor--pressing' : ''}`}>
78
+ <span className='cue-pointer__ripple' />
79
+ <span className='cue-pointer__arrow' dangerouslySetInnerHTML={{ __html: cursorSvg }} />
80
+ </div>
81
+ </TourAnchor>
82
+ );
83
+ };