@cadit-app/script-params 0.5.2 → 0.5.4
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/exporters.d.ts +107 -0
- package/dist/exporters.d.ts.map +1 -0
- package/dist/exporters.js +29 -0
- package/dist/exporters.js.map +1 -0
- package/dist/index.d.ts +11 -555
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -326
- package/dist/index.js.map +1 -1
- package/dist/params/geometry.d.ts +313 -0
- package/dist/params/geometry.d.ts.map +1 -0
- package/dist/params/geometry.js +207 -0
- package/dist/params/geometry.js.map +1 -0
- package/dist/params/index.d.ts +10 -0
- package/dist/params/index.d.ts.map +1 -0
- package/dist/params/index.js +8 -0
- package/dist/params/index.js.map +1 -0
- package/dist/params/schema.d.ts +95 -0
- package/dist/params/schema.d.ts.map +1 -0
- package/dist/params/schema.js +8 -0
- package/dist/params/schema.js.map +1 -0
- package/dist/params/types.d.ts +239 -0
- package/dist/params/types.d.ts.map +1 -0
- package/dist/params/types.js +8 -0
- package/dist/params/types.js.map +1 -0
- package/dist/sceneOutput.d.ts +424 -0
- package/dist/sceneOutput.d.ts.map +1 -0
- package/dist/sceneOutput.js +92 -0
- package/dist/sceneOutput.js.map +1 -0
- package/dist/script.d.ts +132 -0
- package/dist/script.d.ts.map +1 -0
- package/dist/script.js +117 -0
- package/dist/script.js.map +1 -0
- package/dist/utils.d.ts +115 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +224 -0
- package/dist/utils.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scene output types for CADit scripts.
|
|
3
|
+
*
|
|
4
|
+
* These types allow scripts to output CADit scene objects (2D shapes, 3D primitives)
|
|
5
|
+
* instead of a single code object. Supports full CADit features like twist and sculpt.
|
|
6
|
+
*
|
|
7
|
+
* @example Basic shape output with helper functions
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { defineParams, createSceneOutput, rect, circle } from '@cadit-app/script-params';
|
|
10
|
+
*
|
|
11
|
+
* export default defineParams({
|
|
12
|
+
* params: {
|
|
13
|
+
* size: { type: 'number', default: 20 },
|
|
14
|
+
* },
|
|
15
|
+
* main: (p) => createSceneOutput([
|
|
16
|
+
* rect(p.size, p.size, { position: { x: 0, y: 0 }, height: 10 }),
|
|
17
|
+
* circle(p.size / 2, { position: { x: 40, y: 0 }, twist: 0.5 }),
|
|
18
|
+
* ]),
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example Using sculpt for organic shapes
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { defineParams, createSceneOutput, circle } from '@cadit-app/script-params';
|
|
25
|
+
*
|
|
26
|
+
* export default defineParams({
|
|
27
|
+
* params: {},
|
|
28
|
+
* main: () => createSceneOutput([
|
|
29
|
+
* circle(15, {
|
|
30
|
+
* height: 30,
|
|
31
|
+
* sculpt: [
|
|
32
|
+
* { pos: 0, scale: 0.5 },
|
|
33
|
+
* { pos: 0.5, scale: 1.2 },
|
|
34
|
+
* { pos: 1, scale: 0.5 },
|
|
35
|
+
* ],
|
|
36
|
+
* }),
|
|
37
|
+
* ]),
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
/** A point in 2D space */
|
|
42
|
+
export interface Point2D {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
}
|
|
46
|
+
/** A bezier control point with handles */
|
|
47
|
+
export interface BezierPoint2D extends Point2D {
|
|
48
|
+
/** Incoming handle offset (relative to point) */
|
|
49
|
+
handleIn?: {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
};
|
|
53
|
+
/** Outgoing handle offset (relative to point) */
|
|
54
|
+
handleOut?: {
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
};
|
|
58
|
+
/** Node type for editing behavior */
|
|
59
|
+
nodeType?: 'smooth' | 'corner' | 'auto-smooth';
|
|
60
|
+
}
|
|
61
|
+
/** A path point - either simple or with bezier handles */
|
|
62
|
+
export type PathPoint2D = Point2D | BezierPoint2D;
|
|
63
|
+
/**
|
|
64
|
+
* A sculpt point defines scale at a position along the extrusion height.
|
|
65
|
+
* Used to create vase-like, tapered, or bulging shapes.
|
|
66
|
+
*/
|
|
67
|
+
export interface SculptPoint {
|
|
68
|
+
/** Position along extrusion (0 = bottom, 1 = top) */
|
|
69
|
+
pos: number;
|
|
70
|
+
/** Scale factor at this position (1 = original size) */
|
|
71
|
+
scale: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Color specification - can be hex number, RGB array, or CSS hex string.
|
|
75
|
+
* @example 0xff0000, [255, 0, 0], '#ff0000', '#f00'
|
|
76
|
+
*/
|
|
77
|
+
export type Color = number | [number, number, number] | string;
|
|
78
|
+
/**
|
|
79
|
+
* Base properties shared by all CADit shapes.
|
|
80
|
+
* All properties are optional with sensible defaults.
|
|
81
|
+
*/
|
|
82
|
+
export interface ShapeBase {
|
|
83
|
+
/** Position of shape center */
|
|
84
|
+
position?: Point2D;
|
|
85
|
+
/** Rotation in radians */
|
|
86
|
+
rotation?: number;
|
|
87
|
+
/** Fill color */
|
|
88
|
+
color?: Color;
|
|
89
|
+
/** Whether shape is filled (vs outline). Default: true */
|
|
90
|
+
fill?: boolean;
|
|
91
|
+
/** 3D extrusion height in mm. Default: 2 */
|
|
92
|
+
height?: number;
|
|
93
|
+
/** Z position (vertical offset). Default: 0 */
|
|
94
|
+
z?: number;
|
|
95
|
+
/** Twist angle for 3D extrusion in radians. Default: 0 */
|
|
96
|
+
twist?: number;
|
|
97
|
+
/** Sculpt profile for varying scale along extrusion. Default: uniform */
|
|
98
|
+
sculpt?: SculptPoint[];
|
|
99
|
+
}
|
|
100
|
+
/** Rectangle shape */
|
|
101
|
+
export interface RectInput extends ShapeBase {
|
|
102
|
+
type: 'RECT';
|
|
103
|
+
width: number;
|
|
104
|
+
rectHeight: number;
|
|
105
|
+
}
|
|
106
|
+
/** Triangle shape */
|
|
107
|
+
export interface TriangleInput extends ShapeBase {
|
|
108
|
+
type: 'TRIANGLE';
|
|
109
|
+
width: number;
|
|
110
|
+
triangleHeight: number;
|
|
111
|
+
}
|
|
112
|
+
/** Star shape */
|
|
113
|
+
export interface StarInput extends ShapeBase {
|
|
114
|
+
type: 'STAR';
|
|
115
|
+
rays: number;
|
|
116
|
+
outerRadius: number;
|
|
117
|
+
innerRadius: number;
|
|
118
|
+
}
|
|
119
|
+
/** Circle shape */
|
|
120
|
+
export interface CircleInput extends ShapeBase {
|
|
121
|
+
type: 'CIRCLE';
|
|
122
|
+
radius: number;
|
|
123
|
+
segments?: number;
|
|
124
|
+
}
|
|
125
|
+
/** Regular polygon (hexagon, pentagon, etc.) */
|
|
126
|
+
export interface PolyPointsInput extends ShapeBase {
|
|
127
|
+
type: 'POLY_POINTS';
|
|
128
|
+
numPoints: number;
|
|
129
|
+
radius: number;
|
|
130
|
+
}
|
|
131
|
+
/** Heart shape */
|
|
132
|
+
export interface HeartInput extends ShapeBase {
|
|
133
|
+
type: 'HEART';
|
|
134
|
+
width: number;
|
|
135
|
+
heartHeight: number;
|
|
136
|
+
}
|
|
137
|
+
/** Custom polygon from points */
|
|
138
|
+
export interface PolygonInput extends ShapeBase {
|
|
139
|
+
type: 'POLYGON';
|
|
140
|
+
points: PathPoint2D[];
|
|
141
|
+
holes?: PathPoint2D[][];
|
|
142
|
+
}
|
|
143
|
+
/** Compound path (similar to polygon) */
|
|
144
|
+
export interface CompoundPathInput extends ShapeBase {
|
|
145
|
+
type: 'COMPOUND_PATH';
|
|
146
|
+
points: PathPoint2D[];
|
|
147
|
+
holes?: PathPoint2D[][];
|
|
148
|
+
}
|
|
149
|
+
/** Text shape */
|
|
150
|
+
export interface TextInput extends ShapeBase {
|
|
151
|
+
type: 'TEXT';
|
|
152
|
+
text: string;
|
|
153
|
+
fontFamily?: string;
|
|
154
|
+
fontStyle?: string;
|
|
155
|
+
fontWeight?: number;
|
|
156
|
+
}
|
|
157
|
+
/** Union of all CADit shape inputs */
|
|
158
|
+
export type ShapeInput = RectInput | TriangleInput | StarInput | CircleInput | PolyPointsInput | HeartInput | PolygonInput | CompoundPathInput | TextInput;
|
|
159
|
+
/** Alias for ShapeInput */
|
|
160
|
+
export type ShapeDefinition = ShapeInput;
|
|
161
|
+
/** Create a rectangle */
|
|
162
|
+
export declare function rect(width: number, rectHeight: number, options?: Omit<RectInput, 'type' | 'width' | 'rectHeight'>): RectInput;
|
|
163
|
+
/** Create a circle */
|
|
164
|
+
export declare function circle(radius: number, options?: Omit<CircleInput, 'type' | 'radius'>): CircleInput;
|
|
165
|
+
/** Create a star */
|
|
166
|
+
export declare function star(outerRadius: number, innerRadius: number, rays: number, options?: Omit<StarInput, 'type' | 'rays' | 'outerRadius' | 'innerRadius'>): StarInput;
|
|
167
|
+
/** Create a triangle */
|
|
168
|
+
export declare function triangle(width: number, triangleHeight: number, options?: Omit<TriangleInput, 'type' | 'width' | 'triangleHeight'>): TriangleInput;
|
|
169
|
+
/** Create a regular polygon (hexagon, pentagon, etc.) */
|
|
170
|
+
export declare function regularPolygon(numPoints: number, radius: number, options?: Omit<PolyPointsInput, 'type' | 'numPoints' | 'radius'>): PolyPointsInput;
|
|
171
|
+
/** Create a heart shape */
|
|
172
|
+
export declare function heart(width: number, heartHeight: number, options?: Omit<HeartInput, 'type' | 'width' | 'heartHeight'>): HeartInput;
|
|
173
|
+
/** Create a custom polygon from points */
|
|
174
|
+
export declare function polygon(points: PathPoint2D[], options?: Omit<PolygonInput, 'type' | 'points'>): PolygonInput;
|
|
175
|
+
/** Create a text shape */
|
|
176
|
+
export declare function text(content: string, options?: Omit<TextInput, 'type' | 'text'>): TextInput;
|
|
177
|
+
/**
|
|
178
|
+
* A 2D polygon scene object (legacy format).
|
|
179
|
+
*/
|
|
180
|
+
export interface SceneObject2DPolygon {
|
|
181
|
+
type: '2d-polygon';
|
|
182
|
+
points: (Point2D | BezierPoint2D)[];
|
|
183
|
+
holes?: (Point2D | BezierPoint2D)[][];
|
|
184
|
+
position?: {
|
|
185
|
+
x?: number;
|
|
186
|
+
y?: number;
|
|
187
|
+
z?: number;
|
|
188
|
+
};
|
|
189
|
+
rotation?: number;
|
|
190
|
+
scale?: number | {
|
|
191
|
+
x: number;
|
|
192
|
+
y: number;
|
|
193
|
+
};
|
|
194
|
+
fillColor?: string | [number, number, number];
|
|
195
|
+
strokeColor?: string | [number, number, number];
|
|
196
|
+
strokeWidth?: number;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* A 2D rectangle scene object (legacy format).
|
|
200
|
+
*/
|
|
201
|
+
export interface SceneObject2DRect {
|
|
202
|
+
type: '2d-rect';
|
|
203
|
+
/** Width of the rectangle */
|
|
204
|
+
width: number;
|
|
205
|
+
/** Height of the rectangle */
|
|
206
|
+
height: number;
|
|
207
|
+
/** Corner radius for rounded corners */
|
|
208
|
+
cornerRadius?: number;
|
|
209
|
+
/** Position (center of rectangle) */
|
|
210
|
+
position?: {
|
|
211
|
+
x?: number;
|
|
212
|
+
y?: number;
|
|
213
|
+
z?: number;
|
|
214
|
+
};
|
|
215
|
+
/** Rotation in radians */
|
|
216
|
+
rotation?: number;
|
|
217
|
+
/** Fill color */
|
|
218
|
+
fillColor?: string | [number, number, number];
|
|
219
|
+
/** Stroke color */
|
|
220
|
+
strokeColor?: string | [number, number, number];
|
|
221
|
+
/** Stroke width */
|
|
222
|
+
strokeWidth?: number;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* A 2D circle scene object.
|
|
226
|
+
*/
|
|
227
|
+
export interface SceneObject2DCircle {
|
|
228
|
+
type: '2d-circle';
|
|
229
|
+
/** Radius of the circle */
|
|
230
|
+
radius: number;
|
|
231
|
+
/** Number of segments (more = smoother, default 32) */
|
|
232
|
+
segments?: number;
|
|
233
|
+
/** Position (center of circle) */
|
|
234
|
+
position?: {
|
|
235
|
+
x?: number;
|
|
236
|
+
y?: number;
|
|
237
|
+
z?: number;
|
|
238
|
+
};
|
|
239
|
+
/** Fill color */
|
|
240
|
+
fillColor?: string | [number, number, number];
|
|
241
|
+
/** Stroke color */
|
|
242
|
+
strokeColor?: string | [number, number, number];
|
|
243
|
+
/** Stroke width */
|
|
244
|
+
strokeWidth?: number;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* A 2D ellipse scene object.
|
|
248
|
+
*/
|
|
249
|
+
export interface SceneObject2DEllipse {
|
|
250
|
+
type: '2d-ellipse';
|
|
251
|
+
/** Horizontal radius */
|
|
252
|
+
radiusX: number;
|
|
253
|
+
/** Vertical radius */
|
|
254
|
+
radiusY: number;
|
|
255
|
+
/** Number of segments (more = smoother, default 32) */
|
|
256
|
+
segments?: number;
|
|
257
|
+
/** Position (center of ellipse) */
|
|
258
|
+
position?: {
|
|
259
|
+
x?: number;
|
|
260
|
+
y?: number;
|
|
261
|
+
z?: number;
|
|
262
|
+
};
|
|
263
|
+
/** Rotation in radians */
|
|
264
|
+
rotation?: number;
|
|
265
|
+
/** Fill color */
|
|
266
|
+
fillColor?: string | [number, number, number];
|
|
267
|
+
/** Stroke color */
|
|
268
|
+
strokeColor?: string | [number, number, number];
|
|
269
|
+
/** Stroke width */
|
|
270
|
+
strokeWidth?: number;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* A 3D box scene object.
|
|
274
|
+
*/
|
|
275
|
+
export interface SceneObject3DBox {
|
|
276
|
+
type: '3d-box';
|
|
277
|
+
/** Width (X dimension) */
|
|
278
|
+
width: number;
|
|
279
|
+
/** Height (Y dimension) */
|
|
280
|
+
height: number;
|
|
281
|
+
/** Depth (Z dimension) */
|
|
282
|
+
depth: number;
|
|
283
|
+
/** Position (center of box) */
|
|
284
|
+
position?: {
|
|
285
|
+
x?: number;
|
|
286
|
+
y?: number;
|
|
287
|
+
z?: number;
|
|
288
|
+
};
|
|
289
|
+
/** Rotation in radians (Euler angles) */
|
|
290
|
+
rotation?: {
|
|
291
|
+
x?: number;
|
|
292
|
+
y?: number;
|
|
293
|
+
z?: number;
|
|
294
|
+
};
|
|
295
|
+
/** Scale factor */
|
|
296
|
+
scale?: number | {
|
|
297
|
+
x: number;
|
|
298
|
+
y: number;
|
|
299
|
+
z: number;
|
|
300
|
+
};
|
|
301
|
+
/** Material color */
|
|
302
|
+
color?: string | [number, number, number];
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* A 3D cylinder scene object.
|
|
306
|
+
*/
|
|
307
|
+
export interface SceneObject3DCylinder {
|
|
308
|
+
type: '3d-cylinder';
|
|
309
|
+
/** Radius at the top */
|
|
310
|
+
radiusTop?: number;
|
|
311
|
+
/** Radius at the bottom */
|
|
312
|
+
radiusBottom?: number;
|
|
313
|
+
/** Radius (same as radiusTop and radiusBottom, used when both are equal) */
|
|
314
|
+
radius?: number;
|
|
315
|
+
/** Height of the cylinder */
|
|
316
|
+
height: number;
|
|
317
|
+
/** Number of radial segments (default 32) */
|
|
318
|
+
segments?: number;
|
|
319
|
+
/** Position (center of cylinder) */
|
|
320
|
+
position?: {
|
|
321
|
+
x?: number;
|
|
322
|
+
y?: number;
|
|
323
|
+
z?: number;
|
|
324
|
+
};
|
|
325
|
+
/** Rotation in radians */
|
|
326
|
+
rotation?: {
|
|
327
|
+
x?: number;
|
|
328
|
+
y?: number;
|
|
329
|
+
z?: number;
|
|
330
|
+
};
|
|
331
|
+
/** Material color */
|
|
332
|
+
color?: string | [number, number, number];
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* A 3D sphere scene object.
|
|
336
|
+
*/
|
|
337
|
+
export interface SceneObject3DSphere {
|
|
338
|
+
type: '3d-sphere';
|
|
339
|
+
/** Radius of the sphere */
|
|
340
|
+
radius: number;
|
|
341
|
+
/** Number of segments (default 32) */
|
|
342
|
+
segments?: number;
|
|
343
|
+
/** Position (center of sphere) */
|
|
344
|
+
position?: {
|
|
345
|
+
x?: number;
|
|
346
|
+
y?: number;
|
|
347
|
+
z?: number;
|
|
348
|
+
};
|
|
349
|
+
/** Material color */
|
|
350
|
+
color?: string | [number, number, number];
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* A 3D extrusion from a 2D shape.
|
|
354
|
+
*/
|
|
355
|
+
export interface SceneObject3DExtrusion {
|
|
356
|
+
type: '3d-extrusion';
|
|
357
|
+
/** The 2D shape to extrude */
|
|
358
|
+
shape: SceneObject2DPolygon | SceneObject2DRect | SceneObject2DCircle | SceneObject2DEllipse;
|
|
359
|
+
/** Extrusion height */
|
|
360
|
+
height: number;
|
|
361
|
+
/** Position */
|
|
362
|
+
position?: {
|
|
363
|
+
x?: number;
|
|
364
|
+
y?: number;
|
|
365
|
+
z?: number;
|
|
366
|
+
};
|
|
367
|
+
/** Rotation in radians */
|
|
368
|
+
rotation?: {
|
|
369
|
+
x?: number;
|
|
370
|
+
y?: number;
|
|
371
|
+
z?: number;
|
|
372
|
+
};
|
|
373
|
+
/** Material color */
|
|
374
|
+
color?: string | [number, number, number];
|
|
375
|
+
}
|
|
376
|
+
/** All legacy 2D scene object types */
|
|
377
|
+
export type SceneObject2D = SceneObject2DPolygon | SceneObject2DRect | SceneObject2DCircle | SceneObject2DEllipse;
|
|
378
|
+
/** All legacy 3D scene object types */
|
|
379
|
+
export type SceneObject3D = SceneObject3DBox | SceneObject3DCylinder | SceneObject3DSphere | SceneObject3DExtrusion;
|
|
380
|
+
/** Any legacy scene object */
|
|
381
|
+
export type SceneObject = SceneObject2D | SceneObject3D;
|
|
382
|
+
/** Any shape that can be output (CADit native or legacy) */
|
|
383
|
+
export type AnyShape = ShapeInput | SceneObject;
|
|
384
|
+
/**
|
|
385
|
+
* The result of a scene output script.
|
|
386
|
+
* Contains an array of shapes to be added to the CADit scene.
|
|
387
|
+
*/
|
|
388
|
+
export interface SceneOutput {
|
|
389
|
+
/** Marker to identify this as a scene output result */
|
|
390
|
+
readonly __sceneOutput: true;
|
|
391
|
+
/** The shapes to add to the scene */
|
|
392
|
+
objects: AnyShape[];
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Create a scene output result from shapes.
|
|
396
|
+
*
|
|
397
|
+
* Accepts either:
|
|
398
|
+
* - An array of shapes (recommended): `createSceneOutput([rect(...), circle(...)])`
|
|
399
|
+
* - Legacy object format: `createSceneOutput({ objects: [...] })`
|
|
400
|
+
*
|
|
401
|
+
* @example Using helper functions (recommended)
|
|
402
|
+
* ```typescript
|
|
403
|
+
* import { defineParams, createSceneOutput, rect, circle } from '@cadit-app/script-params';
|
|
404
|
+
*
|
|
405
|
+
* export default defineParams({
|
|
406
|
+
* params: {
|
|
407
|
+
* size: { type: 'number', default: 20 },
|
|
408
|
+
* },
|
|
409
|
+
* main: (p) => createSceneOutput([
|
|
410
|
+
* rect(p.size, p.size, { height: 10 }),
|
|
411
|
+
* circle(p.size / 2, { position: { x: 40, y: 0 } }),
|
|
412
|
+
* ]),
|
|
413
|
+
* });
|
|
414
|
+
* ```
|
|
415
|
+
*/
|
|
416
|
+
export declare function createSceneOutput(shapes: AnyShape[]): SceneOutput;
|
|
417
|
+
export declare function createSceneOutput(config: {
|
|
418
|
+
objects: AnyShape[];
|
|
419
|
+
}): SceneOutput;
|
|
420
|
+
/**
|
|
421
|
+
* Type guard to check if a value is a SceneOutput.
|
|
422
|
+
*/
|
|
423
|
+
export declare function isSceneOutput(value: unknown): value is SceneOutput;
|
|
424
|
+
//# sourceMappingURL=sceneOutput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sceneOutput.d.ts","sourceRoot":"","sources":["../src/sceneOutput.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAMH,0BAA0B;AAC1B,MAAM,WAAW,OAAO;IACtB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,0CAA0C;AAC1C,MAAM,WAAW,aAAc,SAAQ,O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,EAAE,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,WAAW,CAAC;AACnE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,QAAQ,EAAE,CAAA;CAAE,GAAG,WAAW,CAAC;AAShF;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAOlE"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scene output types for CADit scripts.
|
|
3
|
+
*
|
|
4
|
+
* These types allow scripts to output CADit scene objects (2D shapes, 3D primitives)
|
|
5
|
+
* instead of a single code object. Supports full CADit features like twist and sculpt.
|
|
6
|
+
*
|
|
7
|
+
* @example Basic shape output with helper functions
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { defineParams, createSceneOutput, rect, circle } from '@cadit-app/script-params';
|
|
10
|
+
*
|
|
11
|
+
* export default defineParams({
|
|
12
|
+
* params: {
|
|
13
|
+
* size: { type: 'number', default: 20 },
|
|
14
|
+
* },
|
|
15
|
+
* main: (p) => createSceneOutput([
|
|
16
|
+
* rect(p.size, p.size, { position: { x: 0, y: 0 }, height: 10 }),
|
|
17
|
+
* circle(p.size / 2, { position: { x: 40, y: 0 }, twist: 0.5 }),
|
|
18
|
+
* ]),
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example Using sculpt for organic shapes
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { defineParams, createSceneOutput, circle } from '@cadit-app/script-params';
|
|
25
|
+
*
|
|
26
|
+
* export default defineParams({
|
|
27
|
+
* params: {},
|
|
28
|
+
* main: () => createSceneOutput([
|
|
29
|
+
* circle(15, {
|
|
30
|
+
* height: 30,
|
|
31
|
+
* sculpt: [
|
|
32
|
+
* { pos: 0, scale: 0.5 },
|
|
33
|
+
* { pos: 0.5, scale: 1.2 },
|
|
34
|
+
* { pos: 1, scale: 0.5 },
|
|
35
|
+
* ],
|
|
36
|
+
* }),
|
|
37
|
+
* ]),
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
// =============================================================================
|
|
42
|
+
// Helper Functions for Creating Shapes
|
|
43
|
+
// =============================================================================
|
|
44
|
+
/** Create a rectangle */
|
|
45
|
+
export function rect(width, rectHeight, options = {}) {
|
|
46
|
+
return { type: 'RECT', width, rectHeight, ...options };
|
|
47
|
+
}
|
|
48
|
+
/** Create a circle */
|
|
49
|
+
export function circle(radius, options = {}) {
|
|
50
|
+
return { type: 'CIRCLE', radius, ...options };
|
|
51
|
+
}
|
|
52
|
+
/** Create a star */
|
|
53
|
+
export function star(outerRadius, innerRadius, rays, options = {}) {
|
|
54
|
+
return { type: 'STAR', rays, outerRadius, innerRadius, ...options };
|
|
55
|
+
}
|
|
56
|
+
/** Create a triangle */
|
|
57
|
+
export function triangle(width, triangleHeight, options = {}) {
|
|
58
|
+
return { type: 'TRIANGLE', width, triangleHeight, ...options };
|
|
59
|
+
}
|
|
60
|
+
/** Create a regular polygon (hexagon, pentagon, etc.) */
|
|
61
|
+
export function regularPolygon(numPoints, radius, options = {}) {
|
|
62
|
+
return { type: 'POLY_POINTS', numPoints, radius, ...options };
|
|
63
|
+
}
|
|
64
|
+
/** Create a heart shape */
|
|
65
|
+
export function heart(width, heartHeight, options = {}) {
|
|
66
|
+
return { type: 'HEART', width, heartHeight, ...options };
|
|
67
|
+
}
|
|
68
|
+
/** Create a custom polygon from points */
|
|
69
|
+
export function polygon(points, options = {}) {
|
|
70
|
+
return { type: 'POLYGON', points, ...options };
|
|
71
|
+
}
|
|
72
|
+
/** Create a text shape */
|
|
73
|
+
export function text(content, options = {}) {
|
|
74
|
+
return { type: 'TEXT', text: content, ...options };
|
|
75
|
+
}
|
|
76
|
+
export function createSceneOutput(input) {
|
|
77
|
+
const objects = Array.isArray(input) ? input : input.objects;
|
|
78
|
+
return {
|
|
79
|
+
__sceneOutput: true,
|
|
80
|
+
objects,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Type guard to check if a value is a SceneOutput.
|
|
85
|
+
*/
|
|
86
|
+
export function isSceneOutput(value) {
|
|
87
|
+
return (typeof value === 'object' &&
|
|
88
|
+
value !== null &&
|
|
89
|
+
'__sceneOutput' in value &&
|
|
90
|
+
value.__sceneOutput === true);
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=sceneOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sceneOutput.js","sourceRoot":"","sources":["../src/sceneOutput.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AA0JH,gFAAgF;AAChF,uCAAuC;AACvC,gFAAgF;AAEhF,yBAAyB;AACzB,MAAM,UAAU,IAAI,CAClB,KAAa,EACb,UAAkB,EAClB,UAA4D,EAAE;IAE9D,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,OAAO,EAAE,CAAC;AACzD,CAAC;AAED,sBAAsB;AACtB,MAAM,UAAU,MAAM,CACpB,MAAc,EACd,UAAgD,EAAE;IAElD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC;AAChD,CAAC;AAED,oBAAoB;AACpB,MAAM,UAAU,IAAI,CAClB,WAAmB,EACnB,WAAmB,EACnB,IAAY,EACZ,UAA4E,EAAE;IAE9E,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,OAAO,EAAE,CAAC;AACtE,CAAC;AAED,wBAAwB;AACxB,MAAM,UAAU,QAAQ,CACtB,KAAa,EACb,cAAsB,EACtB,UAAoE,EAAE;IAEtE,OAAO,EAAE,IAAI,EAAE,UA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ts
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Script module types and core functions (defineParams, createMain).
|
|
3
|
+
*
|
|
4
|
+
* This module provides the main API for defining parametric scripts.
|
|
5
|
+
*/
|
|
6
|
+
import type { ParamSchema, Params } from './params';
|
|
7
|
+
import type { Exporters } from './exporters';
|
|
8
|
+
/**
|
|
9
|
+
* Configuration object for defineParams when using named properties.
|
|
10
|
+
* All options are named for clarity and extensibility.
|
|
11
|
+
*/
|
|
12
|
+
export interface ScriptConfig<S extends ParamSchema, R = unknown> {
|
|
13
|
+
/** The parameter schema defining all inputs. */
|
|
14
|
+
params: S;
|
|
15
|
+
/** Optional main function that generates geometry. */
|
|
16
|
+
main?: (params: Params<S>) => R;
|
|
17
|
+
/** Optional exporters for custom download formats (SVG, PNG, etc.). */
|
|
18
|
+
exporters?: Exporters<Params<S>>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The result returned by defineParams.
|
|
22
|
+
* Contains the schema (for UI), optional exporters, and is optionally callable.
|
|
23
|
+
*/
|
|
24
|
+
export interface ScriptModule<S extends ParamSchema, R = unknown> {
|
|
25
|
+
/** The parameter schema for UI generation. */
|
|
26
|
+
params: S;
|
|
27
|
+
/** Optional exporters for custom download formats. */
|
|
28
|
+
exporters?: Exporters<Params<S>>;
|
|
29
|
+
/**
|
|
30
|
+
* Execute the script with optional parameter overrides.
|
|
31
|
+
* Missing parameters use their default values.
|
|
32
|
+
* Only available if a main function was provided.
|
|
33
|
+
*/
|
|
34
|
+
(inputParams?: Partial<Params<S>>): R;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Infer the params type from a ScriptModule.
|
|
38
|
+
* Use this to get the typed params for use in exporters defined in separate files.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* // In main.ts
|
|
43
|
+
* const script = defineParams({
|
|
44
|
+
* params: {
|
|
45
|
+
* size: { type: 'number', default: 10 },
|
|
46
|
+
* label: { type: 'text', default: 'Hello' },
|
|
47
|
+
* },
|
|
48
|
+
* main: (p) => { ... },
|
|
49
|
+
* });
|
|
50
|
+
* export default script;
|
|
51
|
+
*
|
|
52
|
+
* // In pngExport.ts
|
|
53
|
+
* import type { Exporter, InferParams } from '@cadit-app/script-params';
|
|
54
|
+
* import type script from './main';
|
|
55
|
+
*
|
|
56
|
+
* type QrCodeParams = InferParams<typeof script>;
|
|
57
|
+
* // { size: number; label: string }
|
|
58
|
+
*
|
|
59
|
+
* export const pngExporter: Exporter<QrCodeParams> = {
|
|
60
|
+
* name: 'PNG',
|
|
61
|
+
* export: (params) => { ... }, // params.size is number, params.label is string
|
|
62
|
+
* };
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export type InferParams<T> = T extends ScriptModule<infer S, unknown> ? Params<S> : T extends {
|
|
66
|
+
params: infer S extends ParamSchema;
|
|
67
|
+
} ? Params<S> : never;
|
|
68
|
+
/**
|
|
69
|
+
* Build default values object from a schema.
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
declare function buildDefaults<S extends ParamSchema>(schema: S): Params<S>;
|
|
73
|
+
/**
|
|
74
|
+
* Define parameters for a parametric script.
|
|
75
|
+
*
|
|
76
|
+
* Pass a config object with `params` (required), and optionally `main` and `exporters`.
|
|
77
|
+
*
|
|
78
|
+
* @example Basic usage
|
|
79
|
+
* ```typescript
|
|
80
|
+
* export default defineParams({
|
|
81
|
+
* params: {
|
|
82
|
+
* size: { type: 'number', default: 10 },
|
|
83
|
+
* },
|
|
84
|
+
* main: (params) => Manifold.cube([params.size, params.size, params.size]),
|
|
85
|
+
* });
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @example With exporters
|
|
89
|
+
* ```typescript
|
|
90
|
+
* export default defineParams({
|
|
91
|
+
* params: {
|
|
92
|
+
* size: { type: 'number', default: 10 },
|
|
93
|
+
* },
|
|
94
|
+
* exporters: {
|
|
95
|
+
* svg: { name: 'SVG', export: (p) => svgExport(p) },
|
|
96
|
+
* png: { name: 'PNG', export: (p) => pngExport(p) },
|
|
97
|
+
* },
|
|
98
|
+
* main: (params) => Manifold.cube([params.size, params.size, params.size]),
|
|
99
|
+
* });
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @example Without main (add main separately with createMain)
|
|
103
|
+
* ```typescript
|
|
104
|
+
* const script = defineParams({
|
|
105
|
+
* params: { size: { type: 'number', default: 10 } },
|
|
106
|
+
* exporters: { svg: svgExporter },
|
|
107
|
+
* });
|
|
108
|
+
* export default createMain(script, myMainFunction);
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export declare function defineParams<const S extends ParamSchema, R = unknown>(config: ScriptConfig<S, R>): ScriptModule<S, R>;
|
|
112
|
+
/**
|
|
113
|
+
* Create an executable script module by adding a main function.
|
|
114
|
+
*
|
|
115
|
+
* Use this when you want to define your main function separately from the params,
|
|
116
|
+
* for example when the main is complex or needs to be tested independently.
|
|
117
|
+
*
|
|
118
|
+
* Preserves any exporters defined on the original ScriptModule.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const script = defineParams({
|
|
123
|
+
* params: { size: { type: 'number', default: 10 } },
|
|
124
|
+
* exporters: { svg: svgExporter },
|
|
125
|
+
* });
|
|
126
|
+
*
|
|
127
|
+
* export default createMain(script, (p) => Manifold.cube([p.size, ...]));
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export declare function createMain<S extends ParamSchema, R>(scriptModule: ScriptModule<S, unknown>, main: (params: Params<S>) => R): ScriptModule<S, R>;
|
|
131
|
+
export { buildDefaults as _buildDefaults };
|
|
132
|
+
//# sourceMappingURL=script.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../src/script.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,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