@floless/app 0.123.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 {
@@ -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}
@@ -7202,6 +7202,7 @@
7202
7202
  // project; the header project picker below is a separate, richer combo mirroring
7203
7203
  // the workflow picker). ───────────────────────────────────────────────
7204
7204
  let menuFor = null;
7205
+ const projectExportBusy = new Set();
7205
7206
  function menuItem(action, label) {
7206
7207
  return `<button class="menu-item" data-act="${action}" role="menuitem"><span class="menu-label">${escapeHtml(label)}</span></button>`;
7207
7208
  }
@@ -7260,7 +7261,10 @@
7260
7261
  closeProjMenu();
7261
7262
  // Export is read-only — keep it out of the rename/duplicate/archive busy-lock (and its
7262
7263
  // trailing loadProjects reconcile), so it can run alongside them without contention.
7263
- if (act.dataset.act === 'export') { exportProject(id); return; }
7264
+ if (act.dataset.act === 'export') {
7265
+ if (!projectExportBusy.has(id)) exportProject(id);
7266
+ return;
7267
+ }
7264
7268
  // The PICKER runs outside the busy-lock, the write inside it: an OS file dialog can sit open for as
7265
7269
  // long as the user likes, and holding the lock across it would wedge every other project action
7266
7270
  // behind a dialog nobody can see from here. (Rename's prompt is an in-app modal, so it can hold it.)
@@ -7508,28 +7512,59 @@
7508
7512
  });
7509
7513
  }
7510
7514
 
7511
- // Export a project as a portable .zip (back it up / move it to another machine). Fetch → Blob →
7512
- // download anchor so a server error surfaces as a toast (not a broken download) and success is
7513
- // 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
+
7514
7533
  async function exportProject(id) {
7534
+ if (projectExportBusy.has(id)) return;
7515
7535
  const proj = projects.find((p) => p.id === id);
7516
7536
  const label = proj ? proj.name : id;
7517
- 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
+ };
7518
7545
  try {
7519
- const res = await fetch(`/api/projects/${encodeURIComponent(id)}/export.zip`);
7520
- if (!res.ok) throw new Error((await res.json().catch(() => ({}))).error || `HTTP ${res.status}`);
7521
- const blob = await res.blob();
7522
- const cd = res.headers.get('content-disposition') || '';
7523
- const name = (cd.match(/filename="?([^"]+)"?/) || [])[1] || `${label}.zip`;
7524
- const url = URL.createObjectURL(blob);
7525
- const a = document.createElement('a');
7526
- a.href = url; a.download = name;
7527
- document.body.appendChild(a); a.click(); a.remove();
7528
- setTimeout(() => URL.revokeObjectURL(url), 1000);
7529
- 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');
7530
7550
  track('workspace_project_exported', { app: proj ? proj.app : undefined });
7531
7551
  } catch (err) {
7532
- 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);
7533
7568
  }
7534
7569
  }
7535
7570
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.123.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": {