replicant-squint
v0.1.0
Published
Replicant-style hiccup renderer for SquintJS.
Maintainers
Readme
Replicant Squint
Disclosure: This library was written by Codex GPT 5.5, based on the Clojure Replicant library.
A small Replicant-style hiccup renderer for SquintJS.
This is not a drop-in port of Replicant. It keeps the useful shape of the API and rendering model, but avoids ClojureScript-only features such as protocols, reader-conditionals, and macros.
Install
npm install replicant-squint squint-cljsreplicant-squint ships precompiled ESM in dist/ and Squint source in src/.
NPM / bundler usage
Use package subpath imports from Squint code:
(ns app
(:require ["replicant-squint/dom" :as r]))
(r/render js/document.body
[:main#app.page
[:h1 "Hello"]
[:button {:on {:click #(js/console.log "clicked")}}
"Click"]])The package root also exports replicant.dom, so this works too:
(ns app
(:require ["replicant-squint" :as r]))Browser / import-map usage
For Squint playground-style code that imports namespaces like replicant.dom, map those bare imports to the published ESM files:
<script type="importmap">
{
"imports": {
"squint-cljs/core.js": "https://unpkg.com/[email protected]/src/squint/core.js",
"replicant.dom": "https://unpkg.com/[email protected]/dist/replicant/dom.mjs",
"replicant.alias": "https://unpkg.com/[email protected]/dist/replicant/alias.mjs",
"replicant.string": "https://unpkg.com/[email protected]/dist/replicant/string.mjs"
}
}
</script>Then your Squint code can use normal namespace requires:
(ns app
(:require [replicant.dom :as r]))
(r/render js/document.body [:h1 "Hello"])Alias-style components
(ns app
(:require ["replicant-squint/alias" :as alias]
["replicant-squint/dom" :as r]))
(alias/register! :ui/button
(fn [attrs children]
(into [:button.button attrs] children)))
(r/render js/document.body [:ui/button {:type "button"} "Save"])API
replicant.dom/render el hiccup & [opts]replicant.dom/unmount elreplicant.dom/set-dispatch! freplicant.dom/recall nodereplicant.alias/register! k freplicant.alias/get-registered-aliasesreplicant.alias/expand-1replicant.string/render hiccup & [opts]
Supported render features include tag id/class shorthand, attrs, style maps with automatic px for numeric values, event handlers in :on, keyed child movement with :replicant/key, SVG namespace handling, aliases, and basic lifecycle hooks (:replicant/on-render, :replicant/on-mount, :replicant/on-update, :replicant/on-unmount).
Develop
npm install
npm test
npm run buildThe source is in src/replicant/*.cljs. Build output goes to dist/.
Before publishing, check the package contents:
npm pack --dry-runCurrent limitations
- Squint compiles keywords to strings, so the implementation treats hiccup tags and attr keys as strings internally.
- Replicant's dev assertions, macros, protocol renderer abstraction, async mounting/unmounting transitions, and CLJ/CLJS dual string renderer are intentionally not ported here.
- Alias helpers are functions, not macros. Use
alias/register!instead ofdefalias.
