@hypersoniclabs/helix-cli 0.1.27-helix3.694 → 0.1.27-helix3.695

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/device.js CHANGED
@@ -285,6 +285,55 @@ function isFiniteNumber(value) {
285
285
  function isNonEmptyName(value) {
286
286
  return typeof value === 'string' && value.trim().length > 0;
287
287
  }
288
+ /**
289
+ * R137 `carries` on a slider: the load volume of a deck that carries a parked car.
290
+ * `boxM` is in the Device root frame at offset 0; finite, min < max on every axis, at most 12 x 6 x 12 m.
291
+ * y sliders only; `blockedKey` must be a declared boolean state key. Mirrors the backend/room validators
292
+ * (the room honours the same descriptor only after the backend places it as `placements[].carry`).
293
+ */
294
+ const DEVICE_CARRY_MAX_BOX_M = [12, 6, 12];
295
+ function validateSliderCarries(component, label, state, errors) {
296
+ const path = `${label} carries`;
297
+ if (component.axis !== 'y') {
298
+ errors.push(`${path} is only valid on a y-axis slider`);
299
+ }
300
+ const raw = component.carries;
301
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
302
+ errors.push(`${path} must be an object { boxM, blockedKey? }`);
303
+ return;
304
+ }
305
+ const carries = object(raw);
306
+ for (const key of Object.keys(carries)) {
307
+ if (key !== 'boxM' && key !== 'blockedKey')
308
+ errors.push(`${path}: unknown field "${key}"`);
309
+ }
310
+ const box = object(carries.boxM);
311
+ const vec = (v) => Array.isArray(v) && v.length === 3 && v.every(isFiniteNumber)
312
+ ? v
313
+ : null;
314
+ const min = vec(box.min);
315
+ const max = vec(box.max);
316
+ if (!min || !max) {
317
+ errors.push(`${path}.boxM must be { min: [x,y,z], max: [x,y,z] } with finite numbers`);
318
+ }
319
+ else {
320
+ const axes = ['x', 'y', 'z'];
321
+ for (let i = 0; i < 3; i += 1) {
322
+ if (!(min[i] < max[i]))
323
+ errors.push(`${path}.boxM.min.${axes[i]} must be below max.${axes[i]}`);
324
+ else if (max[i] - min[i] > DEVICE_CARRY_MAX_BOX_M[i])
325
+ errors.push(`${path}.boxM is ${(max[i] - min[i]).toFixed(2)} m on ${axes[i]}; the cap is ${DEVICE_CARRY_MAX_BOX_M.join(' x ')} m`);
326
+ }
327
+ }
328
+ if (carries.blockedKey !== undefined) {
329
+ if (!isNonEmptyName(carries.blockedKey)) {
330
+ errors.push(`${path}.blockedKey must be a non-empty state key`);
331
+ }
332
+ else if (object(state[carries.blockedKey]).type !== 'boolean') {
333
+ errors.push(`${path}.blockedKey "${carries.blockedKey}" must be a declared boolean state key`);
334
+ }
335
+ }
336
+ }
288
337
  /** A node reference resolved through `model.nodeBindings`, as the host does. */
289
338
  function graphNode(context, raw, path) {
290
339
  const semantic = String(raw ?? '');
@@ -2126,6 +2175,8 @@ function validateDeviceProject(input, options = {}) {
2126
2175
  errors.push(`${label} durationMs must be between 16 and 60000`);
2127
2176
  }
2128
2177
  checkEasing(component.easing, label, errors);
2178
+ if (component.carries !== undefined)
2179
+ validateSliderCarries(component, label, state, errors);
2129
2180
  }
2130
2181
  if (component.type === 'clockHands') {
2131
2182
  const label = `clock hands ${componentId}`;