@tscircuit/props 0.0.668 → 0.0.670
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 +2 -0
- package/dist/index.d.ts +2688 -353
- package/dist/index.js +41 -16
- package/dist/index.js.map +1 -1
- package/lib/assembly/device.ts +8 -0
- package/lib/assembly/screen.ts +22 -3
- package/lib/assembly/subassembly.ts +25 -8
- package/lib/common/schematicSize.ts +3 -2
- package/lib/components/diode.ts +8 -0
- package/lib/components/led.ts +4 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -48,27 +48,27 @@ var commonShapeProps = z3.discriminatedUnion("shape", [
|
|
|
48
48
|
]);
|
|
49
49
|
expectTypesMatch(true);
|
|
50
50
|
|
|
51
|
+
// lib/common/url.ts
|
|
52
|
+
import { z as z4 } from "zod";
|
|
53
|
+
var url = z4.preprocess((value) => {
|
|
54
|
+
if (value && typeof value === "object" && "default" in value) {
|
|
55
|
+
return value.default;
|
|
56
|
+
}
|
|
57
|
+
return value;
|
|
58
|
+
}, z4.string());
|
|
59
|
+
|
|
51
60
|
// lib/common/cadModel.ts
|
|
52
61
|
import { z as z6 } from "zod";
|
|
53
62
|
|
|
54
63
|
// lib/common/point3.ts
|
|
55
64
|
import { distance as distance2 } from "circuit-json";
|
|
56
|
-
import { z as
|
|
57
|
-
var point3 =
|
|
65
|
+
import { z as z5 } from "zod";
|
|
66
|
+
var point3 = z5.object({
|
|
58
67
|
x: distance2,
|
|
59
68
|
y: distance2,
|
|
60
69
|
z: distance2
|
|
61
70
|
});
|
|
62
71
|
|
|
63
|
-
// lib/common/url.ts
|
|
64
|
-
import { z as z5 } from "zod";
|
|
65
|
-
var url = z5.preprocess((value) => {
|
|
66
|
-
if (value && typeof value === "object" && "default" in value) {
|
|
67
|
-
return value.default;
|
|
68
|
-
}
|
|
69
|
-
return value;
|
|
70
|
-
}, z5.string());
|
|
71
|
-
|
|
72
72
|
// lib/common/cadModel.ts
|
|
73
73
|
var rotationPoint3 = z6.object({
|
|
74
74
|
x: z6.union([z6.number(), z6.string()]),
|
|
@@ -143,9 +143,18 @@ var assemblySubassemblyProps = z7.object({
|
|
|
143
143
|
message: "name cannot be empty"
|
|
144
144
|
}),
|
|
145
145
|
displayName: z7.string().optional(),
|
|
146
|
+
modelUrl: url.refine((value) => value.trim().length > 0, {
|
|
147
|
+
message: "modelUrl cannot be empty"
|
|
148
|
+
}).optional(),
|
|
146
149
|
cadModel: cadModelProp.optional(),
|
|
147
150
|
children: z7.custom().optional()
|
|
148
|
-
})
|
|
151
|
+
}).refine(
|
|
152
|
+
(assembly) => assembly.modelUrl === void 0 || assembly.cadModel === void 0,
|
|
153
|
+
{
|
|
154
|
+
message: "Provide either modelUrl or cadModel, not both",
|
|
155
|
+
path: ["modelUrl"]
|
|
156
|
+
}
|
|
157
|
+
);
|
|
149
158
|
expectTypesMatch(true);
|
|
150
159
|
|
|
151
160
|
// lib/assembly/cadassembly.ts
|
|
@@ -154,7 +163,10 @@ var assemblyCadAssemblyProps = assemblySubassemblyProps;
|
|
|
154
163
|
// lib/assembly/device.ts
|
|
155
164
|
import { z as z8 } from "zod";
|
|
156
165
|
var assemblyDeviceProps = z8.object({
|
|
157
|
-
name: z8.string().optional()
|
|
166
|
+
name: z8.string().optional(),
|
|
167
|
+
modelUrl: url.refine((value) => value.trim().length > 0, {
|
|
168
|
+
message: "modelUrl cannot be empty"
|
|
169
|
+
}).optional()
|
|
158
170
|
});
|
|
159
171
|
expectTypesMatch(true);
|
|
160
172
|
|
|
@@ -168,11 +180,21 @@ var positiveDistance = (fieldName) => distance.refine((value) => Number.isFinite
|
|
|
168
180
|
});
|
|
169
181
|
var assemblyScreenProps = z9.object({
|
|
170
182
|
name: nonemptyString("name"),
|
|
183
|
+
modelUrl: url.refine((value) => value.trim().length > 0, {
|
|
184
|
+
message: "modelUrl cannot be empty"
|
|
185
|
+
}).optional(),
|
|
171
186
|
connectsTo: nonemptyString("connectsTo"),
|
|
172
187
|
width: positiveDistance("width").optional(),
|
|
173
188
|
height: positiveDistance("height").optional(),
|
|
174
189
|
cadModel: nonemptyString("cadModel").optional()
|
|
175
190
|
}).superRefine((screen, context) => {
|
|
191
|
+
if (screen.modelUrl !== void 0 && screen.cadModel !== void 0) {
|
|
192
|
+
context.addIssue({
|
|
193
|
+
code: z9.ZodIssueCode.custom,
|
|
194
|
+
message: "Provide either modelUrl or cadModel, not both",
|
|
195
|
+
path: ["modelUrl"]
|
|
196
|
+
});
|
|
197
|
+
}
|
|
176
198
|
const hasWidth = screen.width !== void 0;
|
|
177
199
|
const hasHeight = screen.height !== void 0;
|
|
178
200
|
if (hasWidth !== hasHeight) {
|
|
@@ -183,10 +205,10 @@ var assemblyScreenProps = z9.object({
|
|
|
183
205
|
});
|
|
184
206
|
return;
|
|
185
207
|
}
|
|
186
|
-
if (!hasWidth && screen.cadModel === void 0) {
|
|
208
|
+
if (!hasWidth && screen.cadModel === void 0 && screen.modelUrl === void 0) {
|
|
187
209
|
context.addIssue({
|
|
188
210
|
code: z9.ZodIssueCode.custom,
|
|
189
|
-
message: "provide
|
|
211
|
+
message: "provide width and height, cadModel, or modelUrl",
|
|
190
212
|
path: []
|
|
191
213
|
});
|
|
192
214
|
}
|
|
@@ -16192,7 +16214,7 @@ var schematicPinLabel = z27.string().regex(/^[A-Za-z0-9_]+$/);
|
|
|
16192
16214
|
// lib/common/schematicSize.ts
|
|
16193
16215
|
import { distance as distance10 } from "circuit-json";
|
|
16194
16216
|
import { z as z28 } from "zod";
|
|
16195
|
-
var schematicSymbolSize =
|
|
16217
|
+
var schematicSymbolSize = z28.enum(["xs", "sm", "default", "md"]).or(distance10.pipe(z28.number().finite())).describe("distance between pin1 and pin2 of the schematic symbol");
|
|
16196
16218
|
|
|
16197
16219
|
// lib/common/kicadPinMetadata.ts
|
|
16198
16220
|
import { z as z29 } from "zod";
|
|
@@ -18381,6 +18403,7 @@ var diodeProps = commonComponentProps.extend({
|
|
|
18381
18403
|
photo: z102.boolean().optional(),
|
|
18382
18404
|
tvs: z102.boolean().optional(),
|
|
18383
18405
|
schOrientation: schematicOrientation.optional(),
|
|
18406
|
+
schSize: schematicSymbolSize.optional(),
|
|
18384
18407
|
pinLabels: diodePinLabelsProp.optional()
|
|
18385
18408
|
}).superRefine((data, ctx) => {
|
|
18386
18409
|
const enabledFlags = [
|
|
@@ -18456,6 +18479,8 @@ var ledProps = commonComponentProps.extend({
|
|
|
18456
18479
|
wavelength: z103.string().optional(),
|
|
18457
18480
|
schDisplayValue: z103.string().optional(),
|
|
18458
18481
|
schOrientation: schematicOrientation.optional(),
|
|
18482
|
+
/** Select a compact schematic symbol; omitted, default, and md retain the standard symbol. */
|
|
18483
|
+
schSize: schematicSymbolSize.optional(),
|
|
18459
18484
|
// Numeric keys are accepted for compatibility with legacy generated LED
|
|
18460
18485
|
// wrappers, then normalized to the canonical pin1/pin2 representation.
|
|
18461
18486
|
pinLabels: diodePinLabelsProp.or(legacyNumericLedPinLabelsProp).optional(),
|