Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:AFK surf Open agent Browser DOM

From Leeroopedia
Knowledge Sources
Domains Frontend, Web, Editor
Last Updated 2026-10-25 00:00 GMT

Overview

A modern browser DOM environment with Lit-based Web Components, Yjs CRDTs, and a Yarn 4 / Node <23 toolchain for running the BlockSuite editor, data-view, and extension loader.

Description

This environment provides the client-side runtime context for all BlockSuite editor, database block, markdown transform, and extension authoring implementations. It is built on standard browser APIs — the DOM, IndexedDB, BroadcastChannel, and Web Workers — and relies on Lit (Web Components), Preact signals (reactivity), and Yjs (CRDT sync). The toolchain uses Yarn 4.9.1 (Berry) with Node.js <23.0.0 and TypeScript 5.7+ across the monorepo workspaces.

Usage

Use this environment for any editor bootstrap, database block usage, markdown import/export, or extension authoring workflow. It is the mandatory prerequisite for running the BlockSuite playground starter app and every Implementation that mounts an editor, constructs a doc collection, or registers an extension provider.

System Requirements

Category Requirement Notes
OS Any (cross-platform) Linux, macOS, or Windows; WSL2 recommended on Windows
Runtime Node.js <23.0.0 Declared in `engines` field of root package.json; Yarn 4.9.1 (Berry) is the package manager
Browser Evergreen browser Chromium/Firefox/Safari with IndexedDB, BroadcastChannel, and Web Component support
Disk ~2GB For node_modules + Yarn cache and build artifacts

Dependencies

System Packages

  • `node` < 23.0.0
  • `yarn` = 4.9.1 (Berry, enabled via `packageManager` field)

JavaScript Packages

  • `lit` (Web Components / custom elements)
  • `@preact/signals-core` (reactive primitives)
  • `yjs` (CRDT, patched via `resolutions`)
  • `idb` >= 8.0.3 (IndexedDB wrapper for blob persistence)
  • `zod` (extension provider schema validation)
  • `vite` >= 6.0.3 (dev server / build)
  • `vitest` = 3.1.3 (unit + browser tests)
  • `@blocksuite/affine/*` (workspace packages resolved via Yarn workspaces)
  • `@blocksuite/affine-ext-loader` (extension provider base classes)
  • `@blocksuite/affine/sync` (blob/doc/awareness sources: MemoryBlobSource, IndexedDBBlobSource, BroadcastChannel*)

Credentials

No credentials are required for the browser environment itself. The playground may read optional URL parameters:

  • `?room=` — enables BroadcastChannel-based doc/awareness sync across tabs
  • `?blobSource=mock,idb` — adds MockServerBlobSource and/or IndexedDBBlobSource as shadow blob stores
  • `?init=` — selects the data preset used to seed the doc collection

Quick Install

# Install the monorepo with Yarn 4 (Berry)
yarn install

# Start the playground dev server
yarn dev

Code Evidence

Node engine constraint from `package.json:14-16`:

"engines": {
  "node": "<23.0.0"
}

Blob source selection (IndexedDB + BroadcastChannel detection) from `blocksuite/playground/apps/starter/utils/collection.ts:42-51`:

const blobSources = {
  main: new MemoryBlobSource(),
  shadows: [] as BlobSource[],
} satisfies DocCollectionOptions['blobSources'];
if (blobSourceArgs.includes('mock')) {
  blobSources.shadows.push(new MockServerBlobSource(collectionId));
}
if (blobSourceArgs.includes('idb')) {
  blobSources.shadows.push(new IndexedDBBlobSource(collectionId));
}

DOM element creation for the editor from `blocksuite/playground/apps/starter/utils/extensions.ts:54-55`:

const editor = document.createElement('affine-editor-container');
editor.autofocus = true;
editor.doc = store;

Common Errors

Error Message Cause Solution
`Yarn classic commands not supported` Using Yarn 1 (Classic) instead of Berry Run `corepack enable` then `yarn install`; the `packageManager` field pins Yarn 4.9.1
`affine-editor-container is not defined` Custom element not registered (extension effect not run) Ensure `viewManager.get('page'/'edgeless')` is spread into `editor.pageSpecs`/`edgelessSpecs` before mount
`IndexedDB is not defined` Running in a non-browser (Node) context BlockSuite editor code requires a DOM; use a browser or `happy-dom`/`jsdom` in tests
BroadcastChannel sync not working Tabs share the same `room` param? Append `?room=<name>` to the URL in every participating tab

Compatibility Notes

  • SSR / Node: The editor code paths require a DOM; server-side rendering is not supported. Use `happy-dom` (already a devDependency) for vitest browser tests.
  • Older browsers: Requires IndexedDB and BroadcastChannel; very old browsers without Web Component support will not work.
  • Mobile browsers: Supported via dedicated view scopes (`mobile-page`, `mobile-edgeless`) in the extension system.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment