@hivey/cli 0.9.62 → 0.9.63
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.
|
Binary file
|
package/package.json
CHANGED
|
@@ -144,6 +144,8 @@ td.j{max-width:420px}
|
|
|
144
144
|
#toast.show{opacity:1;transform:translateX(-50%)}
|
|
145
145
|
.empty{padding:60px;text-align:center;color:var(--muted)}
|
|
146
146
|
.err{color:var(--block);font-size:12px}
|
|
147
|
+
.flash{animation:flash 1.4s ease-out}
|
|
148
|
+
@keyframes flash{0%,30%,60%{box-shadow:0 0 0 2px #ffd36a,0 0 28px 6px rgba(127,232,255,.75);background-color:rgba(127,232,255,.12)}15%,45%,75%{box-shadow:0 0 0 1px #7fe8ff,0 0 10px 2px rgba(255,211,106,.4)}100%{box-shadow:none}}
|
|
147
149
|
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
|
|
148
150
|
</style>
|
|
149
151
|
</head>
|
|
@@ -65,8 +65,32 @@ function visible(a) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
// ---------------------------------------------------------------- actions
|
|
68
|
+
// click sound: a short sci-fi "warp ping" made with Web Audio (two rising tones and an echo), no file
|
|
69
|
+
let audioCtx = null;
|
|
70
|
+
function warpPing() {
|
|
71
|
+
try {
|
|
72
|
+
audioCtx ||= new (window.AudioContext || window.webkitAudioContext)();
|
|
73
|
+
const ac = audioCtx, t = ac.currentTime, out = ac.createGain();
|
|
74
|
+
out.gain.value = 0.5;
|
|
75
|
+
const echo = ac.createDelay(), fb = ac.createGain();
|
|
76
|
+
echo.delayTime.value = 0.13; fb.gain.value = 0.32;
|
|
77
|
+
out.connect(ac.destination); out.connect(echo); echo.connect(fb); fb.connect(echo); echo.connect(ac.destination);
|
|
78
|
+
[['sine', 880, 1760, 0, 0.26, 0.32], ['triangle', 1320, 2640, 0.07, 0.12, 0.4], ['sine', 440, 660, 0, 0.1, 0.5]].forEach(([type, f0, f1, at, vol, len]) => {
|
|
79
|
+
const o = ac.createOscillator(), g = ac.createGain();
|
|
80
|
+
o.type = type; o.frequency.setValueAtTime(f0, t + at); o.frequency.exponentialRampToValueAtTime(f1, t + at + 0.16);
|
|
81
|
+
g.gain.setValueAtTime(0.0001, t + at); g.gain.exponentialRampToValueAtTime(vol, t + at + 0.02); g.gain.exponentialRampToValueAtTime(0.0001, t + at + len);
|
|
82
|
+
o.connect(g); g.connect(out); o.start(t + at); o.stop(t + at + len + 0.05);
|
|
83
|
+
});
|
|
84
|
+
setTimeout(() => { fb.gain.value = 0; }, 900);
|
|
85
|
+
} catch (e) { /* no audio: the flash is enough */ }
|
|
86
|
+
}
|
|
68
87
|
async function act(a, action) {
|
|
69
|
-
if (action === 'focus')
|
|
88
|
+
if (action === 'focus') {
|
|
89
|
+
warpPing();
|
|
90
|
+
toast(`Opening ${a.name} in hivey…`);
|
|
91
|
+
office.flash(a.id);
|
|
92
|
+
document.querySelectorAll(`[data-id="${CSS.escape(a.id)}"]`).forEach(el => { el.classList.remove('flash'); void el.offsetWidth; el.classList.add('flash'); });
|
|
93
|
+
}
|
|
70
94
|
try {
|
|
71
95
|
const r = await fetch('/hv-office-action', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ pane: a.pane, action }) });
|
|
72
96
|
const j = await r.json();
|
|
@@ -238,7 +262,7 @@ function closeDrawer() { $('#drawer').classList.remove('open'); selected = null;
|
|
|
238
262
|
const office = (() => {
|
|
239
263
|
const host = $('#office'), labels = $('#labels');
|
|
240
264
|
let renderer;
|
|
241
|
-
try { renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true }); } catch (e) { return { ok: false, build() {}, markSelected() {}, resize() {}, fit() {} }; }
|
|
265
|
+
try { renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true }); } catch (e) { return { ok: false, build() {}, markSelected() {}, resize() {}, fit() {}, flash() {} }; }
|
|
242
266
|
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
|
|
243
267
|
renderer.shadowMap.enabled = true;
|
|
244
268
|
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
|
@@ -593,6 +617,36 @@ const office = (() => {
|
|
|
593
617
|
dirty = true;
|
|
594
618
|
if (!REDUCED) placeLabels();
|
|
595
619
|
}
|
|
620
|
+
// click feedback: a gold ring bursts out, a cyan beam flashes and a light pulses at the agent (1.4 s)
|
|
621
|
+
const flashes = [];
|
|
622
|
+
const beamGeo = new THREE.CylinderGeometry(0.55, 0.55, 7, 28, 1, true);
|
|
623
|
+
const glowMat = color => new THREE.MeshBasicMaterial({ color, transparent: true, opacity: 0, blending: THREE.AdditiveBlending, depthWrite: false, toneMapped: false, side: THREE.DoubleSide });
|
|
624
|
+
function flash(id) {
|
|
625
|
+
const d = desks.find(x => x.a.id === id);
|
|
626
|
+
if (!d) return;
|
|
627
|
+
const g = new THREE.Group();
|
|
628
|
+
g.position.copy(d.g.position).add(new THREE.Vector3(0, 0, -0.9 * d.g.scale.x));
|
|
629
|
+
const ring = mesh(G.ring, glowMat('#ffd36a'), 0, 0.06, 0, 1, 1, 1, false); ring.rotation.x = -Math.PI / 2;
|
|
630
|
+
const ring2 = mesh(G.ring, glowMat('#7fe8ff'), 0, 0.07, 0, 1, 1, 1, false); ring2.rotation.x = -Math.PI / 2;
|
|
631
|
+
const beam = mesh(beamGeo, glowMat('#7fe8ff'), 0, 3.5, 0, 1, 1, 1, false);
|
|
632
|
+
const light = new THREE.PointLight('#9fe8ff', 0, 9, 1.4); light.position.y = 2.2;
|
|
633
|
+
g.add(ring, ring2, beam, light); world.add(g);
|
|
634
|
+
flashes.push({ g, ring, ring2, beam, light, t0: performance.now() });
|
|
635
|
+
tags.get(id)?.el.classList.add('hover');
|
|
636
|
+
setTimeout(() => tags.get(id)?.el.classList.remove('hover'), 1600);
|
|
637
|
+
dirty = true;
|
|
638
|
+
}
|
|
639
|
+
function stepFlashes(now) {
|
|
640
|
+
for (let i = flashes.length - 1; i >= 0; i--) {
|
|
641
|
+
const f = flashes[i], p = Math.min(1, (now - f.t0) / 1400), fade = 1 - p;
|
|
642
|
+
const blink = 0.55 + 0.45 * Math.sin(p * Math.PI * 10); // three quick blinks
|
|
643
|
+
f.ring.scale.setScalar(1 + p * 5); f.ring.material.opacity = fade;
|
|
644
|
+
f.ring2.scale.setScalar(1 + Math.max(0, p - 0.15) * 5); f.ring2.material.opacity = p > 0.15 ? fade * 0.8 : 0;
|
|
645
|
+
f.beam.material.opacity = 0.55 * fade * blink; f.beam.scale.set(1 - p * 0.5, 1, 1 - p * 0.5);
|
|
646
|
+
f.light.intensity = 40 * fade * blink;
|
|
647
|
+
if (p >= 1) { world.remove(f.g); [f.ring, f.ring2, f.beam].forEach(m => m.material.dispose()); flashes.splice(i, 1); }
|
|
648
|
+
}
|
|
649
|
+
}
|
|
596
650
|
function markSelected() {
|
|
597
651
|
desks.forEach(d => { d.ring.material.opacity = d.a.id === selected ? 0.9 : 0; tags.get(d.a.id)?.el.classList.toggle('sel', d.a.id === selected); });
|
|
598
652
|
dirty = true;
|
|
@@ -636,7 +690,7 @@ const office = (() => {
|
|
|
636
690
|
function frame(t) {
|
|
637
691
|
requestAnimationFrame(frame);
|
|
638
692
|
if (document.hidden || ui.view !== 'office') return;
|
|
639
|
-
const moving = !REDUCED && desks.some(d => d.a.status === 'working' || d.a.status === 'blocked' || d.team.some(m => m.status === 'working'));
|
|
693
|
+
const moving = flashes.length > 0 || (!REDUCED && desks.some(d => d.a.status === 'working' || d.a.status === 'blocked' || d.team.some(m => m.status === 'working')));
|
|
640
694
|
const dt = Math.min(0.1, (t - (frame.prev || t)) / 1000); frame.prev = t;
|
|
641
695
|
if (!moving && !dirty) return;
|
|
642
696
|
if (moving && t - last < 33) return; // ~30 fps is plenty
|
|
@@ -670,6 +724,7 @@ const office = (() => {
|
|
|
670
724
|
}
|
|
671
725
|
}
|
|
672
726
|
}
|
|
727
|
+
if (flashes.length) stepFlashes(performance.now());
|
|
673
728
|
if (ui.toon) outline.render(scene, cam); else composer.render();
|
|
674
729
|
placeLabels();
|
|
675
730
|
dirty = false;
|
|
@@ -677,7 +732,7 @@ const office = (() => {
|
|
|
677
732
|
new ResizeObserver(() => { resize(); }).observe(host);
|
|
678
733
|
resize(); placeCam();
|
|
679
734
|
requestAnimationFrame(frame);
|
|
680
|
-
return { ok: true, build, markSelected, resize, fit, ready: ship.load() };
|
|
735
|
+
return { ok: true, build, markSelected, resize, fit, flash, ready: ship.load() };
|
|
681
736
|
})();
|
|
682
737
|
|
|
683
738
|
// ---------------------------------------------------------------- views, polling, keys
|
|
@@ -731,6 +786,11 @@ function setMusic(on) {
|
|
|
731
786
|
$('#music').onclick = () => setMusic(!ui.music);
|
|
732
787
|
if (ui.music) addEventListener('pointerdown', () => { if (ui.music && bgm.paused) setMusic(true); }, { once: true });
|
|
733
788
|
$('#music').textContent = ui.music ? '🎵' : '🔇';
|
|
789
|
+
// only while the page is in front of you: pause when you switch to the terminal or another app or tab
|
|
790
|
+
const inFront = () => !document.hidden && document.hasFocus();
|
|
791
|
+
function followFocus() { if (!ui.music) return; if (inFront()) bgm.play().catch(() => {}); else bgm.pause(); }
|
|
792
|
+
addEventListener('blur', followFocus); addEventListener('focus', followFocus);
|
|
793
|
+
document.addEventListener('visibilitychange', followFocus);
|
|
734
794
|
$('#fit').onclick = () => office.fit();
|
|
735
795
|
function toggleStyle() { ui.toon = !ui.toon; save(); $('#style').textContent = ui.toon ? '🎨 comic' : '✨ HD'; renderAll(); }
|
|
736
796
|
$('#style').onclick = toggleStyle;
|