@floless/app 0.151.0 → 0.152.1
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 +14426 -8494
- package/dist/skills/floless-app-knowledge/SKILL.md +25 -2
- package/dist/skills/floless-app-onboarding/SKILL.md +18 -1
- package/dist/skills/floless-app-report-issue/SKILL.md +10 -5
- package/dist/skills/floless-app-routines/SKILL.md +1 -1
- package/dist/skills/floless-app-routines/references/routines-api.md +14 -4
- package/dist/templates/revit-model.flo +6 -2
- package/dist/templates/tekla-parser.flo +6 -2
- package/dist/web/agents.js +146 -9
- package/dist/web/app.css +215 -19
- package/dist/web/app.js +53 -8
- package/dist/web/aware.js +852 -53
- package/dist/web/chat.css +98 -4
- package/dist/web/chat.js +550 -35
- package/dist/web/commands-shell.js +290 -20
- package/dist/web/connections.js +24 -6
- package/dist/web/flo-avatar.js +191 -0
- package/dist/web/flo.js +156 -0
- package/dist/web/guide.js +695 -57
- package/dist/web/index.html +58 -7
- package/dist/web/instructor.js +6 -1
- package/dist/web/local-discovery.js +35 -6
- package/dist/web/panels.js +2 -0
- package/dist/web/parser-setup-recovery.js +250 -0
- package/dist/web/tool-updates.js +330 -36
- package/dist/web/workspace-root-management.js +197 -0
- package/dist/web/workspaces.js +235 -15
- package/package.json +1 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// Flo in the app (#2079): puts web/flo.js's Flo on a small canvas where FloLess is working for you or a person has
|
|
2
|
+
// to decide. It shows the mood its caller already knows and decides nothing. Colours come from the surface's
|
|
3
|
+
// --flo-* custom properties (app.css derives them from the theme tokens), so Flo adds no palette of its own.
|
|
4
|
+
//
|
|
5
|
+
// Every moving Flo (an animated mood, or a one-off such as Hello's hat tip) shares one requestAnimationFrame loop that
|
|
6
|
+
// draws at most 30 times a second (a frame in between does nothing but ask for the next). It runs only while a moving Flo
|
|
7
|
+
// is on screen and the window is visible, and stops when there is nothing to move. Under prefers-reduced-motion
|
|
8
|
+
// every mood is one still frame. Callers attach the canvas in the same task that creates it: a Flo whose canvas
|
|
9
|
+
// is out of the document when a frame runs is dropped from the loop (a feed repaint discards its old nodes), and
|
|
10
|
+
// setMood() brings it back when the same node is shown again.
|
|
11
|
+
(function () {
|
|
12
|
+
const FRAME_MS = 1000 / 30;
|
|
13
|
+
// The still frame: eyes open, Thinking's and Working's light in view, Your call facing the person (no nod). Hello's
|
|
14
|
+
// own still frame is after its hat tip, with the hat back on.
|
|
15
|
+
const STILL_T = 0.6;
|
|
16
|
+
const STILL_T_BY_MOOD = { hello: 1.2 };
|
|
17
|
+
const ANIMATED = new Set(['thinking', 'working']);
|
|
18
|
+
const COLOR_VARS = { line: '--flo-line', fill: '--flo-fill', hat: '--flo-hat', hatLine: '--flo-hat-line', pulse: '--flo-pulse' };
|
|
19
|
+
const avatars = new Set();
|
|
20
|
+
const motion = window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : null;
|
|
21
|
+
// One clock for every Flo, so a node re-created by a repaint carries on where the old one was.
|
|
22
|
+
const epoch = performance.now();
|
|
23
|
+
let frame = 0, lastAnimated = -Infinity;
|
|
24
|
+
|
|
25
|
+
const reduced = () => Boolean(motion && motion.matches);
|
|
26
|
+
// A one-off (`once` seconds, e.g. Hello's hat tip) moves until it has played, then settles once on its still frame.
|
|
27
|
+
function moving(a) {
|
|
28
|
+
if (ANIMATED.has(a.mood)) return true;
|
|
29
|
+
if (!a.playUntil) return false;
|
|
30
|
+
if (performance.now() < a.playUntil) return true;
|
|
31
|
+
a.playUntil = 0; a.dirty = true;
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const animates = (a) => a.onScreen && !reduced() && moving(a);
|
|
35
|
+
|
|
36
|
+
// Resolve each --flo-* through the canvas's own `color`, so canvas gets a colour it can parse whatever form
|
|
37
|
+
// the token takes (hsl with spaces, color-mix...).
|
|
38
|
+
function readColors(canvas) {
|
|
39
|
+
const out = {};
|
|
40
|
+
for (const [key, name] of Object.entries(COLOR_VARS)) {
|
|
41
|
+
canvas.style.color = `var(${name})`;
|
|
42
|
+
out[key] = getComputedStyle(canvas).color;
|
|
43
|
+
}
|
|
44
|
+
canvas.style.color = '';
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function draw(a, now) {
|
|
49
|
+
if (!a.colors) a.colors = readColors(a.canvas);
|
|
50
|
+
const c = a.ctx;
|
|
51
|
+
c.setTransform(a.dpr, 0, 0, a.dpr, 0, 0);
|
|
52
|
+
c.clearRect(0, 0, a.w, a.h);
|
|
53
|
+
const t = !animates(a) ? STILL_T_BY_MOOD[a.mood] ?? STILL_T
|
|
54
|
+
: a.playUntil ? Math.max(0, (now - a.playStart) / 1000) : (now - epoch) / 1000;
|
|
55
|
+
drawFlo(c, { x: a.w / 2, y: a.cy, r: a.r, mood: a.mood, hat: a.hat, t, colors: a.colors });
|
|
56
|
+
a.dirty = false;
|
|
57
|
+
a.placed = true;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function tick(now) {
|
|
61
|
+
frame = 0;
|
|
62
|
+
if (document.hidden) return; // visibilitychange schedules again
|
|
63
|
+
const due = now - lastAnimated >= FRAME_MS - 1;
|
|
64
|
+
let drewAnimated = false;
|
|
65
|
+
for (const a of avatars) {
|
|
66
|
+
if (!a.canvas.isConnected) { forget(a); continue; }
|
|
67
|
+
if (a.dirty || (due && animates(a))) {
|
|
68
|
+
draw(a, now);
|
|
69
|
+
if (animates(a)) drewAnimated = true; // any frame of a moving Flo restarts the 30 fps count
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (drewAnimated) lastAnimated = now;
|
|
73
|
+
schedule();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function forget(a) {
|
|
77
|
+
avatars.delete(a);
|
|
78
|
+
if (seen) seen.unobserve(a.canvas);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function schedule() {
|
|
82
|
+
// A placed Flo whose node was discarded (a repainted card) is let go here, not only by the next frame, which a
|
|
83
|
+
// still Flo never asks for. One just created or shown again may still be on its way into the document.
|
|
84
|
+
for (const a of avatars) if (a.placed && !a.canvas.isConnected) forget(a);
|
|
85
|
+
if (frame || document.hidden) return;
|
|
86
|
+
for (const a of avatars) {
|
|
87
|
+
if (a.dirty || animates(a)) { frame = requestAnimationFrame(tick); return; }
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function redrawAll(recolor) {
|
|
92
|
+
for (const a of avatars) { a.dirty = true; if (recolor) a.colors = null; }
|
|
93
|
+
schedule();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const seen = typeof IntersectionObserver === 'function' ? new IntersectionObserver((entries) => {
|
|
97
|
+
for (const entry of entries) {
|
|
98
|
+
const a = entry.target.floAvatar;
|
|
99
|
+
if (!a) continue;
|
|
100
|
+
// Removing a node ends its intersection: a placed Flo whose node is gone is let go now, with nothing else
|
|
101
|
+
// needing to schedule first (the last card of a conversation is not followed by another).
|
|
102
|
+
if (a.placed && !entry.target.isConnected) { forget(a); continue; }
|
|
103
|
+
a.onScreen = entry.isIntersecting;
|
|
104
|
+
if (a.onScreen) a.dirty = true;
|
|
105
|
+
}
|
|
106
|
+
schedule();
|
|
107
|
+
}) : null;
|
|
108
|
+
|
|
109
|
+
// Reduced motion turned on ends a one-off for good: turned off again, it does not pick the hat tip up halfway.
|
|
110
|
+
if (motion) motion.addEventListener('change', () => {
|
|
111
|
+
if (reduced()) for (const a of avatars) a.playUntil = 0;
|
|
112
|
+
redrawAll(false);
|
|
113
|
+
});
|
|
114
|
+
document.addEventListener('visibilitychange', () => { if (!document.hidden) redrawAll(false); });
|
|
115
|
+
if (typeof MutationObserver === 'function') {
|
|
116
|
+
new MutationObserver(() => redrawAll(true)).observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] });
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function checkMood(mood) {
|
|
120
|
+
if (!FLO_MOODS.includes(mood)) throw new Error(`unknown Flo mood: ${mood}`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// floAvatar(host, { size, mood, hat, hatRoom, once }): appends Flo to host and returns { canvas, play, setMood, destroy }.
|
|
124
|
+
// once: seconds of one-off motion (Hello's hat tip), played on mount and by play(), then a still frame.
|
|
125
|
+
// size: the box height in CSS px. hatRoom (default: hat) keeps space for the hat above the ring, so a Flo that
|
|
126
|
+
// puts its hat on later (Thinking -> Working) keeps the same ring size.
|
|
127
|
+
window.floAvatar = function floAvatar(host, o = {}) {
|
|
128
|
+
const mood = o.mood || 'idle';
|
|
129
|
+
checkMood(mood);
|
|
130
|
+
const size = o.size || 24, hatRoom = o.hatRoom ?? Boolean(o.hat);
|
|
131
|
+
const r = hatRoom ? size / 3.2 : size / 2.4;
|
|
132
|
+
// A one-off move (Hello's hat tip) lifts the hat well above its seat: room for it above the box, pulled up by a
|
|
133
|
+
// negative margin so the layout keeps `size`.
|
|
134
|
+
// Turned about its brim's left end, the outlined hat reaches 3.0 r above the ring centre and 1.36 r to its left;
|
|
135
|
+
// 2 px more on each edge leaves room for anti-aliasing, so the hat never reads as touching the canvas edge.
|
|
136
|
+
const headroom = o.once ? Math.ceil(1.1 * r) + 2 : 0, sideroom = o.once ? Math.ceil(0.15 * r) + 2 : 0;
|
|
137
|
+
const w = (hatRoom ? Math.ceil(2.6 * r) : size) + 2 * sideroom, h = size + headroom;
|
|
138
|
+
const dpr = Math.min(2, window.devicePixelRatio || 1);
|
|
139
|
+
const canvas = document.createElement('canvas');
|
|
140
|
+
canvas.className = 'flo-avatar';
|
|
141
|
+
canvas.setAttribute('aria-hidden', 'true');
|
|
142
|
+
canvas.width = Math.round(w * dpr); canvas.height = Math.round(h * dpr);
|
|
143
|
+
canvas.style.width = `${w}px`; canvas.style.height = `${h}px`;
|
|
144
|
+
if (headroom) canvas.style.marginTop = `-${headroom}px`;
|
|
145
|
+
if (sideroom) { canvas.style.marginLeft = `-${sideroom}px`; canvas.style.marginRight = `-${sideroom}px`; }
|
|
146
|
+
const a = {
|
|
147
|
+
canvas, ctx: canvas.getContext('2d'), dpr, w, h, r, cy: hatRoom ? h - 1.2 * r : h / 2,
|
|
148
|
+
mood, hat: Boolean(o.hat), colors: null, dirty: true, placed: false, onScreen: true,
|
|
149
|
+
once: o.once || 0, playStart: 0, playUntil: 0,
|
|
150
|
+
};
|
|
151
|
+
// Plays its one-off motion from the start (on mount, and again on each play()).
|
|
152
|
+
const play = () => {
|
|
153
|
+
if (!a.once) return;
|
|
154
|
+
// Under reduced motion there is no tip to start (and so none a later switch could pick up halfway).
|
|
155
|
+
if (reduced()) { a.playUntil = 0; a.dirty = true; return; }
|
|
156
|
+
a.playStart = performance.now(); a.playUntil = a.playStart + a.once * 1000; a.dirty = true;
|
|
157
|
+
};
|
|
158
|
+
play();
|
|
159
|
+
canvas.floAvatar = a;
|
|
160
|
+
host.append(canvas);
|
|
161
|
+
avatars.add(a);
|
|
162
|
+
if (seen) seen.observe(canvas);
|
|
163
|
+
schedule();
|
|
164
|
+
return {
|
|
165
|
+
canvas,
|
|
166
|
+
// Plays the one-off motion again (a dialog reopened), then settles on the still frame.
|
|
167
|
+
play() {
|
|
168
|
+
play();
|
|
169
|
+
a.placed = false;
|
|
170
|
+
if (!avatars.has(a)) { avatars.add(a); if (seen) seen.observe(canvas); }
|
|
171
|
+
schedule();
|
|
172
|
+
},
|
|
173
|
+
// Show this mood now. Also brings back a Flo dropped from the loop while its node was out of the document.
|
|
174
|
+
setMood(next, hat = a.hat) {
|
|
175
|
+
checkMood(next);
|
|
176
|
+
if (next !== a.mood || Boolean(hat) !== a.hat) { a.mood = next; a.hat = Boolean(hat); a.dirty = true; }
|
|
177
|
+
// Being shown now: its node may be out of the document for the rest of this task (a feed repaint), so it is
|
|
178
|
+
// not let go until a frame has found it back in place.
|
|
179
|
+
a.placed = false;
|
|
180
|
+
if (!avatars.has(a)) { avatars.add(a); if (seen) seen.observe(canvas); }
|
|
181
|
+
schedule();
|
|
182
|
+
},
|
|
183
|
+
destroy() {
|
|
184
|
+
forget(a);
|
|
185
|
+
canvas.remove();
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
// How many Flos the loop is holding on to: the tests' window on the lifecycle above.
|
|
190
|
+
window.floAvatar.live = () => avatars.size;
|
|
191
|
+
})();
|
package/dist/web/flo.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// Flo, the FloLess site agent: the icon's top node with eyes, and (when it acts as an agent) a white
|
|
2
|
+
// engineer's hard hat. The one drawing module for the app (web/flo-avatar.js mounts it), the marketing preview
|
|
3
|
+
// (marketing/flo/preview.html) and the canvas explainer piece, so none of them can drift from the others. (The
|
|
4
|
+
// HyperFrames videos inline SVG copies of the same geometry.) A plain script with no import/export so the
|
|
5
|
+
// animate build can concatenate it and index.html can load it; Node tests read module.exports. Every name is
|
|
6
|
+
// prefixed: the animate kit already defines clamp, lerp, TAU...
|
|
7
|
+
|
|
8
|
+
const FLO_COLORS = {
|
|
9
|
+
dark: { line: '#6B96C7', fill: '#020817', hat: '#f1f5f9', hatLine: '#f1f5f9', pulse: '#c7d9ef' },
|
|
10
|
+
light: { line: '#1E3A5F', fill: '#ffffff', hat: '#ffffff', hatLine: '#1E3A5F', pulse: '#6B96C7' },
|
|
11
|
+
};
|
|
12
|
+
const FLO_MOODS = ['idle', 'hello', 'thinking', 'working', 'success', 'yourcall', 'warning'];
|
|
13
|
+
const FLO_BLINK_EVERY = 3.4, FLO_BLINK_AT = 1.6, FLO_BLINK_LEN = 0.14;
|
|
14
|
+
const FLO_PULSE_PERIOD = 2.6;
|
|
15
|
+
// The living logo's eyes visit one circle per pulse, in the icon's flow order (Workspace -> Workflow -> Agent),
|
|
16
|
+
// starting at the Agent node so Flo can hop out of the top circle at the start of a piece.
|
|
17
|
+
const FLO_EYE_TOUR = ['agent', 'workspace', 'workflow'];
|
|
18
|
+
|
|
19
|
+
// The FloLess icon (viewBox 192 x 181) as data, so the living logo can animate it.
|
|
20
|
+
const FLO_ICON = {
|
|
21
|
+
w: 192, h: 181, line: 11.67, ringLine: 8.72, ringR: 18.9, sLength: 357.75,
|
|
22
|
+
s: 'M93.48 26.23L32.38 26.23C25.59 26.23 19.35 32.22 15.03 38C11.23 43.09 8.72 49.93 8.72 56.53C8.72 64.7 10.96 71.83 15.03 77.79C19.23 83.95 26.19 90.76 32.38 90.76H159.1C165.72 90.76 171.88 93.89 176.18 98.81C180.65 103.94 183.14 111.95 183.14 118.76C183.14 126.31 181.52 131.54 177.97 137.07C174.15 143.03 159.89 151.23 159.89 151.23',
|
|
23
|
+
arrows: ['M90.12 8.72L106.7 26.8L90.12 44.93', 'M78.53 136.75L95.12 154.82L78.53 172.96'],
|
|
24
|
+
// the bottom shaft is flat-ended and starts inside the Workspace ring (drawn on top), as in the brand file
|
|
25
|
+
shaft: 'M53.5 154.47H88.09',
|
|
26
|
+
nodes: { workspace: [33.41, 156.01], workflow: [138.09, 156.01], agent: [149.71, 24.71] },
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function floClamp(v, a = 0, b = 1) { return Math.max(a, Math.min(b, v)); }
|
|
30
|
+
function floMod(a, n) { return ((a % n) + n) % n; }
|
|
31
|
+
function floBump(u) { return Math.sin(Math.PI * floClamp(u)); } // 0 -> 1 -> 0
|
|
32
|
+
|
|
33
|
+
// floPose(o): every number drawFlo needs, as plain data, so behaviour is testable without a canvas.
|
|
34
|
+
// o.r ring centre-line radius (px); o.stroke ring width (px), default 0.29 r (the icon's own node is 0.46 r);
|
|
35
|
+
// o.mood one of FLO_MOODS; o.t seconds; o.hat hard hat on; o.hatLift 0 (on) .. 1 (lifted away);
|
|
36
|
+
// o.look [x, y] in -1..1 aims the eyes; o.seed shifts the blink so two Flos never blink together;
|
|
37
|
+
// o.open 0..1 scales how open the eyes are (the living logo closes them before a hop);
|
|
38
|
+
// o.colors { line, fill, hat, hatLine, pulse } replaces the theme's FLO_COLORS (the app draws in its own tokens).
|
|
39
|
+
function floPose(o = {}) {
|
|
40
|
+
const r = o.r ?? 24, stroke = o.stroke ?? 0.29 * r, t = o.t ?? 0, mood = o.mood ?? 'idle';
|
|
41
|
+
if (!FLO_MOODS.includes(mood)) throw new Error(`unknown Flo mood: ${mood}`);
|
|
42
|
+
const inner = r - stroke / 2;
|
|
43
|
+
const w = 0.268 * inner, h = 0.585 * inner, sep = 0.354 * inner;
|
|
44
|
+
const bp = floMod(t + (o.seed ?? 0), FLO_BLINK_EVERY) - FLO_BLINK_AT;
|
|
45
|
+
let hk = bp >= 0 && bp < FLO_BLINK_LEN ? 1 - 0.9 * floBump(bp / FLO_BLINK_LEN) : 1;
|
|
46
|
+
const g = floMod(t, 5);
|
|
47
|
+
let lx = g < 1.5 ? 0 : g < 3 ? -1 : g < 4.5 ? 1 : 0, ly = 0, kind = 'pill', orbit = null;
|
|
48
|
+
const hat = o.hat ? { lift: floClamp(o.hatLift ?? 0), rot: 0, dy: 0 } : null;
|
|
49
|
+
if (mood === 'thinking') { lx = -0.4; ly = -1; orbit = { a: floMod(t * 0.8, 1) * 2 * Math.PI, len: Math.PI / 3 }; }
|
|
50
|
+
if (mood === 'working') { lx = 0; hk *= 0.8; orbit = { a: floMod(t * 1.2, 1) * 2 * Math.PI, len: Math.PI / 2.5 }; }
|
|
51
|
+
if (mood === 'success') { kind = 'arc'; lx = 0; }
|
|
52
|
+
if (mood === 'yourcall') { const nod = floMod(t, 2) >= 1; lx = nod ? 0.6 : 0; ly = nod ? 0.4 : 0; }
|
|
53
|
+
if (mood === 'warning') { kind = 'flat'; hk = 0.35; lx = 0; if (hat) { hat.rot = -0.14; hat.dy = 0.12 * r; } }
|
|
54
|
+
if (mood === 'hello' && hat) { const u = floBump(floMod(t, 2.4) / 0.9); hat.lift = Math.max(hat.lift, 0.35 * u); hat.rot = -0.25 * u; }
|
|
55
|
+
if (o.look) [lx, ly] = o.look;
|
|
56
|
+
hk *= floClamp(o.open ?? 1);
|
|
57
|
+
const reach = inner - sep - w;
|
|
58
|
+
return {
|
|
59
|
+
r, stroke, inner, mood,
|
|
60
|
+
eyes: { kind, w, h: h * hk, sep, dx: lx * reach * 0.6, dy: ly * reach * 0.5 },
|
|
61
|
+
hat, orbit, colors: o.colors ?? FLO_COLORS[o.theme === 'light' ? 'light' : 'dark'],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// drawFlo(c, o): Flo centred on its ring at (o.x, o.y). o.squash = [sx, sy] scales about the ring's bottom (hops).
|
|
66
|
+
function drawFlo(c, o = {}) {
|
|
67
|
+
const p = floPose(o), k = p.colors, r = p.r, [sx, sy] = o.squash ?? [1, 1];
|
|
68
|
+
c.save();
|
|
69
|
+
c.translate(o.x ?? 0, (o.y ?? 0) + r); c.scale(sx, sy); c.translate(0, -r);
|
|
70
|
+
c.lineCap = 'round'; c.lineJoin = 'round';
|
|
71
|
+
c.beginPath(); c.arc(0, 0, r, 0, 2 * Math.PI);
|
|
72
|
+
c.fillStyle = k.fill; c.fill(); c.lineWidth = p.stroke; c.strokeStyle = k.line; c.stroke();
|
|
73
|
+
if (p.orbit) {
|
|
74
|
+
c.beginPath(); c.arc(0, 0, r, p.orbit.a, p.orbit.a + p.orbit.len);
|
|
75
|
+
c.lineWidth = p.stroke * 0.55; c.strokeStyle = k.pulse; c.stroke();
|
|
76
|
+
}
|
|
77
|
+
const e = p.eyes;
|
|
78
|
+
for (const s of [-1, 1]) {
|
|
79
|
+
const ex = s * e.sep + e.dx, ey = e.dy;
|
|
80
|
+
c.beginPath();
|
|
81
|
+
if (e.kind === 'arc') {
|
|
82
|
+
c.moveTo(ex - e.w * 0.9, ey + e.h * 0.15); c.quadraticCurveTo(ex, ey - e.h * 0.6, ex + e.w * 0.9, ey + e.h * 0.15);
|
|
83
|
+
c.lineWidth = e.w * 0.75; c.strokeStyle = k.line; c.stroke();
|
|
84
|
+
} else {
|
|
85
|
+
const eh = Math.max(e.h, e.w * 0.3);
|
|
86
|
+
c.roundRect(ex - e.w / 2, ey - eh / 2, e.w, eh, Math.min(e.w, eh) / 2);
|
|
87
|
+
c.fillStyle = k.line; c.fill();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (p.hat) floDrawHat(c, p, k);
|
|
91
|
+
c.restore();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// The hard hat: dome, brim and centre ridge, sized to the ring. In dark the hat has no outline.
|
|
95
|
+
function floDrawHat(c, p, k) {
|
|
96
|
+
const r = p.r, h = p.hat, lw = k.hatLine === k.hat ? 0 : 0.167 * r;
|
|
97
|
+
c.save();
|
|
98
|
+
c.globalAlpha *= 1 - floClamp((h.lift - 0.5) / 0.5); // lifted fully away = gone
|
|
99
|
+
c.translate(-0.9 * r, -0.8 * r + h.dy - h.lift * 2.2 * r); // pivot near the brim's left end: a tip reads as a tip
|
|
100
|
+
c.rotate(h.rot); c.translate(0.9 * r, 0.8 * r);
|
|
101
|
+
c.beginPath(); c.moveTo(-0.958 * r, -0.958 * r);
|
|
102
|
+
c.bezierCurveTo(-0.958 * r, -1.625 * r, -0.542 * r, -1.917 * r, 0, -1.917 * r);
|
|
103
|
+
c.bezierCurveTo(0.542 * r, -1.917 * r, 0.958 * r, -1.625 * r, 0.958 * r, -0.958 * r); c.closePath();
|
|
104
|
+
c.fillStyle = k.hat; c.fill(); if (lw) { c.lineWidth = lw; c.strokeStyle = k.hatLine; c.stroke(); }
|
|
105
|
+
c.beginPath(); c.roundRect(-1.25 * r, -1.083 * r, 2.5 * r, 0.292 * r, 0.146 * r);
|
|
106
|
+
c.fillStyle = k.hat; c.fill(); if (lw) { c.lineWidth = lw; c.strokeStyle = k.hatLine; c.stroke(); }
|
|
107
|
+
c.beginPath(); c.moveTo(0, -1.79 * r); c.lineTo(0, -1.125 * r);
|
|
108
|
+
c.lineWidth = 0.167 * r; c.strokeStyle = k.line; c.stroke();
|
|
109
|
+
c.restore();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// floLogoPose(t, period): where the light pulse is along the S (a dash offset, icon units), how much the
|
|
113
|
+
// top node pops, and which circle has the eyes. The pulse runs from the S's end to its start over 70% of
|
|
114
|
+
// the period and lands on the Agent circle. The eyes hop just after it lands (at 95% of a period): they
|
|
115
|
+
// close over 4% of a period and open in the next circle over the next 4%, so frame 0 shows them open.
|
|
116
|
+
function floLogoPose(t, period = FLO_PULSE_PERIOD) {
|
|
117
|
+
const u = floMod(t, period) / period, travel = floClamp(u / 0.7), L = FLO_ICON.sLength;
|
|
118
|
+
const ease = travel < 0.5 ? 2 * travel * travel : 1 - Math.pow(-2 * travel + 2, 2) / 2;
|
|
119
|
+
const slot = floMod(t, period * 3) / period + 0.05, v = slot - Math.floor(slot);
|
|
120
|
+
const node = FLO_EYE_TOUR[Math.floor(slot) % 3];
|
|
121
|
+
const open = Math.min(floClamp(v / 0.04), floClamp((1 - v) / 0.04));
|
|
122
|
+
return { dashOffset: -L + ease * (L + 12), visible: travel < 1, pop: u < 0.68 ? 0 : floBump((u - 0.68) / 0.22), eyes: { node, open } };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// drawFloLogo(c, o): the living logo, top-left at (o.x, o.y), o.size px wide. o.eyes / o.pulse default true;
|
|
126
|
+
// o.eyesAt pins the eyes to one circle ('workspace' | 'workflow' | 'agent'), fully open, instead of the tour.
|
|
127
|
+
function drawFloLogo(c, o = {}) {
|
|
128
|
+
const k = o.colors ?? FLO_COLORS[o.theme === 'light' ? 'light' : 'dark'], s = (o.size ?? FLO_ICON.w) / FLO_ICON.w, t = o.t ?? 0;
|
|
129
|
+
const lp = floLogoPose(t, o.period);
|
|
130
|
+
c.save(); c.translate(o.x ?? 0, o.y ?? 0); c.scale(s, s);
|
|
131
|
+
c.lineCap = 'round'; c.lineJoin = 'round'; c.strokeStyle = k.line; c.lineWidth = FLO_ICON.line;
|
|
132
|
+
const S = new Path2D(FLO_ICON.s);
|
|
133
|
+
c.stroke(S);
|
|
134
|
+
for (const a of FLO_ICON.arrows) c.stroke(new Path2D(a));
|
|
135
|
+
c.lineCap = 'butt'; c.stroke(new Path2D(FLO_ICON.shaft)); c.lineCap = 'round';
|
|
136
|
+
if (o.pulse !== false && lp.visible) {
|
|
137
|
+
c.save(); c.setLineDash([12, FLO_ICON.sLength + 40]); c.lineDashOffset = lp.dashOffset;
|
|
138
|
+
c.lineWidth = FLO_ICON.line * 0.5; c.strokeStyle = k.pulse; c.stroke(S); c.restore();
|
|
139
|
+
}
|
|
140
|
+
const eyesAt = o.eyes === false ? null : (o.eyesAt ?? lp.eyes.node), open = o.eyesAt ? 1 : lp.eyes.open;
|
|
141
|
+
for (const [name, [nx, ny]] of Object.entries(FLO_ICON.nodes)) {
|
|
142
|
+
const q = name === 'agent' ? 1 + 0.2 * lp.pop : 1; // the pulse lands on the Agent circle
|
|
143
|
+
if (name === eyesAt) {
|
|
144
|
+
drawFlo(c, { x: nx, y: ny, r: FLO_ICON.ringR, stroke: FLO_ICON.ringLine, t, theme: o.theme, colors: o.colors, open, squash: [q, 2 - q] });
|
|
145
|
+
} else {
|
|
146
|
+
c.save(); c.translate(nx, ny + FLO_ICON.ringR); c.scale(q, 2 - q); c.translate(0, -FLO_ICON.ringR);
|
|
147
|
+
c.beginPath(); c.arc(0, 0, FLO_ICON.ringR, 0, 2 * Math.PI);
|
|
148
|
+
c.fillStyle = k.fill; c.fill(); c.lineWidth = FLO_ICON.ringLine; c.strokeStyle = k.line; c.stroke(); c.restore();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
c.restore();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (typeof module !== 'undefined' && module.exports) {
|
|
155
|
+
module.exports = { FLO_COLORS, FLO_MOODS, FLO_ICON, FLO_EYE_TOUR, floPose, floLogoPose, drawFlo, drawFloLogo };
|
|
156
|
+
}
|