インストール
plasma は 5 つのパッケージとして提供されます。ほとんどのアプリはこれらすべてを利用しますが、不要なものは省略できます(例えば store を Solid や vanilla JS から利用する場合は @sh1n4ps/plasma-react を省略できます)。
- Node.js 20+ — ビルドツール群
- TypeScript 5.7+ — plasma の phantom types は最新の型推論を必要とします
- Cloudflare Workers プロジェクト(server 側で使用します。ローカル開発は Miniflare 上で動作します)
パッケージの追加
Section titled “パッケージの追加”pnpm add @sh1n4ps/plasma-core @sh1n4ps/plasma-client @sh1n4ps/plasma-server @sh1n4ps/plasma-reactnpm install @sh1n4ps/plasma-core @sh1n4ps/plasma-client @sh1n4ps/plasma-server @sh1n4ps/plasma-reactyarn add @sh1n4ps/plasma-core @sh1n4ps/plasma-client @sh1n4ps/plasma-server @sh1n4ps/plasma-reactbun add @sh1n4ps/plasma-core @sh1n4ps/plasma-client @sh1n4ps/plasma-server @sh1n4ps/plasma-reactオプションのパッケージ
Section titled “オプションのパッケージ”| パッケージ | 追加するとき |
|---|---|
@sh1n4ps/plasma-devtools |
ページ内 inspector や Chrome DevTools の postMessage bridge が欲しいとき |
@sh1n4ps/plasma-client-sqlite |
client 側でデフォルトの IndexedDB engine の代わりに sql.js / OPFS SQLite engine を使いたいとき |
pnpm add @sh1n4ps/plasma-devtools @sh1n4ps/plasma-client-sqlite各パッケージの役割
Section titled “各パッケージの役割”@sh1n4ps/plasma-core— 純粋な型 + schema DSL + query AST + wire protocol。標準ライブラリ以外に runtime 依存を一切持ちません。あなたのschema.tsファイルが import するのはこれです。@sh1n4ps/plasma-client— IndexedDB engine、IVM による live query、optimistic な mutate + push/pull + rebase、WebSocket subscription ヘルパー、file blob アップロード worker。@sh1n4ps/plasma-server— SQL コンパイラ(SQLite / Postgres dialect)、sync ハンドラ、executor アダプタ(fromBetterSqlite3/fromD1)、SyncCoordinatorDurable Object、R2Storageアダプタ、blob エンドポイント、GC ヘルパー、SequencerDO。@sh1n4ps/plasma-react—PlasmaProvider、useLiveQuery、useMutation、usePlasmaFile。フレームワーク固有の hook はここに含まれ、それ以外はフレームワーク非依存です。@sh1n4ps/plasma-devtools— ページ内 React パネル、Chrome DevTools 拡張向けのpostMessagebridge、plasma の内部 store を読み取る reflection hook。
pnpm ls @sh1n4ps/plasma-core @sh1n4ps/plasma-client @sh1n4ps/plasma-server @sh1n4ps/plasma-react4 つすべてが、インストールしたバージョンで表示されるはずです。