Skip to content

Fix bugs, complete resize features, add lifecycle API, docs, tests, and harden packaging/CI#2

Merged
Stephen10121 merged 2 commits intoStephen10121:mainfrom
VikingDadMedic:hardening-pass
Mar 20, 2026
Merged

Fix bugs, complete resize features, add lifecycle API, docs, tests, and harden packaging/CI#2
Stephen10121 merged 2 commits intoStephen10121:mainfrom
VikingDadMedic:hardening-pass

Conversation

@VikingDadMedic
Copy link
Copy Markdown
Contributor

@VikingDadMedic VikingDadMedic commented Mar 19, 2026

Summary

Two commits that bring the library from WIP to release-ready quality:

Commit 1 -- Feature & bug fix pass:

  • Fix iframeWindowClickedSubscribe unsubscribe targeting wrong map (memory leak)
  • Replace magic sentinel string with exported INACTIVE_MOUSE_ID constant
  • Remove dead code (empty files, commented-out IE scroll code, unused types/CSS)
  • Add touch support to all 4 edge resize components (mobile was advertised but resize was mouse-only)
  • Add 4 corner resize handles (TopLeft, TopRight, BottomLeft, BottomRight) with mouse + touch
  • Add onDragStart/onDragEnd/onResizeStart/onResizeEnd lifecycle callbacks
  • Export new types: WindowPosition, WindowDimensions, INACTIVE_MOUSE_ID
  • Replace docs stub with full documentation page (quick start, API reference, props, callbacks, styling)
  • Expand README with badges, install instructions, usage snippet, and feature list
  • Set up Vitest + Testing Library with 9 tests covering MouseContext, WindowContext, Window, and WindowDragger

Commit 2 -- Hardening pass:

  • Move site-only code (homepage, button, tailwindutils, test harnesses, tests) out of src/lib/ so dist/ only ships library files
  • Add .cursor/ to .gitignore
  • Remove stray console.log handler from Demo
  • Fix onActiveStateChanged payload documented as object (actual: boolean)
  • Add WindowManager props, WindowDragConfig reference, and children prop to docs
  • Upgrade CI: actions/checkout@v4, add Node setup + check/test steps, gate Docker push on push events
  • Harden Dockerfile: pin node:22-slim, replace deprecated npm prune, add .dockerignore

Test plan

  • npm run check passes (0 errors)
  • npm run test passes (9/9 tests)
  • npm run build passes (vite build + svelte-package + publint)
  • dist/ contains only library components (no homepage, button, tailwindutils, tests)
  • Drag and resize work on desktop and mobile (touch)
  • Corner resize handles appear on all 4 corners
  • /docs route renders full documentation
  • /playground route still works

Made with Cursor

Bug fixes:
- Fix iframeWindowClickedSubscribe unsubscribe targeting wrong map
  (was deleting from activeWindowSubscribers instead of
  iframeWindowClickedListeners, causing memory leaks)
- Replace hardcoded sentinel string with exported INACTIVE_MOUSE_ID
  constant across utils.ts, Window.svelte, and WindowManager.svelte
- Fix stale basicStyling prop and invalid style prop in playground

Dead code cleanup:
- Remove empty src/lib/helper.ts
- Remove unused .cover CSS class from Window.svelte
- Remove commented-out IE scroll code from utils.ts and WindowDragger
- Remove unused WithoutChild/WithoutChildren/WithoutChildrenOrChild types
- Delete static/style.css (all CSS commented out) and its app.html link

Touch resize support:
- Add ontouchstart + preventScroll to all four edge resize components
  (TopResize, BottomResize, LeftResize, RightResize) matching the
  existing pattern from WindowDragger

Corner resize handles:
- Add TopLeftResize, TopRightResize, BottomLeftResize, BottomRightResize
  components with both mouse and touch support
- Each adjusts two axes simultaneously with minWidth/minHeight enforcement
- Wire into Window.svelte alongside existing edge handles

Lifecycle callbacks:
- Add onDragStart, onDragEnd, onResizeStart, onResizeEnd to
  ActualWindowProps with WindowPosition and WindowDimensions payload types
- Wire drag callbacks through WindowDragger
- Wire resize callbacks through all edge and corner resize components
- Detect interaction end via INACTIVE_MOUSE_ID broadcast in Window.svelte

Public API expansion:
- Export INACTIVE_MOUSE_ID, WindowPosition, WindowDimensions from index.ts

Documentation:
- Replace /docs stub with full docs page (quick start, API reference,
  props table, lifecycle callbacks, styling guide, exports)
- Expand README with badges, install, usage, feature list, callback docs,
  exports, and links to docs/playground

Testing infrastructure:
- Add vitest, @testing-library/svelte, @testing-library/jest-dom, jsdom
- Add vitest.config.ts with browser resolve conditions for Svelte 5
- Add test and test:watch scripts to package.json
- Write MouseContext tests (subscription, dispatch, touch, sentinel)
- Write WindowContext tests (registration, stacking, iframe unsub fix)
- Write Window.svelte tests (drag regions, conditional resize handles)
- Write WindowDragger tests (mousedown activation, coordinate updates)

Made-with: Cursor
Package hygiene -- stop shipping non-library files to npm:
- Move src/lib/homepage/ to src/homepage/ (site-only components)
- Move src/lib/components/ui/button/ to src/components/ui/button/
- Move src/lib/tailwindutils.ts to src/tailwindutils.ts
- Move src/lib/test-harnesses/ to src/test/harnesses/
- Move test files from src/lib/*.test.ts to src/test/lib/*.test.ts
- Update all import paths in routes, homepage, button, and test files
- dist/ now contains only library code (verified: no homepage, button,
  tailwindutils, test-harnesses, or test files in output)

Repo hygiene:
- Add .cursor/ to .gitignore
- Remove stray console.log button handler from Demo.svelte

Documentation accuracy:
- Fix onActiveStateChanged payload: documented as object but actual
  callback receives a plain boolean
- Add children prop to Window props table (was missing)
- Add WindowManager props section (children, mouseContext, windowContext
  were completely undocumented)
- Add WindowDragConfig reference (top/bottom and left/right mutual
  exclusivity, color debug option, required width+height, example)

CI/CD hardening:
- Upgrade actions/checkout@v1 to v4 (v1 uses deprecated Node 12)
- Add setup-node@v4 with Node 22 and npm cache
- Add npm run check and npm run test steps before Docker build
- Gate Docker push behind github.event_name == 'push' so PRs from
  forks don't fail on missing secrets

Docker hardening:
- Pin base images to node:22-slim instead of unpinned node:slim
- Replace deprecated npm prune --production with npm ci --omit=dev
- Add .dockerignore to exclude node_modules, .git, .svelte-kit, dist,
  .cursor, and markdown files from build context

Made-with: Cursor
@Stephen10121 Stephen10121 merged commit 3090e5a into Stephen10121:main Mar 20, 2026
2 checks passed
@Stephen10121
Copy link
Copy Markdown
Owner

Hey. This looks amazing. Just merged the changes. I will add a contributor section to give credit.

The website already has been updated with the CD pipeline but I'll have to update the npm package manually. Should be updated in no time.

Thank you for your contributions.

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