@@ -153,3 +170,36 @@ export function Header(props: {playgroundRef: PlaygroundActorRef}) {
)
}
+
+function LatencySlider(props: {playgroundRef: PlaygroundActorRef}) {
+ const latency = useSelector(
+ props.playgroundRef,
+ (s) => s.context.featureFlags.yjsLatency,
+ )
+
+ return (
+
+
+
+ {
+ props.playgroundRef.send({
+ type: 'set yjs latency',
+ latency: Number(event.target.value),
+ })
+ }}
+ className="w-16 h-1 accent-blue-500"
+ />
+
+ {latency}ms
+
+
+ Sync latency between editors
+
+ )
+}
diff --git a/apps/playground/src/inspector.tsx b/apps/playground/src/inspector.tsx
index dc3639e17..93aa5150f 100644
--- a/apps/playground/src/inspector.tsx
+++ b/apps/playground/src/inspector.tsx
@@ -1,7 +1,16 @@
import {useActorRef, useSelector} from '@xstate/react'
-import {CheckIcon, CopyIcon, HistoryIcon, TrashIcon} from 'lucide-react'
-import {useEffect, useState} from 'react'
+import {
+ ActivityIcon,
+ CheckIcon,
+ CopyIcon,
+ GitBranchIcon,
+ HistoryIcon,
+ NetworkIcon,
+ TrashIcon,
+} from 'lucide-react'
+import {useContext, useEffect, useState} from 'react'
import {TooltipTrigger, type Key} from 'react-aria-components'
+import {PlaygroundFeatureFlagsContext} from './feature-flags'
import {highlightMachine} from './highlight-json-machine'
import {MarkdownLogo, PortableTextLogo, ReactLogo} from './logos'
import {PatchesList} from './patches-list'
@@ -13,11 +22,22 @@ import {Container} from './primitives/container'
import {Spinner} from './primitives/spinner'
import {Tab, TabList, TabPanel, Tabs} from './primitives/tabs'
import {Tooltip} from './primitives/tooltip'
+import {YjsCrdtPanel} from './yjs-crdt-panel'
+import {YjsOperationLog} from './yjs-operation-log'
+import {YjsTreeViewer} from './yjs-tree-viewer'
-type TabId = 'output' | 'patches' | 'react-preview' | 'markdown-preview'
+type TabId =
+ | 'output'
+ | 'patches'
+ | 'react-preview'
+ | 'markdown-preview'
+ | 'yjs-tree'
+ | 'yjs-ops'
+ | 'yjs-crdt'
export function Inspector(props: {playgroundRef: PlaygroundActorRef}) {
const [activeTab, setActiveTab] = useState
('output')
+ const featureFlags = useContext(PlaygroundFeatureFlagsContext)
const handleTabChange = (key: Key) => {
setActiveTab(key as TabId)
@@ -55,6 +75,30 @@ export function Inspector(props: {playgroundRef: PlaygroundActorRef}) {
Markdown
+ {featureFlags.yjsMode ? (
+
+
+
+ Y.Doc
+
+
+ ) : null}
+ {featureFlags.yjsMode ? (
+
+
+
+ Ops
+
+
+ ) : null}
+ {featureFlags.yjsMode ? (
+
+
+
+ CRDT
+
+
+ ) : null}
@@ -82,6 +126,30 @@ export function Inspector(props: {playgroundRef: PlaygroundActorRef}) {