尚未收集仓库信息。
尚未检测到更新。GitHub 发布版本后会显示在这里。
Infinite WebGL canvas of image, video and embed cards (Pixi v8): culling, LOD textures, auto layout, grid and snapping
翻译准备中
取自仓库 README
正在加载完整 README。
查看完整 README ↗An infinite WebGL canvas of image, video and embed cards, built on Pixi v8. Framework-agnostic TypeScript, made for boards of thousands of cards on an ordinary laptop.
getSnapshot() / loadSnapshot(), net-diff change events with a draw order, applyChange / invertChange for undo, redo and sync, a typed error event, Corkboard.isSupported().Live demo: corkboard.niccolofanton.dev
npm i @niccolofanton/corkboard pixi.js
pixi.js ^8.22.0 is a peer dependency. ESM only, types included. Needs WebGL2.
import { Corkboard } from '@niccolofanton/corkboard';
async function main(): Promise<void> {
const board = await Corkboard.create(document.getElementById('board')!, { theme: 'dark' });
board.add([
{ media: { src: 'https://picsum.photos/seed/1/480/600', aspect: 1.25 } },
{ media: { src: 'https://picsum.photos/seed/2/480/270', video: 'https://example.com/clip.mp4' } },
{ media: { embed: { url: 'https://youtu.be/dQw4w9WgXcQ' } } },
{ media: { embed: { html: '<button onclick="this.textContent++">0</button>' } } },
]);
board.layout.tidy();
board.camera.fit();
board.on('selection', ({ ids }) => console.log(ids));
}
void main();
Corkboard.create is async; a top-level await also works if your build target allows it (Vite: build.target: 'es2022').embeds.resolve (see the API reference).useEffect(() => {
const ctl = new AbortController(); // cancels a create() that StrictMode unmounts mid-flight
let board: Corkboard | undefined;
Corkboard.create(ref.current!, { signal: ctl.signal })
.then((b) => (board = b))
.catch((e) => { if (!ctl.signal.aborted) console.error(e); });
return () => { ctl.abort(); board?.dispose(); };
}, []);
worker-src blob:, or serve the bundled worker and pass textures.workerUrl (below).unsafe-eval: cspSafe: true. Nonce-based style-src: nonce.img-src data: blob: for snapshots and previews. HTML snippets (srcdoc) inherit the page's CSP.import workerUrl from '@niccolofanton/corkboard/decode.worker.js?url'; // Vite; any bundler that gives you a file URL
await Corkboard.create(el, { textures: { workerUrl }, cspSafe: true, nonce });
@niccolofanton/corkboard/unstable: the building blocks (stage, store, layout and snapping functions, getInternals), no semver guarantee.pnpm install
pnpm dev # demo
pnpm test
pnpm build # dist/: library, bundled types, decode worker
MIT