@floless/app 0.130.1 → 0.131.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.
- package/dist/floless-server.cjs +71 -222
- package/dist/web/reference-changes.js +224 -0
- package/dist/web/reference-session.js +141 -0
- package/dist/web/steel-3d-view.js +205 -3
- package/dist/web/steel-editor.html +1982 -201
- package/dist/web/steel-split-view.js +169 -0
- package/package.json +1 -1
package/dist/floless-server.cjs
CHANGED
|
@@ -54980,7 +54980,7 @@ function appVersion() {
|
|
|
54980
54980
|
return resolveVersion({
|
|
54981
54981
|
isSea: isSea2(),
|
|
54982
54982
|
sqVersionXml: readSqVersionXml(),
|
|
54983
|
-
define: true ? "0.
|
|
54983
|
+
define: true ? "0.131.0" : void 0,
|
|
54984
54984
|
pkgVersion: readPkgVersion()
|
|
54985
54985
|
});
|
|
54986
54986
|
}
|
|
@@ -54996,7 +54996,7 @@ function resolveChannel(s) {
|
|
|
54996
54996
|
function appChannel() {
|
|
54997
54997
|
return resolveChannel({
|
|
54998
54998
|
isSea: isSea2(),
|
|
54999
|
-
define: true ? "0.
|
|
54999
|
+
define: true ? "0.131.0" : void 0,
|
|
55000
55000
|
// argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
|
|
55001
55001
|
// carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
|
|
55002
55002
|
modulePath: process.argv[1]
|
|
@@ -55413,7 +55413,6 @@ var parseInches = (raw) => {
|
|
|
55413
55413
|
}
|
|
55414
55414
|
return NaN;
|
|
55415
55415
|
};
|
|
55416
|
-
var mmPerPx = (ptPerFt) => FT_MM / (ptPerFt > 0 ? ptPerFt : 1);
|
|
55417
55416
|
function parseLen(tok) {
|
|
55418
55417
|
let s = String(tok == null ? "" : tok).trim();
|
|
55419
55418
|
if (!s) return NaN;
|
|
@@ -55532,9 +55531,6 @@ function labelsFor(override, style, n) {
|
|
|
55532
55531
|
const auto = autoLabels(style, n);
|
|
55533
55532
|
return auto.map((a, i) => own2[i] != null ? own2[i] : a);
|
|
55534
55533
|
}
|
|
55535
|
-
function sane(g) {
|
|
55536
|
-
return !!(g && Array.isArray(g.origin) && g.origin.length >= 2 && isFinite(g.origin[0]) && isFinite(g.origin[1]));
|
|
55537
|
-
}
|
|
55538
55534
|
var pt2 = (p) => Array.isArray(p) && p.length >= 2 && isFinite(p[0]) && isFinite(p[1]) ? [+p[0], +p[1]] : null;
|
|
55539
55535
|
function gridLines(g) {
|
|
55540
55536
|
const out = [], used = /* @__PURE__ */ new Set();
|
|
@@ -55550,59 +55546,6 @@ function gridLines(g) {
|
|
|
55550
55546
|
}
|
|
55551
55547
|
return out;
|
|
55552
55548
|
}
|
|
55553
|
-
function gridGeometry(g, ptPerFt, opts = {}) {
|
|
55554
|
-
const yUp = !!opts.yUp;
|
|
55555
|
-
const k = mmPerPx(ptPerFt);
|
|
55556
|
-
const px = (mm) => mm / k;
|
|
55557
|
-
const X = parseSpacings(g && g.x), Y = parseSpacings(g && g.y);
|
|
55558
|
-
const ok = sane(g);
|
|
55559
|
-
const ox = ok ? g.origin[0] : 0, oy = ok ? g.origin[1] : 0;
|
|
55560
|
-
const lx = labelsFor(g && g.labels_x, "num", X.offsets.length);
|
|
55561
|
-
const ly = labelsFor(g && g.labels_y, "alpha", Y.offsets.length);
|
|
55562
|
-
const v = X.offsets.map((off, i) => ({ x: ox + px(off), label: lx[i] }));
|
|
55563
|
-
const h = Y.offsets.map((off, i) => ({ y: yUp ? oy + px(off) : oy - px(off), label: ly[i] }));
|
|
55564
|
-
const resolvedZ = parseLevels(g && g.z, g && g.labels_z);
|
|
55565
|
-
const levelsZ = resolvedZ.err ? [] : resolvedZ.levels;
|
|
55566
|
-
const ext = px(g && isFinite(g.ext) ? g.ext : 5 * FT_MM);
|
|
55567
|
-
const xs = v.map((l) => l.x), ys = h.map((l) => l.y);
|
|
55568
|
-
const lines = gridLines(g);
|
|
55569
|
-
const lx0 = lines.length ? Math.min(...lines.flatMap((l) => [l.a[0], l.b[0]])) : ox;
|
|
55570
|
-
const lx1 = lines.length ? Math.max(...lines.flatMap((l) => [l.a[0], l.b[0]])) : ox;
|
|
55571
|
-
const ly0 = lines.length ? Math.min(...lines.flatMap((l) => [l.a[1], l.b[1]])) : oy;
|
|
55572
|
-
const ly1 = lines.length ? Math.max(...lines.flatMap((l) => [l.a[1], l.b[1]])) : oy;
|
|
55573
|
-
const geo = {
|
|
55574
|
-
v,
|
|
55575
|
-
h,
|
|
55576
|
-
lines,
|
|
55577
|
-
zs: levelsZ,
|
|
55578
|
-
errX: X.err,
|
|
55579
|
-
errY: Y.err,
|
|
55580
|
-
errZ: resolvedZ.err,
|
|
55581
|
-
warningsZ: resolvedZ.warnings,
|
|
55582
|
-
ext,
|
|
55583
|
-
x0: Math.min(xs.length ? Math.min(...xs) : ox, lx0) - ext,
|
|
55584
|
-
x1: Math.max(xs.length ? Math.max(...xs) : ox, lx1) + ext,
|
|
55585
|
-
y0: Math.min(ys.length ? Math.min(...ys) : oy, ly0) - ext,
|
|
55586
|
-
y1: Math.max(ys.length ? Math.max(...ys) : oy, ly1) + ext
|
|
55587
|
-
};
|
|
55588
|
-
const axisIds = (dir) => yUp && g && Array.isArray(g.axes) ? g.axes.filter((a) => a && a.dir === dir).map((a) => a.id) : [];
|
|
55589
|
-
const override = (dir, i, legacy) => {
|
|
55590
|
-
if (!yUp) return g && g[legacy] && g[legacy][i] || [];
|
|
55591
|
-
const id = axisIds(dir)[i];
|
|
55592
|
-
return id != null && g && g.ends && g.ends[id] || [];
|
|
55593
|
-
};
|
|
55594
|
-
for (const [i, l] of v.entries()) {
|
|
55595
|
-
const o = override("x", i, "ends_x");
|
|
55596
|
-
l.lo = o[0] != null && isFinite(o[0]) ? +o[0] : geo.y0;
|
|
55597
|
-
l.hi = o[1] != null && isFinite(o[1]) ? +o[1] : geo.y1;
|
|
55598
|
-
}
|
|
55599
|
-
for (const [i, l] of h.entries()) {
|
|
55600
|
-
const o = override("y", i, "ends_y");
|
|
55601
|
-
l.lo = o[0] != null && isFinite(o[0]) ? +o[0] : geo.x0;
|
|
55602
|
-
l.hi = o[1] != null && isFinite(o[1]) ? +o[1] : geo.x1;
|
|
55603
|
-
}
|
|
55604
|
-
return geo;
|
|
55605
|
-
}
|
|
55606
55549
|
|
|
55607
55550
|
// steel-model-v2.ts
|
|
55608
55551
|
var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -65931,58 +65874,6 @@ function planeOffset(positionH, ax, ay, bx, by, dims, rotDeg) {
|
|
|
65931
65874
|
const signed = pos2 === "left" ? -half : half;
|
|
65932
65875
|
return { dx: -(by - ay) / planLen * signed, dy: (bx - ax) / planLen * signed, signed };
|
|
65933
65876
|
}
|
|
65934
|
-
function contractWithExportScopedMemberIds(contract) {
|
|
65935
|
-
const occurrences = /* @__PURE__ */ new Map();
|
|
65936
|
-
(contract.plans ?? []).forEach((plan, planIndex) => {
|
|
65937
|
-
(plan.members ?? []).forEach((member, memberIndex) => {
|
|
65938
|
-
const id = typeof member.id === "string" ? member.id : "";
|
|
65939
|
-
if (!id) return;
|
|
65940
|
-
const rows2 = occurrences.get(id) ?? [];
|
|
65941
|
-
rows2.push({ planIndex, memberIndex, scopedId: id });
|
|
65942
|
-
occurrences.set(id, rows2);
|
|
65943
|
-
});
|
|
65944
|
-
});
|
|
65945
|
-
const reserved = new Set([...occurrences.entries()].filter(([, rows2]) => rows2.length === 1).map(([id]) => id));
|
|
65946
|
-
for (const [id, rows2] of occurrences) {
|
|
65947
|
-
if (rows2.length === 1) continue;
|
|
65948
|
-
const plans2 = new Set(rows2.map((row) => row.planIndex));
|
|
65949
|
-
if (plans2.size !== rows2.length) {
|
|
65950
|
-
throw new SceneContractError(`Member id "${id}" is duplicated within one plan and cannot be exported safely.`);
|
|
65951
|
-
}
|
|
65952
|
-
for (const row of rows2) {
|
|
65953
|
-
const readable = `plan:${row.planIndex + 1}:${id}`;
|
|
65954
|
-
let candidate = Buffer.byteLength(readable, "utf8") <= 256 ? readable : `plan:${row.planIndex + 1}:member:${row.memberIndex + 1}`;
|
|
65955
|
-
let suffix = 2;
|
|
65956
|
-
while (reserved.has(candidate)) candidate = `plan:${row.planIndex + 1}:member:${row.memberIndex + 1}:${suffix++}`;
|
|
65957
|
-
reserved.add(candidate);
|
|
65958
|
-
row.scopedId = candidate;
|
|
65959
|
-
}
|
|
65960
|
-
}
|
|
65961
|
-
const resolveMemberRef = (id, jointId) => {
|
|
65962
|
-
if (!id) return id;
|
|
65963
|
-
const rows2 = occurrences.get(id);
|
|
65964
|
-
if (!rows2 || rows2.length === 0) return id;
|
|
65965
|
-
if (rows2.length > 1) {
|
|
65966
|
-
throw new SceneContractError(
|
|
65967
|
-
`Joint "${jointId}" references sheet-ambiguous member id "${id}"; use model-unique member ids before export.`
|
|
65968
|
-
);
|
|
65969
|
-
}
|
|
65970
|
-
return rows2[0].scopedId;
|
|
65971
|
-
};
|
|
65972
|
-
const plans = (contract.plans ?? []).map((plan, planIndex) => ({
|
|
65973
|
-
...plan,
|
|
65974
|
-
members: (plan.members ?? []).map((member, memberIndex) => {
|
|
65975
|
-
const row = occurrences.get(member.id)?.find((item) => item.planIndex === planIndex && item.memberIndex === memberIndex);
|
|
65976
|
-
return row ? { ...member, id: row.scopedId } : { ...member };
|
|
65977
|
-
})
|
|
65978
|
-
}));
|
|
65979
|
-
const joints = (contract.joints ?? []).map((joint) => ({
|
|
65980
|
-
...joint,
|
|
65981
|
-
main: resolveMemberRef(joint.main, joint.id),
|
|
65982
|
-
secondaries: joint.secondaries?.map((id) => resolveMemberRef(id, joint.id) ?? id)
|
|
65983
|
-
}));
|
|
65984
|
-
return { ...contract, plans, joints };
|
|
65985
|
-
}
|
|
65986
65877
|
function foldedWeight(weights, profile) {
|
|
65987
65878
|
const target = canonProfile(profile);
|
|
65988
65879
|
const hit = Object.entries(weights).find(([k]) => canonProfile(k) === target);
|
|
@@ -66213,97 +66104,6 @@ function canonicalConnectionElement(part) {
|
|
|
66213
66104
|
meta: { ...part.meta, name: part.meta.label, connectionId: part.conn, connectionKind: part.connKind }
|
|
66214
66105
|
};
|
|
66215
66106
|
}
|
|
66216
|
-
function structuralGridRecords(contract) {
|
|
66217
|
-
const referenceSystems = [];
|
|
66218
|
-
const unsupported = [];
|
|
66219
|
-
const logical = /* @__PURE__ */ new Map();
|
|
66220
|
-
const equivalent = /* @__PURE__ */ new Set();
|
|
66221
|
-
(contract.plans ?? []).forEach((plan, planIndex) => {
|
|
66222
|
-
const grid = plan.grid;
|
|
66223
|
-
if (!grid || grid.on === false) return;
|
|
66224
|
-
const ptPerFt = plan.pt_per_ft && plan.pt_per_ft > 0 ? plan.pt_per_ft : 1;
|
|
66225
|
-
const geometry = gridGeometry(grid, ptPerFt);
|
|
66226
|
-
const where = plan.sheet || plan.title || `plan ${planIndex + 1}`;
|
|
66227
|
-
if (geometry.errX || geometry.errY || geometry.errZ) {
|
|
66228
|
-
throw new SceneContractError(`Grid on ${where} is invalid: ${geometry.errX || geometry.errY || geometry.errZ}`);
|
|
66229
|
-
}
|
|
66230
|
-
if (!geometry.v.length || !geometry.h.length) {
|
|
66231
|
-
throw new SceneContractError(`Grid on ${where} must contain at least one X axis and one Y axis.`);
|
|
66232
|
-
}
|
|
66233
|
-
if (!geometry.zs.length) throw new SceneContractError(`Grid on ${where} must contain at least one elevation level.`);
|
|
66234
|
-
if (!Array.isArray(grid.origin) || grid.origin.length < 2 || !grid.origin.every((n) => typeof n === "number" && isFinite(n))) {
|
|
66235
|
-
throw new SceneContractError(`Grid on ${where} has an invalid origin.`);
|
|
66236
|
-
}
|
|
66237
|
-
const root6 = `grid:${planIndex + 1}:${String(plan.sheet || plan.title || "main").trim().replace(/\s+/g, "-")}`;
|
|
66238
|
-
const k = mmPerPx(ptPerFt);
|
|
66239
|
-
const [ox, oy] = grid.origin;
|
|
66240
|
-
const toX = (x) => (x - ox) * k;
|
|
66241
|
-
const toY = (y) => -(y - oy) * k;
|
|
66242
|
-
const bounds = {
|
|
66243
|
-
minX: Math.min(toX(geometry.x0), toX(geometry.x1)),
|
|
66244
|
-
maxX: Math.max(toX(geometry.x0), toX(geometry.x1)),
|
|
66245
|
-
minY: Math.min(toY(geometry.y0), toY(geometry.y1)),
|
|
66246
|
-
maxY: Math.max(toY(geometry.y0), toY(geometry.y1))
|
|
66247
|
-
};
|
|
66248
|
-
const axes = [];
|
|
66249
|
-
geometry.v.forEach((axis, index) => {
|
|
66250
|
-
if (!String(axis.label || "").trim()) throw new SceneContractError(`Grid on ${where} has a blank X-axis label.`);
|
|
66251
|
-
const start2 = Math.min(toY(axis.lo), toY(axis.hi));
|
|
66252
|
-
const end = Math.max(toY(axis.lo), toY(axis.hi));
|
|
66253
|
-
axes.push({
|
|
66254
|
-
id: `${root6}:x:${index + 1}`,
|
|
66255
|
-
direction: "x",
|
|
66256
|
-
offsetMm: toX(axis.x),
|
|
66257
|
-
label: String(axis.label).trim(),
|
|
66258
|
-
...Math.abs(start2 - bounds.minY) > 0.5 ? { startMm: start2 } : {},
|
|
66259
|
-
...Math.abs(end - bounds.maxY) > 0.5 ? { endMm: end } : {}
|
|
66260
|
-
});
|
|
66261
|
-
});
|
|
66262
|
-
geometry.h.forEach((axis, index) => {
|
|
66263
|
-
if (!String(axis.label || "").trim()) throw new SceneContractError(`Grid on ${where} has a blank Y-axis label.`);
|
|
66264
|
-
const start2 = Math.min(toX(axis.lo), toX(axis.hi));
|
|
66265
|
-
const end = Math.max(toX(axis.lo), toX(axis.hi));
|
|
66266
|
-
axes.push({
|
|
66267
|
-
id: `${root6}:y:${index + 1}`,
|
|
66268
|
-
direction: "y",
|
|
66269
|
-
offsetMm: toY(axis.y),
|
|
66270
|
-
label: String(axis.label).trim(),
|
|
66271
|
-
...Math.abs(start2 - bounds.minX) > 0.5 ? { startMm: start2 } : {},
|
|
66272
|
-
...Math.abs(end - bounds.maxX) > 0.5 ? { endMm: end } : {}
|
|
66273
|
-
});
|
|
66274
|
-
});
|
|
66275
|
-
const levels = geometry.zs.map((level, index) => {
|
|
66276
|
-
if (!String(level.label || "").trim()) throw new SceneContractError(`Grid on ${where} has a blank elevation label.`);
|
|
66277
|
-
return { id: `${root6}:level:${level.sourceIndex ?? index}`, elevationMm: level.mm, label: String(level.label).trim() };
|
|
66278
|
-
});
|
|
66279
|
-
const record3 = {
|
|
66280
|
-
id: root6,
|
|
66281
|
-
kind: "structural-grid",
|
|
66282
|
-
name: String(plan.title || plan.sheet || `Grid ${planIndex + 1}`).trim(),
|
|
66283
|
-
origin: [ox * k, -oy * k, 0],
|
|
66284
|
-
axes,
|
|
66285
|
-
levels,
|
|
66286
|
-
bounds
|
|
66287
|
-
};
|
|
66288
|
-
const signature = JSON.stringify({ ...record3, id: "", name: "", axes: axes.map(({ id: _id, ...axis }) => axis), levels: levels.map(({ id: _id, ...level }) => level) });
|
|
66289
|
-
const logicalKey = String(plan.sheet || plan.title || `plan-${planIndex + 1}`).trim().toLowerCase();
|
|
66290
|
-
const prior = logical.get(logicalKey);
|
|
66291
|
-
if (prior && prior !== signature) throw new SceneContractError(`Conflicting structural grids share the identity "${logicalKey}".`);
|
|
66292
|
-
logical.set(logicalKey, signature);
|
|
66293
|
-
if (!equivalent.has(signature)) {
|
|
66294
|
-
equivalent.add(signature);
|
|
66295
|
-
referenceSystems.push(record3);
|
|
66296
|
-
}
|
|
66297
|
-
geometry.lines.forEach((line) => unsupported.push({
|
|
66298
|
-
id: `${root6}:free:${line.id}`,
|
|
66299
|
-
kind: "grid-axis",
|
|
66300
|
-
status: "unsupported",
|
|
66301
|
-
code: "free-angle-grid-axis-unrepresentable",
|
|
66302
|
-
message: `Free-angle grid line "${line.label}" cannot be represented by the AWARE v0.90.0 structural-grid contract.`
|
|
66303
|
-
}));
|
|
66304
|
-
});
|
|
66305
|
-
return { referenceSystems, unsupported };
|
|
66306
|
-
}
|
|
66307
66107
|
function contractForMemberSelection(contractInput, memberIds) {
|
|
66308
66108
|
const { view, issues } = readModelOrIssues(contractInput);
|
|
66309
66109
|
if (!view) throw new InvalidModelV2Error(`selection export requires a valid steel.model/v2 contract: ${issues[0] ?? "unknown"}`, issues);
|
|
@@ -66382,24 +66182,6 @@ function contractToAwareScene(contractInput, sourceId) {
|
|
|
66382
66182
|
if (!sourceId.trim()) throw new SceneContractError("A stable export sourceId is required.");
|
|
66383
66183
|
if (isModelV2(contractInput)) return awareSceneFromModel(contractInput, sourceId);
|
|
66384
66184
|
throw new InvalidModelV2Error("export requires a valid steel.model/v2 contract", ["$.type: expected steel.model/v2"]);
|
|
66385
|
-
const contract = contractWithExportScopedMemberIds(contractInput ?? {});
|
|
66386
|
-
const legacy = contractToScene(contract);
|
|
66387
|
-
const { elements, producerUnsupported } = canonicalExportElements(legacy);
|
|
66388
|
-
const grids = structuralGridRecords(contract);
|
|
66389
|
-
producerUnsupported.push(...grids.unsupported);
|
|
66390
|
-
const scene = {
|
|
66391
|
-
meta: {
|
|
66392
|
-
name: contract.title || "Steel Model",
|
|
66393
|
-
units: "mm",
|
|
66394
|
-
sourceId,
|
|
66395
|
-
sceneHash: ""
|
|
66396
|
-
},
|
|
66397
|
-
elements,
|
|
66398
|
-
operations: legacy.operations,
|
|
66399
|
-
referenceSystems: grids.referenceSystems
|
|
66400
|
-
};
|
|
66401
|
-
scene.meta.sceneHash = sceneHash(scene);
|
|
66402
|
-
return { scene, skipped: legacy.skipped, producerUnsupported, coverage: legacy.coverage };
|
|
66403
66185
|
}
|
|
66404
66186
|
function sceneFromModel(view) {
|
|
66405
66187
|
const blocked = membersBlockingExport(view.doc);
|
|
@@ -71154,7 +70936,8 @@ function selectedPopulation(probe, filter) {
|
|
|
71154
70936
|
function emittedFilter(filter) {
|
|
71155
70937
|
const storeys = filter?.storeys?.length ? filter.storeys : void 0;
|
|
71156
70938
|
const ifcTypes = filter?.ifcTypes?.length ? filter.ifcTypes : void 0;
|
|
71157
|
-
|
|
70939
|
+
const ids = filter?.ids?.length ? filter.ids : void 0;
|
|
70940
|
+
return storeys || ifcTypes || ids ? { ...storeys ? { storeys } : {}, ...ifcTypes ? { ifcTypes } : {}, ...ids ? { ids } : {} } : null;
|
|
71158
70941
|
}
|
|
71159
70942
|
function assertSelectionConfirmed(selected2, filter) {
|
|
71160
70943
|
const asked = emittedFilter(filter);
|
|
@@ -71165,7 +70948,7 @@ function assertSelectionConfirmed(selected2, filter) {
|
|
|
71165
70948
|
"reference-filter-unconfirmed"
|
|
71166
70949
|
);
|
|
71167
70950
|
}
|
|
71168
|
-
for (const axis of ["storeys", "ifcTypes"]) {
|
|
70951
|
+
for (const axis of ["storeys", "ifcTypes", "ids"]) {
|
|
71169
70952
|
if (asked[axis]?.length && !selected2[axis]?.length) {
|
|
71170
70953
|
throw new ReferenceImportError(
|
|
71171
70954
|
"the reader confirmed only part of what you chose, so FloLess stopped rather than show you more of the model than you asked for.",
|
|
@@ -71436,6 +71219,7 @@ function readerInvocation(command, ifcPath, filter, progressive = false) {
|
|
|
71436
71219
|
const emit = emittedFilter(filter);
|
|
71437
71220
|
if (emit?.storeys) config.storeys = emit.storeys;
|
|
71438
71221
|
if (emit?.ifcTypes) config["ifc-types"] = emit.ifcTypes;
|
|
71222
|
+
if (emit?.ids) config.ids = emit.ids;
|
|
71439
71223
|
if (progressive && wantsSegments(command, filter)) config["batch-size"] = PREVIEW_BATCH_SIZE;
|
|
71440
71224
|
}
|
|
71441
71225
|
return { command, description: READER_DESCRIPTION[command], config };
|
|
@@ -71948,6 +71732,9 @@ function sidesDiffer(base, revised) {
|
|
|
71948
71732
|
}
|
|
71949
71733
|
var statedBaseSide = (opts) => Object.hasOwn(opts, "baseFilter");
|
|
71950
71734
|
function compareInvocation(basePath, revisedPath, opts = {}) {
|
|
71735
|
+
for (const [which, f] of [["filter", opts.filter], ["baseFilter", opts.baseFilter]]) {
|
|
71736
|
+
if (f?.ids?.length) throw new ReferenceImportError(`compare does not select by object id \u2014 ${which}.ids cannot be honoured`);
|
|
71737
|
+
}
|
|
71951
71738
|
const config = {
|
|
71952
71739
|
"base-ifc-path": basePath,
|
|
71953
71740
|
"revised-ifc-path": revisedPath
|
|
@@ -72072,6 +71859,7 @@ function watchDisconnect(reply, onGone) {
|
|
|
72072
71859
|
// reference-routes.ts
|
|
72073
71860
|
var APPID = /^[a-z0-9][a-z0-9._-]*$/i;
|
|
72074
71861
|
var REFERENCE_BODY_LIMIT = 210 * 1024 * 1024;
|
|
71862
|
+
var GHOST_ID_CAP = 200;
|
|
72075
71863
|
function runScope(deps, reply, opts = {}) {
|
|
72076
71864
|
let current = null;
|
|
72077
71865
|
const signal = opts.detachOnDisconnect ? { gone: () => false, finish: () => {
|
|
@@ -72806,6 +72594,67 @@ function registerReferenceRoutes(app, deps) {
|
|
|
72806
72594
|
}
|
|
72807
72595
|
}
|
|
72808
72596
|
);
|
|
72597
|
+
app.post(
|
|
72598
|
+
"/api/steel/:appId/reference/:id/ghosts",
|
|
72599
|
+
async (req, reply) => {
|
|
72600
|
+
const scope = runScope(deps, reply);
|
|
72601
|
+
const g = gate2(deps, req.params.appId, req.query.project);
|
|
72602
|
+
if (!g.ok) return reply.status(g.refusal.status).send(g.refusal.body);
|
|
72603
|
+
const entry2 = referencesOf(g.doc).find((r) => r.id === req.params.id);
|
|
72604
|
+
if (!entry2) return reply.status(404).send({ ok: false, error: "no such reference model" });
|
|
72605
|
+
const versionId = req.body?.versionId;
|
|
72606
|
+
const version = typeof versionId === "string" && versionId ? (entry2.versions ?? []).find((v) => v.id === versionId) : void 0;
|
|
72607
|
+
if (!version) {
|
|
72608
|
+
return reply.status(409).send({
|
|
72609
|
+
ok: false,
|
|
72610
|
+
code: "reference-ghost-version-unknown",
|
|
72611
|
+
error: `"${entry2.name}" has no version by that name any more, so the objects that were removed cannot be drawn where they used to be`
|
|
72612
|
+
});
|
|
72613
|
+
}
|
|
72614
|
+
const asked = Array.isArray(req.body?.ids) ? req.body.ids : [];
|
|
72615
|
+
const ids = [...new Set(asked.filter((s) => typeof s === "string" && !!s.trim()))];
|
|
72616
|
+
if (!ids.length) {
|
|
72617
|
+
return reply.status(400).send({ ok: false, code: "reference-ghost-ids-missing", error: "say which objects to draw" });
|
|
72618
|
+
}
|
|
72619
|
+
if (ids.length > GHOST_ID_CAP) {
|
|
72620
|
+
return reply.status(400).send({
|
|
72621
|
+
ok: false,
|
|
72622
|
+
code: "reference-ghost-too-many",
|
|
72623
|
+
error: `FloLess draws at most ${GHOST_ID_CAP} removed objects at a time, and this asked for ${ids.length.toLocaleString("en-US")}`,
|
|
72624
|
+
cap: GHOST_ID_CAP
|
|
72625
|
+
});
|
|
72626
|
+
}
|
|
72627
|
+
try {
|
|
72628
|
+
const abs = originalPath(g.project, version.file);
|
|
72629
|
+
if (!abs) {
|
|
72630
|
+
return reply.status(409).send({
|
|
72631
|
+
ok: false,
|
|
72632
|
+
code: "reference-ghost-file-missing",
|
|
72633
|
+
error: `The file behind version "${version.name}" is no longer in this project, so the objects that were removed cannot be drawn where they used to be. The change list below is unaffected.`
|
|
72634
|
+
});
|
|
72635
|
+
}
|
|
72636
|
+
const geometry = await deps.reader.readModel(companion(g.appId), abs, { ticket: scope.ticket(), filter: { ids } });
|
|
72637
|
+
const unmatched = geometry.selected?.unmatched ?? [];
|
|
72638
|
+
const missing = unmatched.map((u) => typeof u.id === "string" ? u.id : null).filter((s) => !!s);
|
|
72639
|
+
const unresolved = hasUnmatched(geometry.selected ?? null) ? unmatched.length : 0;
|
|
72640
|
+
return {
|
|
72641
|
+
ok: true,
|
|
72642
|
+
versionId: version.id,
|
|
72643
|
+
objects: geometry.objects,
|
|
72644
|
+
dropped: geometry.dropped,
|
|
72645
|
+
...missing.length ? { missing } : {},
|
|
72646
|
+
...unresolved ? { unresolved } : {}
|
|
72647
|
+
};
|
|
72648
|
+
} catch (e) {
|
|
72649
|
+
const r = importRefusal(e);
|
|
72650
|
+
if (r) return reply.status(r.status).send(r.body);
|
|
72651
|
+
app.log.error({ appId: g.appId, id: entry2.id, versionId: version.id, ids: ids.length, err: e }, "reference ghost read failed");
|
|
72652
|
+
return reply.status(500).send({ ok: false, code: "reference-ghost-failed", error: `could not read the removed objects of "${entry2.name}"` });
|
|
72653
|
+
} finally {
|
|
72654
|
+
scope.finish();
|
|
72655
|
+
}
|
|
72656
|
+
}
|
|
72657
|
+
);
|
|
72809
72658
|
app.delete(
|
|
72810
72659
|
"/api/steel/:appId/reference/:id",
|
|
72811
72660
|
async (req, reply) => {
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* reference-changes — what changed between two versions of a reference model. Refs #734, design §7.
|
|
3
|
+
*
|
|
4
|
+
* A reference model is borrowed geometry we never own: an IFC someone else authored, overlaid in the
|
|
5
|
+
* steel editor so you can see it, measure it and snap to it. The architect sends the NEXT version of
|
|
6
|
+
* that file; this panel is the answer to "what actually moved?".
|
|
7
|
+
*
|
|
8
|
+
* THIS MODULE RENDERS AN ANSWER IT DOES NOT COMPUTE. AWARE matches the objects (on IFC GlobalId and
|
|
9
|
+
* nothing else) and `server/reference-compare.ts` validates the response; everything here reads numbers
|
|
10
|
+
* out of that answer and draws them. floless never parses IFC and never compares geometry (CLAUDE.md).
|
|
11
|
+
*
|
|
12
|
+
* THE REFUSAL IS NOT AN ERROR STATE, AND DRAWING IT AS ONE WOULD BE A LIE OF TONE. When no ids pair,
|
|
13
|
+
* "everything added and everything removed" is the symptom of an exporter that regenerated every id, so
|
|
14
|
+
* AWARE returns no `changes` array at all and the server throws rather than handing us one. That is a
|
|
15
|
+
* correct, complete answer about two files that do not relate — not a failure of ours — so it is drawn
|
|
16
|
+
* in the neutral tokens, never `--err` red. THERE IS NO "COMPARE ANYWAY" AND THERE NEVER WILL BE: with
|
|
17
|
+
* no geometry fallback there is nothing left to compare with, so the button could only produce the
|
|
18
|
+
* fabricated list the refusal exists to prevent.
|
|
19
|
+
*
|
|
20
|
+
* TOKENS ARE THIS PAGE'S OWN. `web/steel-editor.html` DOES NOT LOAD `web/app.css` — it says so at :64
|
|
21
|
+
* and :995 — so `--surface-2`, `.guide-step`, `.canvas-empty` and friends do not exist here. Everything
|
|
22
|
+
* below uses the editor's vocabulary (`--panel`, `--sunken`, `--field`, `--mut`, `--line`, and the
|
|
23
|
+
* `--ok`/`--warn`/`--err` ink+bg+edge triads). A token that resolves to nothing fails SILENTLY and looks
|
|
24
|
+
* like an unstyled element rather than an error, so verify a name is in that page's `:root` before use.
|
|
25
|
+
*
|
|
26
|
+
* NO BESPOKE SCROLLBAR CSS IS NEEDED. The page's global `*{scrollbar-width:thin;scrollbar-color:…}` and
|
|
27
|
+
* `*::-webkit-scrollbar*` rules (`web/steel-editor.html:179`) already reach any container added here —
|
|
28
|
+
* the same reason the import modal's picker declares none (:1273). One outer scroll container owns the
|
|
29
|
+
* whole panel; nested scrollports are both where a native bar leaks in and a worse interaction.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/** Every count in design §7.3's header line. `uncomparable` is the one a clean-looking list hides. */
|
|
33
|
+
export const STAT_ORDER = ['added', 'removed', 'changed', 'uncomparable', 'unchanged'];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* How a status reads — glyph, word, and class — because COLOUR ALONE IS NOT AN ENCODING.
|
|
37
|
+
*
|
|
38
|
+
* Each of the FOUR that assert something carries a glyph and a word in the DOM as well as a colour, so
|
|
39
|
+
* the list survives a colourblind reader, a grayscale print and a `data-tip` nobody hovers. (`unchanged`
|
|
40
|
+
* carries neither — see below, and the test asserts the glyphs for the four alone.) `uncomparable` is deliberately DASHED rather
|
|
41
|
+
* than filled even though it borrows the same amber as `changed`: shape is a distinction that survives
|
|
42
|
+
* losing colour entirely, and dashed says "we do not know" where filled asserts a fact.
|
|
43
|
+
*
|
|
44
|
+
* `unchanged` gets NO chip at all. Its whole job is to recede — a badge of equal weight to the other
|
|
45
|
+
* four fights the one thing it is there to communicate.
|
|
46
|
+
*/
|
|
47
|
+
export const STATUS = {
|
|
48
|
+
added: { glyph: '+', word: 'added', cls: 'rc-chip rc-add' },
|
|
49
|
+
removed: { glyph: '−', word: 'removed', cls: 'rc-chip rc-rem' },
|
|
50
|
+
changed: { glyph: '~', word: 'changed', cls: 'rc-chip rc-chg' },
|
|
51
|
+
uncomparable: { glyph: '?', word: 'could not compare', cls: 'rc-chip rc-unk' },
|
|
52
|
+
unchanged: { glyph: '', word: 'unchanged', cls: 'rc-plain' },
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The cap, and it is THIS PAGE'S CAP rather than a new one.
|
|
57
|
+
*
|
|
58
|
+
* The reference object tree solved this exact problem on this exact data and wrote down the
|
|
59
|
+
* measurement: filtering one real building for "mullion" matched ~8,000 objects across ten storeys, and
|
|
60
|
+
* force-expanding them built 2,795 rows — "a wall". So the list is capped and SAYS SO. A silent cap
|
|
61
|
+
* reads as "that is all there was", which on a change list is the same class of lie as folding
|
|
62
|
+
* `uncomparable` into `unchanged`.
|
|
63
|
+
*
|
|
64
|
+
* Kept in step with `REF_TREE_CAP` in `web/steel-editor.html` by intent, not by import: this file is an
|
|
65
|
+
* ES module surfaced on `window` by the same shim the page uses for `GridCore` (find it as
|
|
66
|
+
* `window.ReferenceChanges=RC`), while `REF_TREE_CAP` is a binding inside the editor's big inline
|
|
67
|
+
* classic script, which no module can see.
|
|
68
|
+
*
|
|
69
|
+
* AND NOW SOMETHING WATCHES. `server/reference-caps-parity.test.ts` reads both literals out of the two
|
|
70
|
+
* files and fails when they diverge — "kept in step by intent" is another way of saying unenforced.
|
|
71
|
+
* Cited by SYMBOL rather than line number, because every line citation this feature shipped had already
|
|
72
|
+
* drifted 20-150 lines inside the commit that wrote it.
|
|
73
|
+
*/
|
|
74
|
+
export const RC_CAP = 300;
|
|
75
|
+
|
|
76
|
+
/** `12806` → `12,806`. The page's own convention: the editor formats every count this way. NO COUNT OF
|
|
77
|
+
* USES IS QUOTED — one was, and it went stale on the very commit that quoted it. */
|
|
78
|
+
const num = (n) => (Number.isFinite(n) ? n.toLocaleString() : '—');
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* A distance in words as well as numbers, because "moved 250 mm" is the sentence a person reads.
|
|
82
|
+
*
|
|
83
|
+
* Only ever rendered when `location` actually fired. A column reserved for every changed row would be
|
|
84
|
+
* dead space in the ~90% that did not move, and a "0 mm" printed against a reprofiled column would be
|
|
85
|
+
* an assertion nobody made.
|
|
86
|
+
*/
|
|
87
|
+
export function movedPhrase(change) {
|
|
88
|
+
if (!change || !Array.isArray(change.changedBy) || !change.changedBy.includes('location')) return null;
|
|
89
|
+
const d = change.distance;
|
|
90
|
+
if (!Number.isFinite(d)) return null;
|
|
91
|
+
// Millimetres, one decimal under 10 so a sub-millimetre move is not rounded into "moved 0 mm" — which
|
|
92
|
+
// would read as "it did not move" for the exact case the tolerance was argued over.
|
|
93
|
+
const shown = d < 10 ? d.toFixed(1).replace(/\.0$/, '') : Math.round(d).toLocaleString();
|
|
94
|
+
return 'moved ' + shown + ' mm';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The five header counts, in the order urgency actually runs.
|
|
99
|
+
*
|
|
100
|
+
* NOT A SENTENCE. Rendered as prose, "12,806 unchanged" is the widest and loudest span on the line
|
|
101
|
+
* purely because it has five digits — the count that carries the least meaning dominating by accident of
|
|
102
|
+
* magnitude. As chips, the four that carry a decision or a fact sit at equal weight and `unchanged`
|
|
103
|
+
* comes last, toned down, reading as the odd one out rather than the anchor.
|
|
104
|
+
*
|
|
105
|
+
* EVERY COUNT APPEARS, including `uncomparable` and including zeroes. A zero that is drawn is a fact
|
|
106
|
+
* ("nothing was uncomparable"); a zero that is hidden is indistinguishable from a question nobody asked.
|
|
107
|
+
*/
|
|
108
|
+
export function summaryStats(summary) {
|
|
109
|
+
if (!summary) return [];
|
|
110
|
+
return STAT_ORDER.map((key) => ({
|
|
111
|
+
key,
|
|
112
|
+
n: summary[key],
|
|
113
|
+
text: num(summary[key]),
|
|
114
|
+
word: STATUS[key].word,
|
|
115
|
+
glyph: STATUS[key].glyph,
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Which groups open themselves: the ones holding something to look at.
|
|
121
|
+
*
|
|
122
|
+
* The same instinct as the object tree's `wide` rule — never dump the whole building open, but never
|
|
123
|
+
* hide the thing that matters behind a chevron either. A storey that is 100% unchanged opens collapsed
|
|
124
|
+
* showing only its count, which is the honest summary of a storey nobody needs to read.
|
|
125
|
+
*/
|
|
126
|
+
export function groupNeedsAttention(rows) {
|
|
127
|
+
return Array.isArray(rows) && rows.some((r) => r && r.status && r.status !== 'unchanged');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The default view is "needs attention" — added, removed, changed, uncomparable.
|
|
132
|
+
*
|
|
133
|
+
* BOTH A READ AND A BUDGET. The unchanged rows are the ones nobody asked about, and not building them is
|
|
134
|
+
* also the cheap half of the performance answer: a 12,806-row DOM built on open is the wall the cap
|
|
135
|
+
* exists to prevent, reached before the user has typed anything.
|
|
136
|
+
*/
|
|
137
|
+
export function needsAttention(change) {
|
|
138
|
+
return !!change && change.status !== 'unchanged';
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The window actually drawn, and the sentence that admits to it.
|
|
143
|
+
*
|
|
144
|
+
* Returns `{ shown, note }` — `note` is null only when nothing was withheld. Mirrors the object tree's
|
|
145
|
+
* centred-window recipe so a row the caller wants in view survives the cap rather than being sliced off
|
|
146
|
+
* the end of it.
|
|
147
|
+
*/
|
|
148
|
+
export function capWindow(list, wantIdx) {
|
|
149
|
+
const all = Array.isArray(list) ? list : [];
|
|
150
|
+
if (all.length <= RC_CAP) return { shown: all, note: null };
|
|
151
|
+
let from = 0;
|
|
152
|
+
if (Number.isFinite(wantIdx) && wantIdx >= RC_CAP) from = Math.min(wantIdx - (RC_CAP >> 1), all.length - RC_CAP);
|
|
153
|
+
return {
|
|
154
|
+
shown: all.slice(from, from + RC_CAP),
|
|
155
|
+
note: 'Showing ' + RC_CAP + ' of ' + num(all.length) + ' — use the filter above to narrow this list.',
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The refusal's copy, built from the numbers AWARE actually reported.
|
|
161
|
+
*
|
|
162
|
+
* PLAIN ENGLISH AND IT DOES NOT BLAME THE USER. The two causes it names are the two that are real — this
|
|
163
|
+
* is not a revision of that file, or the exporter regenerated every id — and neither is something the
|
|
164
|
+
* person reading did. The wording is design §7.3's, kept verbatim through review.
|
|
165
|
+
*/
|
|
166
|
+
export function refusalCopy(refused, baseName) {
|
|
167
|
+
const revised = refused && refused.revisedName ? refused.revisedName : 'the new file';
|
|
168
|
+
const base = baseName || 'the version you have';
|
|
169
|
+
const n = refused && Number.isFinite(refused.revisedObjects) ? num(refused.revisedObjects) + ' objects' : 'its objects';
|
|
170
|
+
return {
|
|
171
|
+
lead: 'Nothing in these two files could be matched — none of ' + revised + "'s " + n +
|
|
172
|
+
' share an IFC id with ' + base + '.',
|
|
173
|
+
why: 'Either this is not a revision of ' + base + ', or the tool that exported it gave every object a new id.',
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* The three ways out of a refusal, weighted rather than equal.
|
|
179
|
+
*
|
|
180
|
+
* Design §7.3 calls the middle one "the honest remedy" and then draws three identical buttons, which
|
|
181
|
+
* undersells its own framing. Both files loaded side by side is a workflow that already works today and
|
|
182
|
+
* is what a user actually wants when the automatic answer is unavailable — so it is the primary, and the
|
|
183
|
+
* order runs quietest to loudest.
|
|
184
|
+
*
|
|
185
|
+
* THERE IS NO FOURTH BUTTON. See the module header.
|
|
186
|
+
*/
|
|
187
|
+
export const REFUSAL_ACTIONS = [
|
|
188
|
+
{ id: 'cancel', label: 'Cancel', weight: 'ghost' },
|
|
189
|
+
{ id: 'otherfile', label: 'Choose a different file', weight: 'secondary' },
|
|
190
|
+
{ id: 'separate', label: 'Load it as a separate reference instead', weight: 'primary' },
|
|
191
|
+
];
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Is this comparison like-for-like?
|
|
195
|
+
*
|
|
196
|
+
* A new version read under a different scope than the old one, with nothing saying so, is design §10's
|
|
197
|
+
* "must never happen": rows would appear as added or removed because of the FILTER rather than because
|
|
198
|
+
* the building changed. `selected` carries a receipt per side precisely so this is answerable.
|
|
199
|
+
*/
|
|
200
|
+
export function filterDiffers(selected) {
|
|
201
|
+
if (!selected) return false;
|
|
202
|
+
// WRITTEN AS ESCAPES, NOT AS RAW BYTES, and that is the whole change here — the behaviour is what it
|
|
203
|
+
// always was. These separators used to be literal U+0001/U+0002 characters in the source, which every
|
|
204
|
+
// reader renders as nothing: the line LOOKED like `join('')` with `+ '' +` between the axes. Two
|
|
205
|
+
// independent reviewers duly reported a collision bug that does not exist, and the next reader would
|
|
206
|
+
// eventually have 'fixed' the invisible separators away and created it for real.
|
|
207
|
+
//
|
|
208
|
+
// THEY ARE LOAD-BEARING. Without them `{storeys:['IfcWall']}` and `{ifcTypes:['IfcWall']}` normalise
|
|
209
|
+
// identically, as do `['L1','L2']` and `['L1L2']` — a silent FALSE NEGATIVE on the one check that
|
|
210
|
+
// stops rows being read as "the building changed" when the FILTER changed, which design §10 calls a
|
|
211
|
+
// thing that must never happen. Neither character can occur in an IFC storey or type name.
|
|
212
|
+
const ITEM = '\u0001', AXIS = '\u0002';
|
|
213
|
+
const norm = (s) => {
|
|
214
|
+
if (!s) return '';
|
|
215
|
+
const part = (v) => (Array.isArray(v) && v.length ? [...v].sort().join(ITEM) : '');
|
|
216
|
+
return part(s.storeys) + AXIS + part(s.ifcTypes) + AXIS + part(s.ids);
|
|
217
|
+
};
|
|
218
|
+
return norm(selected.base) !== norm(selected.revised);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export default {
|
|
222
|
+
RC_CAP, STATUS, STAT_ORDER, REFUSAL_ACTIONS,
|
|
223
|
+
summaryStats, movedPhrase, groupNeedsAttention, needsAttention, capWindow, refusalCopy, filterDiffers,
|
|
224
|
+
};
|