@floless/app 0.150.0 → 0.151.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.
@@ -520,15 +520,18 @@
520
520
  });
521
521
  }
522
522
 
523
- async function pickTeklaZip(fallbackInput) {
524
- const file = await pickZipFile(fallbackInput);
525
- if (!file) return null;
523
+ // One ZIP of a Tekla model as a source — shared by the ZIP picker and a ZIP dropped on the card.
524
+ function teklaZipSource(file) {
526
525
  if (!/\.zip$/i.test(file.name) || file.size > 1024 * 1024 * 1024) throw new Error('Choose one Tekla model ZIP up to 1 GB.');
527
526
  return { label: file.name, kind: 'zip', entries: [{ path: file.name, file }] };
528
527
  }
528
+ async function pickTeklaZip(fallbackInput) {
529
+ const file = await pickZipFile(fallbackInput);
530
+ return file ? teklaZipSource(file) : null;
531
+ }
529
532
 
530
533
  // Single-image picker for Add/Replace thumbnail — same File System Access preference + hidden-input
531
- // fallback as the two above. Returns null on cancel; never throws.
534
+ // fallback as pickDrawingFiles and pickZipFile. Returns null on cancel; rethrows anything but a cancel.
532
535
  const THUMB_FILE_TYPES = [{
533
536
  description: 'Image',
534
537
  accept: { 'image/*': ['.png', '.jpg', '.jpeg', '.webp', '.gif', '.bmp'] },
@@ -671,8 +674,8 @@
671
674
 
672
675
  const LS_MODE = 'floless:mode';
673
676
  // Per-app Workspaces presentation. The flag (floless.workspace, surfaced on /api/apps) says WHICH
674
- // apps are workspaces; this map says HOW to render each (presentation is ours — spec §3.2). Two
675
- // first-party apps today; promote to a .flo-declared descriptor when a user-authored one appears.
677
+ // apps are workspaces; this map says HOW to render each (presentation is ours — spec §3.2). All
678
+ // first-party today; promote to a .flo-declared descriptor when a user-authored one appears.
676
679
  // NB: both apps keep the SAME data-step keys (drawings/model/exports/history) so setStep() and the
677
680
  // frame slots are unchanged — only the first two LABELS and which HTML each frame loads differ.
678
681
  //
@@ -680,8 +683,17 @@
680
683
  // "✓ exported HH:MM" line + ⧉ Open / ▤ Reveal); `open:false` (IFC) = reveal-only (no OS default app
681
684
  // for a .ifc). Tekla is an ACTION (host mutation, no file). `kind` matches the server's export route
682
685
  // + listing (projectExportFiles). renderExports()/exportUrl() read wsApp().exports — never a global.
686
+ //
687
+ // `cardIcon`: the create card's mark — the INNER markup of a 24×24 outline drawing, which
688
+ // workspaceCreateCardHtml wraps in an <svg> and inserts unescaped (authored here, never user data).
689
+ // Each one says what the card makes, never whose product it reads: no vendor logo for Revit/Tekla.
690
+ // On a create action, `dropHint` is the line telling the person the card also takes a dropped file
691
+ // (shown only for a kind workspaceCreateCardHtml treats as a dropzone); `dropWarn` is what a READY
692
+ // card that takes no file says when one is dropped on it. Locked and setting-up cards answer with
693
+ // their own sentence instead (cardDropWarning).
683
694
  const WORKSPACE_APPS = {
684
695
  'steel-model': {
696
+ cardIcon: '<path d="M3 8.5h10v3H9.5v6H13v3H3v-3h3.5v-6H3z"/><path d="M3 8.5 11 3.5h10l-8 5"/><path d="M21 3.5v3l-8 5"/><path d="M17.5 8.7v3.8"/><path d="M9.5 17.5l8-5H21l-8 5"/><path d="M21 12.5v3l-8 5"/>', // a 3D I-beam
685
697
  displayName: 'Steel model',
686
698
  projectCapability: 'review, detail, export',
687
699
  createActions: [
@@ -691,6 +703,7 @@
691
703
  capability: 'PDF or image → 3D steel model',
692
704
  sub: 'Turn steel drawings into a 3D model you can review and export.',
693
705
  label: 'Pick drawings',
706
+ dropHint: 'Click or drop drawings',
694
707
  },
695
708
  ],
696
709
  editor: '/steel-editor.html',
@@ -729,6 +742,7 @@
729
742
  ],
730
743
  },
731
744
  vectorize: {
745
+ cardIcon: '<path d="M5 16C8 6 16 6 19 16"/><rect x="3.25" y="16" width="3.5" height="3.5" rx=".5"/><rect x="17.25" y="16" width="3.5" height="3.5" rx=".5"/><rect x="10.5" y="7" width="3" height="3" rx=".5"/><path d="M6.5 8.5h4M13.5 8.5h4"/><circle cx="5" cy="8.5" r="1.5"/><circle cx="19" cy="8.5" r="1.5"/>', // a curve with anchors and handles
732
746
  displayName: 'Trace',
733
747
  projectCapability: 'editable 2D drawing',
734
748
  docGuide: true,
@@ -739,6 +753,7 @@
739
753
  capability: 'Drawing → editable shapes',
740
754
  sub: 'Turn one drawing into editable lines and shapes.',
741
755
  label: 'Pick drawing',
756
+ dropHint: 'Click or drop a drawing',
742
757
  },
743
758
  ],
744
759
  editor: '/vector-editor.html',
@@ -760,7 +775,7 @@
760
775
  // participates in first-paint fallback: /api/apps must positively report the canonical
761
776
  // installer-owned workflow plus its coarse access state before this card appears.
762
777
  serverAuthorizedOnly: true,
763
- cardIcon: 'R',
778
+ cardIcon: '<path d="M12 3 20 7 12 11 4 7z"/><path d="M4 7v10l8 4 8-4V7"/><path d="M12 11v10"/><path d="M4 10.3l8 4 8-4M4 13.7l8 4 8-4"/>', // a building model, floor by floor
764
779
  displayName: 'Revit Parser',
765
780
  projectCapability: 'read-only 3D model',
766
781
  readOnlyLabel: 'Read-only',
@@ -770,6 +785,7 @@
770
785
  capability: 'Read-only 3D model',
771
786
  sub: 'Open an RVT without Revit. Inspect its hierarchy and properties—the source RVT is never changed.',
772
787
  label: 'Choose RVT for Revit Parser',
788
+ dropHint: 'Click or drop an .rvt',
773
789
  }],
774
790
  editor: '/revit-editor.html',
775
791
  filter: null,
@@ -786,7 +802,7 @@
786
802
  // Tekla is a family entitlement; this descriptor names only the read-only parser module so
787
803
  // future Tekla modules can have their own workflows and product language.
788
804
  serverAuthorizedOnly: true,
789
- cardIcon: 'T',
805
+ cardIcon: '<path d="M5 20V4M19 20V4M5 4h14M5 12h14"/><path d="M5 12l14 8M19 12 5 20"/><path d="M3 20h4M17 20h4"/>', // a braced steel frame
790
806
  displayName: 'Tekla Parser',
791
807
  projectCapability: 'read-only 3D model',
792
808
  readOnlyLabel: 'Read-only',
@@ -794,8 +810,9 @@
794
810
  kind: 'tekla-source',
795
811
  headline: 'Tekla Parser',
796
812
  capability: 'Read-only 3D model',
797
- sub: 'Open a Tekla model folder or ZIP as a reviewable 3D model. Inspect its hierarchy and properties—the source model is never changed.',
813
+ sub: 'Open a Tekla model as a reviewable 3D model. Inspect its hierarchy and properties—the source model is never changed.',
798
814
  label: 'Choose Tekla model…',
815
+ dropHint: 'Click or drop a folder or .zip',
799
816
  }],
800
817
  editor: '/tekla-editor.html',
801
818
  filter: null,
@@ -849,7 +866,7 @@
849
866
  // it opens straight into its own editor frame, never the read-only source chrome. Every branch
850
867
  // that means "Revit or Tekla" therefore says so (isModelSourceProject), not serverAuthorizedOnly.
851
868
  serverAuthorizedOnly: true,
852
- cardIcon: 'D', // R = Revit, T = Tekla, D = Drawing Checker
869
+ cardIcon: '<rect x="2.5" y="4.5" width="19" height="15" rx="1.5"/><path d="M15 19.5v-4h6.5"/><path d="m6.5 11 2.5 2.5 5-5"/>', // a drawing sheet, checked
853
870
  displayName: 'Drawing Checker',
854
871
  projectCapability: 'checks shop drawings',
855
872
  createActions: [{
@@ -858,6 +875,8 @@
858
875
  capability: 'Checks shop drawings',
859
876
  sub: 'Make a profile for one client from drawings you already trust.',
860
877
  label: 'New client profile…',
878
+ // Takes no file, but a file dropped on it still gets an answer rather than nothing.
879
+ dropWarn: 'Drawing Checker starts from a client profile, not a file, so nothing was uploaded. Click the card to make the profile, then add reference drawings on its page.',
861
880
  }],
862
881
  editor: '/drawing-check-editor.html',
863
882
  filter: null,
@@ -2109,8 +2128,8 @@
2109
2128
  function workspaceCreateEntries(entries) {
2110
2129
  // Create affordances stay docked at the top, separate from existing projects. Cards come out in
2111
2130
  // descriptor order, per workflow. (A sort used to push the kind:'current' card last because it
2112
- // started from a different mode; that card is gone — #625 — and every remaining action starts
2113
- // from a drawing, so declaration order IS the intended order.)
2131
+ // started from a different mode; that card is gone — #625 — so declaration order IS the intended
2132
+ // order.)
2114
2133
  return entries.flatMap((entry) => {
2115
2134
  const d = WORKSPACE_APPS[entry.templateId];
2116
2135
  const actions = d && Array.isArray(d.createActions) ? d.createActions : [];
@@ -2120,6 +2139,9 @@
2120
2139
 
2121
2140
  function workspaceCreateCardHtml(entry, action) {
2122
2141
  const descriptor = WORKSPACE_APPS[entry.templateId];
2142
+ // The descriptor's own drawing when it has one (see `cardIcon` on WORKSPACE_APPS), else `fallback`.
2143
+ const seedIcon = (fallback) => `<span class="ws-seed-icon" aria-hidden="true">${descriptor?.cardIcon
2144
+ ? `<svg viewBox="0 0 24 24" focusable="false">${descriptor.cardIcon}</svg>` : fallback}</span>`;
2123
2145
  if (entry.missing === true) {
2124
2146
  const descriptionId = `ws-${entry.templateId}-missing`;
2125
2147
  const buttonStart = entry.templateId === 'vectorize'
@@ -2127,7 +2149,8 @@
2127
2149
  : `<button type="button" class="ws-seed ws-seed-remedy" data-command-id="shell.project-steel-missing-workflow" `;
2128
2150
  return buttonStart +
2129
2151
  `aria-label="${escapeAttr(`${action.headline} needs setup — why unavailable`)}" aria-describedby="${escapeAttr(descriptionId)}" ` +
2130
- `data-seed-app="${escapeAttr(entry.appId)}" data-seed-template="${escapeAttr(entry.templateId)}" data-seed-action="${escapeAttr(action.kind)}">` +
2152
+ `data-seed-app="${escapeAttr(entry.appId)}" data-seed-template="${escapeAttr(entry.templateId)}" data-seed-action="${escapeAttr(action.kind)}" ` +
2153
+ `data-drop-warn="${escapeAttr(`Nothing was opened. ${missingWorkspaceWorkflowMessage(entry.templateId)}`)}">` +
2131
2154
  `<span class="ws-seed-icon" aria-hidden="true">!</span>` +
2132
2155
  `<span class="ws-seed-headline">${escapeHtml(action.headline)}</span>` +
2133
2156
  `<span class="ws-seed-capability ws-seed-state">Needs setup</span>` +
@@ -2195,7 +2218,7 @@
2195
2218
  : entry.templateId === 'drawing-check'
2196
2219
  ? `${drawingCheckCommand} data-module-remedy="drawing-check" data-module-remedy-state="${remedyState}"`
2197
2220
  : `${teklaCommand} data-module-remedy="tekla-parser" data-module-remedy-state="${remedyState}"` : '') + `>` +
2198
- `<span class="ws-seed-icon" aria-hidden="true">${escapeHtml(descriptor.cardIcon || '!')}</span>` +
2221
+ seedIcon('!') +
2199
2222
  `<span class="ws-seed-headline">${escapeHtml(descriptor.displayName)}</span>` +
2200
2223
  (descriptor.readOnlyLabel ? `<span class="ws-seed-readonly">${escapeHtml(descriptor.readOnlyLabel)}</span>` : '') +
2201
2224
  `<span class="ws-seed-capability ws-seed-state">${escapeHtml(state.status)}</span>` +
@@ -2203,8 +2226,9 @@
2203
2226
  (state.action ? `<span class="ws-seed-action">${escapeHtml(state.action)} →</span>` : '') +
2204
2227
  `</${actionable ? 'button' : 'div'}>`;
2205
2228
  }
2206
- const acceptsDrop = action.kind === 'drawing' || action.kind === 'rvt';
2229
+ const acceptsDrop = action.kind === 'drawing' || action.kind === 'rvt' || action.kind === 'tekla-source';
2207
2230
  const createCommand = action.kind === 'tekla-source' ? 'data-command-id="shell.project-create-tekla-read" '
2231
+ : action.kind === 'rvt' ? 'data-command-id="shell.project-create-revit-read" '
2208
2232
  : action.kind === 'drawing-check-profile' ? 'data-command-id="shell.project-create-drawing-check-profile" '
2209
2233
  : action.kind !== 'drawing' ? ''
2210
2234
  : entry.templateId === 'steel-model' ? 'data-command-id="shell.project-create-steel-from-drawings" '
@@ -2220,13 +2244,17 @@
2220
2244
  createCommand +
2221
2245
  (action.tip ? `data-tip="${escapeAttr(action.tip)}" ` : '') +
2222
2246
  `data-seed-app="${escapeAttr(entry.appId)}" data-seed-template="${escapeAttr(entry.templateId)}" data-seed-action="${escapeAttr(action.kind)}"` +
2223
- (acceptsDrop ? ` data-seed-drop="${escapeAttr(entry.appId)}" data-seed-drop-kind="${escapeAttr(action.kind)}"` : '') +
2247
+ (acceptsDrop ? ` data-seed-drop="${escapeAttr(entry.appId)}" data-seed-drop-kind="${escapeAttr(action.kind)}"`
2248
+ : ` data-drop-warn="${escapeAttr(action.dropWarn || `Nothing was opened. ${action.headline} doesn’t take a dropped file; click the card to start.`)}"`) +
2224
2249
  `>` +
2225
- `<span class="ws-seed-icon" aria-hidden="true">${escapeHtml(descriptor?.cardIcon || '+')}</span>` +
2250
+ seedIcon('+') +
2226
2251
  `<span class="ws-seed-headline">${escapeHtml(action.headline)}</span>` +
2227
2252
  (descriptor?.readOnlyLabel ? `<span class="ws-seed-readonly">${escapeHtml(descriptor.readOnlyLabel)}</span>` : '') +
2228
2253
  (action.capability ? `<span class="ws-seed-capability">${escapeHtml(action.capability)}</span>` : '') +
2229
2254
  `<span class="ws-seed-sub">${escapeHtml(action.sub)}</span>` +
2255
+ // Kept out of the accessible name (aria-hidden for good measure): the aria-label names the
2256
+ // click route, which everyone has; "or drop" names a pointer-only one.
2257
+ (acceptsDrop && action.dropHint ? `<span class="ws-seed-hint" aria-hidden="true">${escapeHtml(action.dropHint)}</span>` : '') +
2230
2258
  (target
2231
2259
  ? `<span class="ws-seed-target" data-tip="You have more than one of these workflows installed.\nThis card creates on:\n${escapeAttr(target)}">On ${escapeHtml(target)}</span>`
2232
2260
  : '') +
@@ -2370,29 +2398,16 @@
2370
2398
  + (guess ? `${escapeHtml(guess)} ` : 'FloLess could not read the Workspace directory. ')
2371
2399
  + ` <button type="button" id="ws-retry-projects">↻ Try again</button></div>`;
2372
2400
  } else {
2373
- // First-run onboarding (#598). Workflows mode greets a newcomer with a real card and a route
2374
- // into the guided tour; landing HERE first (a direct link, or Workflows already has apps
2375
- // installed so its card never shows) used to be one dim line and no route at all.
2376
- //
2377
- // Deliberately NOT the Workflows card's shape. The create cards are already on screen right
2378
- // above this, and they are the actual first action — a second bordered, accent-filled "start
2379
- // here" panel under them would put two accent affordances in a staring contest and invert the
2380
- // hierarchy. So: the same plain note, one added sentence, and the tour as a QUIET text link
2381
- // (the .onb-build-btn tier, never the filled .onb-tour-btn one).
2382
- //
2383
- // The added sentence says what a project IS, because that is the one thing a newcomer here
2384
- // cannot infer — not "no Run here", which .ws-sub already states unconditionally two lines up.
2401
+ // First-run onboarding (#598, #2046). The create cards above are the actual first action, so the way to the
2402
+ // Guide is a QUIET text link (the .onb-build-btn tier, never the filled .onb-tour-btn one), and the added
2403
+ // sentence says what a project IS — the one thing a newcomer here cannot infer.
2385
2404
  const note = 'No projects yet — start one from the cards above, or Import project to restore an exported .zip.';
2386
2405
  const what = 'A project is an approved, running copy of a workflow app — you open it like a document and keep working. Building or changing the app itself happens in Workflows mode.';
2387
2406
  html += `<div class="ws-empty-note">${escapeHtml(note)} ${escapeHtml(what)}${archived.length ? ' You have archived projects below.' : ''}`
2388
- // Same prompt, same aria wording as the Workflows card — a screen-reader user who meets both
2389
- // entry points should hear one action, not two. The id is what carries focus across a
2390
- // repaint (landingFocusKey keys on it).
2407
+ // The same Guide as the Workflows card. The id is what carries focus across a repaint (landingFocusKey keys on it).
2391
2408
  + `<div class="ws-empty-tour">New here? `
2392
- + `<button type="button" id="ws-onb-tour" class="ws-empty-tour-btn" `
2393
- + `aria-label="Start the guided tour — copies the onboarding prompt to your clipboard" `
2394
- + `data-tip="Copies a prompt — paste it into Claude Code or Codex">Start the guided tour →</button>`
2395
- + `<span class="sr-only ws-empty-tour-live" aria-live="polite"></span>`
2409
+ + `<button type="button" id="ws-onb-tour" class="ws-empty-tour-btn" data-command-id="shell.ask-guide#the Workspaces page" `
2410
+ + `data-tip="Ask the Guide in AI Chat to look at your setup and suggest what to do first.">Ask the Guide →</button>`
2396
2411
  + `</div></div>`;
2397
2412
  }
2398
2413
  }
@@ -2449,7 +2464,7 @@
2449
2464
  tipTruncatedNames();
2450
2465
  // The first-run tour link, when the empty state rendered one. app.js owns the copy behaviour so
2451
2466
  // both entry points to the tour stay identical; a no-op when the button isn't on screen.
2452
- wireTourCopy($landing.querySelector('#ws-onb-tour'));
2467
+ wireAskGuide($landing.querySelector('#ws-onb-tour'));
2453
2468
  reflashCard(); // a repaint must not swallow an in-flight confirmation glow
2454
2469
  }
2455
2470
 
@@ -2789,9 +2804,8 @@
2789
2804
  const appId = seed.dataset.seedApp;
2790
2805
  const templateId = seed.dataset.seedTemplate || appId;
2791
2806
  if (!WORKSPACE_APPS[templateId]) return;
2792
- // Every create action is drawing-first since #625 removed the copy-from-Workflows card. The
2793
- // check stays a check rather than an assumption: a future kind must declare its own branch,
2794
- // not silently inherit the file picker.
2807
+ // Each create kind has its own branch below. The 'drawing' check stays a check rather than an
2808
+ // assumption: a future kind must declare its own branch, not silently inherit the file picker.
2795
2809
  if (seed.dataset.seedAction === 'drawing') {
2796
2810
  if (workspaceWorkflowKnownMissing(appId)) {
2797
2811
  showToast(missingWorkspaceWorkflowMessage(templateId), 'warn');
@@ -2849,11 +2863,10 @@
2849
2863
  openProject(e.target.dataset.open);
2850
2864
  });
2851
2865
 
2852
- // Drop-a-drawing dropzone. A single hidden picker (outside $landing so an innerHTML re-render can't
2853
- // wipe it) backs the click-to-pick; dragover/drop are delegated on $landing so they survive the
2854
- // re-render too. The dashed card lights up (.drag-over) while a file hovers it.
2855
- // Fallback-only hidden input (outside $landing so an innerHTML re-render can't wipe it) —
2856
- // driven by pickDrawingFiles() above when the File System Access API isn't available.
2866
+ // Hidden fallback pickers for the create cards' click path: drawings, one .rvt, a Tekla folder, a
2867
+ // Tekla .zip. They live outside $landing so an innerHTML re-render can't wipe them, and the pick*()
2868
+ // helpers above use them only when the File System Access API is missing. Files DROPPED on a card
2869
+ // are handled by dropOnLanding below.
2857
2870
  const $seedFile = document.createElement('input');
2858
2871
  $seedFile.type = 'file'; $seedFile.accept = '.pdf,image/*'; $seedFile.multiple = true; $seedFile.hidden = true;
2859
2872
  document.body.appendChild($seedFile);
@@ -3046,33 +3059,173 @@
3046
3059
  const $thumbFile = document.createElement('input');
3047
3060
  $thumbFile.type = 'file'; $thumbFile.accept = 'image/*'; $thumbFile.hidden = true;
3048
3061
  document.body.appendChild($thumbFile);
3049
- $landing.addEventListener('dragover', (e) => {
3050
- const zone = e.target.closest('[data-seed-drop]');
3051
- if (!zone) return;
3062
+ // Files dropped on the landing. Every create card takes part: a card that reads a file starts a
3063
+ // project from it, and every other one (locked, needing setup, or Drawing Checker, which starts from
3064
+ // a profile) still accepts the drop so it can say why nothing opened (cardDropWarning). Anywhere else
3065
+ // the drop is refused with a no-drop cursor (the guard below), so the browser never leaves the app to
3066
+ // display the dropped file, which is what an unhandled drop does.
3067
+ const DRAWING_EXTENSIONS = Object.values(DRAWING_FILE_TYPES[0].accept).flat();
3068
+ const isDrawingFile = (file) => DRAWING_EXTENSIONS.some((ext) => file.name.toLowerCase().endsWith(ext));
3069
+ const DRAWING_FORMATS = 'PDF and image files (PNG, JPG, GIF, WebP or BMP)';
3070
+ const draggingFiles = (e) => Array.from(e.dataTransfer?.types || []).includes('Files');
3071
+ // While files are dragged over the window, `data-file-drag` on $landing (so a re-render keeps it)
3072
+ // shows every card that takes a file. Set on every dragenter and dragover, which keep firing while a
3073
+ // drag hovers, so nothing can leave it wrongly cleared for more than a moment. Cleared when the drag
3074
+ // leaves the window (a dragleave whose relatedTarget is null: moving between elements names the new
3075
+ // one), on a drop, and on the first pointer move after the drag — a drag fires no pointer events, and
3076
+ // no event reliably ends one that started outside the page. (A count of enters and leaves was tried
3077
+ // first: one unpaired leave, such as a leftover from the previous drag, cleared it mid-drag.)
3078
+ function endFileDrag() {
3079
+ if (!('fileDrag' in $landing.dataset)) return;
3080
+ delete $landing.dataset.fileDrag;
3081
+ $landing.querySelectorAll('.drag-over').forEach((zone) => zone.classList.remove('drag-over'));
3082
+ }
3083
+ function fileDragEnter(e) {
3084
+ if (draggingFiles(e) && !('fileDrag' in $landing.dataset)) $landing.dataset.fileDrag = '';
3085
+ }
3086
+ function fileDragLeave(e) { if (draggingFiles(e) && !e.relatedTarget) endFileDrag(); }
3087
+ window.addEventListener('dragenter', fileDragEnter);
3088
+ window.addEventListener('dragover', fileDragEnter);
3089
+ window.addEventListener('dragleave', fileDragLeave);
3090
+ window.addEventListener('drop', endFileDrag, true);
3091
+ window.addEventListener('pointermove', endFileDrag, { passive: true });
3092
+ // Anywhere in the app that nothing takes a file — an open dialog, the header — a dropped one is
3093
+ // refused instead of opened in place of FloLess. Bubble phase, and only when nothing below handled
3094
+ // it, so the real drop zones (the cards, chat, Knowledge) answer first; never on a file input,
3095
+ // whose own default is to take the file.
3096
+ const unhandledFileDrag = (e) => draggingFiles(e) && !e.defaultPrevented
3097
+ && !(e.target instanceof HTMLInputElement && e.target.type === 'file');
3098
+ window.addEventListener('dragover', (e) => { if (unhandledFileDrag(e)) { e.preventDefault(); e.dataTransfer.dropEffect = 'none'; } });
3099
+ window.addEventListener('drop', (e) => { if (unhandledFileDrag(e)) e.preventDefault(); });
3100
+
3101
+ // A file dropped on the wrong card: what this card opens, and where the file goes instead. Only a
3102
+ // card that is on screen and ready is ever named, and a folder or .zip is only SUGGESTED for Tekla
3103
+ // Parser, since a folder of drawings or a project archive is neither a Tekla model.
3104
+ function misdropMessage(zone, opens, files, folderCount) {
3105
+ const cardFor = (kind) => $landing.querySelector(`[data-seed-drop-kind="${kind}"] .ws-seed-headline`)?.textContent;
3106
+ const name = zone.querySelector('.ws-seed-headline')?.textContent || 'This card';
3107
+ const other = (card) => (card && card !== name ? card : null);
3108
+ const revit = files.some((file) => /\.rvt$/i.test(file.name)) && other(cardFor('rvt'));
3109
+ const drawing = files.some(isDrawingFile) && other(cardFor('drawing'));
3110
+ const tekla = (folderCount || files.some((file) => /\.zip$/i.test(file.name))) && other(cardFor('tekla-source'));
3111
+ const next = revit ? `Drop it on ${revit} instead.`
3112
+ : drawing ? `Drop it on ${drawing} instead.`
3113
+ : folderCount && zone.dataset.seedDropKind === 'drawing'
3114
+ ? `Folders aren’t opened: drop the drawings inside it instead${tekla ? `, or drop a Tekla model folder on ${tekla}` : ''}.`
3115
+ : tekla ? `If it is a Tekla model, drop it on ${tekla} instead.`
3116
+ : 'Drop one of those, or click the card to choose it.';
3117
+ return `${name} opens ${opens}, so nothing was opened. ${next}`;
3118
+ }
3119
+
3120
+ // What a card that takes no file says when one is dropped on it. A locked or setting-up card answers
3121
+ // with what it shows NOW (retrying setup rewrites the card in place) plus its next step; that text can
3122
+ // carry the server's own remedy naming the person's folders, so it goes out as authored copy.
3123
+ function cardDropWarning(zone) {
3124
+ if (zone.dataset.dropWarn) return zone.dataset.dropWarn;
3125
+ const said = zone.querySelector('.ws-seed-sub')?.textContent?.trim() || '';
3126
+ const action = zone.querySelector('.ws-seed-action')?.textContent?.replace(/\s*→\s*$/, '').trim();
3127
+ // A busy card (setting up, or retrying: its action then reads "Trying…") has nothing to press yet.
3128
+ return authoredToastCopy(`Nothing was opened. ${said}`
3129
+ + (zone.getAttribute('aria-busy') === 'true' ? ' Drop the file again once it finishes.'
3130
+ : action ? ` Use “${action}” on the card, then drop the file again.` : ''));
3131
+ }
3132
+
3133
+ // A Tekla model dropped on its card: the whole model folder, or one .zip of it, read as the folder
3134
+ // and ZIP pickers read them (filesFromDirectoryHandle, teklaZipSource). The folder's handle must be
3135
+ // requested INSIDE the drop event (the browser empties dataTransfer once the handler returns), so
3136
+ // only its answer is awaited. A browser without getAsFileSystemHandle is pointed to the click route.
3137
+ let teklaDropReading = false;
3138
+ function dropTeklaSource(zone, items, files, folderCount) {
3139
+ const appId = zone.dataset.seedDrop;
3140
+ const templateId = zone.dataset.seedTemplate || appId;
3141
+ if (items.length !== 1 || !(folderCount || /\.zip$/i.test(files[0]?.name || ''))) {
3142
+ showToast(misdropMessage(zone, 'a Tekla model folder or one .zip of it', files, folderCount), 'warn');
3143
+ return;
3144
+ }
3145
+ if (teklaDropReading) {
3146
+ showToast('FloLess is still reading the Tekla model you dropped a moment ago, so nothing new was opened. Wait for its project setup to open, then drop again if you need to.', 'warn');
3147
+ return;
3148
+ }
3149
+ const label = items[0].getAsFile?.()?.name || 'the Tekla model';
3150
+ const folder = folderCount ? items[0].getAsFileSystemHandle?.() : null;
3151
+ // A big model folder takes a while to read, and nothing else on screen moves meanwhile.
3152
+ const reading = folderCount ? showToast(`Reading ${label}…`, 'progress') : null;
3153
+ teklaDropReading = true;
3154
+ void (async () => {
3155
+ try {
3156
+ let source;
3157
+ if (!folderCount) source = teklaZipSource(files[0]);
3158
+ else {
3159
+ const handle = await folder;
3160
+ if (handle?.kind !== 'directory') throw new Error('FloLess couldn’t read the dropped folder, so nothing was opened. Click the card to choose the Tekla model folder instead.');
3161
+ source = await filesFromDirectoryHandle(handle);
3162
+ }
3163
+ // The read may have outlasted the moment: never open setup over another window or a project.
3164
+ if (projectSetupState || teklaSourceChoice || $landing.hidden) {
3165
+ throw new Error(`FloLess finished reading ${label}, but something else is open now, so nothing was opened. Drop the model on Tekla Parser again when you are ready.`);
3166
+ }
3167
+ await createFromTeklaSource(appId, templateId, source, zone.isConnected ? zone : null);
3168
+ } catch (error) {
3169
+ // Our own checks throw a plain Error that already says what to do. Anything else is the browser
3170
+ // failing to read a file (moved, locked, unreadable), whose message is not written for people.
3171
+ if (error?.name !== 'Error') console.warn('[workspaces] could not read a dropped Tekla model', error);
3172
+ showToast(error?.name === 'Error' && error.message ? error.message
3173
+ : 'FloLess couldn’t read every file of that Tekla model, so nothing was opened. Check it is still there and not open in another program, then drop it again or click the card to choose it.', 'warn');
3174
+ } finally {
3175
+ teklaDropReading = false;
3176
+ reading?.(true);
3177
+ }
3178
+ })();
3179
+ }
3180
+
3181
+ // Every create card accepts the drag (so a card that takes no file can still answer the drop); off
3182
+ // the cards the no-drop cursor says it lands nowhere.
3183
+ $landing.addEventListener('dragover', dragOverLanding);
3184
+ function dragOverLanding(e) {
3185
+ if (!draggingFiles(e)) return;
3052
3186
  e.preventDefault();
3053
- zone.classList.add('drag-over');
3054
- });
3187
+ const zone = e.target.closest('.ws-seed');
3188
+ if (!zone) { e.dataTransfer.dropEffect = 'none'; return; }
3189
+ if (zone.dataset.seedDrop) zone.classList.add('drag-over');
3190
+ }
3055
3191
  $landing.addEventListener('dragleave', (e) => {
3056
3192
  const zone = e.target.closest('[data-seed-drop]');
3057
3193
  if (zone && !zone.contains(e.relatedTarget)) zone.classList.remove('drag-over');
3058
3194
  });
3059
- $landing.addEventListener('drop', (e) => {
3060
- const zone = e.target.closest('[data-seed-drop]');
3061
- if (!zone) return;
3195
+ $landing.addEventListener('drop', dropOnLanding);
3196
+ function dropOnLanding(e) {
3197
+ if (!draggingFiles(e)) return;
3062
3198
  e.preventDefault();
3063
- zone.classList.remove('drag-over');
3064
- const files = Array.from((e.dataTransfer && e.dataTransfer.files) || []);
3199
+ const zone = e.target.closest('.ws-seed');
3200
+ if (!zone) return;
3201
+ if (!zone.dataset.seedDrop) { showToast(cardDropWarning(zone), 'warn'); return; }
3202
+ const items = Array.from(e.dataTransfer.items || []).filter((item) => item.kind === 'file');
3203
+ const isFolder = items.map((item) => !!item.webkitGetAsEntry?.()?.isDirectory);
3204
+ const folderCount = isFolder.filter(Boolean).length;
3205
+ // A dropped folder also comes through as an empty file named like the folder ("plans.pdf"
3206
+ // included), so the files are taken from the non-folder items only.
3207
+ const files = items.filter((_, i) => !isFolder[i]).map((item) => item.getAsFile()).filter(Boolean);
3065
3208
  // Same two ids as the click path — the dropzone IS the seed button, so it carries both.
3066
- if (zone.dataset.seedDropKind === 'rvt') {
3067
- if (files.length === 1 && /\.rvt$/i.test(files[0].name)) createFromRvt(zone.dataset.seedDrop, zone.dataset.seedTemplate || zone.dataset.seedDrop, files[0]);
3068
- else showToast('Choose one Revit .rvt file.', 'warn');
3069
- } else if (files.length) {
3070
- const appId = zone.dataset.seedDrop;
3071
- const templateId = zone.dataset.seedTemplate || appId;
3072
- if (workspaceWorkflowKnownMissing(appId)) showToast(missingWorkspaceWorkflowMessage(templateId), 'warn');
3073
- else createFromDrawing(appId, templateId, files);
3209
+ const appId = zone.dataset.seedDrop;
3210
+ const templateId = zone.dataset.seedTemplate || appId;
3211
+ const kind = zone.dataset.seedDropKind;
3212
+ if (kind === 'tekla-source') { dropTeklaSource(zone, items, files, folderCount); return; }
3213
+ if (kind === 'rvt') {
3214
+ if (files.length === 1 && !folderCount && /\.rvt$/i.test(files[0].name)) createFromRvt(appId, templateId, files[0]);
3215
+ else showToast(misdropMessage(zone, 'one Revit .rvt file', files, folderCount), 'warn');
3216
+ return;
3074
3217
  }
3075
- });
3218
+ const drawings = files.filter(isDrawingFile);
3219
+ if (!drawings.length) { showToast(misdropMessage(zone, DRAWING_FORMATS, files, folderCount), 'warn'); return; }
3220
+ if (workspaceWorkflowKnownMissing(appId)) { showToast(missingWorkspaceWorkflowMessage(templateId), 'warn'); return; }
3221
+ const skippedFiles = files.length - drawings.length;
3222
+ const skipped = [
3223
+ skippedFiles && `Skipped ${skippedFiles} ${skippedFiles === 1 ? 'file that isn’t a PDF or image' : 'files that aren’t PDFs or images'}.`,
3224
+ folderCount && `Skipped ${folderCount === 1 ? '1 folder' : `${folderCount} folders`}: folders aren’t opened, so drop the drawings inside instead.`,
3225
+ ].filter(Boolean);
3226
+ if (skipped.length) showToast(skipped.join(' '), 'warn');
3227
+ createFromDrawing(appId, templateId, drawings);
3228
+ }
3076
3229
 
3077
3230
  async function promptName(title, label, value) {
3078
3231
  if (!bridge.formModal) return null;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.150.0",
3
+ "version": "0.151.0",
4
4
  "type": "module",
5
- "description": "Thin localhost host for floless.app — serves web/ and shells the aware CLI. No engine, no LLM.",
5
+ "description": "Thin localhost host for floless.app — serves web/ and shells the aware CLI. No engine, no LLM.",
6
6
  "bin": {
7
7
  "floless-app": "bin/floless.mjs"
8
8
  },