@floless/app 0.109.3 → 0.109.4
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 +1035 -123
- package/dist/web/app.css +51 -1
- package/dist/web/aware.js +125 -11
- package/launch.mjs +63 -16
- package/package.json +1 -1
package/dist/web/app.css
CHANGED
|
@@ -3101,7 +3101,36 @@ body {
|
|
|
3101
3101
|
border-top: 1px solid var(--border);
|
|
3102
3102
|
border-bottom: 1px solid var(--border);
|
|
3103
3103
|
}
|
|
3104
|
-
|
|
3104
|
+
/* This is a scroll container (max-height + overflow-y), so it needs the dark scrollbar like every
|
|
3105
|
+
other one — an unthemed one renders the native white bar straight through the dark theme. It had
|
|
3106
|
+
none; caught while adding the note block below, which makes the popover taller and so more likely
|
|
3107
|
+
to scroll. Same treatment as .fm-note above. */
|
|
3108
|
+
.relnotes-body { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
|
|
3109
|
+
.relnotes-body::-webkit-scrollbar { width: 9px; }
|
|
3110
|
+
.relnotes-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
|
|
3111
|
+
.relnotes-body::-webkit-scrollbar-track { background: transparent; }
|
|
3112
|
+
|
|
3113
|
+
/* Why this build can't update itself, shown for the channels that cannot self-apply. Sits between
|
|
3114
|
+
the header and the notes body so the async notes fetch (which replaces .relnotes-body) can never
|
|
3115
|
+
wipe it — the instruction has to outlive the request that failed or lagged. */
|
|
3116
|
+
.relnotes-note {
|
|
3117
|
+
padding: 10px 16px 12px;
|
|
3118
|
+
font-size: 12px;
|
|
3119
|
+
line-height: 1.45;
|
|
3120
|
+
color: var(--text-muted);
|
|
3121
|
+
}
|
|
3122
|
+
.relnotes-note code {
|
|
3123
|
+
font-family: var(--mono);
|
|
3124
|
+
font-size: 11px;
|
|
3125
|
+
color: var(--text);
|
|
3126
|
+
background: var(--bg);
|
|
3127
|
+
border: 1px solid var(--border);
|
|
3128
|
+
border-radius: 4px;
|
|
3129
|
+
padding: 1px 5px;
|
|
3130
|
+
/* A command is the one thing here the user must be able to read in full and select by hand. */
|
|
3131
|
+
word-break: break-all;
|
|
3132
|
+
}
|
|
3133
|
+
.relnotes-actions { padding: 12px 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
|
|
3105
3134
|
|
|
3106
3135
|
/* Typed change bullets — REUSED verbatim by the what's-new panel (one renderer). */
|
|
3107
3136
|
.relnotes-group { margin-bottom: 12px; }
|
|
@@ -3176,7 +3205,28 @@ body {
|
|
|
3176
3205
|
transition: background 0.15s, border-color 0.15s, color 0.15s;
|
|
3177
3206
|
}
|
|
3178
3207
|
.relnotes-changelog:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text-muted); }
|
|
3208
|
+
|
|
3209
|
+
/* Same shape as .relnotes-changelog, one step brighter because it is the RECOMMENDED way out of
|
|
3210
|
+
the no-self-update state, while "Full changelog" is incidental.
|
|
3211
|
+
Not optional styling: without it the anchor rendered at the browser's default #0000EE against
|
|
3212
|
+
the dark theme — caught in the browser pass, and exactly the "no browser default may leak
|
|
3213
|
+
through" rule. It also does NOT take `margin-left:auto`; that belongs to the changelog link
|
|
3214
|
+
alone, which must stay pushed to the right edge as the trailing item. */
|
|
3215
|
+
.relnotes-desktop {
|
|
3216
|
+
background: transparent;
|
|
3217
|
+
border: 1px solid transparent;
|
|
3218
|
+
color: var(--text-muted);
|
|
3219
|
+
padding: 7px 10px;
|
|
3220
|
+
border-radius: 4px;
|
|
3221
|
+
font-size: 12px;
|
|
3222
|
+
text-decoration: none;
|
|
3223
|
+
cursor: pointer;
|
|
3224
|
+
white-space: nowrap;
|
|
3225
|
+
transition: background 0.15s, border-color 0.15s, color 0.15s;
|
|
3226
|
+
}
|
|
3227
|
+
.relnotes-desktop:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
|
|
3179
3228
|
.relnotes-update:focus-visible,
|
|
3229
|
+
.relnotes-desktop:focus-visible,
|
|
3180
3230
|
.relnotes-changelog:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
3181
3231
|
|
|
3182
3232
|
/* Either footer version label becomes a notes affordance once its changelog resolves
|
package/dist/web/aware.js
CHANGED
|
@@ -4191,7 +4191,9 @@
|
|
|
4191
4191
|
if (_notesEscHandler) { document.removeEventListener('keydown', _notesEscHandler, true); _notesEscHandler = null; }
|
|
4192
4192
|
if (_notesOutsideHandler) { document.removeEventListener('mousedown', _notesOutsideHandler, true); _notesOutsideHandler = null; }
|
|
4193
4193
|
if (_notesOriginEl && _notesOriginEl !== anchorEl) { _notesOriginEl.setAttribute('aria-expanded', 'false'); _notesOriginEl.removeAttribute('aria-controls'); }
|
|
4194
|
-
|
|
4194
|
+
// "FloLess", never "floless.app" — the product name is the brand; the domain is internal-only
|
|
4195
|
+
// and must not appear in the UI. This string is the popover's visible title AND its aria-label.
|
|
4196
|
+
const compLabel = component === 'aware' ? 'AWARE' : 'FloLess';
|
|
4195
4197
|
$notesPopover.setAttribute('aria-label', compLabel + ' v' + version + ' release notes');
|
|
4196
4198
|
|
|
4197
4199
|
// Build the "full notes" link, component-aware:
|
|
@@ -4214,10 +4216,81 @@
|
|
|
4214
4216
|
+ `<div class="relnotes-actions">${updateHtml}${changelogHtml}</div>`;
|
|
4215
4217
|
$notesPopover.hidden = false;
|
|
4216
4218
|
|
|
4219
|
+
// ── Channels that cannot self-apply ──────────────────────────────────────────────────────────
|
|
4220
|
+
// Only the desktop (Velopack) build owns Update.exe. The pill carries the server's answer; an
|
|
4221
|
+
// absent value (the AWARE pill) leaves everything below untouched.
|
|
4222
|
+
//
|
|
4223
|
+
// Built with DOM calls and textContent rather than more innerHTML: the command string is the one
|
|
4224
|
+
// piece of server-supplied text rendered here, and textContent cannot be parsed as markup at all.
|
|
4225
|
+
const ds = (anchorEl && anchorEl.dataset) || {};
|
|
4226
|
+
const chan = ds.channel || '';
|
|
4227
|
+
const cannotSelfApply = !!onUpdate && chan !== '' && chan !== 'desktop';
|
|
4228
|
+
const cmdText = ds.command || 'npm i -g @floless/app@latest';
|
|
4229
|
+
// Windows-only, because the desktop build is Windows-only. HIDDEN when unavailable rather than
|
|
4230
|
+
// shown-disabled, per the app's "hide, never show a dead control" rule — offering a download that
|
|
4231
|
+
// does not exist for your OS would repeat the very defect this fixes.
|
|
4232
|
+
const offerDesktop = cannotSelfApply && !!ds.desktop && !!webBase;
|
|
4233
|
+
|
|
4234
|
+
if (cannotSelfApply) {
|
|
4235
|
+
// The explanation belongs HERE, not in a toast: a toast is textContent-only (so it cannot carry
|
|
4236
|
+
// the download link) and auto-dismisses, which is no vessel for an instruction to act on. This
|
|
4237
|
+
// sits between header and body, so the async notes fetch — which replaces .relnotes-body — can
|
|
4238
|
+
// never wipe it, and it stays readable while the user goes and runs the command.
|
|
4239
|
+
const note = document.createElement('div');
|
|
4240
|
+
note.className = 'relnotes-note';
|
|
4241
|
+
const code = document.createElement('code');
|
|
4242
|
+
code.textContent = cmdText;
|
|
4243
|
+
if (ds.transient) {
|
|
4244
|
+
// "close it and open it again", never "restart": the stale code is in the background service,
|
|
4245
|
+
// so refreshing the page — the obvious reading of "restart" inside a browser — changes nothing.
|
|
4246
|
+
note.append('This copy of FloLess is temporary (it was started with ');
|
|
4247
|
+
const npx = document.createElement('code'); npx.textContent = 'npx';
|
|
4248
|
+
note.append(npx, '), so it can’t update itself. ',
|
|
4249
|
+
offerDesktop ? 'Get the desktop app for one-click updates from now on, or run ' : 'Run ',
|
|
4250
|
+
code, ' to make it a permanent install — then close FloLess and open it again.');
|
|
4251
|
+
} else {
|
|
4252
|
+
note.append('This build updates from your terminal. Run ', code,
|
|
4253
|
+
', then close FloLess and open it again.'
|
|
4254
|
+
+ (offerDesktop ? ' Or get the desktop app to update in one click from now on.' : ''));
|
|
4255
|
+
}
|
|
4256
|
+
$notesPopover.querySelector('.relnotes-header').insertAdjacentElement('afterend', note);
|
|
4257
|
+
|
|
4258
|
+
// Label the button for what it ACTUALLY does. "Update now" on a build that cannot update itself
|
|
4259
|
+
// is the reported defect: it was clicked, a command flashed past, nothing updated, and the pill
|
|
4260
|
+
// kept asking. A control may only promise what its channel can deliver.
|
|
4261
|
+
const $btn = $notesPopover.querySelector('.relnotes-update');
|
|
4262
|
+
if ($btn) $btn.textContent = 'Copy update command';
|
|
4263
|
+
|
|
4264
|
+
if (offerDesktop) {
|
|
4265
|
+
// A real anchor, so ctrl/middle-click and copy-link-address behave — not a button faking one.
|
|
4266
|
+
const a = document.createElement('a');
|
|
4267
|
+
a.className = 'relnotes-desktop';
|
|
4268
|
+
a.target = '_blank';
|
|
4269
|
+
a.rel = 'noopener';
|
|
4270
|
+
// `/dashboard/download`, NOT `/download` — the site is a Vite SPA whose only download route is
|
|
4271
|
+
// nested under the authenticated /dashboard, so `/download` falls through to its catch-all
|
|
4272
|
+
// 404. Review caught this, and it is worth spelling out WHY it slipped: a plain HTTP check
|
|
4273
|
+
// "verified" `/download` as 200, but an SPA serves index.html for every path and renders the
|
|
4274
|
+
// 404 client-side, so a status code proves nothing here. Sign-in is an acceptable bounce —
|
|
4275
|
+
// every FloLess user has an account (the app is seat-licensed) — and this is the page that
|
|
4276
|
+
// actually serves the installer.
|
|
4277
|
+
a.href = webBase + '/dashboard/download';
|
|
4278
|
+
a.textContent = 'Get the desktop app ↗';
|
|
4279
|
+
a.setAttribute('data-tip', 'One-click updates from then on — no terminal needed');
|
|
4280
|
+
const actions = $notesPopover.querySelector('.relnotes-actions');
|
|
4281
|
+
if (actions) actions.insertBefore(a, actions.querySelector('.relnotes-changelog'));
|
|
4282
|
+
}
|
|
4283
|
+
}
|
|
4284
|
+
|
|
4217
4285
|
// Wire Update now — it never waits on the notes fetch.
|
|
4218
4286
|
const $update = $notesPopover.querySelector('.relnotes-update');
|
|
4219
4287
|
if ($update && onUpdate) {
|
|
4220
|
-
|
|
4288
|
+
// Deliberately does NOT close for a copy-only channel: the toast alone cannot carry the whole
|
|
4289
|
+
// instruction, so the note must stay on screen while the user acts on it. Closing is right for
|
|
4290
|
+
// the desktop path, where the click really does start the update.
|
|
4291
|
+
$update.onclick = cannotSelfApply
|
|
4292
|
+
? () => { onUpdate(version); }
|
|
4293
|
+
: () => { closeNotesPopover(); onUpdate(version); };
|
|
4221
4294
|
}
|
|
4222
4295
|
|
|
4223
4296
|
// Position relative to the anchor: hang above it (footer is at the bottom), and
|
|
@@ -4234,7 +4307,9 @@
|
|
|
4234
4307
|
try { $notesPopover.focus(); } catch { /* container is tabindex=-1 */ }
|
|
4235
4308
|
|
|
4236
4309
|
// Tab cycles only the (up to 2) action controls; Escape closes + restores focus.
|
|
4237
|
-
|
|
4310
|
+
// `.relnotes-desktop` is in the list or the Tab cycle would skip a control that is reachable by
|
|
4311
|
+
// mouse — keyboard users would never get to the download link.
|
|
4312
|
+
const focusables = () => Array.from($notesPopover.querySelectorAll('.relnotes-update, .relnotes-desktop, .relnotes-changelog'));
|
|
4238
4313
|
_notesEscHandler = (e) => {
|
|
4239
4314
|
if (e.key === 'Escape') { e.preventDefault(); closeNotesPopover(); return; }
|
|
4240
4315
|
if (e.key === 'Tab') {
|
|
@@ -4405,12 +4480,27 @@
|
|
|
4405
4480
|
// branch verbatim: npm copies the command; desktop confirms → relaunch.
|
|
4406
4481
|
async function applyAppUpdate(version) {
|
|
4407
4482
|
if (!$appUpdate) return;
|
|
4408
|
-
//
|
|
4409
|
-
|
|
4483
|
+
// ONLY the desktop (Velopack) build can self-apply — it is the one with Update.exe. Everything
|
|
4484
|
+
// else copies a command for the user's terminal.
|
|
4485
|
+
//
|
|
4486
|
+
// Tested as "is it desktop" rather than the old "is it npm", and that inversion is the fix, not
|
|
4487
|
+
// a tidy-up: adding the npx channel made an `=== 'npm'` test fall through to the Velopack path,
|
|
4488
|
+
// so a build with no Update.exe would have tried to self-update and failed. Naming the ONE
|
|
4489
|
+
// channel that CAN self-apply fails safe for every channel, including ones added later.
|
|
4490
|
+
if ($appUpdate.dataset.channel !== 'desktop') {
|
|
4410
4491
|
const cmd = $appUpdate.dataset.command || 'npm i -g @floless/app@latest';
|
|
4411
|
-
//
|
|
4412
|
-
|
|
4413
|
-
|
|
4492
|
+
// The toast is now a CONFIRMATION — the popover note carries the actual instruction — so it
|
|
4493
|
+
// must report what really happened. It used to claim the command was copied unconditionally,
|
|
4494
|
+
// including when navigator.clipboard was absent (no copy attempted) or the write rejected. If
|
|
4495
|
+
// the copy did not happen, the toast has to show the command AND stay put ('warn' lingers with
|
|
4496
|
+
// a dismiss ×; 'ok' auto-dismisses in 2.5s) so it can still be selected by hand.
|
|
4497
|
+
const copied = () => showToast('Copied — run it in your terminal, then close FloLess and open it again.', 'ok');
|
|
4498
|
+
const failed = () => showToast('Couldn’t copy automatically — run this in your terminal, then close FloLess and open it again: ' + cmd, 'warn');
|
|
4499
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
4500
|
+
navigator.clipboard.writeText(cmd).then(copied, failed);
|
|
4501
|
+
} else {
|
|
4502
|
+
failed();
|
|
4503
|
+
}
|
|
4414
4504
|
return;
|
|
4415
4505
|
}
|
|
4416
4506
|
// desktop (Velopack): one-click download + relaunch. Refuse to start while another
|
|
@@ -4460,10 +4550,19 @@
|
|
|
4460
4550
|
const r = await fetch('/api/update');
|
|
4461
4551
|
const d = await r.json();
|
|
4462
4552
|
if (r.ok && d.supported && d.updateAvailable && d.targetVersion) {
|
|
4463
|
-
|
|
4553
|
+
// Same inversion as applyAppUpdate: carry the command for every channel that CANNOT
|
|
4554
|
+
// self-apply, so a new channel never silently loses its instructions.
|
|
4555
|
+
const selfApply = d.channel === 'desktop';
|
|
4464
4556
|
$appUpdate.textContent = '↑ Update to v' + d.targetVersion;
|
|
4465
4557
|
$appUpdate.dataset.channel = d.channel || 'desktop';
|
|
4466
|
-
$appUpdate.dataset.command = (
|
|
4558
|
+
$appUpdate.dataset.command = (!selfApply && d.command) ? d.command : '';
|
|
4559
|
+
// npx: the running copy lives in a throwaway cache, so the command needs a restart to take
|
|
4560
|
+
// effect. Empty string (not "0") when absent — dataset values are strings and any non-empty
|
|
4561
|
+
// one is truthy, which is exactly how applyAppUpdate reads it.
|
|
4562
|
+
$appUpdate.dataset.transient = d.transient ? '1' : '';
|
|
4563
|
+
// Whether a desktop build exists for THIS OS (Windows-only today) — the popover only offers
|
|
4564
|
+
// the download when it does, so no one is sent after a build that isn't made for them.
|
|
4565
|
+
$appUpdate.dataset.desktop = d.desktopAvailable ? '1' : '';
|
|
4467
4566
|
$appUpdate.dataset.target = d.targetVersion;
|
|
4468
4567
|
$appUpdate.dataset.tip = "What's new in v" + d.targetVersion;
|
|
4469
4568
|
$appUpdate.setAttribute('aria-haspopup', 'dialog');
|
|
@@ -4592,7 +4691,22 @@
|
|
|
4592
4691
|
pillEl.dataset.tip = "What's new in v" + v;
|
|
4593
4692
|
pillEl.setAttribute('aria-haspopup', 'dialog');
|
|
4594
4693
|
if (component === 'aware') { pillEl.textContent = '↑ Upgrade AWARE to v' + v; }
|
|
4595
|
-
else {
|
|
4694
|
+
else {
|
|
4695
|
+
pillEl.textContent = '↑ Update to v' + v;
|
|
4696
|
+
// The override may now name a CHANNEL, and it is read before the 'desktop' default. This path
|
|
4697
|
+
// runs only when the real poll found nothing, so `dataset.channel` is unset — meaning an
|
|
4698
|
+
// npm/npx/dev build with the flag set used to be forced to 'desktop', sending it down the
|
|
4699
|
+
// Velopack self-apply path that has no Update.exe. That is the last route into the branch this
|
|
4700
|
+
// change exists to close, and worse for a test harness: an E2E driving the popover through this
|
|
4701
|
+
// flag silently exercised the DESKTOP variant whatever the build under test, so it could report
|
|
4702
|
+
// confidence about branches it never touched.
|
|
4703
|
+
pillEl.dataset.channel = forced.channel || pillEl.dataset.channel || 'desktop';
|
|
4704
|
+
if (forced.channel && forced.channel !== 'desktop') {
|
|
4705
|
+
pillEl.dataset.command = forced.command || 'npm i -g @floless/app@latest';
|
|
4706
|
+
pillEl.dataset.transient = forced.transient ? '1' : '';
|
|
4707
|
+
pillEl.dataset.desktop = forced.desktopAvailable ? '1' : '';
|
|
4708
|
+
}
|
|
4709
|
+
}
|
|
4596
4710
|
pillEl.hidden = false;
|
|
4597
4711
|
return true;
|
|
4598
4712
|
}
|
package/launch.mjs
CHANGED
|
@@ -46,18 +46,25 @@ function ping() {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
// Probe the running server
|
|
50
|
-
// installed build, "so it's scriptable")
|
|
51
|
-
// a floless server — in which case we never touch it.
|
|
52
|
-
|
|
49
|
+
// Probe the running server via /api/health for what it says about itself: its build version
|
|
50
|
+
// (appVersion — the installed build, "so it's scriptable") AND its distribution channel. Either is
|
|
51
|
+
// null when unreachable, non-JSON, or not a floless server — in which case we never touch it.
|
|
52
|
+
// `channel` is additionally null on builds older than the field, which shouldTakeOver reads as
|
|
53
|
+
// "cannot identify, do not evict".
|
|
54
|
+
function probeRunning() {
|
|
53
55
|
return new Promise((resolve) => {
|
|
54
56
|
const req = http.get(HEALTH_URL, { timeout: 1500 }, (res) => {
|
|
55
57
|
let body = '';
|
|
56
58
|
res.on('data', (c) => { body += c; });
|
|
57
|
-
res.on('end', () => {
|
|
59
|
+
res.on('end', () => {
|
|
60
|
+
try {
|
|
61
|
+
const j = JSON.parse(body);
|
|
62
|
+
resolve({ version: j.appVersion || null, channel: j.appChannel || null });
|
|
63
|
+
} catch { resolve({ version: null, channel: null }); }
|
|
64
|
+
});
|
|
58
65
|
});
|
|
59
|
-
req.on('error', () => resolve(null));
|
|
60
|
-
req.on('timeout', () => { req.destroy(); resolve(null); });
|
|
66
|
+
req.on('error', () => resolve({ version: null, channel: null }));
|
|
67
|
+
req.on('timeout', () => { req.destroy(); resolve({ version: null, channel: null }); });
|
|
61
68
|
});
|
|
62
69
|
}
|
|
63
70
|
|
|
@@ -74,14 +81,37 @@ export function cmpVersion(a, b) {
|
|
|
74
81
|
|
|
75
82
|
// "Newest wins": take over the port ONLY when a known-older floless.app build is serving it
|
|
76
83
|
// AND we know our own version — never kill an unknown/non-floless server, never downgrade.
|
|
77
|
-
|
|
84
|
+
//
|
|
85
|
+
// …plus a tie-break on CHANNEL, because equal version numbers do not mean equal builds. Reported
|
|
86
|
+
// from a real machine: an `npx` copy held the port, the user launched the installed desktop app at
|
|
87
|
+
// the SAME version, this returned false, and the launcher opened a browser onto the npx instance —
|
|
88
|
+
// a build with no Update.exe, so his one-click update turned into a terminal command he could not
|
|
89
|
+
// use. Only the desktop build can self-update, so on a tie it takes over one that cannot.
|
|
90
|
+
//
|
|
91
|
+
// Deliberately conservative in two ways. Only a channel we POSITIVELY RECOGNISE as unable to
|
|
92
|
+
// self-update may be evicted: an older build whose /api/health predates the field reports none, and
|
|
93
|
+
// an unrecognised value (a future or malformed channel) is no more identifiable than a missing one —
|
|
94
|
+
// so both are left alone. "Never kill a server we cannot identify" outranks fixing the tie, and an
|
|
95
|
+
// allow-list keeps that true as channels are added, where a "not desktop" test would silently start
|
|
96
|
+
// evicting each new one. And desktop-over-desktop stays false, so the common double-click of an
|
|
97
|
+
// already-running app is still a no-op instead of a pointless kill-and-restart.
|
|
98
|
+
//
|
|
99
|
+
// `channels` is optional so the version-only contract above is unchanged for every caller that
|
|
100
|
+
// cannot see a channel.
|
|
101
|
+
const EVICTABLE_CHANNELS = new Set(['npm', 'npx', 'dev']); // every build with no Update.exe
|
|
102
|
+
|
|
103
|
+
export function shouldTakeOver(runningVersion, selfVersion, channels = {}) {
|
|
78
104
|
if (!runningVersion || !selfVersion) return false;
|
|
79
|
-
|
|
105
|
+
const cmp = cmpVersion(selfVersion, runningVersion);
|
|
106
|
+
if (cmp !== 0) return cmp > 0; // strictly newer wins; strictly older never downgrades
|
|
107
|
+
const { running = null, self = null } = channels;
|
|
108
|
+
return self === 'desktop' && EVICTABLE_CHANNELS.has(running);
|
|
80
109
|
}
|
|
81
110
|
|
|
82
|
-
// This launcher's own build version (set by runAction from the dispatcher), so cmdOpen can
|
|
83
|
-
// compare against whatever is already serving the port.
|
|
111
|
+
// This launcher's own build version + channel (set by runAction from the dispatcher), so cmdOpen can
|
|
112
|
+
// compare against whatever is already serving the port. The channel decides ties the version cannot.
|
|
84
113
|
let _selfVersion = null;
|
|
114
|
+
let _selfChannel = null;
|
|
85
115
|
|
|
86
116
|
async function waitHealthy(timeoutMs = 30000) {
|
|
87
117
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -173,14 +203,17 @@ export async function cmdOpen() {
|
|
|
173
203
|
// Something is already serving the port. If it's a DIFFERENT, OLDER floless.app build than
|
|
174
204
|
// this one, take it over ("newest wins") so the version the user just launched is the one
|
|
175
205
|
// they get — instead of silently opening the stale instance (e.g. a leftover dev server).
|
|
176
|
-
const running = await
|
|
177
|
-
if (shouldTakeOver(running, _selfVersion)) {
|
|
178
|
-
|
|
206
|
+
const running = await probeRunning();
|
|
207
|
+
if (shouldTakeOver(running.version, _selfVersion, { running: running.channel, self: _selfChannel })) {
|
|
208
|
+
// Name the CHANNELS, not just the versions: on a tie the version pair reads as "v0.5.0 taking
|
|
209
|
+
// over v0.5.0", which looks like a bug in the log unless it says which build won and why.
|
|
210
|
+
log(`floless.app v${running.version} (${running.channel ?? 'unknown'}) is already running on ${PORT}; `
|
|
211
|
+
+ `this build is v${_selfVersion} (${_selfChannel ?? 'unknown'}) — taking over`);
|
|
179
212
|
stopServer();
|
|
180
213
|
await new Promise((r) => setTimeout(r, 500)); // let the OS release the port
|
|
181
214
|
await ensureServerUp();
|
|
182
215
|
} else {
|
|
183
|
-
log(`already running${running ? ` (v${running})` : ''}`);
|
|
216
|
+
log(`already running${running.version ? ` (v${running.version}${running.channel ? `, ${running.channel}` : ''})` : ''}`);
|
|
184
217
|
}
|
|
185
218
|
} else {
|
|
186
219
|
await ensureServerUp();
|
|
@@ -463,6 +496,19 @@ export function parseAction(arg) {
|
|
|
463
496
|
// this is a deliberate no-op with the right instruction. The packaged exe never
|
|
464
497
|
// reaches this: main.ts handles `update` before delegating to runAction.
|
|
465
498
|
async function cmdUpdate() {
|
|
499
|
+
// An npx copy needs DIFFERENT words, and this is the likeliest place it gets asked: the user is
|
|
500
|
+
// already in a terminal. Telling them "this is the npm build" is false, and handing over the bare
|
|
501
|
+
// command reproduces the exact bug the UI now avoids — it installs a separate permanent copy while
|
|
502
|
+
// the copy they are running stays on the old version.
|
|
503
|
+
//
|
|
504
|
+
// The regex is `isNpxPath`'s, duplicated rather than imported ON PURPOSE: launch.mjs is the
|
|
505
|
+
// dependency-free launcher (Node built-ins only, no TS import of version.ts), which is why it also
|
|
506
|
+
// cannot ask appChannel(). Keep the two in step if the cache layout ever changes.
|
|
507
|
+
if (/(^|[\\/])_npx([\\/]|$)/.test(fileURLToPath(import.meta.url))) {
|
|
508
|
+
log('this copy is temporary (started with npx), so it cannot update itself');
|
|
509
|
+
log('install a permanent one with "npm i -g @floless/app@latest", then close FloLess and open it again');
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
466
512
|
log('this is the npm build — update it with "npm i -g @floless/app"');
|
|
467
513
|
log('(the installer build self-updates via "floless-app update")');
|
|
468
514
|
}
|
|
@@ -554,8 +600,9 @@ const ACTIONS = { open: cmdOpen, start: cmdStart, supervise: cmdSupervise, stop:
|
|
|
554
600
|
// the packaged exe dispatcher (main.ts), so both surfaces behave identically. The
|
|
555
601
|
// flag tail (argv.slice(3)) is parsed once here and passed to the action; every
|
|
556
602
|
// existing action takes no params and simply ignores it (only `uninstall` reads it).
|
|
557
|
-
export async function runAction(arg, flagArgv = [], selfVersion = null) {
|
|
603
|
+
export async function runAction(arg, flagArgv = [], selfVersion = null, selfChannel = null) {
|
|
558
604
|
_selfVersion = selfVersion;
|
|
605
|
+
_selfChannel = selfChannel;
|
|
559
606
|
const cmd = parseAction(arg);
|
|
560
607
|
const action = ACTIONS[cmd];
|
|
561
608
|
if (!action) { log(`unknown command "${cmd}" — use: open | start | supervise | stop | restart | login | update | uninstall`); process.exit(2); }
|