The workspace declared pkg/* and pkgs/* both, so one repo had two names for one concept and a package's home was a coin toss. The shared build tooling already lived in pkg/ui/scripts and pkgs reached back into it two levels up; now it is a sibling. hanzo.yml gates on pkg/ui, so the published library stays where CI already looks and the rest joins it. The publish glob follows: one root, one pattern, nothing invisible to it. Co-authored-by: Hanzo Dev <[email protected]>
1.3 KiB
@hanzo/source
Where a rendered element came from, and the editor that opens it.
In development a JSX compiler hands the runtime the file, line and column of
every element it wrote. React drops that; this runtime keeps it, on host
elements, as data-source="file:line:column". Alt + right click on anything and
the development server opens that file in your editor — Vite through
/__open-in-editor, Next through /__nextjs_launch-editor, each via
launch-editor, which honours LAUNCH_EDITOR, then EDITOR, then whichever of
code, cursor, zed or vim is running.
Production bundles carry nothing from this package.
Vite
@hanzo/vite wires it. An app on hanzo() needs no configuration.
Next
Name the runtime in tsconfig.json, which SWC reads:
{ "compilerOptions": { "jsx": "preserve", "jsxImportSource": "@hanzo/source" } }
and render the listener once, in the root layout:
import { Source } from '@hanzo/source/react'
export default function Layout({ children }) {
return (
<html>
<body>
{children}
<Source />
</body>
</html>
)
}
By hand
import { position, open, listen } from '@hanzo/source/client'
position(el) reads the nearest stamp, open(at) asks the server, listen()
binds the gesture and returns the function that unbinds it.