@ai-matrx/canvas 0.6.1 → 0.7.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.d.cts CHANGED
@@ -1,48 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ComponentType, ReactNode, CSSProperties, ButtonHTMLAttributes, HTMLAttributes, ReactElement } from 'react';
3
- import { P as CanvasRect, d as CanvasPaneId, C as CanvasItemId, a as CanvasWindowId, b as CanvasJson, i as CanvasItem, h as CanvasController, N as CanvasPresentation, S as CanvasSessionEvent, Q as CanvasSessionAttachReason, R as CanvasSessionDetachReason, M as CanvasPreferredTarget, e as CanvasStoreBinding, L as CanvasPersistencePort, D as CanvasErrorSink, G as CanvasLayoutRules, Z as ToggleKindInput, F as CanvasKindVisibility, f as CanvasState } from './toggleKind-DhDmWExm.cjs';
4
-
5
- /** One floating thing. Plain data, so a host can draw it in another process. */
6
- type CanvasFloating = {
7
- readonly type: "tooltip";
8
- readonly text: string;
9
- readonly anchor: CanvasRect;
10
- readonly side: "top" | "bottom";
11
- } | {
12
- readonly type: "drop-indicator";
13
- readonly rect: CanvasRect;
14
- readonly paneId: CanvasPaneId;
15
- } | {
16
- readonly type: "tab-drag";
17
- readonly itemId: CanvasItemId;
18
- readonly title: string;
19
- };
20
- interface CanvasOverlayPort {
21
- /** Shows a floating element above everything (native views included); returns its remover. */
22
- show(element: CanvasFloating): () => void;
23
- }
24
- /** A serializable "…" menu: the package keeps the handlers, a host draws the entries. */
25
- type CanvasMenuEntry = {
26
- readonly type: "item";
27
- readonly id: string;
28
- readonly label: string;
29
- readonly destructive?: boolean;
30
- } | {
31
- readonly type: "separator";
32
- };
33
- /** Shows a menu at `anchor` (e.g. Electron `Menu.popup`); resolves the chosen entry id, or null. */
34
- type CanvasShowMenu = (entries: readonly CanvasMenuEntry[], anchor: CanvasRect) => Promise<string | null>;
35
- /** A native body's frame: window CSS pixels plus the device pixel ratio. */
36
- interface CanvasNativeRect extends CanvasRect {
37
- readonly devicePixelRatio: number;
38
- }
39
- interface CanvasNativeBodyInfo {
40
- /** False while package DOM floats over the canvas (a DOM menu, a tab drag): hide the native view. */
41
- readonly visible: boolean;
42
- readonly windowId: CanvasWindowId;
43
- }
44
- /** Reports where a native body sits; null when it is hidden or gone. Called in the frame the layout changed. */
45
- type CanvasNativeBodyFrame = (itemId: CanvasItemId, rect: CanvasNativeRect | null, info: CanvasNativeBodyInfo) => void;
3
+ import { b as CanvasJson, i as CanvasItem, d as CanvasPaneId, h as CanvasController, a as CanvasWindowId, O as CanvasPresentation, T as CanvasSessionEvent, R as CanvasSessionAttachReason, S as CanvasSessionDetachReason, N as CanvasPreferredTarget, C as CanvasItemId, Q as CanvasRect, e as CanvasStoreBinding, M as CanvasPersistencePort, E as CanvasErrorSink, H as CanvasLayoutRules, _ as ToggleKindInput, G as CanvasKindVisibility, f as CanvasState } from './toggleKind-CAI7pndj.cjs';
46
4
 
47
5
  /**
48
6
  * THE canvas kind registry. A kind is one sort of thing the canvas can show —
@@ -188,6 +146,55 @@ declare function registerCanvasKinds(kinds: readonly AnyCanvasKind[]): () => voi
188
146
  declare function getCanvasKind(id: string): AnyCanvasKind | undefined;
189
147
  declare function listCanvasKinds(): AnyCanvasKind[];
190
148
 
149
+ /**
150
+ * Puts `items` into the pane menu of the tab `itemId` (the body's own
151
+ * actions), after the kind's `menuItems`. The latest `items` are read each
152
+ * time the menu opens; pass `[]` to offer nothing.
153
+ */
154
+ declare function useCanvasMenuItems(itemId: CanvasItemId | string | null | undefined, items: readonly CanvasMenuItem[]): void;
155
+
156
+ /** One floating thing. Plain data, so a host can draw it in another process. */
157
+ type CanvasFloating = {
158
+ readonly type: "tooltip";
159
+ readonly text: string;
160
+ readonly anchor: CanvasRect;
161
+ readonly side: "top" | "bottom";
162
+ } | {
163
+ readonly type: "drop-indicator";
164
+ readonly rect: CanvasRect;
165
+ readonly paneId: CanvasPaneId;
166
+ } | {
167
+ readonly type: "tab-drag";
168
+ readonly itemId: CanvasItemId;
169
+ readonly title: string;
170
+ };
171
+ interface CanvasOverlayPort {
172
+ /** Shows a floating element above everything (native views included); returns its remover. */
173
+ show(element: CanvasFloating): () => void;
174
+ }
175
+ /** A serializable "…" menu: the package keeps the handlers, a host draws the entries. */
176
+ type CanvasMenuEntry = {
177
+ readonly type: "item";
178
+ readonly id: string;
179
+ readonly label: string;
180
+ readonly destructive?: boolean;
181
+ } | {
182
+ readonly type: "separator";
183
+ };
184
+ /** Shows a menu at `anchor` (e.g. Electron `Menu.popup`); resolves the chosen entry id, or null. */
185
+ type CanvasShowMenu = (entries: readonly CanvasMenuEntry[], anchor: CanvasRect) => Promise<string | null>;
186
+ /** A native body's frame: window CSS pixels plus the device pixel ratio. */
187
+ interface CanvasNativeRect extends CanvasRect {
188
+ readonly devicePixelRatio: number;
189
+ }
190
+ interface CanvasNativeBodyInfo {
191
+ /** False while package DOM floats over the canvas (a DOM menu, a tab drag): hide the native view. */
192
+ readonly visible: boolean;
193
+ readonly windowId: CanvasWindowId;
194
+ }
195
+ /** Reports where a native body sits; null when it is hidden or gone. Called in the frame the layout changed. */
196
+ type CanvasNativeBodyFrame = (itemId: CanvasItemId, rect: CanvasNativeRect | null, info: CanvasNativeBodyInfo) => void;
197
+
191
198
  /**
192
199
  * What the host answers ONCE for every kind. Saving, sharing and history are
193
200
  * "handled globally" here; the window ports let a desktop host draw floating
@@ -377,6 +384,32 @@ declare function itemTitle(item: CanvasItem, kind: AnyCanvasKind | undefined): s
377
384
  declare function CanvasPaneView({ paneId }: {
378
385
  paneId: CanvasPaneId;
379
386
  }): react.JSX.Element | null;
387
+ /** A background tab's floor (px): icon + ~7 letters + "…" ("Messag…"). Mirrored to CSS as --mxc-tab-min. */
388
+ declare const CANVAS_TAB_MIN_WIDTH = 88;
389
+ /** The active tab's floor (px): icon + ~8 letters + "…" + its close. Mirrored to CSS as --mxc-tab-active-min. */
390
+ declare const CANVAS_ACTIVE_TAB_MIN_WIDTH = 112;
391
+ /**
392
+ * Which tabs the strip shows at this width: all of them when every tab fits
393
+ * at its floor, else as many as fit — always the active one — and the rest
394
+ * are reached through the "All tabs" menu (Chrome / VS Code). Pure, so the
395
+ * rule is testable without a layout engine. `width <= 0` (not measured yet)
396
+ * shows everything.
397
+ */
398
+ declare function fitCanvasTabs(count: number, activeIndex: number, width: number): {
399
+ start: number;
400
+ end: number;
401
+ overflow: boolean;
402
+ compact: boolean;
403
+ };
404
+
405
+ /**
406
+ * One resize gesture (the canvas edge, a split handle). While it runs:
407
+ * `:root[data-mxc-resizing]` (cursor, no motion, `user-select: none` in
408
+ * styles.css), any selection already on the page is cleared, and the
409
+ * document refuses to START a selection — so dragging an edge across the
410
+ * page never selects its text, whatever CSS the host loaded.
411
+ */
412
+ declare function beginCanvasResize(mode: "" | "col" | "row"): () => void;
380
413
 
381
414
  interface CanvasHeaderButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children" | "title"> {
382
415
  /** Accessible name and tooltip. */
@@ -479,4 +512,4 @@ interface BrowserBarProps {
479
512
  /** A browser's back · forward · reload · address bar, for a kind's leading slot or its body. */
480
513
  declare function BrowserBar({ url, canGoBack, canGoForward, onBack, onForward, onReload, onNavigate, trailing, className }: BrowserBarProps): react.JSX.Element;
481
514
 
482
- export { type AnyCanvasKind, BrowserBar, type BrowserBarProps, type BrowserTab, BrowserTabs, type BrowserTabsProps, CanvasColumn, type CanvasColumnProps, type CanvasFloating, CanvasFrame, CanvasHeaderButton, type CanvasHeaderButtonProps, type CanvasHostPorts, type CanvasKind, type CanvasKindIcon, CanvasKindIcons, type CanvasKindProps, type CanvasLauncherEntry, type CanvasMenuEntry, type CanvasMenuItem, CanvasMenuTrigger, type CanvasNativeBodyFrame, type CanvasNativeBodyInfo, type CanvasNativeRect, type CanvasOverlayPort, CanvasPaneView, CanvasPanel, CanvasPanelEmpty, type CanvasPanelProps, CanvasProvider, type CanvasProviderProps, type CanvasShowMenu, CanvasTab, type CanvasTabProps, type CanvasTabStripMode, CanvasToggle, CanvasWindowScope, canvasSessionKey, defineCanvasKind, getCanvasKind, itemTitle, listCanvasKinds, registerCanvasKind, registerCanvasKinds, useCanvas, useCanvasColumnWidth, useCanvasHostPorts, useCanvasIsPresented, useCanvasKind, useCanvasKindToggle, useCanvasKinds, useCanvasLauncherEntries, useCanvasLauncherEntry, useCanvasNativeBodies, useCanvasPresentation, useCanvasState, useCanvasWindowId, useOptionalCanvas, useOptionalCanvasState };
515
+ export { type AnyCanvasKind, BrowserBar, type BrowserBarProps, type BrowserTab, BrowserTabs, type BrowserTabsProps, CANVAS_ACTIVE_TAB_MIN_WIDTH, CANVAS_TAB_MIN_WIDTH, CanvasColumn, type CanvasColumnProps, type CanvasFloating, CanvasFrame, CanvasHeaderButton, type CanvasHeaderButtonProps, type CanvasHostPorts, type CanvasKind, type CanvasKindIcon, CanvasKindIcons, type CanvasKindProps, type CanvasLauncherEntry, type CanvasMenuEntry, type CanvasMenuItem, CanvasMenuTrigger, type CanvasNativeBodyFrame, type CanvasNativeBodyInfo, type CanvasNativeRect, type CanvasOverlayPort, CanvasPaneView, CanvasPanel, CanvasPanelEmpty, type CanvasPanelProps, CanvasProvider, type CanvasProviderProps, type CanvasShowMenu, CanvasTab, type CanvasTabProps, type CanvasTabStripMode, CanvasToggle, CanvasWindowScope, beginCanvasResize, canvasSessionKey, defineCanvasKind, fitCanvasTabs, getCanvasKind, itemTitle, listCanvasKinds, registerCanvasKind, registerCanvasKinds, useCanvas, useCanvasColumnWidth, useCanvasHostPorts, useCanvasIsPresented, useCanvasKind, useCanvasKindToggle, useCanvasKinds, useCanvasLauncherEntries, useCanvasLauncherEntry, useCanvasMenuItems, useCanvasNativeBodies, useCanvasPresentation, useCanvasState, useCanvasWindowId, useOptionalCanvas, useOptionalCanvasState };
package/dist/react.d.ts CHANGED
@@ -1,48 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ComponentType, ReactNode, CSSProperties, ButtonHTMLAttributes, HTMLAttributes, ReactElement } from 'react';
3
- import { P as CanvasRect, d as CanvasPaneId, C as CanvasItemId, a as CanvasWindowId, b as CanvasJson, i as CanvasItem, h as CanvasController, N as CanvasPresentation, S as CanvasSessionEvent, Q as CanvasSessionAttachReason, R as CanvasSessionDetachReason, M as CanvasPreferredTarget, e as CanvasStoreBinding, L as CanvasPersistencePort, D as CanvasErrorSink, G as CanvasLayoutRules, Z as ToggleKindInput, F as CanvasKindVisibility, f as CanvasState } from './toggleKind-DhDmWExm.js';
4
-
5
- /** One floating thing. Plain data, so a host can draw it in another process. */
6
- type CanvasFloating = {
7
- readonly type: "tooltip";
8
- readonly text: string;
9
- readonly anchor: CanvasRect;
10
- readonly side: "top" | "bottom";
11
- } | {
12
- readonly type: "drop-indicator";
13
- readonly rect: CanvasRect;
14
- readonly paneId: CanvasPaneId;
15
- } | {
16
- readonly type: "tab-drag";
17
- readonly itemId: CanvasItemId;
18
- readonly title: string;
19
- };
20
- interface CanvasOverlayPort {
21
- /** Shows a floating element above everything (native views included); returns its remover. */
22
- show(element: CanvasFloating): () => void;
23
- }
24
- /** A serializable "…" menu: the package keeps the handlers, a host draws the entries. */
25
- type CanvasMenuEntry = {
26
- readonly type: "item";
27
- readonly id: string;
28
- readonly label: string;
29
- readonly destructive?: boolean;
30
- } | {
31
- readonly type: "separator";
32
- };
33
- /** Shows a menu at `anchor` (e.g. Electron `Menu.popup`); resolves the chosen entry id, or null. */
34
- type CanvasShowMenu = (entries: readonly CanvasMenuEntry[], anchor: CanvasRect) => Promise<string | null>;
35
- /** A native body's frame: window CSS pixels plus the device pixel ratio. */
36
- interface CanvasNativeRect extends CanvasRect {
37
- readonly devicePixelRatio: number;
38
- }
39
- interface CanvasNativeBodyInfo {
40
- /** False while package DOM floats over the canvas (a DOM menu, a tab drag): hide the native view. */
41
- readonly visible: boolean;
42
- readonly windowId: CanvasWindowId;
43
- }
44
- /** Reports where a native body sits; null when it is hidden or gone. Called in the frame the layout changed. */
45
- type CanvasNativeBodyFrame = (itemId: CanvasItemId, rect: CanvasNativeRect | null, info: CanvasNativeBodyInfo) => void;
3
+ import { b as CanvasJson, i as CanvasItem, d as CanvasPaneId, h as CanvasController, a as CanvasWindowId, O as CanvasPresentation, T as CanvasSessionEvent, R as CanvasSessionAttachReason, S as CanvasSessionDetachReason, N as CanvasPreferredTarget, C as CanvasItemId, Q as CanvasRect, e as CanvasStoreBinding, M as CanvasPersistencePort, E as CanvasErrorSink, H as CanvasLayoutRules, _ as ToggleKindInput, G as CanvasKindVisibility, f as CanvasState } from './toggleKind-CAI7pndj.js';
46
4
 
47
5
  /**
48
6
  * THE canvas kind registry. A kind is one sort of thing the canvas can show —
@@ -188,6 +146,55 @@ declare function registerCanvasKinds(kinds: readonly AnyCanvasKind[]): () => voi
188
146
  declare function getCanvasKind(id: string): AnyCanvasKind | undefined;
189
147
  declare function listCanvasKinds(): AnyCanvasKind[];
190
148
 
149
+ /**
150
+ * Puts `items` into the pane menu of the tab `itemId` (the body's own
151
+ * actions), after the kind's `menuItems`. The latest `items` are read each
152
+ * time the menu opens; pass `[]` to offer nothing.
153
+ */
154
+ declare function useCanvasMenuItems(itemId: CanvasItemId | string | null | undefined, items: readonly CanvasMenuItem[]): void;
155
+
156
+ /** One floating thing. Plain data, so a host can draw it in another process. */
157
+ type CanvasFloating = {
158
+ readonly type: "tooltip";
159
+ readonly text: string;
160
+ readonly anchor: CanvasRect;
161
+ readonly side: "top" | "bottom";
162
+ } | {
163
+ readonly type: "drop-indicator";
164
+ readonly rect: CanvasRect;
165
+ readonly paneId: CanvasPaneId;
166
+ } | {
167
+ readonly type: "tab-drag";
168
+ readonly itemId: CanvasItemId;
169
+ readonly title: string;
170
+ };
171
+ interface CanvasOverlayPort {
172
+ /** Shows a floating element above everything (native views included); returns its remover. */
173
+ show(element: CanvasFloating): () => void;
174
+ }
175
+ /** A serializable "…" menu: the package keeps the handlers, a host draws the entries. */
176
+ type CanvasMenuEntry = {
177
+ readonly type: "item";
178
+ readonly id: string;
179
+ readonly label: string;
180
+ readonly destructive?: boolean;
181
+ } | {
182
+ readonly type: "separator";
183
+ };
184
+ /** Shows a menu at `anchor` (e.g. Electron `Menu.popup`); resolves the chosen entry id, or null. */
185
+ type CanvasShowMenu = (entries: readonly CanvasMenuEntry[], anchor: CanvasRect) => Promise<string | null>;
186
+ /** A native body's frame: window CSS pixels plus the device pixel ratio. */
187
+ interface CanvasNativeRect extends CanvasRect {
188
+ readonly devicePixelRatio: number;
189
+ }
190
+ interface CanvasNativeBodyInfo {
191
+ /** False while package DOM floats over the canvas (a DOM menu, a tab drag): hide the native view. */
192
+ readonly visible: boolean;
193
+ readonly windowId: CanvasWindowId;
194
+ }
195
+ /** Reports where a native body sits; null when it is hidden or gone. Called in the frame the layout changed. */
196
+ type CanvasNativeBodyFrame = (itemId: CanvasItemId, rect: CanvasNativeRect | null, info: CanvasNativeBodyInfo) => void;
197
+
191
198
  /**
192
199
  * What the host answers ONCE for every kind. Saving, sharing and history are
193
200
  * "handled globally" here; the window ports let a desktop host draw floating
@@ -377,6 +384,32 @@ declare function itemTitle(item: CanvasItem, kind: AnyCanvasKind | undefined): s
377
384
  declare function CanvasPaneView({ paneId }: {
378
385
  paneId: CanvasPaneId;
379
386
  }): react.JSX.Element | null;
387
+ /** A background tab's floor (px): icon + ~7 letters + "…" ("Messag…"). Mirrored to CSS as --mxc-tab-min. */
388
+ declare const CANVAS_TAB_MIN_WIDTH = 88;
389
+ /** The active tab's floor (px): icon + ~8 letters + "…" + its close. Mirrored to CSS as --mxc-tab-active-min. */
390
+ declare const CANVAS_ACTIVE_TAB_MIN_WIDTH = 112;
391
+ /**
392
+ * Which tabs the strip shows at this width: all of them when every tab fits
393
+ * at its floor, else as many as fit — always the active one — and the rest
394
+ * are reached through the "All tabs" menu (Chrome / VS Code). Pure, so the
395
+ * rule is testable without a layout engine. `width <= 0` (not measured yet)
396
+ * shows everything.
397
+ */
398
+ declare function fitCanvasTabs(count: number, activeIndex: number, width: number): {
399
+ start: number;
400
+ end: number;
401
+ overflow: boolean;
402
+ compact: boolean;
403
+ };
404
+
405
+ /**
406
+ * One resize gesture (the canvas edge, a split handle). While it runs:
407
+ * `:root[data-mxc-resizing]` (cursor, no motion, `user-select: none` in
408
+ * styles.css), any selection already on the page is cleared, and the
409
+ * document refuses to START a selection — so dragging an edge across the
410
+ * page never selects its text, whatever CSS the host loaded.
411
+ */
412
+ declare function beginCanvasResize(mode: "" | "col" | "row"): () => void;
380
413
 
381
414
  interface CanvasHeaderButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children" | "title"> {
382
415
  /** Accessible name and tooltip. */
@@ -479,4 +512,4 @@ interface BrowserBarProps {
479
512
  /** A browser's back · forward · reload · address bar, for a kind's leading slot or its body. */
480
513
  declare function BrowserBar({ url, canGoBack, canGoForward, onBack, onForward, onReload, onNavigate, trailing, className }: BrowserBarProps): react.JSX.Element;
481
514
 
482
- export { type AnyCanvasKind, BrowserBar, type BrowserBarProps, type BrowserTab, BrowserTabs, type BrowserTabsProps, CanvasColumn, type CanvasColumnProps, type CanvasFloating, CanvasFrame, CanvasHeaderButton, type CanvasHeaderButtonProps, type CanvasHostPorts, type CanvasKind, type CanvasKindIcon, CanvasKindIcons, type CanvasKindProps, type CanvasLauncherEntry, type CanvasMenuEntry, type CanvasMenuItem, CanvasMenuTrigger, type CanvasNativeBodyFrame, type CanvasNativeBodyInfo, type CanvasNativeRect, type CanvasOverlayPort, CanvasPaneView, CanvasPanel, CanvasPanelEmpty, type CanvasPanelProps, CanvasProvider, type CanvasProviderProps, type CanvasShowMenu, CanvasTab, type CanvasTabProps, type CanvasTabStripMode, CanvasToggle, CanvasWindowScope, canvasSessionKey, defineCanvasKind, getCanvasKind, itemTitle, listCanvasKinds, registerCanvasKind, registerCanvasKinds, useCanvas, useCanvasColumnWidth, useCanvasHostPorts, useCanvasIsPresented, useCanvasKind, useCanvasKindToggle, useCanvasKinds, useCanvasLauncherEntries, useCanvasLauncherEntry, useCanvasNativeBodies, useCanvasPresentation, useCanvasState, useCanvasWindowId, useOptionalCanvas, useOptionalCanvasState };
515
+ export { type AnyCanvasKind, BrowserBar, type BrowserBarProps, type BrowserTab, BrowserTabs, type BrowserTabsProps, CANVAS_ACTIVE_TAB_MIN_WIDTH, CANVAS_TAB_MIN_WIDTH, CanvasColumn, type CanvasColumnProps, type CanvasFloating, CanvasFrame, CanvasHeaderButton, type CanvasHeaderButtonProps, type CanvasHostPorts, type CanvasKind, type CanvasKindIcon, CanvasKindIcons, type CanvasKindProps, type CanvasLauncherEntry, type CanvasMenuEntry, type CanvasMenuItem, CanvasMenuTrigger, type CanvasNativeBodyFrame, type CanvasNativeBodyInfo, type CanvasNativeRect, type CanvasOverlayPort, CanvasPaneView, CanvasPanel, CanvasPanelEmpty, type CanvasPanelProps, CanvasProvider, type CanvasProviderProps, type CanvasShowMenu, CanvasTab, type CanvasTabProps, type CanvasTabStripMode, CanvasToggle, CanvasWindowScope, beginCanvasResize, canvasSessionKey, defineCanvasKind, fitCanvasTabs, getCanvasKind, itemTitle, listCanvasKinds, registerCanvasKind, registerCanvasKinds, useCanvas, useCanvasColumnWidth, useCanvasHostPorts, useCanvasIsPresented, useCanvasKind, useCanvasKindToggle, useCanvasKinds, useCanvasLauncherEntries, useCanvasLauncherEntry, useCanvasMenuItems, useCanvasNativeBodies, useCanvasPresentation, useCanvasState, useCanvasWindowId, useOptionalCanvas, useOptionalCanvasState };