@skydesign/tf 0.2.2 → 0.3.2

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/index.d.ts CHANGED
@@ -10,6 +10,9 @@ import { RefAttributes } from 'react';
10
10
  */
11
11
  export declare function createLayoutConfig(overrides?: Partial<LayoutConfig>): LayoutConfig;
12
12
 
13
+ /** Fill a partial option set with the shared defaults (same as GraphvizRenderer's props). */
14
+ export declare function createRenderOptions(overrides?: Partial<RenderOptions>): RenderOptions;
15
+
13
16
  /**
14
17
  * Decode a JSON string that may be single or double-encoded.
15
18
  * Tries direct parse first, then falls back to double-parse for double-encoded strings.
@@ -180,7 +183,10 @@ export declare interface GraphvizRendererProps {
180
183
  nodeWidth?: number;
181
184
  /** Custom node height in points (default: 64) */
182
185
  nodeHeight?: number;
183
- /** Custom spacing between node columns in points */
186
+ /**
187
+ * Custom spacing between node columns in points. Omit to auto-compute the
188
+ * tightest spacing that fits the widest edge label (minimal graph width).
189
+ */
184
190
  nodeColumnSpacing?: number;
185
191
  /** Forward click events to elements beneath the SVG (while preserving zoom/pan) */
186
192
  clickPassthrough?: boolean;
@@ -233,13 +239,6 @@ export declare interface GraphvizRendererRef {
233
239
  highlightNextEdge: () => void;
234
240
  }
235
241
 
236
- /**
237
- * Render graph using custom SVG based on Graphviz JSON output
238
- * @param maxDepth - Edge depth to filter by (null = show all)
239
- * @param includeLesserDepths - If true, show depth <= maxDepth; if false, show only exact depth
240
- * @param config - Layout configuration
241
- * @returns Object containing zoom behavior and SVG references for imperative control
242
- */
243
242
  /** Pan/zoom transform: g = translate(x,y) scale(k). */
244
243
  export declare interface InitialTransform {
245
244
  x: number;
@@ -314,38 +313,69 @@ declare interface NodeMapping_2 {
314
313
  targetNodeId: string;
315
314
  }
316
315
 
317
- export declare function renderCustomGraph(container: HTMLDivElement, json: GraphvizJson, _nodeMapping?: Record<string, NodeMapping_2>, maxDepth?: number | null, includeLesserDepths?: boolean, config?: LayoutConfig, useOrthogonalRendering?: boolean, svgFontSize?: number, debug?: boolean, selectedEdgeId?: number | null, onEdgeSelect?: (edgeIndex: number | null) => void, nodeWidth?: number, nodeHeight?: number, nodeColumnSpacing?: number, enableWheelZoom?: boolean, extra?: RenderExtraOptions): {
318
- zoomBehavior: d3_2.ZoomBehavior<SVGSVGElement, unknown>;
319
- svgElement: SVGSVGElement;
320
- gElement: SVGGElement;
321
- baseFontSize: number;
322
- viewBoxWidth: number;
323
- edges: EdgeInfo[];
324
- initialTransform: InitialTransform;
325
- };
316
+ /**
317
+ * Render graph using custom SVG based on Graphviz JSON output.
318
+ * @returns Zoom behavior and SVG references for imperative control.
319
+ */
320
+ export declare function renderCustomGraph(container: HTMLDivElement, json: GraphvizJson, options: RenderOptions): RenderResult;
326
321
 
327
- export declare interface RenderExtraOptions {
322
+ /** Complete option set for renderCustomGraph. Build via {@link createRenderOptions}. */
323
+ export declare interface RenderOptions {
324
+ /** Edge-id → source/target mapping supplied by the consumer (reserved for future use). */
325
+ nodeMapping: Record<string, NodeMapping_2>;
326
+ /** Edge depth to filter by (null = show all). */
327
+ maxDepth: number | null;
328
+ /** If true, show depth <= maxDepth; if false, show only the exact depth. */
329
+ includeLesserDepths: boolean;
330
+ /** Layout configuration (spacing, arrow, label metrics). */
331
+ config: LayoutConfig;
332
+ /** Orthogonal edge routing (true) vs direct bezier connections (false). */
333
+ useOrthogonalRendering: boolean;
334
+ /** Base font size used for zoom-scale calculations. */
335
+ svgFontSize: number;
336
+ /** Render debug markers (base-edge highlighting, midpoints, bounds). */
337
+ debug: boolean;
338
+ /** Currently selected edge index, or null. */
339
+ selectedEdgeId: number | null;
340
+ /** Edge selection callback; undefined disables click-to-select. */
341
+ onEdgeSelect: ((edgeIndex: number | null) => void) | undefined;
342
+ /** Node box width in points; null keeps the graphviz-computed width. */
343
+ nodeWidth: number | null;
344
+ /** Node box height in points; null keeps the graphviz-computed height. */
345
+ nodeHeight: number | null;
346
+ /**
347
+ * Fixed column spacing in points; null (default) computes the tightest
348
+ * spacing that fits the widest edge label, minimizing total graph width.
349
+ */
350
+ nodeColumnSpacing: number | null;
351
+ /** Enable wheel/double-click zoom. */
352
+ enableWheelZoom: boolean;
328
353
  /**
329
354
  * Headless (Node / SSR) mode. Skips the d3-zoom attachment and never calls
330
355
  * `getBBox`/`getComputedTextLength`; bakes a deterministic initial transform
331
356
  * straight onto `<g>` so the SVG can be serialized to a string. Geometry is
332
357
  * fully determined by the graphviz JSON, so it matches the browser render.
333
358
  */
334
- headless?: boolean;
359
+ headless: boolean;
335
360
  /**
336
361
  * Use this exact initial transform instead of measuring the fit via
337
362
  * `getBBox`. Pass the `initialTransform` returned from a headless render so
338
363
  * the hydrated interactive graph lines up with the SSR'd SVG pixel-for-pixel
339
364
  * (no jump on handover). When omitted in non-headless mode, the legacy
340
- * getBBox-based fit is used (unchanged behavior for existing callers).
365
+ * getBBox-based fit is used.
341
366
  */
342
- initialTransform?: InitialTransform;
367
+ initialTransform: InitialTransform | undefined;
343
368
  }
344
369
 
345
- /**
346
- * Setup zoom and pan for graphviz native SVG rendering
347
- */
348
- export declare function setupZoomPan(container: HTMLDivElement): void;
370
+ declare interface RenderResult {
371
+ zoomBehavior: d3_2.ZoomBehavior<SVGSVGElement, unknown>;
372
+ svgElement: SVGSVGElement;
373
+ gElement: SVGGElement;
374
+ baseFontSize: number;
375
+ viewBoxWidth: number;
376
+ edges: EdgeInfo[];
377
+ initialTransform: InitialTransform;
378
+ }
349
379
 
350
380
  /**
351
381
  * Text element with optional color and background