@floless/app 0.84.0 → 0.86.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.
@@ -131,6 +131,7 @@ const APP_ID = new URLSearchParams(location.search).get('app') || '';
131
131
  // Workspaces: project-keyed contract (see steel-editor.html). Empty = legacy app-keyed URLs.
132
132
  const PROJECT = new URLSearchParams(location.search).get('project') || '';
133
133
  const PROJECT_QS = PROJECT ? ('?project=' + encodeURIComponent(PROJECT)) : '';
134
+ const CONTRACT_QS = PROJECT ? (PROJECT_QS + '&quietMissing=1') : PROJECT_QS;
134
135
  const SVGNS = 'http://www.w3.org/2000/svg';
135
136
  const PALETTE = ['#3b82f6','#22d3ee','#a78bfa','#f59e0b','#34d399','#f472b6','#60a5fa','#facc15'];
136
137
 
@@ -163,8 +164,9 @@ function markDirty(){ dirty = true; saveBtn.disabled = false; setSaved('dirty');
163
164
  async function boot(){
164
165
  if(!APP_ID){ showEmpty('No app specified.'); return; }
165
166
  let res;
166
- try { res = await fetch('/api/contract/' + encodeURIComponent(APP_ID) + PROJECT_QS); }
167
+ try { res = await fetch('/api/contract/' + encodeURIComponent(APP_ID) + CONTRACT_QS); }
167
168
  catch(e){ showEmpty('Could not reach the server.'); return; }
169
+ if(res.status === 204){ showEmpty(); return; }
168
170
  if(!res.ok){ showEmpty(); return; }
169
171
  C = await res.json();
170
172
  F = C && C.filter;
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
- <title>Vectorize — 3D view</title>
6
+ <title>Trace — 3D view</title>
7
7
  <style>
8
8
  /* Locked baseline: shadcn dark slate-blue (same tokens + scrollbar theming as the sibling editors). */
9
9
  :root{--bg:#0f172a;--panel:#1e293b;--line:#334155;--text:#e2e8f0;--mut:#94a3b8;--brand:#3b82f6}
@@ -63,7 +63,7 @@
63
63
  </head>
64
64
  <body>
65
65
  <header>
66
- <b>Vectorize — 3D</b>
66
+ <b>Trace — 3D</b>
67
67
  <span class="stat" id="title">—</span>
68
68
  <span class="spacer"></span>
69
69
  <span class="stat"><b id="nBoxes">0</b> members · <b id="nExtr">0</b> bodies</span>
@@ -222,7 +222,7 @@ function boot(v3d) {
222
222
  skipped = Array.isArray(out.skipped) ? out.skipped : [];
223
223
  const name = (scene.meta && scene.meta.name) || app;
224
224
  $('title').textContent = name;
225
- document.title = 'Vectorize — 3D · ' + name;
225
+ document.title = 'Trace — 3D · ' + name;
226
226
  const boxes = scene.elements.filter((e) => e.kind === 'box').length;
227
227
  const extr = scene.elements.filter((e) => e.kind === 'extrusion').length;
228
228
  $('nBoxes').textContent = boxes; $('nExtr').textContent = extr;
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
- <title>Vectorize — 2D editor</title>
6
+ <title>Traced drawing — editor</title>
7
7
  <style>
8
8
  /* Locked baseline: shadcn dark slate-blue (identical tokens + scrollbar theming as steel-editor.html). */
9
9
  :root{--bg:#0f172a;--panel:#1e293b;--line:#334155;--text:#e2e8f0;--mut:#94a3b8;--brand:#3b82f6;--paper:#f8fafc}
@@ -68,15 +68,18 @@
68
68
  #toast.show{display:flex}
69
69
  #toast .ghost{height:24px;padding:0 8px;background:transparent;border:1px solid var(--line);color:var(--mut);border-radius:5px;font-size:11px}
70
70
  #toast .ghost:hover{color:var(--text);border-color:var(--brand)}
71
+ /* Themed tooltip — replaces native title= so no OS-default tooltip leaks the dark theme. */
72
+ #tooltip{position:fixed;z-index:80;background:var(--panel);border:1px solid var(--line);border-radius:6px;padding:5px 8px;font-size:11.5px;line-height:1.35;color:var(--text);pointer-events:none;max-width:260px;box-shadow:0 8px 22px rgba(0,0,0,.5);opacity:0;transition:opacity .12s}
73
+ #tooltip.show{opacity:1}
71
74
  </style>
72
75
  </head>
73
76
  <body>
74
77
  <header>
75
- <b>Vectorize</b>
78
+ <b>Trace</b>
76
79
  <span class="stat" id="title">—</span>
77
80
  <span class="spacer"></span>
78
81
  <span class="stat"><b id="nEl">0</b> elements · <b id="nTx">0</b> text</span>
79
- <span id="saveStat" title="Edits save to the app's contract automatically" hidden>Auto-save on</span>
82
+ <span id="saveStat" data-tip="Edits save to the app's contract automatically" hidden>Auto-save on</span>
80
83
  <button class="primary" id="exportBtn" disabled>Export SVG</button>
81
84
  </header>
82
85
  <div id="wrap">
@@ -84,7 +87,7 @@
84
87
  <svg id="svg" xmlns="http://www.w3.org/2000/svg"></svg>
85
88
  <div id="state" class="show"><div class="spin"></div><div id="stateMsg">Loading drawing…</div></div>
86
89
  <div id="zoombar">
87
- <button class="ghost" id="fitBtn" title="Fit to view">Fit</button>
90
+ <button class="ghost" id="fitBtn" data-tip="Fit to view">Fit</button>
88
91
  <input type="range" id="zoom" min="10" max="800" value="100" aria-label="Zoom">
89
92
  <span id="zpct">100%</span>
90
93
  </div>
@@ -120,7 +123,12 @@
120
123
  const svg = $('svg');
121
124
  const params = new URLSearchParams(location.search);
122
125
  const app = params.get('app');
123
- const src = params.get('src') || (app ? ('/api/contract/' + encodeURIComponent(app)) : '/vector-example.json');
126
+ // Workspaces: a project-keyed contract lives at projects/<id>/contract.json. Empty PROJECT =
127
+ // legacy app-keyed behaviour (byte-for-byte today's URLs). PROJECT_QS is appended to every
128
+ // /api/contract call so two vectorize projects of the same app never share a draft (spec §4.3).
129
+ const PROJECT = params.get('project') || '';
130
+ const PROJECT_QS = PROJECT ? ('?project=' + encodeURIComponent(PROJECT)) : '';
131
+ const src = params.get('src') || (app ? ('/api/contract/' + encodeURIComponent(app) + PROJECT_QS) : '/vector-example.json');
124
132
  const WEAK = 0.5;
125
133
 
126
134
  let sheet = null;
@@ -307,7 +315,7 @@
307
315
  let saveQueue = Promise.resolve(true);
308
316
  async function doPut() {
309
317
  try {
310
- const res = await fetch('/api/contract/' + encodeURIComponent(app), {
318
+ const res = await fetch('/api/contract/' + encodeURIComponent(app) + PROJECT_QS, {
311
319
  method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(C),
312
320
  });
313
321
  setSaved(res.ok ? 'ok' : 'err');
@@ -382,14 +390,14 @@
382
390
  for (const el of weak) {
383
391
  const row = document.createElement('div'); row.className = 'wrow'; row.dataset.id = el.id || '';
384
392
  const lbl = document.createElement('span'); lbl.className = 'lbl'; lbl.textContent = elLabel(el);
385
- lbl.title = 'Show this trace on the drawing';
393
+ lbl.dataset.tip = 'Show this trace on the drawing';
386
394
  lbl.addEventListener('click', () => locateOnCanvas(el.id));
387
395
  const pct = document.createElement('span'); pct.className = 'pct'; pct.textContent = Math.round((el.confidence || 0) * 100) + '%';
388
396
  const ok = document.createElement('button'); ok.className = 'ghost'; ok.textContent = 'Accept';
389
- ok.title = 'Mark this trace as correct — clears its low-confidence flag.';
397
+ ok.dataset.tip = 'Mark this trace as correct — clears its low-confidence flag.';
390
398
  ok.addEventListener('click', () => acceptEl(el.id));
391
399
  const del = document.createElement('button'); del.className = 'danger'; del.textContent = 'Delete';
392
- del.title = 'Remove this trace from the drawing (Undo available).';
400
+ del.dataset.tip = 'Remove this trace from the drawing (Undo available).';
393
401
  del.addEventListener('click', () => deleteEl(el.id));
394
402
  row.append(lbl, pct, ok, del); box.appendChild(row);
395
403
  }
@@ -436,14 +444,14 @@
436
444
  function afterEdit() { refreshStats(); render(); buildWeakList(); scheduleSave(); }
437
445
 
438
446
  function load(contract) {
439
- if (!contract || !Array.isArray(contract.sheets) || !contract.sheets.length) { showState('This app has no vectorized drawing yet. Drop a PDF and re-bake to read one.'); return; }
447
+ if (!contract || !Array.isArray(contract.sheets) || !contract.sheets.length) { showState('This project has no traced drawing yet. Drop a PDF and re-bake to read one.'); return; }
440
448
  C = contract;
441
449
  sheet = contract.sheets[contract.active || 0] || contract.sheets[0];
442
450
  if (!sheet || !Array.isArray(sheet.elements)) { showState('The drawing has no elements.'); return; }
443
451
  initialWeak = sheet.elements.filter(isWeak).length;
444
452
  const name = (contract.source && contract.source.name) ? contract.source.name : (sheet.label || 'drawing');
445
453
  $('title').textContent = name;
446
- document.title = 'Vectorize — ' + name;
454
+ document.title = 'Trace — ' + name;
447
455
  if (editable) setSaved('ok');
448
456
  refreshStats();
449
457
  buildLayers();
@@ -454,13 +462,34 @@
454
462
  const ctrl = new AbortController();
455
463
  const timer = setTimeout(() => ctrl.abort(), 15000);
456
464
  fetch(src, { headers: { accept: 'application/json' }, signal: ctrl.signal })
457
- .then((r) => { if (!r.ok) throw new Error('HTTP ' + r.status); return r.json(); })
465
+ .then((r) => {
466
+ if (!r.ok) {
467
+ // 404 with no contract yet is expected state for a fresh Workspaces project — show the friendly empty-state message
468
+ if (r.status === 404) return null;
469
+ throw new Error('HTTP ' + r.status);
470
+ }
471
+ return r.json();
472
+ })
458
473
  .then(load)
459
474
  .catch((e) => showState(e.name === 'AbortError' ? 'Loading timed out — is the server reachable?' : ('Could not load the drawing (' + e.message + ').')))
460
475
  .finally(() => clearTimeout(timer));
461
476
 
462
477
  window.addEventListener('resize', () => { if (sheet) syncZoom(); });
463
478
  })();
479
+
480
+ // Themed tooltips (replaces native title=) — one shared element, shown on data-tip hover after a
481
+ // short delay, positioned below the control and clamped to the viewport (same handler as the steel
482
+ // editor's 3D toolbar). Reads data-tip via getAttribute, so JS-set el.dataset.tip works too.
483
+ (function(){ const tip=document.createElement('div'); tip.id='tooltip'; document.body.appendChild(tip); let t=null;
484
+ function show(el){ const txt=el.getAttribute('data-tip'); if(!txt) return; tip.textContent=txt; tip.classList.add('show');
485
+ const r=el.getBoundingClientRect(), tw=tip.offsetWidth, th=tip.offsetHeight;
486
+ let x=Math.max(6,Math.min(r.left+r.width/2-tw/2, innerWidth-tw-6)), y=r.bottom+6; if(y+th>innerHeight-6) y=r.top-th-6;
487
+ tip.style.left=x+'px'; tip.style.top=y+'px'; }
488
+ function hide(){ clearTimeout(t); tip.classList.remove('show'); }
489
+ document.addEventListener('pointerover', e=>{ const el=e.target.closest('[data-tip]'); if(!el) return; clearTimeout(t); t=setTimeout(()=>show(el),400); });
490
+ document.addEventListener('pointerout', e=>{ if(e.target.closest('[data-tip]')) hide(); });
491
+ document.addEventListener('pointerdown', hide, true); // a click hides the tip immediately
492
+ })();
464
493
  </script>
465
494
  </body>
466
495
  </html>