Skip to content

feat: html-friendly distribution bundle#123

Open
tuanddd wants to merge 9 commits intobenjitaylor:mainfrom
tuanddd:feat/html-friendly-distribution-bundle
Open

feat: html-friendly distribution bundle#123
tuanddd wants to merge 9 commits intobenjitaylor:mainfrom
tuanddd:feat/html-friendly-distribution-bundle

Conversation

@tuanddd
Copy link

@tuanddd tuanddd commented Mar 3, 2026

Summary

Adds a browser entrypoint for agentation so it can be used directly from a script tag, while keeping the existing React component API intact.

This PR introduces:

  • a new agentation/browser export with an imperative mount API
  • a self-contained browser bundle at dist/agentation.browser.min.js
  • a global window.Agentation.mount() API for plain HTML pages
  • updated docs and examples for browser usage

What Changed

New browser entrypoint

Added browser.tsx, which:

  • mounts the existing PageFeedbackToolbarCSS component into a singleton browser root
  • exports mountAgentation(props?)
  • returns a handle with:
    • update(nextProps?)
    • destroy()
  • registers window.Agentation = { mount, version } in browser environments

The toolbar UI and behavior still come from the existing React component implementation.

New browser bundle output

Updated tsup.config.ts to build:

  • the existing React library outputs
  • a new browser module build
  • a self-contained browser script bundle:
    • dist/agentation.browser.min.js

The browser bundle includes the runtime it needs and can be loaded directly in a plain HTML page.

New package export

Updated package.json to add:

import { mountAgentation } from "agentation/browser";

This is exposed through the new ./browser subpath export.

Browser runtime shim

Added process-shim.ts so the built browser bundle can run safely in environments where process is not defined.

Docs and examples

Updated:

These now document:

  • React usage through import { Agentation } from "agentation"
  • browser usage through:
    • window.Agentation.mount()
    • import { mountAgentation } from "agentation/browser"

Also updated example-vanilla-js.html to load the built browser bundle locally and mount it on a plain HTML page.

Behavior

The main React entrypoint remains unchanged:

  • import { Agentation } from "agentation" still works as before

The new browser entrypoint adds:

  • a direct script-tag integration path
  • a single mounted toolbar instance per page
  • in-place updates through update()
  • clean teardown through destroy()

Testing

Validated locally:

  • pnpm exec vitest run src/browser.test.tsx
  • pnpm build

Added tests in browser.test.tsx for:

  • browser global registration
  • singleton mount behavior
  • update behavior
  • destroy/remount lifecycle
  • DOM-environment guardrails

E2E test with an actual vanilla HTML has not been performed yet, if this PR gains some traction I'll find some time to do it

benjitaylor and others added 9 commits February 24, 2026 17:33
Canvas overlay for drawing on the page with gesture classification
(box, circle, underline, arrow). Click strokes to create linked
annotations. Includes undo (cmd+z), hover highlighting, and drawing
descriptions in copy output.
Shake the popup if you try to draw while it's open. Replace stroke
width change on hover with a soft translucent glow behind the stroke.
- Drawing glow animates in/out via rAF lerp (0→0.25 alpha) instead of
  snapping. Works for both stroke hover and marker hover directions.
- Canvas hidden when marker visibility is toggled off (H key / eye
  button), unless actively in draw mode.
This reverts commit fbd9b593df59ae67b8a4440743d2d34c385442f2.
Glow highlight lerps via rAF (separate effect, doesn't touch resize/
scroll). Canvas hidden when marker visibility toggled off.
Single-pass rendering with canvas shadowBlur on hovered stroke instead
of the two-pass wide translucent stroke. glowIntensity 0-1 controls
blur radius (0-12px), animated in/out via rAF lerp.
… fade

- Replace shadowBlur glow with globalAlpha dim (non-hovered strokes at 30%)
- Add tooltip exit animation (100ms fade out on unhover)
- Move canvas outside overlay so it fades on toolbar close
- Fix marker exit timing: compute timeout from stagger delay + animation
- Fix marker enter timing: same, prevents class removal mid-animation
- Skip stagger delay for individually added markers (only batch entrance)
- Remove scale(1.3) on markers when linked drawing is hovered
- Add drawCanvasFading state for deletion fade
- Use visibility:hidden for hit-test hiding (canvas uses opacity now)
- Revert canvas from pointer events back to mouse events (fixes strokes
  not registering)
- Add unique IDs to draw strokes and strokeId on annotations (fixes
  wrong strokes being deleted when indices shift)
- Delete/cancel now find strokes by stable ID, not positional index
- Per-stroke fade on delete uses refs for fresh data, no stale closures
- Canvas visibility uses shouldShowMarkers only (hiding markers while
  in draw mode now works, also exits draw mode)
- Remove touch-action, drawModeActive CSS, pointer capture
@vercel
Copy link

vercel bot commented Mar 3, 2026

@tuanddd is attempting to deploy a commit to the Benji Taylor's Projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants