@floless/app 0.116.0 → 0.117.0

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.
@@ -148,12 +148,45 @@
148
148
  const FT_MM = 304.8;
149
149
  const IN_MM = 25.4;
150
150
 
151
+ import { dispatchV2ProjectionCommand } from './steel-model-v2-commands.js';
152
+
151
153
  /** Display-pixel scale for one plan, identical to the adapter's `scaleOf`. Change one, change both. */
152
154
  const scaleOf = (plan) => FT_MM / (plan && plan.pt_per_ft > 0 ? plan.pt_per_ft : 1);
153
155
 
154
156
  /** Kill float noise before it persists into `wp` — the same r6 the three inline call sites applied. */
155
157
  const r6 = (n) => Math.round(n * 1e6) / 1e6;
156
158
 
159
+ /**
160
+ * Copy and recursively freeze the plan-shaped projection handed to the editor in development.
161
+ * Copying is load-bearing: freezing shared arrays would freeze the canonical model too.
162
+ */
163
+ export function deepFreezeProjection(value) {
164
+ const copy = typeof structuredClone === 'function'
165
+ ? structuredClone(value)
166
+ : JSON.parse(JSON.stringify(value));
167
+ // structuredClone drops symbols. The v2 link is non-enumerable boundary metadata, not document data;
168
+ // preserve it, but never descend through it and freeze the linked command session/canonical model.
169
+ const copySymbols = (from, to) => {
170
+ if (!from || !to || typeof from !== 'object' || typeof to !== 'object') return;
171
+ for (const symbol of Object.getOwnPropertySymbols(from)) {
172
+ Object.defineProperty(to, symbol, {
173
+ value: from[symbol], enumerable: false, configurable: false, writable: false,
174
+ });
175
+ }
176
+ if (Array.isArray(from) && Array.isArray(to)) from.forEach((item, i) => copySymbols(item, to[i]));
177
+ else for (const key of Object.keys(from)) copySymbols(from[key], to[key]);
178
+ };
179
+ copySymbols(value, copy);
180
+ const seen = new WeakSet();
181
+ const freeze = (v) => {
182
+ if (!v || typeof v !== 'object' || seen.has(v)) return v;
183
+ seen.add(v);
184
+ for (const k of Object.keys(v)) freeze(v[k]);
185
+ return Object.freeze(v);
186
+ };
187
+ return freeze(copy);
188
+ }
189
+
157
190
  /**
158
191
  * World-mm offsets → one plan's display-pixel offsets, with dz in INCHES. Order is preserved because
159
192
  * copy order is offset-major and therefore observable in the stored contract.
@@ -190,6 +223,7 @@ export function ensureMeta(m) {
190
223
  * Moved verbatim from steel-editor.html (unit 5, P3b-1).
191
224
  */
192
225
  export function retargetTos(m, srcDef, dstDef) {
226
+ if (dispatchV2ProjectionCommand(m, 'retargetTos', [srcDef, dstDef])) return m;
193
227
  const d = dstDef - srcDef; ensureMeta(m);
194
228
  if (m.role === 'column') {
195
229
  if (m.col.tosDef !== false) m.col.tos = dstDef; else if (m.col.tos != null) m.col.tos += d;
@@ -222,7 +256,10 @@ export function elevTargets(m) {
222
256
  * `tosDef=false` is NOT redundant with the checkbox having been unticked — a user can type into the field
223
257
  * of an end that is still following the default, and that keystroke is what breaks the link.
224
258
  */
225
- export function setTosValue(target, tos) { target.tos = tos; target.tosDef = false; }
259
+ export function setTosValue(target, tos) {
260
+ if (dispatchV2ProjectionCommand(target, 'setTosValue', [tos])) return;
261
+ target.tos = tos; target.tosDef = false;
262
+ }
226
263
 
227
264
  /**
228
265
  * The "default" checkbox: store the flag, and re-datum to `defTos` ONLY when turning it back ON.
@@ -232,10 +269,16 @@ export function setTosValue(target, tos) { target.tos = tos; target.tosDef = fal
232
269
  * would be a feature, not this refactor. `applyTosAll` reuses this with `on=true` over every target,
233
270
  * which is precisely its body.
234
271
  */
235
- export function setTosDefault(target, on, defTos) { target.tosDef = on; if (on) target.tos = defTos; }
272
+ export function setTosDefault(target, on, defTos) {
273
+ if (dispatchV2ProjectionCommand(target, 'setTosDefault', [on, defTos])) return;
274
+ target.tosDef = on; if (on) target.tos = defTos;
275
+ }
236
276
 
237
277
  /** A column's base elevation. The inspector BOS inputs, `_dpCommit`'s Bottom branch, and `onBasePick`. */
238
- export function setBos(col, bos) { col.bos = bos; }
278
+ export function setBos(col, bos) {
279
+ if (dispatchV2ProjectionCommand(col, 'setBos', [bos])) return;
280
+ col.bos = bos;
281
+ }
239
282
 
240
283
  /**
241
284
  * Re-datum one member to a sheet default — `syncDefaults`, reached from BOTH `setPlan`'s boot path and
@@ -250,6 +293,7 @@ export function setBos(col, bos) { col.bos = bos; }
250
293
  * writes sit behind that guard.
251
294
  */
252
295
  export function syncToDefault(m, defTos) {
296
+ if (dispatchV2ProjectionCommand(m, 'syncToDefault', [defTos])) return m;
253
297
  ensureMeta(m);
254
298
  if (m.role === 'column') {
255
299
  if (m.col.tosDef !== false && defTos != null) m.col.tos = defTos;
@@ -270,6 +314,7 @@ export function syncToDefault(m, defTos) {
270
314
  * A column rises RIGIDLY: `bos` shifts too (null → `0 + dIn`), so the column is moved, not stretched.
271
315
  */
272
316
  export function elevateBy(m, dIn, base) {
317
+ if (dispatchV2ProjectionCommand(m, 'elevateBy', [dIn, base])) return m;
273
318
  ensureMeta(m);
274
319
  if (m.role === 'column') {
275
320
  m.col.tos = (m.col.tos != null ? m.col.tos : base) + dIn;
@@ -290,6 +335,7 @@ export function elevateBy(m, dIn, base) {
290
335
  * `col` is swapped too. That is what the editor does today, and it is observable in the stored contract.
291
336
  */
292
337
  export function swapColElevation(col, defTos) {
338
+ if (dispatchV2ProjectionCommand(col, 'swapColElevation', [defTos])) return col;
293
339
  const b = (col.bos != null ? col.bos : 0), t = (col.tos != null ? col.tos : defTos);
294
340
  col.bos = t; col.tos = b; col.tosDef = false;
295
341
  return col;
@@ -305,7 +351,10 @@ export function swapColElevation(col, defTos) {
305
351
  * The caller keeps its own `length >= 2` guard: a member reaching here with one end is broken, and
306
352
  * swallowing that here would hide it at every call site.
307
353
  */
308
- export function reverseEnds(m) { m.ends = [m.ends[1], m.ends[0]]; return m; }
354
+ export function reverseEnds(m) {
355
+ if (dispatchV2ProjectionCommand(m, 'reverseEnds')) return m;
356
+ m.ends = [m.ends[1], m.ends[0]]; return m;
357
+ }
309
358
 
310
359
  /**
311
360
  * Copy one end onto the other — the inspector's "Match ends", in both the single and multi panels.
@@ -315,6 +364,7 @@ export function reverseEnds(m) { m.ends = [m.ends[1], m.ends[0]]; return m; }
315
364
  * two ends never alias — which matters the moment anything edits one of them afterwards.
316
365
  */
317
366
  export function copyEndTo(m, from, to) {
367
+ if (dispatchV2ProjectionCommand(m, 'copyEndTo', [from, to])) return m;
318
368
  const s = m.ends[from];
319
369
  m.ends[to] = { tos: s.tos, note: s.note, tosDef: s.tosDef, detail: s.detail, conn: s.conn, connVerified: s.connVerified };
320
370
  return m;
@@ -342,7 +392,10 @@ export function copyEndTo(m, from, to) {
342
392
  * `null`) Remove. Every caller has already BUILT the object; the merge logic that makes "re-infer but
343
393
  * keep my levels" different from "infer" runs on that detached object, before it gets here.
344
394
  */
345
- export function setPlanGrid(plan, grid) { plan.grid = grid; return plan; }
395
+ export function setPlanGrid(plan, grid) {
396
+ if (dispatchV2ProjectionCommand(plan, 'setPlanGrid', [grid])) return plan;
397
+ plan.grid = grid; return plan;
398
+ }
346
399
 
347
400
  /**
348
401
  * Create a grid ONLY when the plan has none — `gridEnsureForLine`, which the free-line tool calls before
@@ -353,7 +406,8 @@ export function setPlanGrid(plan, grid) { plan.grid = grid; return plan; }
353
406
  * than a value so the caller does not build a grid it is about to throw away.
354
407
  */
355
408
  export function ensurePlanGrid(plan, make) {
356
- if (plan.grid) return plan.grid;
409
+ if (plan && plan.grid) return plan.grid;
410
+ if (dispatchV2ProjectionCommand(plan, 'ensurePlanGrid', [make])) return plan.grid;
357
411
  plan.grid = make();
358
412
  return plan.grid;
359
413
  }
@@ -366,6 +420,7 @@ export function ensurePlanGrid(plan, make) {
366
420
  * is invisible to the characterization baseline and has to be preserved by construction.
367
421
  */
368
422
  export function addGridLine(grid, line) {
423
+ if (dispatchV2ProjectionCommand(grid, 'addGridLine', [line])) return grid;
369
424
  if (!Array.isArray(grid.lines)) grid.lines = [];
370
425
  grid.lines.push(line);
371
426
  return grid;
@@ -380,6 +435,7 @@ export function addGridLine(grid, line) {
380
435
  * can diverge. The editor's own keyboard-Delete comment already says so.
381
436
  */
382
437
  export function removeGridLines(grid, ids) {
438
+ if (dispatchV2ProjectionCommand(grid, 'removeGridLines', [ids])) return grid;
383
439
  if (!grid || !Array.isArray(grid.lines)) return grid;
384
440
  grid.lines = grid.lines.filter(l => !ids.has(String(l.id)));
385
441
  return grid;
@@ -391,7 +447,10 @@ export function removeGridLines(grid, ids) {
391
447
  * `sanitizeGridLines` also deletes when the list empties, and whether the key is present is observable in
392
448
  * the stored contract. `= []` would be a data change wearing a refactor's clothes.
393
449
  */
394
- export function clearGridLines(grid) { delete grid.lines; return grid; }
450
+ export function clearGridLines(grid) {
451
+ if (dispatchV2ProjectionCommand(grid, 'clearGridLines')) return grid;
452
+ delete grid.lines; return grid;
453
+ }
395
454
 
396
455
  /**
397
456
  * Rename one free grid line, addressed by INDEX into the stored array — the bubble rename.
@@ -403,6 +462,7 @@ export function clearGridLines(grid) { delete grid.lines; return grid; }
403
462
  * to be deliberate.
404
463
  */
405
464
  export function setGridLineLabel(grid, i, label) {
465
+ if (dispatchV2ProjectionCommand(grid, 'setGridLineLabel', [i, label])) return grid;
406
466
  if (grid.lines && grid.lines[i]) grid.lines[i].label = label;
407
467
  return grid;
408
468
  }
@@ -415,7 +475,10 @@ export function setGridLineLabel(grid, i, label) {
415
475
  * event. With a single pointermove the two are numerically identical, which is why the characterization
416
476
  * op fires two.
417
477
  */
418
- export function setGridLineEnds(line, a, b) { line.a = a; line.b = b; return line; }
478
+ export function setGridLineEnds(line, a, b) {
479
+ if (dispatchV2ProjectionCommand(line, 'setGridLineEnds', [a, b])) return line;
480
+ line.a = a; line.b = b; return line;
481
+ }
419
482
 
420
483
  /**
421
484
  * Assign grid keys, `undefined` meaning DELETE.
@@ -427,6 +490,7 @@ export function setGridLineEnds(line, a, b) { line.a = a; line.b = b; return lin
427
490
  * `gridRenameBubble` across two PRs would be worse than landing this one primitive early.
428
491
  */
429
492
  export function patchGrid(grid, patch) {
493
+ if (dispatchV2ProjectionCommand(grid, 'patchGrid', [patch])) return grid;
430
494
  for (const k of Object.keys(patch)) {
431
495
  if (patch[k] === undefined) delete grid[k];
432
496
  else grid[k] = patch[k];
@@ -435,7 +499,10 @@ export function patchGrid(grid, patch) {
435
499
  }
436
500
 
437
501
  /** The plan's own T.O.S datum. Distinct from the editor's GLOBAL `defaultTOS` — see `elevateBy`. */
438
- export function setPlanDefaultTos(plan, tos) { plan.default_tos = tos; return plan; }
502
+ export function setPlanDefaultTos(plan, tos) {
503
+ if (dispatchV2ProjectionCommand(plan, 'setPlanDefaultTos', [tos])) return plan;
504
+ plan.default_tos = tos; return plan;
505
+ }
439
506
 
440
507
  /**
441
508
  * Replace a plan's member list WHOLESALE — the merge (`#mrgB`), which swaps in the array
@@ -454,7 +521,62 @@ export function setPlanDefaultTos(plan, tos) { plan.default_tos = tos; return pl
454
521
  * No normalisation, no `ensureMeta`, no filtering — the merge already produced a complete list, and adding
455
522
  * any of that would be a behaviour change wearing a refactor's clothes.
456
523
  */
457
- export function setPlanMembers(plan, members) { plan.members = members; return plan; }
524
+ export function setPlanMembers(plan, members) {
525
+ if (dispatchV2ProjectionCommand(plan, 'setPlanMembers', [members])) return plan;
526
+ plan.members = members; return plan;
527
+ }
528
+
529
+ /** Replace or append plan-local dimensions without exposing `P.dims` as a write surface. */
530
+ export function setPlanDims(plan, dims) {
531
+ if (dispatchV2ProjectionCommand(plan, 'setPlanDims', [dims])) return plan;
532
+ plan.dims = dims; return plan;
533
+ }
534
+ export function addPlanDims(plan, dims) {
535
+ if (dispatchV2ProjectionCommand(plan, 'addPlanDims', [dims])) return plan;
536
+ if (!Array.isArray(plan.dims)) plan.dims = [];
537
+ plan.dims.push(...dims);
538
+ return plan;
539
+ }
540
+
541
+ /** Replace the plan-local display frame (`null` means global axes). */
542
+ export function setPlanFrame(plan, frame) {
543
+ if (dispatchV2ProjectionCommand(plan, 'setPlanFrame', [frame])) return plan;
544
+ plan.frame = frame; return plan;
545
+ }
546
+
547
+ /** Member metadata whose canonical v2 spelling differs from the v1 projection. */
548
+ export function setMemberType(member, type) {
549
+ if (dispatchV2ProjectionCommand(member, 'setMemberType', [type])) return member;
550
+ member.memberType = type; return member;
551
+ }
552
+ export function patchMember(member, patch) {
553
+ if (dispatchV2ProjectionCommand(member, 'patchMember', [patch])) return member;
554
+ for (const [key, value] of Object.entries(patch || {})) {
555
+ if (value === undefined) delete member[key];
556
+ else member[key] = value;
557
+ }
558
+ return member;
559
+ }
560
+ export function patchEnd(end, patch) {
561
+ if (dispatchV2ProjectionCommand(end, 'patchEnd', [patch])) return end;
562
+ for (const [key, value] of Object.entries(patch || {})) {
563
+ if (value === undefined || value === '') delete end[key];
564
+ else end[key] = value;
565
+ }
566
+ return end;
567
+ }
568
+ export function setMemberBrace(member, brace) {
569
+ if (dispatchV2ProjectionCommand(member, 'setMemberBrace', [brace])) return member;
570
+ if (brace == null) delete member.brace;
571
+ else member.brace = brace;
572
+ return member;
573
+ }
574
+ export function patchMemberBrace(member, patch) {
575
+ if (dispatchV2ProjectionCommand(member, 'patchMemberBrace', [patch])) return member;
576
+ if (!member.brace || typeof member.brace !== 'object') member.brace = {};
577
+ Object.assign(member.brace, patch);
578
+ return member;
579
+ }
458
580
 
459
581
  /**
460
582
  * Drop every dimension anchor pointing at one of `ids` — the merge's dim-ref detach.
@@ -485,6 +607,7 @@ export function setPlanMembers(plan, members) { plan.members = members; return p
485
607
  * hardening it here would be a behaviour change, so it is pinned by a test instead.
486
608
  */
487
609
  export function detachDimRefs(plan, ids) {
610
+ if (dispatchV2ProjectionCommand(plan, 'detachDimRefs', [ids])) return plan;
488
611
  const aff = new Set(ids);
489
612
  for (const d of (plan.dims || [])) for (const rk of ['aRef', 'bRef']) if (d[rk] && aff.has(d[rk].m)) delete d[rk];
490
613
  return plan;
@@ -542,6 +665,7 @@ export function moveGridLineEnd(gc, grid, ptPerFt, axis, i, end, np) {
542
665
  export function createModelCommands(contract, { activePlan, defaultTosIn, mintId } = {}) {
543
666
  /** Translate in DISPLAY PIXELS with dz in inches — the moved `translateMembers`. */
544
667
  const translate = (members, off) => {
668
+ if (members.length && dispatchV2ProjectionCommand(members[0], 'translate', [members, off])) return;
545
669
  const dz = off[2] || 0;
546
670
  for (const m of members) {
547
671
  ensureMeta(m);
@@ -582,10 +706,17 @@ export function createModelCommands(contract, { activePlan, defaultTosIn, mintId
582
706
  * materialises it BEFORE its `snapshot()`, and moving that here would let a non-array value be captured
583
707
  * into the undo entry, where restore code calling `.map()` on it breaks.
584
708
  */
585
- const addMembers = (plan, members) => { plan.members.push(...members); return plan; };
709
+ const addMembers = (plan, members) => {
710
+ if (members.length && dispatchV2ProjectionCommand(plan, 'addMember', [members[0]])) {
711
+ for (let i = 1; i < members.length; i += 1) dispatchV2ProjectionCommand(plan, 'addMember', [members[i]]);
712
+ return plan;
713
+ }
714
+ plan.members.push(...members); return plan;
715
+ };
586
716
 
587
717
  /** Drop these ids from EVERY plan. Model-wide by design — a selection spans sheets. */
588
718
  const removeMembers = (ids) => {
719
+ if (activePlan && dispatchV2ProjectionCommand(activePlan, 'removeMembers', [ids])) return;
589
720
  for (const pl of (contract.plans || [])) pl.members = (pl.members || []).filter(m => !ids.has(m.id));
590
721
  };
591
722
 
@@ -593,7 +724,10 @@ export function createModelCommands(contract, { activePlan, defaultTosIn, mintId
593
724
  * Replace the whole `wp` array — the 3D member drag (`onMoveMember`), which assigns the array the 3D
594
725
  * module built.
595
726
  */
596
- const replaceEndpoints = (member, wp) => { member.wp = wp; };
727
+ const replaceEndpoints = (member, wp) => {
728
+ if (dispatchV2ProjectionCommand(member, 'replaceEndpoints', [wp])) return;
729
+ member.wp = wp;
730
+ };
597
731
 
598
732
  /**
599
733
  * Write both endpoints, KEEPING the outer array — the 2D grab drag, which does `m.wp[0]=…; m.wp[1]=…`.
@@ -605,7 +739,10 @@ export function createModelCommands(contract, { activePlan, defaultTosIn, mintId
605
739
  * ABSOLUTE, never relative: the caller fires this once per `pointermove` from the grab-time origin, so a
606
740
  * relative primitive would accumulate the delta per mouse event and fling the member off the sheet.
607
741
  */
608
- const setEndpointsInPlace = (member, a, b) => { member.wp[0] = a; member.wp[1] = b; };
742
+ const setEndpointsInPlace = (member, a, b) => {
743
+ if (dispatchV2ProjectionCommand(member, 'setEndpointsInPlace', [a, b])) return;
744
+ member.wp[0] = a; member.wp[1] = b;
745
+ };
609
746
 
610
747
  /**
611
748
  * Write ONE endpoint, addressed by index, keeping the outer `wp` array — `snapEndMulti` (index computed
@@ -623,7 +760,10 @@ export function createModelCommands(contract, { activePlan, defaultTosIn, mintId
623
760
  * No `wp`-shape guard on purpose. `onMoveEndpoint` checks `Array.isArray(m.wp)` before calling, and
624
761
  * moving that guard in here would silence a broken member at the other two sites too.
625
762
  */
626
- const setEndpoint = (member, i, pt) => { member.wp[i] = pt; };
763
+ const setEndpoint = (member, i, pt) => {
764
+ if (dispatchV2ProjectionCommand(member, 'setEndpoint', [i, pt])) return;
765
+ member.wp[i] = pt;
766
+ };
627
767
 
628
768
  const cloneOnto = (src, plan, off) => {
629
769
  const c = clone(src);
@@ -0,0 +1,95 @@
1
+ /*
2
+ * Synchronous browser validation after each v2 editor command.
3
+ *
4
+ * Shape uses the same schema artifact and subset interpreter as the server. Relationship checks cover
5
+ * every reference a live editor command can alter; the server remains the final persistence authority.
6
+ */
7
+
8
+ import { validateSchemaSubset } from './json-schema-subset.js';
9
+
10
+ const rows = (v) => Array.isArray(v) ? v : [];
11
+ const object = (v) => v && typeof v === 'object' && !Array.isArray(v);
12
+
13
+ export function validateClientSteelModelV2(doc, schema) {
14
+ const shape = validateSchemaSubset(doc, schema);
15
+ const issues = shape.errors.map((e) => `${e.path}: ${e.message}`);
16
+ if (!object(doc)) return issues;
17
+ const members = rows(doc.members);
18
+ const memberCounts = new Map();
19
+ for (const member of members) memberCounts.set(member?.id, (memberCounts.get(member?.id) || 0) + 1);
20
+ const memberRef = (id, path) => {
21
+ const count = memberCounts.get(id) || 0;
22
+ if (count !== 1) issues.push(`${count ? 'member-ref-ambiguous' : 'member-ref-unresolved'} at ${path}`);
23
+ };
24
+ for (const [id, count] of memberCounts) if (!id || count !== 1) issues.push(`member-id-${id ? 'duplicate' : 'empty'} at $.members`);
25
+
26
+ const plans = rows(doc.plans);
27
+ const sheets = new Set();
28
+ const presented = new Set();
29
+ const axes = rows(doc.grid?.axes);
30
+ const axisIds = new Set();
31
+ const axisLabels = { x: new Map(), y: new Map(), z: new Map() };
32
+ for (const axis of axes) {
33
+ if (!axis?.id || axisIds.has(axis.id)) issues.push(`grid-axis-id-duplicate at $.grid.axes`);
34
+ axisIds.add(axis?.id);
35
+ const labels = axisLabels[axis?.dir];
36
+ if (labels) labels.set(axis.label, (labels.get(axis.label) || 0) + 1);
37
+ }
38
+ const axisRef = (id, path) => {
39
+ if (id && !axisIds.has(id)) issues.push(`grid-axis-unresolved at ${path}`);
40
+ };
41
+ const controlRef = (ref, path) => {
42
+ if (!ref) return;
43
+ if ((axisLabels.x.get(ref.axis_x) || 0) !== 1 || (axisLabels.y.get(ref.axis_y) || 0) !== 1) {
44
+ issues.push(`control-ref-unresolved at ${path}`);
45
+ }
46
+ };
47
+ for (let pi = 0; pi < plans.length; pi += 1) {
48
+ const plan = plans[pi];
49
+ if (sheets.has(plan.sheet)) issues.push(`plan-sheet-duplicate at $.plans[${pi}].sheet`);
50
+ sheets.add(plan.sheet);
51
+ controlRef(plan.datum_ref, `$.plans[${pi}].datum_ref`);
52
+ controlRef(plan.control2_ref, `$.plans[${pi}].control2_ref`);
53
+ for (const id of rows(plan.memberRefs)) {
54
+ memberRef(id, `$.plans[${pi}].memberRefs`);
55
+ presented.add(id);
56
+ }
57
+ for (const obs of rows(plan.memberObservations)) {
58
+ const bound = rows(obs?.binding?.memberIds);
59
+ if (obs?.binding?.status === 'active') {
60
+ if (!bound.length) issues.push(`observation-cardinality at $.plans[${pi}].memberObservations`);
61
+ for (const id of bound) { memberRef(id, `$.plans[${pi}].memberObservations`); presented.add(id); }
62
+ } else if (bound.length) issues.push(`observation-cardinality at $.plans[${pi}].memberObservations`);
63
+ }
64
+ for (const dim of rows(plan.dims)) {
65
+ for (const key of ['aRef', 'bRef']) {
66
+ if (dim?.[key]?.m) memberRef(dim[key].m, `$.plans[${pi}].dims.${key}.m`);
67
+ if (dim?.[key]?.g) axisRef(dim[key].g, `$.plans[${pi}].dims.${key}.g`);
68
+ }
69
+ }
70
+ }
71
+ for (let i = 0; i < members.length; i += 1) {
72
+ const member = members[i];
73
+ if (member?.role === 'column' && Number.isFinite(member.from?.z?.known)
74
+ && Number.isFinite(member.to?.z?.known) && member.from.z.known > member.to.z.known) {
75
+ issues.push(`column-endpoint-order at $.members[${i}]`);
76
+ }
77
+ for (const end of rows(member?.ends)) if (end?.conn && !rows(doc.connections).some((c) => c?.id === end.conn)) {
78
+ issues.push(`conn-unresolved at $.members[${i}].ends`);
79
+ }
80
+ }
81
+ for (let i = 0; i < rows(doc.joints).length; i += 1) {
82
+ const joint = doc.joints[i];
83
+ if (joint?.main) memberRef(joint.main, `$.joints[${i}].main`);
84
+ for (const id of rows(joint?.secondaries)) memberRef(id, `$.joints[${i}].secondaries`);
85
+ }
86
+ for (let i = 0; i < rows(doc.detail_placements).length; i += 1) {
87
+ const placement = doc.detail_placements[i];
88
+ if (placement?.anchorId) memberRef(placement.anchorId, `$.detail_placements[${i}].anchorId`);
89
+ }
90
+ for (let i = 0; i < rows(doc.views).length; i += 1) axisRef(doc.views[i]?.generated?.axisId, `$.views[${i}].generated.axisId`);
91
+ for (const member of members) if (!presented.has(member?.id) && member?.role !== 'column') {
92
+ issues.push(`member-unpresented at $.members[${member?.id || '?'}]`);
93
+ }
94
+ return issues;
95
+ }