@theoremjs/studio 0.3.4-next.454.gaa3f549 → 0.3.4-next.456.gff60088

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 (25) hide show
  1. package/package.json +4 -4
  2. package/page/assets/{Banner-QCiHVb5K.js → Banner-DBzTZFXK.js} +2 -2
  3. package/page/assets/{ConsoleFrame-DqN62wL7.js → ConsoleFrame-xxYOJ87g.js} +1 -1
  4. package/page/assets/{ContextMenu-DIzJdlQ5.js → ContextMenu-BeVF9aNZ.js} +2 -2
  5. package/page/assets/{ToolResultCharts-CjuviquY.js → ToolResultCharts-DBMZY7TW.js} +1 -1
  6. package/page/assets/{TraceInspector-CwGSe8Oe.js → TraceInspector-CzHEXIY1.js} +1 -1
  7. package/page/assets/{TraceOverview-isg4ubrd.js → TraceOverview-Bxg_mg5E.js} +1 -1
  8. package/page/assets/{browser-engine-DA4ZywPN.js → browser-engine-9AzaOhwz.js} +1 -1
  9. package/page/assets/{browser-transport-B0zaH_Aw.js → browser-transport-C4SkWngw.js} +3 -3
  10. package/page/assets/{export-agent-vV5u7tzN.js → export-agent-Bp0s2CsN.js} +1 -1
  11. package/page/assets/{guardrail-tester-D70vg-Zv.js → guardrail-tester-CS65cwR5.js} +1 -1
  12. package/page/assets/{index-CvrD0wqP.js → index--GBhZcW8.js} +6 -6
  13. package/page/assets/{studio-code-pane-CPon5udY.js → studio-code-pane-B5U9m4Ds.js} +1 -1
  14. package/page/assets/{studio-console-BSV-XHe9.js → studio-console-UkWyi9VN.js} +1 -1
  15. package/page/assets/{studio-decision-Dk1Tsfah.js → studio-decision-CCqMemnt.js} +1 -1
  16. package/page/assets/{studio-embedding-BkBuVy1T.js → studio-embedding-RTptdueU.js} +1 -1
  17. package/page/assets/{studio-host-console-C6f389Xp.js → studio-host-console-4UbIwUY0.js} +2 -2
  18. package/page/assets/{studio-labels-DEEMSKuk.js → studio-labels-I9r-0TcO.js} +1 -1
  19. package/page/assets/{studio-live-uDkVyN2h.js → studio-live-Cn-wK5-R.js} +1 -1
  20. package/page/assets/{studio-map-BVIl4fqd.js → studio-map-BWTX2beg.js} +1 -1
  21. package/page/assets/{studio-trace-replay-DG90ujMk.js → studio-trace-replay-BaTeqFr0.js} +1 -1
  22. package/page/assets/{use-one-call-DIEEQ4qF.js → use-one-call-C0-dw_94.js} +1 -1
  23. package/page/index.html +5 -5
  24. package/ui/pan.js +5 -1
  25. package/ui/studio-map.js +7 -7
package/ui/pan.js CHANGED
@@ -21,6 +21,7 @@ export function fieldStart(field, scroller) {
21
21
  top: box.top - port.top + scroller.scrollTop,
22
22
  };
23
23
  }
24
+ const clamp = (value, most) => Math.min(Math.max(value, 0), Math.max(most, 0));
24
25
  /**
25
26
  * Scroll the box around `field` to `at`, once it can: a field that is still opening has no box that
26
27
  * scrolls yet, so it tries again each frame until the scroll lands. Returns what stops the tries.
@@ -32,7 +33,10 @@ export function scrollOnce(field, at) {
32
33
  tries -= 1;
33
34
  const scroller = scrollerOf(field);
34
35
  if (scroller && scroller.scrollWidth > scroller.clientWidth) {
35
- const { left, top } = at(scroller);
36
+ const wanted = at(scroller);
37
+ // A place past either end lands at that end.
38
+ const left = clamp(wanted.left, scroller.scrollWidth - scroller.clientWidth);
39
+ const top = clamp(wanted.top, scroller.scrollHeight - scroller.clientHeight);
36
40
  scroller.scrollTo({ left, top, behavior: 'instant' });
37
41
  if (Math.abs(scroller.scrollLeft - left) < 1 && Math.abs(scroller.scrollTop - top) < 1)
38
42
  return;
package/ui/studio-map.js CHANGED
@@ -212,14 +212,15 @@ function useLit(layout) {
212
212
  return { lit, on, onLines, lights };
213
213
  }
214
214
  /**
215
- * A family, and the map with or without detail, each start from the top left, or as near it as
216
- * shows the node that is open.
215
+ * A family starts from the top left. The map, opened or turned to or from detail, centres the node
216
+ * that is open, or starts from the top left when none is.
217
217
  */
218
218
  function useStart(field, family, open) {
219
219
  const latest = useRef(open.place);
220
220
  latest.current = open.place;
221
221
  // invariant: the sizes are one of two constants, so they change exactly when the detail does.
222
222
  const { sizes } = open;
223
+ // why: Not on a click: the node clicked is already in view, and the map stays where the reader put it.
223
224
  useEffect(() => {
224
225
  const node = field.current;
225
226
  if (!node)
@@ -228,13 +229,12 @@ function useStart(field, family, open) {
228
229
  const at = family === undefined ? place : undefined;
229
230
  // The field starts past the room around it.
230
231
  return scrollOnce(node, (scroller) => {
231
- const hidden = at !== undefined &&
232
- (at.x + sizes.node.width > scroller.clientWidth ||
233
- at.y + at.height > scroller.clientHeight);
234
232
  const { left, top } = fieldStart(node, scroller);
233
+ if (at === undefined)
234
+ return { left, top };
235
235
  return {
236
- left: left + (hidden ? at.x - sizes.padding : 0),
237
- top: top + (hidden ? at.y - sizes.padding - sizes.heading : 0),
236
+ left: left + at.x + sizes.node.width / 2 - scroller.clientWidth / 2,
237
+ top: top + at.y + at.height / 2 - scroller.clientHeight / 2,
238
238
  };
239
239
  });
240
240
  }, [field, family, sizes]);