@michaelyagi/shoji 0.1.0-beta.3 → 0.1.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +3 -3
  2. package/dist/core/shoji-core.js +16 -1
  3. package/dist/core/shoji-core.js.map +1 -1
  4. package/dist/core/shoji-core.min.js +1 -1
  5. package/dist/core/shoji-core.min.js.map +1 -1
  6. package/dist/esm/core/Gallery.d.ts +2 -0
  7. package/dist/esm/core/index.js +95 -2
  8. package/dist/esm/core/index.js.map +1 -1
  9. package/dist/esm/index.css +86 -820
  10. package/dist/esm/index.js +1 -1
  11. package/dist/esm/index2.css +819 -44
  12. package/dist/esm/index3.css +47 -159
  13. package/dist/esm/index4.css +169 -26
  14. package/dist/esm/index5.css +27 -0
  15. package/dist/esm/plugins/activeThumbnail/index.d.ts +7 -1
  16. package/dist/esm/plugins/activeThumbnail/index.js +55 -16
  17. package/dist/esm/plugins/activeThumbnail/index.js.map +1 -1
  18. package/dist/esm/plugins/rotateFlip/index.js +1 -1
  19. package/dist/esm/plugins/zoom/index.js +1 -1
  20. package/dist/esm/{zoomTransition-BbnYTxY-.js → zoomTransition-CQG__VzO.js} +10 -2
  21. package/dist/esm/zoomTransition-CQG__VzO.js.map +1 -0
  22. package/dist/plugins/activeThumbnail.css +99 -0
  23. package/dist/plugins/activeThumbnail.js +55 -17
  24. package/dist/plugins/activeThumbnail.js.map +1 -1
  25. package/dist/plugins/activeThumbnail.min.css +1 -0
  26. package/dist/plugins/activeThumbnail.min.js +1 -1
  27. package/dist/plugins/activeThumbnail.min.js.map +1 -1
  28. package/dist/plugins/rotateFlip.js.map +1 -1
  29. package/dist/plugins/rotateFlip.min.js.map +1 -1
  30. package/dist/plugins/zoom.js.map +1 -1
  31. package/dist/plugins/zoom.min.js.map +1 -1
  32. package/dist/shoji.css +99 -0
  33. package/dist/shoji.js +69 -17
  34. package/dist/shoji.js.map +1 -1
  35. package/dist/shoji.min.css +1 -1
  36. package/dist/shoji.min.js +1 -1
  37. package/dist/shoji.min.js.map +1 -1
  38. package/package.json +1 -1
  39. package/dist/esm/bodyScrollLock-CC5PJxJp.js +0 -96
  40. package/dist/esm/bodyScrollLock-CC5PJxJp.js.map +0 -1
  41. package/dist/esm/zoomTransition-BbnYTxY-.js.map +0 -1
package/README.md CHANGED
@@ -3,9 +3,9 @@
3
3
  [![CI](https://github.com/MichaelYagi/shoji/actions/workflows/ci.yml/badge.svg)](https://github.com/MichaelYagi/shoji/actions/workflows/ci.yml)
4
4
  [![npm (beta)](https://img.shields.io/npm/v/%40michaelyagi%2Fshoji/beta.svg)](https://www.npmjs.com/package/@michaelyagi/shoji)
5
5
 
6
- A zero-dependency, plugin-first TypeScript lightbox/gallery. Drop in two `<script>`/`<link>` tags, or install from npm everything beyond the minimal lightbox, including every official plugin, is opt-in.
6
+ > **AI-authored.** 100% of the code was written by Claude (Anthropic); I shaped the architecture, scope, and every decision, and did all the testing.
7
7
 
8
- > **Status: beta.** The API is still settlingexpect breaking changes between `0.x` releases.
8
+ A zero-dependency, plugin-first TypeScript lightbox/gallery. Drop in two `<script>`/`<link>` tags, or install from npm everything beyond the minimal lightbox, including every official plugin, is opt-in.
9
9
 
10
10
  ## Features
11
11
 
@@ -14,7 +14,7 @@ A zero-dependency, plugin-first TypeScript lightbox/gallery. Drop in two `<scrip
14
14
  - **Plugin system** — zoom (pinch/pan/wheel), fullscreen, rotate/flip, autoplay/slideshow, active-thumbnail sync, YouTube video embeds, and a grid/masonry/justified layout engine, each independently opt-in.
15
15
  - **Accessibility is not a plugin** — keyboard nav, focus trapping, ARIA roles, and screen-reader announcements live in core.
16
16
  - **Themeable via CSS custom properties** — no hardcoded colors/sizes in JS.
17
- - **Single-file distribution** — `dist/shoji.js` + `dist/shoji.css` (core + every official plugin, self-registering) for zero-setup `<script>` tag use, plus tree-shakable per-plugin ESM entries for bundler users.
17
+ - **Three distributions** — single-file (`dist/shoji.js` + `dist/shoji.css`, core + every plugin, self-registering) for zero-setup `<script>` tag use; core + individual plugin files (`dist/core/shoji-core.(min.)js` + `dist/plugins/{name}.(min.)js`) for `<script>`-tag consumers who want to pick exactly which plugins ship; and tree-shakable per-plugin ESM entries for bundler users.
18
18
  - Size-budgeted and CI-enforced: core ≤ 21 kB, each plugin ≤ 8 kB, full bundle ≤ 90 kB (all min+gzip).
19
19
 
20
20
  ## Install
@@ -14,6 +14,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
14
14
  let styleObserver = null;
15
15
  let intentionalScrollOccurred = false;
16
16
  const LIGHTBOX_SELECTOR = ".shoji-outer";
17
+ function markIntentionalScroll() {
18
+ intentionalScrollOccurred = true;
19
+ }
17
20
  function isRtl() {
18
21
  return getComputedStyle(document.documentElement).direction === "rtl";
19
22
  }
@@ -531,8 +534,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
531
534
  const translateY = to.top + to.height / 2 - (from.top + from.height / 2);
532
535
  return `translate3d(${translateX}px, ${translateY}px, 0) scale3d(${scale}, ${scale}, 1)`;
533
536
  }
537
+ function effectiveOriginBox(origin) {
538
+ const img = origin.querySelector("img");
539
+ if (img) {
540
+ const rect = img.getBoundingClientRect();
541
+ if (rect.width > 0 && rect.height > 0) return rect;
542
+ }
543
+ return origin.getBoundingClientRect();
544
+ }
534
545
  function computeTransform(origin, target, aspectRatio, naturalSize) {
535
- const originRect = origin.getBoundingClientRect();
546
+ const originRect = effectiveOriginBox(origin);
536
547
  const targetRect = effectiveTargetBox(target, aspectRatio, naturalSize);
537
548
  if (targetRect.width === 0 || targetRect.height === 0 || originRect.width === 0 || originRect.height === 0) {
538
549
  return null;
@@ -2579,6 +2590,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2579
2590
  }
2580
2591
  return this.scannedElements[index] ?? null;
2581
2592
  }
2593
+ /** Lets a plugin's background-page `scrollIntoView()` survive `close()`'s scroll restore, routed through this shared instance rather than importing `bodyScrollLock` directly — required for the standalone core+plugins distribution, where a direct import would get its own disconnected module copy (DESIGN.md §4.2/§10). Same reasoning `getOriginElement`/`getActiveMedia` were made public for. */
2594
+ markIntentionalScroll() {
2595
+ markIntentionalScroll();
2596
+ }
2582
2597
  scheduleAutoHide() {
2583
2598
  if (this.autoHideTimer !== null) {
2584
2599
  clearTimeout(this.autoHideTimer);