@floless/app 0.134.0 → 0.134.2
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 +6129 -2881
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +310 -9
- package/dist/skills/steel-drawing-abbreviations/SKILL.md +18 -1
- package/dist/web/app.css +34 -8
- package/dist/web/aware.js +590 -102
- package/dist/web/commands-filter.js +82 -5
- package/dist/web/commands-shell.js +98 -11
- package/dist/web/commands-steel.js +37 -9
- package/dist/web/commands.js +4 -0
- package/dist/web/connection-review-client.js +120 -0
- package/dist/web/index.html +23 -16
- package/dist/web/instructor.js +109 -40
- package/dist/web/steel-3d-core.js +336 -3
- package/dist/web/steel-3d-view.js +923 -160
- package/dist/web/steel-canvas-guidance.js +9 -1
- package/dist/web/steel-editor.html +1408 -68
- package/dist/web/steel-filter-core.js +220 -16
- package/dist/web/steel-filter.html +1261 -50
- package/dist/web/steel-model-commands.js +23 -2
- package/dist/web/steel-model-v2-client-validation.js +6 -0
- package/dist/web/steel-model-v2-commands.js +124 -0
- package/dist/web/workspaces.js +456 -81
- package/package.json +2 -1
|
@@ -12,12 +12,112 @@
|
|
|
12
12
|
* element : { kind:'line'|'text', layer:string, w:number, color:string, d?:string, text?:string, bbox?:number[], dashed?:boolean }
|
|
13
13
|
* mode : any '+'-joined combo of 'layer'/'thickness'/'color', AND-ed (e.g. 'thickness+layer').
|
|
14
14
|
* '' = match nothing. Canonical order = MODE_ORDER.
|
|
15
|
-
* sel : { layers:Set<string>, thicknesses:Set<number>, colors:Set<string> }
|
|
15
|
+
* sel : { layers:Set<string>, thicknesses:Set<number>, colors:Set<string> } — CANONICAL keys
|
|
16
|
+
* (`facetKey`), never raw row/element values. Every producer and consumer of this object
|
|
17
|
+
* must agree on that, which is why they all route through FACET_DIMS + facetKey.
|
|
16
18
|
* filter : { mode, layers:[…], thicknesses:[…], colors:[…], sheets:[{sheet,sourceHash,elements:[…]}] }
|
|
17
19
|
*/
|
|
18
20
|
|
|
19
21
|
/** Canonical dimension order for a mode string. */
|
|
20
|
-
const MODE_ORDER = ['thickness', 'layer', 'color'];
|
|
22
|
+
export const MODE_ORDER = Object.freeze(['thickness', 'layer', 'color']);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* THE dimension descriptor — the ONE place that knows a dimension's three different names for itself.
|
|
26
|
+
*
|
|
27
|
+
* A dimension is called `thickness` in a mode string, its control rows live on `filter.thicknesses`
|
|
28
|
+
* keyed `w`, and the element it matches keys `w` too — but `layer` rows key on `name` while their
|
|
29
|
+
* elements key on `layer`, and nothing in the shapes makes that correspondence visible. The first
|
|
30
|
+
* draft of the Phase D design wrote `line.facets[dim]` with `dim === 'thickness'`, which reads
|
|
31
|
+
* `undefined`: the entire thickness dimension would have matched nothing, silently. Index every
|
|
32
|
+
* lookup through here so that mistake cannot be written a second time.
|
|
33
|
+
*
|
|
34
|
+
* `control` is deliberately ONE field for two things — the filter's control array (`filter.colors`)
|
|
35
|
+
* and the in-memory selection Set (`sel.colors`) already share a name. Keeping it one field is what
|
|
36
|
+
* lets a PRODUCER and a CONSUMER of a selection set be routed through the same descriptor entry, and
|
|
37
|
+
* the whole point of #805 Phase D slice D1 is that they cannot be routed through different ones.
|
|
38
|
+
*
|
|
39
|
+
* FROZEN, and MODE_ORDER with it: these three tables are now the single place the browser predicate,
|
|
40
|
+
* the ledger predicate and the census all resolve a dimension through, and they are exported
|
|
41
|
+
* cross-module into the server. A mutable single source of truth is one assignment away from not
|
|
42
|
+
* being single. (Same treatment as MODEL_V2_TOL in web/steel-3d-core.js.)
|
|
43
|
+
*/
|
|
44
|
+
export const FACET_DIMS = Object.freeze({
|
|
45
|
+
thickness: Object.freeze({ dim: 'thickness', control: 'thicknesses', rowKey: 'w', elementKey: 'w' }),
|
|
46
|
+
layer: Object.freeze({ dim: 'layer', control: 'layers', rowKey: 'name', elementKey: 'layer' }),
|
|
47
|
+
color: Object.freeze({ dim: 'color', control: 'colors', rowKey: 'hex', elementKey: 'color' }),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
/** The dimension a control / selection-set name belongs to — 'colors' -> 'color'. */
|
|
51
|
+
export const FACET_DIM_BY_CONTROL = Object.freeze({ thicknesses: 'thickness', layers: 'layer', colors: 'color' });
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* PURE canonicalisation of one facet value, and nothing else.
|
|
55
|
+
*
|
|
56
|
+
* Behaviour-preserving by construction: this is exactly what the ledger's `selectionIndex` and
|
|
57
|
+
* `selectedBy` have always done — widths rounded to 2 dp, colours lowercased, layer names compared
|
|
58
|
+
* exactly — including the parts nobody designed on purpose. `NaN`, `Infinity`, `-0` and `''` all come
|
|
59
|
+
* back OUT as values because they go IN as values today; `server/steel-selection-predicate.test.ts`
|
|
60
|
+
* pins each one against the pre-refactor code.
|
|
61
|
+
*
|
|
62
|
+
* `undefined` means "not a value for this dimension at all" — the wrong JS type — and is the ONLY
|
|
63
|
+
* rejection performed here. Whether a value is one a human could meaningfully have been SHOWN and
|
|
64
|
+
* EXCLUDED is a different question with a different answer, and it lives in
|
|
65
|
+
* `isDismissibleFacetValue`. Merging the two would turn a refactor of the selection predicate into a
|
|
66
|
+
* silent verdict change, which is precisely what this slice exists to avoid.
|
|
67
|
+
*/
|
|
68
|
+
export function facetKey(dim, value) {
|
|
69
|
+
if (dim === 'thickness') return typeof value === 'number' ? Number(value.toFixed(2)) : undefined;
|
|
70
|
+
if (dim === 'layer') return typeof value === 'string' ? value : undefined;
|
|
71
|
+
if (dim === 'color') return typeof value === 'string' ? value.toLowerCase() : undefined;
|
|
72
|
+
// LOUD, and unreachable from correct code is exactly why. Returning `undefined` for an unknown
|
|
73
|
+
// dimension is indistinguishable from "this value is the wrong type" — so a single typo
|
|
74
|
+
// (`facetKey('colors', …)`, the CONTROL name rather than the dim) would disable every checkbox and
|
|
75
|
+
// make Save write every `on` to false, silently, behind a screen that looks plausible.
|
|
76
|
+
throw new Error(`facetKey: unknown dimension ${JSON.stringify(dim)}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Is this CANONICAL key a value a human could meaningfully have been shown and excluded?
|
|
81
|
+
*
|
|
82
|
+
* Asked only about dismissibility, never about selection: a non-empty string, or a finite number.
|
|
83
|
+
* `NaN`, `Infinity` and `''` stay selectable (see `facetKey`) — they are simply never a basis for
|
|
84
|
+
* dismissing a line without a written justification, so a line carrying one gets an explicit row
|
|
85
|
+
* instead. Fail-closed, and a deliberate behaviour CHANGE from the layer-only rule it generalises,
|
|
86
|
+
* which admitted every non-empty string including a width that is not a width.
|
|
87
|
+
*/
|
|
88
|
+
export function isDismissibleFacetValue(dim, key) {
|
|
89
|
+
if (dim === 'thickness') return typeof key === 'number' && Number.isFinite(key);
|
|
90
|
+
if (dim === 'layer' || dim === 'color') return typeof key === 'string' && key !== '';
|
|
91
|
+
// Same reason as `facetKey`: a quiet `false` here would silently withhold the shorthand for a whole
|
|
92
|
+
// dimension, which reads as "the human excluded nothing" rather than as the typo it is.
|
|
93
|
+
throw new Error(`isDismissibleFacetValue: unknown dimension ${JSON.stringify(dim)}`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The persisted mode as the LEDGER's predicate reads it: a non-string mode defaults to 'layer'.
|
|
98
|
+
* Stated once, here, because `selectionIndex` needs the string and `selectionDims` needs the rule.
|
|
99
|
+
*/
|
|
100
|
+
export function selectionMode(mode) {
|
|
101
|
+
return typeof mode === 'string' ? mode : 'layer';
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The dimensions a persisted mode activates under the LEDGER's rule — a RAW SUBSTRING test, kept
|
|
106
|
+
* verbatim. `xlayer` activates layer; `colour+layer` activates layer and NOT colour; an unknown mode
|
|
107
|
+
* activates nothing and therefore selects everything.
|
|
108
|
+
*
|
|
109
|
+
* Deliberately NOT `modeDims`, which normalises by splitting on '+'. The two genuinely disagree on a
|
|
110
|
+
* malformed persisted mode, and normalising here would silently change a stored verdict. Phase D's
|
|
111
|
+
* answer to that divergence is a canonicity gate on the saved mode — a refusal, not a quiet rewrite —
|
|
112
|
+
* and slice D2 LANDED it: `hasCanonicalMode` is a clause of the Filter-Save route, of the audit's
|
|
113
|
+
* `filter-checkpoint`, and of the exclusion sign-off. So every mode that can reach a completed audit
|
|
114
|
+
* is one where this rule and `modeDims` agree, and the rule stays exactly as it was, in ONE place
|
|
115
|
+
* instead of being re-derived wherever it is needed.
|
|
116
|
+
*/
|
|
117
|
+
export function selectionDims(mode) {
|
|
118
|
+
const raw = selectionMode(mode);
|
|
119
|
+
return MODE_ORDER.filter((dim) => raw.includes(dim));
|
|
120
|
+
}
|
|
21
121
|
|
|
22
122
|
/** The dimensions a mode activates, order-agnostic: 'thickness+layer' -> ['thickness','layer']. */
|
|
23
123
|
export function modeDims(mode) {
|
|
@@ -33,14 +133,22 @@ export function canonicalMode(dims) {
|
|
|
33
133
|
/**
|
|
34
134
|
* The active match predicate — an element passes when it matches EVERY checked dimension (AND).
|
|
35
135
|
* Zero checked dimensions match nothing (a valid, visible "0 shown" state, not a fall-through to all).
|
|
136
|
+
*
|
|
137
|
+
* It compares CANONICAL keys (`facetKey`), which is what makes it the same question the ledger's
|
|
138
|
+
* `selectedBy` asks rather than a lookalike: before #805 Phase D this compared raw values, so a
|
|
139
|
+
* `#ABC123` element and a `#abc123` row were the same value to the server and different values here.
|
|
140
|
+
* An element whose value is not a value for its dimension at all (a numeric layer, a string width)
|
|
141
|
+
* has no canonical key and matches nothing — the ledger has always refused it, and a tick the ledger
|
|
142
|
+
* would never honour is a lie the panel used to be able to tell.
|
|
36
143
|
*/
|
|
37
144
|
export function matchesActive(el, mode, sel) {
|
|
38
145
|
const dims = modeDims(mode);
|
|
39
146
|
if (!dims.length) return false;
|
|
40
|
-
return dims.every((
|
|
41
|
-
d
|
|
42
|
-
|
|
43
|
-
|
|
147
|
+
return dims.every((dim) => {
|
|
148
|
+
const d = FACET_DIMS[dim];
|
|
149
|
+
const key = facetKey(dim, el[d.elementKey]);
|
|
150
|
+
return key !== undefined && sel[d.control].has(key);
|
|
151
|
+
});
|
|
44
152
|
}
|
|
45
153
|
|
|
46
154
|
/**
|
|
@@ -50,10 +158,22 @@ export function matchesActive(el, mode, sel) {
|
|
|
50
158
|
*/
|
|
51
159
|
export function selFromFilter(filter) {
|
|
52
160
|
const onOr = (it, dflt) => (it.on === undefined ? dflt : !!it.on);
|
|
161
|
+
// Sets hold CANONICAL keys, never raw row values — see `matchesActive`. A row whose value is not a
|
|
162
|
+
// value for its dimension contributes nothing: it could never have matched an element the ledger
|
|
163
|
+
// accepts, so admitting it would only let the panel show a tick with no consequence.
|
|
164
|
+
const keys = (dim, rows, dflt) => {
|
|
165
|
+
const out = new Set();
|
|
166
|
+
for (const row of rows) {
|
|
167
|
+
if (!onOr(row, dflt(row))) continue;
|
|
168
|
+
const key = facetKey(dim, row[FACET_DIMS[dim].rowKey]);
|
|
169
|
+
if (key !== undefined) out.add(key);
|
|
170
|
+
}
|
|
171
|
+
return out;
|
|
172
|
+
};
|
|
53
173
|
return {
|
|
54
|
-
layers:
|
|
55
|
-
thicknesses:
|
|
56
|
-
colors:
|
|
174
|
+
layers: keys('layer', filter.layers || [], (l) => !!l.steel),
|
|
175
|
+
thicknesses: keys('thickness', filter.thicknesses || [], () => true),
|
|
176
|
+
colors: keys('color', filter.colors || [], () => true),
|
|
57
177
|
};
|
|
58
178
|
}
|
|
59
179
|
|
|
@@ -65,10 +185,25 @@ export function eyedropperAdd(sel, el, which) {
|
|
|
65
185
|
// Text spans / hairlines (w<=0) have no meaningful stroke width — the popover hides their
|
|
66
186
|
// Thickness row, so "all" must not slip a w:0 into the thickness selection (which would then
|
|
67
187
|
// match every text/hairline element in any thickness mode — the opposite of isolating steel).
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
188
|
+
// The guard is on the CANONICAL key, not the raw width, and that is load-bearing: a raw `0.004`
|
|
189
|
+
// passes `el.w > 0` but canonicalises to `0`, which would slip exactly the `w: 0` this comment
|
|
190
|
+
// forbids into the thickness selection — and then match every text/hairline element in any
|
|
191
|
+
// thickness mode. Unreachable from our own extractor (1-dp widths floor at 0.1) and reachable on
|
|
192
|
+
// the hand-edited filters this slice says genuinely behave differently, which is the population
|
|
193
|
+
// that needs the guard most. A `0 pt` value is also never a row the Filter shows, so ticking it
|
|
194
|
+
// would tick nothing the human can see.
|
|
195
|
+
const width = facetKey('thickness', el.w);
|
|
196
|
+
const hasStroke = el.kind !== 'text' && width !== undefined && width > 0;
|
|
197
|
+
// Canonical keys, for the same reason `selFromFilter` builds them: what lands in the Set has to be
|
|
198
|
+
// the same value `matchesActive` and `applySelToFilter` will look for, or a picked element ticks a
|
|
199
|
+
// box that Save then writes OFF.
|
|
200
|
+
const add = (dim) => {
|
|
201
|
+
const key = facetKey(dim, el[FACET_DIMS[dim].elementKey]);
|
|
202
|
+
if (key !== undefined) sel[FACET_DIMS[dim].control].add(key);
|
|
203
|
+
};
|
|
204
|
+
if (which === 'layer' || which === 'all') add('layer');
|
|
205
|
+
if ((which === 'thickness' || which === 'all') && hasStroke) add('thickness');
|
|
206
|
+
if (which === 'color' || which === 'all') add('color');
|
|
72
207
|
return sel;
|
|
73
208
|
}
|
|
74
209
|
|
|
@@ -172,12 +307,22 @@ export function textFontSize(bbox, text) {
|
|
|
172
307
|
/**
|
|
173
308
|
* Write the live selection + mode back onto the filter block's `on` flags so it persists on the
|
|
174
309
|
* contract (what Save PUTs, and what the reader reads). Mutates and returns `filter`.
|
|
310
|
+
*
|
|
311
|
+
* This is the CONSUMER half of the pair that must never disagree with the producers. Reading a raw
|
|
312
|
+
* row value out of a Set that holds canonical keys is not a near miss — it is a silent discard: the
|
|
313
|
+
* human clicks All, the checkbox renders ticked, and Save writes the row OFF with no error and no
|
|
314
|
+
* visible sign. Every producer (`selFromFilter`, `eyedropperAdd`, and the panel's own All/None and
|
|
315
|
+
* per-row handlers) therefore goes through `facetKey` too.
|
|
175
316
|
*/
|
|
176
317
|
export function applySelToFilter(filter, sel, mode) {
|
|
177
318
|
filter.mode = mode;
|
|
178
|
-
for (const
|
|
179
|
-
|
|
180
|
-
|
|
319
|
+
for (const dim of MODE_ORDER) {
|
|
320
|
+
const d = FACET_DIMS[dim];
|
|
321
|
+
for (const row of filter[d.control] || []) {
|
|
322
|
+
const key = facetKey(dim, row[d.rowKey]);
|
|
323
|
+
row.on = key !== undefined && sel[d.control].has(key);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
181
326
|
return filter;
|
|
182
327
|
}
|
|
183
328
|
|
|
@@ -249,6 +394,10 @@ export function statChip(state) {
|
|
|
249
394
|
// Not an error: the user's selection is fine, the model simply moved under them.
|
|
250
395
|
case 'conflict': return { cls: 'conflict', text: 'Save conflict', badge: null };
|
|
251
396
|
case 'stale': return { cls: 'conflict', text: 'Out of date', badge: null };
|
|
397
|
+
// The filter edit SAVED but the read's layer approval was refused, so the read cannot proceed.
|
|
398
|
+
// Wears the same pill for the same reason: what you see no longer matches the server, and the chip
|
|
399
|
+
// is the route back to the explanation.
|
|
400
|
+
case 'signoff-blocked': return { cls: 'conflict', text: 'Approval needed', badge: null };
|
|
252
401
|
// Informational, not the result of an action the user took — so no green ✓ for a save that never happened.
|
|
253
402
|
case 'note': return { cls: '', text: NOTE_TEXT, badge: null };
|
|
254
403
|
default: return { cls: '', text: '', badge: null };
|
|
@@ -370,3 +519,58 @@ export function liveUpdateAction(frame, ctx) {
|
|
|
370
519
|
// caller's table lookup can never be handed an object or a number off the wire.
|
|
371
520
|
return { act: 'banner', reason: typeof frame.reason === 'string' ? frame.reason : null };
|
|
372
521
|
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* THE canonical "dismissible" facet set — the ONE definition shared by the recorded exclusion
|
|
525
|
+
* sign-off's server digest (server/steel-read-manifest.ts), the sign-off confirm step in
|
|
526
|
+
* steel-filter.html, the `facet-census` coverage check, and the completion audit's
|
|
527
|
+
* shorthand-eligibility predicate. Defining it once is the point: predicates that merely agree can
|
|
528
|
+
* drift, and this one decides when real steel may be dismissed without a line-by-line justification.
|
|
529
|
+
*
|
|
530
|
+
* Generalised from `dismissibleLayerNames` (#805 Phase D slice D2). It is REPLACED, not wrapped: two
|
|
531
|
+
* functions that agree is exactly the shape this epic keeps losing to.
|
|
532
|
+
*
|
|
533
|
+
* Three rules, and the first is load-bearing:
|
|
534
|
+
*
|
|
535
|
+
* 1. **Only dimensions the saved `mode` activates contribute** (`selectionDims` — the LEDGER's rule,
|
|
536
|
+
* the same one `selectionIndex` reads). A line unselected under `mode: 'thickness'` is unselected
|
|
537
|
+
* because of its width, so a layer approval had no bearing on why; borrowing authority from a
|
|
538
|
+
* facet the mode ignores would inherit a premise nobody established. Folding the mode into the SET
|
|
539
|
+
* also closes a silent-broadening hole structurally: an approval recorded under `layer` cannot
|
|
540
|
+
* carry unchanged into a later save under `thickness+layer`, because the set changes, so the
|
|
541
|
+
* digest changes, so the approval is invalid.
|
|
542
|
+
* 2. A value qualifies iff its CANONICAL key is well-formed for its dimension (`facetKey` plus
|
|
543
|
+
* `isDismissibleFacetValue` — a non-empty string, or a finite number) and EVERY row carrying that
|
|
544
|
+
* canonical key has `on === false`. A duplicated value with one row ticked ON is therefore NOT
|
|
545
|
+
* dismissible, and neither is a non-boolean `on`, which is neither ON nor OFF. Grouping by the
|
|
546
|
+
* CANONICAL key is what makes a hand-edited `#ABC123: false` beside `#abc123: true` read as the
|
|
547
|
+
* one conflicted value it is, rather than as an approval of half of it.
|
|
548
|
+
* 3. Values are emitted once each, in the filter's persisted order within their dimension, never
|
|
549
|
+
* sorted — the order is part of the list the human was shown, and a reorder must read as a change.
|
|
550
|
+
* Dimensions are emitted in `MODE_ORDER` order.
|
|
551
|
+
*
|
|
552
|
+
* @returns {Array<{ dim: 'thickness'|'layer'|'color', value: number|string }>}
|
|
553
|
+
*/
|
|
554
|
+
export function dismissibleFacetValues(filter) {
|
|
555
|
+
const source = (filter && typeof filter === 'object' && !Array.isArray(filter)) ? filter : {};
|
|
556
|
+
const active = new Set(selectionDims(source.mode));
|
|
557
|
+
const out = [];
|
|
558
|
+
for (const dim of MODE_ORDER) {
|
|
559
|
+
if (!active.has(dim)) continue;
|
|
560
|
+
const d = FACET_DIMS[dim];
|
|
561
|
+
const rows = Array.isArray(source[d.control]) ? source[d.control] : [];
|
|
562
|
+
const allOff = new Map();
|
|
563
|
+
const order = [];
|
|
564
|
+
for (const row of rows) {
|
|
565
|
+
if (!row || typeof row !== 'object' || Array.isArray(row)) continue;
|
|
566
|
+
const key = facetKey(dim, row[d.rowKey]);
|
|
567
|
+
// Ill-formed values never enter. That is a deliberate FAIL-CLOSED change from the layer-only
|
|
568
|
+
// rule this generalises: such a line simply gets an explicit row instead.
|
|
569
|
+
if (key === undefined || !isDismissibleFacetValue(dim, key)) continue;
|
|
570
|
+
if (!allOff.has(key)) order.push(key);
|
|
571
|
+
allOff.set(key, (allOff.get(key) ?? true) && row.on === false);
|
|
572
|
+
}
|
|
573
|
+
for (const value of order) if (allOff.get(value) === true) out.push({ dim, value });
|
|
574
|
+
}
|
|
575
|
+
return out;
|
|
576
|
+
}
|