@a2f0/agent-tool 0.1.34 → 0.1.35

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a2f0/agent-tool",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "packageManager": "bun@1.4.3",
5
5
  "type": "module",
6
6
  "description": "Portable cross-agent review, PR workflows, and shared skills",
@@ -707,7 +707,7 @@ function defineCarousel(): CustomElementConstructor {
707
707
  return limit > 0 ? slides.slice(0, limit) : slides;
708
708
  }
709
709
 
710
- #render(manifest: ScreenshotManifest, keep?: number): void {
710
+ #render(manifest: ScreenshotManifest): void {
711
711
  this.#manifest = manifest;
712
712
  const slides = this.#slidesFor(manifest);
713
713
  const signal = this.#abort!.signal;
@@ -717,9 +717,35 @@ function defineCarousel(): CustomElementConstructor {
717
717
  this.dataset["state"] = "ready";
718
718
  const project = slides[0]!.light.project;
719
719
  const frame = projectFrame(manifest, project);
720
- const linkBase = this.getAttribute("link-base");
721
720
  const loop = slides.length > 1;
722
- const copies = loop ? this.#copies : 0;
721
+ const track = element("div", { class: "shots-carousel-track", tabindex: "0" }, [this.#list(manifest, slides, loop ? this.#copies : 0)]);
722
+ this.#track = track;
723
+ const root = element("div", { class: "shots-carousel", role: "region", "aria-roledescription": "carousel", "aria-label": this.getAttribute("label") ?? "Screenshots", "data-frame": frame }, [track]);
724
+ const controls = element("div", { class: "shots-carousel-controls" });
725
+ const viewAll = this.getAttribute("view-all-href");
726
+ if (viewAll) controls.append(element("a", { class: "shots-carousel-view-all", href: viewAll, text: this.getAttribute("view-all-label") || "View all screenshots" }));
727
+ if (loop) {
728
+ const previous = element("button", { type: "button", class: "shots-carousel-step", "data-step": "-1", "aria-label": "Previous screens" }, [icon("prev")]);
729
+ const next = element("button", { type: "button", class: "shots-carousel-step", "data-step": "1", "aria-label": "Next screens" }, [icon("next")]);
730
+ previous.addEventListener("click", () => this.step(-1), { signal });
731
+ next.addEventListener("click", () => this.step(1), { signal });
732
+ controls.append(previous, next);
733
+ onScrollSettle(track, () => this.#normalize(), signal);
734
+ if (typeof ResizeObserver === "function") {
735
+ const observer = new ResizeObserver(() => this.#resize());
736
+ observer.observe(track);
737
+ signal.addEventListener("abort", () => observer.disconnect());
738
+ }
739
+ }
740
+ if (controls.childElementCount) root.append(controls);
741
+ this.replaceChildren(root);
742
+ if (loop) this.#jump(this.#copies * slides.length);
743
+ }
744
+
745
+ /** The slide list: the originals between `copies` loop copies on each side. */
746
+ #list(manifest: ScreenshotManifest, slides: { name: string; light: ScreenshotEntry; dark: ScreenshotEntry | undefined }[], copies: number): HTMLUListElement {
747
+ const project = slides[0]!.light.project;
748
+ const linkBase = this.getAttribute("link-base");
723
749
  const list = element("ul", { class: "shots-carousel-list", role: "list" });
724
750
  this.#slides = [];
725
751
  for (let copy = -copies; copy <= copies; copy += 1) {
@@ -744,28 +770,7 @@ function defineCarousel(): CustomElementConstructor {
744
770
  list.append(item);
745
771
  });
746
772
  }
747
- const track = element("div", { class: "shots-carousel-track", tabindex: "0" }, [list]);
748
- this.#track = track;
749
- const root = element("div", { class: "shots-carousel", role: "region", "aria-roledescription": "carousel", "aria-label": this.getAttribute("label") ?? "Screenshots", "data-frame": frame }, [track]);
750
- const controls = element("div", { class: "shots-carousel-controls" });
751
- const viewAll = this.getAttribute("view-all-href");
752
- if (viewAll) controls.append(element("a", { class: "shots-carousel-view-all", href: viewAll, text: this.getAttribute("view-all-label") || "View all screenshots" }));
753
- if (loop) {
754
- const previous = element("button", { type: "button", class: "shots-carousel-step", "data-step": "-1", "aria-label": "Previous screens" }, [icon("prev")]);
755
- const next = element("button", { type: "button", class: "shots-carousel-step", "data-step": "1", "aria-label": "Next screens" }, [icon("next")]);
756
- previous.addEventListener("click", () => this.step(-1), { signal });
757
- next.addEventListener("click", () => this.step(1), { signal });
758
- controls.append(previous, next);
759
- onScrollSettle(track, () => this.#normalize(), signal);
760
- if (typeof ResizeObserver === "function") {
761
- const observer = new ResizeObserver(() => this.#resize());
762
- observer.observe(track);
763
- signal.addEventListener("abort", () => observer.disconnect());
764
- }
765
- }
766
- if (controls.childElementCount) root.append(controls);
767
- this.replaceChildren(root);
768
- if (loop) this.#jump(copies * slides.length + (keep ?? 0));
773
+ return list;
769
774
  }
770
775
 
771
776
  #pitch(): number {
@@ -802,7 +807,13 @@ function defineCarousel(): CustomElementConstructor {
802
807
  const logical = wrapIndex(this.#current(), this.#count), manifest = this.#manifest, signal = this.#abort?.signal;
803
808
  this.#copies = copies;
804
809
  // Outside the observer callback, so the new slides do not resize the track within it.
805
- requestAnimationFrame(() => { if (!signal?.aborted) this.#render(manifest, logical); });
810
+ // Only the slides change: the controls and the view-all link stay the same nodes, so a
811
+ // click or focus on them survives a resize.
812
+ requestAnimationFrame(() => {
813
+ if (signal?.aborted || this.#track !== track) return;
814
+ track.replaceChildren(this.#list(manifest, this.#slidesFor(manifest), copies));
815
+ this.#jump(copies * this.#count + logical);
816
+ });
806
817
  } else this.#normalize();
807
818
  }
808
819