GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - brrock/weave: Clean-room React node editor (n8n/React Flow-style), shipped as a shadcn registry

BranchesTags
Open more actions menu

Latest commit

 

History

14 Commits
14 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
e2e
e2e
 
 
public
public
 
 
scripts
scripts
 
 
src
src
 
 
.gitignore
.gitignore
 
 
.oxfmtrc.json
.oxfmtrc.json
 
 
README.md
README.md
 
 
bun.lock
bun.lock
 
 
components.json
components.json
 
 
index.html
index.html
 
 
package.json
package.json
 
 
registry.json
registry.json
 
 
tsconfig.json
tsconfig.json
 
 
vite.config.ts
vite.config.ts
 
 

Repository files navigation

Weave

A clean-room node editor for React (n8n/React Flow-style), built on shadcn/ui and distributed as a shadcn registry: you install the source into your project, the same way you install shadcn components.

Install

npx shadcn@latest add https://raw.githubusercontent.com/brrock/weave/registry/stable/weave.json       # the canvas library
npx shadcn@latest add https://raw.githubusercontent.com/brrock/weave/registry/stable/weave-demo.json  # optional: n8n-style workflow editor block

Channels

Swap stable in the URL for the channel you want:

Channel URL segment Updated
Stable stable each published GitHub release
Nightly nightly every commit to main
Pinned a release tag, e.g. v0.1.0 never (frozen at that release)

A channel's items only depend on that same channel, so weave-demo from nightly pulls nightly weave. Each item's meta records the version and commit it was built from. Allow about 5 minutes after a publish for GitHub's raw-file cache to refresh.

This installs components/weave/*, the button/tooltip components it needs, and Weave's CSS: the port styles and the weave-flow utility (the flowing-edge beads).

import { Controls, MiniMap, Weave, createFlow, edge, Handle, type NodeProps } from "@/components/weave"

function Step({ data, selected }: NodeProps<{ label: string }>) {
  return (
    <div className={selected ? "rounded-lg border bg-card p-3 ring-2 ring-ring" : "rounded-lg border bg-card p-3"}>
      {data.label}
      <Handle id="in" type="target" />
      <Handle id="out" type="source" />
    </div>
  )
}

const flow = createFlow(
  [{ id: "a", type: "step", position: { x: 0, y: 0 }, data: { label: "A" } },
   { id: "b", type: "step", position: { x: 300, y: 0 }, data: { label: "B" } }],
  [edge("a", "out", "b", "in")],
)

<Weave flow={flow} nodeTypes={{ step: Step }} className="h-dvh">
  <Controls />
  <MiniMap nodeColor={(n) => "--color-violet-500"} /> {/* any CSS colour or custom property */}
</Weave>

flow is the whole API: add, remove, connect, updateNode(Data), updateEdge, select, fitView, zoomAt, layout, group/ungroup, copy/paste/duplicate, undo/redo, and subscribe/get for persistence. Use useStore(flow, selector) outside the canvas and useFlowState(selector) inside nodes.

Sticky notes

type: "note" is built in (your nodeTypes can override it by name). Its data.text renders as light markdown: #–### headings, -/* lists, **bold**, *italic*, `code` and [links](https://…) (web links only). Double-click to edit; Esc, ⌘/Ctrl+Enter or clicking away saves (one undo step). Select a note to resize it from its corner; the size is stored on node.size. Notes and groups draw behind edges and other nodes, and box selection only picks them when fully enclosed.

flow.add([
  {
    id: "n1",
    type: "note",
    position: { x: 0, y: -200 },
    data: { text: "## Inbox\n- **triage** first" },
    size: { w: 280, h: 140 },
  },
]);

The fill is --weave-note (a warm tint of --card). To make your own nodes resizable, put <NodeResizer /> in them and size the body from the size prop. Wrappers carry data-node-id, data-type and data-selected for CSS.

Groups

type: "group" is built in: a titled frame around nodes whose parent is the group's id. Drag the title bar to move the group with everything in it; the frame's body lets clicks through to the canvas, so you can still pan and box-select inside it. The chevron collapses it to its title bar (data.collapsed): the contents hide, edges between them hide, and edges to the outside attach to the group's sides. Double-click the title to rename it, select it to resize it. Dropping a node onto an open group puts it in; dragging it out takes it out. Deleting or copying a group includes its contents.

API Does
flow.group(ids?, title?) frames the nodes (default: the selection) in a new group, returns its id; also ⌘/Ctrl+G
flow.ungroup(id) removes the frame and keeps its contents; also ⇧⌘/Ctrl+G on selected groups
flow.regroup(ids) puts each node into the innermost open group under its centre (what a drop does)
isHidden(state, id) whether a node is inside a collapsed group
shownAs(state, id) the node an edge to id is drawn to: id, or its outermost collapsed group
flow.add([
  { id: "g", type: "group", position: { x: -40, y: 260 }, size: { w: 1060, h: 180 }, data: { title: "Nightly digest" } },
  { id: "cron", type: "step", position: { x: 0, y: 320 }, data: { … }, parent: "g" },
])

Auto-layout

flow.layout() arranges the graph left to right in layers along its edges, so imported or agent-built workflows come out tidy. Each node sits right of everything that feeds it and level with the ports it hangs off, so a branch's outputs keep their top-to-bottom order. Cycles are broken at the edge that closes them, and the first source node stays where it was so the graph doesn't jump. Notes stay put, and open groups refit around their contents. Nodes glide into place (graphs over 250 nodes jump straight there). The whole layout is one undo step, and the returned promise resolves when it's done.

await flow.layout(); // { animate = true, gap = { x: 100, y: 40 } }
flow.fitView();

Undo and redo

Every document change made through flow (add, remove, connect, moveNodes, updateNode(Data), updateEdge, setEdges, and the clipboard, group and layout helpers below) is recorded; selection, viewport and flow.set are not. ⌘/Ctrl+Z undoes and ⇧⌘/Ctrl+Z redoes while the canvas has focus, and a node drag is a single step.

API Does
flow.undo() / flow.redo() step back / forward (the last 100 steps are kept)
flow.canUndo / flow.canRedo whether there is a step; read with useStore(flow, () => flow.canUndo)
flow.batch(fn) runs fn as one step, e.g. a node insert that also rewires edges
flow.begin() opens a batch and returns end(), for steps that span events (custom drags)
flow.untracked(fn) runs fn without recording it, for transient state such as run status
flow.batch(() => {
  flow.add([node]);
  flow.connect(from, to);
});
flow.untracked(() => flow.updateNodeData(id, { status: "running" }));

Copy and paste

With the canvas focused, ⌘/Ctrl+C copies the selected nodes and the edges between them to the clipboard as JSON text ({ "nodes": [...], "edges": [...] }), ⌘/Ctrl+X cuts, ⌘/Ctrl+V pastes with fresh ids at the pointer, and ⌘/Ctrl+D duplicates in place. Pasted text is validated, so JSON from another app or an agent works if it has that shape. They use the browser's clipboard events, so there are no permission prompts.

API Does
flow.copy(ids?) the nodes (default: the selection) and the edges between them, as a Clip
flow.paste(clip, at?) adds the clip with new ids, its top-left at at (default: just below-right of the original), selects it, returns the new ids; one undo step
flow.duplicate() paste(copy())
parseClip(text) validates untrusted JSON into a Clip, or null

Edges

An edge is plain data; these optional fields control how it looks:

Field Does
animated draws beads flowing source → target over a faint track (a solid line under prefers-reduced-motion)
kind app-defined category, rendered as data-kind on the edge's <g> so CSS can target it
className classes for the edge's <g>; SVG stroke properties and --weave-edge* variables set here reach its paths
data anything your app needs; Weave never reads it
label shown on the edge in canvas space, so it pans and zooms with it: a string or any React node
labelAt where the label sits along the edge, 0 (source) to 1 (target); default 0.5
// A dotted "tool" connection, a little heavier than the rest.
{ ...edge("search", "out", "agent", "tools"), kind: "tool", className: "[stroke-dasharray:0.01_6] [stroke-linecap:round] [--weave-edge-width:2.5px]" }
flow.updateEdge(id, { animated: true, label: "stream · 14 values" }) // data is flowing

Each edge renders as <g data-edge-id data-kind data-selected data-animated> around its visible path(s), so plain CSS works too: [data-kind="tool"] path { stroke-dasharray: 2 4 }. Labels render as <div data-edge-label="<edge id>" data-kind> (card surface, muted text); they ignore the pointer so hovering one still reaches the edge. Keep labels strings if you persist or copy edges.

Handles

<Handle> only positions the port (and widens its hit area); its look is plain CSS in @layer components with zero specificity, so a class on the handle or any app stylesheet wins without !important. Restyle through the variables below or the handle's attributes:

Attribute Values
data-handle-id the handle's id
data-type source or target
data-side left, right, top or bottom
data-connected true when at least one edge uses it
data-state valid (a connection drag could end here) or over (it will)
.port {
  width: 11px;
  height: 11px;
  border-width: 1.5px;
} /* <Handle className="port" … /> */
[data-type="source"][data-connected="true"] {
  --weave-handle-fill: var(--weave-handle);
}

Theming

Weave uses your shadcn theme as-is. Surfaces, borders, focus rings, selection and the minimap all read --background, --card, --border, --primary, --muted-foreground, --ring and --radius, so light/dark mode and custom themes apply automatically. That includes themes scoped to a subtree, such as a .theme-blue wrapper.

To restyle the canvas itself, set any of these variables on :root, on a theme class, or on one <Weave className="…">:

Variable Styles Default
--weave-dot background dot grid --muted-foreground at 35%
--weave-edge resting connections (canvas and minimap) --muted-foreground at 45%
--weave-edge-hover hovered connection --foreground at 70%
--weave-edge-selected selected connection, in-progress connection line --primary
--weave-edge-flow animated connections (edge.animated) --primary
--weave-edge-width resting and hovered connection stroke width 1.75px
--weave-edge-width-selected selected connection stroke width 2.5px
--weave-handle port outlines --muted-foreground at 60%
--weave-handle-fill port fill --background
--weave-handle-active hovered ports, and ports a connection drag can reach --primary
--weave-handle-size port diameter 12px
--weave-note sticky note fill --card tinted amber
--weave-group group frame fill --muted at 70%
<Weave className="[--weave-edge-flow:var(--color-emerald-500)]" … />

Upgrading from v0.1

Re-run npx shadcn@latest add …/weave.json so you get the new files (note.tsx, group.tsx) and CSS. Then check these changes:

  • Handles are styled by CSS. Port visuals moved out of <Handle>'s classes into the registry CSS (@layer components). Without that CSS, ports render unstyled. data-handle-type is now data-type.
  • Edge DOM. Each edge's visible path(s) now sit inside <g data-edge-id …>, so selectors like path[pointer-events=stroke] + path need updating to [data-edge-id] path.
  • Flowing edges are beads. weave-flow now draws round beads (0.01 14, 4px) over a faint track, instead of 7 4 dashes. If you'd overridden weave-flow yourself (with !important stroke widths), you can delete that override. Stroke widths now come from --weave-edge-width / --weave-edge-width-selected.
  • History records mutations. add, remove, connect, moveNodes, updateNode(Data), updateEdge and setEdges are now undo steps. Wrap transient updates (run status, animated, live labels) in flow.untracked(() => …) to keep them out of history. flow.set stays unrecorded.
  • Built-in note and group types. Your own nodeTypes.note / nodeTypes.group still win. Nodes of those types now draw behind other nodes.
  • remove includes group contents. It also removes nodes whose parent is a removed node (only relevant once you use parent).

Development

bun install
bun run check   # typecheck (strict), oxlint, oxfmt --check, unit tests
bun dev         # demo at http://localhost:5173
bun run e2e     # Playwright against the running dev server; set CHROME_PATH to use a local Chrome

About

Clean-room React node editor (n8n/React Flow-style), shipped as a shadcn registry

Resources

Readme
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.