@floless/app 0.165.0 → 0.166.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.
@@ -51,6 +51,17 @@ export function createMemberPresenceIndex(model) {
51
51
  return { members, plans };
52
52
  }
53
53
 
54
+ /**
55
+ * Where `member` stands against `plan`'s cut, judged by THIS project's reach and near-cut tolerance — its saved
56
+ * `column_below_reach_mm`, else the default for its standard (300 mm metric, 12 in imperial). 'unknown' for
57
+ * anything that is not a column, and for a plan with no cut level. The one answer `memberPresence` and
58
+ * `projectMember` share, so the row a sheet draws and the reason it is drawn cannot use two different reaches (#2670).
59
+ */
60
+ function columnRelationOnPlan(model, plan, member) {
61
+ if (member.role !== 'column' || !Number.isFinite(plan?.elevation_mm)) return 'unknown';
62
+ return columnCutRelation(member.from?.z, member.to?.z, plan.elevation_mm, columnBelowReachOf(model), defaultColumnNearCut(model?.environment));
63
+ }
64
+
54
65
  /**
55
66
  * The three-source membersOnSheet rule, kept equivalent to the server projection (`membersOnSheet`).
56
67
  *
@@ -65,10 +76,7 @@ export function memberPresence(model, plan, member, index = null) {
65
76
  const lookup = index?.plans.get(plan);
66
77
  const observed = (lookup?.observed || observationIds(plan)).has(member.id);
67
78
  const explicit = lookup ? lookup.explicit.has(member.id) : (plan.memberRefs || []).includes(member.id);
68
- const cutMm = Number.isFinite(plan.elevation_mm) ? plan.elevation_mm : null;
69
- const relation = cutMm !== null && member.role === 'column'
70
- ? columnCutRelation(member.from?.z, member.to?.z, cutMm, columnBelowReachOf(model), defaultColumnNearCut(model?.environment))
71
- : 'unknown';
79
+ const relation = columnRelationOnPlan(model, plan, member);
72
80
  const crossing = relation === 'crossing';
73
81
  const below = relation === 'below';
74
82
  // A base read a little over the cut (#2815): drawn where it is, solid, never moved to the level.
@@ -245,8 +253,12 @@ export function memberProperties(member) {
245
253
 
246
254
  }
247
255
 
248
- /** One canonical member mapped into the display-space vocabulary the 2D canvas consumes. */
249
- export function projectMember(member, plan, session = null) {
256
+ /**
257
+ * One canonical member mapped into the display-space vocabulary the 2D canvas consumes. `plan` is the sheet the
258
+ * row is drawn on (in practice the projection built from it, which carries the same `elevation_mm`); `model` is
259
+ * the document it belongs to, read only for its column reach. Without one the reach is the imperial default.
260
+ */
261
+ export function projectMember(member, plan, session = null, model = null) {
250
262
  const a = worldToSheetPx(member.from, plan);
251
263
  const b = worldToSheetPx(member.to, plan);
252
264
  // Destructured so the emitted key ORDER is byte-identical to what this function built inline before the
@@ -257,21 +269,15 @@ export function projectMember(member, plan, session = null) {
257
269
  Decided HERE, from the member and the plan's own cut, and not handed down by whoever built the list: the
258
270
  `patchMembers` path re-projects a row without asking presence at all, so a flag that came from the caller
259
271
  would be lost on the first drag. Set only when true, so every other row keeps exactly the shape it had. */
260
- if (member.role === 'column') {
261
- // NO `reach` ARGUMENT ON PURPOSE, and it must stay that way or be fixed properly. `below` and
262
- // `far-below` both set the same flag here, so which side of the reach a column falls on cannot
263
- // change this outcome — the default is not load-bearing. The moment anyone distinguishes the two,
264
- // this call starts silently using the imperial 304.8 and ignoring BOTH the project's stored reach
265
- // and its metric default, which is the split-brain `memberPresence` avoids by passing
266
- // `columnBelowReachOf(model)`. Threading the model in here needs a signature change this change
267
- // did not warrant: #2670.
268
- const relation = columnCutRelation(member.from?.z, member.to?.z, plan.elevation_mm);
269
- if (relation === 'below' || relation === 'far-below') projected.belowCut = true;
270
- }
272
+ // Judged at the PROJECT's reach, the same one presence uses (#2670). `below` and `far-below` set the same
273
+ // flag today, but the relation rides on the row's link so a reader that ever tells them apart gets the
274
+ // project's answer and not the imperial default's.
275
+ const cutRelation = columnRelationOnPlan(model, plan, member);
276
+ if (cutRelation === 'below' || cutRelation === 'far-below') projected.belowCut = true;
271
277
  // `viewId` is the identity every command resolves its row by; `sheet` rides along for display only
272
278
  // and must never be used as a lookup key (#938).
273
279
  const base = { session, kind: 'member', memberId: member.id, viewId: planViewId(plan), sheet: plan.sheet };
274
- link(projected, base);
280
+ link(projected, member.role === 'column' ? { ...base, cutRelation } : base);
275
281
  link(projected.ends[0], { ...base, kind: 'end', end: 0 });
276
282
  link(projected.ends[1], { ...base, kind: 'end', end: 1 });
277
283
  link(projected.col, { ...base, kind: 'column' });
@@ -336,7 +342,7 @@ export function createV2Projection(model, viewId, options = {}) {
336
342
  const index = createMemberPresenceIndex(model);
337
343
  return (model.members || []).filter((m) => memberPresence(model, plan, m, index).visible);
338
344
  })();
339
- projection.members = visible.map((m) => projectMember(m, projection, session));
345
+ projection.members = visible.map((m) => projectMember(m, projection, session, model));
340
346
  // Dimensions go with them. A `dim` is anchored to a member point or a grid axis (`aRef`/`bRef`), so on
341
347
  // a refused sheet it measures between two things that are no longer there — and it draws in raw sheet
342
348
  // pixels, so it draws ANYWAY, leaving one confident-looking annotation floating over an empty plan.
@@ -396,7 +402,7 @@ export function createV2Projection(model, viewId, options = {}) {
396
402
  const id = projection.members[i]?.id;
397
403
  if (!wanted.has(id)) continue;
398
404
  const member = canonical.get(id);
399
- if (member) projection.members[i] = projectMember(member, projection, session);
405
+ if (member) projection.members[i] = projectMember(member, projection, session, model);
400
406
  }
401
407
  patchCount += wanted.size;
402
408
  return projection;