@codefrydev/svg-engine 0.1.0 → 0.1.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.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React$1 from 'react';
2
- import { R as RendererProps, E as ElementRenderer } from './types-BTYLCn9x.cjs';
3
- export { a as Element, b as ElementType, P as Preset, T as ToolCategory, c as ToolDef } from './types-BTYLCn9x.cjs';
2
+ import { R as RendererProps, E as ElementRenderer } from './types-BHUCCfQX.cjs';
3
+ export { a as Element, b as ElementType, P as Preset, c as PresetExample, T as ToolCategory, d as ToolDef } from './types-BHUCCfQX.cjs';
4
4
 
5
5
  declare const Renderer: React$1.FC<RendererProps>;
6
6
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React$1 from 'react';
2
- import { R as RendererProps, E as ElementRenderer } from './types-BTYLCn9x.js';
3
- export { a as Element, b as ElementType, P as Preset, T as ToolCategory, c as ToolDef } from './types-BTYLCn9x.js';
2
+ import { R as RendererProps, E as ElementRenderer } from './types-BHUCCfQX.js';
3
+ export { a as Element, b as ElementType, P as Preset, c as PresetExample, T as ToolCategory, d as ToolDef } from './types-BHUCCfQX.js';
4
4
 
5
5
  declare const Renderer: React$1.FC<RendererProps>;
6
6
 
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  hasRenderer,
10
10
  registerRenderer,
11
11
  snap
12
- } from "./chunk-KRCGD3CL.js";
12
+ } from "./chunk-VCDC4W3X.js";
13
13
  export {
14
14
  GRID_SIZE,
15
15
  Renderer,
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import { MouseEvent, ReactNode } from 'react';
2
2
 
3
3
  type ElementType = "select" | "point" | "text" | "line" | "string" | "surface" | "cart" | "disk" | "com" | "particle" | "pivot" | "dashed" | "dashed_line" | "vector" | "ray" | "ground" | "table_edge" | "block" | "sphere" | "shell" | "cylinder" | "slab" | "semicircle" | "quarter_circle" | "cone" | "curved_wedge" | "incline" | "ladder" | "spring" | "pulley" | "rod" | "hinge" | "arc" | "arc_arrow" | "container" | "pipe" | "liquid" | "orbit" | "wire" | "resistor" | "capacitor" | "inductor" | "diode" | "battery" | "meter_v" | "meter_a" | "piston_cylinder" | "heat_engine" | "conduction_rod" | "pv_axes" | "thermo_process" | "carnot_cycle" | "maxwell_boltzmann" | "diatomic_gas" | "random_walk" | "lens_convex" | "lens_concave" | "mirror_concave" | "mirror_convex" | "prism" | "glass_slab" | "slit_double" | "slit_single" | "photon" | "nucleus" | "wedge" | "dimension" | "axes" | "pole_piece" | "b_field_line" | "b_field_curve" | "bezier" | "b_region_in" | "b_region_out" | "current_wire" | "bar_magnet" | "coil" | "meter" | "ac_source" | "axes_3d" | "charge_pos" | "charge_neg" | "dipole" | "charged_plate_pos" | "charged_plate_neg" | "gaussian_sphere" | "gaussian_cylinder" | "mirror_plane" | "energy_level" | "circle" | "ellipse" | "rectangle" | "angle" | "parabola_v" | "parabola_h" | "hyperbola" | "modulus" | "exponential" | "logarithmic" | "sine_wave" | "step_function" | "shaded_area" | "atom" | "charge_plus" | "charge_minus" | "benzene" | "cyclohexane" | "cyclopentane" | "cyclobutane" | "cyclopropane" | "radical" | "lone_pair"
4
4
  /** Rotation preset / reference/Rotation.html */
@@ -62,10 +62,13 @@ interface ElementData {
62
62
  showProjection?: boolean;
63
63
  [key: string]: unknown;
64
64
  }
65
+ type EditHandleKind = "start" | "end" | "cp";
65
66
  interface RenderContext {
66
67
  isSelected?: boolean;
67
68
  isGhost?: boolean;
68
69
  viewMode?: boolean;
70
+ /** Bound to the current element; implements stopPropagation + drag setup in the editor. */
71
+ onHandlePointerDown?: (e: MouseEvent<SVGElement>, kind: EditHandleKind, cpIndex?: number) => void;
69
72
  }
70
73
  type ElementRenderer = (element: ElementData, context: RenderContext) => ReactNode;
71
74
  interface RendererProps {
@@ -82,6 +85,7 @@ interface RendererProps {
82
85
  onBackgroundMouseUp?: (e: React.MouseEvent) => void;
83
86
  onBackgroundMouseLeave?: (e: React.MouseEvent) => void;
84
87
  onElementMouseDown?: (e: React.MouseEvent, element: ElementData) => void;
88
+ onHandlePointerDown?: (e: React.MouseEvent, element: ElementData, kind: EditHandleKind, cpIndex?: number) => void;
85
89
  }
86
90
  interface ToolDef {
87
91
  id: string;
@@ -91,10 +95,16 @@ interface ToolCategory {
91
95
  name: string;
92
96
  tools: ToolDef[];
93
97
  }
98
+ interface PresetExample {
99
+ name: string;
100
+ elements: ElementData[];
101
+ }
94
102
  interface Preset {
95
103
  name: string;
96
104
  elements: ElementData[];
97
105
  toolCategories: ToolCategory[];
106
+ /** Optional named starter scenes; when set, index 0 should match `elements`. */
107
+ examples?: PresetExample[];
98
108
  }
99
109
 
100
- export type { ElementRenderer as E, Preset as P, RendererProps as R, ToolCategory as T, ElementData as a, ElementType as b, ToolDef as c };
110
+ export type { ElementRenderer as E, Preset as P, RendererProps as R, ToolCategory as T, ElementData as a, ElementType as b, PresetExample as c, ToolDef as d };
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import { MouseEvent, ReactNode } from 'react';
2
2
 
3
3
  type ElementType = "select" | "point" | "text" | "line" | "string" | "surface" | "cart" | "disk" | "com" | "particle" | "pivot" | "dashed" | "dashed_line" | "vector" | "ray" | "ground" | "table_edge" | "block" | "sphere" | "shell" | "cylinder" | "slab" | "semicircle" | "quarter_circle" | "cone" | "curved_wedge" | "incline" | "ladder" | "spring" | "pulley" | "rod" | "hinge" | "arc" | "arc_arrow" | "container" | "pipe" | "liquid" | "orbit" | "wire" | "resistor" | "capacitor" | "inductor" | "diode" | "battery" | "meter_v" | "meter_a" | "piston_cylinder" | "heat_engine" | "conduction_rod" | "pv_axes" | "thermo_process" | "carnot_cycle" | "maxwell_boltzmann" | "diatomic_gas" | "random_walk" | "lens_convex" | "lens_concave" | "mirror_concave" | "mirror_convex" | "prism" | "glass_slab" | "slit_double" | "slit_single" | "photon" | "nucleus" | "wedge" | "dimension" | "axes" | "pole_piece" | "b_field_line" | "b_field_curve" | "bezier" | "b_region_in" | "b_region_out" | "current_wire" | "bar_magnet" | "coil" | "meter" | "ac_source" | "axes_3d" | "charge_pos" | "charge_neg" | "dipole" | "charged_plate_pos" | "charged_plate_neg" | "gaussian_sphere" | "gaussian_cylinder" | "mirror_plane" | "energy_level" | "circle" | "ellipse" | "rectangle" | "angle" | "parabola_v" | "parabola_h" | "hyperbola" | "modulus" | "exponential" | "logarithmic" | "sine_wave" | "step_function" | "shaded_area" | "atom" | "charge_plus" | "charge_minus" | "benzene" | "cyclohexane" | "cyclopentane" | "cyclobutane" | "cyclopropane" | "radical" | "lone_pair"
4
4
  /** Rotation preset / reference/Rotation.html */
@@ -62,10 +62,13 @@ interface ElementData {
62
62
  showProjection?: boolean;
63
63
  [key: string]: unknown;
64
64
  }
65
+ type EditHandleKind = "start" | "end" | "cp";
65
66
  interface RenderContext {
66
67
  isSelected?: boolean;
67
68
  isGhost?: boolean;
68
69
  viewMode?: boolean;
70
+ /** Bound to the current element; implements stopPropagation + drag setup in the editor. */
71
+ onHandlePointerDown?: (e: MouseEvent<SVGElement>, kind: EditHandleKind, cpIndex?: number) => void;
69
72
  }
70
73
  type ElementRenderer = (element: ElementData, context: RenderContext) => ReactNode;
71
74
  interface RendererProps {
@@ -82,6 +85,7 @@ interface RendererProps {
82
85
  onBackgroundMouseUp?: (e: React.MouseEvent) => void;
83
86
  onBackgroundMouseLeave?: (e: React.MouseEvent) => void;
84
87
  onElementMouseDown?: (e: React.MouseEvent, element: ElementData) => void;
88
+ onHandlePointerDown?: (e: React.MouseEvent, element: ElementData, kind: EditHandleKind, cpIndex?: number) => void;
85
89
  }
86
90
  interface ToolDef {
87
91
  id: string;
@@ -91,10 +95,16 @@ interface ToolCategory {
91
95
  name: string;
92
96
  tools: ToolDef[];
93
97
  }
98
+ interface PresetExample {
99
+ name: string;
100
+ elements: ElementData[];
101
+ }
94
102
  interface Preset {
95
103
  name: string;
96
104
  elements: ElementData[];
97
105
  toolCategories: ToolCategory[];
106
+ /** Optional named starter scenes; when set, index 0 should match `elements`. */
107
+ examples?: PresetExample[];
98
108
  }
99
109
 
100
- export type { ElementRenderer as E, Preset as P, RendererProps as R, ToolCategory as T, ElementData as a, ElementType as b, ToolDef as c };
110
+ export type { ElementRenderer as E, Preset as P, RendererProps as R, ToolCategory as T, ElementData as a, ElementType as b, PresetExample as c, ToolDef as d };