@loop-kit/graphite-react
v0.1.0
Published
React bindings for Graphite runtime scopes, queries, and interaction input.
Readme
@loop-kit/graphite-react
React projection layer for Graphite runtime scopes, queries, state slices, and recognizers.
Concepts
GraphiteProvider: injects runtime + scope context.useQuery: subscribes toQueryEngineand reruns only on touched deps.useStateSlice: reads validator-derivedStateViewslices.useDispatch: dispatches actions, commits intent patches, and manages overlay patches.useRecognizer+InputBoundary: modular high-frequency gesture routing intoInteractionRuntime.
How To Use
import { GraphiteRuntime, asScopeId } from '@loop-kit/graphite-core';
import { GraphiteProvider, InputBoundary, useStateSlice } from '@loop-kit/graphite-react';
const runtime = new GraphiteRuntime();
const scopeId = asScopeId('main');
function View() {
const dock = useStateSlice('dock');
return <pre>{JSON.stringify(dock, null, 2)}</pre>;
}
export function App() {
return (
<GraphiteProvider runtime={runtime} scopeId={scopeId}>
<InputBoundary>
<View />
</InputBoundary>
</GraphiteProvider>
);
}How Dock Demonstrates It
@loop-kit/dock uses these bindings directly:
DockViewrenders fromuseStateSlice(DOCK_FACET).InputBoundarystreams pointer/key events to drag recognizers.useRecognizer(createDragTabRecognizer())registers docking interaction logic.
Add A New Facet/System
- Register your validator on the runtime.
- Read the facet with
useStateSlice('facet.name')oruseQuery(...). - Wire interaction commands through
useDispatch. - Keep durable changes in commits; keep transient previews in overlay patches.
Commands
moon run graphite-react:typecheckmoon run graphite-react:build
