@floless/app 0.117.1 → 0.119.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +214 -13
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +63 -8
- package/dist/skills/floless-app-vectorize/SKILL.md +91 -29
- package/dist/skills/floless-app-vectorize/scripts/classify_and_trace.py +1039 -0
- package/dist/skills/floless-app-vectorize/scripts/rectify_and_trace.py +447 -0
- package/dist/skills/floless-app-vectorize/scripts/vision_to_contract.py +176 -9
- package/dist/skills/reading-structural-drawings/SKILL.md +35 -3
- package/dist/skills/steel-drawing-abbreviations/SKILL.md +1 -1
- package/dist/skills/steel-drawing-abbreviations/references/standard-us-abbreviations.md +5 -1
- package/dist/web/app.css +56 -6
- package/dist/web/app.js +244 -0
- package/dist/web/index.html +14 -0
- package/dist/web/steel-3d-core.js +3 -3
- package/dist/web/steel-editor.html +20 -10
- package/dist/web/steel-filter-core.js +1 -1
- package/dist/web/vector-3d.html +33 -7
- package/dist/web/vector-editor.html +26 -2
- package/dist/web/workspaces.js +327 -13
- package/package.json +4 -2
package/dist/web/workspaces.js
CHANGED
|
@@ -112,6 +112,73 @@
|
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
// Single-image picker for Add/Replace thumbnail — same File System Access preference + hidden-input
|
|
116
|
+
// fallback as the two above. Returns null on cancel; never throws.
|
|
117
|
+
const THUMB_FILE_TYPES = [{
|
|
118
|
+
description: 'Image',
|
|
119
|
+
accept: { 'image/*': ['.png', '.jpg', '.jpeg', '.webp', '.gif', '.bmp'] },
|
|
120
|
+
}];
|
|
121
|
+
async function pickImageFile(fallbackInput) {
|
|
122
|
+
if (window.showOpenFilePicker) {
|
|
123
|
+
try {
|
|
124
|
+
const [handle] = await window.showOpenFilePicker({ multiple: false, types: THUMB_FILE_TYPES });
|
|
125
|
+
return handle ? handle.getFile() : null;
|
|
126
|
+
} catch (err) {
|
|
127
|
+
if (err && err.name === 'AbortError') return null; // user cancelled — not an error
|
|
128
|
+
throw err;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return new Promise((resolve) => {
|
|
132
|
+
const cleanup = () => {
|
|
133
|
+
fallbackInput.removeEventListener('change', onChange);
|
|
134
|
+
fallbackInput.removeEventListener('cancel', onCancel);
|
|
135
|
+
};
|
|
136
|
+
const onChange = () => { cleanup(); const f = (fallbackInput.files || [])[0] || null; fallbackInput.value = ''; resolve(f); };
|
|
137
|
+
const onCancel = () => { cleanup(); resolve(null); };
|
|
138
|
+
fallbackInput.addEventListener('change', onChange);
|
|
139
|
+
fallbackInput.addEventListener('cancel', onCancel);
|
|
140
|
+
fallbackInput.click();
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// The server's ceiling, mirrored so a doomed upload is refused here with a sentence the user can act
|
|
145
|
+
// on rather than as an HTTP error. MUST stay equal to MAX_THUMBNAIL_BYTES in server/projects-store.ts.
|
|
146
|
+
const MAX_THUMB_BYTES = 8 * 1024 * 1024;
|
|
147
|
+
const MAX_THUMB_SOURCE_BYTES = 64 * 1024 * 1024; // the PICKED file, refused before it is decoded
|
|
148
|
+
const THUMB_MAX_EDGE = 1600; // long edge after downscale — ~18× the 88px card band, ample for the viewer
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Decode the picked file, draw it at a bounded size, and re-encode.
|
|
152
|
+
*
|
|
153
|
+
* Not an optimisation: a phone photo is 3–8 MB for a picture shown 88 px tall, the project's export
|
|
154
|
+
* .zip has to carry every one of those bytes forever, and a duplicate copies them again. Bounding the
|
|
155
|
+
* long edge here means the stored file is tens of KB whatever the user picks.
|
|
156
|
+
*
|
|
157
|
+
* The re-encode also normalises the format. `toBlob` falls back to PNG on an engine that cannot write
|
|
158
|
+
* WebP, so the type we ask for is not necessarily the type we get — which is exactly why the server
|
|
159
|
+
* decides what a file IS from its magic number rather than from the Content-Type we send.
|
|
160
|
+
*/
|
|
161
|
+
async function encodeThumbnail(file) {
|
|
162
|
+
// Refuse on the FILE SIZE, before decoding. The bound below applies to the canvas, which is reached
|
|
163
|
+
// only after `createImageBitmap` has expanded the whole source in memory — a decompression bomb (or
|
|
164
|
+
// an honest 200 MP panorama) can take the tab down there, and an OOM kills the page before any
|
|
165
|
+
// catch can toast about it. 64 MB is far above any camera file and far below that cliff.
|
|
166
|
+
if (file.size > MAX_THUMB_SOURCE_BYTES) throw new Error('too-large');
|
|
167
|
+
let bitmap;
|
|
168
|
+
try { bitmap = await createImageBitmap(file); }
|
|
169
|
+
catch { throw new Error('decode'); }
|
|
170
|
+
const scale = Math.min(1, THUMB_MAX_EDGE / Math.max(bitmap.width, bitmap.height));
|
|
171
|
+
const w = Math.max(1, Math.round(bitmap.width * scale));
|
|
172
|
+
const h = Math.max(1, Math.round(bitmap.height * scale));
|
|
173
|
+
const canvas = document.createElement('canvas');
|
|
174
|
+
canvas.width = w; canvas.height = h;
|
|
175
|
+
canvas.getContext('2d').drawImage(bitmap, 0, 0, w, h);
|
|
176
|
+
if (bitmap.close) bitmap.close();
|
|
177
|
+
const blob = await new Promise((resolve) => canvas.toBlob(resolve, 'image/webp', 0.85));
|
|
178
|
+
if (!blob) throw new Error('encode');
|
|
179
|
+
return blob;
|
|
180
|
+
}
|
|
181
|
+
|
|
115
182
|
let exportState = null; // kind → { path, exportedAt } after a successful list; null = unknown/failed
|
|
116
183
|
// Readiness per CAD destination: host id → the server's readiness object, or {state:'checking'}
|
|
117
184
|
// while probing. Tekla answers from /api/tekla-readiness (a richer probe that can tell "open but
|
|
@@ -736,6 +803,68 @@
|
|
|
736
803
|
`</button>`;
|
|
737
804
|
}
|
|
738
805
|
|
|
806
|
+
/** The URL of a project's stored picture, stamped with `thumbnailTag` — the file's mtime and byte
|
|
807
|
+
* length, derived server-side from the file itself. The stamp is what lets the response be cached
|
|
808
|
+
* hard: replacing the picture changes the URL, so the previous one can never be served in its
|
|
809
|
+
* place. It is also the presence flag — a project has a picture exactly when it is set. */
|
|
810
|
+
const thumbUrl = (p) => `/api/projects/${encodeURIComponent(p.id)}/thumbnail?v=${encodeURIComponent(p.thumbnailTag || '')}`;
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* The card's top band: the generic mark, or — once the project has a picture — the picture, as a
|
|
814
|
+
* real `<button>`.
|
|
815
|
+
*
|
|
816
|
+
* A BUTTON, not the plain span with a dblclick on it, and that is the whole interaction decision.
|
|
817
|
+
* `.ws-card` is `role="button"` and its click handler opens the project on the FIRST click, so a
|
|
818
|
+
* literal double-click could never be evaluated: the card would already have navigated away. Making
|
|
819
|
+
* the band its own control (which stops the click reaching the card) is what makes BOTH gestures
|
|
820
|
+
* work — one click enlarges, and a double-click enlarges once and stays open (the viewer's backdrop
|
|
821
|
+
* dismiss ignores the second click; see openThumbView). It also gives keyboard users a route at all,
|
|
822
|
+
* which no dblclick design can.
|
|
823
|
+
*
|
|
824
|
+
* No `src` in the markup: it is set as a PROPERTY by paintCardThumbs, the same discipline
|
|
825
|
+
* paintRenderThumb uses — which is also what lets a picture that will not decode degrade to a line
|
|
826
|
+
* of text instead of a broken-image glyph.
|
|
827
|
+
*/
|
|
828
|
+
function thumbBandHtml(p, displayApp) {
|
|
829
|
+
const kind = `<span class="ws-kind">${escapeHtml(displayApp)}</span>`;
|
|
830
|
+
if (!p.thumbnailTag) return `<span class="ws-thumb">${kind}▦</span>`;
|
|
831
|
+
return `<button type="button" class="ws-thumb" data-thumb="${escapeAttr(p.id)}" ` +
|
|
832
|
+
`aria-label="${escapeAttr(`View the thumbnail of “${p.name}” larger`)}" data-tip="View this thumbnail larger">` +
|
|
833
|
+
`<img alt="" loading="lazy">${kind}<span class="ws-thumb-expand" aria-hidden="true">⤢</span></button>`;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
/** Point each rendered thumbnail at its bytes. Runs after every landing rebuild, because the
|
|
837
|
+
* rebuild replaces the nodes wholesale. */
|
|
838
|
+
function paintCardThumbs() {
|
|
839
|
+
for (const btn of $landing.querySelectorAll('button.ws-thumb')) {
|
|
840
|
+
const p = projects.find((x) => x.id === btn.dataset.thumb);
|
|
841
|
+
const img = btn.querySelector('img');
|
|
842
|
+
if (!p || !img) continue;
|
|
843
|
+
img.onerror = () => degradeThumb(btn);
|
|
844
|
+
img.src = thumbUrl(p);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
/** A stored picture that will not decode (corrupt bytes, a file removed under us). Swap the control
|
|
849
|
+
* back to a plain span: with nothing to show there is nothing to enlarge, so the "view larger"
|
|
850
|
+
* affordance has to go with it rather than opening an empty viewer. Same degrade — and the same
|
|
851
|
+
* lowercase voice — as the render preview's "preview unavailable". */
|
|
852
|
+
function degradeThumb(btn) {
|
|
853
|
+
const span = document.createElement('span');
|
|
854
|
+
span.className = 'ws-thumb ws-thumb-failed';
|
|
855
|
+
const kind = btn.querySelector('.ws-kind');
|
|
856
|
+
if (kind) span.appendChild(kind);
|
|
857
|
+
span.appendChild(document.createTextNode('thumbnail unavailable'));
|
|
858
|
+
// The decode finishes AFTER renderLanding has restored focus, so this can be pulling the very
|
|
859
|
+
// element a keyboard user is standing on out from under them — dropping them to <body> and undoing
|
|
860
|
+
// the focus carry-over the rebuild went to trouble to provide. Hand focus to the card instead: it
|
|
861
|
+
// is the nearest thing that still means "this project".
|
|
862
|
+
const hadFocus = btn.contains(document.activeElement);
|
|
863
|
+
const card = btn.closest('.ws-card');
|
|
864
|
+
btn.replaceWith(span);
|
|
865
|
+
if (hadFocus && card) card.focus({ focusVisible: true, preventScroll: true });
|
|
866
|
+
}
|
|
867
|
+
|
|
739
868
|
function renderLanding() {
|
|
740
869
|
let html = `<div class="ws-head"><div class="ws-head-text"><h2>Workspaces</h2>` +
|
|
741
870
|
`<div class="ws-sub">Live projects — open a document to keep working. No Run here.</div></div>` +
|
|
@@ -768,11 +897,11 @@
|
|
|
768
897
|
? `<span class="ws-sep"> · </span><span class="ws-meta-wf" data-tip="The workflow this project runs on:\n${escapeAttr(p.app)}">${escapeHtml(p.app)}</span>`
|
|
769
898
|
: '';
|
|
770
899
|
html += `<div class="ws-card" role="button" tabindex="0" data-open="${escapeAttr(p.id)}">` +
|
|
771
|
-
|
|
900
|
+
thumbBandHtml(p, displayApp) +
|
|
772
901
|
`<span class="ws-body"><span><span class="ws-name">${escapeHtml(p.name)}</span>` +
|
|
773
902
|
(projectCapability ? `<span class="ws-meta">${escapeHtml(projectCapability)}</span>` : '') +
|
|
774
903
|
`<span class="ws-meta ws-meta-app"><span class="ws-meta-kind">${escapeHtml(displayApp)}</span>${wfName}<span class="ws-sep"> · </span><span class="t">${escapeHtml(relAgo(p.updatedAt))}</span></span></span>` +
|
|
775
|
-
`<button type="button" class="ws-kebab" data-kebab="${escapeAttr(p.id)}" aria-label="Project actions" data-tip="Rename · Duplicate · Export · Archive">⋯</button>` +
|
|
904
|
+
`<button type="button" class="ws-kebab" data-kebab="${escapeAttr(p.id)}" aria-label="Project actions" data-tip="Rename · Thumbnail · Duplicate · Export · Archive">⋯</button>` +
|
|
776
905
|
`</span></div>`;
|
|
777
906
|
}
|
|
778
907
|
html += `</div>`;
|
|
@@ -837,6 +966,7 @@
|
|
|
837
966
|
if (keepArchivedOpen) { const d = $landing.querySelector('.ws-archived'); if (d) d.open = true; }
|
|
838
967
|
$landing.scrollTop = keepScroll;
|
|
839
968
|
if (keepFocus) $landing.querySelector(keepFocus)?.focus({ focusVisible: true, preventScroll: true });
|
|
969
|
+
paintCardThumbs();
|
|
840
970
|
tipTruncatedNames();
|
|
841
971
|
reflashCard(); // a repaint must not swallow an in-flight confirmation glow
|
|
842
972
|
}
|
|
@@ -885,7 +1015,7 @@
|
|
|
885
1015
|
// element is ACTED on by, never by DOM position: a rebuild reorders the grid (a rename re-fronts its
|
|
886
1016
|
// card), so an index would hand focus to a different project — worse than losing it. Returns null
|
|
887
1017
|
// for anything unrecognised or outside the landing, which simply means "don't restore".
|
|
888
|
-
const FOCUS_KEY_ATTRS = ['data-open', 'data-kebab', 'data-restore', 'data-delete-archived'];
|
|
1018
|
+
const FOCUS_KEY_ATTRS = ['data-open', 'data-kebab', 'data-thumb', 'data-restore', 'data-delete-archived'];
|
|
889
1019
|
function landingFocusKey(el) {
|
|
890
1020
|
if (!el || !$landing.contains(el)) return null;
|
|
891
1021
|
if (el.id) return `#${el.id}`; // #ws-import-project / #ws-retry-projects
|
|
@@ -907,6 +1037,10 @@
|
|
|
907
1037
|
$landing.addEventListener('click', async (e) => {
|
|
908
1038
|
const kebab = e.target.closest('[data-kebab]');
|
|
909
1039
|
if (kebab) { e.stopPropagation(); openProjMenu(kebab.dataset.kebab, kebab); return; }
|
|
1040
|
+
// Before the card's own [data-open] branch below, exactly like the kebab: the thumbnail is the one
|
|
1041
|
+
// region of the card that does something other than open the project.
|
|
1042
|
+
const thumb = e.target.closest('[data-thumb]');
|
|
1043
|
+
if (thumb) { e.stopPropagation(); openThumbView(thumb.dataset.thumb, thumb); return; }
|
|
910
1044
|
const restore = e.target.closest('[data-restore]');
|
|
911
1045
|
if (restore) { e.stopPropagation(); unarchiveProject(restore.dataset.restore); return; }
|
|
912
1046
|
const del = e.target.closest('[data-delete-archived]');
|
|
@@ -931,8 +1065,17 @@
|
|
|
931
1065
|
});
|
|
932
1066
|
$landing.addEventListener('keydown', (e) => {
|
|
933
1067
|
if (e.key !== 'Enter' && e.key !== ' ') return;
|
|
934
|
-
|
|
935
|
-
|
|
1068
|
+
// The CARD ITSELF must be the focused element — never merely an ancestor of it.
|
|
1069
|
+
//
|
|
1070
|
+
// `closest()` walks UP, so the old `e.target.closest('[data-open]')` also matched when focus was on
|
|
1071
|
+
// a nested button INSIDE the card: pressing Enter on the ⋯ kebab found the card above it, called
|
|
1072
|
+
// preventDefault (which suppresses the button's own synthesized click) and opened the project
|
|
1073
|
+
// instead of the menu. That is a live bug on the kebab today, and the thumbnail button below would
|
|
1074
|
+
// have doubled it — Enter on a thumbnail would have opened the project rather than the viewer.
|
|
1075
|
+
// Identity, not ancestry, is the general rule for an interactive control nested in a role=button.
|
|
1076
|
+
if (e.target !== e.target.closest('[data-open]')) return; // a nested button handles its own Enter/Space
|
|
1077
|
+
e.preventDefault();
|
|
1078
|
+
openProject(e.target.dataset.open);
|
|
936
1079
|
});
|
|
937
1080
|
|
|
938
1081
|
// Drop-a-drawing dropzone. A single hidden picker (outside $landing so an innerHTML re-render can't
|
|
@@ -948,6 +1091,10 @@
|
|
|
948
1091
|
const $importZip = document.createElement('input');
|
|
949
1092
|
$importZip.type = 'file'; $importZip.accept = '.zip,application/zip'; $importZip.hidden = true;
|
|
950
1093
|
document.body.appendChild($importZip);
|
|
1094
|
+
// Fallback picker for Add/Replace thumbnail — same reason it lives outside $landing as the two above.
|
|
1095
|
+
const $thumbFile = document.createElement('input');
|
|
1096
|
+
$thumbFile.type = 'file'; $thumbFile.accept = 'image/*'; $thumbFile.hidden = true;
|
|
1097
|
+
document.body.appendChild($thumbFile);
|
|
951
1098
|
$landing.addEventListener('dragover', (e) => {
|
|
952
1099
|
const zone = e.target.closest('[data-seed-drop]');
|
|
953
1100
|
if (!zone) return;
|
|
@@ -6611,7 +6758,18 @@
|
|
|
6611
6758
|
}
|
|
6612
6759
|
function openProjMenu(id, anchor) {
|
|
6613
6760
|
menuFor = id;
|
|
6614
|
-
|
|
6761
|
+
// The thumbnail items sit beside Rename because they are the same KIND of act — editing how the
|
|
6762
|
+
// card presents itself — where Duplicate/Export are lineage and Archive (behind the divider) is
|
|
6763
|
+
// lifecycle. "Thumbnail", not "snapshot": this app already spends that word twice (the screenshots
|
|
6764
|
+
// attached to a Tweak request, and the drawing images behind readFileAsSnapshot), and a third
|
|
6765
|
+
// meaning for "the little picture on a card" is the kind of overload the rest of this codebase
|
|
6766
|
+
// works to avoid. Add/Replace are ONE action under two labels — it always means "pick a picture and
|
|
6767
|
+
// store it" — and Remove is simply ABSENT when there is nothing to remove, never present-but-disabled.
|
|
6768
|
+
const menuProj = projects.find((p) => p.id === id);
|
|
6769
|
+
const hasThumb = !!(menuProj && menuProj.thumbnailTag);
|
|
6770
|
+
const thumbItems = menuItem('thumbnail', hasThumb ? 'Replace thumbnail…' : 'Add thumbnail…')
|
|
6771
|
+
+ (hasThumb ? menuItem('remove-thumbnail', 'Remove thumbnail') : '');
|
|
6772
|
+
$projMenu.innerHTML = menuItem('rename', 'Rename…') + thumbItems + menuItem('duplicate', 'Duplicate') +
|
|
6615
6773
|
menuItem('export', 'Export…') +
|
|
6616
6774
|
'<div class="menu-divider"></div>' + menuItem('archive', 'Archive');
|
|
6617
6775
|
// NO "Convert to the 3D model…" ITEM HERE, and its absence is a decision rather than an oversight.
|
|
@@ -6627,10 +6785,20 @@
|
|
|
6627
6785
|
// `migReady` can actually be true. Until then the Model-step banner carries discovery, and shipping
|
|
6628
6786
|
// a branch with a comment describing behaviour that never happens is worse than shipping neither.
|
|
6629
6787
|
const r = anchor.getBoundingClientRect();
|
|
6630
|
-
|
|
6631
|
-
|
|
6788
|
+
// 288 = the menu's actual 280px width (.menu in app.css) + an 8px margin. It read 260 — an
|
|
6789
|
+
// off-by-20 that let the menu overhang the right edge for a card in the last column.
|
|
6790
|
+
$projMenu.style.left = Math.round(Math.max(8, Math.min(r.left, window.innerWidth - 288))) + 'px';
|
|
6632
6791
|
$projMenu.hidden = false;
|
|
6633
6792
|
$projMenu.classList.add('show');
|
|
6793
|
+
// Flip above the ⋯ when there isn't room below. The menu is only ever positioned from the anchor's
|
|
6794
|
+
// BOTTOM, which was already tight for a card in the last visible row and is one to two rows tighter
|
|
6795
|
+
// now the thumbnail items are in it — without this, Archive lands past the bottom of the window and
|
|
6796
|
+
// cannot be reached. Measured after showing, because a hidden element has no height.
|
|
6797
|
+
const below = r.bottom + 6;
|
|
6798
|
+
const height = $projMenu.offsetHeight;
|
|
6799
|
+
$projMenu.style.top = Math.round(
|
|
6800
|
+
below + height <= window.innerHeight - 8 ? below : Math.max(8, r.top - 6 - height),
|
|
6801
|
+
) + 'px';
|
|
6634
6802
|
}
|
|
6635
6803
|
document.addEventListener('click', (e) => {
|
|
6636
6804
|
if ($projMenu.hidden) return;
|
|
@@ -6644,6 +6812,10 @@
|
|
|
6644
6812
|
// Export is read-only — keep it out of the rename/duplicate/archive busy-lock (and its
|
|
6645
6813
|
// trailing loadProjects reconcile), so it can run alongside them without contention.
|
|
6646
6814
|
if (act.dataset.act === 'export') { exportProject(id); return; }
|
|
6815
|
+
// The PICKER runs outside the busy-lock, the write inside it: an OS file dialog can sit open for as
|
|
6816
|
+
// long as the user likes, and holding the lock across it would wedge every other project action
|
|
6817
|
+
// behind a dialog nobody can see from here. (Rename's prompt is an in-app modal, so it can hold it.)
|
|
6818
|
+
if (act.dataset.act === 'thumbnail') { chooseThumbnail(id); return; }
|
|
6647
6819
|
doProjectAction(act.dataset.act, id);
|
|
6648
6820
|
});
|
|
6649
6821
|
|
|
@@ -6704,6 +6876,71 @@
|
|
|
6704
6876
|
// project whose copy is still in flight) — a re-entry while one is in flight is toasted, not
|
|
6705
6877
|
// silently dropped, so the user knows why the second click did nothing.
|
|
6706
6878
|
let projActionBusy = false;
|
|
6879
|
+
|
|
6880
|
+
/** Replace a project in the local grid and re-front it, then glow the card so the change is visible
|
|
6881
|
+
* WITH the toast rather than seconds later when loadProjects() reconciles. `oldId` differs only for
|
|
6882
|
+
* a rename, which mints a new id — every other action keeps it. Every one of these actions bumps
|
|
6883
|
+
* `updatedAt` server-side, so the reconcile puts the card at the front anyway; doing it now is what
|
|
6884
|
+
* turns a delayed jump into an immediate confirmation. */
|
|
6885
|
+
function frontProject(project, oldId = project.id) {
|
|
6886
|
+
const i = projects.findIndex((p) => p.id === oldId);
|
|
6887
|
+
if (i >= 0) projects.splice(i, 1);
|
|
6888
|
+
projects.unshift(project);
|
|
6889
|
+
renderLanding();
|
|
6890
|
+
flashCard(project.id, { scroll: true });
|
|
6891
|
+
}
|
|
6892
|
+
|
|
6893
|
+
/**
|
|
6894
|
+
* Add or replace a project's thumbnail: pick, downscale, upload.
|
|
6895
|
+
*
|
|
6896
|
+
* Split from `doProjectAction` so the OS picker runs before the busy-lock is taken (see the call
|
|
6897
|
+
* site). The card is not touched until the server has confirmed the write — a cancelled pick, an
|
|
6898
|
+
* undecodable file or a refused upload all leave it exactly as it was.
|
|
6899
|
+
*/
|
|
6900
|
+
async function chooseThumbnail(id) {
|
|
6901
|
+
let file;
|
|
6902
|
+
try { file = await pickImageFile($thumbFile); }
|
|
6903
|
+
catch { showToast('Couldn’t open the file picker', 'warn'); return; }
|
|
6904
|
+
if (!file) return; // cancelled
|
|
6905
|
+
if (file.type && !file.type.startsWith('image/')) {
|
|
6906
|
+
showToast('That doesn’t look like an image — pick a PNG, JPG or WebP.', 'warn');
|
|
6907
|
+
return;
|
|
6908
|
+
}
|
|
6909
|
+
if (projActionBusy) { showToast('Hold on — finishing the last action…', 'warn'); return; }
|
|
6910
|
+
projActionBusy = true;
|
|
6911
|
+
// The menu already distinguishes Add from Replace; the toasts have to say the same thing back.
|
|
6912
|
+
// "Thumbnail added ✓" against a card that now shows a DIFFERENT picture reads as "a second one
|
|
6913
|
+
// exists" — precisely the ambiguity the two menu labels were written to remove.
|
|
6914
|
+
const replacing = !!projects.find((p) => p.id === id)?.thumbnailTag;
|
|
6915
|
+
try {
|
|
6916
|
+
showToast(replacing ? 'Replacing thumbnail…' : 'Adding thumbnail…', 'ok');
|
|
6917
|
+
let blob;
|
|
6918
|
+
try { blob = await encodeThumbnail(file); }
|
|
6919
|
+
catch (err) {
|
|
6920
|
+
showToast(err && err.message === 'too-large'
|
|
6921
|
+
? 'That image file is too large to use as a thumbnail — pick one under 64 MB.'
|
|
6922
|
+
: 'Couldn’t read that image — try a PNG, JPG or WebP.', 'warn');
|
|
6923
|
+
return;
|
|
6924
|
+
}
|
|
6925
|
+
if (blob.size > MAX_THUMB_BYTES) {
|
|
6926
|
+
showToast('That image is too large — thumbnails are capped at 8 MB.', 'warn');
|
|
6927
|
+
return;
|
|
6928
|
+
}
|
|
6929
|
+
// The blob's own type, not the one we asked for: toBlob falls back to PNG where WebP cannot be
|
|
6930
|
+
// written. It only selects the server's body parser — the stored format comes from the bytes.
|
|
6931
|
+
const type = ['image/webp', 'image/png', 'image/jpeg'].includes(blob.type) ? blob.type : 'image/png';
|
|
6932
|
+
const { project } = await api(`/api/projects/${encodeURIComponent(id)}/thumbnail`, {
|
|
6933
|
+
method: 'PUT', headers: { 'content-type': type }, body: blob,
|
|
6934
|
+
});
|
|
6935
|
+
frontProject(project);
|
|
6936
|
+
showToast(replacing ? 'Thumbnail replaced ✓' : 'Thumbnail added ✓', 'ok');
|
|
6937
|
+
track('workspace_project_thumbnail_set', { app: project.app, replaced: replacing });
|
|
6938
|
+
} catch (err) {
|
|
6939
|
+
showToast('Couldn’t save that thumbnail: ' + ((err && err.message) || err), 'warn');
|
|
6940
|
+
} finally { projActionBusy = false; }
|
|
6941
|
+
loadProjects(); // background reconcile, mirroring rename/duplicate/archive
|
|
6942
|
+
}
|
|
6943
|
+
|
|
6707
6944
|
async function doProjectAction(action, id) {
|
|
6708
6945
|
if (projActionBusy) { showToast('Hold on — finishing the last action…', 'warn'); return; }
|
|
6709
6946
|
projActionBusy = true;
|
|
@@ -6718,11 +6955,7 @@
|
|
|
6718
6955
|
// BY THE OLD id and re-front the card — once, with the flash, rather than as a jump a second later
|
|
6719
6956
|
// when loadProjects() reconciles. The unshift must land before any openProject(newId) below so it
|
|
6720
6957
|
// can find the project in `projects`.
|
|
6721
|
-
|
|
6722
|
-
if (i >= 0) projects.splice(i, 1);
|
|
6723
|
-
projects.unshift(project);
|
|
6724
|
-
renderLanding();
|
|
6725
|
-
flashCard(project.id, { scroll: true });
|
|
6958
|
+
frontProject(project, id);
|
|
6726
6959
|
// If the renamed project was the OPEN one, its editor iframes still carry ?project=<old id> —
|
|
6727
6960
|
// re-open so they re-src to the new id (a stale id 404s the next contract read/write/autosave).
|
|
6728
6961
|
if (wasCurrent) await openProject(project.id);
|
|
@@ -6733,6 +6966,14 @@
|
|
|
6733
6966
|
renderLanding();
|
|
6734
6967
|
flashCard(project.id, { scroll: true });
|
|
6735
6968
|
showToast(`Duplicated as "${project.name}"`, 'ok');
|
|
6969
|
+
} else if (action === 'remove-thumbnail') {
|
|
6970
|
+
// No confirm, deliberately. A thumbnail is decorative metadata with nothing downstream of it
|
|
6971
|
+
// and is one menu item away from being re-added — unlike the archived-project Delete, which
|
|
6972
|
+
// erases a contract and its whole ledger and therefore earns a danger dialog. Graduating the
|
|
6973
|
+
// ceremony to the consequence is the rule this app already follows.
|
|
6974
|
+
const { project } = await api(`/api/projects/${encodeURIComponent(id)}/thumbnail`, { method: 'DELETE' });
|
|
6975
|
+
frontProject(project);
|
|
6976
|
+
showToast('Thumbnail removed', 'ok');
|
|
6736
6977
|
} else if (action === 'archive') {
|
|
6737
6978
|
await api(`/api/projects/${encodeURIComponent(id)}/archive`, { method: 'POST', body: '{}' });
|
|
6738
6979
|
projects = projects.filter((p) => p.id !== id); // drop the card now, don't wait for the reload
|
|
@@ -6745,6 +6986,79 @@
|
|
|
6745
6986
|
loadProjects();
|
|
6746
6987
|
}
|
|
6747
6988
|
|
|
6989
|
+
// ── Thumbnail viewer (the enlarge overlay) ─────────────────────────────────────────────────────
|
|
6990
|
+
// Reuses the app's .modal-backdrop/.modal shell and the shared onBackdropDismiss (app.js), so it
|
|
6991
|
+
// closes the three ways every other dialog here does: Esc, the ×, and a click on the backdrop.
|
|
6992
|
+
const $thumbModal = document.getElementById('ws-thumb-modal');
|
|
6993
|
+
const $thumbTitle = document.getElementById('ws-thumb-title');
|
|
6994
|
+
const $thumbFull = document.getElementById('ws-thumb-full');
|
|
6995
|
+
const $thumbClose = document.getElementById('ws-thumb-close');
|
|
6996
|
+
let thumbReturnFocus = null;
|
|
6997
|
+
|
|
6998
|
+
function openThumbView(id, anchor) {
|
|
6999
|
+
const p = projects.find((x) => x.id === id);
|
|
7000
|
+
if (!p || !p.thumbnailTag || !$thumbModal) return;
|
|
7001
|
+
thumbReturnFocus = anchor || document.activeElement;
|
|
7002
|
+
$thumbTitle.textContent = p.name;
|
|
7003
|
+
// A real alt, not "": in here the picture IS the content, and a screen reader that lands on it
|
|
7004
|
+
// should hear what it is rather than skip it.
|
|
7005
|
+
$thumbFull.alt = `Thumbnail of “${p.name}”`;
|
|
7006
|
+
$thumbFull.src = thumbUrl(p);
|
|
7007
|
+
$thumbModal.classList.add('show');
|
|
7008
|
+
$thumbClose.focus({ preventScroll: true });
|
|
7009
|
+
}
|
|
7010
|
+
|
|
7011
|
+
function closeThumbView() {
|
|
7012
|
+
if (!$thumbModal || !$thumbModal.classList.contains('show')) return;
|
|
7013
|
+
$thumbModal.classList.remove('show');
|
|
7014
|
+
$thumbFull.removeAttribute('src'); // let the decoded bytes go; the next open re-reads from cache
|
|
7015
|
+
const back = thumbReturnFocus;
|
|
7016
|
+
thumbReturnFocus = null;
|
|
7017
|
+
if (back && back.isConnected) back.focus({ focusVisible: true, preventScroll: true });
|
|
7018
|
+
}
|
|
7019
|
+
|
|
7020
|
+
if ($thumbModal) {
|
|
7021
|
+
$thumbClose.addEventListener('click', closeThumbView);
|
|
7022
|
+
// The backdrop dismiss must ignore the SECOND click of a double-click. The viewer opens on the
|
|
7023
|
+
// FIRST click, so by the time the second lands the backdrop is already under the cursor — without
|
|
7024
|
+
// this a double-click (the gesture this feature was asked for) would enlarge and instantly close.
|
|
7025
|
+
//
|
|
7026
|
+
// Keyed on `MouseEvent.detail`, the click COUNT, not on elapsed time. A 400 ms window was the first
|
|
7027
|
+
// cut and it was wrong in both directions: Windows' double-click threshold is user-configurable up
|
|
7028
|
+
// to ~900 ms, so a slow double-click still closed the viewer, while a deliberate backdrop click
|
|
7029
|
+
// inside the window was swallowed. `detail > 1` says "this is the 2nd+ click of one sequence"
|
|
7030
|
+
// exactly, with no threshold to be wrong about.
|
|
7031
|
+
let thumbDownDetail = 1;
|
|
7032
|
+
$thumbModal.addEventListener('mousedown', (e) => { thumbDownDetail = e.detail; });
|
|
7033
|
+
onBackdropDismiss($thumbModal, closeThumbView, () => thumbDownDetail <= 1);
|
|
7034
|
+
// Keep focus INSIDE the dialog. A mousedown on the backdrop or the picture blurs whatever was
|
|
7035
|
+
// focused to <body> — which is what the second click of a double-click does, and the E2E caught it:
|
|
7036
|
+
// the viewer stayed open with focus outside itself, so Tab walked into the page behind. Repaired
|
|
7037
|
+
// after the click rather than by preventing the mousedown, because that also killed selecting the
|
|
7038
|
+
// project name and dragging the picture; and only for the two regions that hold no selectable
|
|
7039
|
+
// content, so a text drag on the title is left alone.
|
|
7040
|
+
$thumbModal.addEventListener('click', (e) => {
|
|
7041
|
+
if (!$thumbModal.classList.contains('show')) return; // it dismissed — nothing to hold
|
|
7042
|
+
if ($thumbModal.contains(document.activeElement)) return; // focus never left
|
|
7043
|
+
if (e.target !== $thumbModal && e.target !== $thumbFull) return;
|
|
7044
|
+
$thumbClose.focus({ preventScroll: true });
|
|
7045
|
+
});
|
|
7046
|
+
// Esc on DOCUMENT, in the CAPTURE phase, not on the dialog — for two reasons. The dialog only sees
|
|
7047
|
+
// a keydown while focus is inside it, which the blur above had already broken; and while an
|
|
7048
|
+
// aria-modal dialog is up, Esc belongs to it before any other handler on the page gets a look.
|
|
7049
|
+
document.addEventListener('keydown', (e) => {
|
|
7050
|
+
if (e.key !== 'Escape' || !$thumbModal.classList.contains('show')) return;
|
|
7051
|
+
e.preventDefault();
|
|
7052
|
+
e.stopPropagation();
|
|
7053
|
+
closeThumbView();
|
|
7054
|
+
}, true);
|
|
7055
|
+
$thumbModal.addEventListener('keydown', (e) => {
|
|
7056
|
+
// The dialog holds exactly one control, so the trap is simply "stay on it" — Tab must not walk
|
|
7057
|
+
// out into the page behind an aria-modal dialog.
|
|
7058
|
+
if (e.key === 'Tab') { e.preventDefault(); $thumbClose.focus(); }
|
|
7059
|
+
});
|
|
7060
|
+
}
|
|
7061
|
+
|
|
6748
7062
|
// Export a project as a portable .zip (back it up / move it to another machine). Fetch → Blob →
|
|
6749
7063
|
// download anchor so a server error surfaces as a toast (not a broken download) and success is
|
|
6750
7064
|
// confirmed. ponytail: the whole zip lands in memory here — fine for desktop-scale projects.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floless/app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.119.0",
|
|
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": {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"verify:flo": "node build/verify-flo-descriptions.mjs",
|
|
30
30
|
"verify:flo-naming": "node build/verify-flo-naming.mjs",
|
|
31
31
|
"verify:no-title": "node build/verify-no-title.mjs",
|
|
32
|
+
"verify:no-native-select": "node build/verify-no-native-select.mjs",
|
|
32
33
|
"verify:display-sync": "node build/verify-display-sync.mjs",
|
|
33
34
|
"verify:view-modes": "node build/verify-view-modes.mjs",
|
|
34
35
|
"verify:gateway": "node build/verify-contract-gateway.mjs",
|
|
@@ -36,7 +37,8 @@
|
|
|
36
37
|
"verify:boundary": "node build/verify-model-boundary.mjs",
|
|
37
38
|
"verify:change-reasons": "node build/verify-change-reasons.mjs",
|
|
38
39
|
"typecheck": "tsc --noEmit",
|
|
39
|
-
"prepack": "npm run build"
|
|
40
|
+
"prepack": "npm run build",
|
|
41
|
+
"verify:skill-scripts": "node build/verify-skill-scripts.mjs"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
44
|
"@fastify/static": "^8.0.0",
|