@floless/app 0.172.0 → 0.172.1

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.
@@ -1535,20 +1535,21 @@ export function elementIssues(doc) {
1535
1535
 
1536
1536
  // ---- honest wording: nothing reads "done" for something not drawn or counted ---------------------------
1537
1537
 
1538
- /** E1a: elements are stored and checked, but no sink draws or counts them yet (each sink flips this in E1b/E3). */
1539
- export const SINKS_DRAWING_ELEMENTS = Object.freeze({ view3d: false, plan: false, bom: false, glb: false, ifc: false, host: false });
1538
+ /** Which sinks draw or count elements: E1b draws them in the 3D view, on plans and in the .glb, and bills them; IFC goes through AWARE's gate (element-aware.ts); a host send is E3. */
1539
+ export const SINKS_DRAWING_ELEMENTS = Object.freeze({ view3d: true, plan: true, bom: true, glb: true, ifc: false, host: false });
1540
1540
  export const NEXT_UPDATE = 'that arrives in the next FloLess update';
1541
1541
 
1542
1542
  /**
1543
- * What a chat action says after adding or changing an element (condition 1 of the E1a brief).
1543
+ * What a chat action says after adding or changing an element (condition 1 of the E1a brief): where it now shows, and
1544
+ * that the bill counts it only once it is checked or its values are kept as an assumption, never "done" before.
1544
1545
  * @param {any} element the element (its kind and id)
1545
1546
  * @param {string} [verb]
1546
1547
  * @param {string} [form]
1547
1548
  */
1548
- export function notDrawnYetSentence(element, verb = 'added to the model', form = undefined) {
1549
+ export function elementChangeSentence(element, verb = 'added to the model', form = undefined) {
1549
1550
  const word = kindWord(element.kind, form);
1550
1551
  if (element.kind === UNMODELLED) return `${word} ${element.id} ${verb}. It is not listed in the bill yet; ${NEXT_UPDATE}.`;
1551
- return `${word} ${element.id} ${verb}. It is not drawn in the 3D view or counted in the bill yet; ${NEXT_UPDATE}.`;
1552
+ return `${word} ${element.id} ${verb}. It shows in the 3D view and on plans, and the bill counts it once FloLess has checked it or you keep its values as an assumption.`;
1552
1553
  }
1553
1554
 
1554
1555
  /** The words a person's acceptance of stored values records when they give none of their own. */
@@ -1557,7 +1558,7 @@ export function defaultStoredValuesStatement(id) {
1557
1558
  }
1558
1559
 
1559
1560
  /** The same fact for a whole model, said once beside a list of elements. */
1560
- export const ELEMENTS_NOT_DRAWN_YET = `Walls, slabs and footings are stored and checked, but not drawn in the 3D view or counted in the bill yet; ${NEXT_UPDATE}.`;
1561
+ export const ELEMENTS_WHERE_SHOWN = `Walls, slabs and footings show in the 3D view and on plans, and the bill counts the ones FloLess has checked or whose values are kept as an assumption; an IFC file carries them where AWARE can write them, and sending them to a host application ${NEXT_UPDATE}.`;
1561
1562
 
1562
1563
  const SINK_NAMES = { view3d: 'this 3D view', plan: 'this plan', bom: 'this bill', glb: 'this 3D file', ifc: 'this IFC file', host: 'this send' };
1563
1564
 
@@ -1567,9 +1568,12 @@ const SINK_NAMES = { view3d: 'this 3D view', plan: 'this plan', bom: 'this bill'
1567
1568
  * @param {'view3d'|'plan'|'bom'|'glb'|'ifc'|'host'} sink
1568
1569
  * @returns {{ count: number, ids: string[], byKind: Record<string, number>, sentence: string } | null}
1569
1570
  */
1570
- export function elementsLeftOut(doc, sink) {
1571
- const elements = (Array.isArray(doc?.elements) ? doc.elements : []).filter(isObj);
1572
- if (!elements.length) return null;
1571
+ export function elementsLeftOut(doc, sink, opts = {}, results = undefined) {
1572
+ const all = (Array.isArray(doc?.elements) ? doc.elements : []).filter(isObj);
1573
+ if (!all.length) return null;
1574
+ // A sink that draws (or counts) elements names only the ones it does not, each with why (#3296 E1b).
1575
+ if (SINKS_DRAWING_ELEMENTS[sink]) return elementsNotShown(all, results ?? elementSinkResults(doc, opts), sink);
1576
+ const elements = all;
1573
1577
  const byKind = {};
1574
1578
  for (const e of elements) { const w = kindWord(e.kind); byKind[w] = (byKind[w] ?? 0) + 1; }
1575
1579
  const list = Object.entries(byKind).map(([w, n]) => `${n} ${w.toLowerCase()}${n === 1 ? '' : 's'}`).join(', ');
@@ -1578,9 +1582,32 @@ export function elementsLeftOut(doc, sink) {
1578
1582
  : sink === 'host'
1579
1583
  ? 'FloLess does not send walls, slabs and footings to a host model yet'
1580
1584
  : `FloLess does not ${sink === 'bom' ? 'count' : 'draw'} walls, slabs and footings here yet`;
1585
+ // Each one is named (#3296 E1b QA), so the person can tell which of their walls, slabs and footings are missing.
1586
+ const ids = elements.map((e) => e.id).sort();
1587
+ const named = `${ids.slice(0, 20).join(', ')}${ids.length > 20 ? ` and ${ids.length - 20} more` : ''}`;
1581
1588
  return {
1582
- count: elements.length, ids: elements.map((e) => e.id).sort(), byKind,
1583
- sentence: `${list} ${elements.length === 1 ? 'is' : 'are'} left out of ${SINK_NAMES[sink]}: ${why}; ${NEXT_UPDATE}.`,
1589
+ count: elements.length, ids, byKind,
1590
+ sentence: `${list} (${named}) ${elements.length === 1 ? 'is' : 'are'} left out of ${SINK_NAMES[sink]}: ${why}; ${NEXT_UPDATE}.`,
1591
+ };
1592
+ }
1593
+
1594
+ /** The elements a drawing (or counting) sink does not show, each named with why; null when it shows them all. */
1595
+ function elementsNotShown(all, results, sink) {
1596
+ const counts = sink === 'bom';
1597
+ const out = all.filter((e) => { const r = results.get(e.id); return !r || !(counts ? r.counted : r.drawable); });
1598
+ if (!out.length) return null;
1599
+ const byKind = {};
1600
+ for (const e of out) { const w = kindWord(e.kind); byKind[w] = (byKind[w] ?? 0) + 1; }
1601
+ const list = Object.entries(byKind).map(([w, n]) => `${n} ${w.toLowerCase()}${n === 1 ? '' : 's'}`).join(', ');
1602
+ const why = (e) => {
1603
+ const r = results.get(e.id);
1604
+ if (counts) return r?.reason ?? 'FloLess cannot count it';
1605
+ return r?.evaluated ? 'its values carry no solid FloLess can draw' : (r?.reason ?? 'FloLess cannot work out its solid');
1606
+ };
1607
+ const named = out.slice(0, 20).map((e) => `${e.id} (${why(e)})`).join('; ');
1608
+ return {
1609
+ count: out.length, ids: out.map((e) => e.id).sort(), byKind,
1610
+ sentence: `${list} ${out.length === 1 ? 'is' : 'are'} left out of ${SINK_NAMES[sink]}: ${named}${out.length > 20 ? `; and ${out.length - 20} more` : ''}.`,
1584
1611
  };
1585
1612
  }
1586
1613
 
@@ -1616,8 +1643,8 @@ export function elementSaveWarning(doc, opts = {}) {
1616
1643
  }
1617
1644
 
1618
1645
  /** The receipt as a reply field, `{ elementsLeftOut }`, or nothing when the model has no elements. */
1619
- export function elementsLeftOutAnswer(doc, sink) {
1620
- const e = elementsLeftOut(doc, sink);
1646
+ export function elementsLeftOutAnswer(doc, sink, opts = {}) {
1647
+ const e = elementsLeftOut(doc, sink, opts);
1621
1648
  return e ? { elementsLeftOut: e } : {};
1622
1649
  }
1623
1650
 
@@ -1626,8 +1653,8 @@ export function elementsLeftOutAnswer(doc, sink) {
1626
1653
  * @param {any} doc
1627
1654
  * @param {'view3d'|'plan'|'bom'|'glb'|'ifc'|'host'} sink
1628
1655
  */
1629
- export function elementLeftOutRows(doc, sink) {
1630
- const e = elementsLeftOut(doc, sink);
1656
+ export function elementLeftOutRows(doc, sink, opts = {}) {
1657
+ const e = elementsLeftOut(doc, sink, opts);
1631
1658
  return e ? [{ kind: 'element-not-exported', count: e.count, reason: e.sentence, ids: e.ids }] : [];
1632
1659
  }
1633
1660
 
@@ -1641,3 +1668,217 @@ export function glbMaterialExtras(evaluated) {
1641
1668
  ...(m.material?.density ? { density: { kgM3: m.material.density.kgM3, status: m.material.density.status, basis: m.material.density.basis } } : {}),
1642
1669
  }));
1643
1670
  }
1671
+
1672
+ // ---- the sinks (E1b, plan 2026-11-17-s3-e1b-sinks-PLAN.md revision 2) ------------------------------------
1673
+
1674
+ /** What a sink says of a result FloLess worked out itself (its stored values match what FloLess works out now). */
1675
+ // It says what FloLess did, never that the element was checked: its fit is only partly checked (ELEMENT_FIT_NOT_CHECKED).
1676
+ export const CHECKED_LABEL = 'quantities worked out by FloLess from its type';
1677
+ /** What a sink says of the person's accepted values: drawn and counted as theirs, never as checked. */
1678
+ export const ACCEPTED_LABEL = "the person's accepted values, not checked by FloLess";
1679
+
1680
+ const isPoint2 = (q) => Array.isArray(q) && q.length === 2 && Number.isFinite(q[0]) && Number.isFinite(q[1]);
1681
+
1682
+ /**
1683
+ * Whether a result carries geometry every sink can draw: vertical prisms with real rings and a real height.
1684
+ * @param {any} evaluated
1685
+ */
1686
+ export function drawableGeometry(evaluated) {
1687
+ const prisms = evaluated?.geometry?.format === GEOMETRY_FORMAT ? evaluated.geometry.data?.prisms : null;
1688
+ return Array.isArray(prisms) && prisms.length > 0 && prisms.every((p) => isObj(p)
1689
+ && Array.isArray(p.outline) && p.outline.length >= 3 && p.outline.every(isPoint2)
1690
+ && (p.holes === undefined || (Array.isArray(p.holes) && p.holes.every((h) => Array.isArray(h) && h.length >= 3 && h.every(isPoint2))))
1691
+ && Number.isFinite(p.bottomZ) && Number.isFinite(p.topZ) && p.topZ > p.bottomZ);
1692
+ }
1693
+
1694
+ /**
1695
+ * The one result each sink uses for an element, by its status (plan rev 2 §3), so a drawing and a count never
1696
+ * describe different solids:
1697
+ * - verified: FloLess's result (the stored one is the same), drawn and counted;
1698
+ * - accepted / assumed: the STORED result, geometry and quantities together, drawn and counted as the person's
1699
+ * accepted values, never as checked;
1700
+ * - drifted / held / unknown / record: FloLess's result where it can work one out, drawn and labelled "not counted",
1701
+ * with the reason; no result at all is left out and named.
1702
+ * @param {any} doc
1703
+ * @param {EvaluationOptions} [opts]
1704
+ * @returns {Map<string, { element: any, status: string, reason?: string, counted: boolean, source: 'floless'|'stored'|null, evaluated: any, drawable: boolean, label: string }>}
1705
+ */
1706
+ export function elementSinkResults(doc, opts = {}) {
1707
+ const verification = verifyElements(doc, opts);
1708
+ const results = evaluateModel(doc, opts);
1709
+ const out = new Map();
1710
+ for (const e of (Array.isArray(doc?.elements) ? doc.elements : []).filter(isObj)) {
1711
+ const v = verification.get(e.id) ?? { status: 'held', reason: 'it could not be checked' };
1712
+ const fresh = results.get(e.id)?.evaluated ?? null;
1713
+ const stored = isObj(e.evaluated) ? e.evaluated : null;
1714
+ let evaluated = null; let source = null; let counted = false; let label;
1715
+ if (v.status === 'verified') { evaluated = fresh; source = 'floless'; counted = true; label = CHECKED_LABEL; }
1716
+ else if (v.status === 'accepted' || v.status === 'assumed') {
1717
+ evaluated = stored; source = 'stored'; counted = true;
1718
+ label = `${ACCEPTED_LABEL}${v.reason ? `: ${v.reason}` : ''}`;
1719
+ } else {
1720
+ evaluated = fresh; source = fresh ? 'floless' : null;
1721
+ label = `not counted: ${v.reason ?? v.status}`;
1722
+ }
1723
+ out.set(e.id, {
1724
+ element: e, status: v.status, ...(v.reason ? { reason: v.reason } : {}), counted, source: evaluated ? source : null,
1725
+ evaluated, drawable: drawableGeometry(evaluated), label,
1726
+ });
1727
+ }
1728
+ return out;
1729
+ }
1730
+
1731
+ /** An element's type, or undefined. */
1732
+ function typeOfElement(doc, e) {
1733
+ return (Array.isArray(doc?.element_types) ? doc.element_types : []).find((t) => isObj(t) && t.id === e.typeId);
1734
+ }
1735
+
1736
+ /**
1737
+ * The words and facts every sink carries for an element (the 3D labels, the Model Share pick strip, the `.glb`
1738
+ * extras): what it is, what it is made of with where the density came from, its quantities, and whether it is counted.
1739
+ * @param {any} doc
1740
+ * @param {ReturnType<typeof elementSinkResults> extends Map<string, infer V> ? V : never} r
1741
+ */
1742
+ export function elementSinkMeta(doc, r) {
1743
+ const e = r.element;
1744
+ const type = typeOfElement(doc, e);
1745
+ const form = type?.inputs?.form ?? type?.payload?.form;
1746
+ const materials = (r.evaluated?.semantics?.materials ?? []).filter(isObj).map((m) => ({
1747
+ name: m.material?.name, class: m.material?.class, thicknessMm: m.thicknessMm,
1748
+ density: m.material?.density?.kgM3 ?? 'missing',
1749
+ ...(isObj(m.material?.ref) ? { source: { catalogId: m.material.ref.catalogId, environment: m.material.ref.environment } } : {}),
1750
+ }));
1751
+ return {
1752
+ elementId: e.id, elementKind: e.kind, word: kindWord(e.kind, form), ...(e.mark ? { mark: e.mark } : {}),
1753
+ ...(e.typeId ? { typeId: e.typeId } : {}), ...(type ? { typeName: typeDisplayName(type) } : {}),
1754
+ status: r.status, ...(r.reason ? { reason: r.reason } : {}), counted: r.counted, label: r.label,
1755
+ ...(r.source ? { source: r.source } : {}),
1756
+ ...(materials.length ? { materials, densityBasis: DENSITY_BASIS } : {}),
1757
+ ...(r.counted && isObj(r.evaluated?.quantities) ? { quantities: r.evaluated.quantities } : {}),
1758
+ };
1759
+ }
1760
+
1761
+ /**
1762
+ * The editor scene items for the elements (plan rev 2 §2): one `extrusion` per prism, in world mm, `role: 'element'`
1763
+ * (no depth floor: the evaluator never gives a sink a prism without height), the element's facts in `meta`.
1764
+ * @param {any} doc
1765
+ * @param {EvaluationOptions} [opts]
1766
+ * @param {ReturnType<typeof elementSinkResults>} [results]
1767
+ */
1768
+ export function elementSceneItems(doc, opts = {}, results = elementSinkResults(doc, opts)) {
1769
+ const items = [];
1770
+ for (const [id, r] of results) {
1771
+ if (!r.drawable) continue;
1772
+ const meta = elementSinkMeta(doc, r);
1773
+ r.evaluated.geometry.data.prisms.forEach((p, n) => items.push({
1774
+ // A held or drifted element draws in its own see-through group, never looking like a checked one (review E1b).
1775
+ kind: 'extrusion', role: 'element', id: n ? `${id}#${n}` : id, group: r.counted ? 'element' : 'element-held',
1776
+ footprint: p.outline.map((q) => [q[0], q[1]]),
1777
+ holes: (p.holes ?? []).map((h) => h.map((q) => [q[0], q[1]])),
1778
+ from: p.bottomZ, to: p.topZ, meta,
1779
+ }));
1780
+ }
1781
+ return items;
1782
+ }
1783
+
1784
+ /**
1785
+ * What a plan needs to draw the elements (plan rev 2 §6; `web/element-plan.js` decides what each plan shows): one
1786
+ * entry per drawable element with its prisms in world mm and the words its tooltip says. Nothing is worked out here
1787
+ * that the other sinks do not already use.
1788
+ * @param {any} doc
1789
+ * @param {EvaluationOptions} [opts]
1790
+ */
1791
+ export function elementPlanFootprints(doc, opts = {}, results = elementSinkResults(doc, opts)) {
1792
+ const out = [];
1793
+ for (const [id, r] of results) {
1794
+ if (!r.drawable) continue;
1795
+ const m = elementSinkMeta(doc, r);
1796
+ out.push({
1797
+ id, kind: m.elementKind, word: m.word, ...(m.mark ? { mark: m.mark } : {}), ...(m.typeName ? { typeName: m.typeName } : {}),
1798
+ status: m.status, counted: m.counted, label: m.label,
1799
+ prisms: r.evaluated.geometry.data.prisms.map((p) => ({
1800
+ outline: p.outline.map((q) => [q[0], q[1]]), holes: (p.holes ?? []).map((h) => h.map((q) => [q[0], q[1]])), bottomZ: p.bottomZ, topZ: p.topZ,
1801
+ })),
1802
+ });
1803
+ }
1804
+ return out;
1805
+ }
1806
+
1807
+ /**
1808
+ * What the plan canvas is sent: the outlines it draws and, apart from them, the receipt naming every element it cannot
1809
+ * draw with why (null when it draws them all), so a held element with no solid is said, never dropped.
1810
+ * @param {any} doc
1811
+ * @param {EvaluationOptions} [opts]
1812
+ */
1813
+ export function elementPlanReply(doc, opts = {}, results = elementSinkResults(doc, opts)) {
1814
+ return { footprints: elementPlanFootprints(doc, opts, results), leftOut: elementsLeftOut(doc, 'plan', opts, results) };
1815
+ }
1816
+
1817
+ /**
1818
+ * What the fit check covers, said wherever walls, slabs and footings show (the evaluate reply, the bill and its
1819
+ * report, the plan): what is measured, then what is NOT checked yet. A check not run yet is never a pass, so no
1820
+ * surface may show an all-clear for it (#3296 E1b, owner fallback 2026-11-17).
1821
+ */
1822
+ export const ELEMENT_FIT_NOT_CHECKED = 'How walls, slabs and footings fit is only partly checked: FloLess measures clashes between them and '
1823
+ + 'whether each wall\'s faces sit on its line. Not checked yet: whether each strip footing carries its wall, slab and '
1824
+ + 'footing levels, walls standing on slabs, mitres between walls, and how steel meets concrete. Those arrive in a '
1825
+ + 'later FloLess update.';
1826
+
1827
+ /**
1828
+ * The plan's note: why some elements are not shown (the cut, the registration), the ones it cannot draw, and, whenever
1829
+ * it shows or names any element, what the fit check does not cover yet. Null when there is nothing to say.
1830
+ * @param {{ cutNote?: string | null, leftOut?: string | null, shown?: number }} parts
1831
+ */
1832
+ export function elementPlanNote({ cutNote = null, leftOut = null, shown = 0 } = {}) {
1833
+ const parts = [cutNote, leftOut, shown > 0 || leftOut ? ELEMENT_FIT_NOT_CHECKED : null].filter(Boolean);
1834
+ return parts.length ? parts.join(' ') : null;
1835
+ }
1836
+
1837
+ /** The AWARE scene class of each element kind (aware-aeco/aware#850). */
1838
+ export const AWARE_EXTRUSION_CLASS = Object.freeze({ [WALL]: 'wall', [SLAB]: 'slab', [FOOTING]: 'footing' });
1839
+
1840
+ /** The `quantities` keys AWARE accepts for each class (#850 `quantity_keys`): anything else would be refused. */
1841
+ export const AWARE_QUANTITY_KEYS = Object.freeze({
1842
+ wall: ['lengthMm', 'widthMm', 'heightMm', 'grossSideAreaM2', 'netSideAreaM2', 'grossVolumeM3', 'netVolumeM3', 'grossWeightKg', 'netWeightKg'],
1843
+ slab: ['widthMm', 'perimeterMm', 'grossAreaM2', 'netAreaM2', 'grossVolumeM3', 'netVolumeM3', 'grossWeightKg', 'netWeightKg'],
1844
+ footing: ['lengthMm', 'widthMm', 'heightMm', 'crossSectionAreaM2', 'outerSurfaceAreaM2', 'grossSurfaceAreaM2', 'grossVolumeM3', 'netVolumeM3', 'grossWeightKg', 'netWeightKg'],
1845
+ });
1846
+
1847
+ const ringCcw = (ring) => (signedArea(ring) < 0 ? [...ring].reverse() : ring);
1848
+ const ringCw = (ring) => (signedArea(ring) > 0 ? [...ring].reverse() : ring);
1849
+
1850
+ /**
1851
+ * The geometry of ONE AWARE `extrusion` for an element (plan rev 2 §4): every prism is an item of the same element.
1852
+ * A wall or strip footing gets a frame along its evaluated axis (origin = axis start, u along it, v to its left, normal
1853
+ * +Z) and `axis { u0: 0, u1: length }`; a slab or pad gets a world-aligned frame at its outline's lowest corner. Rings
1854
+ * are moved into the frame, the outline counter-clockwise and the holes clockwise, as AWARE requires.
1855
+ * @param {any} evaluated the result the sink uses (`elementSinkResults`)
1856
+ * @returns {{ frame: { origin: number[], uDir: number[], vDir: number[], normal: number[] }, items: any[], axis?: { u0: number, u1: number } } | null}
1857
+ */
1858
+ export function awareExtrusionGeometry(evaluated) {
1859
+ if (!drawableGeometry(evaluated)) return null;
1860
+ const prisms = evaluated.geometry.data.prisms;
1861
+ const axis = evaluated.geometry.data.axis;
1862
+ let origin; let u; let v; let axisOut;
1863
+ if (isObj(axis) && isPoint2(axis.start) && isPoint2(axis.end)) {
1864
+ const dx = axis.end[0] - axis.start[0]; const dy = axis.end[1] - axis.start[1];
1865
+ const length = Math.hypot(dx, dy);
1866
+ if (!(length > 0)) return null;
1867
+ origin = [axis.start[0], axis.start[1], 0];
1868
+ u = [dx / length, dy / length]; v = [-u[1], u[0]];
1869
+ axisOut = { u0: 0, u1: round(length) };
1870
+ } else {
1871
+ const xs = prisms.flatMap((p) => p.outline.map((q) => q[0])); const ys = prisms.flatMap((p) => p.outline.map((q) => q[1]));
1872
+ origin = [Math.min(...xs), Math.min(...ys), 0]; u = [1, 0]; v = [0, 1];
1873
+ }
1874
+ const local = (q) => { const x = q[0] - origin[0]; const y = q[1] - origin[1]; return [round6(x * u[0] + y * u[1]), round6(x * v[0] + y * v[1])]; };
1875
+ const items = prisms.map((p) => ({
1876
+ outline: ringCcw(p.outline.map(local)),
1877
+ ...(p.holes?.length ? { holes: p.holes.map((h) => ringCw(h.map(local))) } : {}),
1878
+ fromMm: p.bottomZ, depthMm: round6(p.topZ - p.bottomZ),
1879
+ }));
1880
+ return {
1881
+ frame: { origin, uDir: [u[0], u[1], 0], vDir: [v[0], v[1], 0], normal: [0, 0, 1] },
1882
+ items, ...(axisOut ? { axis: axisOut } : {}),
1883
+ };
1884
+ }
@@ -0,0 +1,38 @@
1
+ // #3646: the words beside a stored PDF drawing that carries scripts or other active content, or that FloLess could not
2
+ // check. The server attaches them to each PDF in the lists it already sends (`activeContent`: `label` for the chip, `tip`
3
+ // for its tooltip, `note` for the sentence), and sends the usual "requests changed" or "knowledge changed" event when one
4
+ // changes, so each surface simply renders what it loaded. This file only lays the words out the same way everywhere.
5
+ //
6
+ // FloLess keeps every attached drawing unchanged and only labels it. A PDF that carries nothing has no `activeContent`,
7
+ // and one still being checked shows nothing: a list never says "clean".
8
+ //
9
+ // A plain script (no import/export); its one global is `flolessActiveContent`.
10
+
11
+ (function () {
12
+ const SHA256 = /^[0-9a-f]{64}$/;
13
+
14
+ /** A view that shows something: a finding, or "not checked". */
15
+ const shows = (view) => !!view && (view.state === 'found' || view.state === 'unchecked') && typeof view.label === 'string' && typeof view.note === 'string';
16
+
17
+ /** The answer is a finding (amber) rather than "not checked" (muted). */
18
+ const isFinding = (view) => !!view && view.state === 'found';
19
+
20
+ /** The stored PDFs among a request's `sourceRefs` (an image source never carries any). */
21
+ const pdfRefs = (refs) => (Array.isArray(refs) ? refs : []).filter((ref) => ref && SHA256.test(String(ref.sha256 || ''))
22
+ && (ref.ext === 'pdf' || /\.pdf$/i.test(String(ref.name || ''))));
23
+
24
+ /**
25
+ * The lines a list of `{ name, view }` says, for a strip or dialog naming several files: one per file that shows
26
+ * something, at most `max`, and the names of the rest (`more`), so every file is named wherever it is listed.
27
+ * `finding` is true when any of them carries something.
28
+ */
29
+ function linesOf(entries, max = 3) {
30
+ const shown = (entries || []).filter((e) => shows(e.view));
31
+ return { lines: shown.slice(0, max).map((e) => ({ name: e.name, note: e.view.note })), more: shown.slice(max).map((e) => e.name), finding: shown.some((e) => isFinding(e.view)) };
32
+ }
33
+
34
+ /** The sentence after the lines when there are more than fit: it names every one of them. */
35
+ const moreText = (more) => `${more.length === 1 ? 'Also' : `${more.length} more`} ${more.length === 1 ? 'carries' : 'carry'} active content or could not be checked: ${more.length === 1 ? more[0] : `${more.slice(0, -1).join(', ')} and ${more[more.length - 1]}`}.`;
36
+
37
+ globalThis.flolessActiveContent = { shows, isFinding, pdfRefs, linesOf, moreText };
38
+ })();
@@ -1167,7 +1167,9 @@ function placeExtrusion(mesh, el) {
1167
1167
  shape.holes.push(hole);
1168
1168
  }
1169
1169
  const z0 = Math.min(el.from || 0, el.to || 0), z1 = Math.max(el.from || 0, el.to || 0);
1170
- mesh.geometry = new THREE.ExtrudeGeometry(shape, { depth: Math.max(z1 - z0, 0.5), bevelEnabled: false });
1170
+ // A wall, slab or footing (#3296 E1b) is drawn at its true depth: the evaluator never gives one without height, so
1171
+ // the 0.5 mm floor that keeps a reconstruction's sliver visible would only misdraw a measured solid.
1172
+ mesh.geometry = new THREE.ExtrudeGeometry(shape, { depth: el.role === 'element' ? z1 - z0 : Math.max(z1 - z0, 0.5), bevelEnabled: false });
1171
1173
  mesh.quaternion.identity();
1172
1174
  mesh.position.set(0, 0, z0); // the shape carries world XY; lift the slab to its bottom face
1173
1175
  }
@@ -1367,6 +1369,8 @@ function materialFor(groupKey, family, axis = null) {
1367
1369
  // The shadow pass uses a depth material that ignores renderer.clippingPlanes unless the material
1368
1370
  // opts in — without this, a clip plane, clip box or work area hides geometry that keeps casting.
1369
1371
  mat.clipShadows = true;
1372
+ // #3296 E1b: a wall, slab or footing FloLess does not count is drawn see-through, so it never reads as a checked one.
1373
+ if (groupKey === 'element-held') { mat.transparent = true; mat.opacity = 0.4; mat.depthWrite = false; }
1370
1374
  // Patch for triplanar sampling ONCE, at creation, rather than toggling it with the mode: both
1371
1375
  // replaced chunks are guarded by USE_MAP/USE_ROUGHNESSMAP, so with no maps bound the patched
1372
1376
  // shader is equivalent to the stock one — and Solid never pays a program recompile on switch.
@@ -104,10 +104,15 @@ export function valueOk(subject, v) {
104
104
  }
105
105
  case 'scope': {
106
106
  // `parseScopeDecisionValue`'s shape (#2554 kind 2); the server alone wrote it. #3578: `leavePages` (pages left out
107
- // of a file still read), when present, lets `leaveOut` be empty.
108
- if (!isObj(v) || !only(v, ['keptDigest', 'kept', 'attached', 'leaveOut', 'leavePages']) || v.keptDigest !== subject.keptDigest) return false;
107
+ // of a file still read), when present, lets `leaveOut` be empty; so does #3589's `leaveStrips` (strips of sheets read).
108
+ if (!isObj(v) || !only(v, ['keptDigest', 'kept', 'attached', 'leaveOut', 'leavePages', 'leaveStrips']) || v.keptDigest !== subject.keptDigest) return false;
109
109
  if (v.leavePages !== undefined && !leavePagesOk(v.leavePages)) return false;
110
- if (!nonNegInt(v.kept) || !nonNegInt(v.attached) || v.kept < 1 || !Array.isArray(v.leaveOut) || (v.leaveOut.length < 1 && v.leavePages === undefined)) return false;
110
+ if (v.leaveStrips !== undefined && !leaveStripsOk(v.leaveStrips)) return false;
111
+ if (!nonNegInt(v.kept) || !nonNegInt(v.attached) || v.kept < 1 || !Array.isArray(v.leaveOut)
112
+ || (v.leaveOut.length < 1 && v.leavePages === undefined && v.leaveStrips === undefined)) return false;
113
+ // #3589: a strip is of a page that is read: never of a file left out whole, nor of a page left for later.
114
+ if (v.leaveStrips !== undefined && v.leaveStrips.some((row) => v.leaveOut.some((f) => isObj(f) && f.sha256 === row.sha256)
115
+ || (v.leavePages ?? []).some((left) => left.sha256 === row.sha256 && left.pages.includes(row.page)))) return false;
111
116
  return v.kept + v.leaveOut.length === v.attached && new Set(v.leaveOut.map((f) => isObj(f) && f.sha256)).size === v.leaveOut.length
112
117
  && v.leaveOut.every((f) => isObj(f) && only(f, ['sha256', 'ext', 'bytes', 'names'])
113
118
  && typeof f.sha256 === 'string' && DIGEST.test(f.sha256) && typeof f.ext === 'string' && /^[a-z0-9]{1,8}$/.test(f.ext)
@@ -138,6 +143,17 @@ export function valueOk(subject, v) {
138
143
  }
139
144
  }
140
145
 
146
+ /** `parseScopeLeaveStrips`'s shape (#3589): one strip per page, in (file, page) order, edge and depth and its count. */
147
+ function leaveStripsOk(rows) {
148
+ if (!Array.isArray(rows) || rows.length < 1 || rows.length > 2000) return false;
149
+ return rows.every((row, i) => isObj(row) && only(row, ['sha256', 'page', 'sheet', 'edge', 'depth', 'elements']) && Object.keys(row).length === 6
150
+ && typeof row.sha256 === 'string' && DIGEST.test(row.sha256) && Number.isSafeInteger(row.page) && row.page >= 1 && row.page <= 10000
151
+ && typeof row.sheet === 'string' && /^[A-Za-z0-9][A-Za-z0-9._-]{0,39}$/.test(row.sheet)
152
+ && ['bottom', 'top', 'left', 'right'].includes(row.edge) && Number.isSafeInteger(row.depth) && row.depth >= 1 && row.depth <= 40
153
+ && Number.isSafeInteger(row.elements) && row.elements >= 1
154
+ && (i === 0 || rows[i - 1].sha256 < row.sha256 || (rows[i - 1].sha256 === row.sha256 && rows[i - 1].page < row.page)));
155
+ }
156
+
141
157
  /** One entry of `ai_decisions`, as `isWellFormedAiDecisionList` reads it (less the Filter digest). */
142
158
  function entryOk(entry) {
143
159
  return isObj(entry) && only(entry, ['id', 'buildId', 'channel', 'subject', 'chosen', 'value'])
@@ -432,7 +432,7 @@ export function createCatalogPicker({
432
432
  ? `<div class=scp-material-browser><div class=scp-material-actions><button data-command-id="steel.catalog-material-default" class="scp-semantic scp-material-default" type=button aria-pressed=false><span class=icon aria-hidden=true>↺</span><span><span class=label>Use profile default</span><span class=meta>Automatic per member profile</span></span></button><button data-command-id="steel.catalog-material-current" class="scp-semantic scp-material-current" type=button aria-pressed=false hidden><span class=icon aria-hidden=true>•</span><span><span class=label></span><span class=meta>Current model value · not in this catalog</span></span></button></div><nav class=scp-families role=tree aria-label="Material categories and materials"></nav><div class=scp-tree-state role=status aria-live=polite hidden></div></div><aside class=scp-details></aside>`
433
433
  : `<nav class=scp-families role=tree aria-label="Profile categories"></nav><div class=scp-results role=listbox aria-label="Profiles"></div><aside class=scp-details></aside>`;
434
434
  modal.innerHTML = `<div class=scp-backdrop></div><div class=scp-panel>
435
- <div class=scp-head><div><div class=scp-title id=${modal.id}Title>${isMaterial ? 'Select material' : 'Select profile'}</div><div class=scp-scope></div></div>${withLibrary ? `<div class=scp-seg role=group aria-label="Window mode"><button type=button data-command-id="steel.catalog-mode#Pick" data-mode=pick aria-pressed=true>Pick</button><button type=button data-command-id="steel.catalog-mode#Manage" data-mode=manage aria-pressed=false>Manage</button></div>` : ''}<span class=scp-spacer></span>${withLibrary ? `<div class="scp-newwrap scp-manageonly"><button type=button class=primary data-command-id="steel.catalog-manage-new" aria-haspopup=menu aria-expanded=false>New &#9662;</button><div class=scp-menu role=menu hidden><button type=button role=menuitem data-new=shape data-command-id="steel.catalog-manage-new-shape"><span class=t>Profile from a shape</span><span class=d>Pick a parametric shape, set its sizes, save it</span></button><button type=button role=menuitem data-new=group data-command-id="steel.catalog-manage-new-group-menu"><span class=t>Group</span><span class=d>An empty group under My groups</span></button></div></div>` : ''}<button data-command-id="steel.dialog-close#the ${isMaterial ? 'material' : 'profile'} picker" class="scp-close ghost" aria-label="Close" data-tip="Close">✕</button></div>
435
+ <div class=scp-head><div><div class=scp-title id=${modal.id}Title>${isMaterial ? 'Select material' : 'Select profile'}</div><div class=scp-scope></div></div>${withLibrary ? `<div class=scp-seg role=group aria-label="Window mode"><button type=button data-command-id="steel.catalog-mode#Pick" data-mode=pick aria-pressed=true>Pick</button><button type=button data-command-id="steel.catalog-mode#Manage" data-mode=manage aria-pressed=false>Manage</button></div>` : ''}<span class=scp-spacer></span>${withLibrary ? `<div class="scp-newwrap scp-manageonly"><button type=button class=primary data-command-id="steel.catalog-manage-new" aria-haspopup=menu aria-expanded=false>New &#9662;</button><div class=scp-menu role=menu hidden><button type=button role=menuitem data-new=shape data-command-id="steel.catalog-manage-new-shape"><span class=t>Profile from a shape</span><span class=d>Pick a parametric shape, set its sizes, save it</span></button><button type=button role=menuitem data-new=sketch data-command-id="steel.catalog-manage-new-sketch"><span class=t>Sketch a custom shape</span><span class=d>Draw your own shape with sizes, save it to My shapes</span></button><button type=button role=menuitem data-new=group data-command-id="steel.catalog-manage-new-group-menu"><span class=t>Group</span><span class=d>An empty group under My groups</span></button></div></div>` : ''}<button data-command-id="steel.dialog-close#the ${isMaterial ? 'material' : 'profile'} picker" class="scp-close ghost" aria-label="Close" data-tip="Close">✕</button></div>
436
436
  ${withLibrary ? '<div class=scp-sbwrap>' : ''}<div class=scp-searchbar><input data-command-id="steel.catalog-search#${isMaterial ? 'materials' : 'profiles'}" class=scp-search autocomplete=off aria-label="Search ${isMaterial ? 'materials' : 'profiles'}" placeholder="Search ${isMaterial ? 'material name or alias' : (withLibrary ? 'designation, alias or tag' : 'designation or alias')}">${withShapes ? `<div class=scp-chips role=group aria-label="Show"><button type=button data-command-id="steel.catalog-source#All" data-source=all aria-pressed=true>All</button><button type=button data-command-id="steel.catalog-source#Library" data-source=library aria-pressed=false>Library</button><button type=button data-command-id="steel.catalog-source#Parametric" data-source=parametric aria-pressed=false>Parametric</button>${withLibrary ? `<button type=button data-command-id="steel.catalog-source#Mine" data-source=mine aria-pressed=false data-tip="Saved sizes and everything in your own groups">Mine</button><button type=button data-command-id="steel.catalog-source#Starred" data-source=starred aria-pressed=false>Starred</button>` : ''}</div>` : ''}<span class=scp-count role=status aria-live=polite></span></div>${withLibrary ? '<div class=scp-tagbar role=group aria-label="Filter by tag" hidden></div></div>' : ''}
437
437
  <div class=scp-body>${pickerBody}</div>
438
438
  <div class=scp-foot><span class="scp-source scp-pickonly"></span>${withLibrary ? '<span class="scp-mstatus scp-manageonly" role=status aria-live=polite>Groups, tags and attributes are saved to your library. Catalog groups keep their fixed order.</span>' : ''}<span class=scp-spacer></span><span class="scp-applyhint scp-pickonly" role=status aria-live=polite>Choose a ${isMaterial ? 'material' : 'profile'}</span><button data-command-id="steel.catalog-cancel" class="scp-cancel scp-pickonly ghost">Cancel</button><button data-command-id="steel.catalog-apply" class="scp-apply scp-pickonly primary" hidden>Apply</button>${withLibrary ? '<button type=button class="scp-done scp-manageonly primary" data-command-id="steel.catalog-manage-done">Done</button>' : ''}</div>
@@ -1376,7 +1376,12 @@ export function createCatalogPicker({
1376
1376
  newMenu.addEventListener('click', (event) => {
1377
1377
  const item = event.target.closest('button[data-new]'); if (!item) return;
1378
1378
  closeMenu(false);
1379
- if (item.dataset.new === 'shape') ensureManage().startNewShape(); else ensureManage().startNewGroup();
1379
+ if (item.dataset.new === 'shape') ensureManage().startNewShape();
1380
+ else if (item.dataset.new === 'sketch') {
1381
+ // The section sketcher (epic #3382 P5) is its own window above this one; it listens for this event.
1382
+ const view = doc.defaultView;
1383
+ if (view && typeof view.dispatchEvent === 'function' && typeof view.CustomEvent === 'function') view.dispatchEvent(new view.CustomEvent('floless:open-shape-sketcher', { detail: { invoker: newBtn } }));
1384
+ } else ensureManage().startNewGroup();
1380
1385
  });
1381
1386
  newWrap.addEventListener('keydown', (event) => {
1382
1387
  if (event.key === 'Escape' && !newMenu.hidden) { event.preventDefault(); event.stopPropagation(); closeMenu(true); }