@bendyline/squisq-editor-react 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (394) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +40 -0
  3. package/dist/index.d.ts +188 -55
  4. package/dist/index.js +5094 -2948
  5. package/dist/monaco.js +0 -1
  6. package/dist/styles/index.css +234 -145
  7. package/package.json +9 -6
  8. package/dist/index.js.map +0 -1
  9. package/dist/monaco.js.map +0 -1
  10. package/src/BlockCardView.tsx +0 -121
  11. package/src/BlockPreviewPanel.tsx +0 -69
  12. package/src/BlockPropertiesPopover.tsx +0 -222
  13. package/src/DocumentSettingsDialog.tsx +0 -272
  14. package/src/DropZoneOverlay.tsx +0 -137
  15. package/src/EditorContext.tsx +0 -1274
  16. package/src/EditorShell.tsx +0 -1358
  17. package/src/EmojiPicker.tsx +0 -332
  18. package/src/FolderView.tsx +0 -131
  19. package/src/Icon.tsx +0 -26
  20. package/src/ImageEditor.tsx +0 -395
  21. package/src/ImageNodeView.tsx +0 -284
  22. package/src/ImageViewer.tsx +0 -221
  23. package/src/InlineIcon.ts +0 -84
  24. package/src/InlinePreviewGutter.tsx +0 -590
  25. package/src/LinkDialog.tsx +0 -276
  26. package/src/MediaBin.tsx +0 -500
  27. package/src/MentionExtension.tsx +0 -261
  28. package/src/OutlinePanel.tsx +0 -547
  29. package/src/PlainHtmlPreview.tsx +0 -277
  30. package/src/PreviewControls.tsx +0 -1265
  31. package/src/PreviewPanel.tsx +0 -426
  32. package/src/RawEditor.tsx +0 -743
  33. package/src/RecorderEntry.tsx +0 -162
  34. package/src/StatusBar.tsx +0 -51
  35. package/src/TemplateAnnotation.ts +0 -167
  36. package/src/TemplateContentPreview.tsx +0 -56
  37. package/src/TemplatePicker.tsx +0 -1314
  38. package/src/ThemeCustomizerPanel.tsx +0 -304
  39. package/src/ThemePicker.tsx +0 -433
  40. package/src/TimelineBlockPreview.tsx +0 -37
  41. package/src/TimelineTrack.tsx +0 -671
  42. package/src/Toolbar.tsx +0 -2885
  43. package/src/Tooltip.tsx +0 -142
  44. package/src/TransitionPicker.tsx +0 -390
  45. package/src/VersionHistoryPanel.tsx +0 -359
  46. package/src/ViewMenuPanel.tsx +0 -189
  47. package/src/ViewSwitcher.tsx +0 -56
  48. package/src/WysiwygEditor.tsx +0 -806
  49. package/src/__tests__/blockProperties.test.ts +0 -92
  50. package/src/__tests__/blockPropertiesPopoverTheme.test.tsx +0 -33
  51. package/src/__tests__/blockRange.test.ts +0 -105
  52. package/src/__tests__/blockTagActivity.test.ts +0 -183
  53. package/src/__tests__/buildDocumentPreviewMarkdown.test.ts +0 -75
  54. package/src/__tests__/buildPreviewDocContent.test.ts +0 -65
  55. package/src/__tests__/buildPreviewDocTransition.test.ts +0 -92
  56. package/src/__tests__/canvasSurfaceTextEditing.test.tsx +0 -60
  57. package/src/__tests__/codeContextSectionView.test.tsx +0 -97
  58. package/src/__tests__/codeContextZoneManager.test.ts +0 -127
  59. package/src/__tests__/createShapeLayer.test.ts +0 -46
  60. package/src/__tests__/customLayoutManagerTheme.test.tsx +0 -34
  61. package/src/__tests__/detectMarkdown.test.ts +0 -73
  62. package/src/__tests__/diffContextSections.test.ts +0 -39
  63. package/src/__tests__/documentSettingsDialog.test.tsx +0 -197
  64. package/src/__tests__/drawingShapeRoundTrip.test.ts +0 -49
  65. package/src/__tests__/editorScrollHandoff.test.tsx +0 -102
  66. package/src/__tests__/editorScrollSync.test.ts +0 -65
  67. package/src/__tests__/editorShellCodeContext.test.tsx +0 -86
  68. package/src/__tests__/editorShellProps.test.tsx +0 -550
  69. package/src/__tests__/embeddedMedia.test.ts +0 -48
  70. package/src/__tests__/emojiPicker.test.tsx +0 -93
  71. package/src/__tests__/fileKind.test.ts +0 -112
  72. package/src/__tests__/findMode.test.tsx +0 -104
  73. package/src/__tests__/findModel.test.ts +0 -55
  74. package/src/__tests__/headingTransition.test.ts +0 -176
  75. package/src/__tests__/imageEditAffordance.test.tsx +0 -272
  76. package/src/__tests__/imageEditModalContract.test.tsx +0 -119
  77. package/src/__tests__/imageEditorShell.test.tsx +0 -94
  78. package/src/__tests__/imageEditorState.test.ts +0 -171
  79. package/src/__tests__/inlinePreviewGutter.test.tsx +0 -62
  80. package/src/__tests__/inlinePreviewGutterAllBlocks.test.tsx +0 -103
  81. package/src/__tests__/jsonEditor.test.tsx +0 -223
  82. package/src/__tests__/layersPanel.test.tsx +0 -167
  83. package/src/__tests__/layoutChildRoundTrip.test.ts +0 -71
  84. package/src/__tests__/linkDialogDocPicker.test.tsx +0 -137
  85. package/src/__tests__/majorApiTypes.test.ts +0 -26
  86. package/src/__tests__/markdownCodeFence.test.ts +0 -45
  87. package/src/__tests__/mediaAttachmentFlow.test.ts +0 -110
  88. package/src/__tests__/mediaBinDrop.test.tsx +0 -90
  89. package/src/__tests__/mediaReferences.test.ts +0 -97
  90. package/src/__tests__/narrationSave.test.ts +0 -148
  91. package/src/__tests__/outlinePanel.test.tsx +0 -169
  92. package/src/__tests__/outlineSource.test.ts +0 -217
  93. package/src/__tests__/plainHtmlPreview.test.tsx +0 -125
  94. package/src/__tests__/presentationMode.test.tsx +0 -290
  95. package/src/__tests__/previewControls.test.tsx +0 -571
  96. package/src/__tests__/previewPanelAudioFailure.test.tsx +0 -46
  97. package/src/__tests__/previewPanelPresentation.test.tsx +0 -126
  98. package/src/__tests__/previewPanelTransforms.test.tsx +0 -117
  99. package/src/__tests__/propertiesPanel.test.tsx +0 -69
  100. package/src/__tests__/rawEditorModelIsolation.test.ts +0 -19
  101. package/src/__tests__/recorderFormats.test.ts +0 -146
  102. package/src/__tests__/recorderMediaInsert.test.ts +0 -86
  103. package/src/__tests__/recorderTheme.test.tsx +0 -42
  104. package/src/__tests__/recorderTimingJson.test.ts +0 -41
  105. package/src/__tests__/resolveBlockVisual.test.ts +0 -43
  106. package/src/__tests__/selectionConversions.test.ts +0 -80
  107. package/src/__tests__/statusBar.test.tsx +0 -27
  108. package/src/__tests__/teleprompter.test.tsx +0 -190
  109. package/src/__tests__/templateAnnotationRoundTrip.test.ts +0 -99
  110. package/src/__tests__/templateContentPreview.test.ts +0 -101
  111. package/src/__tests__/templatePickerMetadata.test.ts +0 -32
  112. package/src/__tests__/templatePickerPortal.test.tsx +0 -62
  113. package/src/__tests__/timelineSource.test.ts +0 -134
  114. package/src/__tests__/tiptapBridge.test.ts +0 -575
  115. package/src/__tests__/tiptapBridgeConformance.test.ts +0 -47
  116. package/src/__tests__/tiptapCodeBlockRoundTrip.test.ts +0 -109
  117. package/src/__tests__/tiptapImageRoundTrip.test.ts +0 -73
  118. package/src/__tests__/toolbarSelectionConversion.test.tsx +0 -190
  119. package/src/__tests__/tooltip.test.tsx +0 -72
  120. package/src/__tests__/transformStyleId.test.ts +0 -13
  121. package/src/__tests__/transitionCatalog.test.ts +0 -64
  122. package/src/__tests__/useBlockNavigator.test.tsx +0 -67
  123. package/src/__tests__/useImageEditor.test.tsx +0 -226
  124. package/src/__tests__/useJsonEditorTokens.test.ts +0 -59
  125. package/src/__tests__/useMediaRecorder.test.ts +0 -302
  126. package/src/__tests__/useTimelineClock.test.ts +0 -21
  127. package/src/__tests__/versionHistory.test.tsx +0 -197
  128. package/src/__tests__/viewMenuPanel.test.tsx +0 -130
  129. package/src/__tests__/writeCanvasSettings.test.ts +0 -15
  130. package/src/__tests__/wysiwygImageUpload.test.ts +0 -69
  131. package/src/__tests__/wysiwygTemplateBadgeFocus.test.tsx +0 -56
  132. package/src/asciiDiagram/AsciiDiagramExtension.ts +0 -343
  133. package/src/asciiDiagram/AsciiDiagramWidget.tsx +0 -254
  134. package/src/asciiDiagram/RepairableDiagramExtension.ts +0 -200
  135. package/src/asciiDiagram/__tests__/AsciiDiagramExtension.test.ts +0 -164
  136. package/src/asciiDiagram/__tests__/RepairableDiagramExtension.test.ts +0 -159
  137. package/src/asciiDiagram/__tests__/asciiDiagramCommands.test.ts +0 -284
  138. package/src/asciiDiagram/__tests__/asciiDiagramOps.test.ts +0 -114
  139. package/src/asciiDiagram/__tests__/asciiPaste.test.ts +0 -43
  140. package/src/asciiDiagram/asciiDiagramCommands.ts +0 -174
  141. package/src/asciiDiagram/asciiDiagramData.ts +0 -149
  142. package/src/asciiDiagram/asciiDiagramOps.ts +0 -238
  143. package/src/asciiDiagram/asciiPaste.ts +0 -19
  144. package/src/blockProperties.ts +0 -88
  145. package/src/blockRange.ts +0 -132
  146. package/src/blockSlice.ts +0 -75
  147. package/src/blockTagActivity.ts +0 -233
  148. package/src/buildDocumentPreviewMarkdown.ts +0 -168
  149. package/src/buildPreviewDoc.ts +0 -407
  150. package/src/codeContext/CodeContextSectionView.tsx +0 -124
  151. package/src/codeContext/CodeContextZoneManager.ts +0 -149
  152. package/src/codeContext/CodeContextZones.tsx +0 -121
  153. package/src/codeContext/diffContextSections.ts +0 -38
  154. package/src/codeContext/types.ts +0 -75
  155. package/src/codeSnippet/CodeSnippetExtension.ts +0 -205
  156. package/src/codeSnippet/CodeSnippetWidget.tsx +0 -109
  157. package/src/codeSnippet/__tests__/CodeSnippetExtension.test.ts +0 -95
  158. package/src/codeSnippet/__tests__/codeSnippetLanguages.test.ts +0 -50
  159. package/src/codeSnippet/codeSnippetCommands.ts +0 -21
  160. package/src/codeSnippet/codeSnippetData.ts +0 -43
  161. package/src/codeSnippet/codeSnippetLanguages.ts +0 -216
  162. package/src/customTemplates/AddBin.tsx +0 -126
  163. package/src/customTemplates/CustomLayoutManager.tsx +0 -234
  164. package/src/customTemplates/CustomTemplateContext.tsx +0 -188
  165. package/src/customTemplates/LayerToolbar.tsx +0 -580
  166. package/src/customTemplates/ShapeGlyph.tsx +0 -47
  167. package/src/customTemplates/TemplateDesigner.tsx +0 -433
  168. package/src/customTemplates/__tests__/library.test.ts +0 -96
  169. package/src/customTemplates/__tests__/normalizePositions.test.ts +0 -109
  170. package/src/customTemplates/__tests__/shapeDefs.test.ts +0 -49
  171. package/src/customTemplates/__tests__/useMemoryLayerAdapter.test.ts +0 -108
  172. package/src/customTemplates/designer.css +0 -732
  173. package/src/customTemplates/index.ts +0 -31
  174. package/src/customTemplates/library.ts +0 -110
  175. package/src/customTemplates/normalizePositions.ts +0 -75
  176. package/src/customTemplates/shapeDefs.ts +0 -131
  177. package/src/customTemplates/thumbnail.tsx +0 -63
  178. package/src/customTemplates/tokenDefs.ts +0 -60
  179. package/src/customTemplates/useDocCustomTemplates.ts +0 -52
  180. package/src/customTemplates/useMemoryLayerAdapter.ts +0 -129
  181. package/src/customThemes/CustomThemeContext.tsx +0 -185
  182. package/src/customThemes/CustomThemeDialog.tsx +0 -316
  183. package/src/customThemes/ImportThemeSection.tsx +0 -178
  184. package/src/customThemes/__tests__/CustomThemeContext.test.tsx +0 -64
  185. package/src/customThemes/__tests__/CustomThemeDialog.test.tsx +0 -47
  186. package/src/customThemes/__tests__/customThemeLibrary.test.ts +0 -60
  187. package/src/customThemes/__tests__/importThemeSection.test.tsx +0 -192
  188. package/src/customThemes/customThemeLibrary.ts +0 -100
  189. package/src/customThemes/index.ts +0 -37
  190. package/src/customThemes/themeControls.tsx +0 -229
  191. package/src/customThemes/themeDraft.ts +0 -288
  192. package/src/customThemes/useDocCustomThemes.ts +0 -49
  193. package/src/detectMarkdown.ts +0 -62
  194. package/src/diagram/DiagramCanvas.tsx +0 -260
  195. package/src/diagram/DiagramMaximizedOverlay.tsx +0 -46
  196. package/src/diagram/diagramCommands.ts +0 -604
  197. package/src/diagram/diagramConstants.ts +0 -17
  198. package/src/diagram/types.ts +0 -35
  199. package/src/editorScrollSync.ts +0 -73
  200. package/src/embeddedMedia.ts +0 -78
  201. package/src/emojiData.ts +0 -1317
  202. package/src/fileKind.ts +0 -158
  203. package/src/find/FindHighlightExtension.ts +0 -81
  204. package/src/find/FindToolbar.tsx +0 -314
  205. package/src/find/findModel.ts +0 -77
  206. package/src/frontmatter.ts +0 -29
  207. package/src/frontmatterSettings.ts +0 -23
  208. package/src/headingTransition.ts +0 -291
  209. package/src/hooks/useFileDrop.ts +0 -266
  210. package/src/imageEditor/CanvasSurface.tsx +0 -703
  211. package/src/imageEditor/ImageVersionHistoryDropdown.tsx +0 -396
  212. package/src/imageEditor/LayersPanel.tsx +0 -218
  213. package/src/imageEditor/PropertiesPanel.tsx +0 -474
  214. package/src/imageEditor/Toolbar.tsx +0 -459
  215. package/src/imageEditor/createShapeLayer.ts +0 -280
  216. package/src/imageEditor/icons.tsx +0 -68
  217. package/src/imageEditor/image-editor.css +0 -574
  218. package/src/imageEditor/layers/EditorImageLayer.tsx +0 -45
  219. package/src/imageEditor/layers/EditorShapeLayer.tsx +0 -62
  220. package/src/imageEditor/layers/EditorTextLayer.tsx +0 -45
  221. package/src/imageEditor/layers/SelectionHandles.tsx +0 -86
  222. package/src/imageEditor/state.ts +0 -173
  223. package/src/imageEditor/useImageEditor.ts +0 -385
  224. package/src/imageEditor/useImageEditorTokens.ts +0 -70
  225. package/src/index.ts +0 -559
  226. package/src/jsonEditor/EmbeddedRichTextField.tsx +0 -81
  227. package/src/jsonEditor/JsonEditor.tsx +0 -81
  228. package/src/jsonEditor/JsonEditorContext.tsx +0 -81
  229. package/src/jsonEditor/RenderNode.tsx +0 -87
  230. package/src/jsonEditor/editors.tsx +0 -745
  231. package/src/jsonEditor/index.ts +0 -2
  232. package/src/jsonEditor/json-editor.css +0 -463
  233. package/src/jsonEditor/useJsonEditorTokens.ts +0 -33
  234. package/src/markdownCodeFence.ts +0 -72
  235. package/src/mediaDragMime.ts +0 -32
  236. package/src/mediaEntries.ts +0 -12
  237. package/src/mediaReferences.ts +0 -301
  238. package/src/mermaid/MermaidDiagramCanvas.tsx +0 -693
  239. package/src/mermaid/MermaidDiagramExtension.ts +0 -243
  240. package/src/mermaid/MermaidDiagramTypeThumbnail.tsx +0 -184
  241. package/src/mermaid/MermaidDiagramWidget.tsx +0 -653
  242. package/src/mermaid/MermaidShapePalette.tsx +0 -245
  243. package/src/mermaid/__tests__/MermaidDiagramExtension.test.ts +0 -361
  244. package/src/mermaid/__tests__/mermaidDiagramTypes.test.ts +0 -35
  245. package/src/mermaid/__tests__/mermaidRenderer.test.ts +0 -49
  246. package/src/mermaid/__tests__/mermaidSourceOps.test.ts +0 -213
  247. package/src/mermaid/__tests__/mermaidSyntax.test.ts +0 -71
  248. package/src/mermaid/mermaidCommands.ts +0 -34
  249. package/src/mermaid/mermaidData.ts +0 -31
  250. package/src/mermaid/mermaidDiagramTypes.ts +0 -325
  251. package/src/mermaid/mermaidModel.ts +0 -31
  252. package/src/mermaid/mermaidRenderer.ts +0 -181
  253. package/src/mermaid/mermaidShapes.ts +0 -113
  254. package/src/mermaid/mermaidSourceOps.ts +0 -454
  255. package/src/monaco.ts +0 -35
  256. package/src/monacoWorkers.ts +0 -89
  257. package/src/outlineSource.ts +0 -171
  258. package/src/presentation/PresentationMode.tsx +0 -596
  259. package/src/rawEditorIsolation.ts +0 -18
  260. package/src/recorder/RecorderButton.tsx +0 -80
  261. package/src/recorder/RecorderModal.tsx +0 -706
  262. package/src/recorder/RecorderPanel.tsx +0 -77
  263. package/src/recorder/formats.ts +0 -159
  264. package/src/recorder/hooks/useMediaRecorder.ts +0 -436
  265. package/src/recorder/hooks/useStreamPreview.ts +0 -47
  266. package/src/recorder/insertMediaBlock.ts +0 -30
  267. package/src/recorder/sources/cameraStream.ts +0 -32
  268. package/src/recorder/sources/micStream.ts +0 -25
  269. package/src/recorder/sources/screenStream.ts +0 -162
  270. package/src/recorder/timingJson.ts +0 -66
  271. package/src/resolveBlockVisual.ts +0 -39
  272. package/src/scene/Scene.tsx +0 -647
  273. package/src/scene/SceneBlockExtension.ts +0 -205
  274. package/src/scene/SceneBlockToolbar.tsx +0 -216
  275. package/src/scene/SceneBlockWidget.tsx +0 -441
  276. package/src/scene/ScenePropsBar.tsx +0 -85
  277. package/src/scene/SceneSelection.tsx +0 -111
  278. package/src/scene/SceneSideToolbar.tsx +0 -89
  279. package/src/scene/SceneViewControls.tsx +0 -43
  280. package/src/scene/SceneViewport.tsx +0 -106
  281. package/src/scene/ShapePalette.tsx +0 -196
  282. package/src/scene/__tests__/DiagramAdapter.test.ts +0 -142
  283. package/src/scene/__tests__/SceneBlockExtension.test.ts +0 -33
  284. package/src/scene/__tests__/bezierEdit.test.ts +0 -85
  285. package/src/scene/__tests__/blockLayers.test.ts +0 -57
  286. package/src/scene/__tests__/fitScale.test.ts +0 -19
  287. package/src/scene/__tests__/sceneIsolation.test.tsx +0 -119
  288. package/src/scene/__tests__/shapeLayers.test.ts +0 -106
  289. package/src/scene/__tests__/useSceneHitTest.test.ts +0 -90
  290. package/src/scene/__tests__/useScenePanZoom.test.ts +0 -130
  291. package/src/scene/adapters/DiagramAdapter.ts +0 -79
  292. package/src/scene/adapters/DrawingAdapter.ts +0 -420
  293. package/src/scene/adapters/LayoutAdapter.ts +0 -313
  294. package/src/scene/adapters/blockLayers.ts +0 -159
  295. package/src/scene/commands/SceneCommand.ts +0 -84
  296. package/src/scene/commands/drawingCommands.ts +0 -318
  297. package/src/scene/commands/layoutCommands.ts +0 -301
  298. package/src/scene/fitScale.ts +0 -17
  299. package/src/scene/hooks/useSceneHitTest.ts +0 -105
  300. package/src/scene/hooks/useScenePanZoom.ts +0 -154
  301. package/src/scene/hooks/useSceneSelection.ts +0 -62
  302. package/src/scene/index.ts +0 -90
  303. package/src/scene/layers/DiagramEdges.tsx +0 -142
  304. package/src/scene/layers/edgeGeometry.ts +0 -104
  305. package/src/scene/layers/nodeCard.tsx +0 -164
  306. package/src/scene/layers/renderLayer.tsx +0 -70
  307. package/src/scene/layers/shapeLayers.ts +0 -201
  308. package/src/scene/paths/bezierEdit.ts +0 -208
  309. package/src/scene/scene.css +0 -874
  310. package/src/scene/text/SceneTextOverlay.tsx +0 -161
  311. package/src/scene/text/sceneTextChannel.ts +0 -46
  312. package/src/scene/text/sceneTextConfig.ts +0 -31
  313. package/src/scene/text/sceneTiptap.ts +0 -36
  314. package/src/scene/text/useSceneTextEditing.ts +0 -39
  315. package/src/scene/tools/ConnectTool.ts +0 -209
  316. package/src/scene/tools/DrawingConnectTool.ts +0 -231
  317. package/src/scene/tools/PathTool.ts +0 -158
  318. package/src/scene/tools/PlaceTool.ts +0 -47
  319. package/src/scene/tools/SceneTool.ts +0 -85
  320. package/src/scene/tools/SelectTool.ts +0 -300
  321. package/src/scene/tools/ShapeTool.ts +0 -143
  322. package/src/scene/tools/TextTool.ts +0 -72
  323. package/src/scene/tools/TokenTool.ts +0 -95
  324. package/src/scene/tools/createDrawShapeTool.ts +0 -82
  325. package/src/selectionConversions.ts +0 -155
  326. package/src/styles/ascii-diagram.css +0 -79
  327. package/src/styles/ascii-timeline.css +0 -596
  328. package/src/styles/code-context.css +0 -155
  329. package/src/styles/code-snippet.css +0 -76
  330. package/src/styles/diagram.css +0 -183
  331. package/src/styles/editor.css +0 -7131
  332. package/src/styles/folder-view.css +0 -210
  333. package/src/styles/image-edit-affordance.css +0 -201
  334. package/src/styles/index.css +0 -20
  335. package/src/styles/mermaid-diagram.css +0 -487
  336. package/src/styles/tree-view.css +0 -189
  337. package/src/teleprompter/TeleprompterControls.tsx +0 -218
  338. package/src/teleprompter/TeleprompterSelfView.tsx +0 -22
  339. package/src/teleprompter/TeleprompterSurface.tsx +0 -267
  340. package/src/teleprompter/TeleprompterView.tsx +0 -338
  341. package/src/teleprompter/canvasRenderer.ts +0 -161
  342. package/src/teleprompter/floatingWindow.ts +0 -352
  343. package/src/teleprompter/index.ts +0 -61
  344. package/src/teleprompter/pcmWorklet.ts +0 -62
  345. package/src/teleprompter/recording/insertPreamble.ts +0 -80
  346. package/src/teleprompter/recording/narrationSave.ts +0 -134
  347. package/src/teleprompter/recording/useNarrationRecorder.ts +0 -367
  348. package/src/teleprompter/scrollModel.ts +0 -85
  349. package/src/teleprompter/teleprompterTheme.ts +0 -303
  350. package/src/teleprompter/types.ts +0 -38
  351. package/src/teleprompter/useFloatingWindow.ts +0 -74
  352. package/src/teleprompter/useMicAnalysis.ts +0 -211
  353. package/src/teleprompter/useTeleprompter.ts +0 -421
  354. package/src/templateContentPreviewResolver.ts +0 -360
  355. package/src/timeline/TimelineEditorWidget.tsx +0 -861
  356. package/src/timeline/TimelineViewExtension.ts +0 -252
  357. package/src/timeline/__tests__/TimelineEditorWidget.test.tsx +0 -414
  358. package/src/timeline/__tests__/TimelineViewExtension.test.ts +0 -163
  359. package/src/timeline/__tests__/timelineCommands.test.ts +0 -359
  360. package/src/timeline/__tests__/timelineOps.test.ts +0 -277
  361. package/src/timeline/__tests__/timelinePaste.test.ts +0 -34
  362. package/src/timeline/timelineCommands.ts +0 -421
  363. package/src/timeline/timelineData.ts +0 -54
  364. package/src/timeline/timelineOps.ts +0 -381
  365. package/src/timeline/timelinePaste.ts +0 -8
  366. package/src/timelineSource.ts +0 -244
  367. package/src/tiptap/TiptapAudio.tsx +0 -86
  368. package/src/tiptap/TiptapVideo.tsx +0 -119
  369. package/src/tiptap/useResolvedMediaSrc.ts +0 -47
  370. package/src/tiptapBridge.ts +0 -986
  371. package/src/tooltipPlacement.ts +0 -13
  372. package/src/transformStyleId.ts +0 -17
  373. package/src/transitionCatalog.ts +0 -159
  374. package/src/treeview/TreeOutlineWidget.tsx +0 -390
  375. package/src/treeview/TreeViewExtension.ts +0 -250
  376. package/src/treeview/__tests__/TreeOutlineWidget.test.tsx +0 -156
  377. package/src/treeview/__tests__/TreeViewExtension.test.ts +0 -122
  378. package/src/treeview/__tests__/treeOps.test.ts +0 -177
  379. package/src/treeview/__tests__/treePaste.test.ts +0 -40
  380. package/src/treeview/__tests__/treeViewCommands.test.ts +0 -179
  381. package/src/treeview/treeOps.ts +0 -231
  382. package/src/treeview/treePaste.ts +0 -13
  383. package/src/treeview/treeViewCommands.ts +0 -99
  384. package/src/treeview/treeViewData.ts +0 -41
  385. package/src/types/monaco-shims.d.ts +0 -10
  386. package/src/useBlockNavigator.ts +0 -153
  387. package/src/useHeadingLayout.ts +0 -294
  388. package/src/useMonacoLoader.ts +0 -82
  389. package/src/useTimelineClock.ts +0 -76
  390. package/src/utils/collectInlineFontAwesomeCss.ts +0 -69
  391. package/src/utils/dropUtils.ts +0 -136
  392. package/src/utils/normalizeMalformedAssetUrl.ts +0 -22
  393. package/src/writeCanvasSettings.ts +0 -30
  394. package/src/wysiwygImageUpload.ts +0 -113
@@ -1,352 +0,0 @@
1
- /**
2
- * Floating-teleprompter window manager — framework-free.
3
- *
4
- * Capability ladder, best first:
5
- * 1. `document-pip` — Document Picture-in-Picture (Chromium 116+,
6
- * Firefox 151+): a true always-on-top window hosting live DOM; the
7
- * React surface portals into it.
8
- * 2. `video-pip` — canvas → `captureStream(0)` → `<video>` →
9
- * `requestPictureInPicture()` (Safari's only always-on-top path;
10
- * `webkitSetPresentationMode` fallback). Read-only: the main
11
- * window draws frames and calls `requestFrame()` on analysis
12
- * ticks — never rAF, which throttles under occlusion.
13
- * 3. `popup` — `window.open` (positionable, not always-on-top).
14
- * 4. `docked` — no float.
15
- *
16
- * Every tier is feature-detected at open time and falls through to the
17
- * next on ANY failure. All interactive state stays in the main window;
18
- * floats are render targets only.
19
- */
20
-
21
- import type { FloatTier } from './types';
22
-
23
- interface DocumentPictureInPictureApi {
24
- requestWindow(options?: { width?: number; height?: number }): Promise<Window>;
25
- }
26
-
27
- interface WindowWithDocPip extends Window {
28
- documentPictureInPicture?: DocumentPictureInPictureApi;
29
- }
30
-
31
- interface WebKitVideoElement extends HTMLVideoElement {
32
- webkitSetPresentationMode?: (mode: 'picture-in-picture' | 'inline') => void;
33
- webkitSupportsPresentationMode?: (mode: string) => boolean;
34
- webkitPresentationMode?: string;
35
- }
36
-
37
- interface CaptureTrackWithRequestFrame extends MediaStreamTrack {
38
- requestFrame?: () => void;
39
- }
40
-
41
- export interface FloatOpenOptions {
42
- width: number;
43
- height: number;
44
- /** Try this tier first; the ladder continues below it on failure. */
45
- preferredTier?: FloatTier;
46
- title: string;
47
- }
48
-
49
- export interface CanvasSink {
50
- canvas: HTMLCanvasElement;
51
- width: number;
52
- height: number;
53
- /** Push the freshly drawn canvas frame into the PiP video. */
54
- requestFrame: () => void;
55
- }
56
-
57
- export type FloatEvent = 'closed' | 'tierchange';
58
-
59
- export interface FloatingWindowManager {
60
- readonly tier: FloatTier;
61
- readonly isOpen: boolean;
62
- /** Resolves with the tier that actually opened ('docked' if none could). */
63
- open(opts: FloatOpenOptions): Promise<FloatTier>;
64
- /** Idempotent; restores docked and emits 'closed'. */
65
- close(): void;
66
- /** Portal container for 'document-pip' | 'popup'; null otherwise. */
67
- getPortalTarget(): HTMLElement | null;
68
- /** Canvas sink for 'video-pip'; null otherwise. */
69
- getCanvasSink(): CanvasSink | null;
70
- on(event: FloatEvent, cb: (tier: FloatTier) => void): () => void;
71
- /** Tear everything down (unmount); like close() but silent-safe. */
72
- dispose(): void;
73
- }
74
-
75
- /** Feature-detect the available float tiers, best first. */
76
- export function detectFloatTiers(): FloatTier[] {
77
- const tiers: FloatTier[] = [];
78
- if (typeof window !== 'undefined' && typeof document !== 'undefined') {
79
- if ((window as WindowWithDocPip).documentPictureInPicture) tiers.push('document-pip');
80
- const video = document.createElement('video') as WebKitVideoElement;
81
- const stdPip =
82
- document.pictureInPictureEnabled === true &&
83
- typeof video.requestPictureInPicture === 'function';
84
- const webkitPip =
85
- typeof video.webkitSetPresentationMode === 'function' &&
86
- (video.webkitSupportsPresentationMode?.('picture-in-picture') ?? true);
87
- const canCapture =
88
- typeof HTMLCanvasElement !== 'undefined' &&
89
- typeof HTMLCanvasElement.prototype.captureStream === 'function';
90
- if ((stdPip || webkitPip) && canCapture) tiers.push('video-pip');
91
- if (typeof window.open === 'function') tiers.push('popup');
92
- }
93
- tiers.push('docked');
94
- return tiers;
95
- }
96
-
97
- interface ActiveFloat {
98
- tier: FloatTier;
99
- portalTarget: HTMLElement | null;
100
- canvasSink: CanvasSink | null;
101
- dispose: () => void;
102
- }
103
-
104
- export function createFloatingWindowManager(deps: { styleCss: string }): FloatingWindowManager {
105
- let active: ActiveFloat | null = null;
106
- const listeners: Record<FloatEvent, Set<(tier: FloatTier) => void>> = {
107
- closed: new Set(),
108
- tierchange: new Set(),
109
- };
110
-
111
- const emit = (event: FloatEvent, tier: FloatTier) => {
112
- for (const cb of listeners[event]) cb(tier);
113
- };
114
-
115
- /** Handles user-initiated closes (PiP ✕, popup close, navigation). */
116
- const handleExternalClose = () => {
117
- if (!active) return;
118
- const closing = active;
119
- active = null;
120
- closing.dispose();
121
- emit('tierchange', 'docked');
122
- emit('closed', 'docked');
123
- };
124
-
125
- const openerPageHide = () => manager.close();
126
- if (typeof window !== 'undefined') {
127
- window.addEventListener('pagehide', openerPageHide);
128
- }
129
-
130
- const writeFloatDocument = (doc: Document, title: string): HTMLElement => {
131
- doc.title = title;
132
- const style = doc.createElement('style');
133
- style.textContent = `${deps.styleCss}\nhtml,body{margin:0;height:100%;}#squisq-float-root{height:100%;display:flex;}`;
134
- doc.head.appendChild(style);
135
- const root = doc.createElement('div');
136
- root.id = 'squisq-float-root';
137
- doc.body.appendChild(root);
138
- return root;
139
- };
140
-
141
- const openDocumentPip = async (opts: FloatOpenOptions): Promise<ActiveFloat> => {
142
- const api = (window as WindowWithDocPip).documentPictureInPicture;
143
- if (!api) throw new Error('Document PiP unavailable');
144
- const pip = await api.requestWindow({ width: opts.width, height: opts.height });
145
- // Copy same-origin stylesheets so editor chrome vars resolve; the
146
- // injected styleCss below is what the surface actually depends on.
147
- for (const sheet of Array.from(document.styleSheets)) {
148
- try {
149
- const rules = Array.from(sheet.cssRules)
150
- .map((rule) => rule.cssText)
151
- .join('\n');
152
- const style = pip.document.createElement('style');
153
- style.textContent = rules;
154
- pip.document.head.appendChild(style);
155
- } catch {
156
- if (sheet.href) {
157
- const link = pip.document.createElement('link');
158
- link.rel = 'stylesheet';
159
- link.href = sheet.href;
160
- pip.document.head.appendChild(link);
161
- }
162
- }
163
- }
164
- const root = writeFloatDocument(pip.document, opts.title);
165
- pip.addEventListener('pagehide', handleExternalClose);
166
- return {
167
- tier: 'document-pip',
168
- portalTarget: root,
169
- canvasSink: null,
170
- dispose: () => {
171
- pip.removeEventListener('pagehide', handleExternalClose);
172
- try {
173
- pip.close();
174
- } catch {
175
- // Already closed by the user.
176
- }
177
- },
178
- };
179
- };
180
-
181
- const openVideoPip = async (opts: FloatOpenOptions): Promise<ActiveFloat> => {
182
- const canvas = document.createElement('canvas');
183
- canvas.width = Math.round(opts.width * (window.devicePixelRatio || 1));
184
- canvas.height = Math.round(opts.height * (window.devicePixelRatio || 1));
185
- const ctx = canvas.getContext('2d');
186
- if (!ctx || typeof canvas.captureStream !== 'function') {
187
- throw new Error('canvas.captureStream unavailable');
188
- }
189
- ctx.fillStyle = '#101014';
190
- ctx.fillRect(0, 0, canvas.width, canvas.height);
191
-
192
- let stream: MediaStream;
193
- let requestFrame: () => void;
194
- try {
195
- stream = canvas.captureStream(0);
196
- const track = stream.getVideoTracks()[0] as CaptureTrackWithRequestFrame;
197
- if (typeof track.requestFrame === 'function') {
198
- const pushFrame = track.requestFrame.bind(track);
199
- requestFrame = () => pushFrame();
200
- } else {
201
- // No manual-frame API: fall back to a 30 fps capture; draws still
202
- // happen on analysis ticks so content stays audio-clock driven.
203
- stream = canvas.captureStream(30);
204
- requestFrame = () => undefined;
205
- }
206
- } catch {
207
- stream = canvas.captureStream(30);
208
- requestFrame = () => undefined;
209
- }
210
-
211
- const video = document.createElement('video') as WebKitVideoElement;
212
- video.muted = true;
213
- video.playsInline = true;
214
- video.style.position = 'fixed';
215
- video.style.left = '-10000px';
216
- video.style.width = `${opts.width}px`;
217
- video.srcObject = stream;
218
- document.body.appendChild(video);
219
-
220
- const cleanupDom = () => {
221
- video.pause();
222
- video.srcObject = null;
223
- video.remove();
224
- for (const track of stream.getTracks()) track.stop();
225
- };
226
-
227
- try {
228
- await video.play();
229
- requestFrame();
230
- if (typeof video.requestPictureInPicture === 'function' && document.pictureInPictureEnabled) {
231
- await video.requestPictureInPicture();
232
- video.addEventListener('leavepictureinpicture', handleExternalClose);
233
- } else if (typeof video.webkitSetPresentationMode === 'function') {
234
- video.webkitSetPresentationMode('picture-in-picture');
235
- video.addEventListener('webkitpresentationmodechanged', () => {
236
- if (video.webkitPresentationMode === 'inline') handleExternalClose();
237
- });
238
- } else {
239
- throw new Error('No video PiP API');
240
- }
241
- } catch (err: unknown) {
242
- cleanupDom();
243
- throw err instanceof Error ? err : new Error(String(err));
244
- }
245
-
246
- return {
247
- tier: 'video-pip',
248
- portalTarget: null,
249
- canvasSink: { canvas, width: canvas.width, height: canvas.height, requestFrame },
250
- dispose: () => {
251
- video.removeEventListener('leavepictureinpicture', handleExternalClose);
252
- if (document.pictureInPictureElement === video) {
253
- void document.exitPictureInPicture().catch(() => undefined);
254
- } else if (
255
- typeof video.webkitSetPresentationMode === 'function' &&
256
- video.webkitPresentationMode === 'picture-in-picture'
257
- ) {
258
- video.webkitSetPresentationMode('inline');
259
- }
260
- cleanupDom();
261
- },
262
- };
263
- };
264
-
265
- const openPopup = (opts: FloatOpenOptions): ActiveFloat => {
266
- const popup = window.open(
267
- '',
268
- 'squisq-teleprompter',
269
- `popup=yes,width=${opts.width},height=${opts.height}`,
270
- );
271
- if (!popup) throw new Error('Popup blocked');
272
- const root = writeFloatDocument(popup.document, opts.title);
273
- popup.addEventListener('pagehide', handleExternalClose);
274
- popup.focus();
275
- return {
276
- tier: 'popup',
277
- portalTarget: root,
278
- canvasSink: null,
279
- dispose: () => {
280
- popup.removeEventListener('pagehide', handleExternalClose);
281
- try {
282
- popup.close();
283
- } catch {
284
- // Already closed.
285
- }
286
- },
287
- };
288
- };
289
-
290
- const manager: FloatingWindowManager = {
291
- get tier() {
292
- return active?.tier ?? 'docked';
293
- },
294
- get isOpen() {
295
- return active !== null;
296
- },
297
- async open(opts: FloatOpenOptions): Promise<FloatTier> {
298
- manager.close();
299
- const supported = detectFloatTiers();
300
- const ladder =
301
- opts.preferredTier && supported.includes(opts.preferredTier)
302
- ? [opts.preferredTier, ...supported.filter((t) => t !== opts.preferredTier)]
303
- : supported;
304
- for (const tier of ladder) {
305
- if (tier === 'docked') break;
306
- try {
307
- if (tier === 'document-pip') active = await openDocumentPip(opts);
308
- else if (tier === 'video-pip') active = await openVideoPip(opts);
309
- else if (tier === 'popup') active = openPopup(opts);
310
- if (active) {
311
- emit('tierchange', active.tier);
312
- return active.tier;
313
- }
314
- } catch {
315
- active = null; // fall through to the next tier
316
- }
317
- }
318
- emit('tierchange', 'docked');
319
- return 'docked';
320
- },
321
- close() {
322
- if (!active) return;
323
- const closing = active;
324
- active = null;
325
- closing.dispose();
326
- emit('tierchange', 'docked');
327
- emit('closed', 'docked');
328
- },
329
- getPortalTarget() {
330
- return active?.portalTarget ?? null;
331
- },
332
- getCanvasSink() {
333
- return active?.canvasSink ?? null;
334
- },
335
- on(event: FloatEvent, cb: (tier: FloatTier) => void) {
336
- listeners[event].add(cb);
337
- return () => {
338
- listeners[event].delete(cb);
339
- };
340
- },
341
- dispose() {
342
- manager.close();
343
- if (typeof window !== 'undefined') {
344
- window.removeEventListener('pagehide', openerPageHide);
345
- }
346
- listeners.closed.clear();
347
- listeners.tierchange.clear();
348
- },
349
- };
350
-
351
- return manager;
352
- }
@@ -1,61 +0,0 @@
1
- /**
2
- * Narrate (teleprompter) display mode — public surface.
3
- */
4
-
5
- export {
6
- TeleprompterView,
7
- type TeleprompterViewProps,
8
- type TeleprompterRecordingDeps,
9
- } from './TeleprompterView';
10
- export {
11
- useNarrationRecorder,
12
- type NarrationRecorderController,
13
- type NarrationRecorderState,
14
- type NarrationTake,
15
- } from './recording/useNarrationRecorder';
16
- export {
17
- buildNarrationSavePlan,
18
- executeNarrationSave,
19
- type NarrationSavePlan,
20
- type NarrationSaveResult,
21
- } from './recording/narrationSave';
22
- export {
23
- insertNarrationPreamble,
24
- narrationAnnotationLine,
25
- cameraVideoLine,
26
- } from './recording/insertPreamble';
27
- export { TeleprompterSurface, type TeleprompterSurfaceProps } from './TeleprompterSurface';
28
- export { TeleprompterControls, type TeleprompterControlsProps } from './TeleprompterControls';
29
- export {
30
- useTeleprompter,
31
- vadConfigForSensitivity,
32
- type TeleprompterController,
33
- } from './useTeleprompter';
34
- export { useMicAnalysis, type MicAnalysisHandle, type MicAnalysisStatus } from './useMicAnalysis';
35
- export { PCM_WORKLET_SOURCE, PCM_WORKLET_NAME, registerPcmWorklet } from './pcmWorklet';
36
- export {
37
- createFloatingWindowManager,
38
- detectFloatTiers,
39
- type FloatingWindowManager,
40
- type FloatOpenOptions,
41
- type CanvasSink,
42
- } from './floatingWindow';
43
- export { useFloatingWindow, type FloatingWindowHandle } from './useFloatingWindow';
44
- export {
45
- measureTokenLines,
46
- targetOffsetFor,
47
- stepScroll,
48
- EYE_LINE_FRACTION,
49
- type TokenLineMap,
50
- } from './scrollModel';
51
- export {
52
- TELEPROMPTER_CSS,
53
- ensureTeleprompterStyles,
54
- prompterVarsFromTheme,
55
- } from './teleprompterTheme';
56
- export {
57
- DEFAULT_TELEPROMPTER_PREFS,
58
- type TeleprompterPrefs,
59
- type PrompterTransport,
60
- type FloatTier,
61
- } from './types';
@@ -1,62 +0,0 @@
1
- /**
2
- * The PCM tap AudioWorklet, shipped as an inline source string.
3
- *
4
- * Why inline → Blob URL instead of a bundled asset: `audioWorklet
5
- * .addModule(url)` resolves relative to the host DOCUMENT, so a
6
- * dist-relative asset would need every consumer's bundler to rewrite
7
- * and serve it (editor-react ships zero runtime assets today). The
8
- * worklet is ~30 lines with no imports; inlining follows the
9
- * `PLAYER_BUNDLE` source-string precedent and needs zero bundler
10
- * config. The worklet does NO DSP — it batches 128-sample render
11
- * quanta into 1024-sample frames and posts them (transferably) to the
12
- * main thread, where the pure engine in `@bendyline/squisq/narration`
13
- * runs. The audio render thread never throttles, so pacing keeps
14
- * working while the browser window is fully occluded by recording
15
- * software — the whole point of the teleprompter's scenario 2.
16
- */
17
-
18
- export const PCM_WORKLET_NAME = 'squisq-pcm-tap';
19
-
20
- export const PCM_WORKLET_SOURCE = `
21
- class SquisqPcmTap extends AudioWorkletProcessor {
22
- constructor() {
23
- super();
24
- this._buf = new Float32Array(1024);
25
- this._len = 0;
26
- }
27
- process(inputs) {
28
- const channel = inputs[0] && inputs[0][0];
29
- if (channel && channel.length > 0) {
30
- let i = 0;
31
- while (i < channel.length) {
32
- const n = Math.min(channel.length - i, this._buf.length - this._len);
33
- this._buf.set(channel.subarray(i, i + n), this._len);
34
- this._len += n;
35
- i += n;
36
- if (this._len === this._buf.length) {
37
- const out = this._buf;
38
- this._buf = new Float32Array(1024);
39
- this._len = 0;
40
- // Clone, don't transfer: Chrome recycles buffers transferred out
41
- // of the worklet scope once the receiving handler returns, so a
42
- // transferred hop reads as zeros if anything retains it. A 4 KB
43
- // structured clone at ~47 Hz is negligible.
44
- this.port.postMessage({ pcm: out, audioTime: currentTime });
45
- }
46
- }
47
- }
48
- return true;
49
- }
50
- }
51
- registerProcessor('${PCM_WORKLET_NAME}', SquisqPcmTap);
52
- `;
53
-
54
- /** Register the tap on an AudioContext via a same-origin Blob URL. */
55
- export async function registerPcmWorklet(ctx: AudioContext): Promise<void> {
56
- const url = URL.createObjectURL(new Blob([PCM_WORKLET_SOURCE], { type: 'text/javascript' }));
57
- try {
58
- await ctx.audioWorklet.addModule(url);
59
- } finally {
60
- URL.revokeObjectURL(url);
61
- }
62
- }
@@ -1,80 +0,0 @@
1
- /**
2
- * Pure markdown edit: insert (or replace) the narration reference at the
3
- * start of the document.
4
- *
5
- * The narration take is referenced by a preamble media annotation —
6
- * `{[audio src=audio/narration-….webm anchor=document]}` — the canonical
7
- * authored form `markdownToDoc` lifts into `doc.documentMedia`. A prior
8
- * teleprompter take's line (matched by the `audio/narration-` prefix +
9
- * `anchor=document`) is replaced, so retakes swap the reference instead
10
- * of stacking narrations. The optional camera companion rides on the
11
- * next line as an inline `<video>` (deliberately NOT doc-anchored:
12
- * document-anchored video renders full-bleed behind every block and is
13
- * excluded from export audio — not a talking head).
14
- */
15
-
16
- const NARRATION_LINE =
17
- /^\{\[audio\s[^\]]*src="?audio\/narration-[^\]]*anchor=document[^\]]*\]\}\s*$/;
18
- const CAMERA_LINE = /^<video\s[^>]*src="video\/narration-cam-[^"]*"[^>]*><\/video>\s*$/;
19
-
20
- function quoteSrc(path: string): string {
21
- return /[\s"']/.test(path) ? `"${path.replace(/"/g, '\\"')}"` : path;
22
- }
23
-
24
- export function narrationAnnotationLine(audioPath: string): string {
25
- return `{[audio src=${quoteSrc(audioPath)} anchor=document]}`;
26
- }
27
-
28
- export function cameraVideoLine(cameraPath: string): string {
29
- return `<video src="${cameraPath}" controls width="240"></video>`;
30
- }
31
-
32
- /**
33
- * Insert the narration preamble after the frontmatter (or at the top),
34
- * replacing any previous teleprompter take's lines.
35
- */
36
- export function insertNarrationPreamble(
37
- source: string,
38
- audioPath: string,
39
- cameraPath: string | null,
40
- ): string {
41
- const lines = source.split('\n');
42
-
43
- // Locate the insertion point: after a closing frontmatter fence.
44
- let insertAt = 0;
45
- if (lines[0]?.trim() === '---') {
46
- for (let i = 1; i < lines.length; i++) {
47
- if (lines[i].trim() === '---') {
48
- insertAt = i + 1;
49
- break;
50
- }
51
- }
52
- }
53
-
54
- // Remove a previous take's annotation (+ adjacent camera line).
55
- for (let i = 0; i < lines.length; i++) {
56
- if (!NARRATION_LINE.test(lines[i])) continue;
57
- let removeEnd = i + 1;
58
- while (removeEnd < lines.length && lines[removeEnd].trim() === '') removeEnd++;
59
- if (removeEnd < lines.length && CAMERA_LINE.test(lines[removeEnd])) removeEnd++;
60
- // Also consume one trailing blank so we don't accumulate gaps.
61
- if (removeEnd < lines.length && lines[removeEnd].trim() === '') removeEnd++;
62
- lines.splice(i, removeEnd - i);
63
- if (insertAt > i) insertAt = Math.max(0, insertAt - (removeEnd - i));
64
- break;
65
- }
66
-
67
- const inserted: string[] = [narrationAnnotationLine(audioPath)];
68
- if (cameraPath) {
69
- inserted.push('', cameraVideoLine(cameraPath));
70
- }
71
-
72
- // Blank-line separation on both sides (unless at the very top with
73
- // content immediately following, where only the trailing blank matters).
74
- const before = lines.slice(0, insertAt);
75
- const after = lines.slice(insertAt);
76
- if (before.length > 0 && before[before.length - 1].trim() !== '') before.push('');
77
- if (after.length > 0 && after[0].trim() !== '') inserted.push('');
78
-
79
- return [...before, ...inserted, ...after].join('\n');
80
- }
@@ -1,134 +0,0 @@
1
- /**
2
- * Pure save-plan builder for a narration take, plus its executor.
3
- *
4
- * Follows the recorder's conventions (`RecorderModal.handleSave`):
5
- * audio at `audio/<narration-…>` via `MediaProvider.addMedia` (the
6
- * RETURNED path is authoritative — providers may rename), the timing
7
- * sidecar at `<audio>.timing.json` via `container.writeFile` (falling
8
- * back to `addMedia` with a warning), and ONE `setMarkdownSource` write
9
- * composing every markdown edit from a single snapshot (the single-write
10
- * rule — successive writes each derive from stale source and clobber
11
- * each other).
12
- *
13
- * Block timings deliberately do NOT get baked into heading `duration=`
14
- * pins: pins outrank narration in `applyNarrationTiming`, so baking
15
- * them would shadow every retake. The sidecar owns the timing.
16
- */
17
-
18
- import {
19
- buildNarrationTimingJson,
20
- type NarrationAlignment,
21
- type NarrationScript,
22
- type NarrationTimingJsonV3,
23
- } from '@bendyline/squisq/narration';
24
- import type { MediaProvider } from '@bendyline/squisq/schemas';
25
- import type { ContentContainer } from '@bendyline/squisq/storage';
26
- import { buildFilename } from '../../recorder/formats';
27
- import { encodeTimingJson, timingPathFor } from '../../recorder/timingJson';
28
- import { insertNarrationPreamble } from './insertPreamble';
29
-
30
- export interface NarrationSavePlanArgs {
31
- script: NarrationScript;
32
- /** Null when decode/alignment failed — the sidecar still saves (empty timing). */
33
- alignment: NarrationAlignment | null;
34
- durationSec: number;
35
- audioExt: string;
36
- cameraExt: string | null;
37
- baseWpm: number;
38
- cameraOffsetSec?: number;
39
- }
40
-
41
- export interface NarrationSavePlan {
42
- audioRelativeName: string;
43
- cameraRelativeName: string | null;
44
- sidecarPayload: NarrationTimingJsonV3;
45
- /** Sidecar path for a given (possibly renamed) saved audio path. */
46
- sidecarPathFor: (savedAudioPath: string) => string;
47
- /** Compose ALL markdown edits from one source snapshot. */
48
- nextMarkdown: (
49
- currentSource: string,
50
- savedAudioPath: string,
51
- savedCameraPath: string | null,
52
- ) => string;
53
- }
54
-
55
- export function buildNarrationSavePlan(args: NarrationSavePlanArgs): NarrationSavePlan {
56
- const sidecarPayload: NarrationTimingJsonV3 = args.alignment
57
- ? buildNarrationTimingJson(args.script, args.alignment, args.durationSec, {
58
- baseWpm: args.baseWpm,
59
- ...(args.cameraOffsetSec !== undefined ? { cameraOffsetSec: args.cameraOffsetSec } : {}),
60
- })
61
- : {
62
- version: 3,
63
- sourceText: args.script.sourceText,
64
- duration: args.durationSec,
65
- bookmarks: [],
66
- blocks: [],
67
- generator: { name: 'squisq-teleprompter', method: 'dsp-align', baseWpm: args.baseWpm },
68
- };
69
-
70
- return {
71
- audioRelativeName: `audio/${buildFilename('audio', args.audioExt)}`,
72
- cameraRelativeName: args.cameraExt
73
- ? `video/${buildFilename('video', args.cameraExt, 'narration-cam')}`
74
- : null,
75
- sidecarPayload,
76
- sidecarPathFor: (savedAudioPath) => timingPathFor(savedAudioPath),
77
- nextMarkdown: (currentSource, savedAudioPath, savedCameraPath) =>
78
- insertNarrationPreamble(currentSource, savedAudioPath, savedCameraPath),
79
- };
80
- }
81
-
82
- export interface ExecuteNarrationSaveDeps {
83
- mediaProvider: MediaProvider;
84
- container: ContentContainer | null;
85
- markdownSource: string;
86
- setMarkdownSource: (next: string) => void;
87
- bumpMediaRevision: () => void;
88
- }
89
-
90
- export interface NarrationSaveResult {
91
- audioPath: string;
92
- cameraPath: string | null;
93
- sidecarPath: string;
94
- }
95
-
96
- /** Execute a save plan: media writes, sidecar, then the single markdown write. */
97
- export async function executeNarrationSave(
98
- plan: NarrationSavePlan,
99
- take: { audioBlob: Blob; audioMime: string; cameraBlob: Blob | null; cameraMime: string | null },
100
- deps: ExecuteNarrationSaveDeps,
101
- ): Promise<NarrationSaveResult> {
102
- const audioPath = await deps.mediaProvider.addMedia(
103
- plan.audioRelativeName,
104
- take.audioBlob,
105
- take.audioMime,
106
- );
107
-
108
- const sidecarPath = plan.sidecarPathFor(audioPath);
109
- const encoded = encodeTimingJson(plan.sidecarPayload);
110
- if (deps.container) {
111
- await deps.container.writeFile(sidecarPath, encoded, 'application/json');
112
- } else {
113
- const storedAt = await deps.mediaProvider.addMedia(sidecarPath, encoded, 'application/json');
114
- if (storedAt !== sidecarPath) {
115
- console.warn(
116
- `Narration timing sidecar stored at "${storedAt}" instead of "${sidecarPath}"; ` +
117
- 'narration timing will not be discovered until it sits next to the audio file.',
118
- );
119
- }
120
- }
121
-
122
- let cameraPath: string | null = null;
123
- if (plan.cameraRelativeName && take.cameraBlob && take.cameraMime) {
124
- cameraPath = await deps.mediaProvider.addMedia(
125
- plan.cameraRelativeName,
126
- take.cameraBlob,
127
- take.cameraMime,
128
- );
129
- }
130
-
131
- deps.setMarkdownSource(plan.nextMarkdown(deps.markdownSource, audioPath, cameraPath));
132
- deps.bumpMediaRevision();
133
- return { audioPath, cameraPath, sidecarPath };
134
- }