@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.
- package/.storybook/main.ts +11 -0
- package/.storybook/preview.tsx +21 -0
- package/Configuration/CueConfiguration.ts +27 -0
- package/Configuration/CueProvider.tsx +64 -0
- package/Configuration/CueStageBoundary.tsx +37 -0
- package/Configuration/index.ts +6 -0
- package/Icons.tsx +36 -0
- package/Labels/CueLabels.ts +39 -0
- package/Labels/defaultCueLabels.ts +23 -0
- package/Labels/index.ts +6 -0
- package/Labels/resolveLabels.ts +12 -0
- package/Markdown/CueMarkdown.tsx +31 -0
- package/Markdown/index.ts +5 -0
- package/Markdown/safeUrl.ts +29 -0
- package/README.md +54 -2
- package/Speech/CueSpeech.ts +27 -0
- package/Speech/CueSpeechConfiguration.ts +21 -0
- package/Speech/HttpSpeechOptions.ts +37 -0
- package/Speech/createHttpSpeech.ts +135 -0
- package/Speech/index.ts +7 -0
- package/Speech/silentSpeech.ts +15 -0
- package/Speech/speechClips.ts +66 -0
- package/TourAnchor.tsx +162 -0
- package/TourAnchorSpace.ts +15 -0
- package/TourCallout.ts +22 -0
- package/TourCalloutBubble.tsx +38 -0
- package/TourCamera.ts +17 -0
- package/TourChapter.ts +24 -0
- package/TourChapterList.tsx +65 -0
- package/TourGesture.ts +30 -0
- package/TourOverlayShell.tsx +102 -0
- package/TourPointer.tsx +83 -0
- package/TourSection.ts +24 -0
- package/TourSelfPacedPanel.tsx +26 -0
- package/TourStep.ts +40 -0
- package/TourSubtitles.tsx +22 -0
- package/TourTimelineBar.tsx +127 -0
- package/Tours/index.ts +5 -0
- package/Tours/useCueTours.ts +63 -0
- package/Tours/useTourNudge.ts +37 -0
- package/cursorSvg.ts +12 -0
- package/dist/cjs/Configuration/CueConfiguration.d.ts +11 -0
- package/dist/cjs/Configuration/CueConfiguration.d.ts.map +1 -0
- package/dist/cjs/Configuration/CueProvider.d.ts +19 -0
- package/dist/cjs/Configuration/CueProvider.d.ts.map +1 -0
- package/dist/cjs/Configuration/CueProvider.js +44 -0
- package/dist/cjs/Configuration/CueProvider.js.map +1 -0
- package/dist/cjs/Configuration/CueStageBoundary.d.ts +14 -0
- package/dist/cjs/Configuration/CueStageBoundary.d.ts.map +1 -0
- package/dist/cjs/Configuration/CueStageBoundary.js +45 -0
- package/dist/cjs/Configuration/CueStageBoundary.js.map +1 -0
- package/dist/cjs/Configuration/index.d.ts +4 -0
- package/dist/cjs/Configuration/index.d.ts.map +1 -0
- package/dist/cjs/Examples/AppShell.d.ts +5 -0
- package/dist/cjs/Examples/AppShell.d.ts.map +1 -0
- package/dist/cjs/Examples/LocalizedCue.d.ts +5 -0
- package/dist/cjs/Examples/LocalizedCue.d.ts.map +1 -0
- package/dist/cjs/Examples/OrderDeskTour.d.ts +2 -0
- package/dist/cjs/Examples/OrderDeskTour.d.ts.map +1 -0
- package/dist/cjs/Examples/OwnStageGuard.d.ts +5 -0
- package/dist/cjs/Examples/OwnStageGuard.d.ts.map +1 -0
- package/dist/cjs/Examples/OwnVoice.d.ts +3 -0
- package/dist/cjs/Examples/OwnVoice.d.ts.map +1 -0
- package/dist/cjs/Icons.d.ts +19 -0
- package/dist/cjs/Icons.d.ts.map +1 -0
- package/dist/cjs/Icons.js +33 -0
- package/dist/cjs/Icons.js.map +1 -0
- package/dist/cjs/Labels/CueLabels.d.ts +18 -0
- package/dist/cjs/Labels/CueLabels.d.ts.map +1 -0
- package/dist/cjs/Labels/defaultCueLabels.d.ts +3 -0
- package/dist/cjs/Labels/defaultCueLabels.d.ts.map +1 -0
- package/dist/cjs/Labels/defaultCueLabels.js +24 -0
- package/dist/cjs/Labels/defaultCueLabels.js.map +1 -0
- package/dist/cjs/Labels/index.d.ts +4 -0
- package/dist/cjs/Labels/index.d.ts.map +1 -0
- package/dist/cjs/Labels/resolveLabels.d.ts +3 -0
- package/dist/cjs/Labels/resolveLabels.d.ts.map +1 -0
- package/dist/cjs/Labels/resolveLabels.js +17 -0
- package/dist/cjs/Labels/resolveLabels.js.map +1 -0
- package/dist/cjs/Markdown/CueMarkdown.d.ts +6 -0
- package/dist/cjs/Markdown/CueMarkdown.d.ts.map +1 -0
- package/dist/cjs/Markdown/CueMarkdown.js +34 -0
- package/dist/cjs/Markdown/CueMarkdown.js.map +1 -0
- package/dist/cjs/Markdown/index.d.ts +3 -0
- package/dist/cjs/Markdown/index.d.ts.map +1 -0
- package/dist/cjs/Markdown/safeUrl.d.ts +2 -0
- package/dist/cjs/Markdown/safeUrl.d.ts.map +1 -0
- package/dist/cjs/Markdown/safeUrl.js +34 -0
- package/dist/cjs/Markdown/safeUrl.js.map +1 -0
- package/dist/cjs/Speech/CueSpeech.d.ts +10 -0
- package/dist/cjs/Speech/CueSpeech.d.ts.map +1 -0
- package/dist/cjs/Speech/CueSpeechConfiguration.d.ts +6 -0
- package/dist/cjs/Speech/CueSpeechConfiguration.d.ts.map +1 -0
- package/dist/cjs/Speech/HttpSpeechOptions.d.ts +10 -0
- package/dist/cjs/Speech/HttpSpeechOptions.d.ts.map +1 -0
- package/dist/cjs/Speech/createHttpSpeech.d.ts +4 -0
- package/dist/cjs/Speech/createHttpSpeech.d.ts.map +1 -0
- package/dist/cjs/Speech/createHttpSpeech.js +140 -0
- package/dist/cjs/Speech/createHttpSpeech.js.map +1 -0
- package/dist/cjs/Speech/index.d.ts +5 -0
- package/dist/cjs/Speech/index.d.ts.map +1 -0
- package/dist/cjs/Speech/silentSpeech.d.ts +3 -0
- package/dist/cjs/Speech/silentSpeech.d.ts.map +1 -0
- package/dist/cjs/Speech/silentSpeech.js +16 -0
- package/dist/cjs/Speech/silentSpeech.js.map +1 -0
- package/dist/cjs/Speech/speechClips.d.ts +7 -0
- package/dist/cjs/Speech/speechClips.d.ts.map +1 -0
- package/dist/cjs/Speech/speechClips.js +60 -0
- package/dist/cjs/Speech/speechClips.js.map +1 -0
- package/dist/cjs/TourAnchor.d.ts +14 -0
- package/dist/cjs/TourAnchor.d.ts.map +1 -0
- package/dist/cjs/TourAnchor.js +150 -0
- package/dist/cjs/TourAnchor.js.map +1 -0
- package/dist/cjs/TourAnchorSpace.d.ts +2 -0
- package/dist/cjs/TourAnchorSpace.d.ts.map +1 -0
- package/dist/cjs/TourCallout.d.ts +8 -0
- package/dist/cjs/TourCallout.d.ts.map +1 -0
- package/dist/cjs/TourCalloutBubble.d.ts +9 -0
- package/dist/cjs/TourCalloutBubble.d.ts.map +1 -0
- package/dist/cjs/TourCalloutBubble.js +27 -0
- package/dist/cjs/TourCalloutBubble.js.map +1 -0
- package/dist/cjs/TourCamera.d.ts +6 -0
- package/dist/cjs/TourCamera.d.ts.map +1 -0
- package/dist/cjs/TourChapter.d.ts +8 -0
- package/dist/cjs/TourChapter.d.ts.map +1 -0
- package/dist/cjs/TourChapterList.d.ts +10 -0
- package/dist/cjs/TourChapterList.d.ts.map +1 -0
- package/dist/cjs/TourChapterList.js +68 -0
- package/dist/cjs/TourChapterList.js.map +1 -0
- package/dist/cjs/TourChapterList.stories.d.ts +21 -0
- package/dist/cjs/TourChapterList.stories.d.ts.map +1 -0
- package/dist/cjs/TourGesture.d.ts +12 -0
- package/dist/cjs/TourGesture.d.ts.map +1 -0
- package/dist/cjs/TourOverlayShell.d.ts +13 -0
- package/dist/cjs/TourOverlayShell.d.ts.map +1 -0
- package/dist/cjs/TourOverlayShell.js +77 -0
- package/dist/cjs/TourOverlayShell.js.map +1 -0
- package/dist/cjs/TourPointer.d.ts +9 -0
- package/dist/cjs/TourPointer.d.ts.map +1 -0
- package/dist/cjs/TourPointer.js +74 -0
- package/dist/cjs/TourPointer.js.map +1 -0
- package/dist/cjs/TourSection.d.ts +8 -0
- package/dist/cjs/TourSection.d.ts.map +1 -0
- package/dist/cjs/TourSelfPacedPanel.d.ts +6 -0
- package/dist/cjs/TourSelfPacedPanel.d.ts.map +1 -0
- package/dist/cjs/TourSelfPacedPanel.js +27 -0
- package/dist/cjs/TourSelfPacedPanel.js.map +1 -0
- package/dist/cjs/TourSelfPacedPanel.stories.d.ts +21 -0
- package/dist/cjs/TourSelfPacedPanel.stories.d.ts.map +1 -0
- package/dist/cjs/TourStep.d.ts +12 -0
- package/dist/cjs/TourStep.d.ts.map +1 -0
- package/dist/cjs/TourSubtitles.d.ts +5 -0
- package/dist/cjs/TourSubtitles.d.ts.map +1 -0
- package/dist/cjs/TourSubtitles.js +24 -0
- package/dist/cjs/TourSubtitles.js.map +1 -0
- package/dist/cjs/TourTimelineBar.d.ts +10 -0
- package/dist/cjs/TourTimelineBar.d.ts.map +1 -0
- package/dist/cjs/TourTimelineBar.js +134 -0
- package/dist/cjs/TourTimelineBar.js.map +1 -0
- package/dist/cjs/TourTimelineBar.stories.d.ts +24 -0
- package/dist/cjs/TourTimelineBar.stories.d.ts.map +1 -0
- package/dist/cjs/Tours/index.d.ts +3 -0
- package/dist/cjs/Tours/index.d.ts.map +1 -0
- package/dist/cjs/Tours/useCueTours.d.ts +7 -0
- package/dist/cjs/Tours/useCueTours.d.ts.map +1 -0
- package/dist/cjs/Tours/useCueTours.js +46 -0
- package/dist/cjs/Tours/useCueTours.js.map +1 -0
- package/dist/cjs/Tours/useTourNudge.d.ts +6 -0
- package/dist/cjs/Tours/useTourNudge.d.ts.map +1 -0
- package/dist/cjs/Tours/useTourNudge.js +28 -0
- package/dist/cjs/Tours/useTourNudge.js.map +1 -0
- package/dist/cjs/cursorSvg.d.ts +2 -0
- package/dist/cjs/cursorSvg.d.ts.map +1 -0
- package/dist/cjs/cursorSvg.js +15 -0
- package/dist/cjs/cursorSvg.js.map +1 -0
- package/dist/cjs/index.d.ts +41 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +72 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/tourClock.d.ts +19 -0
- package/dist/cjs/tourClock.d.ts.map +1 -0
- package/dist/cjs/tourClock.js +107 -0
- package/dist/cjs/tourClock.js.map +1 -0
- package/dist/cjs/tourGeometry.d.ts +18 -0
- package/dist/cjs/tourGeometry.d.ts.map +1 -0
- package/dist/cjs/tourGeometry.js +86 -0
- package/dist/cjs/tourGeometry.js.map +1 -0
- package/dist/cjs/tourSelfPaced.d.ts +12 -0
- package/dist/cjs/tourSelfPaced.d.ts.map +1 -0
- package/dist/cjs/tourSelfPaced.js +69 -0
- package/dist/cjs/tourSelfPaced.js.map +1 -0
- package/dist/cjs/tourTimeline.d.ts +40 -0
- package/dist/cjs/tourTimeline.d.ts.map +1 -0
- package/dist/cjs/tourTimeline.js +168 -0
- package/dist/cjs/tourTimeline.js.map +1 -0
- package/dist/cjs/useTourPlayback.d.ts +25 -0
- package/dist/cjs/useTourPlayback.d.ts.map +1 -0
- package/dist/cjs/useTourPlayback.js +245 -0
- package/dist/cjs/useTourPlayback.js.map +1 -0
- package/dist/esm/Configuration/CueConfiguration.d.ts +11 -0
- package/dist/esm/Configuration/CueConfiguration.d.ts.map +1 -0
- package/dist/esm/Configuration/CueConfiguration.js +2 -0
- package/dist/esm/Configuration/CueConfiguration.js.map +1 -0
- package/dist/esm/Configuration/CueProvider.d.ts +19 -0
- package/dist/esm/Configuration/CueProvider.d.ts.map +1 -0
- package/dist/esm/Configuration/CueProvider.js +41 -0
- package/dist/esm/Configuration/CueProvider.js.map +1 -0
- package/dist/esm/Configuration/CueStageBoundary.d.ts +14 -0
- package/dist/esm/Configuration/CueStageBoundary.d.ts.map +1 -0
- package/dist/esm/Configuration/CueStageBoundary.js +43 -0
- package/dist/esm/Configuration/CueStageBoundary.js.map +1 -0
- package/dist/esm/Configuration/index.d.ts +4 -0
- package/dist/esm/Configuration/index.d.ts.map +1 -0
- package/dist/esm/Configuration/index.js +4 -0
- package/dist/esm/Configuration/index.js.map +1 -0
- package/dist/esm/Examples/AppShell.d.ts +5 -0
- package/dist/esm/Examples/AppShell.d.ts.map +1 -0
- package/dist/esm/Examples/AppShell.js +10 -0
- package/dist/esm/Examples/AppShell.js.map +1 -0
- package/dist/esm/Examples/LocalizedCue.d.ts +5 -0
- package/dist/esm/Examples/LocalizedCue.d.ts.map +1 -0
- package/dist/esm/Examples/LocalizedCue.js +11 -0
- package/dist/esm/Examples/LocalizedCue.js.map +1 -0
- package/dist/esm/Examples/OrderDeskTour.d.ts +2 -0
- package/dist/esm/Examples/OrderDeskTour.d.ts.map +1 -0
- package/dist/esm/Examples/OrderDeskTour.js +33 -0
- package/dist/esm/Examples/OrderDeskTour.js.map +1 -0
- package/dist/esm/Examples/OwnStageGuard.d.ts +5 -0
- package/dist/esm/Examples/OwnStageGuard.d.ts.map +1 -0
- package/dist/esm/Examples/OwnStageGuard.js +17 -0
- package/dist/esm/Examples/OwnStageGuard.js.map +1 -0
- package/dist/esm/Examples/OwnVoice.d.ts +3 -0
- package/dist/esm/Examples/OwnVoice.d.ts.map +1 -0
- package/dist/esm/Examples/OwnVoice.js +35 -0
- package/dist/esm/Examples/OwnVoice.js.map +1 -0
- package/dist/esm/Icons.d.ts +19 -0
- package/dist/esm/Icons.d.ts.map +1 -0
- package/dist/esm/Icons.js +31 -0
- package/dist/esm/Icons.js.map +1 -0
- package/dist/esm/Labels/CueLabels.d.ts +18 -0
- package/dist/esm/Labels/CueLabels.d.ts.map +1 -0
- package/dist/esm/Labels/CueLabels.js +2 -0
- package/dist/esm/Labels/CueLabels.js.map +1 -0
- package/dist/esm/Labels/defaultCueLabels.d.ts +3 -0
- package/dist/esm/Labels/defaultCueLabels.d.ts.map +1 -0
- package/dist/esm/Labels/defaultCueLabels.js +22 -0
- package/dist/esm/Labels/defaultCueLabels.js.map +1 -0
- package/dist/esm/Labels/index.d.ts +4 -0
- package/dist/esm/Labels/index.d.ts.map +1 -0
- package/dist/esm/Labels/index.js +4 -0
- package/dist/esm/Labels/index.js.map +1 -0
- package/dist/esm/Labels/resolveLabels.d.ts +3 -0
- package/dist/esm/Labels/resolveLabels.d.ts.map +1 -0
- package/dist/esm/Labels/resolveLabels.js +15 -0
- package/dist/esm/Labels/resolveLabels.js.map +1 -0
- package/dist/esm/Markdown/CueMarkdown.d.ts +6 -0
- package/dist/esm/Markdown/CueMarkdown.d.ts.map +1 -0
- package/dist/esm/Markdown/CueMarkdown.js +32 -0
- package/dist/esm/Markdown/CueMarkdown.js.map +1 -0
- package/dist/esm/Markdown/index.d.ts +3 -0
- package/dist/esm/Markdown/index.d.ts.map +1 -0
- package/dist/esm/Markdown/index.js +3 -0
- package/dist/esm/Markdown/index.js.map +1 -0
- package/dist/esm/Markdown/safeUrl.d.ts +2 -0
- package/dist/esm/Markdown/safeUrl.d.ts.map +1 -0
- package/dist/esm/Markdown/safeUrl.js +32 -0
- package/dist/esm/Markdown/safeUrl.js.map +1 -0
- package/dist/esm/Speech/CueSpeech.d.ts +10 -0
- package/dist/esm/Speech/CueSpeech.d.ts.map +1 -0
- package/dist/esm/Speech/CueSpeech.js +2 -0
- package/dist/esm/Speech/CueSpeech.js.map +1 -0
- package/dist/esm/Speech/CueSpeechConfiguration.d.ts +6 -0
- package/dist/esm/Speech/CueSpeechConfiguration.d.ts.map +1 -0
- package/dist/esm/Speech/CueSpeechConfiguration.js +2 -0
- package/dist/esm/Speech/CueSpeechConfiguration.js.map +1 -0
- package/dist/esm/Speech/HttpSpeechOptions.d.ts +10 -0
- package/dist/esm/Speech/HttpSpeechOptions.d.ts.map +1 -0
- package/dist/esm/Speech/HttpSpeechOptions.js +2 -0
- package/dist/esm/Speech/HttpSpeechOptions.js.map +1 -0
- package/dist/esm/Speech/createHttpSpeech.d.ts +4 -0
- package/dist/esm/Speech/createHttpSpeech.d.ts.map +1 -0
- package/dist/esm/Speech/createHttpSpeech.js +138 -0
- package/dist/esm/Speech/createHttpSpeech.js.map +1 -0
- package/dist/esm/Speech/index.d.ts +5 -0
- package/dist/esm/Speech/index.d.ts.map +1 -0
- package/dist/esm/Speech/index.js +5 -0
- package/dist/esm/Speech/index.js.map +1 -0
- package/dist/esm/Speech/silentSpeech.d.ts +3 -0
- package/dist/esm/Speech/silentSpeech.d.ts.map +1 -0
- package/dist/esm/Speech/silentSpeech.js +14 -0
- package/dist/esm/Speech/silentSpeech.js.map +1 -0
- package/dist/esm/Speech/speechClips.d.ts +7 -0
- package/dist/esm/Speech/speechClips.d.ts.map +1 -0
- package/dist/esm/Speech/speechClips.js +58 -0
- package/dist/esm/Speech/speechClips.js.map +1 -0
- package/dist/esm/TourAnchor.d.ts +14 -0
- package/dist/esm/TourAnchor.d.ts.map +1 -0
- package/dist/esm/TourAnchor.js +148 -0
- package/dist/esm/TourAnchor.js.map +1 -0
- package/dist/esm/TourAnchorSpace.d.ts +2 -0
- package/dist/esm/TourAnchorSpace.d.ts.map +1 -0
- package/dist/esm/TourAnchorSpace.js +2 -0
- package/dist/esm/TourAnchorSpace.js.map +1 -0
- package/dist/esm/TourCallout.d.ts +8 -0
- package/dist/esm/TourCallout.d.ts.map +1 -0
- package/dist/esm/TourCallout.js +2 -0
- package/dist/esm/TourCallout.js.map +1 -0
- package/dist/esm/TourCalloutBubble.d.ts +9 -0
- package/dist/esm/TourCalloutBubble.d.ts.map +1 -0
- package/dist/esm/TourCalloutBubble.js +25 -0
- package/dist/esm/TourCalloutBubble.js.map +1 -0
- package/dist/esm/TourCamera.d.ts +6 -0
- package/dist/esm/TourCamera.d.ts.map +1 -0
- package/dist/esm/TourCamera.js +2 -0
- package/dist/esm/TourCamera.js.map +1 -0
- package/dist/esm/TourChapter.d.ts +8 -0
- package/dist/esm/TourChapter.d.ts.map +1 -0
- package/dist/esm/TourChapter.js +2 -0
- package/dist/esm/TourChapter.js.map +1 -0
- package/dist/esm/TourChapterList.d.ts +10 -0
- package/dist/esm/TourChapterList.d.ts.map +1 -0
- package/dist/esm/TourChapterList.js +66 -0
- package/dist/esm/TourChapterList.js.map +1 -0
- package/dist/esm/TourChapterList.stories.d.ts +21 -0
- package/dist/esm/TourChapterList.stories.d.ts.map +1 -0
- package/dist/esm/TourChapterList.stories.js +53 -0
- package/dist/esm/TourChapterList.stories.js.map +1 -0
- package/dist/esm/TourGesture.d.ts +12 -0
- package/dist/esm/TourGesture.d.ts.map +1 -0
- package/dist/esm/TourGesture.js +2 -0
- package/dist/esm/TourGesture.js.map +1 -0
- package/dist/esm/TourOverlayShell.d.ts +13 -0
- package/dist/esm/TourOverlayShell.d.ts.map +1 -0
- package/dist/esm/TourOverlayShell.js +75 -0
- package/dist/esm/TourOverlayShell.js.map +1 -0
- package/dist/esm/TourPointer.d.ts +9 -0
- package/dist/esm/TourPointer.d.ts.map +1 -0
- package/dist/esm/TourPointer.js +72 -0
- package/dist/esm/TourPointer.js.map +1 -0
- package/dist/esm/TourSection.d.ts +8 -0
- package/dist/esm/TourSection.d.ts.map +1 -0
- package/dist/esm/TourSection.js +2 -0
- package/dist/esm/TourSection.js.map +1 -0
- package/dist/esm/TourSelfPacedPanel.d.ts +6 -0
- package/dist/esm/TourSelfPacedPanel.d.ts.map +1 -0
- package/dist/esm/TourSelfPacedPanel.js +25 -0
- package/dist/esm/TourSelfPacedPanel.js.map +1 -0
- package/dist/esm/TourSelfPacedPanel.stories.d.ts +21 -0
- package/dist/esm/TourSelfPacedPanel.stories.d.ts.map +1 -0
- package/dist/esm/TourSelfPacedPanel.stories.js +41 -0
- package/dist/esm/TourSelfPacedPanel.stories.js.map +1 -0
- package/dist/esm/TourStep.d.ts +12 -0
- package/dist/esm/TourStep.d.ts.map +1 -0
- package/dist/esm/TourStep.js +2 -0
- package/dist/esm/TourStep.js.map +1 -0
- package/dist/esm/TourSubtitles.d.ts +5 -0
- package/dist/esm/TourSubtitles.d.ts.map +1 -0
- package/dist/esm/TourSubtitles.js +22 -0
- package/dist/esm/TourSubtitles.js.map +1 -0
- package/dist/esm/TourTimelineBar.d.ts +10 -0
- package/dist/esm/TourTimelineBar.d.ts.map +1 -0
- package/dist/esm/TourTimelineBar.js +132 -0
- package/dist/esm/TourTimelineBar.js.map +1 -0
- package/dist/esm/TourTimelineBar.stories.d.ts +24 -0
- package/dist/esm/TourTimelineBar.stories.d.ts.map +1 -0
- package/dist/esm/TourTimelineBar.stories.js +62 -0
- package/dist/esm/TourTimelineBar.stories.js.map +1 -0
- package/dist/esm/Tours/index.d.ts +3 -0
- package/dist/esm/Tours/index.d.ts.map +1 -0
- package/dist/esm/Tours/index.js +3 -0
- package/dist/esm/Tours/index.js.map +1 -0
- package/dist/esm/Tours/useCueTours.d.ts +7 -0
- package/dist/esm/Tours/useCueTours.d.ts.map +1 -0
- package/dist/esm/Tours/useCueTours.js +44 -0
- package/dist/esm/Tours/useCueTours.js.map +1 -0
- package/dist/esm/Tours/useTourNudge.d.ts +6 -0
- package/dist/esm/Tours/useTourNudge.d.ts.map +1 -0
- package/dist/esm/Tours/useTourNudge.js +26 -0
- package/dist/esm/Tours/useTourNudge.js.map +1 -0
- package/dist/esm/cursorSvg.d.ts +2 -0
- package/dist/esm/cursorSvg.d.ts.map +1 -0
- package/dist/esm/cursorSvg.js +13 -0
- package/dist/esm/cursorSvg.js.map +1 -0
- package/dist/esm/index.d.ts +41 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +24 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/tourClock.d.ts +19 -0
- package/dist/esm/tourClock.d.ts.map +1 -0
- package/dist/esm/tourClock.js +103 -0
- package/dist/esm/tourClock.js.map +1 -0
- package/dist/esm/tourGeometry.d.ts +18 -0
- package/dist/esm/tourGeometry.d.ts.map +1 -0
- package/dist/esm/tourGeometry.js +80 -0
- package/dist/esm/tourGeometry.js.map +1 -0
- package/dist/esm/tourSelfPaced.d.ts +12 -0
- package/dist/esm/tourSelfPaced.d.ts.map +1 -0
- package/dist/esm/tourSelfPaced.js +64 -0
- package/dist/esm/tourSelfPaced.js.map +1 -0
- package/dist/esm/tourTimeline.d.ts +40 -0
- package/dist/esm/tourTimeline.d.ts.map +1 -0
- package/dist/esm/tourTimeline.js +154 -0
- package/dist/esm/tourTimeline.js.map +1 -0
- package/dist/esm/useTourPlayback.d.ts +25 -0
- package/dist/esm/useTourPlayback.d.ts.map +1 -0
- package/dist/esm/useTourPlayback.js +243 -0
- package/dist/esm/useTourPlayback.js.map +1 -0
- package/index.ts +68 -0
- package/package.json +93 -4
- package/styles.css +485 -0
- package/tourClock.ts +125 -0
- package/tourGeometry.ts +95 -0
- package/tourSelfPaced.ts +93 -0
- package/tourTimeline.ts +237 -0
- package/useTourPlayback.ts +291 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/** Words per minute the narration is assumed to be read at — a calm, unhurried voice-over pace. */ const NARRATION_WORDS_PER_MINUTE = 145;
|
|
6
|
+
/** The breath left at the end of a narrated step before the next one starts. */ const NARRATION_TAIL_MS = 900;
|
|
7
|
+
/** No step is ever shorter than this, however short its line is. */ const MINIMUM_STEP_MS = 2200;
|
|
8
|
+
/** How long a step with nothing to say lasts — a pure camera move. */ const SILENT_STEP_MS = 2500;
|
|
9
|
+
/** How far into a chapter "previous" restarts it rather than going back a chapter, as a video player does. */ const RESTART_CHAPTER_WINDOW_MS = 2000;
|
|
10
|
+
/**
|
|
11
|
+
* Estimates how long a line of narration takes to say.
|
|
12
|
+
* @param narration The line to be spoken.
|
|
13
|
+
* @returns The duration in milliseconds.
|
|
14
|
+
*/ function narrationDurationMs(narration) {
|
|
15
|
+
const words = narration.split(/\s+/u).filter((word)=>word.length > 0).length;
|
|
16
|
+
if (words === 0) return SILENT_STEP_MS;
|
|
17
|
+
const spoken = words / NARRATION_WORDS_PER_MINUTE * 60000;
|
|
18
|
+
return Math.max(MINIMUM_STEP_MS, Math.round(spoken + NARRATION_TAIL_MS));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Gets how long a step lasts, preferring the script's own figure when it states one.
|
|
22
|
+
* @param step The step to measure.
|
|
23
|
+
* @returns The duration in milliseconds.
|
|
24
|
+
*/ function stepDurationMs(step) {
|
|
25
|
+
return step.durationMs ?? narrationDurationMs(step.narration);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Lays the sections out on a single clock so every part of the player can work in one shared unit of time.
|
|
29
|
+
*
|
|
30
|
+
* The clock stays flat: steps and chapters run straight through every section, and a chapter's index is its
|
|
31
|
+
* position across the whole tour — sections only add headings and spans on top, they never fragment the clock.
|
|
32
|
+
* @param sections The scripted sections, in play order.
|
|
33
|
+
* @returns The {@link TourTimeline}.
|
|
34
|
+
*/ function buildTourTimeline(sections) {
|
|
35
|
+
const steps = [];
|
|
36
|
+
const timedChapters = [];
|
|
37
|
+
const timedSections = [];
|
|
38
|
+
let cursor = 0;
|
|
39
|
+
sections.forEach((section, sectionIndex)=>{
|
|
40
|
+
const sectionStart = cursor;
|
|
41
|
+
for (const chapter of section.chapters){
|
|
42
|
+
const chapterStart = cursor;
|
|
43
|
+
const chapterIndex = timedChapters.length;
|
|
44
|
+
for (const step of chapter.steps){
|
|
45
|
+
const endMs = cursor + stepDurationMs(step);
|
|
46
|
+
steps.push({
|
|
47
|
+
step,
|
|
48
|
+
chapterIndex,
|
|
49
|
+
startMs: cursor,
|
|
50
|
+
endMs
|
|
51
|
+
});
|
|
52
|
+
cursor = endMs;
|
|
53
|
+
}
|
|
54
|
+
timedChapters.push({
|
|
55
|
+
chapter,
|
|
56
|
+
sectionIndex,
|
|
57
|
+
startMs: chapterStart,
|
|
58
|
+
endMs: cursor
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
timedSections.push({
|
|
62
|
+
section,
|
|
63
|
+
startMs: sectionStart,
|
|
64
|
+
endMs: cursor
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
steps,
|
|
69
|
+
chapters: timedChapters,
|
|
70
|
+
sections: timedSections,
|
|
71
|
+
durationMs: cursor
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Gets which step is playing at a point on the clock.
|
|
76
|
+
* @param timeline The timeline to look in.
|
|
77
|
+
* @param timeMs The point on the clock, in milliseconds.
|
|
78
|
+
* @returns The index into {@link TourTimeline.steps}, or -1 when the timeline is empty.
|
|
79
|
+
*/ function stepIndexAtTime(timeline, timeMs) {
|
|
80
|
+
if (timeline.steps.length === 0) return -1;
|
|
81
|
+
// The end of the tour belongs to its last step rather than to nothing, so the final line stays on screen
|
|
82
|
+
// when playback finishes instead of the subtitles blanking on the last frame.
|
|
83
|
+
const found = timeline.steps.findIndex((candidate)=>timeMs >= candidate.startMs && timeMs < candidate.endMs);
|
|
84
|
+
if (found >= 0) return found;
|
|
85
|
+
return timeMs < 0 ? 0 : timeline.steps.length - 1;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Gets which chapter is playing at a point on the clock.
|
|
89
|
+
* @param timeline The timeline to look in.
|
|
90
|
+
* @param timeMs The point on the clock, in milliseconds.
|
|
91
|
+
* @returns The index into {@link TourTimeline.chapters}, or -1 when the timeline is empty.
|
|
92
|
+
*/ function chapterIndexAtTime(timeline, timeMs) {
|
|
93
|
+
const stepIndex = stepIndexAtTime(timeline, timeMs);
|
|
94
|
+
return stepIndex < 0 ? -1 : timeline.steps[stepIndex].chapterIndex;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Gets which section is playing at a point on the clock.
|
|
98
|
+
* @param timeline The timeline to look in.
|
|
99
|
+
* @param timeMs The point on the clock, in milliseconds.
|
|
100
|
+
* @returns The index into {@link TourTimeline.sections}, or -1 when the timeline is empty.
|
|
101
|
+
*/ function sectionIndexAtTime(timeline, timeMs) {
|
|
102
|
+
const chapterIndex = chapterIndexAtTime(timeline, timeMs);
|
|
103
|
+
return chapterIndex < 0 ? -1 : timeline.chapters[chapterIndex].sectionIndex;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Gets where on the clock a chapter begins.
|
|
107
|
+
* @param timeline The timeline to look in.
|
|
108
|
+
* @param chapterIndex The chapter to locate.
|
|
109
|
+
* @returns The point on the clock in milliseconds, or 0 when there is no such chapter.
|
|
110
|
+
*/ function chapterStartMs(timeline, chapterIndex) {
|
|
111
|
+
return timeline.chapters[chapterIndex]?.startMs ?? 0;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Gets where "previous chapter" should land from a point on the clock.
|
|
115
|
+
* @param timeline The timeline to look in.
|
|
116
|
+
* @param timeMs The current point on the clock, in milliseconds.
|
|
117
|
+
* @returns The point on the clock to jump to, in milliseconds.
|
|
118
|
+
*/ function previousChapterTargetMs(timeline, timeMs) {
|
|
119
|
+
const current = chapterIndexAtTime(timeline, timeMs);
|
|
120
|
+
if (current < 0) return 0;
|
|
121
|
+
// Well into a chapter, "previous" restarts the one being watched — the same thing a video player does,
|
|
122
|
+
// and what someone who missed the start of an explanation actually wants.
|
|
123
|
+
const startOfCurrent = chapterStartMs(timeline, current);
|
|
124
|
+
if (timeMs - startOfCurrent > RESTART_CHAPTER_WINDOW_MS) return startOfCurrent;
|
|
125
|
+
return chapterStartMs(timeline, Math.max(0, current - 1));
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Gets where "next chapter" should land from a point on the clock.
|
|
129
|
+
* @param timeline The timeline to look in.
|
|
130
|
+
* @param timeMs The current point on the clock, in milliseconds.
|
|
131
|
+
* @returns The point on the clock to jump to, in milliseconds.
|
|
132
|
+
*/ function nextChapterTargetMs(timeline, timeMs) {
|
|
133
|
+
const current = chapterIndexAtTime(timeline, timeMs);
|
|
134
|
+
if (current < 0) return 0;
|
|
135
|
+
if (current >= timeline.chapters.length - 1) return timeline.durationMs;
|
|
136
|
+
return chapterStartMs(timeline, current + 1);
|
|
137
|
+
}
|
|
138
|
+
// The lines still to come after a step that have something to say, in the order they will be needed — what the voice-over is
|
|
139
|
+
// asked for ahead of time so each starts the moment its step does.
|
|
140
|
+
function narrationsAfter(timeline, stepIndex, count) {
|
|
141
|
+
if (stepIndex < 0) return [];
|
|
142
|
+
return timeline.steps.slice(stepIndex + 1, stepIndex + 1 + count).map((timed)=>timed.step.narration).filter((narration)=>narration.length > 0);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Formats a point on the clock the way a video player does.
|
|
146
|
+
* @param timeMs The point on the clock, in milliseconds.
|
|
147
|
+
* @returns The time as `m:ss`.
|
|
148
|
+
*/ function formatTourTime(timeMs) {
|
|
149
|
+
const totalSeconds = Math.max(0, Math.floor(timeMs / 1000));
|
|
150
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
151
|
+
const seconds = totalSeconds % 60;
|
|
152
|
+
return `${minutes}:${seconds.toString().padStart(2, '0')}`;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
exports.MINIMUM_STEP_MS = MINIMUM_STEP_MS;
|
|
156
|
+
exports.RESTART_CHAPTER_WINDOW_MS = RESTART_CHAPTER_WINDOW_MS;
|
|
157
|
+
exports.buildTourTimeline = buildTourTimeline;
|
|
158
|
+
exports.chapterIndexAtTime = chapterIndexAtTime;
|
|
159
|
+
exports.chapterStartMs = chapterStartMs;
|
|
160
|
+
exports.formatTourTime = formatTourTime;
|
|
161
|
+
exports.narrationDurationMs = narrationDurationMs;
|
|
162
|
+
exports.narrationsAfter = narrationsAfter;
|
|
163
|
+
exports.nextChapterTargetMs = nextChapterTargetMs;
|
|
164
|
+
exports.previousChapterTargetMs = previousChapterTargetMs;
|
|
165
|
+
exports.sectionIndexAtTime = sectionIndexAtTime;
|
|
166
|
+
exports.stepDurationMs = stepDurationMs;
|
|
167
|
+
exports.stepIndexAtTime = stepIndexAtTime;
|
|
168
|
+
//# sourceMappingURL=tourTimeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tourTimeline.js","sources":["../../tourTimeline.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { TourChapter } from './TourChapter.js';\nimport type { TourSection } from './TourSection.js';\nimport type { TourStep } from './TourStep.js';\n\n/** Words per minute the narration is assumed to be read at — a calm, unhurried voice-over pace. */\nconst NARRATION_WORDS_PER_MINUTE = 145;\n\n/** The breath left at the end of a narrated step before the next one starts. */\nconst NARRATION_TAIL_MS = 900;\n\n/** No step is ever shorter than this, however short its line is. */\nexport const MINIMUM_STEP_MS = 2200;\n\n/** How long a step with nothing to say lasts — a pure camera move. */\nconst SILENT_STEP_MS = 2500;\n\n/** How far into a chapter \"previous\" restarts it rather than going back a chapter, as a video player does. */\nexport const RESTART_CHAPTER_WINDOW_MS = 2000;\n\n/** A step placed on the tour's clock. */\nexport interface TimedTourStep<TStep extends TourStep = TourStep> {\n /** The step itself. */\n step: TStep;\n\n /** The chapter the step belongs to. */\n chapterIndex: number;\n\n /** When the step starts, in milliseconds from the beginning of the tour. */\n startMs: number;\n\n /** When the step ends, in milliseconds from the beginning of the tour. */\n endMs: number;\n}\n\n/** A chapter placed on the tour's clock. */\nexport interface TimedTourChapter<TStep extends TourStep = TourStep> {\n /** The chapter itself. */\n chapter: TourChapter<TStep>;\n\n /** The section the chapter belongs to. */\n sectionIndex: number;\n\n /** When the chapter starts, in milliseconds from the beginning of the tour. */\n startMs: number;\n\n /** When the chapter ends, in milliseconds from the beginning of the tour. */\n endMs: number;\n}\n\n/** A section placed on the tour's clock. */\nexport interface TimedTourSection<TStep extends TourStep = TourStep> {\n /** The section itself. */\n section: TourSection<TStep>;\n\n /** When the section starts, in milliseconds from the beginning of the tour. */\n startMs: number;\n\n /** When the section ends, in milliseconds from the beginning of the tour. */\n endMs: number;\n}\n\n/** The whole tour laid out on one clock, which is what the progress bar, subtitles and chapter list read. */\nexport interface TourTimeline<TStep extends TourStep = TourStep> {\n /** Every step of every chapter of every section, in play order. */\n steps: TimedTourStep<TStep>[];\n\n /** Every chapter, in play order across all sections. Chapter indices used anywhere in the player index into this list. */\n chapters: TimedTourChapter<TStep>[];\n\n /** Every section, in play order. */\n sections: TimedTourSection<TStep>[];\n\n /** How long the whole tour lasts, in milliseconds. */\n durationMs: number;\n}\n\n/**\n * Estimates how long a line of narration takes to say.\n * @param narration The line to be spoken.\n * @returns The duration in milliseconds.\n */\nexport function narrationDurationMs(narration: string): number {\n const words = narration.split(/\\s+/u).filter(word => word.length > 0).length;\n if (words === 0) return SILENT_STEP_MS;\n\n const spoken = (words / NARRATION_WORDS_PER_MINUTE) * 60000;\n return Math.max(MINIMUM_STEP_MS, Math.round(spoken + NARRATION_TAIL_MS));\n}\n\n/**\n * Gets how long a step lasts, preferring the script's own figure when it states one.\n * @param step The step to measure.\n * @returns The duration in milliseconds.\n */\nexport function stepDurationMs(step: TourStep): number {\n return step.durationMs ?? narrationDurationMs(step.narration);\n}\n\n/**\n * Lays the sections out on a single clock so every part of the player can work in one shared unit of time.\n *\n * The clock stays flat: steps and chapters run straight through every section, and a chapter's index is its\n * position across the whole tour — sections only add headings and spans on top, they never fragment the clock.\n * @param sections The scripted sections, in play order.\n * @returns The {@link TourTimeline}.\n */\nexport function buildTourTimeline<TStep extends TourStep>(sections: TourSection<TStep>[]): TourTimeline<TStep> {\n const steps: TimedTourStep<TStep>[] = [];\n const timedChapters: TimedTourChapter<TStep>[] = [];\n const timedSections: TimedTourSection<TStep>[] = [];\n let cursor = 0;\n\n sections.forEach((section, sectionIndex) => {\n const sectionStart = cursor;\n for (const chapter of section.chapters) {\n const chapterStart = cursor;\n const chapterIndex = timedChapters.length;\n for (const step of chapter.steps) {\n const endMs = cursor + stepDurationMs(step);\n steps.push({ step, chapterIndex, startMs: cursor, endMs });\n cursor = endMs;\n }\n\n timedChapters.push({ chapter, sectionIndex, startMs: chapterStart, endMs: cursor });\n }\n\n timedSections.push({ section, startMs: sectionStart, endMs: cursor });\n });\n\n return { steps, chapters: timedChapters, sections: timedSections, durationMs: cursor };\n}\n\n/**\n * Gets which step is playing at a point on the clock.\n * @param timeline The timeline to look in.\n * @param timeMs The point on the clock, in milliseconds.\n * @returns The index into {@link TourTimeline.steps}, or -1 when the timeline is empty.\n */\nexport function stepIndexAtTime(timeline: TourTimeline, timeMs: number): number {\n if (timeline.steps.length === 0) return -1;\n\n // The end of the tour belongs to its last step rather than to nothing, so the final line stays on screen\n // when playback finishes instead of the subtitles blanking on the last frame.\n const found = timeline.steps.findIndex(candidate => timeMs >= candidate.startMs && timeMs < candidate.endMs);\n if (found >= 0) return found;\n\n return timeMs < 0 ? 0 : timeline.steps.length - 1;\n}\n\n/**\n * Gets which chapter is playing at a point on the clock.\n * @param timeline The timeline to look in.\n * @param timeMs The point on the clock, in milliseconds.\n * @returns The index into {@link TourTimeline.chapters}, or -1 when the timeline is empty.\n */\nexport function chapterIndexAtTime(timeline: TourTimeline, timeMs: number): number {\n const stepIndex = stepIndexAtTime(timeline, timeMs);\n return stepIndex < 0 ? -1 : timeline.steps[stepIndex].chapterIndex;\n}\n\n/**\n * Gets which section is playing at a point on the clock.\n * @param timeline The timeline to look in.\n * @param timeMs The point on the clock, in milliseconds.\n * @returns The index into {@link TourTimeline.sections}, or -1 when the timeline is empty.\n */\nexport function sectionIndexAtTime(timeline: TourTimeline, timeMs: number): number {\n const chapterIndex = chapterIndexAtTime(timeline, timeMs);\n return chapterIndex < 0 ? -1 : timeline.chapters[chapterIndex].sectionIndex;\n}\n\n/**\n * Gets where on the clock a chapter begins.\n * @param timeline The timeline to look in.\n * @param chapterIndex The chapter to locate.\n * @returns The point on the clock in milliseconds, or 0 when there is no such chapter.\n */\nexport function chapterStartMs(timeline: TourTimeline, chapterIndex: number): number {\n return timeline.chapters[chapterIndex]?.startMs ?? 0;\n}\n\n/**\n * Gets where \"previous chapter\" should land from a point on the clock.\n * @param timeline The timeline to look in.\n * @param timeMs The current point on the clock, in milliseconds.\n * @returns The point on the clock to jump to, in milliseconds.\n */\nexport function previousChapterTargetMs(timeline: TourTimeline, timeMs: number): number {\n const current = chapterIndexAtTime(timeline, timeMs);\n if (current < 0) return 0;\n\n // Well into a chapter, \"previous\" restarts the one being watched — the same thing a video player does,\n // and what someone who missed the start of an explanation actually wants.\n const startOfCurrent = chapterStartMs(timeline, current);\n if (timeMs - startOfCurrent > RESTART_CHAPTER_WINDOW_MS) return startOfCurrent;\n\n return chapterStartMs(timeline, Math.max(0, current - 1));\n}\n\n/**\n * Gets where \"next chapter\" should land from a point on the clock.\n * @param timeline The timeline to look in.\n * @param timeMs The current point on the clock, in milliseconds.\n * @returns The point on the clock to jump to, in milliseconds.\n */\nexport function nextChapterTargetMs(timeline: TourTimeline, timeMs: number): number {\n const current = chapterIndexAtTime(timeline, timeMs);\n if (current < 0) return 0;\n if (current >= timeline.chapters.length - 1) return timeline.durationMs;\n\n return chapterStartMs(timeline, current + 1);\n}\n\n// The lines still to come after a step that have something to say, in the order they will be needed — what the voice-over is\n// asked for ahead of time so each starts the moment its step does.\nexport function narrationsAfter(timeline: TourTimeline, stepIndex: number, count: number): string[] {\n if (stepIndex < 0) return [];\n return timeline.steps\n .slice(stepIndex + 1, stepIndex + 1 + count)\n .map(timed => timed.step.narration)\n .filter(narration => narration.length > 0);\n}\n\n/**\n * Formats a point on the clock the way a video player does.\n * @param timeMs The point on the clock, in milliseconds.\n * @returns The time as `m:ss`.\n */\nexport function formatTourTime(timeMs: number): string {\n const totalSeconds = Math.max(0, Math.floor(timeMs / 1000));\n const minutes = Math.floor(totalSeconds / 60);\n const seconds = totalSeconds % 60;\n return `${minutes}:${seconds.toString().padStart(2, '0')}`;\n}\n"],"names":["NARRATION_WORDS_PER_MINUTE","NARRATION_TAIL_MS","MINIMUM_STEP_MS","SILENT_STEP_MS","RESTART_CHAPTER_WINDOW_MS","narrationDurationMs","narration","words","split","filter","word","length","spoken","Math","max","round","stepDurationMs","step","durationMs","buildTourTimeline","sections","steps","timedChapters","timedSections","cursor","forEach","section","sectionIndex","sectionStart","chapter","chapters","chapterStart","chapterIndex","endMs","push","startMs","stepIndexAtTime","timeline","timeMs","found","findIndex","candidate","chapterIndexAtTime","stepIndex","sectionIndexAtTime","chapterStartMs","previousChapterTargetMs","current","startOfCurrent","nextChapterTargetMs","narrationsAfter","count","slice","map","timed","formatTourTime","totalSeconds","floor","minutes","seconds","toString","padStart"],"mappings":";;AAAA;AACA;AAMA,oGACA,MAAMA,0BAAAA,GAA6B,GAAA;AAEnC,iFACA,MAAMC,iBAAAA,GAAoB,GAAA;AAE1B,qEACO,MAAMC,eAAAA,GAAkB;AAE/B,uEACA,MAAMC,cAAAA,GAAiB,IAAA;AAEvB,+GACO,MAAMC,yBAAAA,GAA4B;AA2DzC;;;;IAKO,SAASC,mBAAAA,CAAoBC,SAAiB,EAAA;AACjD,IAAA,MAAMC,KAAAA,GAAQD,SAAAA,CAAUE,KAAK,CAAC,MAAA,CAAA,CAAQC,MAAM,CAACC,CAAAA,IAAAA,GAAQA,IAAAA,CAAKC,MAAM,GAAG,GAAGA,MAAM;IAC5E,IAAIJ,KAAAA,KAAU,GAAG,OAAOJ,cAAAA;IAExB,MAAMS,MAAAA,GAAS,KAACL,GAAQP,0BAAAA,GAA8B,KAAA;AACtD,IAAA,OAAOa,KAAKC,GAAG,CAACZ,iBAAiBW,IAAAA,CAAKE,KAAK,CAACH,MAAAA,GAASX,iBAAAA,CAAAA,CAAAA;AACzD;AAEA;;;;IAKO,SAASe,cAAAA,CAAeC,IAAc,EAAA;AACzC,IAAA,OAAOA,IAAAA,CAAKC,UAAU,IAAIb,mBAAAA,CAAoBY,KAAKX,SAAS,CAAA;AAChE;AAEA;;;;;;;IAQO,SAASa,iBAAAA,CAA0CC,QAA8B,EAAA;AACpF,IAAA,MAAMC,QAAgC,EAAE;AACxC,IAAA,MAAMC,gBAA2C,EAAE;AACnD,IAAA,MAAMC,gBAA2C,EAAE;AACnD,IAAA,IAAIC,MAAAA,GAAS,CAAA;IAEbJ,QAAAA,CAASK,OAAO,CAAC,CAACC,OAAAA,EAASC,YAAAA,GAAAA;AACvB,QAAA,MAAMC,YAAAA,GAAeJ,MAAAA;AACrB,QAAA,KAAK,MAAMK,OAAAA,IAAWH,OAAAA,CAAQI,QAAQ,CAAE;AACpC,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import type { TourStep } from './TourStep.js';
|
|
3
|
+
import { type TourTimeline } from './tourTimeline.js';
|
|
4
|
+
export interface TourPlayback<TStep extends TourStep = TourStep> {
|
|
5
|
+
timeline: TourTimeline<TStep>;
|
|
6
|
+
timeMs: number;
|
|
7
|
+
isPlaying: boolean;
|
|
8
|
+
isAudioEnabled: boolean;
|
|
9
|
+
areSubtitlesEnabled: boolean;
|
|
10
|
+
isSpeechAvailable: boolean;
|
|
11
|
+
hasNarrationFailed: boolean;
|
|
12
|
+
step: TStep | undefined;
|
|
13
|
+
chapterIndex: number;
|
|
14
|
+
sectionIndex: number;
|
|
15
|
+
togglePlay(): void;
|
|
16
|
+
pause(): void;
|
|
17
|
+
seekTo(timeMs: number): void;
|
|
18
|
+
goToChapter(chapterIndex: number): void;
|
|
19
|
+
goToPreviousChapter(): void;
|
|
20
|
+
goToNextChapter(): void;
|
|
21
|
+
toggleAudio(): void;
|
|
22
|
+
toggleSubtitles(): void;
|
|
23
|
+
}
|
|
24
|
+
export declare function useTourPlayback<TStep extends TourStep>(sections: TourSection<TStep>[]): TourPlayback<TStep>;
|
|
25
|
+
//# sourceMappingURL=useTourPlayback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTourPlayback.d.ts","sourceRoot":"","sources":["../../useTourPlayback.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EACH,KAAK,YAAY,EASpB,MAAM,mBAAmB,CAAC;AAS3B,MAAM,WAAW,YAAY,CAAC,KAAK,SAAS,QAAQ,GAAG,QAAQ;IAE3D,QAAQ,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IAG9B,MAAM,EAAE,MAAM,CAAC;IAGf,SAAS,EAAE,OAAO,CAAC;IAGnB,cAAc,EAAE,OAAO,CAAC;IAGxB,mBAAmB,EAAE,OAAO,CAAC;IAG7B,iBAAiB,EAAE,OAAO,CAAC;IAG3B,kBAAkB,EAAE,OAAO,CAAC;IAG5B,IAAI,EAAE,KAAK,GAAG,SAAS,CAAC;IAGxB,YAAY,EAAE,MAAM,CAAC;IAGrB,YAAY,EAAE,MAAM,CAAC;IAGrB,UAAU,IAAI,IAAI,CAAC;IAGnB,KAAK,IAAI,IAAI,CAAC;IAGd,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAG7B,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAGxC,mBAAmB,IAAI,IAAI,CAAC;IAG5B,eAAe,IAAI,IAAI,CAAC;IAGxB,WAAW,IAAI,IAAI,CAAC;IAGpB,eAAe,IAAI,IAAI,CAAC;CAC3B;AAgBD,wBAAgB,eAAe,CAAC,KAAK,SAAS,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,CAiM3G"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var CueProvider = require('./Configuration/CueProvider.js');
|
|
5
|
+
var tourClock = require('./tourClock.js');
|
|
6
|
+
var tourTimeline = require('./tourTimeline.js');
|
|
7
|
+
|
|
8
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
9
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
10
|
+
// How many steps ahead of the one being said the voice-over is requested, so each line starts the moment its step does.
|
|
11
|
+
const NARRATION_LOOKAHEAD_STEPS = 2;
|
|
12
|
+
/** How often the clock advances. Fine enough for a progress bar, coarse enough not to re-render at frame rate. */ const TICK_MS = 100;
|
|
13
|
+
/**
|
|
14
|
+
* Runs the guided tour: advances one clock, and keeps the voice-over pointed at whatever the clock says is
|
|
15
|
+
* being narrated.
|
|
16
|
+
* @param sections The scripted sections to play.
|
|
17
|
+
* @returns The {@link TourPlayback} controls and state.
|
|
18
|
+
* @remarks
|
|
19
|
+
* The clock is the single source of truth — subtitles, progress, chapter highlighting and how much of the
|
|
20
|
+
* tour's stage is showing are all read from it, so seeking anywhere is consistent by construction. Pacing
|
|
21
|
+
* follows the schedule, with two adjustments at the boundaries where the schedule and the voice disagree
|
|
22
|
+
* (see {@link advanceTourClock}): a line finishing ahead of its step's estimate skips the leftover dead air,
|
|
23
|
+
* and a line still being said as the estimate runs out holds the clock at the step's end until it finishes —
|
|
24
|
+
* bounded, so a voice that never finishes cannot stall the whole tour. Whatever is playing is always
|
|
25
|
+
* silenced the moment the step it belongs to is left, whichever direction that happens in.
|
|
26
|
+
*/ function useTourPlayback(sections) {
|
|
27
|
+
const timeline = react.useMemo(()=>tourTimeline.buildTourTimeline(sections), [
|
|
28
|
+
sections
|
|
29
|
+
]);
|
|
30
|
+
const [timeMs, setTimeState] = react.useState(0);
|
|
31
|
+
// The clock's position, readable by the ticker without going through a state updater: an updater must not have
|
|
32
|
+
// side effects, and the tick has one - it ends playback when the tour reaches its end.
|
|
33
|
+
const timeMsRef = react.useRef(0);
|
|
34
|
+
const setTimeMs = react.useCallback((next)=>{
|
|
35
|
+
timeMsRef.current = typeof next === 'function' ? next(timeMsRef.current) : next;
|
|
36
|
+
setTimeState(timeMsRef.current);
|
|
37
|
+
}, []);
|
|
38
|
+
const [isPlaying, setIsPlaying] = react.useState(true);
|
|
39
|
+
const [isAudioEnabled, setIsAudioEnabled] = react.useState(true);
|
|
40
|
+
const [areSubtitlesEnabled, setAreSubtitlesEnabled] = react.useState(true);
|
|
41
|
+
const [hasNarrationFailed, setHasNarrationFailed] = react.useState(false);
|
|
42
|
+
const { useSpeech } = CueProvider.useCueConfiguration();
|
|
43
|
+
const { isAvailable: isSpeechAvailable, isPreparing, isSpeaking, hasError: hasSpeechError, speak, prefetch, stop } = useSpeech();
|
|
44
|
+
const stepIndex = tourTimeline.stepIndexAtTime(timeline, timeMs);
|
|
45
|
+
const step = stepIndex >= 0 ? timeline.steps[stepIndex].step : undefined;
|
|
46
|
+
const chapterIndex = tourTimeline.chapterIndexAtTime(timeline, timeMs);
|
|
47
|
+
const sectionIndex = tourTimeline.sectionIndexAtTime(timeline, timeMs);
|
|
48
|
+
// Which step the voice has already been given. Reset to nothing whenever playback jumps or is silenced,
|
|
49
|
+
// so resuming or seeking back always speaks the line again rather than sitting through it in silence.
|
|
50
|
+
const narratedStepRef = react.useRef(-1);
|
|
51
|
+
// The narration currently being watched for completion: set when a line is handed to the voice, marked
|
|
52
|
+
// started once audio is actually being prepared or spoken, and cleared once it is known to have ended.
|
|
53
|
+
// Refs rather than state — nothing here needs to trigger its own render.
|
|
54
|
+
const pendingNarrationRef = react.useRef(null);
|
|
55
|
+
const narrationFinishedRef = react.useRef(null);
|
|
56
|
+
const narrationHoldRef = react.useRef(null);
|
|
57
|
+
react.useEffect(()=>{
|
|
58
|
+
if (!isPlaying) return;
|
|
59
|
+
let previous = performance.now();
|
|
60
|
+
const ticker = setInterval(()=>{
|
|
61
|
+
const now = performance.now();
|
|
62
|
+
const elapsed = now - previous;
|
|
63
|
+
previous = now;
|
|
64
|
+
const advance = tourClock.advanceTourClock(timeline, timeMsRef.current, elapsed, now, {
|
|
65
|
+
pendingStepIndex: pendingNarrationRef.current?.stepIndex ?? null,
|
|
66
|
+
finished: narrationFinishedRef.current,
|
|
67
|
+
holdStartedAt: narrationHoldRef.current
|
|
68
|
+
});
|
|
69
|
+
narrationHoldRef.current = advance.holdStartedAt;
|
|
70
|
+
if (advance.finishedConsumed) {
|
|
71
|
+
narrationFinishedRef.current = null;
|
|
72
|
+
}
|
|
73
|
+
setTimeMs(advance.timeMs);
|
|
74
|
+
if (!advance.isPlaying) {
|
|
75
|
+
setIsPlaying(false);
|
|
76
|
+
}
|
|
77
|
+
}, TICK_MS);
|
|
78
|
+
return ()=>clearInterval(ticker);
|
|
79
|
+
}, [
|
|
80
|
+
isPlaying,
|
|
81
|
+
timeline,
|
|
82
|
+
setTimeMs
|
|
83
|
+
]);
|
|
84
|
+
react.useEffect(()=>{
|
|
85
|
+
if (!isPlaying || !isAudioEnabled || !isSpeechAvailable) {
|
|
86
|
+
narratedStepRef.current = -1;
|
|
87
|
+
pendingNarrationRef.current = null;
|
|
88
|
+
narrationFinishedRef.current = null;
|
|
89
|
+
narrationHoldRef.current = null;
|
|
90
|
+
stop();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (narratedStepRef.current === stepIndex) return;
|
|
94
|
+
narratedStepRef.current = stepIndex;
|
|
95
|
+
narrationFinishedRef.current = null;
|
|
96
|
+
const narration = stepIndex >= 0 ? timeline.steps[stepIndex].step.narration : '';
|
|
97
|
+
if (narration.length > 0) {
|
|
98
|
+
pendingNarrationRef.current = {
|
|
99
|
+
stepIndex,
|
|
100
|
+
started: false
|
|
101
|
+
};
|
|
102
|
+
// speak() tears down whatever the voice was still saying for the step just left, before
|
|
103
|
+
// starting this step's line — leaving a step always silences it, never lets it bleed forward.
|
|
104
|
+
void speak(narration);
|
|
105
|
+
} else {
|
|
106
|
+
// A silent, camera-only step — nothing to say, but anything still playing from the step before
|
|
107
|
+
// it must be cut off rather than left to talk over a scene it no longer belongs to.
|
|
108
|
+
pendingNarrationRef.current = null;
|
|
109
|
+
stop();
|
|
110
|
+
}
|
|
111
|
+
}, [
|
|
112
|
+
isPlaying,
|
|
113
|
+
isAudioEnabled,
|
|
114
|
+
isSpeechAvailable,
|
|
115
|
+
stepIndex,
|
|
116
|
+
timeline,
|
|
117
|
+
speak,
|
|
118
|
+
stop
|
|
119
|
+
]);
|
|
120
|
+
// Asks the voice for the lines still to come while the current one is being said, so each starts the moment its
|
|
121
|
+
// step does instead of waiting for the speech service. The current line goes first: nothing is requested until it
|
|
122
|
+
// is audible, so the lookahead never competes with the line the viewer is waiting for.
|
|
123
|
+
react.useEffect(()=>{
|
|
124
|
+
if (!isPlaying || !isAudioEnabled || !isSpeechAvailable || stepIndex < 0) return;
|
|
125
|
+
// The line being waited for has been handed to the voice but is not audible yet: ask for nothing else.
|
|
126
|
+
const pending = pendingNarrationRef.current;
|
|
127
|
+
if (pending && (!pending.started || isPreparing)) return;
|
|
128
|
+
for (const narration of tourTimeline.narrationsAfter(timeline, stepIndex, NARRATION_LOOKAHEAD_STEPS))prefetch(narration);
|
|
129
|
+
}, [
|
|
130
|
+
isPlaying,
|
|
131
|
+
isAudioEnabled,
|
|
132
|
+
isSpeechAvailable,
|
|
133
|
+
isPreparing,
|
|
134
|
+
stepIndex,
|
|
135
|
+
timeline,
|
|
136
|
+
prefetch
|
|
137
|
+
]);
|
|
138
|
+
// Watches the voice to notice when the pending line has finished. "Finished" is a transition — the line
|
|
139
|
+
// must have been heard preparing or speaking before silence counts as its end, otherwise the quiet moment
|
|
140
|
+
// between asking for a clip and the first audio arriving would be mistaken for completion.
|
|
141
|
+
react.useEffect(()=>{
|
|
142
|
+
const pending = pendingNarrationRef.current;
|
|
143
|
+
if (!pending) return;
|
|
144
|
+
if (isPreparing || isSpeaking) {
|
|
145
|
+
pending.started = true;
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (pending.started) {
|
|
149
|
+
pendingNarrationRef.current = null;
|
|
150
|
+
narrationFinishedRef.current = {
|
|
151
|
+
stepIndex: pending.stepIndex,
|
|
152
|
+
finishedAt: performance.now()
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}, [
|
|
156
|
+
isPreparing,
|
|
157
|
+
isSpeaking
|
|
158
|
+
]);
|
|
159
|
+
// A failing voice-over must not make the tour silently silent: switch the audio toggle off so the
|
|
160
|
+
// transport shows what happened, and make sure subtitles are on so the words still reach the viewer.
|
|
161
|
+
// The clock keeps running throughout — narration failing never stalls the tour.
|
|
162
|
+
react.useEffect(()=>{
|
|
163
|
+
if (!hasSpeechError || !isAudioEnabled) return;
|
|
164
|
+
setHasNarrationFailed(true);
|
|
165
|
+
setIsAudioEnabled(false);
|
|
166
|
+
setAreSubtitlesEnabled(true);
|
|
167
|
+
}, [
|
|
168
|
+
hasSpeechError,
|
|
169
|
+
isAudioEnabled
|
|
170
|
+
]);
|
|
171
|
+
const seekTo = react.useCallback((target)=>{
|
|
172
|
+
narratedStepRef.current = -1;
|
|
173
|
+
pendingNarrationRef.current = null;
|
|
174
|
+
narrationFinishedRef.current = null;
|
|
175
|
+
narrationHoldRef.current = null;
|
|
176
|
+
setTimeMs(Math.min(Math.max(0, target), timeline.durationMs));
|
|
177
|
+
}, [
|
|
178
|
+
timeline.durationMs,
|
|
179
|
+
setTimeMs
|
|
180
|
+
]);
|
|
181
|
+
const isPlayingRef = react.useRef(isPlaying);
|
|
182
|
+
isPlayingRef.current = isPlaying;
|
|
183
|
+
const togglePlay = react.useCallback(()=>{
|
|
184
|
+
// Pressing play at the very end starts over rather than doing nothing, which is what a finished
|
|
185
|
+
// video does and what someone reaching for the button after it ends is asking for.
|
|
186
|
+
if (!isPlayingRef.current) {
|
|
187
|
+
if (timeMsRef.current >= timeline.durationMs) setTimeMs(0);
|
|
188
|
+
narratedStepRef.current = -1;
|
|
189
|
+
}
|
|
190
|
+
setIsPlaying(!isPlayingRef.current);
|
|
191
|
+
}, [
|
|
192
|
+
timeline.durationMs,
|
|
193
|
+
setTimeMs
|
|
194
|
+
]);
|
|
195
|
+
const pause = react.useCallback(()=>setIsPlaying(false), []);
|
|
196
|
+
const goToChapter = react.useCallback((target)=>seekTo(tourTimeline.chapterStartMs(timeline, target)), [
|
|
197
|
+
seekTo,
|
|
198
|
+
timeline
|
|
199
|
+
]);
|
|
200
|
+
const goToPreviousChapter = react.useCallback(()=>seekTo(tourTimeline.previousChapterTargetMs(timeline, timeMs)), [
|
|
201
|
+
seekTo,
|
|
202
|
+
timeline,
|
|
203
|
+
timeMs
|
|
204
|
+
]);
|
|
205
|
+
const goToNextChapter = react.useCallback(()=>seekTo(tourTimeline.nextChapterTargetMs(timeline, timeMs)), [
|
|
206
|
+
seekTo,
|
|
207
|
+
timeline,
|
|
208
|
+
timeMs
|
|
209
|
+
]);
|
|
210
|
+
// Turning the voice-over back on is also how a failed narration is retried, so the failure flag clears
|
|
211
|
+
// and the current line is spoken afresh.
|
|
212
|
+
const isAudioEnabledRef = react.useRef(isAudioEnabled);
|
|
213
|
+
isAudioEnabledRef.current = isAudioEnabled;
|
|
214
|
+
const toggleAudio = react.useCallback(()=>{
|
|
215
|
+
if (!isAudioEnabledRef.current) {
|
|
216
|
+
setHasNarrationFailed(false);
|
|
217
|
+
narratedStepRef.current = -1;
|
|
218
|
+
}
|
|
219
|
+
setIsAudioEnabled(!isAudioEnabledRef.current);
|
|
220
|
+
}, []);
|
|
221
|
+
const toggleSubtitles = react.useCallback(()=>setAreSubtitlesEnabled((current)=>!current), []);
|
|
222
|
+
return {
|
|
223
|
+
timeline,
|
|
224
|
+
timeMs,
|
|
225
|
+
isPlaying,
|
|
226
|
+
isAudioEnabled,
|
|
227
|
+
areSubtitlesEnabled,
|
|
228
|
+
isSpeechAvailable,
|
|
229
|
+
hasNarrationFailed,
|
|
230
|
+
step,
|
|
231
|
+
chapterIndex,
|
|
232
|
+
sectionIndex,
|
|
233
|
+
togglePlay,
|
|
234
|
+
pause,
|
|
235
|
+
seekTo,
|
|
236
|
+
goToChapter,
|
|
237
|
+
goToPreviousChapter,
|
|
238
|
+
goToNextChapter,
|
|
239
|
+
toggleAudio,
|
|
240
|
+
toggleSubtitles
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
exports.useTourPlayback = useTourPlayback;
|
|
245
|
+
//# sourceMappingURL=useTourPlayback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTourPlayback.js","sources":["../../useTourPlayback.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useCueConfiguration } from './Configuration/CueProvider.js';\nimport type { TourSection } from './TourSection.js';\nimport type { TourStep } from './TourStep.js';\nimport { advanceTourClock } from './tourClock.js';\nimport {\n type TourTimeline,\n buildTourTimeline,\n chapterIndexAtTime,\n chapterStartMs,\n narrationsAfter,\n nextChapterTargetMs,\n previousChapterTargetMs,\n sectionIndexAtTime,\n stepIndexAtTime,\n} from './tourTimeline.js';\n\n// How many steps ahead of the one being said the voice-over is requested, so each line starts the moment its step does.\nconst NARRATION_LOOKAHEAD_STEPS = 2;\n\n/** How often the clock advances. Fine enough for a progress bar, coarse enough not to re-render at frame rate. */\nconst TICK_MS = 100;\n\n/** Everything the tour's chrome needs to draw itself and drive playback. */\nexport interface TourPlayback<TStep extends TourStep = TourStep> {\n /** The whole tour laid out on one clock. */\n timeline: TourTimeline<TStep>;\n\n /** Where playback has got to, in milliseconds. */\n timeMs: number;\n\n /** Whether the tour is running. */\n isPlaying: boolean;\n\n /** Whether the voice-over is switched on. */\n isAudioEnabled: boolean;\n\n /** Whether subtitles are switched on. */\n areSubtitlesEnabled: boolean;\n\n /** Whether a voice-over service is available at all. */\n isSpeechAvailable: boolean;\n\n /** Whether the voice-over has failed and the tour is carrying on with subtitles instead. */\n hasNarrationFailed: boolean;\n\n /** The step being played, or undefined when the script is empty. */\n step: TStep | undefined;\n\n /** The chapter being played. */\n chapterIndex: number;\n\n /** The section the playing chapter belongs to. */\n sectionIndex: number;\n\n /** Starts or stops playback. */\n togglePlay(): void;\n\n /** Stops playback where it is, whatever state it was in — what switching to self-paced reading uses. */\n pause(): void;\n\n /** Moves playback to a point on the clock. */\n seekTo(timeMs: number): void;\n\n /** Moves playback to the start of a chapter. */\n goToChapter(chapterIndex: number): void;\n\n /** Restarts the current chapter, or goes back one when barely into it. */\n goToPreviousChapter(): void;\n\n /** Skips to the next chapter. */\n goToNextChapter(): void;\n\n /** Switches the voice-over on or off. */\n toggleAudio(): void;\n\n /** Switches subtitles on or off. */\n toggleSubtitles(): void;\n}\n\n/**\n * Runs the guided tour: advances one clock, and keeps the voice-over pointed at whatever the clock says is\n * being narrated.\n * @param sections The scripted sections to play.\n * @returns The {@link TourPlayback} controls and state.\n * @remarks\n * The clock is the single source of truth — subtitles, progress, chapter highlighting and how much of the\n * tour's stage is showing are all read from it, so seeking anywhere is consistent by construction. Pacing\n * follows the schedule, with two adjustments at the boundaries where the schedule and the voice disagree\n * (see {@link advanceTourClock}): a line finishing ahead of its step's estimate skips the leftover dead air,\n * and a line still being said as the estimate runs out holds the clock at the step's end until it finishes —\n * bounded, so a voice that never finishes cannot stall the whole tour. Whatever is playing is always\n * silenced the moment the step it belongs to is left, whichever direction that happens in.\n */\nexport function useTourPlayback<TStep extends TourStep>(sections: TourSection<TStep>[]): TourPlayback<TStep> {\n const timeline = useMemo(() => buildTourTimeline(sections), [sections]);\n const [timeMs, setTimeState] = useState(0);\n // The clock's position, readable by the ticker without going through a state updater: an updater must not have\n // side effects, and the tick has one - it ends playback when the tour reaches its end.\n const timeMsRef = useRef(0);\n const setTimeMs = useCallback((next: number | ((current: number) => number)) => {\n timeMsRef.current = typeof next === 'function' ? next(timeMsRef.current) : next;\n setTimeState(timeMsRef.current);\n }, []);\n const [isPlaying, setIsPlaying] = useState(true);\n const [isAudioEnabled, setIsAudioEnabled] = useState(true);\n const [areSubtitlesEnabled, setAreSubtitlesEnabled] = useState(true);\n const [hasNarrationFailed, setHasNarrationFailed] = useState(false);\n const { useSpeech } = useCueConfiguration();\n const { isAvailable: isSpeechAvailable, isPreparing, isSpeaking, hasError: hasSpeechError, speak, prefetch, stop } = useSpeech();\n\n const stepIndex = stepIndexAtTime(timeline, timeMs);\n const step = stepIndex >= 0 ? timeline.steps[stepIndex].step : undefined;\n const chapterIndex = chapterIndexAtTime(timeline, timeMs);\n const sectionIndex = sectionIndexAtTime(timeline, timeMs);\n\n // Which step the voice has already been given. Reset to nothing whenever playback jumps or is silenced,\n // so resuming or seeking back always speaks the line again rather than sitting through it in silence.\n const narratedStepRef = useRef(-1);\n\n // The narration currently being watched for completion: set when a line is handed to the voice, marked\n // started once audio is actually being prepared or spoken, and cleared once it is known to have ended.\n // Refs rather than state — nothing here needs to trigger its own render.\n const pendingNarrationRef = useRef<{ stepIndex: number; started: boolean } | null>(null);\n const narrationFinishedRef = useRef<{ stepIndex: number; finishedAt: number } | null>(null);\n const narrationHoldRef = useRef<number | null>(null);\n\n useEffect(() => {\n if (!isPlaying) return;\n\n let previous = performance.now();\n const ticker = setInterval(() => {\n const now = performance.now();\n const elapsed = now - previous;\n previous = now;\n const advance = advanceTourClock(timeline, timeMsRef.current, elapsed, now, {\n pendingStepIndex: pendingNarrationRef.current?.stepIndex ?? null,\n finished: narrationFinishedRef.current,\n holdStartedAt: narrationHoldRef.current,\n });\n narrationHoldRef.current = advance.holdStartedAt;\n if (advance.finishedConsumed) {\n narrationFinishedRef.current = null;\n }\n\n setTimeMs(advance.timeMs);\n if (!advance.isPlaying) {\n setIsPlaying(false);\n }\n }, TICK_MS);\n\n return () => clearInterval(ticker);\n }, [isPlaying, timeline, setTimeMs]);\n\n useEffect(() => {\n if (!isPlaying || !isAudioEnabled || !isSpeechAvailable) {\n narratedStepRef.current = -1;\n pendingNarrationRef.current = null;\n narrationFinishedRef.current = null;\n narrationHoldRef.current = null;\n stop();\n return;\n }\n\n if (narratedStepRef.current === stepIndex) return;\n narratedStepRef.current = stepIndex;\n\n narrationFinishedRef.current = null;\n const narration = stepIndex >= 0 ? timeline.steps[stepIndex].step.narration : '';\n if (narration.length > 0) {\n pendingNarrationRef.current = { stepIndex, started: false };\n\n // speak() tears down whatever the voice was still saying for the step just left, before\n // starting this step's line — leaving a step always silences it, never lets it bleed forward.\n void speak(narration);\n } else {\n // A silent, camera-only step — nothing to say, but anything still playing from the step before\n // it must be cut off rather than left to talk over a scene it no longer belongs to.\n pendingNarrationRef.current = null;\n stop();\n }\n }, [isPlaying, isAudioEnabled, isSpeechAvailable, stepIndex, timeline, speak, stop]);\n\n // Asks the voice for the lines still to come while the current one is being said, so each starts the moment its\n // step does instead of waiting for the speech service. The current line goes first: nothing is requested until it\n // is audible, so the lookahead never competes with the line the viewer is waiting for.\n useEffect(() => {\n if (!isPlaying || !isAudioEnabled || !isSpeechAvailable || stepIndex < 0) return;\n\n // The line being waited for has been handed to the voice but is not audible yet: ask for nothing else.\n const pending = pendingNarrationRef.current;\n if (pending && (!pending.started || isPreparing)) return;\n\n for (const narration of narrationsAfter(timeline, stepIndex, NARRATION_LOOKAHEAD_STEPS)) prefetch(narration);\n }, [isPlaying, isAudioEnabled, isSpeechAvailable, isPreparing, stepIndex, timeline, prefetch]);\n\n // Watches the voice to notice when the pending line has finished. \"Finished\" is a transition — the line\n // must have been heard preparing or speaking before silence counts as its end, otherwise the quiet moment\n // between asking for a clip and the first audio arriving would be mistaken for completion.\n useEffect(() => {\n const pending = pendingNarrationRef.current;\n if (!pending) return;\n\n if (isPreparing || isSpeaking) {\n pending.started = true;\n return;\n }\n\n if (pending.started) {\n pendingNarrationRef.current = null;\n narrationFinishedRef.current = { stepIndex: pending.stepIndex, finishedAt: performance.now() };\n }\n }, [isPreparing, isSpeaking]);\n\n // A failing voice-over must not make the tour silently silent: switch the audio toggle off so the\n // transport shows what happened, and make sure subtitles are on so the words still reach the viewer.\n // The clock keeps running throughout — narration failing never stalls the tour.\n useEffect(() => {\n if (!hasSpeechError || !isAudioEnabled) return;\n\n setHasNarrationFailed(true);\n setIsAudioEnabled(false);\n setAreSubtitlesEnabled(true);\n }, [hasSpeechError, isAudioEnabled]);\n\n const seekTo = useCallback((target: number) => {\n narratedStepRef.current = -1;\n pendingNarrationRef.current = null;\n narrationFinishedRef.current = null;\n narrationHoldRef.current = null;\n setTimeMs(Math.min(Math.max(0, target), timeline.durationMs));\n }, [timeline.durationMs, setTimeMs]);\n\n const isPlayingRef = useRef(isPlaying);\n isPlayingRef.current = isPlaying;\n const togglePlay = useCallback(() => {\n // Pressing play at the very end starts over rather than doing nothing, which is what a finished\n // video does and what someone reaching for the button after it ends is asking for.\n if (!isPlayingRef.current) {\n if (timeMsRef.current >= timeline.durationMs) setTimeMs(0);\n narratedStepRef.current = -1;\n }\n\n setIsPlaying(!isPlayingRef.current);\n }, [timeline.durationMs, setTimeMs]);\n\n const pause = useCallback(() => setIsPlaying(false), []);\n\n const goToChapter = useCallback((target: number) => seekTo(chapterStartMs(timeline, target)), [seekTo, timeline]);\n const goToPreviousChapter = useCallback(() => seekTo(previousChapterTargetMs(timeline, timeMs)), [seekTo, timeline, timeMs]);\n const goToNextChapter = useCallback(() => seekTo(nextChapterTargetMs(timeline, timeMs)), [seekTo, timeline, timeMs]);\n\n // Turning the voice-over back on is also how a failed narration is retried, so the failure flag clears\n // and the current line is spoken afresh.\n const isAudioEnabledRef = useRef(isAudioEnabled);\n isAudioEnabledRef.current = isAudioEnabled;\n const toggleAudio = useCallback(() => {\n if (!isAudioEnabledRef.current) {\n setHasNarrationFailed(false);\n narratedStepRef.current = -1;\n }\n\n setIsAudioEnabled(!isAudioEnabledRef.current);\n }, []);\n\n const toggleSubtitles = useCallback(() => setAreSubtitlesEnabled(current => !current), []);\n\n return {\n timeline,\n timeMs,\n isPlaying,\n isAudioEnabled,\n areSubtitlesEnabled,\n isSpeechAvailable,\n hasNarrationFailed,\n step,\n chapterIndex,\n sectionIndex,\n togglePlay,\n pause,\n seekTo,\n goToChapter,\n goToPreviousChapter,\n goToNextChapter,\n toggleAudio,\n toggleSubtitles,\n };\n}\n"],"names":["NARRATION_LOOKAHEAD_STEPS","TICK_MS","useTourPlayback","sections","timeline","useMemo","buildTourTimeline","timeMs","setTimeState","useState","timeMsRef","useRef","setTimeMs","useCallback","next","current","isPlaying","setIsPlaying","isAudioEnabled","setIsAudioEnabled","areSubtitlesEnabled","setAreSubtitlesEnabled","hasNarrationFailed","setHasNarrationFailed","useSpeech","useCueConfiguration","isAvailable","isSpeechAvailable","isPreparing","isSpeaking","hasError","hasSpeechError","speak","prefetch","stop","stepIndex","stepIndexAtTime","step","steps","undefined","chapterIndex","chapterIndexAtTime","sectionIndex","sectionIndexAtTime","narratedStepRef","pendingNarrationRef","narrationFinishedRef","narrationHoldRef","useEffect","previous","performance","now","ticker","setInterval","elapsed","advance","advanceTourClock","pendingStepIndex","finished","holdStartedAt","finishedConsumed","clearInterval","narration","length","started","pending","narrationsAfter","finishedAt","seekTo","target","Math","min","max","durationMs","isPlayingRef","togglePlay","pause","goToChapter","chapterStartMs","goToPreviousChapter","previousChapterTargetMs","goToNextChapter","nextChapterTargetMs","isAudioEnabledRef","toggleAudio","toggleSubtitles"],"mappings":";;;;;;;AAAA;AACA;AAmBA;AACA,MAAMA,yBAAAA,GAA4B,CAAA;AAElC,mHACA,MAAMC,OAAAA,GAAU,GAAA;AA2DhB;;;;;;;;;;;;;IAcO,SAASC,eAAAA,CAAwCC,QAA8B,EAAA;AAClF,IAAA,MAAMC,QAAAA,GAAWC,aAAAA,CAAQ,IAAMC,8BAAAA,CAAkBH,QAAAA,CAAAA,EAAW;AAACA,QAAAA;AAAS,KAAA,CAAA;AACtE,IAAA,MAAM,CAACI,MAAAA,EAAQC,YAAAA,CAAa,GAAGC,cAAAA,CAAS,CAAA,CAAA;;;AAGxC,IAAA,MAAMC,YAAYC,YAAAA,CAAO,CAAA,CAAA;IACzB,MAAMC,SAAAA,GAAYC,kBAAY,CAACC,IAAAA,GAAAA;QAC3BJ,SAAAA,CAAUK,OAAO,GAAG,OAAOD,IAAAA,KAAS,aAAaA,IAAAA,CAAKJ,SAAAA,CAAUK,OAAO,CAAA,GAAID,IAAAA;AAC3EN,QAAAA,YAAAA,CAAaE,UAAUK,OAAO,CAAA;AAClC,IAAA,CAAA,EAAG,EAAE,CAAA;AACL,IAAA,MAAM,CAACC,SAAAA,EAAWC,YAAAA,CAAa,GAAGR,cAAAA,CAAS,IAAA,CAAA;AAC3C,IAAA,MAAM,CAACS,cAAAA,EAAgBC,iBAAAA,CAAkB,GAAGV,cAAAA,CAAS,IAAA,CAAA;AACrD,IAAA,MAAM,CAACW,mBAAAA,EAAqBC,sBAAAA,CAAuB,GAAGZ,cAAAA,CAAS,IAAA,CAAA;AAC/D,IAAA,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AAA;;;AAInH,IAAA,MAAM4E,oBAAoBxE,YAAAA,CAAOO,cAAAA,CAAAA;AACjCiE,IAAAA,iBAAAA,CAAkBpE,OAAO,GAAGG,cAAAA;AAC5B,IAAA,MAAMkE,cAAcvE,iBAAAA,CAAY,IAAA;QAC5B,IAAI,CAACsE,iBAAAA,CAAkBpE,OAAO,EAAE;YAC5BQ,qBAAAA,CAAsB,KAAA,CAAA;YACtBqB,eAAAA,CAAgB7B,OAAO,GAAG,EAAC;AAC/B,QAAA;QAEAI,iBAAAA,CAAkB,CAACgE,kBAAkBpE,OAAO,CAAA;AAChD,IAAA,CAAA,EAAG,EAAE,CAAA;IAEL,MAAMsE,eAAAA,GAAkBxE,kBAAY,IAAMQ,sBAAAA,CAAuBN,CAAAA,OAAAA,GAAW,CAACA,UAAU,EAAE,CAAA;IAEzF,OAAO;AACHX,QAAAA,QAAAA;AACAG,QAAAA,MAAAA;AACAS,QAAAA,SAAAA;AACAE,QAAAA,cAAAA;AACAE,QAAAA,mBAAAA;AACAO,QAAAA,iBAAAA;AACAL,QAAAA,kBAAAA;AACAe,QAAAA,IAAAA;AACAG,QAAAA,YAAAA;AACAE,QAAAA,YAAAA;AACAiC,QAAAA,UAAAA;AACAC,QAAAA,KAAAA;AACAR,QAAAA,MAAAA;AACAS,QAAAA,WAAAA;AACAE,QAAAA,mBAAAA;AACAE,QAAAA,eAAAA;AACAG,QAAAA,WAAAA;AACAC,QAAAA;AACJ,KAAA;AACJ;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import type { CueLabels } from '../Labels/CueLabels.js';
|
|
3
|
+
import type { CueSpeechConfiguration } from '../Speech/CueSpeechConfiguration.js';
|
|
4
|
+
export interface CueConfiguration {
|
|
5
|
+
speech?: CueSpeechConfiguration;
|
|
6
|
+
labels?: Partial<CueLabels>;
|
|
7
|
+
stageBoundary?: ComponentType<{
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=CueConfiguration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CueConfiguration.d.ts","sourceRoot":"","sources":["../../../Configuration/CueConfiguration.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAKlF,MAAM,WAAW,gBAAgB;IAK7B,MAAM,CAAC,EAAE,sBAAsB,CAAC;IAGhC,MAAM,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAO5B,aAAa,CAAC,EAAE,aAAa,CAAC;QAAE,QAAQ,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;CAC1D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CueConfiguration.js","sourceRoot":"","sources":["../../../Configuration/CueConfiguration.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import { type CueLabels } from '../Labels/CueLabels.js';
|
|
3
|
+
import type { CueConfiguration } from './CueConfiguration.js';
|
|
4
|
+
import type { ComponentType } from 'react';
|
|
5
|
+
import type { CueSpeech } from '../Speech/CueSpeech.js';
|
|
6
|
+
export interface ResolvedCueConfiguration {
|
|
7
|
+
useSpeech: () => CueSpeech;
|
|
8
|
+
unlockAudio: () => void;
|
|
9
|
+
labels: CueLabels;
|
|
10
|
+
stageBoundary: ComponentType<{
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
export interface CueProviderProps extends CueConfiguration {
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
export declare const CueProvider: ({ speech, labels, stageBoundary, children }: CueProviderProps) => React.JSX.Element;
|
|
18
|
+
export declare const useCueConfiguration: () => ResolvedCueConfiguration;
|
|
19
|
+
//# sourceMappingURL=CueProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CueProvider.d.ts","sourceRoot":"","sources":["../../../Configuration/CueProvider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAsC,MAAM,OAAO,CAAC;AAClF,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAIxD,MAAM,WAAW,wBAAwB;IAErC,SAAS,EAAE,MAAM,SAAS,CAAC;IAE3B,WAAW,EAAE,MAAM,IAAI,CAAC;IAExB,MAAM,EAAE,SAAS,CAAC;IAElB,aAAa,EAAE,aAAa,CAAC;QAAE,QAAQ,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;CACzD;AAiBD,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IAEtD,QAAQ,EAAE,SAAS,CAAC;CACvB;AAMD,eAAO,MAAM,WAAW,GAAI,6CAA6C,gBAAgB,sBASxF,CAAC;AAMF,eAAO,MAAM,mBAAmB,QAAO,wBAA+D,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useMemo, useContext, createContext } from 'react';
|
|
3
|
+
import { resolveLabels } from '../Labels/resolveLabels.js';
|
|
4
|
+
import { CueStageBoundary } from './CueStageBoundary.js';
|
|
5
|
+
import { silentSpeech } from '../Speech/silentSpeech.js';
|
|
6
|
+
|
|
7
|
+
// A tour with no voice-over plays silently: there is no service, so nothing is ever said.
|
|
8
|
+
const useSilentSpeech = ()=>silentSpeech;
|
|
9
|
+
const defaults = {
|
|
10
|
+
useSpeech: useSilentSpeech,
|
|
11
|
+
unlockAudio: ()=>undefined,
|
|
12
|
+
labels: resolveLabels(),
|
|
13
|
+
stageBoundary: CueStageBoundary
|
|
14
|
+
};
|
|
15
|
+
const CueConfigurationContext = /*#__PURE__*/ createContext(defaults);
|
|
16
|
+
/**
|
|
17
|
+
* Tells the tours below it how to speak, what to call their buttons and how to guard their stage. Put it once near the
|
|
18
|
+
* root of the application; without it a tour plays silently, in English.
|
|
19
|
+
*/ const CueProvider = ({ speech, labels, stageBoundary, children })=>{
|
|
20
|
+
const value = useMemo(()=>({
|
|
21
|
+
useSpeech: speech?.useSpeech ?? useSilentSpeech,
|
|
22
|
+
unlockAudio: ()=>speech?.unlock?.(),
|
|
23
|
+
labels: resolveLabels(labels),
|
|
24
|
+
stageBoundary: stageBoundary ?? CueStageBoundary
|
|
25
|
+
}), [
|
|
26
|
+
speech,
|
|
27
|
+
labels,
|
|
28
|
+
stageBoundary
|
|
29
|
+
]);
|
|
30
|
+
return /*#__PURE__*/ jsx(CueConfigurationContext.Provider, {
|
|
31
|
+
value: value,
|
|
32
|
+
children: children
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Gets the configuration of the nearest {@link CueProvider}, or the defaults when there is none.
|
|
37
|
+
* @returns The {@link ResolvedCueConfiguration}.
|
|
38
|
+
*/ const useCueConfiguration = ()=>useContext(CueConfigurationContext);
|
|
39
|
+
|
|
40
|
+
export { CueProvider, useCueConfiguration };
|
|
41
|
+
//# sourceMappingURL=CueProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CueProvider.js","sources":["../../../Configuration/CueProvider.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport React, { type ReactNode, createContext, useContext, useMemo } from 'react';\nimport { type CueLabels } from '../Labels/CueLabels.js';\nimport { resolveLabels } from '../Labels/resolveLabels.js';\nimport { CueStageBoundary } from './CueStageBoundary.js';\nimport type { CueConfiguration } from './CueConfiguration.js';\nimport type { ComponentType } from 'react';\nimport type { CueSpeech } from '../Speech/CueSpeech.js';\nimport { silentSpeech } from '../Speech/silentSpeech.js';\n\n/** The configuration as the tour reads it: everything is there. */\nexport interface ResolvedCueConfiguration {\n /** The hook that gives a tour its voice; a silent one when the tours play without a voice-over. */\n useSpeech: () => CueSpeech;\n /** Unlocks audio playback from a viewer's gesture; does nothing when there is no voice-over. */\n unlockAudio: () => void;\n /** Every text of the tour's chrome. */\n labels: CueLabels;\n /** What guards the stage of a tour. */\n stageBoundary: ComponentType<{ children: ReactNode }>;\n}\n\n// A tour with no voice-over plays silently: there is no service, so nothing is ever said.\nconst useSilentSpeech = (): CueSpeech => silentSpeech;\n\nconst defaults: ResolvedCueConfiguration = {\n useSpeech: useSilentSpeech,\n unlockAudio: () => undefined,\n labels: resolveLabels(),\n stageBoundary: CueStageBoundary\n};\n\nconst CueConfigurationContext = createContext<ResolvedCueConfiguration>(defaults);\n\n/**\n * Props for {@link CueProvider}.\n */\nexport interface CueProviderProps extends CueConfiguration {\n /** What the configuration applies to: the tours. */\n children: ReactNode;\n}\n\n/**\n * Tells the tours below it how to speak, what to call their buttons and how to guard their stage. Put it once near the\n * root of the application; without it a tour plays silently, in English.\n */\nexport const CueProvider = ({ speech, labels, stageBoundary, children }: CueProviderProps) => {\n const value = useMemo<ResolvedCueConfiguration>(() => ({\n useSpeech: speech?.useSpeech ?? useSilentSpeech,\n unlockAudio: () => speech?.unlock?.(),\n labels: resolveLabels(labels),\n stageBoundary: stageBoundary ?? CueStageBoundary\n }), [speech, labels, stageBoundary]);\n\n return <CueConfigurationContext.Provider value={value}>{children}</CueConfigurationContext.Provider>;\n};\n\n/**\n * Gets the configuration of the nearest {@link CueProvider}, or the defaults when there is none.\n * @returns The {@link ResolvedCueConfiguration}.\n */\nexport const useCueConfiguration = (): ResolvedCueConfiguration => useContext(CueConfigurationContext);\n"],"names":["useSilentSpeech","silentSpeech","defaults","useSpeech","unlockAudio","undefined","labels","resolveLabels","stageBoundary","CueStageBoundary","CueConfigurationContext","createContext","CueProvider","speech","children","value","useMemo","unlock","_jsx","Provider","useCueConfiguration","useContext"],"mappings":";;;;;;AAwBA;AACA,MAAMA,kBAAkB,IAAiBC,YAAAA;AAEzC,MAAMC,QAAAA,GAAqC;IACvCC,SAAAA,EAAWH,eAAAA;AACXI,IAAAA,WAAAA,EAAa,IAAMC,SAAAA;IACnBC,MAAAA,EAAQC,aAAAA,EAAAA;IACRC,aAAAA,EAAeC;AACnB,CAAA;AAEA,MAAMC,wCAA0BC,aAAAA,CAAwCT,QAAAA,CAAAA;AAUxE;;;AAGC,IACM,MAAMU,WAAAA,GAAc,CAAC,EAAEC,MAAM,EAAEP,MAAM,EAAEE,aAAa,EAAEM,QAAQ,EAAoB,GAAA;IACrF,MAAMC,KAAAA,GAAQC,OAAAA,CAAkC,KAAO;AACnDb,YAAAA,SAAAA,EAAWU,QAAQV,SAAAA,IAAaH,eAAAA;AAChCI,YAAAA,WAAAA,EAAa,IAAMS,MAAAA,EAAQI,MAAAA,IAAAA;AAC3BX,YAAAA,MAAAA,EAAQC,aAAAA,CAAcD,MAAAA,CAAAA;AACtBE,YAAAA,aAAAA,EAAeA,aAAAA,IAAiBC;AACpC,SAAA,CAAA,EAAI;AAACI,QAAAA,MAAAA;AAAQP,QAAAA,MAAAA;AAAQE,QAAAA;AAAc,KAAA,CAAA;IAEnC,qBAAOU,GAAA,CAACR,wBAAwBS,QAAQ,EAAA;QAACJ,KAAAA,EAAOA,KAAAA;AAAQD,QAAAA,QAAAA,EAAAA;;AAC5D;AAEA;;;AAGC,IACM,MAAMM,mBAAAA,GAAsB,IAAgCC,WAAWX,uBAAAA;;"}
|