How whale4113/cloud-document-converter works
Project type and purpose
• This is a browser‐extension project (“Cloud Document Converter”) within a pnpm/turbo monorepo.
• Its goal is to let end‐users on Lark Docs pages download or copy the document content as Markdown.
File structure
• Top‐level monorepo config:
• pnpm-workspace.yaml, turbo.json – orchestrate multi‐package builds.
• .github/workflows – CI, releases, dependency updates.
• apps/chrome-extension – the extension codebase:
• popup.html + popup.js – extension UI.
• background.ts – background script handles heavy lifting (file generation, downloads).
• content.ts – content script injected into Lark Docs pages.
• src/common – shared utilities (i18n, messaging, notifications).
• scripts/… – build helpers (version bump, cross‐browser build).
• rollup.config.js + tsconfig*.json – build pipeline for web, Node, extension.
• packages/common – shared utility library.
• packages/lark – core Lark‐doc‐to‐Markdown parsing and file handling.
• other packages – eslint-config, rollup-config, typescript-config.
README for architectural hints
• Features emphasize two flows: “Download as Markdown” and “Copy as Markdown.”
• Interactions happen on Lark Docs pages, then pass through extension scripts, through the lark parser, and finally to user.
a. Main components
• Browser extension UI (popup)
• Content Script (injected into Lark Docs page)
• Background Script (orchestrator)
• Core Parsing Library (packages/lark)
• Shared Utility Library (packages/common)
• Build & Tooling (pnpm, turbo, Rollup, scripts)
• External Systems: Lark Docs web page, Lark file/CDN endpoints, Chrome/Edge/Firefox stores
• CI/CD pipeline (GitHub Actions)
b. Relationships and interactions
1. User opens the extension popup → UI triggers a message.
2. Popup communicates with Background Script via chrome.runtime.
3. Background Script may ask Content Script to scrape the current Lark Docs DOM or fetch docx via Lark API.
4. Content Script returns raw document data to Background.
5. Background invokes packages/lark to convert to Markdown (using shared/common utils).
6. Background triggers file download or writes to clipboard.
7. Build pipeline (Rollup, turbo) compiles TypeScript, bundles packages, outputs extension artifact.
8. CI/CD publishes to extension stores.
c. Architectural patterns and principles
• Separation of concerns: UI / orchestration / parsing / utilities
• Message‐passing micro‐frontend (content vs. background vs. popup)
• Monorepo workspace – code reuse and consistent configs
• Layered build pipeline – each package has its own Rollup and tsconfig but shares root tooling
d. Key technologies and libraries
• TypeScript, Rollup, pnpm workspaces, turborepo
• Chrome Extension APIs (runtime messaging, downloads, storage)
• packages/lark for parsing docx and DOM → Markdown
• packages/common for shared utilities (DOM, image handling, time)
• GitHub Actions for CI, GitHub Releases, Dependabot