@ai-matrx/canvas 0.6.0 → 0.6.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/dist/react.js CHANGED
@@ -1845,7 +1845,7 @@ function useCanvasLauncherEntries() {
1845
1845
  // src/react/CanvasColumn.tsx
1846
1846
  import {
1847
1847
  useEffect as useEffect7,
1848
- useLayoutEffect as useLayoutEffect4,
1848
+ useLayoutEffect as useLayoutEffect5,
1849
1849
  useRef as useRef7,
1850
1850
  useState as useState6,
1851
1851
  useSyncExternalStore as useSyncExternalStore4
@@ -1859,7 +1859,7 @@ import {
1859
1859
  lazy,
1860
1860
  memo,
1861
1861
  useEffect as useEffect5,
1862
- useLayoutEffect as useLayoutEffect2,
1862
+ useLayoutEffect as useLayoutEffect3,
1863
1863
  useMemo as useMemo2,
1864
1864
  useRef as useRef5,
1865
1865
  useState as useState4
@@ -1869,6 +1869,7 @@ import {
1869
1869
  import {
1870
1870
  forwardRef,
1871
1871
  useEffect as useEffect3,
1872
+ useLayoutEffect as useLayoutEffect2,
1872
1873
  useRef as useRef3,
1873
1874
  useState as useState3
1874
1875
  } from "react";
@@ -1974,6 +1975,21 @@ var ChevronRightIcon = (p) => /* @__PURE__ */ jsx3(Glyph, { ...p, children: /* @
1974
1975
 
1975
1976
  // src/react/chrome.tsx
1976
1977
  import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
1978
+ var useIsoLayoutEffect = typeof window === "undefined" ? useEffect3 : useLayoutEffect2;
1979
+ function useTruncated(title) {
1980
+ const ref = useRef3(null);
1981
+ const [truncated, setTruncated] = useState3(false);
1982
+ useIsoLayoutEffect(() => {
1983
+ const el = ref.current;
1984
+ if (!el) return void 0;
1985
+ const check = () => setTruncated(el.scrollWidth - el.clientWidth > 1);
1986
+ check();
1987
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(check);
1988
+ observer?.observe(el);
1989
+ return () => observer?.disconnect();
1990
+ }, [title]);
1991
+ return { ref, truncated };
1992
+ }
1977
1993
  var cx = (...names) => names.filter(Boolean).join(" ");
1978
1994
  function useTooltip(text) {
1979
1995
  const internals = useOptionalCanvasInternals();
@@ -2113,6 +2129,7 @@ function CanvasPanelEmpty({ children, className }) {
2113
2129
  }
2114
2130
  var CanvasTab = forwardRef(function CanvasTab2({ title, icon, note, active, onSelect, onClose, className, onKeyDown, onClick, ...rest }, ref) {
2115
2131
  const shown = title || "New tab";
2132
+ const name = useTruncated(shown);
2116
2133
  return /* @__PURE__ */ jsxs3(
2117
2134
  "div",
2118
2135
  {
@@ -2122,6 +2139,7 @@ var CanvasTab = forwardRef(function CanvasTab2({ title, icon, note, active, onSe
2122
2139
  tabIndex: active ? 0 : -1,
2123
2140
  "data-slot": "browser-tab",
2124
2141
  "data-active": active ? "" : void 0,
2142
+ "data-truncated": name.truncated ? "" : void 0,
2125
2143
  title: shown,
2126
2144
  className: cx("mxc-tab", className),
2127
2145
  ...rest,
@@ -2139,7 +2157,7 @@ var CanvasTab = forwardRef(function CanvasTab2({ title, icon, note, active, onSe
2139
2157
  },
2140
2158
  children: [
2141
2159
  /* @__PURE__ */ jsx4("span", { className: "mxc-tab-icon", children: icon }),
2142
- /* @__PURE__ */ jsx4("span", { className: "mxc-tab-title", children: shown }),
2160
+ /* @__PURE__ */ jsx4("span", { ref: name.ref, className: "mxc-tab-title", children: shown }),
2143
2161
  note ? /* @__PURE__ */ jsx4("span", { className: "mxc-tab-note", "data-slot": "browser-tab-note", children: note }) : null,
2144
2162
  onClose ? /* @__PURE__ */ jsx4(
2145
2163
  "button",
@@ -2471,7 +2489,7 @@ function useSlotSize(slots, paneId) {
2471
2489
 
2472
2490
  // src/react/bodies.tsx
2473
2491
  import { Fragment, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
2474
- var useIsoLayoutEffect = typeof window === "undefined" ? useEffect5 : useLayoutEffect2;
2492
+ var useIsoLayoutEffect2 = typeof window === "undefined" ? useEffect5 : useLayoutEffect3;
2475
2493
  var LAZY = /* @__PURE__ */ Symbol.for("ai-matrx.canvas.lazy");
2476
2494
  function kindComponent(kind) {
2477
2495
  if (kind.component) return kind.component;
@@ -2588,8 +2606,8 @@ function CanvasBodyLayer() {
2588
2606
  const [placement] = useState4(
2589
2607
  () => slots ? createPlacement(() => root.current, slots, () => layer.native.remeasure()) : null
2590
2608
  );
2591
- useIsoLayoutEffect(() => placement?.place());
2592
- useIsoLayoutEffect(() => slots && placement ? slots.subscribe(placement.place) : void 0, [slots, placement]);
2609
+ useIsoLayoutEffect2(() => placement?.place());
2610
+ useIsoLayoutEffect2(() => slots && placement ? slots.subscribe(placement.place) : void 0, [slots, placement]);
2593
2611
  const shape = parseSignature(signature);
2594
2612
  if (!slots || !placement || !shape) return null;
2595
2613
  return /* @__PURE__ */ jsx6("div", { ref: root, className: "mxc-bodies", "data-mxc-bodies": windowId, children: shape.placed.map(({ hostId, itemId, paneId, active, kept }) => /* @__PURE__ */ jsx6(
@@ -2671,7 +2689,7 @@ var BodyHost = memo(function BodyHost2({
2671
2689
  const mounted = kind?.unmountWhenHidden ? visible : everShown;
2672
2690
  const presentation = usePanePresentation(slots, paneId, isFullscreen, paneCount);
2673
2691
  const drop = usePaneDrop(paneId, () => slots.section(paneId));
2674
- useIsoLayoutEffect(() => {
2692
+ useIsoLayoutEffect2(() => {
2675
2693
  const el = element.current;
2676
2694
  if (!placement || !el) return void 0;
2677
2695
  return placement.register(hostId, { element: el, paneId });
@@ -2769,8 +2787,8 @@ function NativeBody({ itemId, windowId, visible, children }) {
2769
2787
  const rect = { ...toCanvasRect(box), devicePixelRatio: window.devicePixelRatio || 1 };
2770
2788
  layer.native.report(itemId, rect, { visible: !layer.isBlocked(), windowId });
2771
2789
  };
2772
- useIsoLayoutEffect(() => measure.current());
2773
- useIsoLayoutEffect(() => {
2790
+ useIsoLayoutEffect2(() => measure.current());
2791
+ useIsoLayoutEffect2(() => {
2774
2792
  const el = ref.current;
2775
2793
  const run = () => measure.current();
2776
2794
  const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(run);
@@ -2823,10 +2841,10 @@ var ItemBoundary = class extends Component {
2823
2841
  };
2824
2842
 
2825
2843
  // src/react/CanvasPane.tsx
2826
- import { Component as Component2, useEffect as useEffect6, useLayoutEffect as useLayoutEffect3, useRef as useRef6, useState as useState5 } from "react";
2844
+ import { Component as Component2, useEffect as useEffect6, useLayoutEffect as useLayoutEffect4, useRef as useRef6, useState as useState5 } from "react";
2827
2845
  import * as Menu from "@radix-ui/react-dropdown-menu";
2828
2846
  import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
2829
- var useIsoLayoutEffect2 = typeof window === "undefined" ? useEffect6 : useLayoutEffect3;
2847
+ var useIsoLayoutEffect3 = typeof window === "undefined" ? useEffect6 : useLayoutEffect4;
2830
2848
  function itemTitle(item, kind) {
2831
2849
  if (item.title) return item.title;
2832
2850
  if (item.kind === CANVAS_LAUNCHER_KIND) return "New tab";
@@ -2883,7 +2901,7 @@ function CanvasPaneView({ paneId }) {
2883
2901
  const bodyRef = useRef6(null);
2884
2902
  const presentation = usePanePresentation(slots, paneId, isFullscreen, paneCount);
2885
2903
  const drop = usePaneDrop(paneId, () => sectionRef.current);
2886
- useIsoLayoutEffect2(() => {
2904
+ useIsoLayoutEffect3(() => {
2887
2905
  const body = bodyRef.current;
2888
2906
  const section = sectionRef.current;
2889
2907
  if (body) slots.set(paneId, body);
@@ -2973,7 +2991,7 @@ function TabStrip({ tabs, activeItemId }) {
2973
2991
  setOverflow((prev) => prev.start === start && prev.end === end ? prev : { start, end });
2974
2992
  };
2975
2993
  const tabKey = tabs.map((tab) => tab.itemId).join("|");
2976
- useIsoLayoutEffect2(() => {
2994
+ useIsoLayoutEffect3(() => {
2977
2995
  const el = strip.current;
2978
2996
  if (!el) return void 0;
2979
2997
  const reveal = () => {
@@ -3149,7 +3167,7 @@ function safeMenu(build) {
3149
3167
 
3150
3168
  // src/react/CanvasColumn.tsx
3151
3169
  import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
3152
- var useIsoLayoutEffect3 = typeof window === "undefined" ? useEffect7 : useLayoutEffect4;
3170
+ var useIsoLayoutEffect4 = typeof window === "undefined" ? useEffect7 : useLayoutEffect5;
3153
3171
  function subscribeViewport(listener) {
3154
3172
  window.addEventListener("resize", listener);
3155
3173
  return () => window.removeEventListener("resize", listener);
@@ -3307,7 +3325,7 @@ function LayoutNodeView({ node }) {
3307
3325
  }
3308
3326
  function useMeasuredWidth(ref, enabled) {
3309
3327
  const [width, setWidth] = useState6(0);
3310
- useIsoLayoutEffect3(() => {
3328
+ useIsoLayoutEffect4(() => {
3311
3329
  const el = ref.current;
3312
3330
  if (!enabled || !el) return;
3313
3331
  setWidth(el.getBoundingClientRect().width);