@codefrydev/svg-engine 0.1.0
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/README.md +57 -0
- package/dist/chunk-KRCGD3CL.js +2794 -0
- package/dist/editor.cjs +5864 -0
- package/dist/editor.d.cts +77 -0
- package/dist/editor.d.ts +77 -0
- package/dist/editor.js +3060 -0
- package/dist/index.cjs +2829 -0
- package/dist/index.d.cts +28 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +24 -0
- package/dist/types-BTYLCn9x.d.cts +100 -0
- package/dist/types-BTYLCn9x.d.ts +100 -0
- package/dist/wc.cjs +1 -0
- package/dist/wc.d.cts +151 -0
- package/dist/wc.d.ts +151 -0
- package/dist/wc.iife.js +354 -0
- package/dist/wc.js +1 -0
- package/package.json +59 -0
package/dist/wc.d.cts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
declare function defineSvgEngineComponents(): void;
|
|
2
|
+
|
|
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
|
+
/** Rotation preset / reference/Rotation.html */
|
|
5
|
+
| "point_mass" | "block_mass" | "com_indicator" | "system_boundary" | "dashed_path" | "rocket" | "uniform_rod" | "solid_disk" | "hoop_ring" | "rolling_body" | "inclined_wedge" | "curve_arrow"
|
|
6
|
+
/** reference/WaveOcillation.html */
|
|
7
|
+
| "mass_box" | "pendulum" | "phasor" | "damped_wave" | "vane_liquid" | "torsion_pendulum" | "standing_wave" | "wave_pulse" | "shm_graph" | "energy_graph" | "strobe_shm" | "wall" | "tuning_fork" | "speaker" | "wavefronts" | "mach_cone" | "beats_graph";
|
|
8
|
+
interface ElementData {
|
|
9
|
+
id: number | string;
|
|
10
|
+
type: ElementType | string;
|
|
11
|
+
x1: number;
|
|
12
|
+
y1: number;
|
|
13
|
+
x2: number;
|
|
14
|
+
y2: number;
|
|
15
|
+
label?: string;
|
|
16
|
+
value?: string;
|
|
17
|
+
color?: string;
|
|
18
|
+
strokeWidth?: number;
|
|
19
|
+
fontSize?: number;
|
|
20
|
+
fillOpacity?: number;
|
|
21
|
+
lineStyle?: "solid" | "dashed" | "dotted" | string;
|
|
22
|
+
curveHeight?: number;
|
|
23
|
+
/** Quadratic/cubic-style control points (e.g. bezier tool). */
|
|
24
|
+
cps?: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
}[];
|
|
28
|
+
showArrow?: boolean;
|
|
29
|
+
compression?: number;
|
|
30
|
+
showHeat?: boolean;
|
|
31
|
+
engineType?: "engine" | "refrigerator" | string;
|
|
32
|
+
efficiency?: number;
|
|
33
|
+
processType?: "isotherm" | "adiabatic" | "isobaric" | "isochoric" | string;
|
|
34
|
+
t1?: number;
|
|
35
|
+
t2?: number;
|
|
36
|
+
showRotations?: boolean;
|
|
37
|
+
steps?: number;
|
|
38
|
+
rotation?: number;
|
|
39
|
+
/** Modern physics / energy level diagrams (reference/ElectroStatics.html). */
|
|
40
|
+
energy?: string;
|
|
41
|
+
/** P–V axes labels (reference/thermo.html). */
|
|
42
|
+
xLabel?: string;
|
|
43
|
+
yLabel?: string;
|
|
44
|
+
/** Point mass, COM marker, pivot scale (reference/Rotation.html). */
|
|
45
|
+
size?: number;
|
|
46
|
+
showVelocity?: boolean;
|
|
47
|
+
showOmega?: boolean;
|
|
48
|
+
/** Spring coil count (reference/Rotation.html spring path). */
|
|
49
|
+
coils?: number;
|
|
50
|
+
/** Wave / SHM (reference/WaveOcillation.html). */
|
|
51
|
+
amplitude?: number;
|
|
52
|
+
loops?: number;
|
|
53
|
+
graphType?: "x" | "v" | "a" | "all" | string;
|
|
54
|
+
domain?: "time" | "position" | string;
|
|
55
|
+
damping?: number;
|
|
56
|
+
frequency?: number;
|
|
57
|
+
beatFreq?: number;
|
|
58
|
+
velocityRatio?: number;
|
|
59
|
+
rings?: number;
|
|
60
|
+
machNumber?: number;
|
|
61
|
+
showForces?: boolean;
|
|
62
|
+
showProjection?: boolean;
|
|
63
|
+
[key: string]: unknown;
|
|
64
|
+
}
|
|
65
|
+
interface ToolDef {
|
|
66
|
+
id: string;
|
|
67
|
+
name: string;
|
|
68
|
+
}
|
|
69
|
+
interface ToolCategory {
|
|
70
|
+
name: string;
|
|
71
|
+
tools: ToolDef[];
|
|
72
|
+
}
|
|
73
|
+
interface Preset {
|
|
74
|
+
name: string;
|
|
75
|
+
elements: ElementData[];
|
|
76
|
+
toolCategories: ToolCategory[];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
declare const presets: {
|
|
80
|
+
mechanics: Preset;
|
|
81
|
+
circuit: Preset;
|
|
82
|
+
thermo: Preset;
|
|
83
|
+
optical: Preset;
|
|
84
|
+
magnetism: Preset;
|
|
85
|
+
light: Preset;
|
|
86
|
+
waves: Preset;
|
|
87
|
+
waveOscillation: Preset;
|
|
88
|
+
rotation: Preset;
|
|
89
|
+
graph: Preset;
|
|
90
|
+
electrostatics: Preset;
|
|
91
|
+
chemistry: Preset;
|
|
92
|
+
mechanical: Preset;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
type EditorWindowMode = "floating" | "inline";
|
|
96
|
+
|
|
97
|
+
type PresetKey = keyof typeof presets;
|
|
98
|
+
declare class CodefrydevSvgEngine extends HTMLElement {
|
|
99
|
+
static observedAttributes: string[];
|
|
100
|
+
private root?;
|
|
101
|
+
private editorRef;
|
|
102
|
+
/** Overrides parsed `data` attribute when set from JS. */
|
|
103
|
+
private _elements;
|
|
104
|
+
private _preset;
|
|
105
|
+
private _mode;
|
|
106
|
+
private _viewMode;
|
|
107
|
+
/** Keeps Editor from resetting on unrelated attribute updates (e.g. title). */
|
|
108
|
+
private committedInitial;
|
|
109
|
+
private pendingReseed;
|
|
110
|
+
connectedCallback(): void;
|
|
111
|
+
disconnectedCallback(): void;
|
|
112
|
+
attributeChangedCallback(name: string): void;
|
|
113
|
+
get elements(): ElementData[];
|
|
114
|
+
set elements(els: ElementData[]);
|
|
115
|
+
get preset(): PresetKey | undefined;
|
|
116
|
+
set preset(v: PresetKey | undefined);
|
|
117
|
+
get mode(): EditorWindowMode;
|
|
118
|
+
set mode(v: EditorWindowMode);
|
|
119
|
+
get viewMode(): boolean;
|
|
120
|
+
set viewMode(v: boolean);
|
|
121
|
+
getData(): ElementData[];
|
|
122
|
+
setData(els: ElementData[]): void;
|
|
123
|
+
toJSON(): string;
|
|
124
|
+
clear(): void;
|
|
125
|
+
minimize(): void;
|
|
126
|
+
maximize(): void;
|
|
127
|
+
restore(): void;
|
|
128
|
+
close(): void;
|
|
129
|
+
private readParsedInitial;
|
|
130
|
+
private render;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
declare class CodefrydevSvgEnginePrev extends HTMLElement {
|
|
134
|
+
static observedAttributes: string[];
|
|
135
|
+
private root?;
|
|
136
|
+
private svgRef;
|
|
137
|
+
private _elements;
|
|
138
|
+
private _showGrid;
|
|
139
|
+
connectedCallback(): void;
|
|
140
|
+
disconnectedCallback(): void;
|
|
141
|
+
attributeChangedCallback(): void;
|
|
142
|
+
get elements(): ElementData[];
|
|
143
|
+
set elements(els: ElementData[]);
|
|
144
|
+
get showGrid(): boolean;
|
|
145
|
+
set showGrid(v: boolean);
|
|
146
|
+
setData(els: ElementData[]): void;
|
|
147
|
+
toSvg(): string;
|
|
148
|
+
private render;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export { CodefrydevSvgEngine, CodefrydevSvgEnginePrev, type PresetKey, defineSvgEngineComponents };
|
package/dist/wc.d.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
declare function defineSvgEngineComponents(): void;
|
|
2
|
+
|
|
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
|
+
/** Rotation preset / reference/Rotation.html */
|
|
5
|
+
| "point_mass" | "block_mass" | "com_indicator" | "system_boundary" | "dashed_path" | "rocket" | "uniform_rod" | "solid_disk" | "hoop_ring" | "rolling_body" | "inclined_wedge" | "curve_arrow"
|
|
6
|
+
/** reference/WaveOcillation.html */
|
|
7
|
+
| "mass_box" | "pendulum" | "phasor" | "damped_wave" | "vane_liquid" | "torsion_pendulum" | "standing_wave" | "wave_pulse" | "shm_graph" | "energy_graph" | "strobe_shm" | "wall" | "tuning_fork" | "speaker" | "wavefronts" | "mach_cone" | "beats_graph";
|
|
8
|
+
interface ElementData {
|
|
9
|
+
id: number | string;
|
|
10
|
+
type: ElementType | string;
|
|
11
|
+
x1: number;
|
|
12
|
+
y1: number;
|
|
13
|
+
x2: number;
|
|
14
|
+
y2: number;
|
|
15
|
+
label?: string;
|
|
16
|
+
value?: string;
|
|
17
|
+
color?: string;
|
|
18
|
+
strokeWidth?: number;
|
|
19
|
+
fontSize?: number;
|
|
20
|
+
fillOpacity?: number;
|
|
21
|
+
lineStyle?: "solid" | "dashed" | "dotted" | string;
|
|
22
|
+
curveHeight?: number;
|
|
23
|
+
/** Quadratic/cubic-style control points (e.g. bezier tool). */
|
|
24
|
+
cps?: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
}[];
|
|
28
|
+
showArrow?: boolean;
|
|
29
|
+
compression?: number;
|
|
30
|
+
showHeat?: boolean;
|
|
31
|
+
engineType?: "engine" | "refrigerator" | string;
|
|
32
|
+
efficiency?: number;
|
|
33
|
+
processType?: "isotherm" | "adiabatic" | "isobaric" | "isochoric" | string;
|
|
34
|
+
t1?: number;
|
|
35
|
+
t2?: number;
|
|
36
|
+
showRotations?: boolean;
|
|
37
|
+
steps?: number;
|
|
38
|
+
rotation?: number;
|
|
39
|
+
/** Modern physics / energy level diagrams (reference/ElectroStatics.html). */
|
|
40
|
+
energy?: string;
|
|
41
|
+
/** P–V axes labels (reference/thermo.html). */
|
|
42
|
+
xLabel?: string;
|
|
43
|
+
yLabel?: string;
|
|
44
|
+
/** Point mass, COM marker, pivot scale (reference/Rotation.html). */
|
|
45
|
+
size?: number;
|
|
46
|
+
showVelocity?: boolean;
|
|
47
|
+
showOmega?: boolean;
|
|
48
|
+
/** Spring coil count (reference/Rotation.html spring path). */
|
|
49
|
+
coils?: number;
|
|
50
|
+
/** Wave / SHM (reference/WaveOcillation.html). */
|
|
51
|
+
amplitude?: number;
|
|
52
|
+
loops?: number;
|
|
53
|
+
graphType?: "x" | "v" | "a" | "all" | string;
|
|
54
|
+
domain?: "time" | "position" | string;
|
|
55
|
+
damping?: number;
|
|
56
|
+
frequency?: number;
|
|
57
|
+
beatFreq?: number;
|
|
58
|
+
velocityRatio?: number;
|
|
59
|
+
rings?: number;
|
|
60
|
+
machNumber?: number;
|
|
61
|
+
showForces?: boolean;
|
|
62
|
+
showProjection?: boolean;
|
|
63
|
+
[key: string]: unknown;
|
|
64
|
+
}
|
|
65
|
+
interface ToolDef {
|
|
66
|
+
id: string;
|
|
67
|
+
name: string;
|
|
68
|
+
}
|
|
69
|
+
interface ToolCategory {
|
|
70
|
+
name: string;
|
|
71
|
+
tools: ToolDef[];
|
|
72
|
+
}
|
|
73
|
+
interface Preset {
|
|
74
|
+
name: string;
|
|
75
|
+
elements: ElementData[];
|
|
76
|
+
toolCategories: ToolCategory[];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
declare const presets: {
|
|
80
|
+
mechanics: Preset;
|
|
81
|
+
circuit: Preset;
|
|
82
|
+
thermo: Preset;
|
|
83
|
+
optical: Preset;
|
|
84
|
+
magnetism: Preset;
|
|
85
|
+
light: Preset;
|
|
86
|
+
waves: Preset;
|
|
87
|
+
waveOscillation: Preset;
|
|
88
|
+
rotation: Preset;
|
|
89
|
+
graph: Preset;
|
|
90
|
+
electrostatics: Preset;
|
|
91
|
+
chemistry: Preset;
|
|
92
|
+
mechanical: Preset;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
type EditorWindowMode = "floating" | "inline";
|
|
96
|
+
|
|
97
|
+
type PresetKey = keyof typeof presets;
|
|
98
|
+
declare class CodefrydevSvgEngine extends HTMLElement {
|
|
99
|
+
static observedAttributes: string[];
|
|
100
|
+
private root?;
|
|
101
|
+
private editorRef;
|
|
102
|
+
/** Overrides parsed `data` attribute when set from JS. */
|
|
103
|
+
private _elements;
|
|
104
|
+
private _preset;
|
|
105
|
+
private _mode;
|
|
106
|
+
private _viewMode;
|
|
107
|
+
/** Keeps Editor from resetting on unrelated attribute updates (e.g. title). */
|
|
108
|
+
private committedInitial;
|
|
109
|
+
private pendingReseed;
|
|
110
|
+
connectedCallback(): void;
|
|
111
|
+
disconnectedCallback(): void;
|
|
112
|
+
attributeChangedCallback(name: string): void;
|
|
113
|
+
get elements(): ElementData[];
|
|
114
|
+
set elements(els: ElementData[]);
|
|
115
|
+
get preset(): PresetKey | undefined;
|
|
116
|
+
set preset(v: PresetKey | undefined);
|
|
117
|
+
get mode(): EditorWindowMode;
|
|
118
|
+
set mode(v: EditorWindowMode);
|
|
119
|
+
get viewMode(): boolean;
|
|
120
|
+
set viewMode(v: boolean);
|
|
121
|
+
getData(): ElementData[];
|
|
122
|
+
setData(els: ElementData[]): void;
|
|
123
|
+
toJSON(): string;
|
|
124
|
+
clear(): void;
|
|
125
|
+
minimize(): void;
|
|
126
|
+
maximize(): void;
|
|
127
|
+
restore(): void;
|
|
128
|
+
close(): void;
|
|
129
|
+
private readParsedInitial;
|
|
130
|
+
private render;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
declare class CodefrydevSvgEnginePrev extends HTMLElement {
|
|
134
|
+
static observedAttributes: string[];
|
|
135
|
+
private root?;
|
|
136
|
+
private svgRef;
|
|
137
|
+
private _elements;
|
|
138
|
+
private _showGrid;
|
|
139
|
+
connectedCallback(): void;
|
|
140
|
+
disconnectedCallback(): void;
|
|
141
|
+
attributeChangedCallback(): void;
|
|
142
|
+
get elements(): ElementData[];
|
|
143
|
+
set elements(els: ElementData[]);
|
|
144
|
+
get showGrid(): boolean;
|
|
145
|
+
set showGrid(v: boolean);
|
|
146
|
+
setData(els: ElementData[]): void;
|
|
147
|
+
toSvg(): string;
|
|
148
|
+
private render;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export { CodefrydevSvgEngine, CodefrydevSvgEnginePrev, type PresetKey, defineSvgEngineComponents };
|