@tscircuit/props 0.0.669 → 0.0.671
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 +8273 -3597
- package/dist/index.js +60 -16
- package/dist/index.js.map +1 -1
- package/lib/assembly/device.ts +22 -3
- package/lib/assembly/screen.ts +36 -3
- package/lib/assembly/subassembly.ts +37 -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,25 @@ var assemblySubassemblyProps = z7.object({
|
|
|
143
143
|
message: "name cannot be empty"
|
|
144
144
|
}),
|
|
145
145
|
displayName: z7.string().optional(),
|
|
146
|
+
model: z7.string().trim().min(1).optional(),
|
|
147
|
+
modelUrl: url.refine((value) => value.trim().length > 0, {
|
|
148
|
+
message: "modelUrl cannot be empty"
|
|
149
|
+
}).optional(),
|
|
146
150
|
cadModel: cadModelProp.optional(),
|
|
147
151
|
children: z7.custom().optional()
|
|
148
|
-
})
|
|
152
|
+
}).refine(
|
|
153
|
+
(assembly) => assembly.modelUrl === void 0 || assembly.cadModel === void 0,
|
|
154
|
+
{
|
|
155
|
+
message: "Provide either modelUrl or cadModel, not both",
|
|
156
|
+
path: ["modelUrl"]
|
|
157
|
+
}
|
|
158
|
+
).refine(
|
|
159
|
+
(assembly) => assembly.model === void 0 || assembly.modelUrl === void 0 && assembly.cadModel === void 0,
|
|
160
|
+
{
|
|
161
|
+
message: "Provide only one of model, modelUrl, or cadModel",
|
|
162
|
+
path: ["model"]
|
|
163
|
+
}
|
|
164
|
+
);
|
|
149
165
|
expectTypesMatch(true);
|
|
150
166
|
|
|
151
167
|
// lib/assembly/cadassembly.ts
|
|
@@ -154,8 +170,18 @@ var assemblyCadAssemblyProps = assemblySubassemblyProps;
|
|
|
154
170
|
// lib/assembly/device.ts
|
|
155
171
|
import { z as z8 } from "zod";
|
|
156
172
|
var assemblyDeviceProps = z8.object({
|
|
157
|
-
name: z8.string().optional()
|
|
158
|
-
|
|
173
|
+
name: z8.string().optional(),
|
|
174
|
+
model: z8.string().trim().min(1).optional(),
|
|
175
|
+
modelUrl: url.refine((value) => value.trim().length > 0, {
|
|
176
|
+
message: "modelUrl cannot be empty"
|
|
177
|
+
}).optional()
|
|
178
|
+
}).refine(
|
|
179
|
+
(device) => device.model === void 0 || device.modelUrl === void 0,
|
|
180
|
+
{
|
|
181
|
+
message: "Provide either model or modelUrl, not both",
|
|
182
|
+
path: ["model"]
|
|
183
|
+
}
|
|
184
|
+
);
|
|
159
185
|
expectTypesMatch(true);
|
|
160
186
|
|
|
161
187
|
// lib/assembly/screen.ts
|
|
@@ -168,11 +194,29 @@ var positiveDistance = (fieldName) => distance.refine((value) => Number.isFinite
|
|
|
168
194
|
});
|
|
169
195
|
var assemblyScreenProps = z9.object({
|
|
170
196
|
name: nonemptyString("name"),
|
|
197
|
+
model: z9.string().trim().min(1).optional(),
|
|
198
|
+
modelUrl: url.refine((value) => value.trim().length > 0, {
|
|
199
|
+
message: "modelUrl cannot be empty"
|
|
200
|
+
}).optional(),
|
|
171
201
|
connectsTo: nonemptyString("connectsTo"),
|
|
172
202
|
width: positiveDistance("width").optional(),
|
|
173
203
|
height: positiveDistance("height").optional(),
|
|
174
204
|
cadModel: nonemptyString("cadModel").optional()
|
|
175
205
|
}).superRefine((screen, context) => {
|
|
206
|
+
if (screen.model !== void 0 && (screen.modelUrl !== void 0 || screen.cadModel !== void 0)) {
|
|
207
|
+
context.addIssue({
|
|
208
|
+
code: z9.ZodIssueCode.custom,
|
|
209
|
+
message: "Provide only one of model, modelUrl, or cadModel",
|
|
210
|
+
path: ["model"]
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
if (screen.modelUrl !== void 0 && screen.cadModel !== void 0) {
|
|
214
|
+
context.addIssue({
|
|
215
|
+
code: z9.ZodIssueCode.custom,
|
|
216
|
+
message: "Provide either modelUrl or cadModel, not both",
|
|
217
|
+
path: ["modelUrl"]
|
|
218
|
+
});
|
|
219
|
+
}
|
|
176
220
|
const hasWidth = screen.width !== void 0;
|
|
177
221
|
const hasHeight = screen.height !== void 0;
|
|
178
222
|
if (hasWidth !== hasHeight) {
|
|
@@ -183,10 +227,10 @@ var assemblyScreenProps = z9.object({
|
|
|
183
227
|
});
|
|
184
228
|
return;
|
|
185
229
|
}
|
|
186
|
-
if (!hasWidth && screen.cadModel === void 0) {
|
|
230
|
+
if (!hasWidth && screen.cadModel === void 0 && screen.modelUrl === void 0 && screen.model === void 0) {
|
|
187
231
|
context.addIssue({
|
|
188
232
|
code: z9.ZodIssueCode.custom,
|
|
189
|
-
message: "provide
|
|
233
|
+
message: "provide width and height, model, cadModel, or modelUrl",
|
|
190
234
|
path: []
|
|
191
235
|
});
|
|
192
236
|
}
|