@bendyline/squisq-editor-react 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DocumentSettingsDialog.d.ts +26 -0
- package/dist/DocumentSettingsDialog.d.ts.map +1 -0
- package/dist/DocumentSettingsDialog.js +115 -0
- package/dist/DocumentSettingsDialog.js.map +1 -0
- package/dist/EditorContext.d.ts +248 -4
- package/dist/EditorContext.d.ts.map +1 -1
- package/dist/EditorContext.js +248 -10
- package/dist/EditorContext.js.map +1 -1
- package/dist/EditorShell.d.ts +184 -4
- package/dist/EditorShell.d.ts.map +1 -1
- package/dist/EditorShell.js +184 -12
- package/dist/EditorShell.js.map +1 -1
- package/dist/EmojiPicker.d.ts +50 -0
- package/dist/EmojiPicker.d.ts.map +1 -0
- package/dist/EmojiPicker.js +182 -0
- package/dist/EmojiPicker.js.map +1 -0
- package/dist/ImageEditor.d.ts +68 -0
- package/dist/ImageEditor.d.ts.map +1 -0
- package/dist/ImageEditor.js +166 -0
- package/dist/ImageEditor.js.map +1 -0
- package/dist/ImageNodeView.d.ts +13 -1
- package/dist/ImageNodeView.d.ts.map +1 -1
- package/dist/ImageNodeView.js +172 -19
- package/dist/ImageNodeView.js.map +1 -1
- package/dist/ImageViewer.d.ts +26 -0
- package/dist/ImageViewer.d.ts.map +1 -0
- package/dist/ImageViewer.js +119 -0
- package/dist/ImageViewer.js.map +1 -0
- package/dist/InlineIcon.d.ts +17 -0
- package/dist/InlineIcon.d.ts.map +1 -0
- package/dist/InlineIcon.js +72 -0
- package/dist/InlineIcon.js.map +1 -0
- package/dist/InlinePreviewGutter.d.ts +52 -0
- package/dist/InlinePreviewGutter.d.ts.map +1 -0
- package/dist/InlinePreviewGutter.js +397 -0
- package/dist/InlinePreviewGutter.js.map +1 -0
- package/dist/LinkDialog.d.ts +43 -0
- package/dist/LinkDialog.d.ts.map +1 -0
- package/dist/LinkDialog.js +102 -0
- package/dist/LinkDialog.js.map +1 -0
- package/dist/MediaBin.d.ts +12 -1
- package/dist/MediaBin.d.ts.map +1 -1
- package/dist/MediaBin.js +13 -3
- package/dist/MediaBin.js.map +1 -1
- package/dist/MentionExtension.js +10 -7
- package/dist/MentionExtension.js.map +1 -1
- package/dist/OutlinePanel.d.ts +17 -0
- package/dist/OutlinePanel.d.ts.map +1 -0
- package/dist/OutlinePanel.js +167 -0
- package/dist/OutlinePanel.js.map +1 -0
- package/dist/PlainHtmlPreview.d.ts +50 -0
- package/dist/PlainHtmlPreview.d.ts.map +1 -0
- package/dist/PlainHtmlPreview.js +155 -0
- package/dist/PlainHtmlPreview.js.map +1 -0
- package/dist/PreviewControls.d.ts +15 -1
- package/dist/PreviewControls.d.ts.map +1 -1
- package/dist/PreviewControls.js +75 -18
- package/dist/PreviewControls.js.map +1 -1
- package/dist/PreviewPanel.d.ts +11 -10
- package/dist/PreviewPanel.d.ts.map +1 -1
- package/dist/PreviewPanel.js +20 -17
- package/dist/PreviewPanel.js.map +1 -1
- package/dist/RawEditor.d.ts.map +1 -1
- package/dist/RawEditor.js +198 -4
- package/dist/RawEditor.js.map +1 -1
- package/dist/RecorderEntry.d.ts +24 -0
- package/dist/RecorderEntry.d.ts.map +1 -0
- package/dist/RecorderEntry.js +139 -0
- package/dist/RecorderEntry.js.map +1 -0
- package/dist/TemplateAnnotation.d.ts.map +1 -1
- package/dist/TemplateAnnotation.js +32 -6
- package/dist/TemplateAnnotation.js.map +1 -1
- package/dist/TemplatePicker.d.ts +53 -0
- package/dist/TemplatePicker.d.ts.map +1 -0
- package/dist/TemplatePicker.js +388 -0
- package/dist/TemplatePicker.js.map +1 -0
- package/dist/ThemeCustomizerPanel.d.ts +32 -0
- package/dist/ThemeCustomizerPanel.d.ts.map +1 -0
- package/dist/ThemeCustomizerPanel.js +256 -0
- package/dist/ThemeCustomizerPanel.js.map +1 -0
- package/dist/ThemePicker.d.ts +33 -0
- package/dist/ThemePicker.d.ts.map +1 -0
- package/dist/ThemePicker.js +148 -0
- package/dist/ThemePicker.js.map +1 -0
- package/dist/Toolbar.d.ts.map +1 -1
- package/dist/Toolbar.js +508 -33
- package/dist/Toolbar.js.map +1 -1
- package/dist/VersionHistoryPanel.d.ts +14 -0
- package/dist/VersionHistoryPanel.d.ts.map +1 -0
- package/dist/VersionHistoryPanel.js +147 -0
- package/dist/VersionHistoryPanel.js.map +1 -0
- package/dist/ViewMenuPanel.d.ts +13 -0
- package/dist/ViewMenuPanel.d.ts.map +1 -0
- package/dist/ViewMenuPanel.js +58 -0
- package/dist/ViewMenuPanel.js.map +1 -0
- package/dist/WysiwygEditor.d.ts.map +1 -1
- package/dist/WysiwygEditor.js +198 -9
- package/dist/WysiwygEditor.js.map +1 -1
- package/dist/__tests__/detectMarkdown.test.js +0 -14
- package/dist/__tests__/detectMarkdown.test.js.map +1 -1
- package/dist/__tests__/documentSettingsDialog.test.d.ts +2 -0
- package/dist/__tests__/documentSettingsDialog.test.d.ts.map +1 -0
- package/dist/__tests__/documentSettingsDialog.test.js +132 -0
- package/dist/__tests__/documentSettingsDialog.test.js.map +1 -0
- package/dist/__tests__/emojiPicker.test.d.ts +2 -0
- package/dist/__tests__/emojiPicker.test.d.ts.map +1 -0
- package/dist/__tests__/emojiPicker.test.js +111 -0
- package/dist/__tests__/emojiPicker.test.js.map +1 -0
- package/dist/__tests__/fileKind.test.js +13 -0
- package/dist/__tests__/fileKind.test.js.map +1 -1
- package/dist/__tests__/imageEditAffordance.test.d.ts +2 -0
- package/dist/__tests__/imageEditAffordance.test.d.ts.map +1 -0
- package/dist/__tests__/imageEditAffordance.test.js +188 -0
- package/dist/__tests__/imageEditAffordance.test.js.map +1 -0
- package/dist/__tests__/imageEditorShell.test.d.ts +2 -0
- package/dist/__tests__/imageEditorShell.test.d.ts.map +1 -0
- package/dist/__tests__/imageEditorShell.test.js +52 -0
- package/dist/__tests__/imageEditorShell.test.js.map +1 -0
- package/dist/__tests__/imageEditorState.test.d.ts +3 -0
- package/dist/__tests__/imageEditorState.test.d.ts.map +1 -0
- package/dist/__tests__/imageEditorState.test.js +148 -0
- package/dist/__tests__/imageEditorState.test.js.map +1 -0
- package/dist/__tests__/inlinePreviewGutter.test.d.ts +2 -0
- package/dist/__tests__/inlinePreviewGutter.test.d.ts.map +1 -0
- package/dist/__tests__/inlinePreviewGutter.test.js +51 -0
- package/dist/__tests__/inlinePreviewGutter.test.js.map +1 -0
- package/dist/__tests__/inlinePreviewGutterAllBlocks.test.d.ts +2 -0
- package/dist/__tests__/inlinePreviewGutterAllBlocks.test.d.ts.map +1 -0
- package/dist/__tests__/inlinePreviewGutterAllBlocks.test.js +63 -0
- package/dist/__tests__/inlinePreviewGutterAllBlocks.test.js.map +1 -0
- package/dist/__tests__/jsonEditor.test.d.ts +2 -0
- package/dist/__tests__/jsonEditor.test.d.ts.map +1 -0
- package/dist/__tests__/jsonEditor.test.js +134 -0
- package/dist/__tests__/jsonEditor.test.js.map +1 -0
- package/dist/__tests__/layersPanel.test.d.ts +2 -0
- package/dist/__tests__/layersPanel.test.d.ts.map +1 -0
- package/dist/__tests__/layersPanel.test.js +84 -0
- package/dist/__tests__/layersPanel.test.js.map +1 -0
- package/dist/__tests__/linkDialogDocPicker.test.d.ts +7 -0
- package/dist/__tests__/linkDialogDocPicker.test.d.ts.map +1 -0
- package/dist/__tests__/linkDialogDocPicker.test.js +75 -0
- package/dist/__tests__/linkDialogDocPicker.test.js.map +1 -0
- package/dist/__tests__/mediaAttachmentFlow.test.d.ts +2 -0
- package/dist/__tests__/mediaAttachmentFlow.test.d.ts.map +1 -0
- package/dist/__tests__/mediaAttachmentFlow.test.js +99 -0
- package/dist/__tests__/mediaAttachmentFlow.test.js.map +1 -0
- package/dist/__tests__/outlinePanel.test.d.ts +2 -0
- package/dist/__tests__/outlinePanel.test.d.ts.map +1 -0
- package/dist/__tests__/outlinePanel.test.js +68 -0
- package/dist/__tests__/outlinePanel.test.js.map +1 -0
- package/dist/__tests__/plainHtmlPreview.test.d.ts +2 -0
- package/dist/__tests__/plainHtmlPreview.test.d.ts.map +1 -0
- package/dist/__tests__/plainHtmlPreview.test.js +87 -0
- package/dist/__tests__/plainHtmlPreview.test.js.map +1 -0
- package/dist/__tests__/propertiesPanel.test.d.ts +2 -0
- package/dist/__tests__/propertiesPanel.test.d.ts.map +1 -0
- package/dist/__tests__/propertiesPanel.test.js +64 -0
- package/dist/__tests__/propertiesPanel.test.js.map +1 -0
- package/dist/__tests__/recorderFormats.test.d.ts +2 -0
- package/dist/__tests__/recorderFormats.test.d.ts.map +1 -0
- package/dist/__tests__/recorderFormats.test.js +121 -0
- package/dist/__tests__/recorderFormats.test.js.map +1 -0
- package/dist/__tests__/recorderTimingJson.test.d.ts +2 -0
- package/dist/__tests__/recorderTimingJson.test.d.ts.map +1 -0
- package/dist/__tests__/recorderTimingJson.test.js +37 -0
- package/dist/__tests__/recorderTimingJson.test.js.map +1 -0
- package/dist/__tests__/templateAnnotationRoundTrip.test.d.ts +2 -0
- package/dist/__tests__/templateAnnotationRoundTrip.test.d.ts.map +1 -0
- package/dist/__tests__/templateAnnotationRoundTrip.test.js +31 -0
- package/dist/__tests__/templateAnnotationRoundTrip.test.js.map +1 -0
- package/dist/__tests__/tiptapBridge.test.js +26 -0
- package/dist/__tests__/tiptapBridge.test.js.map +1 -1
- package/dist/__tests__/tiptapImageRoundTrip.test.d.ts +2 -0
- package/dist/__tests__/tiptapImageRoundTrip.test.d.ts.map +1 -0
- package/dist/__tests__/tiptapImageRoundTrip.test.js +68 -0
- package/dist/__tests__/tiptapImageRoundTrip.test.js.map +1 -0
- package/dist/__tests__/useImageEditor.test.d.ts +2 -0
- package/dist/__tests__/useImageEditor.test.d.ts.map +1 -0
- package/dist/__tests__/useImageEditor.test.js +131 -0
- package/dist/__tests__/useImageEditor.test.js.map +1 -0
- package/dist/__tests__/useMediaRecorder.test.d.ts +2 -0
- package/dist/__tests__/useMediaRecorder.test.d.ts.map +1 -0
- package/dist/__tests__/useMediaRecorder.test.js +153 -0
- package/dist/__tests__/useMediaRecorder.test.js.map +1 -0
- package/dist/__tests__/versionHistory.test.d.ts +2 -0
- package/dist/__tests__/versionHistory.test.d.ts.map +1 -0
- package/dist/__tests__/versionHistory.test.js +124 -0
- package/dist/__tests__/versionHistory.test.js.map +1 -0
- package/dist/blockSlice.d.ts +24 -0
- package/dist/blockSlice.d.ts.map +1 -0
- package/dist/blockSlice.js +63 -0
- package/dist/blockSlice.js.map +1 -0
- package/dist/buildPreviewDoc.d.ts.map +1 -1
- package/dist/buildPreviewDoc.js +52 -2
- package/dist/buildPreviewDoc.js.map +1 -1
- package/dist/emojiData.d.ts +81 -0
- package/dist/emojiData.d.ts.map +1 -0
- package/dist/emojiData.js +1283 -0
- package/dist/emojiData.js.map +1 -0
- package/dist/fileKind.d.ts +6 -2
- package/dist/fileKind.d.ts.map +1 -1
- package/dist/fileKind.js +25 -4
- package/dist/fileKind.js.map +1 -1
- package/dist/hooks/useFileDrop.d.ts.map +1 -1
- package/dist/hooks/useFileDrop.js +40 -4
- package/dist/hooks/useFileDrop.js.map +1 -1
- package/dist/imageEditor/CanvasSurface.d.ts +31 -0
- package/dist/imageEditor/CanvasSurface.d.ts.map +1 -0
- package/dist/imageEditor/CanvasSurface.js +264 -0
- package/dist/imageEditor/CanvasSurface.js.map +1 -0
- package/dist/imageEditor/ImageVersionHistoryDropdown.d.ts +39 -0
- package/dist/imageEditor/ImageVersionHistoryDropdown.d.ts.map +1 -0
- package/dist/imageEditor/ImageVersionHistoryDropdown.js +283 -0
- package/dist/imageEditor/ImageVersionHistoryDropdown.js.map +1 -0
- package/dist/imageEditor/LayersPanel.d.ts +14 -0
- package/dist/imageEditor/LayersPanel.d.ts.map +1 -0
- package/dist/imageEditor/LayersPanel.js +43 -0
- package/dist/imageEditor/LayersPanel.js.map +1 -0
- package/dist/imageEditor/PropertiesPanel.d.ts +14 -0
- package/dist/imageEditor/PropertiesPanel.d.ts.map +1 -0
- package/dist/imageEditor/PropertiesPanel.js +97 -0
- package/dist/imageEditor/PropertiesPanel.js.map +1 -0
- package/dist/imageEditor/Toolbar.d.ts +30 -0
- package/dist/imageEditor/Toolbar.d.ts.map +1 -0
- package/dist/imageEditor/Toolbar.js +108 -0
- package/dist/imageEditor/Toolbar.js.map +1 -0
- package/dist/imageEditor/icons.d.ts +24 -0
- package/dist/imageEditor/icons.d.ts.map +1 -0
- package/dist/imageEditor/icons.js +45 -0
- package/dist/imageEditor/icons.js.map +1 -0
- package/dist/imageEditor/layers/EditorImageLayer.d.ts +16 -0
- package/dist/imageEditor/layers/EditorImageLayer.d.ts.map +1 -0
- package/dist/imageEditor/layers/EditorImageLayer.js +37 -0
- package/dist/imageEditor/layers/EditorImageLayer.js.map +1 -0
- package/dist/imageEditor/layers/EditorShapeLayer.d.ts +15 -0
- package/dist/imageEditor/layers/EditorShapeLayer.d.ts.map +1 -0
- package/dist/imageEditor/layers/EditorShapeLayer.js +20 -0
- package/dist/imageEditor/layers/EditorShapeLayer.js.map +1 -0
- package/dist/imageEditor/layers/EditorTextLayer.d.ts +18 -0
- package/dist/imageEditor/layers/EditorTextLayer.d.ts.map +1 -0
- package/dist/imageEditor/layers/EditorTextLayer.js +13 -0
- package/dist/imageEditor/layers/EditorTextLayer.js.map +1 -0
- package/dist/imageEditor/layers/SelectionHandles.d.ts +17 -0
- package/dist/imageEditor/layers/SelectionHandles.d.ts.map +1 -0
- package/dist/imageEditor/layers/SelectionHandles.js +19 -0
- package/dist/imageEditor/layers/SelectionHandles.js.map +1 -0
- package/dist/imageEditor/state.d.ts +76 -0
- package/dist/imageEditor/state.d.ts.map +1 -0
- package/dist/imageEditor/state.js +87 -0
- package/dist/imageEditor/state.js.map +1 -0
- package/dist/imageEditor/useImageEditor.d.ts +53 -0
- package/dist/imageEditor/useImageEditor.d.ts.map +1 -0
- package/dist/imageEditor/useImageEditor.js +244 -0
- package/dist/imageEditor/useImageEditor.js.map +1 -0
- package/dist/imageEditor/useImageEditorTokens.d.ts +16 -0
- package/dist/imageEditor/useImageEditorTokens.d.ts.map +1 -0
- package/dist/imageEditor/useImageEditorTokens.js +45 -0
- package/dist/imageEditor/useImageEditorTokens.js.map +1 -0
- package/dist/index.d.ts +48 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -1
- package/dist/jsonEditor/EmbeddedRichTextField.d.ts +15 -0
- package/dist/jsonEditor/EmbeddedRichTextField.d.ts.map +1 -0
- package/dist/jsonEditor/EmbeddedRichTextField.js +74 -0
- package/dist/jsonEditor/EmbeddedRichTextField.js.map +1 -0
- package/dist/jsonEditor/JsonEditor.d.ts +36 -0
- package/dist/jsonEditor/JsonEditor.d.ts.map +1 -0
- package/dist/jsonEditor/JsonEditor.js +15 -0
- package/dist/jsonEditor/JsonEditor.js.map +1 -0
- package/dist/jsonEditor/JsonEditorContext.d.ts +28 -0
- package/dist/jsonEditor/JsonEditorContext.d.ts.map +1 -0
- package/dist/jsonEditor/JsonEditorContext.js +41 -0
- package/dist/jsonEditor/JsonEditorContext.js.map +1 -0
- package/dist/jsonEditor/RenderNode.d.ts +16 -0
- package/dist/jsonEditor/RenderNode.d.ts.map +1 -0
- package/dist/jsonEditor/RenderNode.js +32 -0
- package/dist/jsonEditor/RenderNode.js.map +1 -0
- package/dist/jsonEditor/editors.d.ts +36 -0
- package/dist/jsonEditor/editors.d.ts.map +1 -0
- package/dist/jsonEditor/editors.js +347 -0
- package/dist/jsonEditor/editors.js.map +1 -0
- package/dist/jsonEditor/index.d.ts +3 -0
- package/dist/jsonEditor/index.d.ts.map +1 -0
- package/dist/jsonEditor/index.js +2 -0
- package/dist/jsonEditor/index.js.map +1 -0
- package/dist/jsonEditor/useJsonEditorTokens.d.ts +13 -0
- package/dist/jsonEditor/useJsonEditorTokens.d.ts.map +1 -0
- package/dist/jsonEditor/useJsonEditorTokens.js +38 -0
- package/dist/jsonEditor/useJsonEditorTokens.js.map +1 -0
- package/dist/recorder/RecorderButton.d.ts +31 -0
- package/dist/recorder/RecorderButton.d.ts.map +1 -0
- package/dist/recorder/RecorderButton.js +24 -0
- package/dist/recorder/RecorderButton.js.map +1 -0
- package/dist/recorder/RecorderModal.d.ts +59 -0
- package/dist/recorder/RecorderModal.d.ts.map +1 -0
- package/dist/recorder/RecorderModal.js +333 -0
- package/dist/recorder/RecorderModal.js.map +1 -0
- package/dist/recorder/RecorderPanel.d.ts +25 -0
- package/dist/recorder/RecorderPanel.d.ts.map +1 -0
- package/dist/recorder/RecorderPanel.js +30 -0
- package/dist/recorder/RecorderPanel.js.map +1 -0
- package/dist/recorder/formats.d.ts +51 -0
- package/dist/recorder/formats.d.ts.map +1 -0
- package/dist/recorder/formats.js +144 -0
- package/dist/recorder/formats.js.map +1 -0
- package/dist/recorder/hooks/useMediaRecorder.d.ts +90 -0
- package/dist/recorder/hooks/useMediaRecorder.d.ts.map +1 -0
- package/dist/recorder/hooks/useMediaRecorder.js +277 -0
- package/dist/recorder/hooks/useMediaRecorder.js.map +1 -0
- package/dist/recorder/hooks/useStreamPreview.d.ts +22 -0
- package/dist/recorder/hooks/useStreamPreview.d.ts.map +1 -0
- package/dist/recorder/hooks/useStreamPreview.js +44 -0
- package/dist/recorder/hooks/useStreamPreview.js.map +1 -0
- package/dist/recorder/sources/cameraStream.d.ts +22 -0
- package/dist/recorder/sources/cameraStream.d.ts.map +1 -0
- package/dist/recorder/sources/cameraStream.js +24 -0
- package/dist/recorder/sources/cameraStream.js.map +1 -0
- package/dist/recorder/sources/micStream.d.ts +15 -0
- package/dist/recorder/sources/micStream.d.ts.map +1 -0
- package/dist/recorder/sources/micStream.js +24 -0
- package/dist/recorder/sources/micStream.js.map +1 -0
- package/dist/recorder/sources/screenStream.d.ts +53 -0
- package/dist/recorder/sources/screenStream.d.ts.map +1 -0
- package/dist/recorder/sources/screenStream.js +114 -0
- package/dist/recorder/sources/screenStream.js.map +1 -0
- package/dist/recorder/timingJson.d.ts +51 -0
- package/dist/recorder/timingJson.d.ts.map +1 -0
- package/dist/recorder/timingJson.js +42 -0
- package/dist/recorder/timingJson.js.map +1 -0
- package/dist/tiptap/TiptapAudio.d.ts +26 -0
- package/dist/tiptap/TiptapAudio.d.ts.map +1 -0
- package/dist/tiptap/TiptapAudio.js +58 -0
- package/dist/tiptap/TiptapAudio.js.map +1 -0
- package/dist/tiptap/TiptapVideo.d.ts +30 -0
- package/dist/tiptap/TiptapVideo.d.ts.map +1 -0
- package/dist/tiptap/TiptapVideo.js +66 -0
- package/dist/tiptap/TiptapVideo.js.map +1 -0
- package/dist/tiptap/useResolvedMediaSrc.d.ts +2 -0
- package/dist/tiptap/useResolvedMediaSrc.d.ts.map +1 -0
- package/dist/tiptap/useResolvedMediaSrc.js +42 -0
- package/dist/tiptap/useResolvedMediaSrc.js.map +1 -0
- package/dist/tiptapBridge.d.ts.map +1 -1
- package/dist/tiptapBridge.js +210 -16
- package/dist/tiptapBridge.js.map +1 -1
- package/dist/useHeadingLayout.d.ts +54 -0
- package/dist/useHeadingLayout.d.ts.map +1 -0
- package/dist/useHeadingLayout.js +260 -0
- package/dist/useHeadingLayout.js.map +1 -0
- package/dist/utils/collectInlineFontAwesomeCss.d.ts +21 -0
- package/dist/utils/collectInlineFontAwesomeCss.d.ts.map +1 -0
- package/dist/utils/collectInlineFontAwesomeCss.js +68 -0
- package/dist/utils/collectInlineFontAwesomeCss.js.map +1 -0
- package/dist/utils/dropUtils.d.ts +21 -2
- package/dist/utils/dropUtils.d.ts.map +1 -1
- package/dist/utils/dropUtils.js +43 -4
- package/dist/utils/dropUtils.js.map +1 -1
- package/dist/utils/normalizeMalformedAssetUrl.d.ts +15 -0
- package/dist/utils/normalizeMalformedAssetUrl.d.ts.map +1 -0
- package/dist/utils/normalizeMalformedAssetUrl.js +27 -0
- package/dist/utils/normalizeMalformedAssetUrl.js.map +1 -0
- package/package.json +8 -5
- package/src/DocumentSettingsDialog.tsx +266 -0
- package/src/EditorContext.tsx +534 -10
- package/src/EditorShell.tsx +691 -63
- package/src/EmojiPicker.tsx +332 -0
- package/src/ImageEditor.tsx +327 -0
- package/src/ImageNodeView.tsx +222 -21
- package/src/ImageViewer.tsx +221 -0
- package/src/InlineIcon.ts +84 -0
- package/src/InlinePreviewGutter.tsx +582 -0
- package/src/LinkDialog.tsx +276 -0
- package/src/MediaBin.tsx +22 -3
- package/src/MentionExtension.tsx +10 -7
- package/src/OutlinePanel.tsx +295 -0
- package/src/PlainHtmlPreview.tsx +211 -0
- package/src/PreviewControls.tsx +130 -24
- package/src/PreviewPanel.tsx +38 -21
- package/src/RawEditor.tsx +215 -4
- package/src/RecorderEntry.tsx +164 -0
- package/src/TemplateAnnotation.ts +32 -6
- package/src/TemplatePicker.tsx +818 -0
- package/src/ThemeCustomizerPanel.tsx +595 -0
- package/src/ThemePicker.tsx +319 -0
- package/src/Toolbar.tsx +708 -111
- package/src/VersionHistoryPanel.tsx +329 -0
- package/src/ViewMenuPanel.tsx +188 -0
- package/src/WysiwygEditor.tsx +229 -9
- package/src/__tests__/detectMarkdown.test.ts +0 -15
- package/src/__tests__/documentSettingsDialog.test.tsx +147 -0
- package/src/__tests__/emojiPicker.test.tsx +133 -0
- package/src/__tests__/fileKind.test.ts +16 -0
- package/src/__tests__/imageEditAffordance.test.tsx +268 -0
- package/src/__tests__/imageEditorShell.test.tsx +57 -0
- package/src/__tests__/imageEditorState.test.ts +171 -0
- package/src/__tests__/inlinePreviewGutter.test.tsx +62 -0
- package/src/__tests__/inlinePreviewGutterAllBlocks.test.tsx +103 -0
- package/src/__tests__/jsonEditor.test.tsx +168 -0
- package/src/__tests__/layersPanel.test.tsx +97 -0
- package/src/__tests__/linkDialogDocPicker.test.tsx +137 -0
- package/src/__tests__/mediaAttachmentFlow.test.ts +110 -0
- package/src/__tests__/outlinePanel.test.tsx +79 -0
- package/src/__tests__/plainHtmlPreview.test.tsx +107 -0
- package/src/__tests__/propertiesPanel.test.tsx +69 -0
- package/src/__tests__/recorderFormats.test.ts +146 -0
- package/src/__tests__/recorderTimingJson.test.ts +41 -0
- package/src/__tests__/templateAnnotationRoundTrip.test.ts +34 -0
- package/src/__tests__/tiptapBridge.test.ts +29 -0
- package/src/__tests__/tiptapImageRoundTrip.test.ts +73 -0
- package/src/__tests__/useImageEditor.test.tsx +159 -0
- package/src/__tests__/useMediaRecorder.test.ts +186 -0
- package/src/__tests__/versionHistory.test.tsx +197 -0
- package/src/blockSlice.ts +75 -0
- package/src/buildPreviewDoc.ts +61 -6
- package/src/emojiData.ts +1337 -0
- package/src/fileKind.ts +30 -6
- package/src/hooks/useFileDrop.ts +40 -4
- package/src/imageEditor/CanvasSurface.tsx +402 -0
- package/src/imageEditor/ImageVersionHistoryDropdown.tsx +396 -0
- package/src/imageEditor/LayersPanel.tsx +143 -0
- package/src/imageEditor/PropertiesPanel.tsx +428 -0
- package/src/imageEditor/Toolbar.tsx +242 -0
- package/src/imageEditor/icons.tsx +144 -0
- package/src/imageEditor/image-editor.css +450 -0
- package/src/imageEditor/layers/EditorImageLayer.tsx +45 -0
- package/src/imageEditor/layers/EditorShapeLayer.tsx +62 -0
- package/src/imageEditor/layers/EditorTextLayer.tsx +45 -0
- package/src/imageEditor/layers/SelectionHandles.tsx +86 -0
- package/src/imageEditor/state.ts +153 -0
- package/src/imageEditor/useImageEditor.ts +328 -0
- package/src/imageEditor/useImageEditorTokens.ts +70 -0
- package/src/index.ts +82 -0
- package/src/jsonEditor/EmbeddedRichTextField.tsx +81 -0
- package/src/jsonEditor/JsonEditor.tsx +81 -0
- package/src/jsonEditor/JsonEditorContext.tsx +75 -0
- package/src/jsonEditor/RenderNode.tsx +66 -0
- package/src/jsonEditor/editors.tsx +678 -0
- package/src/jsonEditor/index.ts +2 -0
- package/src/jsonEditor/json-editor.css +463 -0
- package/src/jsonEditor/useJsonEditorTokens.ts +63 -0
- package/src/recorder/RecorderButton.tsx +72 -0
- package/src/recorder/RecorderModal.tsx +596 -0
- package/src/recorder/RecorderPanel.tsx +93 -0
- package/src/recorder/formats.ts +159 -0
- package/src/recorder/hooks/useMediaRecorder.ts +378 -0
- package/src/recorder/hooks/useStreamPreview.ts +47 -0
- package/src/recorder/sources/cameraStream.ts +32 -0
- package/src/recorder/sources/micStream.ts +25 -0
- package/src/recorder/sources/screenStream.ts +162 -0
- package/src/recorder/timingJson.ts +66 -0
- package/src/styles/editor.css +2490 -51
- package/src/styles/image-edit-affordance.css +201 -0
- package/src/styles/index.css +10 -0
- package/src/tiptap/TiptapAudio.tsx +86 -0
- package/src/tiptap/TiptapVideo.tsx +119 -0
- package/src/tiptap/useResolvedMediaSrc.ts +47 -0
- package/src/tiptapBridge.ts +227 -22
- package/src/useHeadingLayout.ts +294 -0
- package/src/utils/collectInlineFontAwesomeCss.ts +69 -0
- package/src/utils/dropUtils.ts +54 -6
- package/src/utils/normalizeMalformedAssetUrl.ts +22 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useMediaRecorder
|
|
3
|
+
*
|
|
4
|
+
* React wrapper around `MediaRecorder` that handles stream acquisition,
|
|
5
|
+
* the recorder lifecycle, and produces a single `Blob` on stop. Selects
|
|
6
|
+
* a browser-supported MIME type via {@link resolveFormat}.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors the shape of `useVideoExport` in `@bendyline/squisq-video-react`
|
|
9
|
+
* (request → start → stop → blob), inverted for capture rather than
|
|
10
|
+
* export.
|
|
11
|
+
*/
|
|
12
|
+
import { type CaptureKind } from '../formats.js';
|
|
13
|
+
/** Which capture source to use. `screen+mic` mixes the microphone into the screen stream. */
|
|
14
|
+
export type RecorderSource = 'mic' | 'camera' | 'screen' | 'screen+mic';
|
|
15
|
+
/** Discriminated state describing what the recorder is currently doing. */
|
|
16
|
+
export type RecorderState = 'idle' | 'requesting' | 'ready' | 'recording' | 'stopping' | 'stopped' | 'error';
|
|
17
|
+
export interface UseMediaRecorderOptions {
|
|
18
|
+
/** Which capture pipeline to use. */
|
|
19
|
+
source: RecorderSource;
|
|
20
|
+
/**
|
|
21
|
+
* Preferred MIME type override. When the browser supports it, this
|
|
22
|
+
* wins over the default candidate list. When unset (or unsupported),
|
|
23
|
+
* the hook probes a built-in priority list.
|
|
24
|
+
*/
|
|
25
|
+
mimeType?: string;
|
|
26
|
+
/** Video track constraints for camera / screen sources. */
|
|
27
|
+
videoConstraints?: MediaTrackConstraints | boolean;
|
|
28
|
+
/** Audio track constraints for mic / camera / screen+mic sources. */
|
|
29
|
+
audioConstraints?: MediaTrackConstraints | boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Bits-per-second hint passed to `MediaRecorder`. Most browsers cap to
|
|
32
|
+
* reasonable defaults internally; leaving this undefined is usually
|
|
33
|
+
* fine.
|
|
34
|
+
*/
|
|
35
|
+
bitsPerSecond?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Whether to attempt to capture system audio when `source === 'screen'`
|
|
38
|
+
* or `'screen+mic'`. Browser support is limited (desktop Chromium
|
|
39
|
+
* only); when unsupported the resulting stream simply omits it.
|
|
40
|
+
*/
|
|
41
|
+
systemAudio?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface UseMediaRecorderResult {
|
|
44
|
+
/** Current recorder state. */
|
|
45
|
+
state: RecorderState;
|
|
46
|
+
/** Live `MediaStream` after `request()` succeeds; useful for preview. */
|
|
47
|
+
stream: MediaStream | null;
|
|
48
|
+
/** Final `Blob` after `stop()` resolves, or `null` while recording. */
|
|
49
|
+
blob: Blob | null;
|
|
50
|
+
/** MIME type the recorder actually used (after `request()`). */
|
|
51
|
+
mimeType: string | null;
|
|
52
|
+
/** File extension matching `mimeType` (e.g. `.webm`). */
|
|
53
|
+
extension: string | null;
|
|
54
|
+
/** Suggested container directory (`'audio'` for mic, `'video'` for camera/screen). */
|
|
55
|
+
directory: 'audio' | 'video' | null;
|
|
56
|
+
/** Milliseconds elapsed since `start()` was called. Updates ~10× per second while recording. */
|
|
57
|
+
durationMs: number;
|
|
58
|
+
/** Most recent error, if any. */
|
|
59
|
+
error: Error | null;
|
|
60
|
+
/**
|
|
61
|
+
* Acquire the stream and prepare a `MediaRecorder`. After this resolves
|
|
62
|
+
* the hook is in `'ready'` state and a `<video>`/`<audio>` element can
|
|
63
|
+
* preview `stream`. Call `start()` to begin recording.
|
|
64
|
+
*/
|
|
65
|
+
request: () => Promise<void>;
|
|
66
|
+
/** Start recording. Must be called from `'ready'`. */
|
|
67
|
+
start: () => void;
|
|
68
|
+
/**
|
|
69
|
+
* Stop recording and resolve with the resulting `Blob`. Safe to call
|
|
70
|
+
* from `'recording'`; a no-op from any other state (resolves with the
|
|
71
|
+
* existing `blob`, or `null`).
|
|
72
|
+
*/
|
|
73
|
+
stop: () => Promise<Blob | null>;
|
|
74
|
+
/**
|
|
75
|
+
* Tear everything down — stops the recorder if running, releases all
|
|
76
|
+
* tracks, disposes the AudioContext mixer (if any), and returns to
|
|
77
|
+
* `'idle'`. Always safe to call.
|
|
78
|
+
*/
|
|
79
|
+
cancel: () => void;
|
|
80
|
+
/** Reset state without releasing the stream. Useful for re-recording. */
|
|
81
|
+
reset: () => void;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Returns the kind of capture that the given source produces. Exposed
|
|
85
|
+
* separately from {@link useMediaRecorder} so non-React callers
|
|
86
|
+
* (e.g. headless tests) can resolve a format up front.
|
|
87
|
+
*/
|
|
88
|
+
export declare function getCaptureKind(source: RecorderSource): CaptureKind;
|
|
89
|
+
export declare function useMediaRecorder(options: UseMediaRecorderOptions): UseMediaRecorderResult;
|
|
90
|
+
//# sourceMappingURL=useMediaRecorder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMediaRecorder.d.ts","sourceRoot":"","sources":["../../../src/recorder/hooks/useMediaRecorder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAGL,KAAK,WAAW,EAEjB,MAAM,eAAe,CAAC;AAKvB,6FAA6F;AAC7F,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,YAAY,CAAC;AAExE,2E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AE,MAAM,IAAI,CAAC;CACnB;AA0CD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,WAAW,CAElE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,sBAAsB,CAgOzF"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useMediaRecorder
|
|
3
|
+
*
|
|
4
|
+
* React wrapper around `MediaRecorder` that handles stream acquisition,
|
|
5
|
+
* the recorder lifecycle, and produces a single `Blob` on stop. Selects
|
|
6
|
+
* a browser-supported MIME type via {@link resolveFormat}.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors the shape of `useVideoExport` in `@bendyline/squisq-video-react`
|
|
9
|
+
* (request → start → stop → blob), inverted for capture rather than
|
|
10
|
+
* export.
|
|
11
|
+
*/
|
|
12
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
13
|
+
import { resolveFormat, supportsMediaRecorder, } from '../formats.js';
|
|
14
|
+
import { requestMicStream } from '../sources/micStream.js';
|
|
15
|
+
import { requestCameraStream } from '../sources/cameraStream.js';
|
|
16
|
+
import { requestScreenStream } from '../sources/screenStream.js';
|
|
17
|
+
/**
|
|
18
|
+
* Acquire the right stream for the chosen source. Returns the stream
|
|
19
|
+
* plus an optional `dispose` callback for sources that own auxiliary
|
|
20
|
+
* resources (e.g. the screen+mic AudioContext mixer).
|
|
21
|
+
*/
|
|
22
|
+
async function acquireStream(opts) {
|
|
23
|
+
switch (opts.source) {
|
|
24
|
+
case 'mic': {
|
|
25
|
+
const audio = typeof opts.audioConstraints === 'object' ? opts.audioConstraints : undefined;
|
|
26
|
+
const stream = await requestMicStream(audio);
|
|
27
|
+
return { stream, dispose: () => { } };
|
|
28
|
+
}
|
|
29
|
+
case 'camera': {
|
|
30
|
+
const stream = await requestCameraStream({
|
|
31
|
+
video: opts.videoConstraints ?? true,
|
|
32
|
+
audio: opts.audioConstraints ?? true,
|
|
33
|
+
});
|
|
34
|
+
return { stream, dispose: () => { } };
|
|
35
|
+
}
|
|
36
|
+
case 'screen':
|
|
37
|
+
case 'screen+mic': {
|
|
38
|
+
const handle = await requestScreenStream({
|
|
39
|
+
video: opts.videoConstraints ?? true,
|
|
40
|
+
systemAudio: opts.systemAudio ?? false,
|
|
41
|
+
includeMicrophone: opts.source === 'screen+mic',
|
|
42
|
+
microphoneConstraints: typeof opts.audioConstraints === 'object' ? opts.audioConstraints : undefined,
|
|
43
|
+
});
|
|
44
|
+
return { stream: handle.stream, dispose: handle.dispose };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Whether the chosen source records video (vs. audio-only). */
|
|
49
|
+
function captureKindFor(source) {
|
|
50
|
+
return source === 'mic' ? 'audio' : 'video';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Returns the kind of capture that the given source produces. Exposed
|
|
54
|
+
* separately from {@link useMediaRecorder} so non-React callers
|
|
55
|
+
* (e.g. headless tests) can resolve a format up front.
|
|
56
|
+
*/
|
|
57
|
+
export function getCaptureKind(source) {
|
|
58
|
+
return captureKindFor(source);
|
|
59
|
+
}
|
|
60
|
+
export function useMediaRecorder(options) {
|
|
61
|
+
const [state, setState] = useState('idle');
|
|
62
|
+
const [stream, setStream] = useState(null);
|
|
63
|
+
const [blob, setBlob] = useState(null);
|
|
64
|
+
const [format, setFormat] = useState(null);
|
|
65
|
+
const [durationMs, setDurationMs] = useState(0);
|
|
66
|
+
const [error, setError] = useState(null);
|
|
67
|
+
const recorderRef = useRef(null);
|
|
68
|
+
const chunksRef = useRef([]);
|
|
69
|
+
const disposeStreamRef = useRef(null);
|
|
70
|
+
const startTimestampRef = useRef(null);
|
|
71
|
+
const tickerRef = useRef(null);
|
|
72
|
+
const stopResolversRef = useRef([]);
|
|
73
|
+
// Stable copy of options for callbacks that read them late. Re-evaluated
|
|
74
|
+
// each render, but each callback closes over the ref so we don't have
|
|
75
|
+
// to recreate them on every options change.
|
|
76
|
+
const optionsRef = useRef(options);
|
|
77
|
+
optionsRef.current = options;
|
|
78
|
+
const clearTicker = useCallback(() => {
|
|
79
|
+
if (tickerRef.current !== null) {
|
|
80
|
+
clearInterval(tickerRef.current);
|
|
81
|
+
tickerRef.current = null;
|
|
82
|
+
}
|
|
83
|
+
}, []);
|
|
84
|
+
const releaseStream = useCallback(() => {
|
|
85
|
+
const s = recorderRef.current?.stream;
|
|
86
|
+
if (s) {
|
|
87
|
+
s.getTracks().forEach((t) => t.stop());
|
|
88
|
+
}
|
|
89
|
+
// Also stop whatever we last handed to setStream — it may differ
|
|
90
|
+
// from recorderRef.current.stream when stream/recorder lifecycles
|
|
91
|
+
// diverged (e.g. cancel before start).
|
|
92
|
+
setStream((current) => {
|
|
93
|
+
current?.getTracks().forEach((t) => t.stop());
|
|
94
|
+
return null;
|
|
95
|
+
});
|
|
96
|
+
disposeStreamRef.current?.();
|
|
97
|
+
disposeStreamRef.current = null;
|
|
98
|
+
}, []);
|
|
99
|
+
const reset = useCallback(() => {
|
|
100
|
+
setBlob(null);
|
|
101
|
+
setDurationMs(0);
|
|
102
|
+
setError(null);
|
|
103
|
+
chunksRef.current = [];
|
|
104
|
+
startTimestampRef.current = null;
|
|
105
|
+
clearTicker();
|
|
106
|
+
// If a stream is still live from a prior `request()`, hop back to
|
|
107
|
+
// `'ready'` so the UI can offer "record again" without the caller
|
|
108
|
+
// having to re-acquire permissions. Otherwise drop to `'idle'`.
|
|
109
|
+
const rec = recorderRef.current;
|
|
110
|
+
if (rec && rec.state === 'inactive' && rec.stream.active) {
|
|
111
|
+
setState('ready');
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
setState('idle');
|
|
115
|
+
}
|
|
116
|
+
}, [clearTicker]);
|
|
117
|
+
const cancel = useCallback(() => {
|
|
118
|
+
const rec = recorderRef.current;
|
|
119
|
+
if (rec && rec.state !== 'inactive') {
|
|
120
|
+
try {
|
|
121
|
+
rec.stop();
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
// Ignore — we're tearing down anyway.
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
recorderRef.current = null;
|
|
128
|
+
releaseStream();
|
|
129
|
+
clearTicker();
|
|
130
|
+
chunksRef.current = [];
|
|
131
|
+
startTimestampRef.current = null;
|
|
132
|
+
// Any in-flight stop() promises won't get a blob.
|
|
133
|
+
stopResolversRef.current.splice(0).forEach((resolve) => resolve(null));
|
|
134
|
+
setBlob(null);
|
|
135
|
+
setDurationMs(0);
|
|
136
|
+
setError(null);
|
|
137
|
+
setState('idle');
|
|
138
|
+
}, [clearTicker, releaseStream]);
|
|
139
|
+
const request = useCallback(async () => {
|
|
140
|
+
if (!supportsMediaRecorder()) {
|
|
141
|
+
const err = new Error('MediaRecorder is not supported in this environment.');
|
|
142
|
+
setError(err);
|
|
143
|
+
setState('error');
|
|
144
|
+
throw err;
|
|
145
|
+
}
|
|
146
|
+
if (state === 'recording' || state === 'stopping') {
|
|
147
|
+
// Don't start a parallel acquisition while one is in flight.
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
setError(null);
|
|
151
|
+
setState('requesting');
|
|
152
|
+
try {
|
|
153
|
+
const { stream: nextStream, dispose } = await acquireStream(optionsRef.current);
|
|
154
|
+
const resolved = resolveFormat(captureKindFor(optionsRef.current.source), optionsRef.current.mimeType);
|
|
155
|
+
const recorderOptions = {};
|
|
156
|
+
if (resolved.mimeType)
|
|
157
|
+
recorderOptions.mimeType = resolved.mimeType;
|
|
158
|
+
if (optionsRef.current.bitsPerSecond) {
|
|
159
|
+
recorderOptions.bitsPerSecond = optionsRef.current.bitsPerSecond;
|
|
160
|
+
}
|
|
161
|
+
const recorder = new MediaRecorder(nextStream, recorderOptions);
|
|
162
|
+
recorder.ondataavailable = (e) => {
|
|
163
|
+
if (e.data && e.data.size > 0)
|
|
164
|
+
chunksRef.current.push(e.data);
|
|
165
|
+
};
|
|
166
|
+
recorder.onstop = () => {
|
|
167
|
+
// The recorded MIME type is authoritative once data is in hand —
|
|
168
|
+
// some browsers down-negotiate the format (e.g. drop codec hint).
|
|
169
|
+
const recordedType = recorder.mimeType || resolved.mimeType || 'application/octet-stream';
|
|
170
|
+
const finalBlob = new Blob(chunksRef.current, { type: recordedType });
|
|
171
|
+
chunksRef.current = [];
|
|
172
|
+
setBlob(finalBlob);
|
|
173
|
+
setState('stopped');
|
|
174
|
+
clearTicker();
|
|
175
|
+
stopResolversRef.current.splice(0).forEach((resolve) => resolve(finalBlob));
|
|
176
|
+
};
|
|
177
|
+
recorder.onerror = (event) => {
|
|
178
|
+
const detail = event.error;
|
|
179
|
+
const err = detail instanceof Error ? detail : new Error('Recorder error');
|
|
180
|
+
setError(err);
|
|
181
|
+
setState('error');
|
|
182
|
+
clearTicker();
|
|
183
|
+
stopResolversRef.current.splice(0).forEach((resolve) => resolve(null));
|
|
184
|
+
};
|
|
185
|
+
recorderRef.current = recorder;
|
|
186
|
+
disposeStreamRef.current = dispose;
|
|
187
|
+
setStream(nextStream);
|
|
188
|
+
setFormat(resolved);
|
|
189
|
+
setBlob(null);
|
|
190
|
+
setDurationMs(0);
|
|
191
|
+
setState('ready');
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
const normalized = err instanceof Error ? err : new Error('Stream acquisition failed');
|
|
195
|
+
setError(normalized);
|
|
196
|
+
setState('error');
|
|
197
|
+
throw normalized;
|
|
198
|
+
}
|
|
199
|
+
}, [state, clearTicker]);
|
|
200
|
+
const start = useCallback(() => {
|
|
201
|
+
const rec = recorderRef.current;
|
|
202
|
+
if (!rec) {
|
|
203
|
+
const err = new Error('Recorder is not ready. Call request() first.');
|
|
204
|
+
setError(err);
|
|
205
|
+
setState('error');
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (rec.state === 'recording')
|
|
209
|
+
return;
|
|
210
|
+
chunksRef.current = [];
|
|
211
|
+
setBlob(null);
|
|
212
|
+
setDurationMs(0);
|
|
213
|
+
startTimestampRef.current = Date.now();
|
|
214
|
+
rec.start(1000);
|
|
215
|
+
setState('recording');
|
|
216
|
+
clearTicker();
|
|
217
|
+
tickerRef.current = setInterval(() => {
|
|
218
|
+
if (startTimestampRef.current !== null) {
|
|
219
|
+
setDurationMs(Date.now() - startTimestampRef.current);
|
|
220
|
+
}
|
|
221
|
+
}, 100);
|
|
222
|
+
}, [clearTicker]);
|
|
223
|
+
const stop = useCallback(() => {
|
|
224
|
+
const rec = recorderRef.current;
|
|
225
|
+
if (!rec || rec.state === 'inactive') {
|
|
226
|
+
return Promise.resolve(blob);
|
|
227
|
+
}
|
|
228
|
+
setState('stopping');
|
|
229
|
+
return new Promise((resolve) => {
|
|
230
|
+
stopResolversRef.current.push(resolve);
|
|
231
|
+
try {
|
|
232
|
+
rec.stop();
|
|
233
|
+
}
|
|
234
|
+
catch (err) {
|
|
235
|
+
const normalized = err instanceof Error ? err : new Error('Failed to stop recorder');
|
|
236
|
+
setError(normalized);
|
|
237
|
+
setState('error');
|
|
238
|
+
clearTicker();
|
|
239
|
+
stopResolversRef.current.splice(0).forEach((r) => r(null));
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}, [blob, clearTicker]);
|
|
243
|
+
// Final unmount cleanup — make sure we don't leak the camera light /
|
|
244
|
+
// screen-capture indicator if the component disappears mid-recording.
|
|
245
|
+
useEffect(() => {
|
|
246
|
+
return () => {
|
|
247
|
+
const rec = recorderRef.current;
|
|
248
|
+
if (rec && rec.state !== 'inactive') {
|
|
249
|
+
try {
|
|
250
|
+
rec.stop();
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
// ignore
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
releaseStream();
|
|
257
|
+
clearTicker();
|
|
258
|
+
stopResolversRef.current.splice(0).forEach((resolve) => resolve(null));
|
|
259
|
+
};
|
|
260
|
+
}, [releaseStream, clearTicker]);
|
|
261
|
+
return {
|
|
262
|
+
state,
|
|
263
|
+
stream,
|
|
264
|
+
blob,
|
|
265
|
+
mimeType: format?.mimeType ?? null,
|
|
266
|
+
extension: format?.extension ?? null,
|
|
267
|
+
directory: format?.directory ?? null,
|
|
268
|
+
durationMs,
|
|
269
|
+
error,
|
|
270
|
+
request,
|
|
271
|
+
start,
|
|
272
|
+
stop,
|
|
273
|
+
cancel,
|
|
274
|
+
reset,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=useMediaRecorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMediaRecorder.js","sourceRoot":"","sources":["../../../src/recorder/hooks/useMediaRecorder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EACL,aAAa,EACb,qBAAqB,GAGtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAA2B,MAAM,4BAA4B,CAAC;AAmF1F;;;;GAIG;AACH,KAAK,UAAU,aAAa,CAC1B,IAA6B;IAE7B,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,KAAK,CAAC,CAAC,CAAC;YACX,MAAM,KAAK,GAAG,OAAO,IAAI,CAAC,gBAAgB,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC;YAC5F,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,KAAK,CAAC,CAAC;YAC7C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC;QACvC,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,MAAM,GAAG,MAAM,mBAAmB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;QACpC,SAAS,EAAE,MAAM,EAAE,SAAS,IAAI,IAAI;QACpC,UAAU;QACV,KAAK;QACL,OAAO;QACP,KAAK;QACL,IAAI;QACJ,MAAM;QACN,KAAK;KACN,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useStreamPreview — binds a `MediaStream` to a `<video>` element's
|
|
3
|
+
* `srcObject`. Decouples the preview surface from `useMediaRecorder`,
|
|
4
|
+
* letting hosts compose the preview element however they like.
|
|
5
|
+
*/
|
|
6
|
+
import { type RefObject } from 'react';
|
|
7
|
+
/**
|
|
8
|
+
* Assign `stream` to `<video>.srcObject` whenever either changes; clears
|
|
9
|
+
* it on unmount or when `stream` is `null`. The element is set to
|
|
10
|
+
* `playsInline` + `muted` automatically because previewing your own
|
|
11
|
+
* microphone with audio playthrough creates a feedback loop.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const videoRef = useRef<HTMLVideoElement>(null);
|
|
16
|
+
* const { stream } = useMediaRecorder({ source: 'camera' });
|
|
17
|
+
* useStreamPreview(videoRef, stream);
|
|
18
|
+
* return <video ref={videoRef} autoPlay />;
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function useStreamPreview(ref: RefObject<HTMLVideoElement | null>, stream: MediaStream | null): void;
|
|
22
|
+
//# sourceMappingURL=useStreamPreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStreamPreview.d.ts","sourceRoot":"","sources":["../../../src/recorder/hooks/useStreamPreview.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAElD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,EACvC,MAAM,EAAE,WAAW,GAAG,IAAI,GACzB,IAAI,CAqBN"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useStreamPreview — binds a `MediaStream` to a `<video>` element's
|
|
3
|
+
* `srcObject`. Decouples the preview surface from `useMediaRecorder`,
|
|
4
|
+
* letting hosts compose the preview element however they like.
|
|
5
|
+
*/
|
|
6
|
+
import { useEffect } from 'react';
|
|
7
|
+
/**
|
|
8
|
+
* Assign `stream` to `<video>.srcObject` whenever either changes; clears
|
|
9
|
+
* it on unmount or when `stream` is `null`. The element is set to
|
|
10
|
+
* `playsInline` + `muted` automatically because previewing your own
|
|
11
|
+
* microphone with audio playthrough creates a feedback loop.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const videoRef = useRef<HTMLVideoElement>(null);
|
|
16
|
+
* const { stream } = useMediaRecorder({ source: 'camera' });
|
|
17
|
+
* useStreamPreview(videoRef, stream);
|
|
18
|
+
* return <video ref={videoRef} autoPlay />;
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export function useStreamPreview(ref, stream) {
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const el = ref.current;
|
|
24
|
+
if (!el)
|
|
25
|
+
return;
|
|
26
|
+
el.muted = true;
|
|
27
|
+
el.playsInline = true;
|
|
28
|
+
el.srcObject = stream;
|
|
29
|
+
if (stream) {
|
|
30
|
+
// Some browsers don't auto-play on srcObject assignment; trigger
|
|
31
|
+
// it explicitly and ignore the inevitable "user gesture required"
|
|
32
|
+
// rejections — the preview will play on the next interaction.
|
|
33
|
+
void el.play().catch(() => { });
|
|
34
|
+
}
|
|
35
|
+
return () => {
|
|
36
|
+
// Only detach when this effect is tearing down. Don't stop tracks
|
|
37
|
+
// — that's the recorder's responsibility.
|
|
38
|
+
if (el.srcObject === stream) {
|
|
39
|
+
el.srcObject = null;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}, [ref, stream]);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=useStreamPreview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStreamPreview.js","sourceRoot":"","sources":["../../../src/recorder/hooks/useStreamPreview.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAkB,MAAM,OAAO,CAAC;AAElD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAuC,EACvC,MAA0B;IAE1B,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE;YAAE,OAAO;QAChB,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC;QAChB,EAAE,CAAC,WAAW,GAAG,IAAI,CAAC;QACtB,EAAE,CAAC,SAAS,GAAG,MAAM,CAAC;QACtB,IAAI,MAAM,EAAE,CAAC;YACX,iEAAiE;YACjE,kEAAkE;YAClE,8DAA8D;YAC9D,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,GAAG,EAAE;YACV,kEAAkE;YAClE,0CAA0C;YAC1C,IAAI,EAAE,CAAC,SAAS,KAAK,MAAM,EAAE,CAAC;gBAC5B,EAAE,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Camera + microphone capture via `getUserMedia({ video, audio })`.
|
|
3
|
+
*/
|
|
4
|
+
export interface CameraStreamOptions {
|
|
5
|
+
/** Video track constraints (resolution, facing mode, frame rate). Pass `true` for browser default, or `false` to omit video. */
|
|
6
|
+
video?: boolean | MediaTrackConstraints;
|
|
7
|
+
/** Audio track constraints. Pass `true` for browser default, or `false` to omit audio. */
|
|
8
|
+
audio?: boolean | MediaTrackConstraints;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Request a camera + mic `MediaStream`. Caller owns the stream and must
|
|
12
|
+
* stop its tracks when done.
|
|
13
|
+
*
|
|
14
|
+
* Both tracks are requested by default. To capture video only, pass
|
|
15
|
+
* `audio: false`; to capture audio only use {@link requestMicStream}
|
|
16
|
+
* instead.
|
|
17
|
+
*
|
|
18
|
+
* @throws When `mediaDevices` is unavailable, or when the user denies
|
|
19
|
+
* permission.
|
|
20
|
+
*/
|
|
21
|
+
export declare function requestCameraStream(options?: CameraStreamOptions): Promise<MediaStream>;
|
|
22
|
+
//# sourceMappingURL=cameraStream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cameraStream.d.ts","sourceRoot":"","sources":["../../../src/recorder/sources/cameraStream.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,mBAAmB;IAClC,gIAAgI;IAChI,KAAK,CAAC,EAAE,OAAO,GAAG,qBAAqB,CAAC;IACxC,0FAA0F;IAC1F,KAAK,CAAC,EAAE,OAAO,GAAG,qBAAqB,CAAC;CACzC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC,CAO7F"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Camera + microphone capture via `getUserMedia({ video, audio })`.
|
|
3
|
+
*/
|
|
4
|
+
import { supportsUserMedia } from '../formats.js';
|
|
5
|
+
/**
|
|
6
|
+
* Request a camera + mic `MediaStream`. Caller owns the stream and must
|
|
7
|
+
* stop its tracks when done.
|
|
8
|
+
*
|
|
9
|
+
* Both tracks are requested by default. To capture video only, pass
|
|
10
|
+
* `audio: false`; to capture audio only use {@link requestMicStream}
|
|
11
|
+
* instead.
|
|
12
|
+
*
|
|
13
|
+
* @throws When `mediaDevices` is unavailable, or when the user denies
|
|
14
|
+
* permission.
|
|
15
|
+
*/
|
|
16
|
+
export async function requestCameraStream(options) {
|
|
17
|
+
if (!supportsUserMedia()) {
|
|
18
|
+
throw new Error('navigator.mediaDevices.getUserMedia is not available in this environment.');
|
|
19
|
+
}
|
|
20
|
+
const video = options?.video ?? true;
|
|
21
|
+
const audio = options?.audio ?? true;
|
|
22
|
+
return navigator.mediaDevices.getUserMedia({ video, audio });
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=cameraStream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cameraStream.js","sourceRoot":"","sources":["../../../src/recorder/sources/cameraStream.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AASlD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAA6B;IACrE,IAAI,CAAC,iBAAiB,EAAE,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;IAC/F,CAAC;IACD,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,IAAI,CAAC;IACrC,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,IAAI,CAAC;IACrC,OAAO,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Microphone-only capture via `getUserMedia({ audio: true })`.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Request a microphone-only `MediaStream`. Caller owns the stream and
|
|
6
|
+
* must stop its tracks when done.
|
|
7
|
+
*
|
|
8
|
+
* @param constraints - Optional audio constraints (sample rate, device
|
|
9
|
+
* id, echo cancellation, etc.). Defaults to `true` — let the browser
|
|
10
|
+
* pick.
|
|
11
|
+
* @throws When `mediaDevices` is unavailable, or when the user denies
|
|
12
|
+
* permission (the underlying `getUserMedia` rejection propagates).
|
|
13
|
+
*/
|
|
14
|
+
export declare function requestMicStream(constraints?: MediaTrackConstraints): Promise<MediaStream>;
|
|
15
|
+
//# sourceMappingURL=micStream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"micStream.d.ts","sourceRoot":"","sources":["../../../src/recorder/sources/micStream.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,WAAW,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,WAAW,CAAC,CAQhG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Microphone-only capture via `getUserMedia({ audio: true })`.
|
|
3
|
+
*/
|
|
4
|
+
import { supportsUserMedia } from '../formats.js';
|
|
5
|
+
/**
|
|
6
|
+
* Request a microphone-only `MediaStream`. Caller owns the stream and
|
|
7
|
+
* must stop its tracks when done.
|
|
8
|
+
*
|
|
9
|
+
* @param constraints - Optional audio constraints (sample rate, device
|
|
10
|
+
* id, echo cancellation, etc.). Defaults to `true` — let the browser
|
|
11
|
+
* pick.
|
|
12
|
+
* @throws When `mediaDevices` is unavailable, or when the user denies
|
|
13
|
+
* permission (the underlying `getUserMedia` rejection propagates).
|
|
14
|
+
*/
|
|
15
|
+
export async function requestMicStream(constraints) {
|
|
16
|
+
if (!supportsUserMedia()) {
|
|
17
|
+
throw new Error('navigator.mediaDevices.getUserMedia is not available in this environment.');
|
|
18
|
+
}
|
|
19
|
+
return navigator.mediaDevices.getUserMedia({
|
|
20
|
+
audio: constraints ?? true,
|
|
21
|
+
video: false,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=micStream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"micStream.js","sourceRoot":"","sources":["../../../src/recorder/sources/micStream.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,WAAmC;IACxE,IAAI,CAAC,iBAAiB,EAAE,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;IAC/F,CAAC;IACD,OAAO,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC;QACzC,KAAK,EAAE,WAAW,IAAI,IAAI;QAC1B,KAAK,EAAE,KAAK;KACb,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Screen capture via `getDisplayMedia`, with optional microphone mixing.
|
|
3
|
+
*
|
|
4
|
+
* The browser-native `getDisplayMedia({ audio: true })` flag only
|
|
5
|
+
* captures *system* audio (and only on Chromium on desktop). For
|
|
6
|
+
* narrated screencasts, hosts usually want the speaker's voice too —
|
|
7
|
+
* we provide an opt-in "include mic" path that pulls a parallel
|
|
8
|
+
* `getUserMedia` audio track and mixes it into the screen stream via
|
|
9
|
+
* `AudioContext`, so the resulting `MediaStream` carries a single audio
|
|
10
|
+
* track and a single video track.
|
|
11
|
+
*/
|
|
12
|
+
export interface ScreenStreamOptions {
|
|
13
|
+
/** Video constraints for the screen surface. Pass `true` for browser default. */
|
|
14
|
+
video?: boolean | MediaTrackConstraints;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to attempt to capture the system audio (tab / window / monitor
|
|
17
|
+
* audio). Browser support is limited (desktop Chromium only); when the
|
|
18
|
+
* platform doesn't honor this flag, the resulting stream simply omits
|
|
19
|
+
* the system audio track.
|
|
20
|
+
*/
|
|
21
|
+
systemAudio?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to also pull the microphone via `getUserMedia` and mix it
|
|
24
|
+
* into the resulting stream's audio track. When both `systemAudio` and
|
|
25
|
+
* `includeMicrophone` produce tracks, they're combined via
|
|
26
|
+
* `AudioContext` into a single output track.
|
|
27
|
+
*/
|
|
28
|
+
includeMicrophone?: boolean;
|
|
29
|
+
/** Microphone track constraints, when `includeMicrophone` is true. */
|
|
30
|
+
microphoneConstraints?: MediaTrackConstraints;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Handle returned by {@link requestScreenStream}. The `stream` is what
|
|
34
|
+
* gets handed to `MediaRecorder`; the `dispose()` callback shuts down
|
|
35
|
+
* any auxiliary resources (e.g. the mic-mix `AudioContext`). Callers
|
|
36
|
+
* must also stop the stream's tracks via `stream.getTracks().forEach(t
|
|
37
|
+
* => t.stop())` when done — `dispose()` cleans up everything that isn't
|
|
38
|
+
* the stream itself.
|
|
39
|
+
*/
|
|
40
|
+
export interface ScreenStreamHandle {
|
|
41
|
+
stream: MediaStream;
|
|
42
|
+
/** Auxiliary cleanup beyond the stream tracks. Safe to call multiple times. */
|
|
43
|
+
dispose: () => void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Request a screen-capture `MediaStream`, optionally with a mixed-in
|
|
47
|
+
* microphone track. Caller owns the resulting stream.
|
|
48
|
+
*
|
|
49
|
+
* @throws When `getDisplayMedia` isn't available, or when the user
|
|
50
|
+
* cancels the picker / denies permission.
|
|
51
|
+
*/
|
|
52
|
+
export declare function requestScreenStream(options?: ScreenStreamOptions): Promise<ScreenStreamHandle>;
|
|
53
|
+
//# sourceMappingURL=screenStream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenStream.d.ts","sourceRoot":"","sources":["../../../src/recorder/sources/screenStream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,MAAM,WAAW,mBAAmB;IAClC,iFAAiF;IACjF,KAAK,CAAC,EAAE,OAAO,GAAG,qBAAqB,CAAC;IACxC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sEAAsE;IACtE,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;CAC/C;AA8BD;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,WAAW,CAAC;IACpB,+EAA+E;IAC/E,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,kBAAkB,CAAC,CA2E7B"}
|