mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-12-05 11:15:01 +03:00
refactor(workspace): dissolve native-playground into domain directories
This commit is contained in:
1 parent
9cd813275b
commit
6f9f1cace5
318 files changed
+1557
-458
No files matched your search
@@ -73,9 +73,36 @@ jobs:
|
||||
- '.github/actions/setup-node/**'
|
||||
- '.github/workflows/np-web-fast.yml'
|
||||
web-build:
|
||||
- 'packages/frontend/**'
|
||||
- 'packages/common/**'
|
||||
- 'blocksuite/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs,css,json}'
|
||||
- 'packages/frontend/admin/**'
|
||||
- 'packages/frontend/apps/**'
|
||||
- 'packages/frontend/component/**'
|
||||
- 'packages/frontend/core/**'
|
||||
- 'packages/frontend/electron-api/**'
|
||||
- 'packages/frontend/i18n/**'
|
||||
- 'packages/frontend/mobile-native/**'
|
||||
- 'packages/frontend/native/**'
|
||||
- 'packages/frontend/routes/**'
|
||||
- 'packages/frontend/templates/**'
|
||||
- 'packages/frontend/track/**'
|
||||
- 'packages/common/auth/**'
|
||||
- 'packages/common/debug/**'
|
||||
- 'packages/common/env/**'
|
||||
- 'packages/common/error/**'
|
||||
- 'packages/common/graphql/**'
|
||||
- 'packages/common/infra/**'
|
||||
- 'packages/common/native/**'
|
||||
- 'packages/common/nbstore/**'
|
||||
- 'packages/common/reader/**'
|
||||
- 'packages/common/realtime/**'
|
||||
- 'packages/common/s3-compat/**'
|
||||
- 'packages/common/theme/**'
|
||||
- 'blocksuite/affine/**'
|
||||
- 'blocksuite/framework/**'
|
||||
- 'blocksuite/playground/**'
|
||||
- 'blocksuite/integration-test/**'
|
||||
- 'blocksuite/docs/**'
|
||||
- 'blocksuite/docs-site/**'
|
||||
- 'blocksuite/tsconfig.json'
|
||||
- 'tools/cli/**'
|
||||
- '**/package.json'
|
||||
- '**/tsconfig*.json'
|
||||
@@ -176,6 +203,8 @@ jobs:
|
||||
--select server-mail --select server-blob --select server-sync \
|
||||
--select server-http --select server-worker --select affine-server "${timings[@]}"
|
||||
cat ../../.artifacts/server-harness/run.json
|
||||
test -s ../../.artifacts/server-harness/run.json
|
||||
test -s ../../.artifacts/csf-frame-audit/frames.json
|
||||
test "$status" = passed
|
||||
|
||||
- name: Upload run report
|
||||
@@ -193,7 +222,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
defaults:
|
||||
run:
|
||||
working-directory: blocksuite/native-playground
|
||||
working-directory: packages/frontend
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
@@ -212,7 +241,7 @@ jobs:
|
||||
- name: Cache Cargo artifacts
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: blocksuite/native-playground -> target
|
||||
workspaces: packages/frontend -> target
|
||||
key: lint-wasm
|
||||
|
||||
- name: Format check
|
||||
@@ -227,8 +256,8 @@ jobs:
|
||||
- name: Perf guardrail self-tests and generated token/icon unit tests
|
||||
run: |
|
||||
node --test perf/compare-n3.test.mjs
|
||||
rustc --edition 2024 --test -D warnings tokens/tokens.rs -o /tmp/tokens_test && /tmp/tokens_test
|
||||
rustc --edition 2024 --test -D warnings tokens/icons.rs -o /tmp/icons_test && /tmp/icons_test
|
||||
rustc --edition 2024 --test -D warnings ../ui/tokens/tokens.rs -o /tmp/tokens_test && /tmp/tokens_test
|
||||
rustc --edition 2024 --test -D warnings ../ui/tokens/icons.rs -o /tmp/icons_test && /tmp/icons_test
|
||||
rm -f /tmp/tokens_test /tmp/icons_test
|
||||
|
||||
- name: Verify generated tokens, icons, and fonts.lock have zero drift
|
||||
@@ -241,7 +270,7 @@ jobs:
|
||||
| tar -xz --strip-components=1 -C /tmp/np-token-deps/node_modules/@toeverything/theme
|
||||
curl -fsSL "https://registry.npmjs.org/@blocksuite/icons/-/icons-${ICONS_VER}.tgz" \
|
||||
| tar -xz --strip-components=1 -C /tmp/np-token-deps/node_modules/@blocksuite/icons
|
||||
node tokens/extract-tokens.mjs --check --node-modules /tmp/np-token-deps/node_modules
|
||||
node ../ui/tokens/extract-tokens.mjs --check --node-modules /tmp/np-token-deps/node_modules
|
||||
rm -rf /tmp/np-token-deps
|
||||
|
||||
- name: Check WebAssembly target
|
||||
@@ -254,7 +283,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
defaults:
|
||||
run:
|
||||
working-directory: blocksuite/native-playground
|
||||
working-directory: packages/frontend
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
@@ -284,7 +313,7 @@ jobs:
|
||||
- name: Cache Cargo artifacts
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: blocksuite/native-playground -> target
|
||||
workspaces: packages/frontend -> target
|
||||
key: headless-linux
|
||||
|
||||
- name: Run workspace unit tests (default and harness)
|
||||
@@ -294,16 +323,18 @@ jobs:
|
||||
|
||||
- name: Build WebAssembly bundle and run headless Chromium smoke test
|
||||
run: |
|
||||
mkdir -p artifacts web/pkg
|
||||
mkdir -p artifacts ../../blocksuite/crates/playground/web/pkg
|
||||
cargo build --locked -p playground --target wasm32-unknown-unknown --release
|
||||
wasm-bindgen --target web --out-dir web/pkg target/wasm32-unknown-unknown/release/playground.wasm
|
||||
WASM_RAW=$(wc -c < web/pkg/playground_bg.wasm | tr -d ' ')
|
||||
WASM_GZIP=$(gzip -9 -c web/pkg/playground_bg.wasm | wc -c | tr -d ' ')
|
||||
wasm-bindgen --target web --out-dir ../../blocksuite/crates/playground/web/pkg target/wasm32-unknown-unknown/release/playground.wasm
|
||||
WASM_RAW=$(wc -c < ../../blocksuite/crates/playground/web/pkg/playground_bg.wasm | tr -d ' ')
|
||||
WASM_GZIP=$(gzip -9 -c ../../blocksuite/crates/playground/web/pkg/playground_bg.wasm | wc -c | tr -d ' ')
|
||||
echo "WASM_RAW=$WASM_RAW" >> "$GITHUB_ENV"
|
||||
echo "WASM_GZIP=$WASM_GZIP" >> "$GITHUB_ENV"
|
||||
node scripts/web-smoke.mjs \
|
||||
--out artifacts/wasm-chromium.png \
|
||||
--out-edgeless artifacts/wasm-chromium-edgeless.png
|
||||
test -s artifacts/wasm-chromium.png
|
||||
test -s artifacts/wasm-chromium-edgeless.png
|
||||
|
||||
- name: Deterministic headless render, audit, 4-fps check, and 30-frame bench
|
||||
run: |
|
||||
@@ -318,6 +349,8 @@ jobs:
|
||||
--snapshot artifacts/linux-run2.json \
|
||||
--width 1280 \
|
||||
--height 800
|
||||
test -s artifacts/linux-run1.png
|
||||
test -s artifacts/linux-run1.json
|
||||
sha1=$(sha256sum artifacts/linux-run1.png | awk '{print $1}')
|
||||
sha2=$(sha256sum artifacts/linux-run2.png | awk '{print $1}')
|
||||
echo "Run 1 SHA256: $sha1"
|
||||
@@ -331,24 +364,55 @@ jobs:
|
||||
--commit "${{ github.sha }}" \
|
||||
--web-wasm-raw "$WASM_RAW" \
|
||||
--web-wasm-gzip "$WASM_GZIP"
|
||||
test -s artifacts/perf-metrics.json
|
||||
|
||||
- name: Compare against rolling N-3 baseline
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
if [ -f perf/compare-n3.mjs ]; then
|
||||
node perf/compare-n3.mjs \
|
||||
--fetch-github \
|
||||
--repo "${{ github.repository }}" \
|
||||
--branch darksky/native-playground \
|
||||
--workflow native-playground.yml \
|
||||
--run-id "${{ github.run_id }}" \
|
||||
--current artifacts/perf-metrics.json \
|
||||
--json-out artifacts/perf-verdict.json \
|
||||
--fail-on-regression >> "$GITHUB_STEP_SUMMARY"
|
||||
else
|
||||
echo "No perf/compare-n3.mjs present; skipping N-3 comparison." >> "$GITHUB_STEP_SUMMARY"
|
||||
test -f perf/compare-n3.mjs
|
||||
STRICT_PERF_FLAG="--require-n3"
|
||||
if [ "${NP_ALLOW_PERF_BOOTSTRAP:-0}" = "1" ]; then
|
||||
STRICT_PERF_FLAG=""
|
||||
fi
|
||||
node perf/compare-n3.mjs \
|
||||
--fetch-github \
|
||||
--repo "${{ github.repository }}" \
|
||||
--branch darksky/native-playground \
|
||||
--workflow native-playground.yml \
|
||||
--run-id "${{ github.run_id }}" \
|
||||
--current artifacts/perf-metrics.json \
|
||||
--json-out artifacts/perf-verdict.json \
|
||||
$STRICT_PERF_FLAG \
|
||||
--fail-on-regression >> "$GITHUB_STEP_SUMMARY"
|
||||
test -s artifacts/perf-verdict.json
|
||||
node -e '
|
||||
const fs = require("node:fs");
|
||||
const v = JSON.parse(fs.readFileSync("artifacts/perf-verdict.json", "utf8"));
|
||||
const allowBootstrap = process.env.NP_ALLOW_PERF_BOOTSTRAP === "1";
|
||||
const shaRe = /^[0-9a-f]{40}$/;
|
||||
if (
|
||||
(!allowBootstrap && (v.baseline_depth !== "N-3" || !shaRe.test(v.baseline_commit || ""))) ||
|
||||
(allowBootstrap && v.baseline_depth !== "bootstrap" && !shaRe.test(v.baseline_commit || "")) ||
|
||||
!Array.isArray(v.metrics) ||
|
||||
v.metrics.length === 0
|
||||
) {
|
||||
throw new Error(`Invalid perf-verdict.json: baseline_depth=${v.baseline_depth}, baseline_commit=${v.baseline_commit}, metrics=${v.metrics?.length}`);
|
||||
}
|
||||
const dropped = v.metrics.filter(m => m.status === "DROPPED");
|
||||
if (dropped.length > 0) {
|
||||
throw new Error(`Unacknowledged dropped baseline metrics: ${dropped.map(m => m.key).join(", ")}`);
|
||||
}
|
||||
const unacceptedBootstrap = v.metrics.filter(m => m.status === "BOOTSTRAP");
|
||||
if (!allowBootstrap && unacceptedBootstrap.length > 0) {
|
||||
throw new Error(`Unacknowledged BOOTSTRAP metrics against N-3 baseline: ${unacceptedBootstrap.map(m => m.key).join(", ")}`);
|
||||
}
|
||||
const compared = v.metrics.filter(m => m.baseline != null && m.current != null);
|
||||
if (!allowBootstrap && compared.length === 0) {
|
||||
throw new Error("No metrics were compared against prior N-3 baseline history");
|
||||
}
|
||||
console.log(`perf-verdict.json verified: ${v.baseline_depth} (${(v.baseline_commit || "none").slice(0, 10)}), ${v.metrics.length} metrics, ${unacceptedBootstrap.length} unacknowledged bootstrap, 0 dropped`);
|
||||
'
|
||||
|
||||
- name: Upload perf metrics artifact
|
||||
if: always()
|
||||
@@ -356,8 +420,8 @@ jobs:
|
||||
with:
|
||||
name: perf-metrics
|
||||
path: |
|
||||
blocksuite/native-playground/artifacts/perf-metrics.json
|
||||
blocksuite/native-playground/artifacts/perf-verdict.json
|
||||
packages/frontend/artifacts/perf-metrics.json
|
||||
packages/frontend/artifacts/perf-verdict.json
|
||||
if-no-files-found: ignore
|
||||
|
||||
- name: Upload Linux headless and Web smoke artifacts
|
||||
@@ -366,10 +430,10 @@ jobs:
|
||||
with:
|
||||
name: headless-linux-artifacts
|
||||
path: |
|
||||
blocksuite/native-playground/artifacts/linux-run1.png
|
||||
blocksuite/native-playground/artifacts/linux-run1.json
|
||||
blocksuite/native-playground/artifacts/wasm-chromium.png
|
||||
blocksuite/native-playground/artifacts/wasm-chromium-edgeless.png
|
||||
packages/frontend/artifacts/linux-run1.png
|
||||
packages/frontend/artifacts/linux-run1.json
|
||||
packages/frontend/artifacts/wasm-chromium.png
|
||||
packages/frontend/artifacts/wasm-chromium-edgeless.png
|
||||
if-no-files-found: ignore
|
||||
|
||||
macos-headless:
|
||||
@@ -377,7 +441,7 @@ jobs:
|
||||
runs-on: macos-15
|
||||
defaults:
|
||||
run:
|
||||
working-directory: blocksuite/native-playground
|
||||
working-directory: packages/frontend
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
@@ -388,7 +452,7 @@ jobs:
|
||||
- name: Cache Cargo artifacts
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: blocksuite/native-playground -> target
|
||||
workspaces: packages/frontend -> target
|
||||
key: macos-headless
|
||||
|
||||
- name: Check workspace all targets
|
||||
@@ -412,6 +476,8 @@ jobs:
|
||||
--snapshot artifacts/macos-run2.json \
|
||||
--width 1280 \
|
||||
--height 800
|
||||
test -s artifacts/macos-run1.png
|
||||
test -s artifacts/macos-run1.json
|
||||
sha1=$(shasum -a 256 artifacts/macos-run1.png | awk '{print $1}')
|
||||
sha2=$(shasum -a 256 artifacts/macos-run2.png | awk '{print $1}')
|
||||
echo "Run 1 SHA256: $sha1"
|
||||
@@ -424,8 +490,9 @@ jobs:
|
||||
with:
|
||||
name: headless-macos-artifacts
|
||||
path: |
|
||||
blocksuite/native-playground/artifacts/macos-run1.png
|
||||
blocksuite/native-playground/artifacts/macos-run1.json
|
||||
packages/frontend/artifacts/macos-run1.png
|
||||
packages/frontend/artifacts/macos-run1.json
|
||||
if-no-files-found: error
|
||||
|
||||
js-room-coop:
|
||||
name: JS Room Coop & Rust-JS E2E
|
||||
@@ -461,15 +528,15 @@ jobs:
|
||||
- name: Cache Cargo artifacts
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: blocksuite/native-playground -> target
|
||||
workspaces: packages/frontend -> target
|
||||
key: js-room-coop
|
||||
|
||||
- name: Build bs-relay and bs_doc_driver
|
||||
working-directory: blocksuite/native-playground
|
||||
working-directory: packages/frontend
|
||||
run: cargo build --locked -p blocksuite-playground-doc --bin bs-relay --example bs_doc_driver
|
||||
|
||||
- name: Verify JS-authored surface snapshots without writeback
|
||||
working-directory: blocksuite/native-playground
|
||||
working-directory: packages/frontend
|
||||
run: cargo test --locked -p blocksuite-playground-doc --example bs_doc_driver js_authored_surface
|
||||
|
||||
- name: Lint, format, and typecheck JS room sync
|
||||
@@ -500,8 +567,8 @@ jobs:
|
||||
|
||||
- name: Verify surface geometry oracle and live Rust-JS room sync
|
||||
env:
|
||||
BS_RELAY_BIN: ${{ github.workspace }}/blocksuite/native-playground/target/debug/bs-relay
|
||||
BS_DOC_DRIVER_BIN: ${{ github.workspace }}/blocksuite/native-playground/target/debug/examples/bs_doc_driver
|
||||
BS_RELAY_BIN: ${{ github.workspace }}/packages/frontend/target/debug/bs-relay
|
||||
BS_DOC_DRIVER_BIN: ${{ github.workspace }}/packages/frontend/target/debug/examples/bs_doc_driver
|
||||
run: |
|
||||
(cd blocksuite/framework/sync && ../../../node_modules/.bin/vitest run)
|
||||
(cd blocksuite/playground && ../../node_modules/.bin/vitest run)
|
||||
|
||||
@@ -104,3 +104,6 @@ storageState.json
|
||||
/.playwright-browsers/
|
||||
**/.vitest-attachments/
|
||||
/blocksuite/framework/std/src/__tests__/gfx/__screenshots__/
|
||||
/packages/frontend/target/
|
||||
/packages/frontend/artifacts/
|
||||
/blocksuite/crates/playground/web/pkg/
|
||||
+5
-1
@@ -6,5 +6,9 @@
|
||||
"tabWidth": 2,
|
||||
"arrowParens": "avoid",
|
||||
"sortPackageJson": false,
|
||||
"ignorePatterns": ["**/*.toml"]
|
||||
"ignorePatterns": [
|
||||
"**/*.toml",
|
||||
"packages/frontend/artifacts/**",
|
||||
"blocksuite/crates/playground/web/pkg/**"
|
||||
]
|
||||
}
|
||||
+6
-1
@@ -43,6 +43,7 @@
|
||||
".vscode",
|
||||
".context",
|
||||
".codex",
|
||||
".agents",
|
||||
".yarnrc.yml",
|
||||
".docker",
|
||||
"**/.storybook",
|
||||
@@ -73,7 +74,11 @@
|
||||
"tests/oracle-contracts/**",
|
||||
"packages/backend/server-types/assets/*.license.json",
|
||||
"packages/backend/native/src/*.license.json",
|
||||
"blocksuite/native-playground/**",
|
||||
"packages/ui/**",
|
||||
"packages/frontend/perf/**",
|
||||
"packages/frontend/scripts/**",
|
||||
"packages/frontend/artifacts/**",
|
||||
"blocksuite/crates/**",
|
||||
"blocksuite/docs/api/**",
|
||||
"blocksuite/docs-site/.vitepress/.temp/**",
|
||||
"blocksuite/docs-site/api/**",
|
||||
|
||||
+5
-1
@@ -43,7 +43,11 @@ tests/blocksuite/snapshots
|
||||
tests/oracle-contracts/**
|
||||
packages/backend/server-types/assets/*.license.json
|
||||
packages/backend/native/src/*.license.json
|
||||
blocksuite/native-playground/**
|
||||
packages/ui/**
|
||||
packages/frontend/perf/**
|
||||
packages/frontend/scripts/**
|
||||
packages/frontend/artifacts/**
|
||||
blocksuite/crates/**
|
||||
blocksuite/docs/api/**
|
||||
blocksuite/docs-site/.vitepress/.temp/**
|
||||
blocksuite/docs-site/api/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Working on AFFiNE Native Playground (for agents)
|
||||
|
||||
These rules apply at the repository root on the `darksky/native-playground` branch and on topic branches under `darksky/np/**`. Subdirectory `AGENTS.md` files (for example `blocksuite/native-playground/AGENTS.md`) give narrower rules beside the code they govern.
|
||||
These rules apply at the repository root on the `darksky/native-playground` branch and on topic branches under `darksky/np/**`. Subdirectory `AGENTS.md` files (for example `packages/frontend/AGENTS.md`, `packages/ui/AGENTS.md`, and `blocksuite/crates/AGENTS.md`) give narrower rules beside the code they govern.
|
||||
|
||||
## Branch and CI workflow
|
||||
|
||||
@@ -12,7 +12,7 @@ These rules apply at the repository root on the `darksky/native-playground` bran
|
||||
|
||||
- **Performance regression gate:** A CI benchmark metric can regress by **more than 10%** against the rolling `N-3` baseline. In that case, the performance guardian reviews the change before it lands.
|
||||
|
||||
- **Cargo rustflags isolation:** Root `.cargo/config.toml` adds NAPI linker flags (`-all_load`, `-undefined dynamic_lookup`, `-z nodelete`). Cargo joins these flags into nested workspaces. Always set `CARGO_ENCODED_RUSTFLAGS=""` when you build and test `blocksuite/native-playground` and the standalone `packages/backend/` workspace.
|
||||
- **Cargo rustflags isolation:** Root `.cargo/config.toml` adds NAPI linker flags (`-all_load`, `-undefined dynamic_lookup`, `-z nodelete`). Cargo joins these flags into nested workspaces. Always set `CARGO_ENCODED_RUSTFLAGS=""` when you build and test `packages/frontend/` and the standalone `packages/backend/` workspace.
|
||||
|
||||
- **Static gates:** `node scripts/ci/check-l0-tier-a.mjs` has no dependencies and runs in under a second. It guards the `packages/backend/` layering and hygiene. It also guards workflow references and the `waitForTimeout` / `.skip` ratchet in `scripts/ci/l0-ratchet.json`. The ratchet counts can only go down. To lower the ceiling, run the script with `--update-baseline`.
|
||||
|
||||
|
||||
@@ -1,33 +1,19 @@
|
||||
# Working in `blocksuite/native-playground` (for agents)
|
||||
# Working in `blocksuite/crates/` (for agents)
|
||||
|
||||
This document records the active engineering invariants enforced in CI today alongside the planned contracts for upcoming crates and editor features.
|
||||
`blocksuite/crates/` holds the pure BlockSuite CRDT document engine (`doc/`), the standalone playground application (`playground/`), and browser geometry/style oracle fixtures (`oracle/`).
|
||||
These crates belong to the client Cargo workspace rooted at `packages/frontend/Cargo.toml`.
|
||||
|
||||
## Active Invariants (enforced now)
|
||||
|
||||
### Workspace boundaries
|
||||
- `crates/ui`: Single fused internal GPU UI library (vendored once without upstream sync hooks, zero internal `proc-macro = true` crates, zero external UI-kit dependencies). It knows **nothing** about BlockSuite or AFFiNE (`scripts/check-invariants.sh` rejects `blocksuite` and `affine` inside `crates/ui`) and embeds zero fonts (fonts are registered by the application via `cx.text_system().add_fonts(...)`).
|
||||
- `crates/doc` (`blocksuite-playground-doc`) & `bs-relay`: Pure CRDT document engine and binary room sync relay (`#![forbid(unsafe_code)]`, zero GUI/platform dependencies, `scripts/check-invariants.sh` rejects `ui`, `wgpu`, `objc2`, and `web-sys` in `crates/doc/Cargo.toml`) built on `y-octo 0.4.0`. Preserves 53-bit `clientId` (`1..=2^53 - 1`), complete flavour schema defaults (`schema/`, 0 JS writeback updates on initial load), top-level Awareness `color` alongside `user` and `selectionV2`, deterministic `now_ms`-driven undo/awareness clocks (`session/`), WebSocket-only `seed-claim` / `seed-claim-result` single-winner arbitration (keyed by `seed:<docId>`), awareness refcounting across connections that forwards a removal (including the equal-clock live-to-`null` form `y-protocols` uses to expire a peer) once the last owner releases a client, `?ws=` relay origin forwarding with permissive blob CORS headers, and `wasm32-unknown-unknown` compatibility under `--no-default-features`. `read/` (`PageDocSession::read_page_snapshot`) is the typed read side: an ordered `PageSnapshot` tree of `BlockNode`s whose `BlockContent` covers every supported block flavour, keeps the normalized JSON of every `prop:*`, numbers `numbered` list runs, reads `prop:textAlign` and the note display modes by their BlockSuite wire values (`both` / `doc` / `edgeless`), reports blocks outside the root tree as `detached`, and reads any other flavour as `Unknown` instead of dropping it.
|
||||
- `crates/playground`: Application layer owning the shipping `PlaygroundView` (`lib.rs`, `chrome.rs`, `view_room.rs`), the tracked repository font registration (`Inter` and the four `IBM Plex Mono` faces), the native macOS desktop entry (`native-playground`), the WebAssembly canvas entry (`wasm_main`), and the deterministic headless verification CLI (`src/bin/bs_harness/`). `theme.rs` resolves colors, typography and icons from the generated `tokens/tokens.rs` / `tokens/icons.rs` (pulled in with `include!`, never copied and never reformatted) for `PlaygroundTheme::{Light, Dark}`; `block_flow/` is the Page-mode renderer; `rich_text/` is the rich paragraph engine; `editor_session/` and `clipboard/` are the page editor; `overlays/` holds the popovers and the interactive block controls; `room_client/` is live room sync; `showcase.rs` seeds the deterministic `seed_showcase_doc` workspace shown without a room (every Page-mode block, one image blob, one remote collaborator).
|
||||
- `blocksuite/crates/doc` (`blocksuite-playground-doc`) & `bs-relay`: Pure CRDT document engine and binary room sync relay (`#![forbid(unsafe_code)]`, zero GUI/platform dependencies, `packages/frontend/scripts/check-invariants.sh` rejects `ui`, `wgpu`, `objc2`, and `web-sys` in `blocksuite/blocksuite/crates/doc/Cargo.toml`) built on `y-octo 0.4.0`. Preserves 53-bit `clientId` (`1..=2^53 - 1`), complete flavour schema defaults (`schema/`, 0 JS writeback updates on initial load), top-level Awareness `color` alongside `user` and `selectionV2`, deterministic `now_ms`-driven undo/awareness clocks (`session/`), WebSocket-only `seed-claim` / `seed-claim-result` single-winner arbitration (keyed by `seed:<docId>`), awareness refcounting across connections that forwards a removal (including the equal-clock live-to-`null` form `y-protocols` uses to expire a peer) once the last owner releases a client, `?ws=` relay origin forwarding with permissive blob CORS headers, and `wasm32-unknown-unknown` compatibility under `--no-default-features`. `read/` (`PageDocSession::read_page_snapshot`) is the typed read side: an ordered `PageSnapshot` tree of `BlockNode`s whose `BlockContent` covers every supported block flavour, keeps the normalized JSON of every `prop:*`, numbers `numbered` list runs, reads `prop:textAlign` and the note display modes by their BlockSuite wire values (`both` / `doc` / `edgeless`), reports blocks outside the root tree as `detached`, and reads any other flavour as `Unknown` instead of dropping it.
|
||||
- `blocksuite/crates/playground`: Application layer owning the shipping `PlaygroundView` (`lib.rs`, `chrome.rs`, `view_room.rs`), the tracked repository font registration (`Inter` and the four `IBM Plex Mono` faces), the native macOS desktop entry (`native-playground`), the WebAssembly canvas entry (`wasm_main`), and the deterministic headless verification CLI (`src/bin/bs_harness/`). `theme.rs` resolves colors, typography and icons from the generated `packages/ui/tokens/tokens.rs` / `packages/ui/tokens/icons.rs` (pulled in with `include!`, never copied and never reformatted) for `PlaygroundTheme::{Light, Dark}`; `block_flow/` is the Page-mode renderer; `rich_text/` is the rich paragraph engine; `editor_session/` and `clipboard/` are the page editor; `overlays/` holds the popovers and the interactive block controls; `room_client/` is live room sync; `showcase.rs` seeds the deterministic `seed_showcase_doc` workspace shown without a room (every Page-mode block, one image blob, one remote collaborator).
|
||||
- `unexpected_cfgs = "deny"` is enforced workspace-wide in `Cargo.toml`; dead upstream feature gates are forbidden.
|
||||
|
||||
### Platform matrix
|
||||
`crates/ui` compiles cleanly across three targets from one crate:
|
||||
- **macOS (`target_os = "macos"`)**: AppKit + Metal + CoreText, including windowless `MetalHeadlessRenderer` readback, full mip-0 `MetalAtlas` zero-init, and offscreen `MacWindow` frame/scale fallbacks.
|
||||
- **Linux Headless (`target_os = "linux"`)**: `wgpu` + `cosmic-text` via `WgpuHeadlessRenderer` on Mesa `lavapipe` for deterministic software rasterization in CI.
|
||||
- **Web (`target_family = "wasm"`)**: Single-threaded `wasm32-unknown-unknown` + WebGPU/WebGL2 + `CanvasFontFallback` + block-scoped `ImeMirror` (no `wasm_thread`, no `http_client`), verified in headless Chromium via `scripts/web-smoke.mjs` (`--query` loads the page with a query string such as a live room, `--min-title-ink` waits for that much page ink before capturing; without a query it also drives composition across blocks and composition and paste in the toolbar's link field through the hidden textarea).
|
||||
|
||||
### Determinism, single clock, and zero tester branches
|
||||
- **Single UI execution path**: Headless shell rendering (`bs-harness render`), desktop (`main.rs`), and Web (`wasm_main`) all instantiate and render the exact same shipping `PlaygroundView` through `Application::with_platform(...)` and `Window::draw()`.
|
||||
- **No wall clock outside `crates/ui/src/platform/`**: `Instant::now()` and `SystemTime::now()` are forbidden anywhere outside `crates/ui/src/platform/` (`scripts/check-invariants.sh`). Host thread-park deadlines read monotonic time in `crates/ui/src/platform/clock.rs`; animations and transitions read the scheduler clock (`cx.background_executor().now()`, backed by `TestScheduler` in headless/test runs and the platform scheduler in desktop/web).
|
||||
- **Motion is pure data**: Transitions are declared once as `(from, to, curve, start_ms, duration_ms)` and evaluated as a pure function of scheduler time. Never write frame-by-frame recurrence loops or `sleep` waits.
|
||||
- **Zero tester branches**: Application and layout logic never inspect `is_headless` or inline `#[cfg(any(test, feature = "harness"))]` to alter behavior (`scripts/check-invariants.sh`).
|
||||
- **Four-rate replay invariance**: Stepped `PlaygroundView` transitions (the mode switch, the slash menu and the formatting toolbar opening and closing) must progress monotonically with in-flight frames and produce byte-identical terminal `FrameSnapshot` JSON at `60`, `120`, `24`, and `7` fps (`bs-harness fps-check`).
|
||||
- **Callsite tracing**: Under the `harness` feature, `InteractiveElement::snapshot(...)` records post-layout bounds, `content_mask`, interactivity, focus, and `#[track_caller]` `file:line` origins into `Window::frame_snapshot()` for `sources_at(x, y)` and `bs-harness audit`. The snapshot schema and the audit rules are the repository's `tools/frame-audit` (a `serde`-only path dependency of `crates/ui`, re-exported from `ui::harness`). Change them there and keep both workspaces' tests green. Non-harness release builds compile to no-op stubs.
|
||||
- **Locked builds & rustflags isolation**: `Cargo.lock` is committed and CI runs with `--locked` and `CARGO_ENCODED_RUSTFLAGS=""` (`scripts/check-invariants.sh` verifies fresh `cargo rustc --print link-args` contains zero leaked root NAPI flags).
|
||||
- `blocksuite/crates/oracle/`: Browser-captured style and surface geometry fixtures (`style-oracle.json`, `surface-oracle.json`, `surface-baselines.json`, `surface-metrics-test.ttf`), `surface-baselines.mjs`, `surface-oracle.spec.mjs`, `extract-style-oracle.spec.ts`, and browser-mode `vitest.config.ts` (`browser.enabled: true` so `scripts/ci/vitest-node-projects.mjs` skips it).
|
||||
|
||||
### Page rendering and room sync
|
||||
- **World space vs screen space**: `BlockFlow` lays a `PageSnapshot` out in document coordinates (origin at the page column's top-left, independent of window and scroll) and reuses the body of every block whose content, width and theme are unchanged. `PageViewport` maps world space onto the screen (`viewport origin + world - scroll`); only blocks intersecting the viewport become elements. Top bar, mode switcher, theme toggle and presence badges are screen-space chrome.
|
||||
- **Style oracle parity**: Block metrics (`paragraph_spec` with baselines and heading letter spacing, quote/code/divider/bookmark constants, margin collapsing, 24px child indent, the 944px container with 96px / 24px side padding) mirror BlockSuite's page CSS and are asserted against `tokens/style-oracle.json` in both themes by `crates/playground` tests, on the constants (L1) and on rendered frames (L2). Change a metric only together with the oracle.
|
||||
- **Style oracle parity**: Block metrics (`paragraph_spec` with baselines and heading letter spacing, quote/code/divider/bookmark constants, margin collapsing, 24px child indent, the 944px container with 96px / 24px side padding) mirror BlockSuite's page CSS and are asserted against `blocksuite/crates/oracle/style-oracle.json` in both themes by `blocksuite/crates/playground` tests, on the constants (L1) and on rendered frames (L2). Change a metric only together with the oracle.
|
||||
- **Block semantics**: `prop:textAlign` (`left` / `center` / `right`) aligns paragraph and list text and is inherited by nested children that set none; a list prefix stays at the left edge. A collapsed heading hides its own children and the siblings under it up to the next heading of its level; a collapsed toggle hides its children.
|
||||
- **First-line prefixes**: List bullets, numbers, checkboxes and toggles are placed against the first line of the item's text, and a numbered prefix sits on that line's baseline. Single-style labels (title, code, captions, cards) use the plain `InlineLayout`.
|
||||
- **Snapshot ids**: `page.title_block`, `page.local_caret`, `page.selection`, `page.block.<blockId>`, `page.presence.<clientId>.caret|label`, `chrome.theme_toggle`, `chrome.presence.<clientId>`; block controls and overlays are listed under *Overlays and block controls*. A block, a control or a marker records its element snapshot only while it lies completely inside the page viewport; one cut by the fold is clipped on purpose.
|
||||
@@ -56,21 +42,14 @@ This document records the active engineering invariants enforced in CI today alo
|
||||
- **Sizes and radii**: Interactive targets are at least 24 × 24 px (toolbar buttons 28 × 28, edge to edge). Rows and buttons round concentrically with their container: 8 px menu with 4 px padding and 4 px rows (BlockSuite pads its menu `8px 4px 8px 8px`; 4 px all around keeps the radii concentric), 8 px toolbar with 4 px padding and 4 px buttons (`gap = 2px, pad = 4px`, intentionally compact relative to JS `8px / 0 6px` so the toolbar fits a 320 px window between its 8 px margins). The toolbar is 297 px wide, with 8 px on either side of the line between the mark and the alignment buttons.
|
||||
- **Verification**: `bs-harness render --state <name>` renders one overlay state of the showcase, `bs-harness audit-states` audits every state in both themes at `1280` and `320` px, and `bs-harness record-demo <dir>` writes the frames of a 60 fps walk through typing, composition, the slash menu, the toolbar and the block controls; all drive the view through input events, the input handler and `dispatch_overlay` only.
|
||||
|
||||
### Performance guardrail and theme/style oracle
|
||||
- **`perf/` (`schema.json`, `accepted.json`, `compare-n3.mjs`, `compare-n3.test.mjs`)**: Zero-dependency rolling `N-3` CI comparator with strict schema validation and rerun history anchoring (`--run-id` `created_at` cutoff + pagination). Deterministic byte sizes (`artifacts_bytes.*`) and work counters (non-`_ms` `benchmarks.*`) are hard-gated at strictly `> 10%` (`--fail-on-regression` exits `1`); shared-runner wall-clock timings (`benchmarks.*_ms` at `> 10%`, `ci_wall_ms.*` at `> 10%` and `> 15_000 ms`) are report-only `ADVISORY_SLOWDOWN`. Intentional increases are acknowledged via `{ metric, accepted_value, reason }` ceiling entries in `perf/accepted.json` (with report-only `stale_acceptances` once the rolling baseline catches up). Unmeasured sub-keys are omitted or `null` (never padded with synthetic `0`s) so newly introduced metrics transition through `BOOTSTRAP`.
|
||||
- **`tokens/` (`extract-tokens.mjs`, `tokens.rs`, `icons.rs`, `fonts.lock`, `extract-style-oracle.spec.ts`, `style-oracle.json`)**: `extract-tokens.mjs` deterministically generates Rust-`Ord`-sorted `tokens.rs`, `icons.rs` (preserving inherited `<svg fill>` and stroke attributes), and `fonts.lock` (SHA-256 font asset manifest + `CommunityCanvasTextFonts` descriptors), with `--check` and `rustc --edition 2024 --test` enforced on every push in CI. `style-oracle.json` is regenerated via Vitest Browser (`extract-style-oracle.spec.ts`, `isolate: false` reusable iframe) whenever BlockSuite styles or themes change (until its browser CI job lands).
|
||||
|
||||
### Rich paragraph layout
|
||||
- **Variable-font slant axis**: CoreText and Swash specialize an upright variable face at its minimum OpenType `slnt` coordinate for italic and oblique requests, alongside `wght`. A native static italic face retains its own outlines. Pixel letter spacing shifts shaped clusters and their total advance together.
|
||||
- **`RichParagraph`**: The single rich-text engine: `BlockFlow` lays out and paints paragraph and list text with it (`LaidOutRichParagraph::paint_at`, the same path `RichParagraphElement` uses), and reads remote carets and selections from its geometry. Cursor and selection geometry uses source UTF-16 positions and extended-grapheme boundaries. Each inline reference occupies one document unit regardless of its resolved label width, wraps as one inline object (the words before it stay on their line), and its prefix is the generated `LinkedPageIcon` SVG painted at the `DecorationKind::PageGlyph` bounds. `color` and `background` marks resolve through the theme (`DecorationKind::Highlight` behind the glyphs), and bold follows CSS `bolder`. Shaped lines supply wrapping, painting, hit targets, and both caret affinities at a soft wrap.
|
||||
- **Inline style parity**: Code boxes and links follow the light/dark theme tokens and browser measurements in `tokens/style-oracle.json`; the code box metrics are constants that a test keeps equal to the oracle, so the oracle JSON is never embedded in the shipped binary. Plain and rich renders of one document can be reproduced with `bs-harness render-rich-sample --out-plain plain.png --out-rich rich.png`.
|
||||
- **Inline style parity**: Code boxes and links follow the light/dark theme tokens and browser measurements in `blocksuite/crates/oracle/style-oracle.json`; the code box metrics are constants that a test keeps equal to the oracle, so the oracle JSON is never embedded in the shipped binary. Plain and rich renders of one document can be reproduced with `bs-harness render-rich-sample --out-plain plain.png --out-rich rich.png`.
|
||||
|
||||
### Edgeless rendering and GPU transforms
|
||||
- **End-to-end GPU transforms and local clip masks**: `Window::with_paint_transformation` composes 2D affine transforms (`TransformationMatrix`) on a stack and `Window::with_local_paint_mask` intersects pre-transform local clip rects (`ContentMask<Pixels>`). All GPU primitives (`Quad`, `Shadow`, `Underline`, `MonochromeSprite`, `SubpixelSprite`, `PolychromeSprite`, and `PathRasterizationVertex`) are 16-byte aligned (`size_of % 16 == 0`, verified by compile-time assertions) for WebGL2 `RGBA32U` instance-texture decoding. Both Metal (`shaders.metal`) and wgpu/WebGL2 (`shaders.wgsl`, `shaders_webgl.wgsl`, `shaders_subpixel.wgsl`) transform vertices on the GPU, reserve bit 31 of `quad_id` (`0x80000000u`) in `vs_quad` / `quad_vertex` for the solid-quad fast path, evaluate SDFs in local space scaled by `transform_scale` for 1-device-pixel anti-aliasing across zooms and rotations, and clip against both screen-space `content_mask` and pre-transform `local_content_mask`.
|
||||
- **Quarter-octave glyph zoom bucketing**: Under non-unit paint scales, `Window::paint_glyph` and `Window::paint_glyph_in_run` quantize rasterization scale to quarter-octave buckets (`2^(round(4*log2(s))/4)` clamped to `[0.25, 8.0]`), rasterizing atlas tiles at `font_size * bucket` while scaling local quad bounds by `1 / bucket` so cached `1.0x` `RichParagraph` / `BlockFlow` layouts render crisply at `0.1x..6.0x` without re-shaping or relayouting during pan/zoom.
|
||||
- **Procedural dot-grid (`BackgroundTag::DotGrid = 4`)**: Renders the Edgeless background grid in a single fullscreen `Quad` draw call with 1-device-pixel anti-aliased dots centered in each tile with screen offset `(0.5 * gap - pan * zoom).rem_euclid(gap)` per axis and spacing matching BlockSuite's `getBgGridGap(zoom)`.
|
||||
### Edgeless spatial canvas and interactive authoring
|
||||
- **Spatial camera & canvas (`edgeless/`)**: `edgeless/camera.rs` (`EdgelessCamera`) manages pan/zoom (`[0.1, 6.0]`), cursor-anchored wheel zoom, and fit-to-bounds (initialized before building `chrome.edgeless_zoom` so Frame 1 displays the fitted zoom percentage). `edgeless/scene.rs` and `edgeless/canvas_paint.rs` prepare and render Surface-parented Frames and EdgelessText and root-parented Notes in a single snapshot pass. Note dimensions are world units. Layout uses the logical width divided by scale. Collapsed notes clip to the stored world height, which already includes scale. The canvas merges the block and vector paint streams by fractional index and Frame/Group ancestry (`prop:childElementIds` treats every present key as a frame member, and equal indices preserve source enumeration order within each stream — live incremental sync and independent multi-author merged updates follow `(Reverse(client), clock)` integration order, whereas a late-join single V1 snapshot with cross-client causal edits among equal-index overlapping elements can invert their tie-break paint/pick order until `y-octo` exposes per-map integration order). Equal indices continue the active stream, with blocks first at the start. Notes reuse their cached `BlockFlow::layout_nodes` during pan/zoom. All items paint under `edgeless.viewport`, with bottom-centered creation toolbar (`chrome.edgeless_toolbar`) and bottom-right screen-space zoom controls (`chrome.edgeless_zoom`, stacked cleanly above `chrome.edgeless_toolbar` on narrow viewports `< 660 px`). `bs-harness render --mode edgeless [--zoom <f32>] [--pan <x>,<y>]` renders spatial states, `bs-harness audit-states` audits Edgeless default + `0.5x` + `2.0x` + authoring states (`edgeless_selected`, `edgeless_marquee`, `edgeless_inline_edit`, `edgeless_authoring`) in Light/Dark at `1280` and `320` px, and `bs-harness bench` measures `edgeless_1k_pan_zoom_frame_ms` and asserts `edgeless_1k_pan_zoom_blocks_relayout == 0`.
|
||||
- **Edgeless interactive authoring & inline IME editing (`edgeless/{toolbar,hit_test,overlay,label_editor,inline_edit,gestures,commit,commands}.rs`)**: `chrome.edgeless_toolbar` provides Select (`V`/`Escape`), Hand (`H` or holding `Space`), Note (`N`), Shape (`S` with rect/ellipse/diamond/triangle picker), Connector (`C` with cardinal port snapping and live orthogonal connector preview), Brush (`P`), Highlighter, Text (`T`), and Frame (`F`, populating `prop:childElementIds`). World-space hit-testing walks exact reverse paint order (inverse-rotated OBBs for shapes/texts, routed polyline distance from `SurfaceLayout` for connectors/strokes, exact `layout_inline` title pill and border for frames). Selection renders a screen-crisp `edgeless.selection_box`, 8 resize handles (`edgeless.handle.nw..w`), top rotation handle (`edgeless.handle.rotate`, `15°` snap with `Shift`), and `2×3` 6-dot `14px` Edgeless `gfx` drag handle (`edgeless.drag_handle`) on selected blocks; resize and rotation handles are suppressed while inline label editing is active, and the underlying static label is hidden until commit. Dragging, resizing, rotating, deleting (`Backspace`/`Delete`), and z-reordering (`[`/`]` via `fractional-indexing@3.2.0` keys in `crates/doc/src/fractional_index.rs`) commit single atomic undo steps on `PageDocSession` and broadcast over `RoomProtocol`. Double-clicking a Note or EdgelessText edits rich text inline via `EditorSession` + `EntityInputHandler` with camera-mapped `bounds_for_range`; double-clicking a Shape, Connector, SurfaceText, or Frame title edits its `Y.Text` inline (`edgeless.inline_edit`) with full UTF-16 + IME preedit support.
|
||||
- **Edgeless interactive authoring & inline IME editing (`edgeless/{toolbar,hit_test,overlay,label_editor,inline_edit,gestures,commit,commands}.rs`)**: `chrome.edgeless_toolbar` provides Select (`V`/`Escape`), Hand (`H` or holding `Space`), Note (`N`), Shape (`S` with rect/ellipse/diamond/triangle picker), Connector (`C` with cardinal port snapping and live orthogonal connector preview), Brush (`P`), Highlighter, Text (`T`), and Frame (`F`, populating `prop:childElementIds`). World-space hit-testing walks exact reverse paint order (inverse-rotated OBBs for shapes/texts, routed polyline distance from `SurfaceLayout` for connectors/strokes, exact `layout_inline` title pill and border for frames). Selection renders a screen-crisp `edgeless.selection_box`, 8 resize handles (`edgeless.handle.nw..w`), top rotation handle (`edgeless.handle.rotate`, `15°` snap with `Shift`), and `2×3` 6-dot `14px` Edgeless `gfx` drag handle (`edgeless.drag_handle`) on selected blocks; resize and rotation handles are suppressed while inline label editing is active, and the underlying static label is hidden until commit. Dragging, resizing, rotating, deleting (`Backspace`/`Delete`), and z-reordering (`[`/`]` via `fractional-indexing@3.2.0` keys in `blocksuite/blocksuite/crates/doc/src/fractional_index.rs`) commit single atomic undo steps on `PageDocSession` and broadcast over `RoomProtocol`. Double-clicking a Note or EdgelessText edits rich text inline via `EditorSession` + `EntityInputHandler` with camera-mapped `bounds_for_range`; double-clicking a Shape, Connector, SurfaceText, or Frame title edits its `Y.Text` inline (`edgeless.inline_edit`) with full UTF-16 + IME preedit support.
|
||||
|
||||
### Surface reading and painting
|
||||
|
||||
@@ -78,43 +57,15 @@ This document records the active engineering invariants enforced in CI today alo
|
||||
- `surface::layout_surface` accepts element snapshots and world bounds for external blocks. It finds ports on rotated shape outlines and routes orthogonal connectors using their two endpoint bounds. The router follows BlockSuite's `ConnectorPathGenerator`. A connector's `rough` flag enables jitter and `roughness` sets its amplitude. Scribbled shapes follow RoughJS hachure, `pointsOnPath` sampling and seeded operation order. Brush and highlighter share the perfect-freehand pressure outline and midpoint quadratic curves. EdgelessCanvas caches geometry by document revision, theme and environment revision. Fully visible elements emit `edgeless.surface.<id>` in screen coordinates. The standalone harness uses the same painter.
|
||||
- The canvas clips its viewport in screen coordinates. Within the camera transform, each rotated shape or text pushes its own center rotation before its label mask. The GPU inverse-maps coverage into the label's local coordinates while retaining the screen-space viewport clip.
|
||||
|
||||
- The JS surface oracle runs the BlockSuite shape, connector and freehand implementations and compares their coordinates to `tokens/surface-oracle.json`. Rust tests consume the same geometry and font baselines.
|
||||
- The JS surface oracle runs the BlockSuite shape, connector and freehand implementations and compares their coordinates to `blocksuite/crates/oracle/surface-oracle.json`. Rust tests consume the same geometry and font baselines.
|
||||
- With repository JavaScript dependencies installed, `cargo test --locked -p blocksuite-playground-doc --example bs_doc_driver js_authored_surface` verifies data and rich-text marks written by Yjs against the typed Rust snapshot and compares the encoded document before and after reading.
|
||||
|
||||
### Rust Module Organization & Fast Verification
|
||||
- **Proactive modularization**: Split files by responsibility (targeting ~500–800 production lines; promote `<name>.rs` to `<name>/mod.rs` when introducing submodules). Keep each `mod.rs` as the dependency and visibility hub (`pub(super) use ...`), import siblings via `use super::...`, and hoist cross-layer shared items to the narrowest common ancestor `mod.rs`.
|
||||
- **Global optimum & clean boundaries**: Prefer structural cleanup and bold deletion over band-aid patches. Delete obsolete code outright, fold single-caller one-way fragments back into their caller, and extract shared helpers only for stable domain concepts, genuine multi-site reuse, or key invariants — never for one-line expressions.
|
||||
- **Focused, table-driven tests**: Keep test-only imports and helpers inside `#[cfg(test)] mod tests`, placing unit tests in the file under test and cross-submodule tests in the lowest common `mod.rs`. Keep every test file and function name aligned with its actual assertion scope, and group similar scenarios into table-driven loops rather than proliferating near-identical `#[test]` functions.
|
||||
- **Sub-60-second verification loop**: Validate uncertain paths with minimal focused spikes first and remove scaffolding before landing. Keep routine edit-verify turns under **60 seconds** using targeted `cargo check --locked -p ...` / `cargo test --locked -p ... --lib <filter>` and `./scripts/check-invariants.sh` (which enforces `super::super` bans, `mod.rs` layout, orphan-file detection, and per-file LOC limits automatically alongside `rustfmt.toml`).
|
||||
- **Sub-60-second verification loop**: Validate uncertain paths with minimal focused spikes first and remove scaffolding before landing. Keep routine edit-verify turns under **60 seconds** using targeted `cargo check --locked -p ...` / `cargo test --locked -p ... --lib <filter>` and `./packages/frontend/scripts/check-invariants.sh` (which enforces `super::super` bans, `mod.rs` layout, orphan-file detection, and per-file LOC limits automatically alongside `rustfmt.toml`).
|
||||
|
||||
## Planned Contracts (upcoming crates & features)
|
||||
|
||||
- **Whiteboard surface elements**: Mindmap tree layout and editing on the Edgeless spatial canvas.
|
||||
|
||||
## Build & verification commands
|
||||
|
||||
Always clear inherited root rustflags:
|
||||
|
||||
```sh
|
||||
CARGO_ENCODED_RUSTFLAGS="" cargo fmt --all -- --check
|
||||
CARGO_ENCODED_RUSTFLAGS="" cargo clippy --locked --workspace --all-targets --features harness -- -D warnings
|
||||
CARGO_ENCODED_RUSTFLAGS="" cargo check --locked -p ui -p playground --target wasm32-unknown-unknown
|
||||
CARGO_ENCODED_RUSTFLAGS="" cargo check --locked -p blocksuite-playground-doc --no-default-features --target wasm32-unknown-unknown
|
||||
CARGO_ENCODED_RUSTFLAGS="" cargo test --locked --workspace
|
||||
CARGO_ENCODED_RUSTFLAGS="" cargo test --locked --workspace --features harness
|
||||
CARGO_ENCODED_RUSTFLAGS="" cargo run --locked --bin bs-harness --features harness -- render --theme dark --mode page --out frame.png --snapshot frame.json
|
||||
CARGO_ENCODED_RUSTFLAGS="" cargo run --locked --bin bs-harness --features harness -- probes
|
||||
CARGO_ENCODED_RUSTFLAGS="" cargo run --locked --bin bs-harness --features harness -- bench --json perf-metrics.json
|
||||
CARGO_ENCODED_RUSTFLAGS="" cargo run --locked --bin bs-harness --features harness -- render-surface-sample --theme light --out surface-light.png --snapshot surface-light.json
|
||||
CARGO_ENCODED_RUSTFLAGS="" cargo run --locked --bin bs-harness --features harness -- render-editor artifacts/editor
|
||||
CARGO_ENCODED_RUSTFLAGS="" cargo run --locked --bin bs-harness --features harness -- render --state slash_menu_open --out slash.png --snapshot slash.json
|
||||
CARGO_ENCODED_RUSTFLAGS="" cargo run --locked --bin bs-harness --features harness -- audit-states
|
||||
CARGO_ENCODED_RUSTFLAGS="" cargo run --locked --bin bs-harness --features harness -- fps-check
|
||||
CARGO_ENCODED_RUSTFLAGS="" cargo run --locked --bin bs-harness --features harness -- record-demo artifacts/demo
|
||||
./scripts/check-invariants.sh
|
||||
node --test perf/compare-n3.test.mjs
|
||||
node tokens/extract-tokens.mjs --check
|
||||
rustc --edition 2024 --test -D warnings tokens/tokens.rs -o /tmp/tokens_test && /tmp/tokens_test
|
||||
rustc --edition 2024 --test -D warnings tokens/icons.rs -o /tmp/icons_test && /tmp/icons_test
|
||||
rm -f /tmp/tokens_test /tmp/icons_test
|
||||
```
|
||||
File renamed without changes.
@@ -1,5 +1,6 @@
|
||||
[package]
|
||||
name = "blocksuite-playground-doc"
|
||||
workspace = "../../../packages/frontend"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
publish.workspace = true
|
||||
+1
-1
@@ -1396,7 +1396,7 @@ mod surface_roundtrip {
|
||||
});
|
||||
process.stdout.write(JSON.stringify(Array.from(Y.encodeStateAsUpdate(doc))));
|
||||
"#;
|
||||
let project = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../../..");
|
||||
let project = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../..");
|
||||
let mut child = Command::new("node")
|
||||
.current_dir(project)
|
||||
.args(["--input-type=module", "-e", script])
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+3
-3
@@ -1,9 +1,9 @@
|
||||
import fs from 'node:fs';
|
||||
|
||||
const root = new URL('../', import.meta.url);
|
||||
const root = new URL('./', import.meta.url);
|
||||
const fonts = [
|
||||
['IBM Plex Mono', '../../packages/frontend/component/src/fonts/ibm-plex-mono/IBMPlexMono-Regular.ttf'],
|
||||
['Surface Metrics Test', 'tokens/surface-metrics-test.ttf'],
|
||||
['IBM Plex Mono', '../../../packages/frontend/component/src/fonts/ibm-plex-mono/IBMPlexMono-Regular.ttf'],
|
||||
['Surface Metrics Test', './surface-metrics-test.ttf'],
|
||||
];
|
||||
|
||||
// Measure the same inline span and containing line box as the surface text renderer.
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -79,7 +79,7 @@ export default defineConfig({
|
||||
},
|
||||
plugins: [tc39DecoratorsPlugin(), vanillaExtractPlugin()],
|
||||
test: {
|
||||
include: ['../native-playground/tokens/extract-style-oracle.spec.ts'],
|
||||
include: ['../crates/oracle/extract-style-oracle.spec.ts'],
|
||||
fileParallelism: false,
|
||||
testTimeout: 60_000,
|
||||
browser: {
|
||||
+3
-2
@@ -1,5 +1,6 @@
|
||||
[package]
|
||||
name = "playground"
|
||||
workspace = "../../../packages/frontend"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
publish.workspace = true
|
||||
@@ -31,7 +32,7 @@ blocksuite-playground-doc = { path = "../doc", default-features = false }
|
||||
image.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
ui = { path = "../ui" }
|
||||
ui = { path = "../../../packages/ui/ui" }
|
||||
unicode-bidi.workspace = true
|
||||
unicode-linebreak = "0.1"
|
||||
unicode-segmentation.workspace = true
|
||||
@@ -39,7 +40,7 @@ y-octo = { version = "0.4.0", default-features = false, features = ["session"] }
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3"
|
||||
ui = { path = "../ui", features = ["harness"] }
|
||||
ui = { path = "../../../packages/ui/ui", features = ["harness"] }
|
||||
|
||||
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||
futures-util = { version = "0.3", default-features = false, features = ["sink", "std"] }
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-2
@@ -781,7 +781,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn oracle() -> serde_json::Value {
|
||||
serde_json::from_str(include_str!("../../../tokens/style-oracle.json"))
|
||||
serde_json::from_str(include_str!("../../oracle/style-oracle.json"))
|
||||
.expect("style oracle is valid JSON")
|
||||
}
|
||||
|
||||
@@ -3194,7 +3194,7 @@ mod tests {
|
||||
#[test]
|
||||
fn yjs_bring_to_front_repaints_the_shape_over_the_note() {
|
||||
let oracle: serde_json::Value =
|
||||
serde_json::from_str(include_str!("../../../tokens/surface-oracle.json")).unwrap();
|
||||
serde_json::from_str(include_str!("../../oracle/surface-oracle.json")).unwrap();
|
||||
let update =
|
||||
|name: &str| serde_json::from_value::<Vec<u8>>(oracle["layers"][name].clone()).unwrap();
|
||||
let mut doc = DocState::new("order", 71).unwrap();
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -704,7 +704,7 @@ mod tests {
|
||||
#[test]
|
||||
fn rich_paragraph_layout_geometry_marks_alignment_and_bidi_invariants() {
|
||||
let oracle: serde_json::Value =
|
||||
serde_json::from_str(include_str!("../../../../tokens/style-oracle.json")).unwrap();
|
||||
serde_json::from_str(include_str!("../../../oracle/style-oracle.json")).unwrap();
|
||||
let platform = HeadlessPlatform::new(128, 64, 1.);
|
||||
let app = Application::with_platform(platform)
|
||||
.run_embedded(|cx| crate::register_bundled_fonts(cx).unwrap());
|
||||
+1
-1
@@ -481,7 +481,7 @@ mod tests {
|
||||
#[test]
|
||||
fn code_box_constants_match_the_browser_oracle() {
|
||||
let oracle: serde_json::Value =
|
||||
serde_json::from_str(include_str!("../../../../tokens/style-oracle.json")).unwrap();
|
||||
serde_json::from_str(include_str!("../../../oracle/style-oracle.json")).unwrap();
|
||||
for (mode, name) in [(ThemeMode::Light, "light"), (ThemeMode::Dark, "dark")] {
|
||||
let node = &oracle["themes"][name]["inline_formats"]["inline_code"];
|
||||
let css = |property: &str| -> f32 {
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -2,7 +2,7 @@ use super::*;
|
||||
use blocksuite_playground_doc::read::{RichText, SurfaceElement, SurfaceElementKind};
|
||||
use serde_json::{Value, json};
|
||||
fn oracle() -> Value {
|
||||
serde_json::from_str(include_str!("../../../../tokens/surface-oracle.json")).unwrap()
|
||||
serde_json::from_str(include_str!("../../../oracle/surface-oracle.json")).unwrap()
|
||||
}
|
||||
fn val(p: P) -> Value {
|
||||
json!([p.0, p.1])
|
||||
File renamed without changes.
+2
-3
@@ -731,14 +731,13 @@ mod tests {
|
||||
#[test]
|
||||
fn centered_shape_baselines_match_chromium_in_tall_and_short_shapes() {
|
||||
let cases: Vec<serde_json::Value> =
|
||||
serde_json::from_str(include_str!("../../../../tokens/surface-baselines.json"))
|
||||
.unwrap();
|
||||
serde_json::from_str(include_str!("../../../oracle/surface-baselines.json")).unwrap();
|
||||
let platform = HeadlessPlatform::new(64, 64, 1.);
|
||||
let app = Application::with_platform(platform).run_embedded(|cx| {
|
||||
crate::register_bundled_fonts(cx).unwrap();
|
||||
cx.text_system()
|
||||
.add_fonts(vec![std::borrow::Cow::Borrowed(include_bytes!(
|
||||
"../../../../tokens/surface-metrics-test.ttf"
|
||||
"../../../oracle/surface-metrics-test.ttf"
|
||||
))])
|
||||
.unwrap();
|
||||
});
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+10
-10
@@ -1,8 +1,8 @@
|
||||
//! Theme tokens, icons and bundled fonts for the playground.
|
||||
//!
|
||||
//! Colors, typography and icons come straight from the generated `tokens/tokens.rs` and
|
||||
//! `tokens/icons.rs` files, so a regenerated token set reaches every render target without
|
||||
//! touching this crate. They are pulled in with `include!` rather than `#[path]` modules
|
||||
//! Colors, typography and icons come straight from the generated `packages/ui/tokens/tokens.rs`
|
||||
//! and `packages/ui/tokens/icons.rs` files, so a regenerated token set reaches every render target
|
||||
//! without touching this crate. They are pulled in with `include!` rather than `#[path]` modules
|
||||
//! so `rustfmt` never rewrites the generated sources.
|
||||
|
||||
use std::{
|
||||
@@ -17,12 +17,12 @@ use ui::{
|
||||
|
||||
#[allow(dead_code, clippy::all)]
|
||||
pub mod tokens {
|
||||
include!("../../../tokens/tokens.rs");
|
||||
include!("../../../../packages/ui/tokens/tokens.rs");
|
||||
}
|
||||
|
||||
#[allow(dead_code, clippy::all)]
|
||||
pub mod icons {
|
||||
include!("../../../tokens/icons.rs");
|
||||
include!("../../../../packages/ui/tokens/icons.rs");
|
||||
}
|
||||
|
||||
pub use icons::{IconDef, icon_by_name};
|
||||
@@ -34,19 +34,19 @@ pub const FONT_SANS: &str = "Inter";
|
||||
pub const FONT_CODE: &str = "IBM Plex Mono";
|
||||
|
||||
const INTER_VARIABLE_TTF: &[u8] = include_bytes!(
|
||||
"../../../../../packages/frontend/component/src/fonts/inter/Inter-VariableFont_slnt,wght.ttf"
|
||||
"../../../../packages/frontend/component/src/fonts/inter/Inter-VariableFont_slnt,wght.ttf"
|
||||
);
|
||||
const IBM_PLEX_MONO_REGULAR_TTF: &[u8] = include_bytes!(
|
||||
"../../../../../packages/frontend/component/src/fonts/ibm-plex-mono/IBMPlexMono-Regular.ttf"
|
||||
"../../../../packages/frontend/component/src/fonts/ibm-plex-mono/IBMPlexMono-Regular.ttf"
|
||||
);
|
||||
const IBM_PLEX_MONO_BOLD_TTF: &[u8] = include_bytes!(
|
||||
"../../../../../packages/frontend/component/src/fonts/ibm-plex-mono/IBMPlexMono-Bold.ttf"
|
||||
"../../../../packages/frontend/component/src/fonts/ibm-plex-mono/IBMPlexMono-Bold.ttf"
|
||||
);
|
||||
const IBM_PLEX_MONO_ITALIC_TTF: &[u8] = include_bytes!(
|
||||
"../../../../../packages/frontend/component/src/fonts/ibm-plex-mono/IBMPlexMono-Italic.ttf"
|
||||
"../../../../packages/frontend/component/src/fonts/ibm-plex-mono/IBMPlexMono-Italic.ttf"
|
||||
);
|
||||
const IBM_PLEX_MONO_BOLD_ITALIC_TTF: &[u8] = include_bytes!(
|
||||
"../../../../../packages/frontend/component/src/fonts/ibm-plex-mono/IBMPlexMono-BoldItalic.ttf"
|
||||
"../../../../packages/frontend/component/src/fonts/ibm-plex-mono/IBMPlexMono-BoldItalic.ttf"
|
||||
);
|
||||
|
||||
/// Registers the tracked repository fonts (`Inter` and `IBM Plex Mono`) into the active
|
||||
Loaded 100 of 318 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user