@crievo/omni 0.0.0-stage → 0.1.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/.env.example +41 -0
- package/README.md +2 -2
- package/bin/omni.mjs +14 -0
- package/docs/onboarding/clone-voice.png +0 -0
- package/docs/onboarding/getting-started.png +0 -0
- package/docs/onboarding/new-video.png +0 -0
- package/docs/onboarding/providers.png +0 -0
- package/docs/onboarding/publish.png +0 -0
- package/docs/onboarding/references.png +0 -0
- package/docs/onboarding.md +212 -0
- package/omnivideo.config.example.json +437 -0
- package/package.json +40 -4
- package/reference/captions.md +156 -0
- package/reference/carousel-contract.md +91 -0
- package/reference/cloud.md +96 -0
- package/reference/learnings.md +792 -0
- package/reference/omnichat.md +305 -0
- package/reference/premiere-mcp.md +91 -0
- package/reference/publish.md +305 -0
- package/reference/scenes-contract.md +109 -0
- package/reference/studio.md +666 -0
- package/reference/voicestudio.md +81 -0
- package/reference/writing-for-voice.md +67 -0
- package/requirements.txt +3 -0
- package/studio/api/app.ts +87 -0
- package/studio/api/lib/errors.ts +33 -0
- package/studio/api/lib/files.ts +41 -0
- package/studio/api/lib/hono.ts +9 -0
- package/studio/api/lib/result.ts +14 -0
- package/studio/api/lib/validate.ts +31 -0
- package/studio/api/lib/video.ts +10 -0
- package/studio/api/middleware/json-charset.ts +11 -0
- package/studio/api/middleware/local-only.ts +32 -0
- package/studio/api/middleware/no-timeout.ts +10 -0
- package/studio/api/routes/admin.ts +18 -0
- package/studio/api/routes/agent-cascade.ts +100 -0
- package/studio/api/routes/agent-history.ts +23 -0
- package/studio/api/routes/agent.ts +162 -0
- package/studio/api/routes/analytics.ts +31 -0
- package/studio/api/routes/approval.ts +60 -0
- package/studio/api/routes/archive.ts +12 -0
- package/studio/api/routes/captions.ts +28 -0
- package/studio/api/routes/carousel.ts +38 -0
- package/studio/api/routes/clone.ts +27 -0
- package/studio/api/routes/create.ts +19 -0
- package/studio/api/routes/events.ts +11 -0
- package/studio/api/routes/export.ts +14 -0
- package/studio/api/routes/media.ts +30 -0
- package/studio/api/routes/omnichat.ts +113 -0
- package/studio/api/routes/onboarding.ts +14 -0
- package/studio/api/routes/publish.ts +40 -0
- package/studio/api/routes/queue.ts +14 -0
- package/studio/api/routes/references.ts +40 -0
- package/studio/api/routes/runner.ts +17 -0
- package/studio/api/routes/schedule.ts +47 -0
- package/studio/api/routes/services.ts +11 -0
- package/studio/api/routes/sessions.ts +27 -0
- package/studio/api/routes/settings.ts +102 -0
- package/studio/api/routes/sound.ts +45 -0
- package/studio/api/routes/thumbnail.ts +18 -0
- package/studio/api/routes/usage.ts +13 -0
- package/studio/api/routes/videos.ts +41 -0
- package/studio/api/routes/voices.ts +71 -0
- package/studio/api/services/admin.ts +113 -0
- package/studio/api/services/agent-cascade.ts +975 -0
- package/studio/api/services/agent-claude.ts +47 -0
- package/studio/api/services/agent-history.ts +103 -0
- package/studio/api/services/agent-persona.ts +77 -0
- package/studio/api/services/agent-tools.ts +2237 -0
- package/studio/api/services/agent-ui-tools.ts +259 -0
- package/studio/api/services/agent-wait.ts +32 -0
- package/studio/api/services/agent.ts +553 -0
- package/studio/api/services/analytics.ts +92 -0
- package/studio/api/services/approval.ts +134 -0
- package/studio/api/services/archive.ts +38 -0
- package/studio/api/services/captions.ts +268 -0
- package/studio/api/services/carousel.ts +206 -0
- package/studio/api/services/classify.ts +196 -0
- package/studio/api/services/clone-phrases.ts +75 -0
- package/studio/api/services/clone.ts +722 -0
- package/studio/api/services/create.ts +421 -0
- package/studio/api/services/events.ts +215 -0
- package/studio/api/services/media.ts +32 -0
- package/studio/api/services/omnichat.ts +624 -0
- package/studio/api/services/onboarding.ts +77 -0
- package/studio/api/services/publish.ts +287 -0
- package/studio/api/services/queue.ts +150 -0
- package/studio/api/services/references.ts +269 -0
- package/studio/api/services/root.ts +60 -0
- package/studio/api/services/services.ts +114 -0
- package/studio/api/services/sessions.ts +1007 -0
- package/studio/api/services/settings.ts +983 -0
- package/studio/api/services/sound.ts +311 -0
- package/studio/api/services/thumbnail.ts +133 -0
- package/studio/api/services/usage.ts +27 -0
- package/studio/api/services/videos.ts +418 -0
- package/studio/api/services/voice-pause.ts +98 -0
- package/studio/api/services/voices.ts +324 -0
- package/studio/runner/runner.ts +244 -0
- package/studio/shared/omni-actions.ts +68 -0
- package/studio/shared/omni-admin.ts +52 -0
- package/studio/shared/omni-farewell.ts +48 -0
- package/studio/shared/omni-hotword.ts +20 -0
- package/studio/shared/omni-screens.ts +228 -0
- package/studio/shared/schemas/admin.ts +15 -0
- package/studio/shared/schemas/agent-cascade.ts +58 -0
- package/studio/shared/schemas/agent-history.ts +73 -0
- package/studio/shared/schemas/agent.ts +50 -0
- package/studio/shared/schemas/analytics.ts +6 -0
- package/studio/shared/schemas/approval.ts +22 -0
- package/studio/shared/schemas/captions.ts +19 -0
- package/studio/shared/schemas/carousel.ts +26 -0
- package/studio/shared/schemas/clone.ts +40 -0
- package/studio/shared/schemas/common.ts +16 -0
- package/studio/shared/schemas/omnichat.ts +54 -0
- package/studio/shared/schemas/onboarding.ts +5 -0
- package/studio/shared/schemas/publish.ts +45 -0
- package/studio/shared/schemas/references.ts +20 -0
- package/studio/shared/schemas/settings.ts +82 -0
- package/studio/shared/schemas/sound.ts +22 -0
- package/studio/shared/schemas/videos.ts +38 -0
- package/studio/shared/schemas/voices.ts +23 -0
- package/studio/shared/types/api.ts +1290 -0
- package/studio/studio.ts +148 -0
- package/studio/tsconfig.json +15 -0
- package/studio/web/assets/logos/cartesia.svg +4 -0
- package/studio/web/assets/logos/elevenlabs.svg +12 -0
- package/studio/web/assets/logos/fish.svg +24 -0
- package/studio/web/assets/logos/omni-black.png +0 -0
- package/studio/web/assets/logos/omni-white.png +0 -0
- package/studio/web/assets/logos/voicestudio.svg +21 -0
- package/studio/web/components/AgentMark.tsx +7 -0
- package/studio/web/components/AgentWalking.tsx +11 -0
- package/studio/web/components/ApiKeyField.tsx +104 -0
- package/studio/web/components/AppShell.tsx +64 -0
- package/studio/web/components/ApprovalNotice.tsx +65 -0
- package/studio/web/components/AvatarGroupIcon.tsx +22 -0
- package/studio/web/components/AvatarNameField.tsx +86 -0
- package/studio/web/components/AvatarPicker.tsx +84 -0
- package/studio/web/components/BrandLogo.tsx +16 -0
- package/studio/web/components/CartesiaPlanSetting.tsx +90 -0
- package/studio/web/components/ClaudeWalking.tsx +32 -0
- package/studio/web/components/CloneVoiceDialog/GuidedScript.tsx +39 -0
- package/studio/web/components/CloneVoiceDialog/LanguageBar.tsx +37 -0
- package/studio/web/components/CloneVoiceDialog/LevelMeter.tsx +31 -0
- package/studio/web/components/CloneVoiceDialog/ProviderChoice.tsx +81 -0
- package/studio/web/components/CloneVoiceDialog/QualityPanel.tsx +62 -0
- package/studio/web/components/CloneVoiceDialog/RecordStep.tsx +50 -0
- package/studio/web/components/CloneVoiceDialog/RecorderBar.tsx +79 -0
- package/studio/web/components/CloneVoiceDialog/RedoSummary.tsx +54 -0
- package/studio/web/components/CloneVoiceDialog/SaveStep.tsx +91 -0
- package/studio/web/components/CloneVoiceDialog/SourceBar.tsx +30 -0
- package/studio/web/components/CloneVoiceDialog/index.tsx +141 -0
- package/studio/web/components/CloneVoiceDialog/types.ts +28 -0
- package/studio/web/components/CloneVoiceDialog/useCloneVoice.ts +528 -0
- package/studio/web/components/ConnectionSignals.tsx +51 -0
- package/studio/web/components/EditVoiceDialog/EditVoiceFooter.tsx +72 -0
- package/studio/web/components/EditVoiceDialog/ProviderCards.tsx +81 -0
- package/studio/web/components/EditVoiceDialog/index.tsx +256 -0
- package/studio/web/components/ErrorBanner.tsx +115 -0
- package/studio/web/components/FinishedTask.tsx +41 -0
- package/studio/web/components/FishModelSetting.tsx +69 -0
- package/studio/web/components/FishPriceSetting.tsx +44 -0
- package/studio/web/components/HumanBanner.tsx +64 -0
- package/studio/web/components/Lightbox.tsx +41 -0
- package/studio/web/components/LogStream.tsx +42 -0
- package/studio/web/components/Markdown.tsx +21 -0
- package/studio/web/components/MissingDmsPanel/BatchSend.tsx +137 -0
- package/studio/web/components/MissingDmsPanel/CommentCard.tsx +168 -0
- package/studio/web/components/MissingDmsPanel/CommentFeed.tsx +45 -0
- package/studio/web/components/MissingDmsPanel/DmBubble.tsx +38 -0
- package/studio/web/components/MissingDmsPanel/ReplyComposer.tsx +63 -0
- package/studio/web/components/MissingDmsPanel/index.tsx +98 -0
- package/studio/web/components/NotFound.tsx +48 -0
- package/studio/web/components/Omni/OmniAvatarPicker.tsx +92 -0
- package/studio/web/components/Omni/OmniCards.tsx +202 -0
- package/studio/web/components/Omni/OmniGlow.tsx +183 -0
- package/studio/web/components/Omni/OmniHistory.tsx +119 -0
- package/studio/web/components/Omni/OmniHotword.tsx +40 -0
- package/studio/web/components/Omni/OmniMicSelect.tsx +92 -0
- package/studio/web/components/Omni/OmniVoiceSample.tsx +81 -0
- package/studio/web/components/Omni/OmniWidget.tsx +743 -0
- package/studio/web/components/Omni/PendingActions.tsx +200 -0
- package/studio/web/components/Omni/Transcript.tsx +127 -0
- package/studio/web/components/OmnichatAccountStatus.tsx +87 -0
- package/studio/web/components/OmnichatRulePanel/RuleConfig.tsx +150 -0
- package/studio/web/components/OmnichatRulePanel/RuleDryRun.tsx +15 -0
- package/studio/web/components/OmnichatRulePanel/RuleEnableConfirm.tsx +42 -0
- package/studio/web/components/OmnichatRulePanel/RuleSkeleton.tsx +18 -0
- package/studio/web/components/OmnichatRulePanel/RuleStatus.tsx +55 -0
- package/studio/web/components/OmnichatRulePanel/index.tsx +115 -0
- package/studio/web/components/OmnichatRulePanel/rule-steps.ts +67 -0
- package/studio/web/components/OmnichatRulePanel/steps/MessageStep.tsx +91 -0
- package/studio/web/components/OmnichatRulePanel/steps/RepliesStep.tsx +201 -0
- package/studio/web/components/OmnichatRulePanel/steps/TriggerStep.tsx +76 -0
- package/studio/web/components/OmnichatRulePanel/steps/types.ts +11 -0
- package/studio/web/components/Palette.tsx +17 -0
- package/studio/web/components/PlatformCard.tsx +109 -0
- package/studio/web/components/PlatformIcon.tsx +19 -0
- package/studio/web/components/ProviderCard.tsx +80 -0
- package/studio/web/components/ProviderDetail.tsx +367 -0
- package/studio/web/components/ProviderLogo.tsx +20 -0
- package/studio/web/components/QueuePanel.tsx +77 -0
- package/studio/web/components/ReferenceActions.tsx +89 -0
- package/studio/web/components/ReferencePicker.tsx +136 -0
- package/studio/web/components/ResultMessage.tsx +7 -0
- package/studio/web/components/RuleForm.tsx +138 -0
- package/studio/web/components/RuleLog.tsx +151 -0
- package/studio/web/components/RunningTask.tsx +23 -0
- package/studio/web/components/SampleList.tsx +55 -0
- package/studio/web/components/SessionPanel.tsx +352 -0
- package/studio/web/components/SettingRow.tsx +14 -0
- package/studio/web/components/SettingsCategorySkeleton.tsx +25 -0
- package/studio/web/components/SidePanel.tsx +77 -0
- package/studio/web/components/Sidebar.tsx +289 -0
- package/studio/web/components/StageStepper.tsx +87 -0
- package/studio/web/components/StudioOffline.tsx +80 -0
- package/studio/web/components/TaskName.tsx +17 -0
- package/studio/web/components/TopBanners.tsx +30 -0
- package/studio/web/components/VideoOmnichatPanel.tsx +287 -0
- package/studio/web/components/VoiceAvatar.tsx +33 -0
- package/studio/web/components/VoiceCarousel.tsx +196 -0
- package/studio/web/components/VoiceCategory.tsx +9 -0
- package/studio/web/components/VoiceModal.tsx +39 -0
- package/studio/web/components/VoiceProfileCard.tsx +75 -0
- package/studio/web/components/VoiceProfilePicker.tsx +107 -0
- package/studio/web/components/VoiceProfilesSettings.tsx +150 -0
- package/studio/web/components/VoiceProviderCard.tsx +118 -0
- package/studio/web/components/VoiceProvidersCard.tsx +26 -0
- package/studio/web/components/WaitList.tsx +21 -0
- package/studio/web/components/icons.tsx +247 -0
- package/studio/web/components/ui/accordion.tsx +47 -0
- package/studio/web/components/ui/badge.tsx +18 -0
- package/studio/web/components/ui/calendar.tsx +43 -0
- package/studio/web/components/ui/chart.tsx +229 -0
- package/studio/web/components/ui/checkbox.tsx +26 -0
- package/studio/web/components/ui/cx.ts +2 -0
- package/studio/web/components/ui/date-time-picker.tsx +84 -0
- package/studio/web/components/ui/panel.tsx +23 -0
- package/studio/web/components/ui/picker.tsx +58 -0
- package/studio/web/components/ui/popover.tsx +24 -0
- package/studio/web/components/ui/select.tsx +89 -0
- package/studio/web/components/ui/skeleton.tsx +10 -0
- package/studio/web/components/ui/slider.tsx +68 -0
- package/studio/web/components/ui/switch.tsx +13 -0
- package/studio/web/components/ui/tooltip.test.tsx +30 -0
- package/studio/web/components/ui/tooltip.tsx +59 -0
- package/studio/web/hooks/useAccounts.ts +27 -0
- package/studio/web/hooks/useAdmin.ts +12 -0
- package/studio/web/hooks/useAnalytics.ts +21 -0
- package/studio/web/hooks/useAvatarAudioReactive.ts +87 -0
- package/studio/web/hooks/useBrowserConnect.ts +48 -0
- package/studio/web/hooks/useClonePlan.ts +14 -0
- package/studio/web/hooks/useConnected.ts +7 -0
- package/studio/web/hooks/useLiveQuery.ts +29 -0
- package/studio/web/hooks/useMenuCollapsed.ts +32 -0
- package/studio/web/hooks/useMicDevices.ts +53 -0
- package/studio/web/hooks/useMissingDms.ts +211 -0
- package/studio/web/hooks/useMissingSetupSteps.ts +26 -0
- package/studio/web/hooks/useNow.ts +11 -0
- package/studio/web/hooks/useOmniAgent.ts +278 -0
- package/studio/web/hooks/useOmniClaude.ts +124 -0
- package/studio/web/hooks/useOmniDock.ts +142 -0
- package/studio/web/hooks/useOmniGreeting.ts +60 -0
- package/studio/web/hooks/useOmniHotword.ts +128 -0
- package/studio/web/hooks/useOmnichat.ts +26 -0
- package/studio/web/hooks/useOnboarding.ts +27 -0
- package/studio/web/hooks/usePost.ts +23 -0
- package/studio/web/hooks/useQueue.ts +10 -0
- package/studio/web/hooks/useReferences.ts +20 -0
- package/studio/web/hooks/useRuleEditor.ts +101 -0
- package/studio/web/hooks/useRunner.ts +24 -0
- package/studio/web/hooks/useSaveAction.ts +23 -0
- package/studio/web/hooks/useSchedule.ts +11 -0
- package/studio/web/hooks/useServices.ts +10 -0
- package/studio/web/hooks/useSessions.ts +15 -0
- package/studio/web/hooks/useSettings.ts +11 -0
- package/studio/web/hooks/useSettingsSection.ts +30 -0
- package/studio/web/hooks/useSidePanel.ts +23 -0
- package/studio/web/hooks/useSound.ts +30 -0
- package/studio/web/hooks/useUsage.ts +11 -0
- package/studio/web/hooks/useVideoVoice.ts +36 -0
- package/studio/web/hooks/useVideos.ts +21 -0
- package/studio/web/hooks/useVoiceProfilePreview.ts +52 -0
- package/studio/web/hooks/useVoiceProfiles.ts +7 -0
- package/studio/web/hooks/useVoiceRunning.ts +10 -0
- package/studio/web/hooks/useVoiceStudioClosed.ts +8 -0
- package/studio/web/index.html +19 -0
- package/studio/web/lib/agent.ts +7 -0
- package/studio/web/lib/alerts.ts +210 -0
- package/studio/web/lib/analytics-metrics.ts +351 -0
- package/studio/web/lib/api.ts +70 -0
- package/studio/web/lib/audio.ts +39 -0
- package/studio/web/lib/avatars.ts +41 -0
- package/studio/web/lib/calendar.ts +218 -0
- package/studio/web/lib/caption-position.ts +249 -0
- package/studio/web/lib/carousel.ts +24 -0
- package/studio/web/lib/chime.ts +42 -0
- package/studio/web/lib/clone-voice.ts +55 -0
- package/studio/web/lib/export.ts +11 -0
- package/studio/web/lib/files.ts +8 -0
- package/studio/web/lib/format.ts +93 -0
- package/studio/web/lib/media.ts +29 -0
- package/studio/web/lib/mic-device.ts +72 -0
- package/studio/web/lib/missing-dms.ts +70 -0
- package/studio/web/lib/omni-cards.ts +42 -0
- package/studio/web/lib/omni-cascade.ts +1067 -0
- package/studio/web/lib/omni-greeting-audio.ts +24 -0
- package/studio/web/lib/omni-hotword.ts +231 -0
- package/studio/web/lib/omni-panel.ts +67 -0
- package/studio/web/lib/omni-realtime.ts +811 -0
- package/studio/web/lib/omni-ui.ts +402 -0
- package/studio/web/lib/omni-wait.ts +174 -0
- package/studio/web/lib/omnichat-api.ts +44 -0
- package/studio/web/lib/orb.ts +270 -0
- package/studio/web/lib/pcm-recorder.ts +115 -0
- package/studio/web/lib/platforms.ts +17 -0
- package/studio/web/lib/providers.ts +27 -0
- package/studio/web/lib/publish-draft.ts +52 -0
- package/studio/web/lib/publish-settings.ts +81 -0
- package/studio/web/lib/query-client.ts +122 -0
- package/studio/web/lib/references.ts +13 -0
- package/studio/web/lib/services.ts +40 -0
- package/studio/web/lib/sessions.ts +103 -0
- package/studio/web/lib/settings-categories.ts +58 -0
- package/studio/web/lib/sound-audio.ts +33 -0
- package/studio/web/lib/sound-timeline.ts +291 -0
- package/studio/web/lib/sse.ts +86 -0
- package/studio/web/lib/stage-history.ts +141 -0
- package/studio/web/lib/stages.ts +344 -0
- package/studio/web/lib/studio-offline.ts +60 -0
- package/studio/web/lib/upload.ts +24 -0
- package/studio/web/lib/video-tabs.ts +118 -0
- package/studio/web/lib/voice-profile-draft.ts +34 -0
- package/studio/web/lib/voice-profiles.ts +3 -0
- package/studio/web/main.tsx +14 -0
- package/studio/web/pages/AdminPage/index.tsx +123 -0
- package/studio/web/pages/AgentPage/components/Measurements.tsx +102 -0
- package/studio/web/pages/AgentPage/index.tsx +28 -0
- package/studio/web/pages/AnalyticsPage/components/About.tsx +52 -0
- package/studio/web/pages/AnalyticsPage/components/ChannelCards.tsx +106 -0
- package/studio/web/pages/AnalyticsPage/components/ChannelView.tsx +137 -0
- package/studio/web/pages/AnalyticsPage/components/CollectionStatus.tsx +46 -0
- package/studio/web/pages/AnalyticsPage/components/Comparison.tsx +68 -0
- package/studio/web/pages/AnalyticsPage/components/Diagnosis.tsx +50 -0
- package/studio/web/pages/AnalyticsPage/components/Highlights.tsx +49 -0
- package/studio/web/pages/AnalyticsPage/components/Hint.tsx +11 -0
- package/studio/web/pages/AnalyticsPage/components/HookVsBody.tsx +100 -0
- package/studio/web/pages/AnalyticsPage/components/HourlyWave.tsx +133 -0
- package/studio/web/pages/AnalyticsPage/components/Insights.tsx +70 -0
- package/studio/web/pages/AnalyticsPage/components/MetricCard.tsx +46 -0
- package/studio/web/pages/AnalyticsPage/components/PlanSection.tsx +40 -0
- package/studio/web/pages/AnalyticsPage/components/ProgressionChart.tsx +155 -0
- package/studio/web/pages/AnalyticsPage/components/ReelBarsChart.tsx +154 -0
- package/studio/web/pages/AnalyticsPage/components/ReelThumb.tsx +19 -0
- package/studio/web/pages/AnalyticsPage/components/ReelView.tsx +290 -0
- package/studio/web/pages/AnalyticsPage/components/ReelsTable.tsx +269 -0
- package/studio/web/pages/AnalyticsPage/components/RequestWithFocus.tsx +38 -0
- package/studio/web/pages/AnalyticsPage/components/SegmentedControl.tsx +35 -0
- package/studio/web/pages/AnalyticsPage/components/VsMedian.tsx +31 -0
- package/studio/web/pages/AnalyticsPage/index.tsx +17 -0
- package/studio/web/pages/GettingStartedPage/index.tsx +174 -0
- package/studio/web/pages/NewVideoPage/components/DeliverablesPicker.tsx +62 -0
- package/studio/web/pages/NewVideoPage/components/FormatPicker.tsx +33 -0
- package/studio/web/pages/NewVideoPage/index.tsx +133 -0
- package/studio/web/pages/NotFoundPage/index.tsx +9 -0
- package/studio/web/pages/OmnichatPage/components/NewFromLink.tsx +59 -0
- package/studio/web/pages/OmnichatPage/components/RuleListItem.tsx +64 -0
- package/studio/web/pages/OmnichatPage/components/RulePreview.tsx +14 -0
- package/studio/web/pages/OmnichatPage/components/RuleView.tsx +88 -0
- package/studio/web/pages/OmnichatPage/index.tsx +153 -0
- package/studio/web/pages/QueuePage/index.tsx +22 -0
- package/studio/web/pages/ReferencePage/components/ReferenceTexts.tsx +131 -0
- package/studio/web/pages/ReferencePage/index.tsx +216 -0
- package/studio/web/pages/ReferencesPage/components/NewReferenceForm.tsx +150 -0
- package/studio/web/pages/ReferencesPage/components/ReferenceCard.tsx +42 -0
- package/studio/web/pages/ReferencesPage/components/ReferenceGridSkeleton.tsx +31 -0
- package/studio/web/pages/ReferencesPage/index.tsx +67 -0
- package/studio/web/pages/SchedulePage/components/CalendarSkeleton.tsx +18 -0
- package/studio/web/pages/SchedulePage/components/DayView.tsx +177 -0
- package/studio/web/pages/SchedulePage/components/HourPicker.tsx +103 -0
- package/studio/web/pages/SchedulePage/components/MonthDayCell.tsx +111 -0
- package/studio/web/pages/SchedulePage/components/MonthView.tsx +47 -0
- package/studio/web/pages/SchedulePage/components/PlatformIcons.tsx +12 -0
- package/studio/web/pages/SchedulePage/components/PostThumb.tsx +15 -0
- package/studio/web/pages/SchedulePage/components/WeekColumn.tsx +75 -0
- package/studio/web/pages/SchedulePage/components/WeekView.tsx +35 -0
- package/studio/web/pages/SchedulePage/index.tsx +285 -0
- package/studio/web/pages/SettingsPage/components/AgentAccounts.tsx +263 -0
- package/studio/web/pages/SettingsPage/components/AgentCategory.tsx +20 -0
- package/studio/web/pages/SettingsPage/components/ModelPicker.tsx +49 -0
- package/studio/web/pages/SettingsPage/components/ModelsSettings.tsx +138 -0
- package/studio/web/pages/SettingsPage/components/PlatformsCategory.tsx +23 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/AccountStatus.tsx +29 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/AutoPublishPanel.tsx +90 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/BrowserConnect.tsx +62 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/CheckField.tsx +19 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/InstagramPanel.tsx +113 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/OmnichatSettingsPanel.tsx +146 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/SaveBar.tsx +33 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/SchedulePanel.tsx +132 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/SettingsCard.tsx +47 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/SettingsCardGroup.tsx +19 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/TextPanel.tsx +55 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/TiktokPanel.tsx +123 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/YoutubePanel.tsx +100 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/badges.tsx +15 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/index.tsx +40 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/types.ts +10 -0
- package/studio/web/pages/SettingsPage/components/UsageCategory.tsx +389 -0
- package/studio/web/pages/SettingsPage/components/VoiceProvidersCategory.tsx +97 -0
- package/studio/web/pages/SettingsPage/index.tsx +85 -0
- package/studio/web/pages/VideoPage/components/AudioPlayer.tsx +113 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/AxisField.tsx +50 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionList.tsx +56 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionListItem.tsx +92 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionMargins.tsx +57 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionStyleFields.tsx +70 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionTextForm.tsx +87 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/ColorField.tsx +37 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/MarginField.tsx +59 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/NumberField.tsx +57 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/PositionControls.tsx +140 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/captionEditor.ts +215 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/useCaptionPosition.ts +154 -0
- package/studio/web/pages/VideoPage/components/CarouselChangeRequest.tsx +72 -0
- package/studio/web/pages/VideoPage/components/CarouselCompositionStage.tsx +80 -0
- package/studio/web/pages/VideoPage/components/CarouselCreate.tsx +63 -0
- package/studio/web/pages/VideoPage/components/CarouselMissing.tsx +19 -0
- package/studio/web/pages/VideoPage/components/CarouselPublishStage.tsx +173 -0
- package/studio/web/pages/VideoPage/components/CarouselScriptStage.tsx +82 -0
- package/studio/web/pages/VideoPage/components/CarouselSlideCard.tsx +49 -0
- package/studio/web/pages/VideoPage/components/CarouselViewer.tsx +55 -0
- package/studio/web/pages/VideoPage/components/ChangedVoices.tsx +53 -0
- package/studio/web/pages/VideoPage/components/CompositionStage.tsx +78 -0
- package/studio/web/pages/VideoPage/components/CoverPicker.tsx +32 -0
- package/studio/web/pages/VideoPage/components/EditorStage.tsx +53 -0
- package/studio/web/pages/VideoPage/components/LineTakes.tsx +160 -0
- package/studio/web/pages/VideoPage/components/LineTextEditor.tsx +124 -0
- package/studio/web/pages/VideoPage/components/LineVoicePicker.tsx +37 -0
- package/studio/web/pages/VideoPage/components/MediaImage.tsx +25 -0
- package/studio/web/pages/VideoPage/components/MotionScriptStage.tsx +39 -0
- package/studio/web/pages/VideoPage/components/NarrationStage.tsx +70 -0
- package/studio/web/pages/VideoPage/components/PublishForm.tsx +387 -0
- package/studio/web/pages/VideoPage/components/PublishStage.tsx +76 -0
- package/studio/web/pages/VideoPage/components/PublishText.tsx +149 -0
- package/studio/web/pages/VideoPage/components/ScenesApprovalPanel.tsx +278 -0
- package/studio/web/pages/VideoPage/components/ScheduledInfo.tsx +72 -0
- package/studio/web/pages/VideoPage/components/ScriptApprovalPanel.tsx +189 -0
- package/studio/web/pages/VideoPage/components/ScriptStage.tsx +17 -0
- package/studio/web/pages/VideoPage/components/SequencePlayer.tsx +146 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/AddSound.tsx +117 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/AreaSelection.tsx +74 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/BedPanel.tsx +94 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/BedRow.tsx +45 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/CaptionOverlay.tsx +44 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/CaptionSaveBar.tsx +32 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/CaptionsPanel.tsx +22 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/ClipBlock.tsx +111 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/ClipPanel.tsx +76 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/CutsPanel.tsx +44 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EditorTabBar.tsx +73 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EffectChoice.tsx +46 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EffectItem.tsx +89 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EffectPanel.tsx +232 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EffectsRow.tsx +21 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/Lane.tsx +39 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/MarkerRow.tsx +40 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/MuteButton.tsx +36 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/NumberInput.tsx +37 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/PlanWarnings.tsx +19 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/PlayerResizeHandle.tsx +50 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/PreviewControls.tsx +51 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SceneRow.tsx +54 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SettingsPanel.tsx +65 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SoundLibrary.tsx +99 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SoundPreview.tsx +82 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SpeedPanel.tsx +128 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineDock.tsx +56 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineFooter.tsx +26 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineSkeleton.tsx +21 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineToolbar.tsx +160 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineTracks.tsx +121 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TrackSidebar.tsx +30 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/VoiceRow.tsx +53 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/Waveform.tsx +97 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/clipActions.ts +50 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/effectActions.ts +161 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/index.tsx +161 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/timelineGeometry.ts +45 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/types.ts +43 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useAutosave.ts +107 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useEditorShortcuts.ts +168 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useFitHeight.ts +40 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useFollowPlayhead.ts +21 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useListenMix.ts +43 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/usePlayback.ts +231 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/usePlayerWidth.ts +27 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useSoundData.ts +124 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useSoundTimeline.ts +511 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/CompareVersions.tsx +111 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/VersionCard.tsx +81 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/VersionMedia.tsx +24 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/VersionText.tsx +15 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/index.tsx +109 -0
- package/studio/web/pages/VideoPage/components/StageProcess.tsx +126 -0
- package/studio/web/pages/VideoPage/components/StageResult.tsx +69 -0
- package/studio/web/pages/VideoPage/components/SwapReference.tsx +92 -0
- package/studio/web/pages/VideoPage/components/ThumbnailPanel.tsx +252 -0
- package/studio/web/pages/VideoPage/components/TimingPanel.tsx +89 -0
- package/studio/web/pages/VideoPage/components/VideoPlayer.tsx +18 -0
- package/studio/web/pages/VideoPage/components/VideoSkeleton.tsx +50 -0
- package/studio/web/pages/VideoPage/components/VideoVoiceInfo.tsx +33 -0
- package/studio/web/pages/VideoPage/components/VideoVoicePicker.tsx +165 -0
- package/studio/web/pages/VideoPage/components/VoicePauseBanner.tsx +56 -0
- package/studio/web/pages/VideoPage/components/WithLogo.tsx +10 -0
- package/studio/web/pages/VideoPage/index.tsx +295 -0
- package/studio/web/pages/VideosPage/components/PublishedOn.tsx +85 -0
- package/studio/web/pages/VideosPage/components/ServicesPanel.tsx +81 -0
- package/studio/web/pages/VideosPage/components/SessionsPanel.tsx +62 -0
- package/studio/web/pages/VideosPage/components/VideoListSkeleton.tsx +25 -0
- package/studio/web/pages/VideosPage/components/VideoRow.tsx +122 -0
- package/studio/web/pages/VideosPage/index.tsx +134 -0
- package/studio/web/pages/VoicePage/index.tsx +28 -0
- package/studio/web/router.tsx +201 -0
- package/studio/web/styles/base/elements.css +55 -0
- package/studio/web/styles/base/utilities.css +25 -0
- package/studio/web/styles/components/badge.css +33 -0
- package/studio/web/styles/components/claude-running.css +27 -0
- package/studio/web/styles/components/claude-session.css +212 -0
- package/studio/web/styles/components/claude-walking.css +92 -0
- package/studio/web/styles/components/clone-voice-save.css +136 -0
- package/studio/web/styles/components/clone-voice.css +379 -0
- package/studio/web/styles/components/controls.css +70 -0
- package/studio/web/styles/components/data-and-image.css +54 -0
- package/studio/web/styles/components/forms.css +132 -0
- package/studio/web/styles/components/human-banner.css +99 -0
- package/studio/web/styles/components/lightbox.css +50 -0
- package/studio/web/styles/components/markdown.css +68 -0
- package/studio/web/styles/components/modal.css +70 -0
- package/studio/web/styles/components/omni-cards.css +105 -0
- package/studio/web/styles/components/omni.css +859 -0
- package/studio/web/styles/components/omnichat.css +538 -0
- package/studio/web/styles/components/panel.css +115 -0
- package/studio/web/styles/components/platform-card.css +140 -0
- package/studio/web/styles/components/provider-card.css +132 -0
- package/studio/web/styles/components/queue.css +185 -0
- package/studio/web/styles/components/reference-actions.css +133 -0
- package/studio/web/styles/components/reference-picker.css +146 -0
- package/studio/web/styles/components/results-drawer.css +224 -0
- package/studio/web/styles/components/segmented.css +115 -0
- package/studio/web/styles/components/side-panel-tab.css +23 -0
- package/studio/web/styles/components/status-signals.css +66 -0
- package/studio/web/styles/components/stepper.css +208 -0
- package/studio/web/styles/components/table.css +19 -0
- package/studio/web/styles/components/tabs.css +24 -0
- package/studio/web/styles/components/ui/accordion.css +71 -0
- package/studio/web/styles/components/ui/chart.css +162 -0
- package/studio/web/styles/components/ui/checkbox.css +37 -0
- package/studio/web/styles/components/ui/date-picker.css +153 -0
- package/studio/web/styles/components/ui/select.css +110 -0
- package/studio/web/styles/components/ui/skeleton.css +25 -0
- package/studio/web/styles/components/ui/slider.css +81 -0
- package/studio/web/styles/components/ui/switch.css +41 -0
- package/studio/web/styles/components/ui/tooltip.css +24 -0
- package/studio/web/styles/components/voice-carousel.css +255 -0
- package/studio/web/styles/components/voice-editor.css +179 -0
- package/studio/web/styles/components/voice-grid.css +56 -0
- package/studio/web/styles/components/voice-profiles.css +192 -0
- package/studio/web/styles/design-system.md +136 -0
- package/studio/web/styles/index.css +116 -0
- package/studio/web/styles/layout/page.css +41 -0
- package/studio/web/styles/layout/sidebar-groups.css +39 -0
- package/studio/web/styles/layout/sidebar.css +111 -0
- package/studio/web/styles/pages/agent.css +26 -0
- package/studio/web/styles/pages/analytics/dashboard.css +614 -0
- package/studio/web/styles/pages/analytics/insights.css +48 -0
- package/studio/web/styles/pages/getting-started.css +166 -0
- package/studio/web/styles/pages/new-video/form.css +32 -0
- package/studio/web/styles/pages/not-found.css +59 -0
- package/studio/web/styles/pages/references.css +204 -0
- package/studio/web/styles/pages/schedule/calendar.css +541 -0
- package/studio/web/styles/pages/schedule/chip-states.css +60 -0
- package/studio/web/styles/pages/settings/models.css +72 -0
- package/studio/web/styles/pages/settings/shell.css +361 -0
- package/studio/web/styles/pages/settings/usage.css +63 -0
- package/studio/web/styles/pages/studio-offline.css +105 -0
- package/studio/web/styles/pages/video/caption-controls.css +194 -0
- package/studio/web/styles/pages/video/captions-grid.css +70 -0
- package/studio/web/styles/pages/video/captions.css +79 -0
- package/studio/web/styles/pages/video/editor-chat.css +103 -0
- package/studio/web/styles/pages/video/export.css +50 -0
- package/studio/web/styles/pages/video/frames.css +29 -0
- package/studio/web/styles/pages/video/fullscreen-stage.css +400 -0
- package/studio/web/styles/pages/video/instagram-carousel.css +309 -0
- package/studio/web/styles/pages/video/layout.css +285 -0
- package/studio/web/styles/pages/video/narration.css +138 -0
- package/studio/web/styles/pages/video/preview-overview.css +11 -0
- package/studio/web/styles/pages/video/processing-notice.css +34 -0
- package/studio/web/styles/pages/video/publish-when.css +76 -0
- package/studio/web/styles/pages/video/publish.css +97 -0
- package/studio/web/styles/pages/video/result.css +96 -0
- package/studio/web/styles/pages/video/scenes.css +167 -0
- package/studio/web/styles/pages/video/sound-timeline.css +672 -0
- package/studio/web/styles/pages/video/sound-toolbar.css +149 -0
- package/studio/web/styles/pages/video/take-player.css +100 -0
- package/studio/web/styles/pages/video/thumbnail.css +157 -0
- package/studio/web/styles/pages/video/timeline.css +117 -0
- package/studio/web/styles/pages/video/voice-picker.css +14 -0
- package/studio/web/styles/pages/video-list/active-row.css +27 -0
- package/studio/web/styles/pages/video-list/card-link.css +49 -0
- package/studio/web/styles/pages/video-list/list.css +86 -0
- package/studio/web/styles/theme/identity/details.css +204 -0
- package/studio/web/styles/theme/identity/shell.css +249 -0
- package/studio/web/styles/theme/identity/surfaces.css +183 -0
- package/studio/web/styles/theme/identity/titles-and-buttons.css +120 -0
- package/studio/web/styles/theme/no-borders/blocks.css +208 -0
- package/studio/web/styles/theme/no-borders/controls.css +256 -0
- package/studio/web/styles/tokens.css +245 -0
- package/studio/web/types/api.ts +2 -0
- package/studio/web/types/assets.d.ts +9 -0
- package/templates/brief.md +27 -0
- package/templates/captions.html +204 -0
- package/templates/carousel-composition.md +47 -0
- package/templates/carousel-script.md +60 -0
- package/templates/components/voiceavatar/README.md +87 -0
- package/templates/components/voiceavatar/demo.html +50 -0
- package/templates/components/voiceavatar/voiceavatar.js +415 -0
- package/templates/motion.md +80 -0
- package/templates/playbook.md +43 -0
- package/templates/reference.md +123 -0
- package/templates/scene.html +112 -0
- package/templates/scenes.example.json +96 -0
- package/templates/script.md +63 -0
- package/templates/slide.html +71 -0
- package/templates/wireframe.html +91 -0
- package/tools/analysis.mjs +300 -0
- package/tools/approval.mjs +442 -0
- package/tools/assemble.mjs +942 -0
- package/tools/build-motion.mjs +437 -0
- package/tools/captions.mjs +246 -0
- package/tools/carousel.mjs +558 -0
- package/tools/compose.mjs +307 -0
- package/tools/cuts.mjs +74 -0
- package/tools/editor.mjs +419 -0
- package/tools/epidemic-capture.js +54 -0
- package/tools/fanout.mjs +69 -0
- package/tools/history.mjs +70 -0
- package/tools/history.py +61 -0
- package/tools/job-queue.mjs +180 -0
- package/tools/job_queue.py +430 -0
- package/tools/lib/agents.mjs +412 -0
- package/tools/lib/channel.mjs +399 -0
- package/tools/lib/claude-settings.mjs +67 -0
- package/tools/lib/cli.mjs +9 -0
- package/tools/lib/fanout.mjs +234 -0
- package/tools/lib/http.mjs +94 -0
- package/tools/lib/index.js +14 -0
- package/tools/lib/mcp-server.mjs +69 -0
- package/tools/lib/metrics/metrics.mjs +204 -0
- package/tools/lib/narration.mjs +15 -0
- package/tools/lib/oauth-client.mjs +295 -0
- package/tools/lib/omnichat/config.mjs +139 -0
- package/tools/lib/omnichat/errors.mjs +42 -0
- package/tools/lib/omnichat/extract.mjs +82 -0
- package/tools/lib/omnichat/gate.mjs +151 -0
- package/tools/lib/omnichat/manual.mjs +166 -0
- package/tools/lib/omnichat/match.mjs +78 -0
- package/tools/lib/omnichat/pass.mjs +393 -0
- package/tools/lib/omnichat/record.mjs +208 -0
- package/tools/lib/omnichat/text.mjs +315 -0
- package/tools/lib/omnichat/webhook.mjs +166 -0
- package/tools/lib/pairing.mjs +99 -0
- package/tools/lib/paths.mjs +41 -0
- package/tools/lib/platforms/instagram.mjs +469 -0
- package/tools/lib/platforms/tiktok.mjs +343 -0
- package/tools/lib/platforms/youtube.mjs +228 -0
- package/tools/lib/publish/publish.mjs +244 -0
- package/tools/lib/schedule/schedule.mjs +191 -0
- package/tools/lib/service.mjs +134 -0
- package/tools/lib/skill-client.mjs +126 -0
- package/tools/lib/skills-release.mjs +196 -0
- package/tools/lib/testing.mjs +52 -0
- package/tools/lib/up.mjs +187 -0
- package/tools/metrics.mjs +415 -0
- package/tools/models.mjs +134 -0
- package/tools/narrate.mjs +257 -0
- package/tools/omni.mjs +298 -0
- package/tools/omni_paths.py +12 -0
- package/tools/omnichat.mjs +1577 -0
- package/tools/omnivideo.py +1122 -0
- package/tools/package.mjs +130 -0
- package/tools/platforms.mjs +236 -0
- package/tools/premiere.mjs +533 -0
- package/tools/publish.mjs +1496 -0
- package/tools/reference.mjs +1408 -0
- package/tools/render.mjs +426 -0
- package/tools/runner.mjs +156 -0
- package/tools/setup.mjs +466 -0
- package/tools/skills-release.mjs +93 -0
- package/tools/sound.mjs +1323 -0
- package/tools/soundtrack.mjs +217 -0
- package/tools/thumbnail.mjs +271 -0
- package/tools/timing.mjs +108 -0
- package/tools/usage.py +628 -0
- package/tools/voice-envelope.mjs +185 -0
- package/tools/voice.py +448 -0
- package/tools/voice_sample.py +75 -0
- package/tools/wireframe.mjs +230 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/* Analytics page helpers: number formats, the metric definitions (used by the table, comparison,
|
|
2
|
+
bar chart, cards and the all-metrics accordion), the tabs, periods and milestones, and the parser
|
|
3
|
+
of the last channel analysis (channel/analyses/<day>.md). Numbers come from tools/analysis.mjs
|
|
4
|
+
(over tools/metrics.mjs, collected hourly by the launchd agent). */
|
|
5
|
+
|
|
6
|
+
import { useEffect, useRef, useState, type ReactNode } from "react";
|
|
7
|
+
import type { ChartConfig } from "../components/ui/chart";
|
|
8
|
+
import {
|
|
9
|
+
Activity,
|
|
10
|
+
Bookmark,
|
|
11
|
+
ChatCircleText,
|
|
12
|
+
Clock,
|
|
13
|
+
Eye,
|
|
14
|
+
FastForward,
|
|
15
|
+
FilmStrip,
|
|
16
|
+
Flag,
|
|
17
|
+
Heart,
|
|
18
|
+
Lightbulb,
|
|
19
|
+
ListChecks,
|
|
20
|
+
Microscope,
|
|
21
|
+
Notepad,
|
|
22
|
+
Radar,
|
|
23
|
+
ShareNetwork,
|
|
24
|
+
Table,
|
|
25
|
+
Target,
|
|
26
|
+
Users,
|
|
27
|
+
} from "../components/icons";
|
|
28
|
+
import type { ComparableMetric, MetricsSnapshot, ReelMetrics } from "../types/api";
|
|
29
|
+
|
|
30
|
+
/* --- formats ------------------------------------------------------------------------- */
|
|
31
|
+
export const fmtNum = (v: number | null | undefined, decimals = 0) =>
|
|
32
|
+
v == null ? "—" : v.toLocaleString("pt-BR", { minimumFractionDigits: decimals, maximumFractionDigits: decimals });
|
|
33
|
+
export const fmtPct = (v: number | null | undefined) => (v == null ? "—" : `${fmtNum(v, 1)}%`);
|
|
34
|
+
export const fmtSec = (v: number | null | undefined) => (v == null ? "—" : `${fmtNum(v, 1)} s`);
|
|
35
|
+
export const fmtAge = (h: number | null | undefined) =>
|
|
36
|
+
h == null ? "—" : h < 48 ? `${Math.round(h)} h` : `${Math.round(h / 24)} d`;
|
|
37
|
+
export const fmtDay = (d: string) => `${d.slice(8, 10)}/${d.slice(5, 7)}`;
|
|
38
|
+
export const dayOf = (t: number) => new Date(t).toLocaleDateString("pt-BR", { day: "2-digit", month: "2-digit" });
|
|
39
|
+
export const hourOf = (t: number) => new Date(t).toLocaleTimeString("pt-BR", { hour: "2-digit", minute: "2-digit" });
|
|
40
|
+
export const shortLabel = (t: string, n = 30) => (t.length > n ? `${t.slice(0, n - 1).trimEnd()}…` : t);
|
|
41
|
+
/* compact for an axis: 26 mil, 25,5 mil: the decimal shows only when it exists (the axis doesn't
|
|
42
|
+
repeat "26 mil" for 25,500 and 26,000) */
|
|
43
|
+
export const compact = (v: number) => {
|
|
44
|
+
if (v < 1000) return fmtNum(v);
|
|
45
|
+
const k = v / 1000;
|
|
46
|
+
return `${fmtNum(k, Number.isInteger(Math.round(k * 10) / 10) ? 0 : 1)} mil`;
|
|
47
|
+
};
|
|
48
|
+
/* count Y axis: compact only when it doesn't repeat the same label (2,120 to 2,130 became five
|
|
49
|
+
"2,1 mil"); below 10 mil, or with the whole curve within 2% of the top, the whole number */
|
|
50
|
+
export const fmtAxisY = (values: number[]) => {
|
|
51
|
+
const max = Math.max(...values),
|
|
52
|
+
min = Math.min(...values);
|
|
53
|
+
return max < 10_000 || max - min < max * 0.02 ? (v: number) => fmtNum(v) : compact;
|
|
54
|
+
};
|
|
55
|
+
export const perThousand = (n: number | null | undefined, views: number | null | undefined) =>
|
|
56
|
+
n == null || !views ? null : (n / views) * 1000;
|
|
57
|
+
|
|
58
|
+
export function median(values: number[]) {
|
|
59
|
+
const v = [...values].sort((a, b) => a - b);
|
|
60
|
+
if (!v.length) return null;
|
|
61
|
+
const m = v.length >> 1;
|
|
62
|
+
return v.length % 2 ? v[m] : (v[m - 1] + v[m]) / 2;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* an element's width, so the y bar axis fits on a phone */
|
|
66
|
+
export function useWidth<T extends HTMLElement>() {
|
|
67
|
+
const ref = useRef<T>(null);
|
|
68
|
+
const [width, setWidth] = useState(0);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
const el = ref.current;
|
|
71
|
+
if (!el) return;
|
|
72
|
+
const ro = new ResizeObserver(([e]) => setWidth(e.contentRect.width));
|
|
73
|
+
ro.observe(el);
|
|
74
|
+
return () => ro.disconnect();
|
|
75
|
+
}, []);
|
|
76
|
+
return [ref, width] as const;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* --- the metrics, once ------------------------------------------------------------------- */
|
|
80
|
+
export type MetricId =
|
|
81
|
+
| "views"
|
|
82
|
+
| "reach"
|
|
83
|
+
| "likes"
|
|
84
|
+
| "skip"
|
|
85
|
+
| "watched"
|
|
86
|
+
| "watched_s"
|
|
87
|
+
| "saves_per_k"
|
|
88
|
+
| "shares_per_k"
|
|
89
|
+
| "comments_per_k"
|
|
90
|
+
| "saves"
|
|
91
|
+
| "shares"
|
|
92
|
+
| "comments"
|
|
93
|
+
| "interactions"
|
|
94
|
+
| "total_watch";
|
|
95
|
+
/* `median`: the key in Medians; `lowerIsBetter`: skip; `judges`: what the metric judges (shown in hints) */
|
|
96
|
+
export type MetricDef = {
|
|
97
|
+
name: string;
|
|
98
|
+
of: (s: MetricsSnapshot) => number | null;
|
|
99
|
+
fmt: (v: number) => string;
|
|
100
|
+
median?: ComparableMetric;
|
|
101
|
+
lowerIsBetter?: boolean;
|
|
102
|
+
judges?: string;
|
|
103
|
+
};
|
|
104
|
+
export const METRICS: Record<MetricId, MetricDef> = {
|
|
105
|
+
views: { name: "Views", of: s => s.views, fmt: v => fmtNum(v), median: "views", judges: "o alcance" },
|
|
106
|
+
reach: { name: "Alcance", of: s => s.reach, fmt: v => fmtNum(v), median: "reach" },
|
|
107
|
+
likes: { name: "Curtidas", of: s => s.likes, fmt: v => fmtNum(v), median: "likes" },
|
|
108
|
+
skip: {
|
|
109
|
+
name: "Pulam em 3 s",
|
|
110
|
+
of: s => s.skip_3s_pct,
|
|
111
|
+
fmt: v => fmtPct(v),
|
|
112
|
+
median: "skip_3s_pct",
|
|
113
|
+
lowerIsBetter: true,
|
|
114
|
+
judges: "o gancho: quadro 0 e primeira frase",
|
|
115
|
+
},
|
|
116
|
+
watched: {
|
|
117
|
+
name: "% assistido",
|
|
118
|
+
of: s => s.watched_pct,
|
|
119
|
+
fmt: v => fmtPct(v),
|
|
120
|
+
median: "watched_pct",
|
|
121
|
+
judges: "o miolo",
|
|
122
|
+
},
|
|
123
|
+
watched_s: { name: "Assistido médio", of: s => s.avg_watch_s, fmt: v => fmtSec(v), median: "avg_watch_s" },
|
|
124
|
+
saves_per_k: {
|
|
125
|
+
name: "Salvos/mil",
|
|
126
|
+
of: s => perThousand(s.saves, s.views),
|
|
127
|
+
fmt: v => fmtNum(v, 1),
|
|
128
|
+
median: "saves_per_k",
|
|
129
|
+
judges: "a utilidade",
|
|
130
|
+
},
|
|
131
|
+
shares_per_k: {
|
|
132
|
+
name: "Compart./mil",
|
|
133
|
+
of: s => perThousand(s.shares, s.views),
|
|
134
|
+
fmt: v => fmtNum(v, 1),
|
|
135
|
+
median: "shares_per_k",
|
|
136
|
+
judges: "o tema",
|
|
137
|
+
},
|
|
138
|
+
comments_per_k: {
|
|
139
|
+
name: "Coment./mil",
|
|
140
|
+
of: s => perThousand(s.comments, s.views),
|
|
141
|
+
fmt: v => fmtNum(v, 1),
|
|
142
|
+
median: "comments_per_k",
|
|
143
|
+
judges: "o CTA",
|
|
144
|
+
},
|
|
145
|
+
saves: { name: "Salvos", of: s => s.saves, fmt: v => fmtNum(v), median: "saves" },
|
|
146
|
+
shares: { name: "Compartilhamentos", of: s => s.shares, fmt: v => fmtNum(v), median: "shares" },
|
|
147
|
+
comments: { name: "Comentários", of: s => s.comments, fmt: v => fmtNum(v), median: "comments" },
|
|
148
|
+
interactions: { name: "Interações", of: s => s.interactions, fmt: v => fmtNum(v) },
|
|
149
|
+
total_watch: { name: "Tempo total assistido", of: s => s.total_watch_h, fmt: v => `${fmtNum(v, 1)} h` },
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/* each metric's icon, in the tabs */
|
|
153
|
+
export type IconComponent = (p: { "aria-hidden"?: boolean | "true" | "false" }) => ReactNode;
|
|
154
|
+
export const METRIC_ICON: Record<MetricId, IconComponent> = {
|
|
155
|
+
views: Eye,
|
|
156
|
+
reach: Radar,
|
|
157
|
+
likes: Heart,
|
|
158
|
+
skip: FastForward,
|
|
159
|
+
watched: Clock,
|
|
160
|
+
watched_s: Clock,
|
|
161
|
+
saves_per_k: Bookmark,
|
|
162
|
+
shares_per_k: ShareNetwork,
|
|
163
|
+
comments_per_k: ChatCircleText,
|
|
164
|
+
saves: Bookmark,
|
|
165
|
+
shares: ShareNetwork,
|
|
166
|
+
comments: ChatCircleText,
|
|
167
|
+
interactions: Activity,
|
|
168
|
+
total_watch: Clock,
|
|
169
|
+
};
|
|
170
|
+
export const metricValue = (r: ReelMetrics, id: MetricId) => (r.current ? METRICS[id].of(r.current) : null);
|
|
171
|
+
|
|
172
|
+
/* a card's trend: "+12,3%" (or percentage points), up or down, good/bad/neutral */
|
|
173
|
+
export type Trend = { text: string; up: boolean; good: boolean | null };
|
|
174
|
+
export function variation(
|
|
175
|
+
value: number | null | undefined,
|
|
176
|
+
ref: number | null | undefined,
|
|
177
|
+
lowerIsBetter = false,
|
|
178
|
+
inPoints = false,
|
|
179
|
+
): Trend | null {
|
|
180
|
+
if (value == null || ref == null || (!inPoints && ref === 0)) return null;
|
|
181
|
+
const d = inPoints ? value - ref : ((value - ref) / ref) * 100;
|
|
182
|
+
if (Math.abs(d) < 0.05) return { text: inPoints ? "0 p.p." : "0%", up: true, good: null };
|
|
183
|
+
return {
|
|
184
|
+
text: `${d > 0 ? "+" : ""}${fmtNum(d, 1)}${inPoints ? " p.p." : "%"}`,
|
|
185
|
+
up: d > 0,
|
|
186
|
+
good: d > 0 !== lowerIsBetter,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/* --- charts ------------------------------------------------------------------------------ */
|
|
191
|
+
export const DAY_MS = 86_400_000;
|
|
192
|
+
export const axisProps = { tickLine: false, axisLine: false, tickMargin: 8 } as const;
|
|
193
|
+
/* no animation: the panel shows numbers, not an effect; and a background tab freezes
|
|
194
|
+
requestAnimationFrame, which left the chart stuck on the first frame */
|
|
195
|
+
export const noAnimation = { isAnimationActive: false } as const;
|
|
196
|
+
|
|
197
|
+
/* channel progression (dashboard-01's ChartAreaInteractive, as a wave line with area) */
|
|
198
|
+
export type ProgressionId = "views" | "comments" | "saves" | "followers";
|
|
199
|
+
export type Period = "24h" | "7d" | "30d";
|
|
200
|
+
export const PROGRESSION: { id: ProgressionId; name: string; description: string; Icon: IconComponent }[] = [
|
|
201
|
+
{ id: "views", name: "Views", description: "Views somadas de todos os Reels, a cada coleta", Icon: Eye },
|
|
202
|
+
{
|
|
203
|
+
id: "comments",
|
|
204
|
+
name: "Comentários",
|
|
205
|
+
description: "Comentários somados de todos os Reels, a cada coleta",
|
|
206
|
+
Icon: ChatCircleText,
|
|
207
|
+
},
|
|
208
|
+
{ id: "saves", name: "Salvos", description: "Salvos somados de todos os Reels, a cada coleta", Icon: Bookmark },
|
|
209
|
+
{ id: "followers", name: "Seguidores", description: "Seguidores da conta, a cada coleta", Icon: Users },
|
|
210
|
+
];
|
|
211
|
+
export const PERIODS: { id: Period; name: string; ms: number }[] = [
|
|
212
|
+
{ id: "24h", name: "24 h", ms: DAY_MS },
|
|
213
|
+
{ id: "7d", name: "7 dias", ms: 7 * DAY_MS },
|
|
214
|
+
{ id: "30d", name: "30 dias", ms: 30 * DAY_MS },
|
|
215
|
+
];
|
|
216
|
+
export const BAR_METRICS: MetricId[] = ["skip", "watched", "saves_per_k", "shares_per_k", "comments_per_k", "views"];
|
|
217
|
+
|
|
218
|
+
/* --- the Reels table ----------------------------------------------------------------------
|
|
219
|
+
A column's cell is `text(r)` (null → a muted "—"); with `metric`, the page adds VsMedian
|
|
220
|
+
(the comparison with the median) after the text. */
|
|
221
|
+
export type Column = {
|
|
222
|
+
id: string;
|
|
223
|
+
name: string;
|
|
224
|
+
value: (r: ReelMetrics) => number | string | null;
|
|
225
|
+
text: (r: ReelMetrics) => string | null;
|
|
226
|
+
metric?: MetricId;
|
|
227
|
+
num?: boolean;
|
|
228
|
+
default?: boolean;
|
|
229
|
+
};
|
|
230
|
+
export const metricColumn = (id: MetricId, isDefault = false, name = METRICS[id].name): Column => ({
|
|
231
|
+
id,
|
|
232
|
+
name,
|
|
233
|
+
default: isDefault,
|
|
234
|
+
num: true,
|
|
235
|
+
metric: id,
|
|
236
|
+
value: r => metricValue(r, id),
|
|
237
|
+
text: r => {
|
|
238
|
+
const v = metricValue(r, id);
|
|
239
|
+
return v == null ? "—" : METRICS[id].fmt(v);
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
export const COLUMNS: Column[] = [
|
|
243
|
+
{
|
|
244
|
+
id: "age",
|
|
245
|
+
name: "Idade",
|
|
246
|
+
default: true,
|
|
247
|
+
num: true,
|
|
248
|
+
value: r => r.current?.age_h ?? null,
|
|
249
|
+
text: r => fmtAge(r.current?.age_h),
|
|
250
|
+
},
|
|
251
|
+
metricColumn("views", true),
|
|
252
|
+
metricColumn("skip", true),
|
|
253
|
+
metricColumn("watched", true),
|
|
254
|
+
metricColumn("saves_per_k", true),
|
|
255
|
+
metricColumn("comments_per_k", true),
|
|
256
|
+
metricColumn("reach"),
|
|
257
|
+
metricColumn("likes"),
|
|
258
|
+
metricColumn("shares_per_k"),
|
|
259
|
+
metricColumn("watched_s"),
|
|
260
|
+
{ id: "duration", name: "Duração", num: true, value: r => r.duration_s, text: r => fmtSec(r.duration_s) },
|
|
261
|
+
{ id: "pillar", name: "Pilar", value: r => r.pillar, text: r => r.pillar },
|
|
262
|
+
{ id: "goal", name: "Objetivo", value: r => r.goal, text: r => r.goal },
|
|
263
|
+
];
|
|
264
|
+
export const PAGE_SIZE = 20;
|
|
265
|
+
/* the "all" option of the table filters */
|
|
266
|
+
export const ALL = "";
|
|
267
|
+
|
|
268
|
+
export const COMPARISON_ROWS: MetricId[] = [
|
|
269
|
+
"views",
|
|
270
|
+
"skip",
|
|
271
|
+
"watched",
|
|
272
|
+
"watched_s",
|
|
273
|
+
"saves_per_k",
|
|
274
|
+
"shares_per_k",
|
|
275
|
+
"comments_per_k",
|
|
276
|
+
"reach",
|
|
277
|
+
"likes",
|
|
278
|
+
];
|
|
279
|
+
|
|
280
|
+
/* --- insights and plan, from the last analysis (channel/analyses/<day>.md) ------------------- */
|
|
281
|
+
export type Section = { title: string; body: string };
|
|
282
|
+
export function sections(md: string): { intro: string; sections: Section[] } {
|
|
283
|
+
const parts = md.split(/^## /m);
|
|
284
|
+
return {
|
|
285
|
+
intro: parts[0],
|
|
286
|
+
sections: parts.slice(1).map(p => {
|
|
287
|
+
const i = p.indexOf("\n");
|
|
288
|
+
return { title: (i < 0 ? p : p.slice(0, i)).trim(), body: i < 0 ? "" : p.slice(i + 1).trim() };
|
|
289
|
+
}),
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/* "1. **Title.** evidence…": each item becomes an accordion; what comes after the list, a note */
|
|
294
|
+
export function numberedItems(body: string) {
|
|
295
|
+
const blocks = body.split(/^\d+\.\s+/m);
|
|
296
|
+
const items: { title: string; text: string }[] = [];
|
|
297
|
+
let rest = blocks[0].trim();
|
|
298
|
+
for (const b of blocks.slice(1)) {
|
|
299
|
+
const [item, ...after] = b.trim().split(/\n\s*\n/);
|
|
300
|
+
const m = /^\*\*(.+?)\*\*\s*([\s\S]*)$/.exec(item.trim());
|
|
301
|
+
items.push(
|
|
302
|
+
m ? { title: m[1].replace(/[.:]$/, ""), text: m[2] } : { title: shortLabel(item.trim(), 80), text: item.trim() },
|
|
303
|
+
);
|
|
304
|
+
if (after.length) rest = [rest, ...after].filter(Boolean).join("\n\n");
|
|
305
|
+
}
|
|
306
|
+
return { items, rest };
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export const POINTS_CONFIG = { reels: { label: "Reels", color: "var(--chart-1)" } } satisfies ChartConfig;
|
|
310
|
+
|
|
311
|
+
/* --- tabs ------------------------------------------------------------------------------------ */
|
|
312
|
+
export type ChannelTab = "reels" | "insights" | "plan" | "points";
|
|
313
|
+
export const CHANNEL_TABS: { id: ChannelTab; name: string; Icon: IconComponent }[] = [
|
|
314
|
+
{ id: "reels", name: "Reels", Icon: Table },
|
|
315
|
+
{ id: "insights", name: "Insights", Icon: Lightbulb },
|
|
316
|
+
{ id: "plan", name: "Plano", Icon: ListChecks },
|
|
317
|
+
{ id: "points", name: "Gancho × miolo", Icon: Target },
|
|
318
|
+
];
|
|
319
|
+
|
|
320
|
+
/* a Reel's hourly wave */
|
|
321
|
+
export const HOURS: MetricId[] = ["views", "reach", "skip", "watched", "saves", "shares", "comments"];
|
|
322
|
+
/* age on the axis: with a step under 1 h, the minutes (37 h 15); else like fmtAge() */
|
|
323
|
+
export const ageAxis = (h: number, step: number) =>
|
|
324
|
+
step < 1 && h < 48 ? `${Math.floor(h)} h ${String(Math.round((h % 1) * 60)).padStart(2, "0")}` : fmtAge(h);
|
|
325
|
+
|
|
326
|
+
export type ReelTab = "diagnosis" | "opening" | "milestones" | "script";
|
|
327
|
+
export const REEL_TABS: { id: ReelTab; name: string; Icon: IconComponent }[] = [
|
|
328
|
+
{ id: "diagnosis", name: "Diagnóstico", Icon: Microscope },
|
|
329
|
+
{ id: "opening", name: "Abertura", Icon: FilmStrip },
|
|
330
|
+
{ id: "milestones", name: "Marcos", Icon: Flag },
|
|
331
|
+
{ id: "script", name: "Roteiro", Icon: Notepad },
|
|
332
|
+
];
|
|
333
|
+
export const MILESTONES = ["1h", "3h", "24h", "72h", "7d", "30d"];
|
|
334
|
+
export const MILESTONE_LABEL: Record<string, string> = {
|
|
335
|
+
"1h": "1 h",
|
|
336
|
+
"3h": "3 h",
|
|
337
|
+
"24h": "24 h",
|
|
338
|
+
"72h": "72 h",
|
|
339
|
+
"7d": "7 dias",
|
|
340
|
+
"30d": "30 dias",
|
|
341
|
+
};
|
|
342
|
+
export const ALL_METRICS: MetricId[] = [
|
|
343
|
+
"reach",
|
|
344
|
+
"likes",
|
|
345
|
+
"interactions",
|
|
346
|
+
"comments",
|
|
347
|
+
"shares",
|
|
348
|
+
"saves",
|
|
349
|
+
"watched_s",
|
|
350
|
+
"total_watch",
|
|
351
|
+
];
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* The studio API client. `api` is typed end to end from the server's routes (hono/client over
|
|
2
|
+
api/app.ts's AppType): paths, params, query strings, JSON bodies and response bodies. Data the
|
|
3
|
+
UI keeps on screen goes through TanStack Query (hooks/*) with `read`; one-off actions use `send`.
|
|
4
|
+
Path params go through `enc` (hono/client doesn't encode them). */
|
|
5
|
+
|
|
6
|
+
import { hc, type ClientResponse } from "hono/client";
|
|
7
|
+
import type { AppType } from "../../api/app";
|
|
8
|
+
|
|
9
|
+
export const client = hc<AppType>("/");
|
|
10
|
+
export const api = client.api;
|
|
11
|
+
|
|
12
|
+
/* a path param as the URL carries it */
|
|
13
|
+
export const enc = encodeURIComponent;
|
|
14
|
+
|
|
15
|
+
/* the common response envelope of every POST */
|
|
16
|
+
export type ApiResponse = {
|
|
17
|
+
ok: boolean;
|
|
18
|
+
output?: string;
|
|
19
|
+
error?: string;
|
|
20
|
+
slug?: string;
|
|
21
|
+
session?: string;
|
|
22
|
+
id?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/* the last result of a save action, shown by ResultMessage; null = nothing yet */
|
|
26
|
+
export type ActionResult = { ok: boolean; output?: string; error?: string } | null;
|
|
27
|
+
|
|
28
|
+
type AnyResponse = ClientResponse<unknown, number, "json" | "text" | "redirect">;
|
|
29
|
+
/* the JSON body of a 200 (what `read` returns) / of any status (what `send` returns) */
|
|
30
|
+
export type OkJson<R> = R extends ClientResponse<infer T, infer S, "json"> ? (S extends 200 ? T : never) : never;
|
|
31
|
+
export type AnyJson<R> = R extends ClientResponse<infer T, number, "json"> ? T : never;
|
|
32
|
+
|
|
33
|
+
/* the hosted studio's answer while the studio isn't connected to it */
|
|
34
|
+
export class RunnerOffline extends Error {}
|
|
35
|
+
|
|
36
|
+
/* a GET's JSON; any other status throws "<status>: <body>" (RunnerOffline when the studio isn't connected) */
|
|
37
|
+
export async function read<R extends AnyResponse>(request: Promise<R>): Promise<OkJson<R>> {
|
|
38
|
+
const r = await request;
|
|
39
|
+
if (!r.ok) {
|
|
40
|
+
const body = await r.text();
|
|
41
|
+
/* the hosted studio without the studio connected (cloud/studio): the message the Worker wrote */
|
|
42
|
+
if (r.status === 503) {
|
|
43
|
+
try {
|
|
44
|
+
const j = JSON.parse(body);
|
|
45
|
+
if (j?.offline) throw new RunnerOffline(String(j.error));
|
|
46
|
+
} catch (e) {
|
|
47
|
+
if (e instanceof RunnerOffline) throw e;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
throw new Error(`${r.status}: ${body}`);
|
|
51
|
+
}
|
|
52
|
+
return (await r.json()) as OkJson<R>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* what a POST answers: the route's own JSON, read with the envelope's optional fields */
|
|
56
|
+
export type Envelope<R> = AnyJson<R> & ApiResponse;
|
|
57
|
+
|
|
58
|
+
/* a POST's envelope; never throws for an HTTP error: a body that isn't JSON (the plain 404, the
|
|
59
|
+
guard's 403/415) comes back as { ok: false, error: "<status>: <statusText>" } */
|
|
60
|
+
export async function send<R extends AnyResponse>(request: Promise<R>): Promise<Envelope<R>> {
|
|
61
|
+
const r = await request;
|
|
62
|
+
try {
|
|
63
|
+
return (await r.json()) as Envelope<R>;
|
|
64
|
+
} catch {
|
|
65
|
+
return { ok: false, error: `${r.status}: ${r.statusText}` } as Envelope<R>;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* the message of a caught error */
|
|
70
|
+
export const errorText = (e: unknown) => String((e as Error)?.message ?? e);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* Audio helpers shared by the players and the voice screens. */
|
|
2
|
+
|
|
3
|
+
let playingNow: HTMLAudioElement | null = null;
|
|
4
|
+
|
|
5
|
+
/* whoever starts playing pauses what was playing: also applies to the sequence player */
|
|
6
|
+
export function claimAudio(el: HTMLAudioElement) {
|
|
7
|
+
if (playingNow && playingNow !== el) playingNow.pause();
|
|
8
|
+
playingNow = el;
|
|
9
|
+
}
|
|
10
|
+
export function releaseAudio(el: HTMLAudioElement | null) {
|
|
11
|
+
if (playingNow === el) playingNow = null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* a chosen file's duration; a recorder's webm comes as Infinity and becomes 0 */
|
|
15
|
+
export function audioDuration(url: string): Promise<number> {
|
|
16
|
+
return new Promise(resolve => {
|
|
17
|
+
const a = new Audio();
|
|
18
|
+
a.preload = "metadata";
|
|
19
|
+
a.onloadedmetadata = () => resolve(Number.isFinite(a.duration) ? a.duration : 0);
|
|
20
|
+
a.onerror = () => resolve(0);
|
|
21
|
+
a.src = url;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let audioCtx: AudioContext | null = null;
|
|
26
|
+
/* the <audio> sound goes through the analyser and on to the output; null if the browser refuses */
|
|
27
|
+
export function createAudioAnalyser(a: HTMLAudioElement): AnalyserNode | null {
|
|
28
|
+
try {
|
|
29
|
+
audioCtx ??= new AudioContext();
|
|
30
|
+
if (audioCtx.state === "suspended") audioCtx.resume().catch(() => {});
|
|
31
|
+
const an = audioCtx.createAnalyser();
|
|
32
|
+
an.fftSize = 512;
|
|
33
|
+
audioCtx.createMediaElementSource(a).connect(an);
|
|
34
|
+
an.connect(audioCtx.destination);
|
|
35
|
+
return an;
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* Voice avatar seeds. The avatar is drawn from the voice id (always the same for the same voice). */
|
|
2
|
+
|
|
3
|
+
/* FNV-1a hash of a text: the avatar's seed */
|
|
4
|
+
export function seedOf(text: string) {
|
|
5
|
+
let h = 2166136261;
|
|
6
|
+
for (let i = 0; i < text.length; i++) {
|
|
7
|
+
h ^= text.charCodeAt(i);
|
|
8
|
+
h = Math.imul(h, 16777619);
|
|
9
|
+
}
|
|
10
|
+
return h >>> 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* mulberry32: a seeded random generator */
|
|
14
|
+
export function randomSeed(seed: number) {
|
|
15
|
+
let a = seed;
|
|
16
|
+
return () => {
|
|
17
|
+
a = (a + 0x6d2b79f5) | 0;
|
|
18
|
+
let t = Math.imul(a ^ (a >>> 15), 1 | a);
|
|
19
|
+
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
|
20
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* ten avatars, one per hue (36° apart), in shuffled order and each with a shuffled drawing */
|
|
25
|
+
export function shuffleAvatars(): string[] {
|
|
26
|
+
const hues = Array.from({ length: 10 }, (_, i) => (i * 36 + Math.floor(Math.random() * 12)) % 360);
|
|
27
|
+
for (let i = hues.length - 1; i > 0; i--) {
|
|
28
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
29
|
+
[hues[i], hues[j]] = [hues[j], hues[i]];
|
|
30
|
+
}
|
|
31
|
+
return hues.map(h => `h${h}-${Math.random().toString(36).slice(2, 8).padEnd(6, "0")}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* The orb's colors for a voice: three. The same hue the voice always had (the avatar picked when
|
|
35
|
+
cloning pins it with `h<hue>-`): a vivid main color, a lighter neighbor and a deeper one. */
|
|
36
|
+
export function orbPalette(seed: string): string[] {
|
|
37
|
+
const pinned = /^h(\d{1,3})-/.exec(seed);
|
|
38
|
+
const h = pinned ? Number(pinned[1]) % 360 : randomSeed(seedOf(seed))() * 360;
|
|
39
|
+
const hsl = (dh: number, s: number, l: number) => `hsl(${Math.round((h + dh + 360) % 360)} ${s}% ${l}%)`;
|
|
40
|
+
return [hsl(0, 96, 54), hsl(34, 100, 70), hsl(-30, 84, 40)];
|
|
41
|
+
}
|