@datalayer/lexical-loro 0.2.5 → 1.0.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/package.json +1 -1
- package/lib/App.d.ts +0 -2
- package/lib/App.js +0 -141
- package/lib/Editor.d.ts +0 -2
- package/lib/Editor.js +0 -115
- package/lib/Settings.d.ts +0 -2
- package/lib/Settings.js +0 -57
- package/lib/appSettings.d.ts +0 -36
- package/lib/appSettings.js +0 -48
- package/lib/collab/loro/Bindings.d.ts +0 -41
- package/lib/collab/loro/Bindings.js +0 -99
- package/lib/collab/loro/Debug.d.ts +0 -33
- package/lib/collab/loro/Debug.js +0 -452
- package/lib/collab/loro/LexicalCollaborationContext.d.ts +0 -19
- package/lib/collab/loro/LexicalCollaborationContext.js +0 -52
- package/lib/collab/loro/LexicalCollaborationPlugin.d.ts +0 -24
- package/lib/collab/loro/LexicalCollaborationPlugin.js +0 -83
- package/lib/collab/loro/State.d.ts +0 -53
- package/lib/collab/loro/State.js +0 -94
- package/lib/collab/loro/components/LoroCollaborationUI.d.ts +0 -13
- package/lib/collab/loro/components/LoroCollaborationUI.js +0 -9
- package/lib/collab/loro/components/LoroCollaborators.d.ts +0 -8
- package/lib/collab/loro/components/LoroCollaborators.js +0 -102
- package/lib/collab/loro/components/index.d.ts +0 -2
- package/lib/collab/loro/components/index.js +0 -6
- package/lib/collab/loro/index.d.ts +0 -6
- package/lib/collab/loro/index.js +0 -10
- package/lib/collab/loro/integrators/BaseIntegrator.d.ts +0 -14
- package/lib/collab/loro/integrators/BaseIntegrator.js +0 -5
- package/lib/collab/loro/integrators/CounterIntegrator.d.ts +0 -23
- package/lib/collab/loro/integrators/CounterIntegrator.js +0 -44
- package/lib/collab/loro/integrators/ListIntegrator.d.ts +0 -23
- package/lib/collab/loro/integrators/ListIntegrator.js +0 -53
- package/lib/collab/loro/integrators/MapIntegrator.d.ts +0 -24
- package/lib/collab/loro/integrators/MapIntegrator.js +0 -235
- package/lib/collab/loro/integrators/TextIntegrator.d.ts +0 -25
- package/lib/collab/loro/integrators/TextIntegrator.js +0 -55
- package/lib/collab/loro/integrators/TreeIntegrator.d.ts +0 -36
- package/lib/collab/loro/integrators/TreeIntegrator.js +0 -251
- package/lib/collab/loro/nodes/NodeFactory.d.ts +0 -15
- package/lib/collab/loro/nodes/NodeFactory.js +0 -101
- package/lib/collab/loro/nodes/NodesMapper.d.ts +0 -120
- package/lib/collab/loro/nodes/NodesMapper.js +0 -277
- package/lib/collab/loro/propagators/DecoratorNodePropagator.d.ts +0 -60
- package/lib/collab/loro/propagators/DecoratorNodePropagator.js +0 -306
- package/lib/collab/loro/propagators/ElementNodePropagator.d.ts +0 -62
- package/lib/collab/loro/propagators/ElementNodePropagator.js +0 -326
- package/lib/collab/loro/propagators/LineBreakNodePropagator.d.ts +0 -57
- package/lib/collab/loro/propagators/LineBreakNodePropagator.js +0 -200
- package/lib/collab/loro/propagators/RootNodePropagator.d.ts +0 -55
- package/lib/collab/loro/propagators/RootNodePropagator.js +0 -174
- package/lib/collab/loro/propagators/TextNodePropagator.d.ts +0 -60
- package/lib/collab/loro/propagators/TextNodePropagator.js +0 -440
- package/lib/collab/loro/propagators/index.d.ts +0 -49
- package/lib/collab/loro/propagators/index.js +0 -30
- package/lib/collab/loro/provider/websocket.d.ts +0 -116
- package/lib/collab/loro/provider/websocket.js +0 -911
- package/lib/collab/loro/servers/index.d.ts +0 -0
- package/lib/collab/loro/servers/index.js +0 -4
- package/lib/collab/loro/servers/ws/callback.d.ts +0 -5
- package/lib/collab/loro/servers/ws/callback.js +0 -89
- package/lib/collab/loro/servers/ws/server.d.ts +0 -2
- package/lib/collab/loro/servers/ws/server.js +0 -29
- package/lib/collab/loro/servers/ws/utils.d.ts +0 -40
- package/lib/collab/loro/servers/ws/utils.js +0 -517
- package/lib/collab/loro/sync/SyncCursors.d.ts +0 -32
- package/lib/collab/loro/sync/SyncCursors.js +0 -475
- package/lib/collab/loro/sync/SyncLexicalToLoro.d.ts +0 -4
- package/lib/collab/loro/sync/SyncLexicalToLoro.js +0 -113
- package/lib/collab/loro/sync/SyncLoroToLexical.d.ts +0 -5
- package/lib/collab/loro/sync/SyncLoroToLexical.js +0 -100
- package/lib/collab/loro/types/LexicalNodeData.d.ts +0 -32
- package/lib/collab/loro/types/LexicalNodeData.js +0 -75
- package/lib/collab/loro/useCollaboration.d.ts +0 -12
- package/lib/collab/loro/useCollaboration.js +0 -260
- package/lib/collab/loro/utils/InitialContent.d.ts +0 -64
- package/lib/collab/loro/utils/InitialContent.js +0 -113
- package/lib/collab/loro/utils/LexicalToLoro.d.ts +0 -18
- package/lib/collab/loro/utils/LexicalToLoro.js +0 -100
- package/lib/collab/loro/utils/Utils.d.ts +0 -44
- package/lib/collab/loro/utils/Utils.js +0 -157
- package/lib/collab/loro/wsProvider.d.ts +0 -8
- package/lib/collab/loro/wsProvider.js +0 -35
- package/lib/collab/utils/invariant.d.ts +0 -1
- package/lib/collab/utils/invariant.js +0 -15
- package/lib/collab/utils/simpleDiffWithCursor.d.ts +0 -5
- package/lib/collab/utils/simpleDiffWithCursor.js +0 -35
- package/lib/collab/yjs/Bindings.d.ts +0 -23
- package/lib/collab/yjs/Bindings.js +0 -26
- package/lib/collab/yjs/Debug.d.ts +0 -23
- package/lib/collab/yjs/Debug.js +0 -213
- package/lib/collab/yjs/LexicalCollaborationContext.d.ts +0 -10
- package/lib/collab/yjs/LexicalCollaborationContext.js +0 -37
- package/lib/collab/yjs/LexicalCollaborationPlugin.d.ts +0 -21
- package/lib/collab/yjs/LexicalCollaborationPlugin.js +0 -63
- package/lib/collab/yjs/State.d.ts +0 -51
- package/lib/collab/yjs/State.js +0 -35
- package/lib/collab/yjs/nodes/AnyCollabNode.d.ts +0 -5
- package/lib/collab/yjs/nodes/AnyCollabNode.js +0 -1
- package/lib/collab/yjs/nodes/CollabDecoratorNode.d.ts +0 -22
- package/lib/collab/yjs/nodes/CollabDecoratorNode.js +0 -64
- package/lib/collab/yjs/nodes/CollabElementNode.d.ts +0 -40
- package/lib/collab/yjs/nodes/CollabElementNode.js +0 -462
- package/lib/collab/yjs/nodes/CollabLineBreakNode.d.ts +0 -19
- package/lib/collab/yjs/nodes/CollabLineBreakNode.js +0 -44
- package/lib/collab/yjs/nodes/CollabTextNode.d.ts +0 -25
- package/lib/collab/yjs/nodes/CollabTextNode.js +0 -103
- package/lib/collab/yjs/provider/websocket.d.ts +0 -88
- package/lib/collab/yjs/provider/websocket.js +0 -415
- package/lib/collab/yjs/servers/index.d.ts +0 -0
- package/lib/collab/yjs/servers/index.js +0 -0
- package/lib/collab/yjs/servers/ws/callback.d.ts +0 -5
- package/lib/collab/yjs/servers/ws/callback.js +0 -72
- package/lib/collab/yjs/servers/ws/server.d.ts +0 -2
- package/lib/collab/yjs/servers/ws/server.js +0 -25
- package/lib/collab/yjs/servers/ws/utils.d.ts +0 -49
- package/lib/collab/yjs/servers/ws/utils.js +0 -284
- package/lib/collab/yjs/sync/SyncCursors.d.ts +0 -39
- package/lib/collab/yjs/sync/SyncCursors.js +0 -351
- package/lib/collab/yjs/sync/SyncEditorStates.d.ts +0 -10
- package/lib/collab/yjs/sync/SyncEditorStates.js +0 -200
- package/lib/collab/yjs/useCollaboration.d.ts +0 -12
- package/lib/collab/yjs/useCollaboration.js +0 -255
- package/lib/collab/yjs/utils/Utils.d.ts +0 -25
- package/lib/collab/yjs/utils/Utils.js +0 -402
- package/lib/collab/yjs/wsProvider.d.ts +0 -3
- package/lib/collab/yjs/wsProvider.js +0 -21
- package/lib/commenting/index.d.ts +0 -41
- package/lib/commenting/index.js +0 -328
- package/lib/context/FlashMessageContext.d.ts +0 -7
- package/lib/context/FlashMessageContext.js +0 -24
- package/lib/context/SettingsContext.d.ts +0 -12
- package/lib/context/SettingsContext.js +0 -38
- package/lib/context/SharedHistoryContext.d.ts +0 -11
- package/lib/context/SharedHistoryContext.js +0 -11
- package/lib/context/ToolbarContext.d.ts +0 -65
- package/lib/context/ToolbarContext.js +0 -84
- package/lib/demo.d.ts +0 -12
- package/lib/demo.js +0 -45
- package/lib/hooks/useFlashMessage.d.ts +0 -2
- package/lib/hooks/useFlashMessage.js +0 -8
- package/lib/hooks/useModal.d.ts +0 -5
- package/lib/hooks/useModal.js +0 -26
- package/lib/hooks/useReport.d.ts +0 -1
- package/lib/hooks/useReport.js +0 -50
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -5
- package/lib/nodes/AutocompleteNode.d.ts +0 -27
- package/lib/nodes/AutocompleteNode.js +0 -60
- package/lib/nodes/CounterComponent.d.ts +0 -6
- package/lib/nodes/CounterComponent.js +0 -137
- package/lib/nodes/CounterNode.d.ts +0 -23
- package/lib/nodes/CounterNode.js +0 -47
- package/lib/nodes/DateTimeNode/DateTimeComponent.d.ts +0 -8
- package/lib/nodes/DateTimeNode/DateTimeComponent.js +0 -119
- package/lib/nodes/DateTimeNode/DateTimeNode.d.ts +0 -27
- package/lib/nodes/DateTimeNode/DateTimeNode.js +0 -82
- package/lib/nodes/EmojiNode.d.ts +0 -18
- package/lib/nodes/EmojiNode.js +0 -54
- package/lib/nodes/EquationComponent.d.ts +0 -9
- package/lib/nodes/EquationComponent.js +0 -75
- package/lib/nodes/EquationNode.d.ts +0 -26
- package/lib/nodes/EquationNode.js +0 -109
- package/lib/nodes/ExcalidrawNode/ExcalidrawComponent.d.ts +0 -8
- package/lib/nodes/ExcalidrawNode/ExcalidrawComponent.js +0 -110
- package/lib/nodes/ExcalidrawNode/ExcalidrawImage.d.ts +0 -50
- package/lib/nodes/ExcalidrawNode/ExcalidrawImage.js +0 -55
- package/lib/nodes/ExcalidrawNode/index.d.ts +0 -32
- package/lib/nodes/ExcalidrawNode/index.js +0 -117
- package/lib/nodes/FigmaNode.d.ts +0 -20
- package/lib/nodes/FigmaNode.js +0 -52
- package/lib/nodes/ImageComponent.d.ts +0 -16
- package/lib/nodes/ImageComponent.js +0 -272
- package/lib/nodes/ImageNode.d.ts +0 -50
- package/lib/nodes/ImageNode.js +0 -151
- package/lib/nodes/InlineImageNode/InlineImageComponent.d.ts +0 -26
- package/lib/nodes/InlineImageNode/InlineImageComponent.js +0 -161
- package/lib/nodes/InlineImageNode/InlineImageNode.d.ts +0 -59
- package/lib/nodes/InlineImageNode/InlineImageNode.js +0 -162
- package/lib/nodes/KeywordNode.d.ts +0 -14
- package/lib/nodes/KeywordNode.js +0 -37
- package/lib/nodes/LayoutContainerNode.d.ts +0 -24
- package/lib/nodes/LayoutContainerNode.js +0 -95
- package/lib/nodes/LayoutItemNode.d.ts +0 -16
- package/lib/nodes/LayoutItemNode.js +0 -69
- package/lib/nodes/MentionNode.d.ts +0 -20
- package/lib/nodes/MentionNode.js +0 -85
- package/lib/nodes/PageBreakNode/index.d.ts +0 -17
- package/lib/nodes/PageBreakNode/index.js +0 -83
- package/lib/nodes/PlaygroundNodes.d.ts +0 -3
- package/lib/nodes/PlaygroundNodes.js +0 -75
- package/lib/nodes/PollComponent.d.ts +0 -9
- package/lib/nodes/PollComponent.js +0 -85
- package/lib/nodes/PollNode.d.ts +0 -43
- package/lib/nodes/PollNode.js +0 -153
- package/lib/nodes/SpecialTextNode.d.ts +0 -24
- package/lib/nodes/SpecialTextNode.js +0 -54
- package/lib/nodes/StickyComponent.d.ts +0 -10
- package/lib/nodes/StickyComponent.js +0 -162
- package/lib/nodes/StickyNode.d.ts +0 -31
- package/lib/nodes/StickyNode.js +0 -76
- package/lib/nodes/TweetNode.d.ts +0 -21
- package/lib/nodes/TweetNode.js +0 -119
- package/lib/nodes/YouTubeNode.d.ts +0 -22
- package/lib/nodes/YouTubeNode.js +0 -84
- package/lib/plugins/ActionsPlugin/index.d.ts +0 -5
- package/lib/plugins/ActionsPlugin/index.js +0 -168
- package/lib/plugins/AutoEmbedPlugin/index.d.ts +0 -19
- package/lib/plugins/AutoEmbedPlugin/index.js +0 -158
- package/lib/plugins/AutoLinkPlugin/index.d.ts +0 -2
- package/lib/plugins/AutoLinkPlugin/index.js +0 -15
- package/lib/plugins/AutocompletePlugin/index.d.ts +0 -10
- package/lib/plugins/AutocompletePlugin/index.js +0 -2477
- package/lib/plugins/CodeActionMenuPlugin/components/CopyButton/index.d.ts +0 -7
- package/lib/plugins/CodeActionMenuPlugin/components/CopyButton/index.js +0 -46
- package/lib/plugins/CodeActionMenuPlugin/components/PrettierButton/index.d.ts +0 -17
- package/lib/plugins/CodeActionMenuPlugin/components/PrettierButton/index.js +0 -115
- package/lib/plugins/CodeActionMenuPlugin/index.d.ts +0 -5
- package/lib/plugins/CodeActionMenuPlugin/index.js +0 -104
- package/lib/plugins/CodeActionMenuPlugin/utils.d.ts +0 -1
- package/lib/plugins/CodeActionMenuPlugin/utils.js +0 -22
- package/lib/plugins/CodeHighlightPrismPlugin/index.d.ts +0 -2
- package/lib/plugins/CodeHighlightPrismPlugin/index.js +0 -14
- package/lib/plugins/CodeHighlightShikiPlugin/index.d.ts +0 -2
- package/lib/plugins/CodeHighlightShikiPlugin/index.js +0 -14
- package/lib/plugins/CollapsiblePlugin/CollapsibleContainerNode.d.ts +0 -25
- package/lib/plugins/CollapsiblePlugin/CollapsibleContainerNode.js +0 -135
- package/lib/plugins/CollapsiblePlugin/CollapsibleContentNode.d.ts +0 -16
- package/lib/plugins/CollapsiblePlugin/CollapsibleContentNode.js +0 -83
- package/lib/plugins/CollapsiblePlugin/CollapsibleTitleNode.d.ts +0 -16
- package/lib/plugins/CollapsiblePlugin/CollapsibleTitleNode.js +0 -85
- package/lib/plugins/CollapsiblePlugin/CollapsibleUtils.d.ts +0 -2
- package/lib/plugins/CollapsiblePlugin/CollapsibleUtils.js +0 -12
- package/lib/plugins/CollapsiblePlugin/index.d.ts +0 -3
- package/lib/plugins/CollapsiblePlugin/index.js +0 -132
- package/lib/plugins/CommentPlugin/index.d.ts +0 -9
- package/lib/plugins/CommentPlugin/index.js +0 -460
- package/lib/plugins/ComponentPickerPlugin/index.d.ts +0 -2
- package/lib/plugins/ComponentPickerPlugin/index.js +0 -276
- package/lib/plugins/ContextMenuPlugin/index.d.ts +0 -2
- package/lib/plugins/ContextMenuPlugin/index.js +0 -112
- package/lib/plugins/CounterPlugin/index.d.ts +0 -3
- package/lib/plugins/CounterPlugin/index.js +0 -24
- package/lib/plugins/DateTimePlugin/index.d.ts +0 -8
- package/lib/plugins/DateTimePlugin/index.js +0 -28
- package/lib/plugins/DebugPlugin/index.d.ts +0 -3
- package/lib/plugins/DebugPlugin/index.js +0 -219
- package/lib/plugins/DocsPlugin/index.d.ts +0 -2
- package/lib/plugins/DocsPlugin/index.js +0 -4
- package/lib/plugins/DragDropPastePlugin/index.d.ts +0 -1
- package/lib/plugins/DragDropPastePlugin/index.js +0 -37
- package/lib/plugins/DraggableBlockPlugin/index.d.ts +0 -12
- package/lib/plugins/DraggableBlockPlugin/index.js +0 -36
- package/lib/plugins/EmojiPickerPlugin/index.d.ts +0 -1
- package/lib/plugins/EmojiPickerPlugin/index.js +0 -84
- package/lib/plugins/EmojisPlugin/index.d.ts +0 -2
- package/lib/plugins/EmojisPlugin/index.js +0 -56
- package/lib/plugins/EquationsPlugin/index.d.ts +0 -14
- package/lib/plugins/EquationsPlugin/index.js +0 -34
- package/lib/plugins/ExcalidrawPlugin/index.d.ts +0 -5
- package/lib/plugins/ExcalidrawPlugin/index.js +0 -44
- package/lib/plugins/FigmaPlugin/index.d.ts +0 -4
- package/lib/plugins/FigmaPlugin/index.js +0 -24
- package/lib/plugins/FloatingLinkEditorPlugin/index.d.ts +0 -15
- package/lib/plugins/FloatingLinkEditorPlugin/index.js +0 -280
- package/lib/plugins/FloatingTextFormatToolbarPlugin/index.d.ts +0 -7
- package/lib/plugins/FloatingTextFormatToolbarPlugin/index.js +0 -219
- package/lib/plugins/ImagesPlugin/index.d.ts +0 -24
- package/lib/plugins/ImagesPlugin/index.js +0 -195
- package/lib/plugins/InlineImagePlugin/index.d.ts +0 -17
- package/lib/plugins/InlineImagePlugin/index.js +0 -180
- package/lib/plugins/KeywordsPlugin/index.d.ts +0 -2
- package/lib/plugins/KeywordsPlugin/index.js +0 -35
- package/lib/plugins/LayoutPlugin/InsertLayoutDialog.d.ts +0 -6
- package/lib/plugins/LayoutPlugin/InsertLayoutDialog.js +0 -21
- package/lib/plugins/LayoutPlugin/LayoutPlugin.d.ts +0 -7
- package/lib/plugins/LayoutPlugin/LayoutPlugin.js +0 -135
- package/lib/plugins/LinkPlugin/index.d.ts +0 -6
- package/lib/plugins/LinkPlugin/index.js +0 -11
- package/lib/plugins/MarkdownShortcutPlugin/index.d.ts +0 -2
- package/lib/plugins/MarkdownShortcutPlugin/index.js +0 -6
- package/lib/plugins/MarkdownTransformers/index.d.ts +0 -8
- package/lib/plugins/MarkdownTransformers/index.js +0 -238
- package/lib/plugins/MaxLengthPlugin/index.d.ts +0 -3
- package/lib/plugins/MaxLengthPlugin/index.js +0 -41
- package/lib/plugins/MentionsPlugin/index.d.ts +0 -2
- package/lib/plugins/MentionsPlugin/index.js +0 -564
- package/lib/plugins/PageBreakPlugin/index.d.ts +0 -4
- package/lib/plugins/PageBreakPlugin/index.js +0 -31
- package/lib/plugins/PasteLogPlugin/index.d.ts +0 -2
- package/lib/plugins/PasteLogPlugin/index.js +0 -27
- package/lib/plugins/PollPlugin/index.d.ts +0 -8
- package/lib/plugins/PollPlugin/index.js +0 -38
- package/lib/plugins/ShortcutsPlugin/index.d.ts +0 -6
- package/lib/plugins/ShortcutsPlugin/index.js +0 -116
- package/lib/plugins/ShortcutsPlugin/shortcuts.d.ts +0 -59
- package/lib/plugins/ShortcutsPlugin/shortcuts.js +0 -173
- package/lib/plugins/SpecialTextPlugin/index.d.ts +0 -2
- package/lib/plugins/SpecialTextPlugin/index.js +0 -50
- package/lib/plugins/SpeechToTextPlugin/index.d.ts +0 -5
- package/lib/plugins/SpeechToTextPlugin/index.js +0 -86
- package/lib/plugins/StickyPlugin/index.d.ts +0 -2
- package/lib/plugins/StickyPlugin/index.js +0 -16
- package/lib/plugins/TabFocusPlugin/index.d.ts +0 -1
- package/lib/plugins/TabFocusPlugin/index.js +0 -38
- package/lib/plugins/TableActionMenuPlugin/index.d.ts +0 -5
- package/lib/plugins/TableActionMenuPlugin/index.js +0 -492
- package/lib/plugins/TableCellResizer/index.d.ts +0 -3
- package/lib/plugins/TableCellResizer/index.js +0 -297
- package/lib/plugins/TableHoverActionsPlugin/index.d.ts +0 -4
- package/lib/plugins/TableHoverActionsPlugin/index.js +0 -188
- package/lib/plugins/TableOfContentsPlugin/index.d.ts +0 -2
- package/lib/plugins/TableOfContentsPlugin/index.js +0 -116
- package/lib/plugins/TablePlugin.d.ts +0 -31
- package/lib/plugins/TablePlugin.js +0 -63
- package/lib/plugins/TestRecorderPlugin/index.d.ts +0 -3
- package/lib/plugins/TestRecorderPlugin/index.js +0 -346
- package/lib/plugins/ToolbarPlugin/fontSize.d.ts +0 -9
- package/lib/plugins/ToolbarPlugin/fontSize.js +0 -84
- package/lib/plugins/ToolbarPlugin/index.d.ts +0 -9
- package/lib/plugins/ToolbarPlugin/index.js +0 -500
- package/lib/plugins/ToolbarPlugin/utils.d.ts +0 -26
- package/lib/plugins/ToolbarPlugin/utils.js +0 -247
- package/lib/plugins/TreeViewPlugin/index.d.ts +0 -2
- package/lib/plugins/TreeViewPlugin/index.js +0 -7
- package/lib/plugins/TwitterPlugin/index.d.ts +0 -4
- package/lib/plugins/TwitterPlugin/index.js +0 -24
- package/lib/plugins/TypingPerfPlugin/index.d.ts +0 -2
- package/lib/plugins/TypingPerfPlugin/index.js +0 -97
- package/lib/plugins/YouTubePlugin/index.d.ts +0 -4
- package/lib/plugins/YouTubePlugin/index.js +0 -24
- package/lib/server/validation.d.ts +0 -1
- package/lib/server/validation.js +0 -115
- package/lib/setupEnv.d.ts +0 -2
- package/lib/setupEnv.js +0 -29
- package/lib/themes/CommentEditorTheme.d.ts +0 -4
- package/lib/themes/CommentEditorTheme.js +0 -11
- package/lib/themes/PlaygroundEditorTheme.d.ts +0 -4
- package/lib/themes/PlaygroundEditorTheme.js +0 -124
- package/lib/themes/StickyEditorTheme.d.ts +0 -4
- package/lib/themes/StickyEditorTheme.js +0 -11
- package/lib/tyes.dt.d.ts +0 -12
- package/lib/tyes.dt.js +0 -4
- package/lib/ui/Button.d.ts +0 -12
- package/lib/ui/Button.js +0 -6
- package/lib/ui/ColorPicker.d.ts +0 -14
- package/lib/ui/ColorPicker.js +0 -219
- package/lib/ui/ContentEditable.d.ts +0 -9
- package/lib/ui/ContentEditable.js +0 -6
- package/lib/ui/Dialog.d.ts +0 -10
- package/lib/ui/Dialog.js +0 -8
- package/lib/ui/DropDown.d.ts +0 -18
- package/lib/ui/DropDown.js +0 -133
- package/lib/ui/DropdownColorPicker.d.ts +0 -13
- package/lib/ui/DropdownColorPicker.js +0 -6
- package/lib/ui/EquationEditor.d.ts +0 -8
- package/lib/ui/EquationEditor.js +0 -11
- package/lib/ui/ExcalidrawModal.d.ts +0 -42
- package/lib/ui/ExcalidrawModal.js +0 -103
- package/lib/ui/FileInput.d.ts +0 -10
- package/lib/ui/FileInput.js +0 -5
- package/lib/ui/FlashMessage.d.ts +0 -7
- package/lib/ui/FlashMessage.js +0 -6
- package/lib/ui/ImageResizer.d.ts +0 -17
- package/lib/ui/ImageResizer.js +0 -171
- package/lib/ui/KatexEquationAlterer.d.ts +0 -8
- package/lib/ui/KatexEquationAlterer.js +0 -23
- package/lib/ui/KatexRenderer.d.ts +0 -6
- package/lib/ui/KatexRenderer.js +0 -24
- package/lib/ui/Modal.d.ts +0 -9
- package/lib/ui/Modal.js +0 -48
- package/lib/ui/Select.d.ts +0 -8
- package/lib/ui/Select.js +0 -5
- package/lib/ui/Switch.d.ts +0 -8
- package/lib/ui/Switch.js +0 -6
- package/lib/ui/TextInput.d.ts +0 -13
- package/lib/ui/TextInput.js +0 -7
- package/lib/utils/docSerialization.d.ts +0 -3
- package/lib/utils/docSerialization.js +0 -60
- package/lib/utils/emoji-list.d.ts +0 -20
- package/lib/utils/emoji-list.js +0 -16609
- package/lib/utils/getDOMRangeRect.d.ts +0 -8
- package/lib/utils/getDOMRangeRect.js +0 -26
- package/lib/utils/getSelectedNode.d.ts +0 -2
- package/lib/utils/getSelectedNode.js +0 -28
- package/lib/utils/getThemeSelector.d.ts +0 -2
- package/lib/utils/getThemeSelector.js +0 -14
- package/lib/utils/isMobileWidth.d.ts +0 -7
- package/lib/utils/isMobileWidth.js +0 -11
- package/lib/utils/joinClasses.d.ts +0 -1
- package/lib/utils/joinClasses.js +0 -7
- package/lib/utils/setFloatingElemPosition.d.ts +0 -1
- package/lib/utils/setFloatingElemPosition.js +0 -59
- package/lib/utils/setFloatingElemPositionForLinkEditor.d.ts +0 -1
- package/lib/utils/setFloatingElemPositionForLinkEditor.js +0 -36
- package/lib/utils/swipe.d.ts +0 -4
- package/lib/utils/swipe.js +0 -94
- package/lib/utils/url.d.ts +0 -2
- package/lib/utils/url.js +0 -31
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { ObservableV2 } from 'lib0/observable';
|
|
2
|
-
import * as awarenessProtocol from 'y-protocols/awareness';
|
|
3
|
-
export declare const messageSync = 0;
|
|
4
|
-
export declare const messageQueryAwareness = 3;
|
|
5
|
-
export declare const messageAwareness = 1;
|
|
6
|
-
export declare const messageAuth = 2;
|
|
7
|
-
/**
|
|
8
|
-
* Websocket Provider for Yjs. Creates a websocket connection to sync the shared document.
|
|
9
|
-
* The document name is attached to the provided url. I.e. the following example
|
|
10
|
-
* creates a websocket connection to http://localhost:1234/my-document-name
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* import * as Y from 'yjs'
|
|
14
|
-
* import { WebsocketProvider } from 'y-websocket'
|
|
15
|
-
* const doc = new Y.Doc()
|
|
16
|
-
* const provider = new WebsocketProvider('http://localhost:1234', 'my-document-name', doc)
|
|
17
|
-
*
|
|
18
|
-
* @extends {ObservableV2<{ 'connection-close': (event: CloseEvent | null, provider: WebsocketProvider) => any, 'status': (event: { status: 'connected' | 'disconnected' | 'connecting' }) => any, 'connection-error': (event: Event, provider: WebsocketProvider) => any, 'sync': (state: boolean) => any }>}
|
|
19
|
-
*/
|
|
20
|
-
export declare class WebsocketProvider extends ObservableV2<any> {
|
|
21
|
-
serverUrl: string;
|
|
22
|
-
roomname: string;
|
|
23
|
-
doc: any;
|
|
24
|
-
_WS: any;
|
|
25
|
-
protocols: any[];
|
|
26
|
-
params: {};
|
|
27
|
-
awareness: any;
|
|
28
|
-
ws: any;
|
|
29
|
-
wsconnected: boolean;
|
|
30
|
-
wsconnecting: boolean;
|
|
31
|
-
bcconnected: boolean;
|
|
32
|
-
disableBc: boolean;
|
|
33
|
-
bcChannel: string;
|
|
34
|
-
maxBackoffTime: number;
|
|
35
|
-
wsUnsuccessfulReconnects: number;
|
|
36
|
-
messageIntegrators: any[];
|
|
37
|
-
_synced: boolean;
|
|
38
|
-
wsLastMessageReceived: number;
|
|
39
|
-
shouldConnect: boolean;
|
|
40
|
-
_checkInterval: any;
|
|
41
|
-
_resyncInterval: any;
|
|
42
|
-
_updateIntegrator: any;
|
|
43
|
-
_awarenessUpdateIntegrator: any;
|
|
44
|
-
_exitIntegrator: any;
|
|
45
|
-
_bcSubscriber: any;
|
|
46
|
-
/**
|
|
47
|
-
* @param {string} serverUrl
|
|
48
|
-
* @param {string} roomname
|
|
49
|
-
* @param {Y.Doc} doc
|
|
50
|
-
* @param {object} opts
|
|
51
|
-
* @param {boolean} [opts.connect]
|
|
52
|
-
* @param {awarenessProtocol.Awareness} [opts.awareness]
|
|
53
|
-
* @param {Object<string,string>} [opts.params] specify url parameters
|
|
54
|
-
* @param {Array<string>} [opts.protocols] specify websocket protocols
|
|
55
|
-
* @param {typeof WebSocket} [opts.WebSocketPolyfill] Optionall provide a WebSocket polyfill
|
|
56
|
-
* @param {number} [opts.resyncInterval] Request server state every `resyncInterval` milliseconds
|
|
57
|
-
* @param {number} [opts.maxBackoffTime] Maximum amount of time to wait before trying to reconnect (we try to reconnect using exponential backoff)
|
|
58
|
-
* @param {boolean} [opts.disableBc] Disable cross-tab BroadcastChannel communication
|
|
59
|
-
*/
|
|
60
|
-
constructor(serverUrl: any, roomname: any, doc: any, { connect, awareness, params, protocols, WebSocketPolyfill, resyncInterval, maxBackoffTime, disableBc }?: {
|
|
61
|
-
connect?: boolean;
|
|
62
|
-
awareness?: awarenessProtocol.Awareness;
|
|
63
|
-
params?: {};
|
|
64
|
-
protocols?: any[];
|
|
65
|
-
WebSocketPolyfill?: {
|
|
66
|
-
new (url: string | URL, protocols?: string | string[]): WebSocket;
|
|
67
|
-
prototype: WebSocket;
|
|
68
|
-
readonly CONNECTING: 0;
|
|
69
|
-
readonly OPEN: 1;
|
|
70
|
-
readonly CLOSING: 2;
|
|
71
|
-
readonly CLOSED: 3;
|
|
72
|
-
};
|
|
73
|
-
resyncInterval?: number;
|
|
74
|
-
maxBackoffTime?: number;
|
|
75
|
-
disableBc?: boolean;
|
|
76
|
-
});
|
|
77
|
-
get url(): string;
|
|
78
|
-
/**
|
|
79
|
-
* @type {boolean}
|
|
80
|
-
*/
|
|
81
|
-
get synced(): boolean;
|
|
82
|
-
set synced(state: boolean);
|
|
83
|
-
destroy(): void;
|
|
84
|
-
connectBc(): void;
|
|
85
|
-
disconnectBc(): void;
|
|
86
|
-
disconnect(): void;
|
|
87
|
-
connect(): void;
|
|
88
|
-
}
|
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
import { ObservableV2 } from 'lib0/observable';
|
|
2
|
-
import * as syncProtocol from 'y-protocols/sync';
|
|
3
|
-
import * as authProtocol from 'y-protocols/auth';
|
|
4
|
-
import * as bc from 'lib0/broadcastchannel';
|
|
5
|
-
import * as time from 'lib0/time';
|
|
6
|
-
import * as encoding from 'lib0/encoding';
|
|
7
|
-
import * as decoding from 'lib0/decoding';
|
|
8
|
-
import * as awarenessProtocol from 'y-protocols/awareness';
|
|
9
|
-
import * as math from 'lib0/math';
|
|
10
|
-
import * as url from 'lib0/url';
|
|
11
|
-
import * as env from 'lib0/environment';
|
|
12
|
-
export const messageSync = 0;
|
|
13
|
-
export const messageQueryAwareness = 3;
|
|
14
|
-
export const messageAwareness = 1;
|
|
15
|
-
export const messageAuth = 2;
|
|
16
|
-
/**
|
|
17
|
-
* encoder, decoder, provider, emitSynced, messageType
|
|
18
|
-
* @type {Array<function(encoding.Encoder, decoding.Decoder, WebsocketProvider, boolean, number):void>}
|
|
19
|
-
*/
|
|
20
|
-
const messageIntegrators = [];
|
|
21
|
-
messageIntegrators[messageSync] = (encoder, decoder, provider, emitSynced, _messageType) => {
|
|
22
|
-
encoding.writeVarUint(encoder, messageSync);
|
|
23
|
-
const syncMessageType = syncProtocol.readSyncMessage(decoder, encoder, provider.doc, provider);
|
|
24
|
-
if (emitSynced && syncMessageType === syncProtocol.messageYjsSyncStep2 &&
|
|
25
|
-
!provider.synced) {
|
|
26
|
-
provider.synced = true;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
messageIntegrators[messageQueryAwareness] = (encoder, _decoder, provider, _emitSynced, _messageType) => {
|
|
30
|
-
encoding.writeVarUint(encoder, messageAwareness);
|
|
31
|
-
encoding.writeVarUint8Array(encoder, awarenessProtocol.encodeAwarenessUpdate(provider.awareness, Array.from(provider.awareness.getStates().keys())));
|
|
32
|
-
};
|
|
33
|
-
messageIntegrators[messageAwareness] = (_encoder, decoder, provider, _emitSynced, _messageType) => {
|
|
34
|
-
awarenessProtocol.applyAwarenessUpdate(provider.awareness, decoding.readVarUint8Array(decoder), provider);
|
|
35
|
-
};
|
|
36
|
-
messageIntegrators[messageAuth] = (_encoder, decoder, provider, _emitSynced, _messageType) => {
|
|
37
|
-
authProtocol.readAuthMessage(decoder, provider.doc, (_ydoc, reason) => permissionDeniedIntegrator(provider, reason));
|
|
38
|
-
};
|
|
39
|
-
// @todo - this should depend on awareness.outdatedTime
|
|
40
|
-
const messageReconnectTimeout = 30000;
|
|
41
|
-
/**
|
|
42
|
-
* @param {WebsocketProvider} provider
|
|
43
|
-
* @param {string} reason
|
|
44
|
-
*/
|
|
45
|
-
const permissionDeniedIntegrator = (provider, reason) => console.warn(`Permission denied to access ${provider.url}.\n${reason}`);
|
|
46
|
-
/**
|
|
47
|
-
* @param {WebsocketProvider} provider
|
|
48
|
-
* @param {Uint8Array} buf
|
|
49
|
-
* @param {boolean} emitSynced
|
|
50
|
-
* @return {encoding.Encoder}
|
|
51
|
-
*/
|
|
52
|
-
const readMessage = (provider, buf, emitSynced) => {
|
|
53
|
-
const decoder = decoding.createDecoder(buf);
|
|
54
|
-
const encoder = encoding.createEncoder();
|
|
55
|
-
const messageType = decoding.readVarUint(decoder);
|
|
56
|
-
const messageIntegrator = provider.messageIntegrators[messageType];
|
|
57
|
-
if ( /** @type {any} */(messageIntegrator)) {
|
|
58
|
-
messageIntegrator(encoder, decoder, provider, emitSynced, messageType);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
console.error('Unable to compute message');
|
|
62
|
-
}
|
|
63
|
-
return encoder;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Outsource this function so that a new websocket connection is created immediately.
|
|
67
|
-
* I suspect that the `ws.onclose` event is not always fired if there are network issues.
|
|
68
|
-
*
|
|
69
|
-
* @param {WebsocketProvider} provider
|
|
70
|
-
* @param {WebSocket} ws
|
|
71
|
-
* @param {CloseEvent | null} event
|
|
72
|
-
*/
|
|
73
|
-
const closeWebsocketConnection = (provider, ws, event) => {
|
|
74
|
-
if (ws === provider.ws) {
|
|
75
|
-
provider.emit('connection-close', [event, provider]);
|
|
76
|
-
provider.ws = null;
|
|
77
|
-
ws.close();
|
|
78
|
-
provider.wsconnecting = false;
|
|
79
|
-
if (provider.wsconnected) {
|
|
80
|
-
provider.wsconnected = false;
|
|
81
|
-
provider.synced = false;
|
|
82
|
-
// update awareness (all users except local left)
|
|
83
|
-
awarenessProtocol.removeAwarenessStates(provider.awareness, Array.from(provider.awareness.getStates().keys()).filter((client) => client !== provider.doc.clientID), provider);
|
|
84
|
-
provider.emit('status', [{
|
|
85
|
-
status: 'disconnected'
|
|
86
|
-
}]);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
provider.wsUnsuccessfulReconnects++;
|
|
90
|
-
}
|
|
91
|
-
// Start with no reconnect timeout and increase timeout by
|
|
92
|
-
// using exponential backoff starting with 100ms
|
|
93
|
-
setTimeout(setupWS, math.min(math.pow(2, provider.wsUnsuccessfulReconnects) * 100, provider.maxBackoffTime), provider);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* @param {WebsocketProvider} provider
|
|
98
|
-
*/
|
|
99
|
-
const setupWS = (provider) => {
|
|
100
|
-
if (provider.shouldConnect && provider.ws === null) {
|
|
101
|
-
const websocket = new provider._WS(provider.url, provider.protocols);
|
|
102
|
-
websocket.binaryType = 'arraybuffer';
|
|
103
|
-
provider.ws = websocket;
|
|
104
|
-
provider.wsconnecting = true;
|
|
105
|
-
provider.wsconnected = false;
|
|
106
|
-
provider.synced = false;
|
|
107
|
-
websocket.onmessage = (event) => {
|
|
108
|
-
provider.wsLastMessageReceived = time.getUnixTime();
|
|
109
|
-
const encoder = readMessage(provider, new Uint8Array(event.data), true);
|
|
110
|
-
if (encoding.length(encoder) > 1) {
|
|
111
|
-
websocket.send(encoding.toUint8Array(encoder));
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
websocket.onerror = (event) => {
|
|
115
|
-
provider.emit('connection-error', [event, provider]);
|
|
116
|
-
};
|
|
117
|
-
websocket.onclose = (event) => {
|
|
118
|
-
closeWebsocketConnection(provider, websocket, event);
|
|
119
|
-
};
|
|
120
|
-
websocket.onopen = () => {
|
|
121
|
-
provider.wsLastMessageReceived = time.getUnixTime();
|
|
122
|
-
provider.wsconnecting = false;
|
|
123
|
-
provider.wsconnected = true;
|
|
124
|
-
provider.wsUnsuccessfulReconnects = 0;
|
|
125
|
-
provider.emit('status', [{
|
|
126
|
-
status: 'connected'
|
|
127
|
-
}]);
|
|
128
|
-
// always send sync step 1 when connected
|
|
129
|
-
const encoder = encoding.createEncoder();
|
|
130
|
-
encoding.writeVarUint(encoder, messageSync);
|
|
131
|
-
syncProtocol.writeSyncStep1(encoder, provider.doc);
|
|
132
|
-
websocket.send(encoding.toUint8Array(encoder));
|
|
133
|
-
// broadcast local awareness state
|
|
134
|
-
if (provider.awareness.getLocalState() !== null) {
|
|
135
|
-
const encoderAwarenessState = encoding.createEncoder();
|
|
136
|
-
encoding.writeVarUint(encoderAwarenessState, messageAwareness);
|
|
137
|
-
encoding.writeVarUint8Array(encoderAwarenessState, awarenessProtocol.encodeAwarenessUpdate(provider.awareness, [
|
|
138
|
-
provider.doc.clientID
|
|
139
|
-
]));
|
|
140
|
-
websocket.send(encoding.toUint8Array(encoderAwarenessState));
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
provider.emit('status', [{
|
|
144
|
-
status: 'connecting'
|
|
145
|
-
}]);
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
/**
|
|
149
|
-
* @param {WebsocketProvider} provider
|
|
150
|
-
* @param {ArrayBuffer} buf
|
|
151
|
-
*/
|
|
152
|
-
const broadcastMessage = (provider, buf) => {
|
|
153
|
-
const ws = provider.ws;
|
|
154
|
-
if (provider.wsconnected && ws && ws.readyState === ws.OPEN) {
|
|
155
|
-
ws.send(buf);
|
|
156
|
-
}
|
|
157
|
-
if (provider.bcconnected) {
|
|
158
|
-
bc.publish(provider.bcChannel, buf, provider);
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
/**
|
|
162
|
-
* Websocket Provider for Yjs. Creates a websocket connection to sync the shared document.
|
|
163
|
-
* The document name is attached to the provided url. I.e. the following example
|
|
164
|
-
* creates a websocket connection to http://localhost:1234/my-document-name
|
|
165
|
-
*
|
|
166
|
-
* @example
|
|
167
|
-
* import * as Y from 'yjs'
|
|
168
|
-
* import { WebsocketProvider } from 'y-websocket'
|
|
169
|
-
* const doc = new Y.Doc()
|
|
170
|
-
* const provider = new WebsocketProvider('http://localhost:1234', 'my-document-name', doc)
|
|
171
|
-
*
|
|
172
|
-
* @extends {ObservableV2<{ 'connection-close': (event: CloseEvent | null, provider: WebsocketProvider) => any, 'status': (event: { status: 'connected' | 'disconnected' | 'connecting' }) => any, 'connection-error': (event: Event, provider: WebsocketProvider) => any, 'sync': (state: boolean) => any }>}
|
|
173
|
-
*/
|
|
174
|
-
export class WebsocketProvider extends ObservableV2 {
|
|
175
|
-
serverUrl = '';
|
|
176
|
-
roomname = '';
|
|
177
|
-
doc = null;
|
|
178
|
-
_WS = null;
|
|
179
|
-
protocols = [];
|
|
180
|
-
params = {};
|
|
181
|
-
awareness = null;
|
|
182
|
-
ws = null;
|
|
183
|
-
wsconnected = false;
|
|
184
|
-
wsconnecting = false;
|
|
185
|
-
bcconnected = false;
|
|
186
|
-
disableBc = false;
|
|
187
|
-
bcChannel = '';
|
|
188
|
-
maxBackoffTime = 2500;
|
|
189
|
-
wsUnsuccessfulReconnects = 0;
|
|
190
|
-
messageIntegrators = [];
|
|
191
|
-
_synced = false;
|
|
192
|
-
wsLastMessageReceived = 0;
|
|
193
|
-
shouldConnect = false;
|
|
194
|
-
_checkInterval = null;
|
|
195
|
-
_resyncInterval = null;
|
|
196
|
-
_updateIntegrator = null;
|
|
197
|
-
_awarenessUpdateIntegrator = null;
|
|
198
|
-
_exitIntegrator = null;
|
|
199
|
-
_bcSubscriber = null;
|
|
200
|
-
/**
|
|
201
|
-
* @param {string} serverUrl
|
|
202
|
-
* @param {string} roomname
|
|
203
|
-
* @param {Y.Doc} doc
|
|
204
|
-
* @param {object} opts
|
|
205
|
-
* @param {boolean} [opts.connect]
|
|
206
|
-
* @param {awarenessProtocol.Awareness} [opts.awareness]
|
|
207
|
-
* @param {Object<string,string>} [opts.params] specify url parameters
|
|
208
|
-
* @param {Array<string>} [opts.protocols] specify websocket protocols
|
|
209
|
-
* @param {typeof WebSocket} [opts.WebSocketPolyfill] Optionall provide a WebSocket polyfill
|
|
210
|
-
* @param {number} [opts.resyncInterval] Request server state every `resyncInterval` milliseconds
|
|
211
|
-
* @param {number} [opts.maxBackoffTime] Maximum amount of time to wait before trying to reconnect (we try to reconnect using exponential backoff)
|
|
212
|
-
* @param {boolean} [opts.disableBc] Disable cross-tab BroadcastChannel communication
|
|
213
|
-
*/
|
|
214
|
-
constructor(serverUrl, roomname, doc, { connect = true, awareness = new awarenessProtocol.Awareness(doc), params = {}, protocols = [], WebSocketPolyfill = WebSocket, resyncInterval = -1, maxBackoffTime = 2500, disableBc = false } = {}) {
|
|
215
|
-
super();
|
|
216
|
-
// ensure that serverUrl does not end with /
|
|
217
|
-
while (serverUrl[serverUrl.length - 1] === '/') {
|
|
218
|
-
serverUrl = serverUrl.slice(0, serverUrl.length - 1);
|
|
219
|
-
}
|
|
220
|
-
this.serverUrl = serverUrl;
|
|
221
|
-
this.bcChannel = serverUrl + '/' + roomname;
|
|
222
|
-
this.maxBackoffTime = maxBackoffTime;
|
|
223
|
-
/**
|
|
224
|
-
* The specified url parameters. This can be safely updated. The changed parameters will be used
|
|
225
|
-
* when a new connection is established.
|
|
226
|
-
* @type {Object<string,string>}
|
|
227
|
-
*/
|
|
228
|
-
this.params = params;
|
|
229
|
-
this.protocols = protocols;
|
|
230
|
-
this.roomname = roomname;
|
|
231
|
-
this.doc = doc;
|
|
232
|
-
this._WS = WebSocketPolyfill;
|
|
233
|
-
this.awareness = awareness;
|
|
234
|
-
this.wsconnected = false;
|
|
235
|
-
this.wsconnecting = false;
|
|
236
|
-
this.bcconnected = false;
|
|
237
|
-
this.disableBc = disableBc;
|
|
238
|
-
this.wsUnsuccessfulReconnects = 0;
|
|
239
|
-
this.messageIntegrators = messageIntegrators.slice();
|
|
240
|
-
/**
|
|
241
|
-
* @type {boolean}
|
|
242
|
-
*/
|
|
243
|
-
this._synced = false;
|
|
244
|
-
/**
|
|
245
|
-
* @type {WebSocket?}
|
|
246
|
-
*/
|
|
247
|
-
this.ws = null;
|
|
248
|
-
this.wsLastMessageReceived = 0;
|
|
249
|
-
/**
|
|
250
|
-
* Whether to connect to other peers or not
|
|
251
|
-
* @type {boolean}
|
|
252
|
-
*/
|
|
253
|
-
this.shouldConnect = connect;
|
|
254
|
-
/**
|
|
255
|
-
* @type {number}
|
|
256
|
-
*/
|
|
257
|
-
this._resyncInterval = 0;
|
|
258
|
-
if (resyncInterval > 0) {
|
|
259
|
-
this._resyncInterval = /** @type {any} */ (setInterval(() => {
|
|
260
|
-
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
261
|
-
// resend sync step 1
|
|
262
|
-
const encoder = encoding.createEncoder();
|
|
263
|
-
encoding.writeVarUint(encoder, messageSync);
|
|
264
|
-
syncProtocol.writeSyncStep1(encoder, doc);
|
|
265
|
-
this.ws.send(encoding.toUint8Array(encoder));
|
|
266
|
-
}
|
|
267
|
-
}, resyncInterval));
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* @param {ArrayBuffer} data
|
|
271
|
-
* @param {any} origin
|
|
272
|
-
*/
|
|
273
|
-
this._bcSubscriber = (data, origin) => {
|
|
274
|
-
if (origin !== this) {
|
|
275
|
-
const encoder = readMessage(this, new Uint8Array(data), false);
|
|
276
|
-
if (encoding.length(encoder) > 1) {
|
|
277
|
-
bc.publish(this.bcChannel, encoding.toUint8Array(encoder), this);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
/**
|
|
282
|
-
* Listens to Yjs updates and sends them to remote peers (ws and broadcastchannel)
|
|
283
|
-
* @param {Uint8Array} update
|
|
284
|
-
* @param {any} origin
|
|
285
|
-
*/
|
|
286
|
-
this._updateIntegrator = (update, origin) => {
|
|
287
|
-
if (origin !== this) {
|
|
288
|
-
const encoder = encoding.createEncoder();
|
|
289
|
-
encoding.writeVarUint(encoder, messageSync);
|
|
290
|
-
syncProtocol.writeUpdate(encoder, update);
|
|
291
|
-
broadcastMessage(this, encoding.toUint8Array(encoder));
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
this.doc.on('update', this._updateIntegrator);
|
|
295
|
-
/**
|
|
296
|
-
* @param {any} changed
|
|
297
|
-
* @param {any} _origin
|
|
298
|
-
*/
|
|
299
|
-
this._awarenessUpdateIntegrator = ({ added, updated, removed }, _origin) => {
|
|
300
|
-
const changedClients = added.concat(updated).concat(removed);
|
|
301
|
-
const encoder = encoding.createEncoder();
|
|
302
|
-
encoding.writeVarUint(encoder, messageAwareness);
|
|
303
|
-
encoding.writeVarUint8Array(encoder, awarenessProtocol.encodeAwarenessUpdate(awareness, changedClients));
|
|
304
|
-
broadcastMessage(this, encoding.toUint8Array(encoder));
|
|
305
|
-
};
|
|
306
|
-
this._exitIntegrator = () => {
|
|
307
|
-
awarenessProtocol.removeAwarenessStates(this.awareness, [doc.clientID], 'app closed');
|
|
308
|
-
};
|
|
309
|
-
if (env.isNode && typeof process !== 'undefined') {
|
|
310
|
-
process.on('exit', this._exitIntegrator);
|
|
311
|
-
}
|
|
312
|
-
awareness.on('update', this._awarenessUpdateIntegrator);
|
|
313
|
-
this._checkInterval = /** @type {any} */ (setInterval(() => {
|
|
314
|
-
if (this.wsconnected &&
|
|
315
|
-
messageReconnectTimeout <
|
|
316
|
-
time.getUnixTime() - this.wsLastMessageReceived) {
|
|
317
|
-
// no message received in a long time - not even your own awareness
|
|
318
|
-
// updates (which are updated every 15 seconds)
|
|
319
|
-
closeWebsocketConnection(this, /** @type {WebSocket} */ (this.ws), null);
|
|
320
|
-
}
|
|
321
|
-
}, messageReconnectTimeout / 10));
|
|
322
|
-
if (connect) {
|
|
323
|
-
this.connect();
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
get url() {
|
|
327
|
-
const encodedParams = url.encodeQueryParams(this.params);
|
|
328
|
-
return this.serverUrl + '/' + this.roomname +
|
|
329
|
-
(encodedParams.length === 0 ? '' : '?' + encodedParams);
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* @type {boolean}
|
|
333
|
-
*/
|
|
334
|
-
get synced() {
|
|
335
|
-
return this._synced;
|
|
336
|
-
}
|
|
337
|
-
set synced(state) {
|
|
338
|
-
if (this._synced !== state) {
|
|
339
|
-
this._synced = state;
|
|
340
|
-
super.emit('synced', [state]);
|
|
341
|
-
super.emit('sync', [state]);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
destroy() {
|
|
345
|
-
if (this._resyncInterval !== 0) {
|
|
346
|
-
clearInterval(this._resyncInterval);
|
|
347
|
-
}
|
|
348
|
-
clearInterval(this._checkInterval);
|
|
349
|
-
this.disconnect();
|
|
350
|
-
if (env.isNode && typeof process !== 'undefined') {
|
|
351
|
-
process.off('exit', this._exitIntegrator);
|
|
352
|
-
}
|
|
353
|
-
this.awareness.off('update', this._awarenessUpdateIntegrator);
|
|
354
|
-
this.doc.off('update', this._updateIntegrator);
|
|
355
|
-
super.destroy();
|
|
356
|
-
}
|
|
357
|
-
connectBc() {
|
|
358
|
-
if (this.disableBc) {
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
361
|
-
if (!this.bcconnected) {
|
|
362
|
-
bc.subscribe(this.bcChannel, this._bcSubscriber);
|
|
363
|
-
this.bcconnected = true;
|
|
364
|
-
}
|
|
365
|
-
// send sync step1 to bc
|
|
366
|
-
// write sync step 1
|
|
367
|
-
const encoderSync = encoding.createEncoder();
|
|
368
|
-
encoding.writeVarUint(encoderSync, messageSync);
|
|
369
|
-
syncProtocol.writeSyncStep1(encoderSync, this.doc);
|
|
370
|
-
bc.publish(this.bcChannel, encoding.toUint8Array(encoderSync), this);
|
|
371
|
-
// broadcast local state
|
|
372
|
-
const encoderState = encoding.createEncoder();
|
|
373
|
-
encoding.writeVarUint(encoderState, messageSync);
|
|
374
|
-
syncProtocol.writeSyncStep2(encoderState, this.doc);
|
|
375
|
-
bc.publish(this.bcChannel, encoding.toUint8Array(encoderState), this);
|
|
376
|
-
// write queryAwareness
|
|
377
|
-
const encoderAwarenessQuery = encoding.createEncoder();
|
|
378
|
-
encoding.writeVarUint(encoderAwarenessQuery, messageQueryAwareness);
|
|
379
|
-
bc.publish(this.bcChannel, encoding.toUint8Array(encoderAwarenessQuery), this);
|
|
380
|
-
// broadcast local awareness state
|
|
381
|
-
const encoderAwarenessState = encoding.createEncoder();
|
|
382
|
-
encoding.writeVarUint(encoderAwarenessState, messageAwareness);
|
|
383
|
-
encoding.writeVarUint8Array(encoderAwarenessState, awarenessProtocol.encodeAwarenessUpdate(this.awareness, [
|
|
384
|
-
this.doc.clientID
|
|
385
|
-
]));
|
|
386
|
-
bc.publish(this.bcChannel, encoding.toUint8Array(encoderAwarenessState), this);
|
|
387
|
-
}
|
|
388
|
-
disconnectBc() {
|
|
389
|
-
// broadcast message with local awareness state set to null (indicating disconnect)
|
|
390
|
-
const encoder = encoding.createEncoder();
|
|
391
|
-
encoding.writeVarUint(encoder, messageAwareness);
|
|
392
|
-
encoding.writeVarUint8Array(encoder, awarenessProtocol.encodeAwarenessUpdate(this.awareness, [
|
|
393
|
-
this.doc.clientID
|
|
394
|
-
], new Map()));
|
|
395
|
-
broadcastMessage(this, encoding.toUint8Array(encoder));
|
|
396
|
-
if (this.bcconnected) {
|
|
397
|
-
bc.unsubscribe(this.bcChannel, this._bcSubscriber);
|
|
398
|
-
this.bcconnected = false;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
disconnect() {
|
|
402
|
-
this.shouldConnect = false;
|
|
403
|
-
this.disconnectBc();
|
|
404
|
-
if (this.ws !== null) {
|
|
405
|
-
closeWebsocketConnection(this, this.ws, null);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
connect() {
|
|
409
|
-
this.shouldConnect = true;
|
|
410
|
-
if (!this.wsconnected && this.ws === null) {
|
|
411
|
-
setupWS(this);
|
|
412
|
-
this.connectBc();
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import http from 'http';
|
|
2
|
-
import * as number from 'lib0/number';
|
|
3
|
-
const CALLBACK_URL = process.env.CALLBACK_URL ? new URL(process.env.CALLBACK_URL) : null;
|
|
4
|
-
const CALLBACK_TIMEOUT = number.parseInt(process.env.CALLBACK_TIMEOUT || '5000');
|
|
5
|
-
const CALLBACK_OBJECTS = process.env.CALLBACK_OBJECTS ? JSON.parse(process.env.CALLBACK_OBJECTS) : {};
|
|
6
|
-
export const isCallbackSet = !!CALLBACK_URL;
|
|
7
|
-
/**
|
|
8
|
-
* @param {import('./utils.js').WSSharedDoc} doc
|
|
9
|
-
*/
|
|
10
|
-
export const callbackIntegrator = (doc) => {
|
|
11
|
-
const room = doc.name;
|
|
12
|
-
const dataToSend = {
|
|
13
|
-
room,
|
|
14
|
-
data: {}
|
|
15
|
-
};
|
|
16
|
-
const sharedObjectList = Object.keys(CALLBACK_OBJECTS);
|
|
17
|
-
sharedObjectList.forEach(sharedObjectName => {
|
|
18
|
-
const sharedObjectType = CALLBACK_OBJECTS[sharedObjectName];
|
|
19
|
-
dataToSend.data[sharedObjectName] = {
|
|
20
|
-
type: sharedObjectType,
|
|
21
|
-
content: getContent(sharedObjectName, sharedObjectType, doc).toJSON()
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
if (CALLBACK_URL) {
|
|
25
|
-
callbackRequest(CALLBACK_URL, CALLBACK_TIMEOUT, dataToSend);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* @param {URL} url
|
|
30
|
-
* @param {number} timeout
|
|
31
|
-
* @param {Object} data
|
|
32
|
-
*/
|
|
33
|
-
const callbackRequest = (url, timeout, data) => {
|
|
34
|
-
data = JSON.stringify(data);
|
|
35
|
-
const options = {
|
|
36
|
-
hostname: url.hostname,
|
|
37
|
-
port: url.port,
|
|
38
|
-
path: url.pathname,
|
|
39
|
-
timeout,
|
|
40
|
-
method: 'POST',
|
|
41
|
-
headers: {
|
|
42
|
-
'Content-Type': 'application/json',
|
|
43
|
-
'Content-Length': Buffer.byteLength(data)
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
const req = http.request(options);
|
|
47
|
-
req.on('timeout', () => {
|
|
48
|
-
console.warn('Callback request timed out.');
|
|
49
|
-
req.abort();
|
|
50
|
-
});
|
|
51
|
-
req.on('error', (e) => {
|
|
52
|
-
console.error('Callback request error.', e);
|
|
53
|
-
req.abort();
|
|
54
|
-
});
|
|
55
|
-
req.write(data);
|
|
56
|
-
req.end();
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* @param {string} objName
|
|
60
|
-
* @param {string} objType
|
|
61
|
-
* @param {import('./utils.js').WSSharedDoc} doc
|
|
62
|
-
*/
|
|
63
|
-
const getContent = (objName, objType, doc) => {
|
|
64
|
-
switch (objType) {
|
|
65
|
-
case 'Array': return doc.getArray(objName);
|
|
66
|
-
case 'Map': return doc.getMap(objName);
|
|
67
|
-
case 'Text': return doc.getText(objName);
|
|
68
|
-
case 'XmlFragment': return doc.getXmlFragment(objName);
|
|
69
|
-
case 'XmlElement': return doc.getXmlElement(objName);
|
|
70
|
-
default: return {};
|
|
71
|
-
}
|
|
72
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { WebSocketServer } from 'ws';
|
|
3
|
-
import http from 'http';
|
|
4
|
-
import * as number from 'lib0/number';
|
|
5
|
-
import { setupWSConnection } from './utils';
|
|
6
|
-
const wss = new WebSocketServer({ noServer: true });
|
|
7
|
-
const host = process.env.HOST || 'localhost';
|
|
8
|
-
const port = number.parseInt(process.env.PORT || '1234');
|
|
9
|
-
const server = http.createServer((_request, response) => {
|
|
10
|
-
response.writeHead(200, { 'Content-Type': 'text/plain' });
|
|
11
|
-
response.end('okay');
|
|
12
|
-
});
|
|
13
|
-
wss.on('connection', setupWSConnection);
|
|
14
|
-
server.on('upgrade', (request, socket, head) => {
|
|
15
|
-
// You may check auth of request here..
|
|
16
|
-
// Call `wss.HandleUpgrade` *after* you checked whether the client has access
|
|
17
|
-
// (e.g. by checking cookies, or url parameters).
|
|
18
|
-
// See https://github.com/websockets/ws#client-authentication
|
|
19
|
-
wss.handleUpgrade(request, socket, head, /** @param {any} ws */ /** @param {any} ws */ ws => {
|
|
20
|
-
wss.emit('connection', ws, request);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
server.listen(port, host, () => {
|
|
24
|
-
console.log(`running at '${host}' on port ${port}`);
|
|
25
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import * as Y from 'yjs';
|
|
2
|
-
/**
|
|
3
|
-
* @param {{bindState: function(string,WSSharedDoc):void,
|
|
4
|
-
* writeState:function(string,WSSharedDoc):Promise<any>,provider:any}|null} persistence_
|
|
5
|
-
*/
|
|
6
|
-
export declare const setPersistence: (persistence_: any) => void;
|
|
7
|
-
/**
|
|
8
|
-
* @return {null|{bindState: function(string,WSSharedDoc):void,
|
|
9
|
-
* writeState:function(string,WSSharedDoc):Promise<any>}|null} used persistence layer
|
|
10
|
-
*/
|
|
11
|
-
export declare const getPersistence: () => any;
|
|
12
|
-
/**
|
|
13
|
-
* @type {Map<string,WSSharedDoc>}
|
|
14
|
-
*/
|
|
15
|
-
export declare const docs: Map<any, any>;
|
|
16
|
-
/**
|
|
17
|
-
* This function is called once every time a Yjs document is created. You can
|
|
18
|
-
* use it to pull data from an external source or initialize content.
|
|
19
|
-
*
|
|
20
|
-
* @param {(ydoc: Y.Doc) => Promise<void>} f
|
|
21
|
-
*/
|
|
22
|
-
export declare const setContentInitializor: (f: any) => void;
|
|
23
|
-
export declare class WSSharedDoc extends Y.Doc {
|
|
24
|
-
name: string;
|
|
25
|
-
conns: any;
|
|
26
|
-
awareness: any;
|
|
27
|
-
whenInitialized: any;
|
|
28
|
-
/**
|
|
29
|
-
* @param {string} name
|
|
30
|
-
*/
|
|
31
|
-
constructor(name: any);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Gets a Y.Doc by name, whether in memory or on disk
|
|
35
|
-
*
|
|
36
|
-
* @param {string} docname - the name of the Y.Doc to find or create
|
|
37
|
-
* @param {boolean} gc - whether to allow gc on the doc (applies only when created)
|
|
38
|
-
* @return {WSSharedDoc}
|
|
39
|
-
*/
|
|
40
|
-
export declare const getYDoc: (docname: any, gc?: boolean) => WSSharedDoc;
|
|
41
|
-
/**
|
|
42
|
-
* @param {import('ws').WebSocket} conn
|
|
43
|
-
* @param {import('http').IncomingMessage} req
|
|
44
|
-
* @param {any} opts
|
|
45
|
-
*/
|
|
46
|
-
export declare const setupWSConnection: (conn: any, req: any, { docName, gc }?: {
|
|
47
|
-
docName?: any;
|
|
48
|
-
gc?: boolean;
|
|
49
|
-
}) => void;
|