Svg js generator
Make a pixel-perfect, dependency-free replica of an inline-SVG component whose geometry is regenerated by JavaScript (cursor-, scroll-, or time-driven) by reading its actual generator source from the page bundle, instead of inferring a parametric model from measured curves. Use when the thing you need to clone, extract, or replicate is an inline <svg> with real <path>/shape children whose motion is driven by JS (no <canvas>, no <animate>/SMIL). Do NOT use for <canvas> (WebGL/canvas2d), declarative CSS/SMIL keyframes, Lottie/Rive, or <img>/<video> — those are sibling extraction skills with a completely different strategy.From its SKILL.md
npx -y skills add novarii/component-extractor --skill svg-js-generatorAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
10.2 KB, as published. Nobody here has run it
svg-js-generator extraction
Make a pixel-perfect, dependency-free replica of an inline-SVG component whose geometry is regenerated by JavaScript (cursor / scroll / time driven) by reading its actual generator source from the page bundle — not by inferring a model.
One of a family of per-rendering extraction skills. This file covers exactly one class. If the classifier below says otherwise, stop and use the sibling skill (canvas2d, webgl, lottie-rive, smil-css, video-asset). Mixing strategies is how runs go wrong.
Driver: browser-harness (on $PATH, heredoc form — see its SKILL.md). Swap for
agent-browser if you prefer; only the capture calls change.
The one principle
Extract, don't infer. If it renders client-side, the generator was shipped to the browser — go read it. Fitting a parametric model to measured curves is lossy and underdetermined: you will match one element and one response curve and still get the global arrangement wrong, because you guessed the model class and never recovered the real constants. Reading the source is exact by construction.
Corollary for verification: numbers before pixels, many states before "done".
When this skill applies (classify first — 30 seconds)
browser-harness <<'PY'
# adjust the locator to your target's heading/label
r = js(r"""(() => {
const card=[...document.querySelectorAll('*')].find(e=>/YOUR TARGET TEXT/i.test(e.textContent)&&e.querySelector('svg'));
const svg=card&&card.querySelector('svg'); if(!svg) return {svg:false};
return {svg:true, paths:svg.querySelectorAll('path,rect,circle,polygon').length,
viewBox:svg.getAttribute('viewBox'),
hasCanvas:!!card.querySelector('canvas'),
inlineGen: svg.querySelectorAll('animate,animateTransform').length===0}; // no SMIL => JS-driven
})()""")
print(r)
PY
Proceed only if: an inline <svg> with real <path>/shape children, no <canvas>,
and no <animate>/SMIL (so motion is JS, not declarative). Then sample the same
shape's d over ~2 s with the pointer away — if it changes on its own it's a time
loop (still fine), if it changes only on hover it's input-driven (our main case).
Bail to a sibling skill if: <canvas> present (canvas2d/webgl), SMIL/CSS keyframes
present (smil-css — just copy DOM+styles), or it's an <img>/<video>/Lottie JSON
(asset — just download it).
Pipeline
1. Locate & isolate the target
Reach the public page first — logged-in sessions often redirect to auth. If
example.com bounces to login, follow a "learn more"/footer link to the real
marketing URL (we found linear.app/homepage that way). Then isolate the leaf
element, not an ancestor:
# GOTCHA: textContent matches the wrapper too. Filter by a width/closest() guard.
const card=[...document.querySelectorAll('[class*=Card]')]
.find(c=>/TARGET/.test(c.innerText) && c.getBoundingClientRect().width<600);
const svg=card.querySelector('svg'); svg.id='target'; // tag it for later calls
2. Extract the rest geometry verbatim
Dump svg.outerHTML at rest. This alone hands you every figure-level constant —
element count, spacing, angles, color/stroke, corner radii, filter defs — the exact
dimension a "fit the model" approach keeps missing. Read the numbers straight out of
the path d strings.
3. Find the generator in the bundle
List external scripts, download in parallel, grep for distinctive tokens drawn from step 2. The intersection of three usually pins one chunk:
- a literal magic number copied from a path
d(e.g.57.843), - the filter/gradient
idstem from<defs>(e.g.barShadow), - the CSS-module class stem (
Benefits_momentum__42Pqx→ grepmomentum).
browser-harness <<'PY'
import json; print("\n".join(json.loads(js("JSON.stringify([...document.scripts].filter(s=>s.src).map(s=>s.src))"))))
PY
# > urls.txt ; then:
cat urls.txt | xargs -P8 -I{} sh -c 'curl -s "{}" -o "$(basename {})"'
grep -l "MAGIC_NUMBER" *.js # one file should match all three tokens
4. Read & transcribe the generator
Minified is fine — light-reformat by inserting newlines after ; { } , and read:
uv run --quiet python - <<'PY'
s=open('CHUNK.js').read(); i=s.find('MAGIC_NUMBER')
out=s[i-1500:i+2000]
for ch in ';{},': out=out.replace(ch,ch+'\n')
print(out)
PY
Recover, exactly: the input→target function(s) (height/opacity/transform as a
function of cursor/scroll), the constant tables (anchors, rest values), the
path-template strings (copy them character-for-character), and the easing/spring
config (useSpring({stiffness,damping,mass}), cubic-bezier, GSAP ease). Verify the
template reproduces the rest DOM to the digit before trusting it.
5. Transplant dependency-free
Reimplement small deps inline (a framer-motion spring is ~6 lines of semi-implicit
Euler with the same k/c/m). Ship the library only when reimplementation doesn't
scale (physics/layout engines). Map the raw input the same way the source does
(e.g. mouseX = (clientX-left)/width * viewBoxW; rest = Infinity/sentinel).
6. Verify — numeric, then multi-state pixel
- Numeric first: drive the live target and your replica to the same input, read both states from the DOM, diff the arrays. Sub-pixel cursor jitter means the live capture never lands on your exact input — solve for the input offset that best fits, then compare (we proved a match to 0.02 once we backed out a 0.66px cursor delta). Don't call a mismatch before doing this.
- Then pixels: registered diff at matched DPR, across rest + several inputs +
viewports/breakpoints +
prefers-reduced-motion. One-state diffs lie.
# crop a figure from a full-viewport shot (clip coords are document-space; this isn't)
uv run --quiet --with pillow python - <<'PY'
from PIL import Image; import json
r=json.load(open('rect.json')); im=Image.open('full.png'); sc=im.size[0]/1512.0
im.crop((round(r['x']*sc),round(r['y']*sc),round((r['x']+r['w'])*sc),round((r['y']+r['h'])*sc))).save('crop.png')
PY
7. Package
Wrap as a custom element / single mount(el) fn so it drops into any framework. Keep
the original viewBox + preserveAspectRatio; respect prefers-reduced-motion.
Gotchas (field-tested on linear.app FIG 0.4)
- Wrapper vs leaf:
textContentmatches ancestors; an unguardedfindgrabs the wrap div and its first svg. Guard by width /closest(leafSelector). - Auth redirect: logged-in root → login. Follow a public link to the marketing URL.
js()marshalling: returnJSON.stringify(...)andjson.loadsit. Raw arrays come back as{}.- Daemon wedges on mouse dispatch over heavy pages (spring rAF floods CDP). Do one
action per
browser-harnesscall and wrap in a shell retry loop until the artifact appears.pkill -f browser_harness; rm -f /tmp/bu-default.sockto reset. Page.captureScreenshotclipis document-space, butgetBoundingClientRectis viewport-space → black crops. Screenshot full viewport, crop withrect*dprinstead.- framer-motion writes
style.filteronto the SVGfilterattribute, overriding anyfilter="url(#…)". Replicate what the DOM actually shows, not what the JSX reads — a referenced drop-shadow filter may render nothing. - CDP
cdp(method, **params)— params are kwargs, not a dict.
Limitations / bail conditions
- Heavy minification/obfuscation (control-flow flattening, computed constants) →
source unreadable; drop to instrument (wrap the draw/anim API) or behavioral
capture (dense
input→outputsampling, only for low-dimensional deterministic input). - Non-determinism — accumulated physics state, unseeded randomness, live data, time-loop drift: if you can't enumerate the inputs you can't recover the mapping.
- Hidden/build-up state — intro sequences, IntersectionObserver triggers. Snapshot the settled state, not the load-time intro (we saw 30 paths during intro vs 11 at rest).
- Unshippable assets — licensed fonts/textures, browser-specific filter/blend output. grep can't fetch a font; substitute and note it.
- Legal — fine for learning/internal; lifting someone's logo/IP verbatim into production is not. Say so.
Worked examples (instance-specific — kept out of the method above)
Concrete runs — exact chunk IDs, captured constants, recovery stories — live in
examples/, one file per component. They're examples of the method, not method; if
linear.app vanished they'd be useless to the next target, which is why they're not inlined here.
examples/linear-fig.md— linear.app FIG 0.4 "Designed for speed" (the reference run; replica in../../designed-for-speed/index.html). 15-bar JS-driven inline SVG: generator in chunk33084, piecewise-linear tent height, framer-motion spring; rest pixel-diff 0.0, dynamics match to 0.02.examples/vercel-globe.md— Vercel homepage infrastructure globe (replica in../../vercel-globe/). The JS-generator + declarative-SMIL hybrid: generator in chunk38sbm37cgkcnq(DeployGlobe), routes encoded as grid-walkdirectionsstrings, motion emitted as<animate>onuserSpaceOnUseradial gradients. Astart→typing→building→ deployedstate machine swaps a 20-route blue cascade for 5 teal delivery routes — invisible in a singleouterHTML; cracked by sampling the trace colour live over the cycle. Phase-locked diff ≈ 0.4–1.2/255.
When you finish a new extraction, add examples/<site>-<component>.md here instead of
threading its specifics back into this file.