@floless/app 0.122.0 → 0.123.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.
@@ -97,6 +97,67 @@ export function bgRect(sheet) {
97
97
  return { x: 0, y: 0, w: pg.w || 0, h: pg.h || 0 };
98
98
  }
99
99
 
100
+ /** The floor and the no-measurement default for a text element's font-size (both pre-date this helper). */
101
+ const TEXT_MIN_FONT = 8;
102
+ const TEXT_DEFAULT_FONT = 10;
103
+ /**
104
+ * The narrowest per-glyph advance, as a fraction of the bbox height, that horizontal text can plausibly
105
+ * have. The tightest real glyphs — period, comma, `i`, space — advance ~0.25 of the font size against a
106
+ * ~1.15-font-size line box, i.e. ~0.21; this keeps a ~2x margin under that so no horizontal run is ever
107
+ * mistaken for a vertical one. See textFontSize for what the number decides.
108
+ */
109
+ const MIN_HORIZONTAL_ADVANCE = 0.1;
110
+
111
+ /**
112
+ * The `font-size` for one text element, from its bounding box and its string.
113
+ *
114
+ * The producer records a bbox and the text, never a rotation, so the writing direction has to be
115
+ * INFERRED. For horizontal text the run advances along X, so the box's HEIGHT is the glyph height —
116
+ * which is what the view always used. For a rotated (vertical) run the long axis is Y, so the height is
117
+ * the whole STRING LENGTH, not the glyph size: on one real photographed set a vertical plot stamp
118
+ * measured 9.3 wide x 373.8 tall and rendered at font-size 373.8 — ~4500px of text over a page ~1000
119
+ * units wide, dwarfing the linework, with title-block lines behind it at 250-348 (#591).
120
+ *
121
+ * The discriminator is per-glyph PLAUSIBILITY, not the raw aspect ratio, because aspect alone cannot
122
+ * separate the two cases: a 2-glyph horizontal ".," is as tall-and-thin as a 2-glyph vertical run.
123
+ * So: assume the run is horizontal, which makes `h` the glyph height and requires the n glyphs to span
124
+ * at least `MIN_HORIZONTAL_ADVANCE * n * h` along X. A box narrower than that cannot hold the string
125
+ * horizontally at that glyph height, so the run is vertical and the SHORT side is the glyph height.
126
+ *
127
+ * Note the test is on the ADVANCE (w vs n*h), so it does not care how long the string is — a 60-glyph
128
+ * stamp and a 6-glyph title-block line are judged by the same rule. What it does depend on is that `h`
129
+ * is inflated by the glyph count in the vertical case, which is why short vertical runs are the weak
130
+ * end: a run of ~3 glyphs or more is caught, 2 is not.
131
+ *
132
+ * `w < h` is not redundant with that test, and it is what stops this from making a drawing WORSE.
133
+ * Rotation is not only 0 or 90 degrees — a label along a diagonal brace has an axis-aligned bbox with
134
+ * BOTH sides inflated, and for a long run the n*h threshold is large enough to swallow it: a 60-glyph
135
+ * span in a 350x100 box passes (350 < 600) while its short side is the HEIGHT. Without this guard the
136
+ * helper would hand back 350 where the old expression gave 100 — the opposite of its own promise to
137
+ * take the short side. With it, the returned side is never the long one, so the size can only ever go
138
+ * down. (Found by review, not by the tests, which had no shallow-angle case; there is one now.)
139
+ *
140
+ * Everything else is deliberately untouched, so a correctly-oriented drawing renders byte-identically:
141
+ * every horizontal run, a single glyph (no run to measure), and a degenerate box with no positive width
142
+ * (nothing to measure the glyph height WITH) all keep the height. A 2-glyph vertical run is the known
143
+ * gap and is left alone on purpose — at 2 glyph-heights the oversize is mild, and tightening the
144
+ * constant far enough to catch it would start shrinking narrow horizontal text, which is the worse
145
+ * failure (unreadable labels on every drawing, to fix a rare one).
146
+ */
147
+ export function textFontSize(bbox, text) {
148
+ // Junk coerces to 0 rather than NaN, so a malformed bbox lands on the default below instead of
149
+ // poisoning the comparison (NaN fails every test, which would silently mean "horizontal").
150
+ const num = (v) => (Number.isFinite(Number(v)) ? Number(v) : 0);
151
+ const b = Array.isArray(bbox) ? bbox : [];
152
+ const w = num(b[2]) - num(b[0]);
153
+ const h = num(b[3]) - num(b[1]);
154
+ const glyphs = (text == null ? '' : String(text)).trim().length;
155
+ const vertical = glyphs > 1 && w > 0 && w < h && w < h * glyphs * MIN_HORIZONTAL_ADVANCE;
156
+ const side = vertical ? w : h;
157
+ // `|| TEXT_DEFAULT_FONT` for a zero/unmeasurable side, then the floor — the two-step the page shipped.
158
+ return Math.max(TEXT_MIN_FONT, side || TEXT_DEFAULT_FONT);
159
+ }
160
+
100
161
  /**
101
162
  * Write the live selection + mode back onto the filter block's `on` flags so it persists on the
102
163
  * contract (what Save PUTs, and what the reader reads). Mutates and returns `filter`.
@@ -90,6 +90,17 @@ button:focus-visible{outline:2px solid var(--brand);outline-offset:1px}
90
90
  input[type=checkbox]{-webkit-appearance:none;appearance:none;width:14px;height:14px;flex:none;border:1px solid #475569;border-radius:3px;background:transparent;cursor:pointer;margin:0;vertical-align:middle}
91
91
  input[type=checkbox]:checked{background:var(--brand);border-color:var(--brand);background-image:url("data:image/svg+xml,%3Csvg viewBox='0 0 10 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 4l3 3 5-5' stroke='%23fff' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:center}
92
92
  input:focus-visible{outline:2px solid var(--brand);outline-offset:1px}
93
+ /* FORCED COLORS (Windows High Contrast): the OS overrides every authored colour, so the custom fill and
94
+ the SVG tick above both collapse to system colours and checked stops being tellable from unchecked.
95
+ Give the platform its own widget back — there the UA control is the accessible one, and the
96
+ white-square leak the rule above exists to fix cannot arise because the OS picks the colours.
97
+ This surface was NOT otherwise changed by #592: its global checkbox already predates it. The gap is
98
+ the same one Codex raised on the four converted surfaces, and leaving one page behaving differently
99
+ in High Contrast is worse than the small extra diff. */
100
+ @media (forced-colors: active){
101
+ input[type=checkbox]{-webkit-appearance:revert;appearance:revert;width:revert;height:revert;
102
+ border:revert;background:revert;background-image:none}
103
+ }
93
104
  .facet.dim{opacity:.4} .facet.dim .opts,.facet.dim .acts{pointer-events:none}
94
105
  .hint{color:var(--mut);font-size:11px;line-height:1.5}
95
106
  footer{margin-top:auto;display:flex;align-items:center;gap:6px;flex-wrap:wrap;border-top:1px solid var(--line);padding-top:12px}
@@ -217,7 +228,7 @@ body.publication-blocked #empty{position:static;flex:1}
217
228
  </div>
218
229
 
219
230
  <script type="module">
220
- import { matchesActive, modeDims, canonicalMode, selFromFilter, eyedropperAdd, countShown, bgRect, applySelToFilter, normalizeFilter, liveUpdateAction, statChip, newMutationId, sheetLabel, NOTE_TEXT } from './steel-filter-core.js';
231
+ import { matchesActive, modeDims, canonicalMode, selFromFilter, eyedropperAdd, countShown, bgRect, textFontSize, applySelToFilter, normalizeFilter, liveUpdateAction, statChip, newMutationId, sheetLabel, NOTE_TEXT } from './steel-filter-core.js';
221
232
 
222
233
  const APP_ID = new URLSearchParams(location.search).get('app') || '';
223
234
  // Workspaces: project-keyed contract (see steel-editor.html). Empty = legacy app-keyed URLs.
@@ -834,7 +845,11 @@ function buildOverlay(){
834
845
  n = document.createElementNS(SVGNS, 'text');
835
846
  const b = el.bbox || [0,0,0,0];
836
847
  n.setAttribute('x', b[0]); n.setAttribute('y', b[3] || b[1]);
837
- n.setAttribute('font-size', Math.max(8, (b[3]-b[1]) || 10));
848
+ // Sized by textFontSize, not by the bbox height: on a rotated run the height is the string
849
+ // LENGTH, and taking it verbatim rendered title-block text at font-size 373 (#591). It fixes
850
+ // the SIZE only — a vertical run is still drawn horizontally, because the producer records no
851
+ // rotation direction to draw it with.
852
+ n.setAttribute('font-size', textFontSize(b, el.text));
838
853
  n.setAttribute('fill', layerColor[el.layer] || '#cbd5e1');
839
854
  n.textContent = el.text || '';
840
855
  } else {
@@ -25,13 +25,15 @@
25
25
  * UNITS AND SIGNS — the one thing to get right.
26
26
  * Contract geometry is per-sheet display pixels scaled by `plan.pt_per_ft`, with Y growing DOWNWARD, and
27
27
  * elevations in INCHES. World mm is X east, Y "up the plan", Z up. So the plan Y axis is NEGATED, exactly
28
- * as `server/contract-to-scene.ts:dispToMm` does it. That negation is a reflection: it reverses handedness,
28
+ * as `steel-3d-core.js:dispToMm` does it. That negation is a reflection: it reverses handedness,
29
29
  * which is why `sheetFrame` documents what happens to a local frame's sense.
30
30
  *
31
- * This mirrors `contract-to-scene.ts`'s conversion rather than importing it (that file is server TypeScript;
32
- * this one is a browser module). Two independent world-mm conversions would be a real hazard — a model that
33
- * renders in one place and exports in another — so the mirror is held in lock-step by a parity test matrix
34
- * (`server/steel-model-adapter.test.ts`, "parity with contract-to-scene"). Change one, change both.
31
+ * IT IS NO LONGER A MIRROR. This module, the 3D view and `server/contract-to-scene.ts` all CALL the one
32
+ * `dispToMm` in `steel-3d-core.js` — a browser module the server already imports, so "that file is server
33
+ * TypeScript" never justified a second copy. Two independent world-mm conversions were a real hazard (a
34
+ * model that renders in one place and exports in another) and the parity test matrix
35
+ * (`server/steel-model-adapter.test.ts`, "parity with contract-to-scene") that held them in lock-step by
36
+ * hand is kept: it now guards the shared conversion instead of a copy of it.
35
37
  *
36
38
  * The two agree on every conversion of well-formed data: px scale, the Y negation, inches to mm (including
37
39
  * numeric strings), and the plumb-column rule. They diverge, deliberately and by assertion, on MALFORMED or
@@ -44,16 +46,12 @@
44
46
  * recorded here rather than asserted, since pinning a NaN as expected output would entrench a bug).
45
47
  */
46
48
 
47
- import { MODEL_V2_TOL, memberGeometryV2 } from './steel-3d-core.js';
49
+ import { MODEL_V2_TOL, memberGeometryV2, dispToMm } from './steel-3d-core.js';
48
50
 
49
- const FT_MM = 304.8;
50
51
  const IN_MM = 25.4; // ← becomes 1 when the contract stores elevations in mm (metric canonicalization)
51
52
 
52
- /** Scale for one plan's display pixels → mm. Matches contract-to-scene: a missing/zero pt_per_ft means 1. */
53
- const scaleOf = (plan) => FT_MM / (plan && plan.pt_per_ft > 0 ? plan.pt_per_ft : 1);
54
-
55
- /** Display point → world mm. Y is NEGATED (display Y grows down; world Y grows up the plan). */
56
- const dispToMm = (pt, k) => [pt[0] * k, -pt[1] * k];
53
+ /** One plan's `pt_per_ft`, or undefined — `dispToMm` reads a missing/zero/negative scale as 1 pt/ft. */
54
+ const ptPerFtOf = (plan) => plan && plan.pt_per_ft;
57
55
 
58
56
  const finitePt = (p) => Array.isArray(p) && p.length >= 2 && Number.isFinite(p[0]) && Number.isFinite(p[1]);
59
57
 
@@ -80,7 +78,8 @@ const num = (v) => {
80
78
  * Validity is the server's to judge, and a read boundary that quietly fell back to the v1 arm for a
81
79
  * malformed v2 document would answer with confident nonsense — a v2 member has no `wp`, so every method
82
80
  * would report an absence rather than a problem. Mirrored rather than imported because that module is
83
- * server TypeScript and this is a browser module; the same is true of the `dispToMm` mirror above.
81
+ * server TypeScript and this is a browser module — a reason that holds for the DISCRIMINATOR only; the
82
+ * `dispToMm` mirror it used to cite alongside is gone, imported from `steel-3d-core.js` now.
84
83
  */
85
84
  export function createModelAdapter(contract, opts = {}) {
86
85
  return (contract && typeof contract === 'object' && contract.type === 'steel.model/v2')
@@ -171,11 +170,11 @@ function createModelAdapterV1(contract, { activeSheet } = {}) {
171
170
  const m = memberById(id);
172
171
  if (!m || !Array.isArray(m.wp) || m.wp.length < 2 || !finitePt(m.wp[0]) || !finitePt(m.wp[1])) return null;
173
172
  const plan = planFor(m);
174
- const k = scaleOf(plan);
173
+ const ptPerFt = ptPerFtOf(plan);
175
174
  const z0 = endElevMm(m, plan, 0), z1 = endElevMm(m, plan, 1);
176
175
  if (z0 == null || z1 == null) return null;
177
- const a = dispToMm(m.wp[0], k);
178
- const b = m.role === 'column' ? a : dispToMm(m.wp[1], k); // plumb: the top shares the base X/Y
176
+ const a = dispToMm(m.wp[0], ptPerFt);
177
+ const b = m.role === 'column' ? a : dispToMm(m.wp[1], ptPerFt); // plumb: the top shares the base X/Y
179
178
  return { from: [a[0], a[1], z0], to: [b[0], b[1], z1], frame: 'world-mm' };
180
179
  },
181
180
 
@@ -204,8 +203,7 @@ function createModelAdapterV1(contract, { activeSheet } = {}) {
204
203
  if (!f || !finitePt(f.o) || !finitePt(f.u)) return null;
205
204
  const len = Math.hypot(f.u[0], f.u[1]);
206
205
  if (!(len > 0)) return null; // a zero-length axis carries no direction — matches the editor's sanitizeFrame
207
- const k = scaleOf(p);
208
- return { origin: dispToMm(f.o, k), xAxis: [f.u[0] / len, -f.u[1] / len] };
206
+ return { origin: dispToMm(f.o, ptPerFtOf(p)), xAxis: [f.u[0] / len, -f.u[1] / len] };
209
207
  },
210
208
 
211
209
  /**
@@ -145,13 +145,13 @@
145
145
  * previous version was stale within one PR, twice.
146
146
  */
147
147
 
148
- const FT_MM = 304.8;
149
148
  const IN_MM = 25.4;
150
149
 
151
150
  import { dispatchV2ProjectionCommand } from './steel-model-v2-commands.js';
151
+ import { mmPerPx } from './grid-core.js';
152
152
 
153
- /** Display-pixel scale for one plan, identical to the adapter's `scaleOf`. Change one, change both. */
154
- const scaleOf = (plan) => FT_MM / (plan && plan.pt_per_ft > 0 ? plan.pt_per_ft : 1);
153
+ /** Display-pixel scale for one plan — the shared `mmPerPx`, not a fourth copy to keep in lock-step. */
154
+ const scaleOf = (plan) => mmPerPx(plan && plan.pt_per_ft);
155
155
 
156
156
  /** Kill float noise before it persists into `wp` — the same r6 the three inline call sites applied. */
157
157
  const r6 = (n) => Math.round(n * 1e6) / 1e6;
@@ -191,7 +191,7 @@ export function deepFreezeProjection(value) {
191
191
  * World-mm offsets → one plan's display-pixel offsets, with dz in INCHES. Order is preserved because
192
192
  * copy order is offset-major and therefore observable in the stored contract.
193
193
  *
194
- * Y IS NEGATED: display Y grows down, world Y grows up the plan — the inverse of the adapter's
194
+ * Y IS NEGATED: display Y grows down, world Y grows up the plan — the inverse of `steel-3d-core`'s
195
195
  * `dispToMm`. A ROUNDED inverse, not an exact one: `r6` quantises to 6dp, so a round trip lands within
196
196
  * ~1e-5 mm rather than exactly. The tests assert the quantised values rather than pretending otherwise,
197
197
  * because the quantisation is the pre-existing behaviour being preserved.
@@ -6,9 +6,8 @@
6
6
  * control to a world point. Nothing here infers a view kind or substitutes missing registration data.
7
7
  */
8
8
 
9
- import { parseSpacings, labelsFor } from './grid-core.js';
9
+ import { parseSpacings, labelsFor, mmPerPx } from './grid-core.js';
10
10
 
11
- const FT_MM = 304.8;
12
11
  const ROUND = 1e9;
13
12
  const clean = (n) => {
14
13
  const q = Math.round(n * ROUND) / ROUND;
@@ -100,10 +99,13 @@ export function planTransform(plan) {
100
99
  const registrationGrid = plan.modelGrid || plan.grid;
101
100
  const world0 = plan.datum_ref ? gridIntersection(registrationGrid, plan.datum_ref, plan) : [0, 0];
102
101
  const world1 = gridIntersection(registrationGrid, plan.control2_ref, plan);
103
- const mmPerPx = FT_MM / ptPerFt;
102
+ // The shared plan scale. Its zero/negative fallback is unreachable here — the guard above already
103
+ // refused any sheet whose `pt_per_ft` is not a positive finite number — so this is the same value
104
+ // the inline `FT_MM / ptPerFt` produced, from the one implementation.
105
+ const scale = mmPerPx(ptPerFt);
104
106
  const local1 = [
105
- (plan.control2_at[0] - plan.datum_at[0]) * mmPerPx,
106
- (plan.datum_at[1] - plan.control2_at[1]) * mmPerPx,
107
+ (plan.control2_at[0] - plan.datum_at[0]) * scale,
108
+ (plan.datum_at[1] - plan.control2_at[1]) * scale,
107
109
  ];
108
110
  const worldDelta = [world1[0] - world0[0], world1[1] - world0[1]];
109
111
  const localLen = Math.hypot(local1[0], local1[1]);
@@ -118,7 +120,7 @@ export function planTransform(plan) {
118
120
  if (![c, s, fitScale, world0[0], world0[1]].every(Number.isFinite)) {
119
121
  return refuse('registration-invalid', `sheet "${plan.sheet || '?'}" has a non-finite registration transform`, plan);
120
122
  }
121
- return { datumPx: plan.datum_at, world0, mmPerPx, fitScale, rotation, c, s };
123
+ return { datumPx: plan.datum_at, world0, mmPerPx: scale, fitScale, rotation, c, s };
122
124
  }
123
125
 
124
126
  /** Canonical world-mm work point → this plan's display px. */
@@ -8,8 +8,6 @@
8
8
  */
9
9
  import { parseLen, fmtLen } from './grid-core.js';
10
10
 
11
- export const DEFAULT_CUT_MM = 24 * 25.4;
12
-
13
11
  /**
14
12
  * Display modes a saved view may carry. Must stay a superset of the 3D toolbar's `#m3dMode`
15
13
  * buttons in steel-editor.html — a mode the dropdown offers but this list omits is silently
@@ -45,7 +45,39 @@
45
45
  #bar .tb-sep{width:1px;height:18px;background:var(--line);flex:0 0 auto}
46
46
  /* Group visibility toggles folded INLINE into the pill (leaves bottom-left to the skip panel). */
47
47
  #bar .gck{display:inline-flex;align-items:center;gap:6px;background:var(--panel);border:1px solid var(--line);border-radius:6px;padding:4px 9px;box-shadow:0 4px 14px rgba(0,0,0,.45);cursor:pointer;color:var(--text);font-size:12px}
48
- #bar .gck input{accent-color:var(--brand);cursor:pointer;margin:0}
48
+ /* Global checkbox theming (CLAUDE.md "Style EVERY control … no browser default may leak through").
49
+ `accent-color` alone — which every checkbox on this surface used to rely on — tints only the
50
+ CHECKED fill; the UNCHECKED box stays the UA widget, a solid white square on this dark page.
51
+ Rebuilt as its own box + ::before tick, matching steel-filter.html:90 and steel-editor.html. The
52
+ tick is a fixed 9px, NOT a percentage: the box is `display:inline-grid` with `place-content:center`,
53
+ so its track is sized by this very item and a percentage width resolves to 0 — measured at 6x, the
54
+ checked box painted a solid brand square with no check in it. */
55
+ input[type=checkbox]{appearance:none;-webkit-appearance:none;width:14px;height:14px;flex:none;padding:0;
56
+ border:1px solid #475569;border-radius:3px;background:var(--bg);cursor:pointer;display:inline-grid;place-content:center;
57
+ transition:border-color .12s,background-color .12s}
58
+ input[type=checkbox]::before{content:'';width:9px;height:9px;background:#fff;transform:scale(0);transition:transform .12s ease;
59
+ clip-path:polygon(14% 44%,0 65%,50% 100%,100% 16%,80% 0%,43% 62%)}
60
+ input[type=checkbox]:checked{background:var(--brand);border-color:var(--brand)}
61
+ input[type=checkbox]:checked::before{transform:scale(1)}
62
+ input[type=checkbox]:focus-visible{outline:2px solid var(--brand);outline-offset:2px}
63
+ /* INDETERMINATE. `appearance:none` deletes the platform's mixed-state dash, and only `:checked`
64
+ reveals the tick — so a box put in the mixed state would render exactly like an unchecked one.
65
+ Declared on every surface so the next page to set .indeterminate inherits it rather than shipping
66
+ a checkbox that silently reports "no" for "the selection disagrees". (Codex review on #592.) */
67
+ input[type=checkbox]:indeterminate{background:var(--brand);border-color:var(--brand)}
68
+ input[type=checkbox]:indeterminate::before{transform:scale(1);clip-path:none;height:2px;border-radius:1px}
69
+ /* FORCED COLORS (Windows High Contrast): the OS overrides every authored colour, so the custom fill
70
+ and the clipped tick both collapse to system colours and the states stop being tellable apart.
71
+ Give the platform its own widget back — there the UA control is the accessible one, and the
72
+ white-on-dark leak this rule exists to fix cannot arise because the OS picks the colours.
73
+ verify-native-controls cannot see inside a conditional @media, so this neither satisfies nor
74
+ weakens it. (Codex review on #592.) */
75
+ @media (forced-colors: active){
76
+ input[type=checkbox]{appearance:revert;-webkit-appearance:revert;width:revert;height:revert;
77
+ border:revert;background:revert;display:revert;padding:revert}
78
+ input[type=checkbox]::before{content:none}
79
+ }
80
+ #bar .gck input{cursor:pointer;margin:0}
49
81
  #bar .gck .ct{color:var(--mut);font-variant-numeric:tabular-nums;font-size:11px}
50
82
  #bar .gck .sw{width:9px;height:9px;border-radius:2px;flex:none}
51
83
  /* The unplaced-entities panel, docked bottom-left. Glanceable (never a modal — it coexists with
@@ -38,7 +38,39 @@
38
38
  aside h3{margin:0;font-size:10px;color:var(--mut);text-transform:uppercase;letter-spacing:.06em}
39
39
  .ck{display:flex;align-items:center;gap:8px;padding:5px 6px;border-radius:6px;cursor:pointer;color:var(--text)}
40
40
  .ck:hover{background:var(--line)}
41
- .ck input{accent-color:var(--brand);cursor:pointer;margin:0}
41
+ /* Global checkbox theming (CLAUDE.md "Style EVERY control … no browser default may leak through").
42
+ `accent-color` alone — which every checkbox on this surface used to rely on — tints only the
43
+ CHECKED fill; the UNCHECKED box stays the UA widget, a solid white square on this dark page.
44
+ Rebuilt as its own box + ::before tick, matching steel-filter.html:90 and steel-editor.html. The
45
+ tick is a fixed 9px, NOT a percentage: the box is `display:inline-grid` with `place-content:center`,
46
+ so its track is sized by this very item and a percentage width resolves to 0 — measured at 6x, the
47
+ checked box painted a solid brand square with no check in it. */
48
+ input[type=checkbox]{appearance:none;-webkit-appearance:none;width:14px;height:14px;flex:none;padding:0;
49
+ border:1px solid #475569;border-radius:3px;background:var(--bg);cursor:pointer;display:inline-grid;place-content:center;
50
+ transition:border-color .12s,background-color .12s}
51
+ input[type=checkbox]::before{content:'';width:9px;height:9px;background:#fff;transform:scale(0);transition:transform .12s ease;
52
+ clip-path:polygon(14% 44%,0 65%,50% 100%,100% 16%,80% 0%,43% 62%)}
53
+ input[type=checkbox]:checked{background:var(--brand);border-color:var(--brand)}
54
+ input[type=checkbox]:checked::before{transform:scale(1)}
55
+ input[type=checkbox]:focus-visible{outline:2px solid var(--brand);outline-offset:2px}
56
+ /* INDETERMINATE. `appearance:none` deletes the platform's mixed-state dash, and only `:checked`
57
+ reveals the tick — so a box put in the mixed state would render exactly like an unchecked one.
58
+ Declared on every surface so the next page to set .indeterminate inherits it rather than shipping
59
+ a checkbox that silently reports "no" for "the selection disagrees". (Codex review on #592.) */
60
+ input[type=checkbox]:indeterminate{background:var(--brand);border-color:var(--brand)}
61
+ input[type=checkbox]:indeterminate::before{transform:scale(1);clip-path:none;height:2px;border-radius:1px}
62
+ /* FORCED COLORS (Windows High Contrast): the OS overrides every authored colour, so the custom fill
63
+ and the clipped tick both collapse to system colours and the states stop being tellable apart.
64
+ Give the platform its own widget back — there the UA control is the accessible one, and the
65
+ white-on-dark leak this rule exists to fix cannot arise because the OS picks the colours.
66
+ verify-native-controls cannot see inside a conditional @media, so this neither satisfies nor
67
+ weakens it. (Codex review on #592.) */
68
+ @media (forced-colors: active){
69
+ input[type=checkbox]{appearance:revert;-webkit-appearance:revert;width:revert;height:revert;
70
+ border:revert;background:revert;display:revert;padding:revert}
71
+ input[type=checkbox]::before{content:none}
72
+ }
73
+ .ck input{cursor:pointer;margin:0}
42
74
  .ck .ct{margin-left:auto;color:var(--mut);font-variant-numeric:tabular-nums;font-size:11px}
43
75
  .muted{color:var(--mut);font-size:12px;line-height:1.5}
44
76
  hr{border:0;border-top:1px solid var(--line);margin:0}
@@ -1468,72 +1468,16 @@
1468
1468
  });
1469
1469
 
1470
1470
  // ── Approve (per-project) ───────────────────────────────────────────────────
1471
- // Shared by the header ✓ Approve and the Exports-tab gate link ("Approve this version"), so the
1472
- // sign-off is one flow. On success it stamps current.approvedAt (server returns it) so the
1473
- // Exports gate unlocks without a reload.
1474
- async function legacyApproveProject() {
1475
- if (!current) return;
1476
- // The flag, not the attribute — `aria-disabled` is advisory and the button stays clickable BY
1477
- // DESIGN (that is what keeps its data-tip reachable), so this is the check that actually holds.
1478
- // Without it the header button still fires the 404 that #490 is about. Say what to do instead
1479
- // rather than reporting the failure: the user has no model, and that is the only useful sentence.
1480
- // RE-PROBE before refusing, never refuse from the cache. A stale `false` here is far worse than
1481
- // the 404 it replaced: it blocks a legitimate sign-off while confidently telling the user to read a
1482
- // drawing they have already read — and stale IS reachable, because a model can appear without this
1483
- // pane hearing about it (an AI read landing while Drawings is open, a staged review confirmed
1484
- // elsewhere, the editor's first autosave). One request at click time removes the whole class.
1485
- if (!exportsHasModel) {
1486
- const stillNone = !(await projectHasContract(current.id, current.app));
1487
- if (!current) return; // closed during the probe
1488
- applyModelPresence(!stillNone); // correct the cache either way — the header was lying too
1489
- if (stillNone) {
1490
- showToast(`There’s no model to approve yet — read a drawing on ${stepLabel('drawings')} first.`, 'warn');
1491
- return;
1492
- }
1493
- }
1494
- const approvingProject = current;
1495
- const btn = document.getElementById('ws-approve');
1496
- // Unreachable today (#ws-approve is static markup), but approveProject is driven from THREE
1497
- // controls — a silent return would turn all three into dead clicks if the header were ever renamed.
1498
- if (!btn) {
1499
- console.error('[workspaces] #ws-approve is missing — Approve cannot run');
1500
- showToast('Couldn’t start Approve — reload the page.', 'warn');
1501
- return;
1502
- }
1503
- btn.disabled = true;
1504
- const prev = btn.textContent;
1505
- btn.textContent = '◆ Approving…';
1506
- try {
1507
- // Flush the editor's debounced autosave FIRST (same-origin iframe) so Approve bakes the
1508
- // LATEST edits, not a stale contract — a user can edit then hit Approve before the ~debounce
1509
- // fires. flushContract() PUTs the live contract and resolves; a save failure aborts the bake.
1510
- const win = frames.model && frames.model.contentWindow;
1511
- if (win && typeof win.flushContract === 'function') await win.flushContract();
1512
- throw new Error('Legacy one-click approval is disabled; use Review and approve.');
1513
- // Kept only so this retired branch remains parseable while its surrounding historical comments
1514
- // are removed in a later cleanup; execution cannot cross the throw above.
1515
- const res = null;
1516
- if (res && res.approvedAt) approvingProject.approvedAt = res.approvedAt; // unlock exports
1517
- const stillOpen = current && current.id === approvingProject.id;
1518
- if (stillOpen && !$wsHistory.hidden && res && res.version && Number.isInteger(Number(res.version.n))) {
1519
- expandDiffOnce = { projectId: approvingProject.id, n: Number(res.version.n) };
1520
- }
1521
- showToast(`Approved — "${approvingProject.name}" is baked into ${projectAppName(approvingProject)}`, 'ok');
1522
- track('workspace_project_approved', { app: approvingProject.app }); // a successful sign-off
1523
- // First Approve for this app calms the "✦ Start here" beacon (the document-archetype
1524
- // analog of a workflow's first Run); ticks the Review + Approve guide rows.
1525
- if (bridge.markWorkspaceApproved && wsDescOf(approvingProject)?.docGuide) {
1526
- bridge.markWorkspaceApproved(approvingProject.app);
1527
- }
1528
- if (stillOpen) {
1529
- syncWorkspaceGuide();
1530
- if (!$wsExports.hidden) renderExports(); // reflect the unlocked gate immediately if it's open
1531
- if (!$wsHistory.hidden) await renderHistory(); // reflect it, clear the banner, and open the new version's comparison
1532
- }
1533
- } catch (err) {
1534
- showToast('Approve failed: ' + (err && err.message || err), 'warn');
1535
- } finally { btn.disabled = false; btn.textContent = prev; }
1536
- }
1471
+ // One sign-off flow behind FOUR controls, all of which call approveProject(): the header
1472
+ // #ws-approve ("Review & approve"), the Exports pending-changes banner ([data-review-changes]),
1473
+ // the Exports gate link #ws-exports-approve ("Approve this version"), and History's
1474
+ // #hist-approve ("Review changes").
1475
+ //
1476
+ // What unlocks the Exports gate without a reload is the confirm's refreshApprovalState() +
1477
+ // renderExports(), which re-read the server's approval state and export sources — NOT the
1478
+ // `approvedAt` stamp. The gate is `exportSourcesState.status === 'ready' && an explicit source`
1479
+ // (paintExports), and it never reads approvedAt: that field is compatibility metadata only, as
1480
+ // the approvalState declaration above says.
1537
1481
  const approvalDecisionLabel = (decision) => decision === 'approve' ? 'Approve this change' : 'Leave pending';
1538
1482
 
1539
1483
  function renderApprovalReview() {
@@ -7258,6 +7202,7 @@
7258
7202
  // project; the header project picker below is a separate, richer combo mirroring
7259
7203
  // the workflow picker). ───────────────────────────────────────────────
7260
7204
  let menuFor = null;
7205
+ const projectExportBusy = new Set();
7261
7206
  function menuItem(action, label) {
7262
7207
  return `<button class="menu-item" data-act="${action}" role="menuitem"><span class="menu-label">${escapeHtml(label)}</span></button>`;
7263
7208
  }
@@ -7316,7 +7261,10 @@
7316
7261
  closeProjMenu();
7317
7262
  // Export is read-only — keep it out of the rename/duplicate/archive busy-lock (and its
7318
7263
  // trailing loadProjects reconcile), so it can run alongside them without contention.
7319
- if (act.dataset.act === 'export') { exportProject(id); return; }
7264
+ if (act.dataset.act === 'export') {
7265
+ if (!projectExportBusy.has(id)) exportProject(id);
7266
+ return;
7267
+ }
7320
7268
  // The PICKER runs outside the busy-lock, the write inside it: an OS file dialog can sit open for as
7321
7269
  // long as the user likes, and holding the lock across it would wedge every other project action
7322
7270
  // behind a dialog nobody can see from here. (Rename's prompt is an in-app modal, so it can hold it.)
@@ -7564,28 +7512,59 @@
7564
7512
  });
7565
7513
  }
7566
7514
 
7567
- // Export a project as a portable .zip (back it up / move it to another machine). Fetch → Blob →
7568
- // download anchor so a server error surfaces as a toast (not a broken download) and success is
7569
- // confirmed. ponytail: the whole zip lands in memory here — fine for desktop-scale projects.
7515
+ // Export a project as a portable .zip. The localhost host owns the native Save dialog because only
7516
+ // it can start at this project's exact exports directory; the old browser download anchor could be
7517
+ // blocked and always targeted Downloads. Cancel is an ordinary no-op. A per-project guard prevents
7518
+ // duplicate dialogs without blocking unrelated project actions while the chooser is open.
7519
+ async function downloadProjectExport(id, label) {
7520
+ const res = await fetch(`/api/projects/${encodeURIComponent(id)}/export.zip`);
7521
+ if (!res.ok) throw new Error((await res.json().catch(() => ({}))).error || `HTTP ${res.status}`);
7522
+ const blob = await res.blob();
7523
+ const cd = res.headers.get('content-disposition') || '';
7524
+ const name = (cd.match(/filename="?([^"]+)"?/) || [])[1] || `${label}.zip`;
7525
+ const url = URL.createObjectURL(blob);
7526
+ const a = document.createElement('a');
7527
+ a.href = url; a.download = name;
7528
+ document.body.appendChild(a); a.click(); a.remove();
7529
+ setTimeout(() => URL.revokeObjectURL(url), 1000);
7530
+ return name;
7531
+ }
7532
+
7570
7533
  async function exportProject(id) {
7534
+ if (projectExportBusy.has(id)) return;
7571
7535
  const proj = projects.find((p) => p.id === id);
7572
7536
  const label = proj ? proj.name : id;
7573
- showToast(`Exporting “${label}”…`, 'ok');
7537
+ projectExportBusy.add(id);
7538
+ const dismissProgress = showToast(`Exporting “${label}”…`, 'progress');
7539
+ let progressVisible = true;
7540
+ const finishProgress = () => {
7541
+ if (!progressVisible) return;
7542
+ progressVisible = false;
7543
+ dismissProgress();
7544
+ };
7574
7545
  try {
7575
- const res = await fetch(`/api/projects/${encodeURIComponent(id)}/export.zip`);
7576
- if (!res.ok) throw new Error((await res.json().catch(() => ({}))).error || `HTTP ${res.status}`);
7577
- const blob = await res.blob();
7578
- const cd = res.headers.get('content-disposition') || '';
7579
- const name = (cd.match(/filename="?([^"]+)"?/) || [])[1] || `${label}.zip`;
7580
- const url = URL.createObjectURL(blob);
7581
- const a = document.createElement('a');
7582
- a.href = url; a.download = name;
7583
- document.body.appendChild(a); a.click(); a.remove();
7584
- setTimeout(() => URL.revokeObjectURL(url), 1000);
7585
- showToast(`Exported ✓ — ${name}`, 'ok');
7546
+ const result = await api(`/api/projects/${encodeURIComponent(id)}/export/save`, { method: 'POST', body: '{}' });
7547
+ finishProgress();
7548
+ if (result.cancelled) return;
7549
+ showToast(`Exported “${label}” — ${result.filename}`, 'ok');
7586
7550
  track('workspace_project_exported', { app: proj ? proj.app : undefined });
7587
7551
  } catch (err) {
7588
- showToast('Export failed: ' + (err && err.message || err), 'warn');
7552
+ if (err && err.body && err.body.code === 'native-save-unavailable') {
7553
+ try {
7554
+ const filename = await downloadProjectExport(id, label);
7555
+ finishProgress();
7556
+ showToast(`Exported “${label}” — ${filename}`, 'ok');
7557
+ track('workspace_project_exported', { app: proj ? proj.app : undefined });
7558
+ return;
7559
+ } catch (fallbackError) {
7560
+ err = fallbackError;
7561
+ }
7562
+ }
7563
+ finishProgress();
7564
+ showToast(`Couldn’t export “${label}”: ${err && err.message || err}`, 'warn');
7565
+ } finally {
7566
+ finishProgress();
7567
+ projectExportBusy.delete(id);
7589
7568
  }
7590
7569
  }
7591
7570
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.122.0",
3
+ "version": "0.123.1",
4
4
  "type": "module",
5
5
  "description": "Thin localhost host for floless.app — serves web/ and shells the aware CLI. No engine, no LLM.",
6
6
  "bin": {
@@ -31,6 +31,7 @@
31
31
  "verify:no-title": "node build/verify-no-title.mjs",
32
32
  "verify:no-native-select": "node build/verify-no-native-select.mjs",
33
33
  "verify:scrollbars": "node build/verify-scrollbars.mjs",
34
+ "verify:native-controls": "node build/verify-native-controls.mjs",
34
35
  "verify:display-sync": "node build/verify-display-sync.mjs",
35
36
  "verify:view-modes": "node build/verify-view-modes.mjs",
36
37
  "verify:gateway": "node build/verify-contract-gateway.mjs",