partforge 0.105.0 → 0.105.1

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": "partforge",
3
- "version": "0.105.0",
3
+ "version": "0.105.1",
4
4
  "description": "Turn a declarative part definition into a parametric-CAD web app (three.js + Manifold/Replicad). Requires a Vite-based consumer.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -12,6 +12,7 @@
12
12
  // active — getView() is the driver's only window onto it.
13
13
  import { viewAnimations, createPlayback, stepIndexAt } from "./animation.js";
14
14
  import { createInfoPopover, attachInfo } from "./controls.js";
15
+ import { stageClearFor } from "./stage-clear.js";
15
16
 
16
17
  function el(tag, className, text) {
17
18
  const node = document.createElement(tag);
@@ -675,13 +676,14 @@ export function attachAnimationControls(viewer, part, {
675
676
  const barRect = bar.getBoundingClientRect();
676
677
  // Publish the bar's vertical claim on the stage as --pf-anim-clear: the
677
678
  // distance from the stage's bottom edge to the bar's top, 0px when the bar
678
- // is hidden (a view with no animations). Hosts that float their own chrome
679
- // at the stage's bottom-centre (partforge-cloud's status/forging stack)
680
- // read it to sit above the bar instead of under it; with no bar mounted
681
- // the property is never set and a var() fallback of 0px applies.
682
- const clear = bar.style.display === "none"
683
- ? 0
684
- : Math.max(0, Math.round(stageRect.bottom - barRect.top));
679
+ // is hidden — by us (a view with no animations, sketch mode: the inline
680
+ // display) OR by a host stylesheet, which leaves our inline display alone
681
+ // and empties the bar's box, the case stageClearFor tests. Hosts that
682
+ // float their own chrome at the stage's bottom-centre (partforge-cloud's
683
+ // status/forging stack) read it to sit above the bar instead of under it;
684
+ // with no bar mounted the property is never set and a var() fallback of
685
+ // 0px applies.
686
+ const clear = bar.style.display === "none" ? 0 : stageClearFor(stageRect, barRect);
685
687
  container.style.setProperty("--pf-anim-clear", `${clear}px`);
686
688
  const cubeEl = container.querySelector(cubeSelector);
687
689
  const viewbarRect = viewbarEl?.getBoundingClientRect() ?? null;
@@ -702,8 +704,8 @@ export function attachAnimationControls(viewer, part, {
702
704
  // back in here.
703
705
  function isCrowded({ stageRect, barRect, viewbarRect, cubeRect, cubeEl }) {
704
706
  // A bar that is not on screen cannot be crowded by anything — the same
705
- // condition the --pf-anim-clear calculation above uses.
706
- if (bar.style.display === "none") return false;
707
+ // two conditions the --pf-anim-clear calculation above uses.
708
+ if (bar.style.display === "none" || barRect.height === 0) return false;
707
709
  const nominal = nominalClusterRect(viewbarRect, cubeRect, publishedSize(cubeEl));
708
710
  // Same vertical-band test the placement path applies, against the nominal
709
711
  // rect: bands that do not intersect cannot collide, so there is nothing to
@@ -33,6 +33,7 @@ import { createAnnotateMode } from "./annotate/annotate-mode.js";
33
33
  import { attachAnnotateControls } from "./annotate/annotate-controls.js";
34
34
  import { attachSketchToolbar } from "./annotate/sketch-toolbar.js";
35
35
  import { attachViewcubeControls } from "./viewcube/viewcube-controls.js";
36
+ import { stageClearFor } from "./stage-clear.js";
36
37
 
37
38
  // The mount handle, factored out so its shape is unit-testable without booting
38
39
  // the full mount() pipeline (WASM + workers + DOM).
@@ -599,16 +600,14 @@ export function mount(part, { createWorker, elements = {}, onBuild, onPick, onDo
599
600
  }
600
601
  // Publish the viewbar's vertical claim so chrome.css can stack the cube on
601
602
  // top of it without hardcoding a height that cutaway/measure/annotate
602
- // action rows can change.
603
+ // action rows can change. A hidden bar (ours or a host stylesheet's)
604
+ // claims 0 — stage-clear.js has the why; the observer fires on the hide
605
+ // itself, since the bar's box goes to zero.
603
606
  const viewbarEl = els.viewer.querySelector("#viewbar");
604
607
  if (viewbarEl && typeof ResizeObserver === "function") {
605
608
  const publishViewbarClear = () => {
606
- const stageRect = els.viewer.getBoundingClientRect();
607
- const barRect = viewbarEl.getBoundingClientRect();
608
- els.viewer.style.setProperty(
609
- "--pf-viewbar-clear",
610
- `${Math.max(0, Math.round(stageRect.bottom - barRect.top))}px`,
611
- );
609
+ const clear = stageClearFor(els.viewer.getBoundingClientRect(), viewbarEl.getBoundingClientRect());
610
+ els.viewer.style.setProperty("--pf-viewbar-clear", `${clear}px`);
612
611
  };
613
612
  const viewbarObserver = new ResizeObserver(publishViewbarClear);
614
613
  viewbarObserver.observe(viewbarEl);
@@ -0,0 +1,18 @@
1
+ // The one arithmetic behind the stage's two "clearance" custom properties —
2
+ // --pf-viewbar-clear (mount.js) and --pf-anim-clear (animation-controls.js):
3
+ // how far up from the stage's bottom edge a floating bar reaches, so chrome
4
+ // that stacks above it (the view cube, a host's status pills) can sit clear.
5
+ //
6
+ // A bar with NO BOX claims nothing. `getBoundingClientRect()` on a
7
+ // `display: none` element is all zeros, and `stageRect.bottom - 0` is the
8
+ // stage's bottom edge in viewport pixels — the whole stage height, or more.
9
+ // Publishing that would fling everything stacked on the bar off the top of
10
+ // the stage. The inline-style check the anim bar used to make
11
+ // (`bar.style.display === "none"`) only saw its own hide; a host hiding the
12
+ // bar from a stylesheet (partforge-cloud's part-open sheet does exactly that
13
+ // to #viewbar and .pf-anim-bar) left the publishers measuring the zero rect.
14
+ // The rect itself is the test: hidden by anyone, for any reason, it is empty.
15
+ export function stageClearFor(stageRect, barRect) {
16
+ if (!barRect || barRect.height === 0) return 0;
17
+ return Math.max(0, Math.round(stageRect.bottom - barRect.top));
18
+ }