@tscircuit/props 0.0.669 → 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/dist/index.d.ts +3660 -1338
- package/dist/index.js +37 -15
- 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/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
|
}
|