@bendyline/squisq-editor-react 2.1.0 → 2.3.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 (415) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +40 -0
  3. package/dist/chunk-54UGTQBO.js +862 -0
  4. package/dist/chunk-5JMHFAVW.js +2408 -0
  5. package/dist/chunk-5Q4JN4I5.js +132 -0
  6. package/dist/chunk-6VDYKI3L.js +49 -0
  7. package/dist/chunk-GS7QWYFT.js +9 -0
  8. package/dist/chunk-MJJK7YQB.js +949 -0
  9. package/dist/chunk-NITZVAXL.js +986 -0
  10. package/dist/chunk-TRCKHRBS.js +35234 -0
  11. package/dist/chunk-V44VP242.js +3256 -0
  12. package/dist/image-editor/index.d.ts +223 -0
  13. package/dist/image-editor/index.js +15 -0
  14. package/dist/index.d.ts +2060 -4040
  15. package/dist/index.js +496 -40014
  16. package/dist/json-editor/index.d.ts +27 -0
  17. package/dist/json-editor/index.js +7 -0
  18. package/dist/monaco.d.ts +1 -1
  19. package/dist/monaco.js +1 -2
  20. package/dist/recorder/index.d.ts +407 -0
  21. package/dist/recorder/index.js +43 -0
  22. package/dist/shell/index.d.ts +9 -0
  23. package/dist/shell/index.js +22 -0
  24. package/dist/shell-BxSCBm4H.d.ts +1064 -0
  25. package/dist/styles/index.css +598 -161
  26. package/dist/teleprompter/index.d.ts +497 -0
  27. package/dist/teleprompter/index.js +57 -0
  28. package/package.json +34 -8
  29. package/dist/index.js.map +0 -1
  30. package/dist/monaco.js.map +0 -1
  31. package/src/BlockCardView.tsx +0 -121
  32. package/src/BlockPreviewPanel.tsx +0 -69
  33. package/src/BlockPropertiesPopover.tsx +0 -222
  34. package/src/DocumentSettingsDialog.tsx +0 -272
  35. package/src/DropZoneOverlay.tsx +0 -137
  36. package/src/EditorContext.tsx +0 -1274
  37. package/src/EditorShell.tsx +0 -1358
  38. package/src/EmojiPicker.tsx +0 -332
  39. package/src/FolderView.tsx +0 -131
  40. package/src/Icon.tsx +0 -26
  41. package/src/ImageEditor.tsx +0 -395
  42. package/src/ImageNodeView.tsx +0 -284
  43. package/src/ImageViewer.tsx +0 -221
  44. package/src/InlineIcon.ts +0 -84
  45. package/src/InlinePreviewGutter.tsx +0 -590
  46. package/src/LinkDialog.tsx +0 -276
  47. package/src/MediaBin.tsx +0 -500
  48. package/src/MentionExtension.tsx +0 -261
  49. package/src/OutlinePanel.tsx +0 -547
  50. package/src/PlainHtmlPreview.tsx +0 -277
  51. package/src/PreviewControls.tsx +0 -1265
  52. package/src/PreviewPanel.tsx +0 -426
  53. package/src/RawEditor.tsx +0 -743
  54. package/src/RecorderEntry.tsx +0 -162
  55. package/src/StatusBar.tsx +0 -51
  56. package/src/TemplateAnnotation.ts +0 -167
  57. package/src/TemplateContentPreview.tsx +0 -56
  58. package/src/TemplatePicker.tsx +0 -1314
  59. package/src/ThemeCustomizerPanel.tsx +0 -304
  60. package/src/ThemePicker.tsx +0 -433
  61. package/src/TimelineBlockPreview.tsx +0 -37
  62. package/src/TimelineTrack.tsx +0 -671
  63. package/src/Toolbar.tsx +0 -2885
  64. package/src/Tooltip.tsx +0 -142
  65. package/src/TransitionPicker.tsx +0 -390
  66. package/src/VersionHistoryPanel.tsx +0 -359
  67. package/src/ViewMenuPanel.tsx +0 -189
  68. package/src/ViewSwitcher.tsx +0 -56
  69. package/src/WysiwygEditor.tsx +0 -806
  70. package/src/__tests__/blockProperties.test.ts +0 -92
  71. package/src/__tests__/blockPropertiesPopoverTheme.test.tsx +0 -33
  72. package/src/__tests__/blockRange.test.ts +0 -105
  73. package/src/__tests__/blockTagActivity.test.ts +0 -183
  74. package/src/__tests__/buildDocumentPreviewMarkdown.test.ts +0 -75
  75. package/src/__tests__/buildPreviewDocContent.test.ts +0 -65
  76. package/src/__tests__/buildPreviewDocTransition.test.ts +0 -92
  77. package/src/__tests__/canvasSurfaceTextEditing.test.tsx +0 -60
  78. package/src/__tests__/codeContextSectionView.test.tsx +0 -97
  79. package/src/__tests__/codeContextZoneManager.test.ts +0 -127
  80. package/src/__tests__/createShapeLayer.test.ts +0 -46
  81. package/src/__tests__/customLayoutManagerTheme.test.tsx +0 -34
  82. package/src/__tests__/detectMarkdown.test.ts +0 -73
  83. package/src/__tests__/diffContextSections.test.ts +0 -39
  84. package/src/__tests__/documentSettingsDialog.test.tsx +0 -197
  85. package/src/__tests__/drawingShapeRoundTrip.test.ts +0 -49
  86. package/src/__tests__/editorScrollHandoff.test.tsx +0 -102
  87. package/src/__tests__/editorScrollSync.test.ts +0 -65
  88. package/src/__tests__/editorShellCodeContext.test.tsx +0 -86
  89. package/src/__tests__/editorShellProps.test.tsx +0 -550
  90. package/src/__tests__/embeddedMedia.test.ts +0 -48
  91. package/src/__tests__/emojiPicker.test.tsx +0 -93
  92. package/src/__tests__/fileKind.test.ts +0 -112
  93. package/src/__tests__/findMode.test.tsx +0 -104
  94. package/src/__tests__/findModel.test.ts +0 -55
  95. package/src/__tests__/headingTransition.test.ts +0 -176
  96. package/src/__tests__/imageEditAffordance.test.tsx +0 -272
  97. package/src/__tests__/imageEditModalContract.test.tsx +0 -119
  98. package/src/__tests__/imageEditorShell.test.tsx +0 -94
  99. package/src/__tests__/imageEditorState.test.ts +0 -171
  100. package/src/__tests__/inlinePreviewGutter.test.tsx +0 -62
  101. package/src/__tests__/inlinePreviewGutterAllBlocks.test.tsx +0 -103
  102. package/src/__tests__/jsonEditor.test.tsx +0 -223
  103. package/src/__tests__/layersPanel.test.tsx +0 -167
  104. package/src/__tests__/layoutChildRoundTrip.test.ts +0 -71
  105. package/src/__tests__/linkDialogDocPicker.test.tsx +0 -137
  106. package/src/__tests__/majorApiTypes.test.ts +0 -26
  107. package/src/__tests__/markdownCodeFence.test.ts +0 -45
  108. package/src/__tests__/mediaAttachmentFlow.test.ts +0 -110
  109. package/src/__tests__/mediaBinDrop.test.tsx +0 -90
  110. package/src/__tests__/mediaReferences.test.ts +0 -97
  111. package/src/__tests__/narrationSave.test.ts +0 -148
  112. package/src/__tests__/outlinePanel.test.tsx +0 -169
  113. package/src/__tests__/outlineSource.test.ts +0 -217
  114. package/src/__tests__/plainHtmlPreview.test.tsx +0 -125
  115. package/src/__tests__/presentationMode.test.tsx +0 -290
  116. package/src/__tests__/previewControls.test.tsx +0 -571
  117. package/src/__tests__/previewPanelAudioFailure.test.tsx +0 -46
  118. package/src/__tests__/previewPanelPresentation.test.tsx +0 -126
  119. package/src/__tests__/previewPanelTransforms.test.tsx +0 -117
  120. package/src/__tests__/propertiesPanel.test.tsx +0 -69
  121. package/src/__tests__/rawEditorModelIsolation.test.ts +0 -19
  122. package/src/__tests__/recorderFormats.test.ts +0 -146
  123. package/src/__tests__/recorderMediaInsert.test.ts +0 -86
  124. package/src/__tests__/recorderTheme.test.tsx +0 -42
  125. package/src/__tests__/recorderTimingJson.test.ts +0 -41
  126. package/src/__tests__/resolveBlockVisual.test.ts +0 -43
  127. package/src/__tests__/selectionConversions.test.ts +0 -80
  128. package/src/__tests__/statusBar.test.tsx +0 -27
  129. package/src/__tests__/teleprompter.test.tsx +0 -190
  130. package/src/__tests__/templateAnnotationRoundTrip.test.ts +0 -99
  131. package/src/__tests__/templateContentPreview.test.ts +0 -101
  132. package/src/__tests__/templatePickerMetadata.test.ts +0 -32
  133. package/src/__tests__/templatePickerPortal.test.tsx +0 -62
  134. package/src/__tests__/timelineSource.test.ts +0 -134
  135. package/src/__tests__/tiptapBridge.test.ts +0 -575
  136. package/src/__tests__/tiptapBridgeConformance.test.ts +0 -47
  137. package/src/__tests__/tiptapCodeBlockRoundTrip.test.ts +0 -109
  138. package/src/__tests__/tiptapImageRoundTrip.test.ts +0 -73
  139. package/src/__tests__/toolbarSelectionConversion.test.tsx +0 -190
  140. package/src/__tests__/tooltip.test.tsx +0 -72
  141. package/src/__tests__/transformStyleId.test.ts +0 -13
  142. package/src/__tests__/transitionCatalog.test.ts +0 -64
  143. package/src/__tests__/useBlockNavigator.test.tsx +0 -67
  144. package/src/__tests__/useImageEditor.test.tsx +0 -226
  145. package/src/__tests__/useJsonEditorTokens.test.ts +0 -59
  146. package/src/__tests__/useMediaRecorder.test.ts +0 -302
  147. package/src/__tests__/useTimelineClock.test.ts +0 -21
  148. package/src/__tests__/versionHistory.test.tsx +0 -197
  149. package/src/__tests__/viewMenuPanel.test.tsx +0 -130
  150. package/src/__tests__/writeCanvasSettings.test.ts +0 -15
  151. package/src/__tests__/wysiwygImageUpload.test.ts +0 -69
  152. package/src/__tests__/wysiwygTemplateBadgeFocus.test.tsx +0 -56
  153. package/src/asciiDiagram/AsciiDiagramExtension.ts +0 -343
  154. package/src/asciiDiagram/AsciiDiagramWidget.tsx +0 -254
  155. package/src/asciiDiagram/RepairableDiagramExtension.ts +0 -200
  156. package/src/asciiDiagram/__tests__/AsciiDiagramExtension.test.ts +0 -164
  157. package/src/asciiDiagram/__tests__/RepairableDiagramExtension.test.ts +0 -159
  158. package/src/asciiDiagram/__tests__/asciiDiagramCommands.test.ts +0 -284
  159. package/src/asciiDiagram/__tests__/asciiDiagramOps.test.ts +0 -114
  160. package/src/asciiDiagram/__tests__/asciiPaste.test.ts +0 -43
  161. package/src/asciiDiagram/asciiDiagramCommands.ts +0 -174
  162. package/src/asciiDiagram/asciiDiagramData.ts +0 -149
  163. package/src/asciiDiagram/asciiDiagramOps.ts +0 -238
  164. package/src/asciiDiagram/asciiPaste.ts +0 -19
  165. package/src/blockProperties.ts +0 -88
  166. package/src/blockRange.ts +0 -132
  167. package/src/blockSlice.ts +0 -75
  168. package/src/blockTagActivity.ts +0 -233
  169. package/src/buildDocumentPreviewMarkdown.ts +0 -168
  170. package/src/buildPreviewDoc.ts +0 -407
  171. package/src/codeContext/CodeContextSectionView.tsx +0 -124
  172. package/src/codeContext/CodeContextZoneManager.ts +0 -149
  173. package/src/codeContext/CodeContextZones.tsx +0 -121
  174. package/src/codeContext/diffContextSections.ts +0 -38
  175. package/src/codeContext/types.ts +0 -75
  176. package/src/codeSnippet/CodeSnippetExtension.ts +0 -205
  177. package/src/codeSnippet/CodeSnippetWidget.tsx +0 -109
  178. package/src/codeSnippet/__tests__/CodeSnippetExtension.test.ts +0 -95
  179. package/src/codeSnippet/__tests__/codeSnippetLanguages.test.ts +0 -50
  180. package/src/codeSnippet/codeSnippetCommands.ts +0 -21
  181. package/src/codeSnippet/codeSnippetData.ts +0 -43
  182. package/src/codeSnippet/codeSnippetLanguages.ts +0 -216
  183. package/src/customTemplates/AddBin.tsx +0 -126
  184. package/src/customTemplates/CustomLayoutManager.tsx +0 -234
  185. package/src/customTemplates/CustomTemplateContext.tsx +0 -188
  186. package/src/customTemplates/LayerToolbar.tsx +0 -580
  187. package/src/customTemplates/ShapeGlyph.tsx +0 -47
  188. package/src/customTemplates/TemplateDesigner.tsx +0 -433
  189. package/src/customTemplates/__tests__/library.test.ts +0 -96
  190. package/src/customTemplates/__tests__/normalizePositions.test.ts +0 -109
  191. package/src/customTemplates/__tests__/shapeDefs.test.ts +0 -49
  192. package/src/customTemplates/__tests__/useMemoryLayerAdapter.test.ts +0 -108
  193. package/src/customTemplates/designer.css +0 -732
  194. package/src/customTemplates/index.ts +0 -31
  195. package/src/customTemplates/library.ts +0 -110
  196. package/src/customTemplates/normalizePositions.ts +0 -75
  197. package/src/customTemplates/shapeDefs.ts +0 -131
  198. package/src/customTemplates/thumbnail.tsx +0 -63
  199. package/src/customTemplates/tokenDefs.ts +0 -60
  200. package/src/customTemplates/useDocCustomTemplates.ts +0 -52
  201. package/src/customTemplates/useMemoryLayerAdapter.ts +0 -129
  202. package/src/customThemes/CustomThemeContext.tsx +0 -185
  203. package/src/customThemes/CustomThemeDialog.tsx +0 -316
  204. package/src/customThemes/ImportThemeSection.tsx +0 -178
  205. package/src/customThemes/__tests__/CustomThemeContext.test.tsx +0 -64
  206. package/src/customThemes/__tests__/CustomThemeDialog.test.tsx +0 -47
  207. package/src/customThemes/__tests__/customThemeLibrary.test.ts +0 -60
  208. package/src/customThemes/__tests__/importThemeSection.test.tsx +0 -192
  209. package/src/customThemes/customThemeLibrary.ts +0 -100
  210. package/src/customThemes/index.ts +0 -37
  211. package/src/customThemes/themeControls.tsx +0 -229
  212. package/src/customThemes/themeDraft.ts +0 -288
  213. package/src/customThemes/useDocCustomThemes.ts +0 -49
  214. package/src/detectMarkdown.ts +0 -62
  215. package/src/diagram/DiagramCanvas.tsx +0 -260
  216. package/src/diagram/DiagramMaximizedOverlay.tsx +0 -46
  217. package/src/diagram/diagramCommands.ts +0 -604
  218. package/src/diagram/diagramConstants.ts +0 -17
  219. package/src/diagram/types.ts +0 -35
  220. package/src/editorScrollSync.ts +0 -73
  221. package/src/embeddedMedia.ts +0 -78
  222. package/src/emojiData.ts +0 -1317
  223. package/src/fileKind.ts +0 -158
  224. package/src/find/FindHighlightExtension.ts +0 -81
  225. package/src/find/FindToolbar.tsx +0 -314
  226. package/src/find/findModel.ts +0 -77
  227. package/src/frontmatter.ts +0 -29
  228. package/src/frontmatterSettings.ts +0 -23
  229. package/src/headingTransition.ts +0 -291
  230. package/src/hooks/useFileDrop.ts +0 -266
  231. package/src/imageEditor/CanvasSurface.tsx +0 -703
  232. package/src/imageEditor/ImageVersionHistoryDropdown.tsx +0 -396
  233. package/src/imageEditor/LayersPanel.tsx +0 -218
  234. package/src/imageEditor/PropertiesPanel.tsx +0 -474
  235. package/src/imageEditor/Toolbar.tsx +0 -459
  236. package/src/imageEditor/createShapeLayer.ts +0 -280
  237. package/src/imageEditor/icons.tsx +0 -68
  238. package/src/imageEditor/image-editor.css +0 -574
  239. package/src/imageEditor/layers/EditorImageLayer.tsx +0 -45
  240. package/src/imageEditor/layers/EditorShapeLayer.tsx +0 -62
  241. package/src/imageEditor/layers/EditorTextLayer.tsx +0 -45
  242. package/src/imageEditor/layers/SelectionHandles.tsx +0 -86
  243. package/src/imageEditor/state.ts +0 -173
  244. package/src/imageEditor/useImageEditor.ts +0 -385
  245. package/src/imageEditor/useImageEditorTokens.ts +0 -70
  246. package/src/index.ts +0 -559
  247. package/src/jsonEditor/EmbeddedRichTextField.tsx +0 -81
  248. package/src/jsonEditor/JsonEditor.tsx +0 -81
  249. package/src/jsonEditor/JsonEditorContext.tsx +0 -81
  250. package/src/jsonEditor/RenderNode.tsx +0 -87
  251. package/src/jsonEditor/editors.tsx +0 -745
  252. package/src/jsonEditor/index.ts +0 -2
  253. package/src/jsonEditor/json-editor.css +0 -463
  254. package/src/jsonEditor/useJsonEditorTokens.ts +0 -33
  255. package/src/markdownCodeFence.ts +0 -72
  256. package/src/mediaDragMime.ts +0 -32
  257. package/src/mediaEntries.ts +0 -12
  258. package/src/mediaReferences.ts +0 -301
  259. package/src/mermaid/MermaidDiagramCanvas.tsx +0 -693
  260. package/src/mermaid/MermaidDiagramExtension.ts +0 -243
  261. package/src/mermaid/MermaidDiagramTypeThumbnail.tsx +0 -184
  262. package/src/mermaid/MermaidDiagramWidget.tsx +0 -653
  263. package/src/mermaid/MermaidShapePalette.tsx +0 -245
  264. package/src/mermaid/__tests__/MermaidDiagramExtension.test.ts +0 -361
  265. package/src/mermaid/__tests__/mermaidDiagramTypes.test.ts +0 -35
  266. package/src/mermaid/__tests__/mermaidRenderer.test.ts +0 -49
  267. package/src/mermaid/__tests__/mermaidSourceOps.test.ts +0 -213
  268. package/src/mermaid/__tests__/mermaidSyntax.test.ts +0 -71
  269. package/src/mermaid/mermaidCommands.ts +0 -34
  270. package/src/mermaid/mermaidData.ts +0 -31
  271. package/src/mermaid/mermaidDiagramTypes.ts +0 -325
  272. package/src/mermaid/mermaidModel.ts +0 -31
  273. package/src/mermaid/mermaidRenderer.ts +0 -181
  274. package/src/mermaid/mermaidShapes.ts +0 -113
  275. package/src/mermaid/mermaidSourceOps.ts +0 -454
  276. package/src/monaco.ts +0 -35
  277. package/src/monacoWorkers.ts +0 -89
  278. package/src/outlineSource.ts +0 -171
  279. package/src/presentation/PresentationMode.tsx +0 -596
  280. package/src/rawEditorIsolation.ts +0 -18
  281. package/src/recorder/RecorderButton.tsx +0 -80
  282. package/src/recorder/RecorderModal.tsx +0 -706
  283. package/src/recorder/RecorderPanel.tsx +0 -77
  284. package/src/recorder/formats.ts +0 -159
  285. package/src/recorder/hooks/useMediaRecorder.ts +0 -436
  286. package/src/recorder/hooks/useStreamPreview.ts +0 -47
  287. package/src/recorder/insertMediaBlock.ts +0 -30
  288. package/src/recorder/sources/cameraStream.ts +0 -32
  289. package/src/recorder/sources/micStream.ts +0 -25
  290. package/src/recorder/sources/screenStream.ts +0 -162
  291. package/src/recorder/timingJson.ts +0 -66
  292. package/src/resolveBlockVisual.ts +0 -39
  293. package/src/scene/Scene.tsx +0 -647
  294. package/src/scene/SceneBlockExtension.ts +0 -205
  295. package/src/scene/SceneBlockToolbar.tsx +0 -216
  296. package/src/scene/SceneBlockWidget.tsx +0 -441
  297. package/src/scene/ScenePropsBar.tsx +0 -85
  298. package/src/scene/SceneSelection.tsx +0 -111
  299. package/src/scene/SceneSideToolbar.tsx +0 -89
  300. package/src/scene/SceneViewControls.tsx +0 -43
  301. package/src/scene/SceneViewport.tsx +0 -106
  302. package/src/scene/ShapePalette.tsx +0 -196
  303. package/src/scene/__tests__/DiagramAdapter.test.ts +0 -142
  304. package/src/scene/__tests__/SceneBlockExtension.test.ts +0 -33
  305. package/src/scene/__tests__/bezierEdit.test.ts +0 -85
  306. package/src/scene/__tests__/blockLayers.test.ts +0 -57
  307. package/src/scene/__tests__/fitScale.test.ts +0 -19
  308. package/src/scene/__tests__/sceneIsolation.test.tsx +0 -119
  309. package/src/scene/__tests__/shapeLayers.test.ts +0 -106
  310. package/src/scene/__tests__/useSceneHitTest.test.ts +0 -90
  311. package/src/scene/__tests__/useScenePanZoom.test.ts +0 -130
  312. package/src/scene/adapters/DiagramAdapter.ts +0 -79
  313. package/src/scene/adapters/DrawingAdapter.ts +0 -420
  314. package/src/scene/adapters/LayoutAdapter.ts +0 -313
  315. package/src/scene/adapters/blockLayers.ts +0 -159
  316. package/src/scene/commands/SceneCommand.ts +0 -84
  317. package/src/scene/commands/drawingCommands.ts +0 -318
  318. package/src/scene/commands/layoutCommands.ts +0 -301
  319. package/src/scene/fitScale.ts +0 -17
  320. package/src/scene/hooks/useSceneHitTest.ts +0 -105
  321. package/src/scene/hooks/useScenePanZoom.ts +0 -154
  322. package/src/scene/hooks/useSceneSelection.ts +0 -62
  323. package/src/scene/index.ts +0 -90
  324. package/src/scene/layers/DiagramEdges.tsx +0 -142
  325. package/src/scene/layers/edgeGeometry.ts +0 -104
  326. package/src/scene/layers/nodeCard.tsx +0 -164
  327. package/src/scene/layers/renderLayer.tsx +0 -70
  328. package/src/scene/layers/shapeLayers.ts +0 -201
  329. package/src/scene/paths/bezierEdit.ts +0 -208
  330. package/src/scene/scene.css +0 -874
  331. package/src/scene/text/SceneTextOverlay.tsx +0 -161
  332. package/src/scene/text/sceneTextChannel.ts +0 -46
  333. package/src/scene/text/sceneTextConfig.ts +0 -31
  334. package/src/scene/text/sceneTiptap.ts +0 -36
  335. package/src/scene/text/useSceneTextEditing.ts +0 -39
  336. package/src/scene/tools/ConnectTool.ts +0 -209
  337. package/src/scene/tools/DrawingConnectTool.ts +0 -231
  338. package/src/scene/tools/PathTool.ts +0 -158
  339. package/src/scene/tools/PlaceTool.ts +0 -47
  340. package/src/scene/tools/SceneTool.ts +0 -85
  341. package/src/scene/tools/SelectTool.ts +0 -300
  342. package/src/scene/tools/ShapeTool.ts +0 -143
  343. package/src/scene/tools/TextTool.ts +0 -72
  344. package/src/scene/tools/TokenTool.ts +0 -95
  345. package/src/scene/tools/createDrawShapeTool.ts +0 -82
  346. package/src/selectionConversions.ts +0 -155
  347. package/src/styles/ascii-diagram.css +0 -79
  348. package/src/styles/ascii-timeline.css +0 -596
  349. package/src/styles/code-context.css +0 -155
  350. package/src/styles/code-snippet.css +0 -76
  351. package/src/styles/diagram.css +0 -183
  352. package/src/styles/editor.css +0 -7131
  353. package/src/styles/folder-view.css +0 -210
  354. package/src/styles/image-edit-affordance.css +0 -201
  355. package/src/styles/index.css +0 -20
  356. package/src/styles/mermaid-diagram.css +0 -487
  357. package/src/styles/tree-view.css +0 -189
  358. package/src/teleprompter/TeleprompterControls.tsx +0 -218
  359. package/src/teleprompter/TeleprompterSelfView.tsx +0 -22
  360. package/src/teleprompter/TeleprompterSurface.tsx +0 -267
  361. package/src/teleprompter/TeleprompterView.tsx +0 -338
  362. package/src/teleprompter/canvasRenderer.ts +0 -161
  363. package/src/teleprompter/floatingWindow.ts +0 -352
  364. package/src/teleprompter/index.ts +0 -61
  365. package/src/teleprompter/pcmWorklet.ts +0 -62
  366. package/src/teleprompter/recording/insertPreamble.ts +0 -80
  367. package/src/teleprompter/recording/narrationSave.ts +0 -134
  368. package/src/teleprompter/recording/useNarrationRecorder.ts +0 -367
  369. package/src/teleprompter/scrollModel.ts +0 -85
  370. package/src/teleprompter/teleprompterTheme.ts +0 -303
  371. package/src/teleprompter/types.ts +0 -38
  372. package/src/teleprompter/useFloatingWindow.ts +0 -74
  373. package/src/teleprompter/useMicAnalysis.ts +0 -211
  374. package/src/teleprompter/useTeleprompter.ts +0 -421
  375. package/src/templateContentPreviewResolver.ts +0 -360
  376. package/src/timeline/TimelineEditorWidget.tsx +0 -861
  377. package/src/timeline/TimelineViewExtension.ts +0 -252
  378. package/src/timeline/__tests__/TimelineEditorWidget.test.tsx +0 -414
  379. package/src/timeline/__tests__/TimelineViewExtension.test.ts +0 -163
  380. package/src/timeline/__tests__/timelineCommands.test.ts +0 -359
  381. package/src/timeline/__tests__/timelineOps.test.ts +0 -277
  382. package/src/timeline/__tests__/timelinePaste.test.ts +0 -34
  383. package/src/timeline/timelineCommands.ts +0 -421
  384. package/src/timeline/timelineData.ts +0 -54
  385. package/src/timeline/timelineOps.ts +0 -381
  386. package/src/timeline/timelinePaste.ts +0 -8
  387. package/src/timelineSource.ts +0 -244
  388. package/src/tiptap/TiptapAudio.tsx +0 -86
  389. package/src/tiptap/TiptapVideo.tsx +0 -119
  390. package/src/tiptap/useResolvedMediaSrc.ts +0 -47
  391. package/src/tiptapBridge.ts +0 -986
  392. package/src/tooltipPlacement.ts +0 -13
  393. package/src/transformStyleId.ts +0 -17
  394. package/src/transitionCatalog.ts +0 -159
  395. package/src/treeview/TreeOutlineWidget.tsx +0 -390
  396. package/src/treeview/TreeViewExtension.ts +0 -250
  397. package/src/treeview/__tests__/TreeOutlineWidget.test.tsx +0 -156
  398. package/src/treeview/__tests__/TreeViewExtension.test.ts +0 -122
  399. package/src/treeview/__tests__/treeOps.test.ts +0 -177
  400. package/src/treeview/__tests__/treePaste.test.ts +0 -40
  401. package/src/treeview/__tests__/treeViewCommands.test.ts +0 -179
  402. package/src/treeview/treeOps.ts +0 -231
  403. package/src/treeview/treePaste.ts +0 -13
  404. package/src/treeview/treeViewCommands.ts +0 -99
  405. package/src/treeview/treeViewData.ts +0 -41
  406. package/src/types/monaco-shims.d.ts +0 -10
  407. package/src/useBlockNavigator.ts +0 -153
  408. package/src/useHeadingLayout.ts +0 -294
  409. package/src/useMonacoLoader.ts +0 -82
  410. package/src/useTimelineClock.ts +0 -76
  411. package/src/utils/collectInlineFontAwesomeCss.ts +0 -69
  412. package/src/utils/dropUtils.ts +0 -136
  413. package/src/utils/normalizeMalformedAssetUrl.ts +0 -22
  414. package/src/writeCanvasSettings.ts +0 -30
  415. 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
- }