[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6EGP8VY4JM3FV65J30M85PH":3,"skill-same:01M6EGP8VY4JM3FV65J30M85PH":67},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":20,"frontMatter":21,"refName":22,"commitSha":23,"skillDirectory":24,"forksCount":25,"repositoryHtmlUrl":26,"repositoryHomepageUrl":27,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M6EGP8VY4JM3FV65J30M85PH","yjs",null,"ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FTerminalSkills\u002Fskills\u002Fyjs\u002FSKILL.md",[],[5],"2026-11-10 10:12:30",false,"# Yjs — CRDT Framework for Collaborative Editing\n\n\n## Overview\n\n\nYjs, the high-performance CRDT (Conflict-free Replicated Data Type) framework for building collaborative applications. Helps developers implement real-time document editing, offline-first sync, and peer-to-peer collaboration with automatic conflict resolution.\n\n\n## Instructions\n\n### Document and Shared Types\n\nCreate collaborative data structures that merge automatically:\n\n```typescript\n\u002F\u002F src\u002Fcollaboration\u002Fdocument.ts — Set up a collaborative document with shared types\nimport * as Y from \"yjs\";\n\n\u002F\u002F A Y.Doc is the top-level container for all shared data\n\u002F\u002F Every connected client gets a copy that stays in sync\nconst doc = new Y.Doc();\n\n\u002F\u002F Y.Text — collaborative rich text (used with editors like Tiptap, ProseMirror)\nconst yText = doc.getText(\"document-content\");\nyText.insert(0, \"Hello, \");\nyText.insert(7, \"world!\");\n\u002F\u002F Result: \"Hello, world!\" — inserts merge correctly even if concurrent\n\n\u002F\u002F Y.Map — collaborative key-value store (like a shared object)\nconst yMap = doc.getMap(\"settings\");\nyMap.set(\"theme\", \"dark\");\nyMap.set(\"fontSize\", 14);\n\u002F\u002F Two users setting different keys: both applied\n\u002F\u002F Two users setting the same key: last-write-wins (deterministic)\n\n\u002F\u002F Y.Array — collaborative ordered list\nconst yArray = doc.getArray(\"tasks\");\nyArray.push([{ id: \"1\", title: \"Design mockup\", done: false }]);\nyArray.push([{ id: \"2\", title: \"Implement API\", done: false }]);\n\u002F\u002F Concurrent inserts at different positions: both preserved in correct order\n\n\u002F\u002F Y.XmlFragment — collaborative XML tree (for rich text editors)\nconst yXml = doc.getXmlFragment(\"rich-content\");\n\u002F\u002F Used internally by editor bindings (Tiptap, ProseMirror, Slate)\n\n\u002F\u002F Nested structures — Y types can be nested arbitrarily\nconst yNestedMap = new Y.Map();\nyNestedMap.set(\"status\", \"active\");\nyMap.set(\"project\", yNestedMap);  \u002F\u002F Map inside a map\n```\n\n### WebSocket Provider\n\nConnect clients through a WebSocket server for real-time sync:\n\n```typescript\n\u002F\u002F src\u002Fcollaboration\u002Fprovider.ts — WebSocket-based real-time sync\nimport * as Y from \"yjs\";\nimport { WebsocketProvider } from \"y-websocket\";\n\nconst doc = new Y.Doc();\n\n\u002F\u002F Connect to a y-websocket server\n\u002F\u002F All clients in the same room sync automatically\nconst provider = new WebsocketProvider(\n  \"wss:\u002F\u002Fyour-yjs-server.example.com\",  \u002F\u002F WebSocket server URL\n  \"document-room-123\",                   \u002F\u002F Room name — clients in same room sync\n  doc,\n  {\n    connect: true,                        \u002F\u002F Auto-connect on creation\n    params: { token: \"auth-token-here\" }, \u002F\u002F Auth params sent on connect\n  }\n);\n\n\u002F\u002F Awareness — lightweight presence data (cursors, selections, user info)\n\u002F\u002F Unlike document state, awareness is ephemeral (not persisted)\nconst awareness = provider.awareness;\n\nawareness.setLocalStateField(\"user\", {\n  name: \"Alice\",\n  color: \"#ff5733\",\n  cursor: null,\n});\n\n\u002F\u002F Listen to other users' awareness changes\nawareness.on(\"change\", () => {\n  const states = awareness.getStates();  \u002F\u002F Map\u003CclientId, state>\n  states.forEach((state, clientId) => {\n    if (clientId !== doc.clientID) {\n      console.log(`User ${state.user?.name} is connected`);\n    }\n  });\n});\n\n\u002F\u002F Connection status\nprovider.on(\"status\", ({ status }: { status: string }) => {\n  console.log(`Connection: ${status}`);  \u002F\u002F \"connecting\" | \"connected\" | \"disconnected\"\n});\n\n\u002F\u002F Sync status — fires when initial sync with server is complete\nprovider.on(\"sync\", (isSynced: boolean) => {\n  if (isSynced) console.log(\"Document fully synced with server\");\n});\n```\n\n### Server-Side Setup\n\nRun a y-websocket server for document persistence:\n\n```typescript\n\u002F\u002F server\u002Fyjs-server.ts — WebSocket server with persistence\nimport { WebSocketServer } from \"ws\";\nimport { setupWSConnection, setPersistence } from \"y-websocket\u002Fbin\u002Futils\";\nimport * as Y from \"yjs\";\nimport { MongodbPersistence } from \"y-mongodb-provider\";\n\nconst wss = new WebSocketServer({ port: 1234 });\n\n\u002F\u002F Persist documents to MongoDB (survives server restarts)\nconst mdb = new MongodbPersistence(process.env.MONGODB_URL!, {\n  collectionName: \"yjs-documents\",\n  flushSize: 100,          \u002F\u002F Batch 100 updates before flushing to DB\n  multipleCollections: true, \u002F\u002F Separate collection per document for performance\n});\n\nsetPersistence({\n  bindState: async (docName: string, ydoc: Y.Doc) => {\n    \u002F\u002F Load existing document state from MongoDB\n    const persistedDoc = await mdb.getYDoc(docName);\n    const persistedState = Y.encodeStateAsUpdate(persistedDoc);\n    Y.applyUpdate(ydoc, persistedState);\n\n    \u002F\u002F Save updates as they happen\n    ydoc.on(\"update\", (update: Uint8Array) => {\n      mdb.storeUpdate(docName, update);\n    });\n  },\n  writeState: async (docName: string, ydoc: Y.Doc) => {\n    \u002F\u002F Called when all clients disconnect — final persistence\n    await mdb.flushDocument(docName);\n  },\n});\n\nwss.on(\"connection\", (ws, req) => {\n  \u002F\u002F Authenticate the connection\n  const token = new URL(req.url!, \"http:\u002F\u002Flocalhost\").searchParams.get(\"token\");\n  if (!verifyToken(token)) {\n    ws.close(4001, \"Unauthorized\");\n    return;\n  }\n\n  setupWSConnection(ws, req);\n});\n\nconsole.log(\"Yjs WebSocket server running on port 1234\");\n```\n\n### Editor Integration (Tiptap)\n\nAdd collaborative editing to a Tiptap rich text editor:\n\n```tsx\n\u002F\u002F src\u002Fcomponents\u002FCollaborativeEditor.tsx — Tiptap with Yjs collaboration\nimport { useEditor, EditorContent } from \"@tiptap\u002Freact\";\nimport StarterKit from \"@tiptap\u002Fstarter-kit\";\nimport Collaboration from \"@tiptap\u002Fextension-collaboration\";\nimport CollaborationCursor from \"@tiptap\u002Fextension-collaboration-cursor\";\nimport * as Y from \"yjs\";\nimport { WebsocketProvider } from \"y-websocket\";\n\ninterface Props {\n  documentId: string;\n  userName: string;\n  userColor: string;\n}\n\nexport function CollaborativeEditor({ documentId, userName, userColor }: Props) {\n  const doc = useMemo(() => new Y.Doc(), []);\n  const provider = useMemo(\n    () => new WebsocketProvider(\"wss:\u002F\u002Fyjs.example.com\", documentId, doc),\n    [doc, documentId]\n  );\n\n  const editor = useEditor({\n    extensions: [\n      StarterKit.configure({\n        history: false,    \u002F\u002F Disable default history — Yjs handles undo\u002Fredo\n      }),\n      Collaboration.configure({\n        document: doc,     \u002F\u002F Bind editor content to Yjs document\n      }),\n      CollaborationCursor.configure({\n        provider,          \u002F\u002F Share cursor positions via awareness\n        user: { name: userName, color: userColor },\n      }),\n    ],\n  });\n\n  \u002F\u002F Clean up on unmount\n  useEffect(() => {\n    return () => {\n      provider.destroy();\n      doc.destroy();\n    };\n  }, [doc, provider]);\n\n  return (\n    \u003Cdiv className=\"editor-container\">\n      \u003CEditorContent editor={editor} \u002F>\n      \u003CConnectionStatus provider={provider} \u002F>\n    \u003C\u002Fdiv>\n  );\n}\n\nfunction ConnectionStatus({ provider }: { provider: WebsocketProvider }) {\n  const [status, setStatus] = useState(\"connecting\");\n\n  useEffect(() => {\n    const handler = ({ status }: { status: string }) => setStatus(status);\n    provider.on(\"status\", handler);\n    return () => provider.off(\"status\", handler);\n  }, [provider]);\n\n  return (\n    \u003Cdiv className={`status-badge ${status}`}>\n      {status === \"connected\" ? \"? Connected\" : \"? Reconnecting...\"}\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n### Offline Support and Sync\n\nHandle offline editing with automatic merge on reconnect:\n\n```typescript\n\u002F\u002F src\u002Fcollaboration\u002Foffline.ts — IndexedDB persistence for offline support\nimport * as Y from \"yjs\";\nimport { IndexeddbPersistence } from \"y-indexeddb\";\nimport { WebsocketProvider } from \"y-websocket\";\n\nconst doc = new Y.Doc();\n\n\u002F\u002F IndexedDB provider — saves document locally in the browser\n\u002F\u002F Changes made offline are preserved and synced when reconnected\nconst indexedDb = new IndexeddbPersistence(\"my-app-docs\", doc);\n\nindexedDb.on(\"synced\", () => {\n  console.log(\"Local data loaded from IndexedDB\");\n});\n\n\u002F\u002F WebSocket provider — syncs with other clients when online\nconst wsProvider = new WebsocketProvider(\"wss:\u002F\u002Fyjs.example.com\", \"doc-123\", doc);\n\n\u002F\u002F The two providers work together:\n\u002F\u002F 1. Online: changes sync via WebSocket AND save to IndexedDB\n\u002F\u002F 2. Offline: changes save to IndexedDB only\n\u002F\u002F 3. Reconnect: IndexedDB state syncs with server, merging all changes\n\n\u002F\u002F Observe document changes (from any source: local, remote, or loaded from DB)\ndoc.on(\"update\", (update: Uint8Array, origin: any) => {\n  if (origin === \"local\") {\n    console.log(\"Local change\");\n  } else {\n    console.log(\"Remote change received\");\n  }\n});\n```\n\n## Installation\n\n```bash\n# Core library\nnpm install yjs\n\n# Providers (pick what you need)\nnpm install y-websocket          # WebSocket sync\nnpm install y-indexeddb           # Browser offline persistence\nnpm install y-webrtc              # Peer-to-peer sync (no server)\n\n# Editor bindings\nnpm install @tiptap\u002Fextension-collaboration @tiptap\u002Fextension-collaboration-cursor\n\n# Server persistence\nnpm install y-mongodb-provider    # MongoDB\nnpm install y-leveldb             # LevelDB (lightweight)\n```\n\n\n## Examples\n\n\n### Example 1: Setting up Yjs with a custom configuration\n\n**User request:**\n\n```\nI just installed Yjs. Help me configure it for my TypeScript + React workflow with my preferred keybindings.\n```\n\nThe agent creates the configuration file with TypeScript-aware settings, configures relevant plugins\u002Fextensions for React development, sets up keyboard shortcuts matching the user's preferences, and verifies the setup works correctly.\n\n### Example 2: Extending Yjs with custom functionality\n\n**User request:**\n\n```\nI want to add a custom websocket provider to Yjs. How do I build one?\n```\n\nThe agent scaffolds the extension\u002Fplugin project, implements the core functionality following Yjs's API patterns, adds configuration options, and provides testing instructions to verify it works end-to-end.\n\n\n## Guidelines\n\n1. **Choose the right shared type** — Y.Text for documents, Y.Map for settings\u002Fstate, Y.Array for lists; don't force everything into one type\n2. **Keep documents small** — Large Y.Docs (>10MB) impact performance; split content into multiple documents\n3. **Use awareness for ephemeral data** — Cursors, selections, and typing indicators belong in awareness, not document state\n4. **Always add offline persistence** — y-indexeddb prevents data loss on disconnect; it's one line of code\n5. **Authenticate at the provider level** — Validate tokens in the WebSocket server before allowing sync\n6. **Batch observations** — Use `doc.transact()` to group multiple changes into one update event\n7. **Garbage collect** — Call `doc.gc = true` to enable garbage collection of deleted content\n8. **Test concurrent edits** — Open multiple browser tabs and edit simultaneously; verify merge behavior\n",{},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002FTerminalSkills\u002Fskills\u002Fyjs",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":7,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill yjs",{"tool":37,"command":38},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill yjs",{"tool":40,"command":41},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill yjs","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FTerminalSkills\u002Fskills\u002Fyjs\u002FSKILL.md",true,[45,51,55,59,63],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"navigation-split-view.md","REFERENCE","参考文档",8005,"https:\u002F\u002Fgithub.com\u002Fvitalikpestov\u002FSkills-Catalog\u002Fblob\u002Fmain\u002F_Mobile-Dev\u002Ffrom-article-18-ui-ux\u002Fclaude-code-apple-skills\u002Fskills\u002Fios\u002Fnavigation-patterns\u002Fnavigation-split-view.md",{"path":52,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":53,"sourceHtmlUrl":54},"navigation-stack.md",7417,"https:\u002F\u002Fgithub.com\u002Fvitalikpestov\u002FSkills-Catalog\u002Fblob\u002Fmain\u002F_Mobile-Dev\u002Ffrom-article-18-ui-ux\u002Fclaude-code-apple-skills\u002Fskills\u002Fios\u002Fnavigation-patterns\u002Fnavigation-stack.md",{"path":56,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":57,"sourceHtmlUrl":58},"navigation-transitions.md",6689,"https:\u002F\u002Fgithub.com\u002Fvitalikpestov\u002FSkills-Catalog\u002Fblob\u002Fmain\u002F_Mobile-Dev\u002Ffrom-article-18-ui-ux\u002Fclaude-code-apple-skills\u002Fskills\u002Fios\u002Fnavigation-patterns\u002Fnavigation-transitions.md",{"path":60,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":61,"sourceHtmlUrl":62},"programmatic-navigation.md",10394,"https:\u002F\u002Fgithub.com\u002Fvitalikpestov\u002FSkills-Catalog\u002Fblob\u002Fmain\u002F_Mobile-Dev\u002Ffrom-article-18-ui-ux\u002Fclaude-code-apple-skills\u002Fskills\u002Fios\u002Fnavigation-patterns\u002Fprogrammatic-navigation.md",{"path":64,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":65,"sourceHtmlUrl":66},"tab-view.md",7358,"https:\u002F\u002Fgithub.com\u002Fvitalikpestov\u002FSkills-Catalog\u002Fblob\u002Fmain\u002F_Mobile-Dev\u002Ffrom-article-18-ui-ux\u002Fclaude-code-apple-skills\u002Fskills\u002Fios\u002Fnavigation-patterns\u002Ftab-view.md",[68,77,86,95,101,107],{"skillNo":69,"name":70,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":18},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[74,75,76],"model","model hierarchy","model hierarchy skill",{"skillNo":78,"name":79,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":18},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[83,84,85],"MCP","zoom","zoom mcp",{"skillNo":87,"name":88,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":18},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[92,93,94,84],"sdk","zoom apps sdk","apps",{"skillNo":96,"name":97,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":18},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[97],{"skillNo":102,"name":103,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":18},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[103],{"skillNo":108,"name":109,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":18},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[109]]