@jossuealcala/madre 1.1.2 → 1.1.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/CHANGELOG.en.md +40 -1
- package/CHANGELOG.md +40 -1
- package/README.en.md +3 -3
- package/README.md +3 -3
- package/SECURITY.md +11 -6
- package/TRADEMARKS.md +6 -2
- package/bin/madre.mjs +76 -11
- package/docs/REFERENCE.md +16 -10
- package/docs/SDK.md +36 -9
- package/docs/en/REFERENCE.md +12 -8
- package/docs/en/SDK.md +34 -8
- package/docs/en/training/README.md +1 -1
- package/docs/sdk/connector-module.mjs +1 -1
- package/docs/sdk/hello-module.mjs +39 -4
- package/docs/training/README.md +1 -1
- package/docs/training/train.sh +3 -0
- package/habilidades/explicamelo-facil/HABILIDAD.md +19 -0
- package/habilidades/hojas-de-calculo/HABILIDAD.md +18 -0
- package/habilidades/mensajes-a-clientes/HABILIDAD.md +19 -0
- package/habilidades/publicaciones-para-redes/HABILIDAD.md +19 -0
- package/habilidades/resumen-y-pendientes/HABILIDAD.md +18 -0
- package/habilidades/tu-pagina-paso-a-paso/HABILIDAD.md +19 -0
- package/package.json +7 -4
- package/public/activity.js +66 -22
- package/public/app.js +4947 -894
- package/public/assets/brand/OFL-SpaceGrotesk.txt +93 -0
- package/public/assets/brand/SpaceGrotesk-latin-ext.woff2 +0 -0
- package/public/assets/brand/SpaceGrotesk-latin.woff2 +0 -0
- package/public/assets/brand/madre-app-180.png +0 -0
- package/public/assets/brand/madre-app-192.png +0 -0
- package/public/assets/brand/madre-app-512.png +0 -0
- package/public/assets/brand/madre-app.svg +1 -1
- package/public/assets/brand/madre-favicon.svg +1 -1
- package/public/attribution.js +29 -19
- package/public/auto-open.js +102 -0
- package/public/brands.js +36 -19
- package/public/changes.js +63 -0
- package/public/en.js +1085 -102
- package/public/es.js +2940 -1656
- package/public/i18n.js +11 -0
- package/public/index.html +31 -27
- package/public/loader.js +322 -117
- package/public/macroverso.js +57 -355
- package/public/manual-content.js +69 -9
- package/public/manual.js +21 -6
- package/public/market-view.js +298 -84
- package/public/market.js +25 -2
- package/public/mcp-catalog.js +7 -2
- package/public/missions.js +169 -0
- package/public/news-scenes.js +292 -0
- package/public/nostromo-engine.js +935 -654
- package/public/notices.js +78 -0
- package/public/notifications.js +119 -0
- package/public/power.js +1 -1
- package/public/provider-marks.js +170 -0
- package/public/provider-pick.js +147 -0
- package/public/resay.js +4 -0
- package/public/review-ask.js +16 -13
- package/public/routing.js +29 -3
- package/public/salas-mac.css +467 -47
- package/public/salas-mac.html +8 -5
- package/public/salas-mac.js +805 -109
- package/public/salas.css +2 -2
- package/public/salas.html +2 -2
- package/public/salas.js +1 -1
- package/public/starters.js +128 -0
- package/public/styles.css +3036 -340
- package/public/subscription.js +303 -0
- package/public/terms-field.js +170 -0
- package/public/terms.js +117 -19
- package/public/tips.js +158 -0
- package/public/tour-chapters.js +88 -88
- package/public/tour.js +364 -46
- package/public/troubleshooting.js +313 -27
- package/public/welcome-scene.js +446 -0
- package/public/welcome.js +827 -282
- package/src/adapters/claude.mjs +2 -1
- package/src/adapters/codex.mjs +2 -1
- package/src/adapters/cursor.mjs +9 -6
- package/src/adapters/gemini-rest.mjs +236 -0
- package/src/adapters/gemini.mjs +13 -7
- package/src/adapters/grok.mjs +290 -0
- package/src/adapters/madre.mjs +71 -23
- package/src/adapters/opencode.mjs +15 -2
- package/src/adapters/process.mjs +14 -3
- package/src/adapters/steps.mjs +176 -0
- package/src/app-invite.mjs +90 -0
- package/src/auth-probe.mjs +32 -0
- package/src/billing-key.mjs +8 -0
- package/src/billing.mjs +317 -0
- package/src/bridge/policy.mjs +1 -1
- package/src/capabilities.mjs +46 -10
- package/src/chats.mjs +44 -2
- package/src/checkpoint.mjs +119 -1
- package/src/codex-route.mjs +113 -0
- package/src/commands.mjs +5 -2
- package/src/credentials.mjs +46 -8
- package/src/dataset.mjs +18 -7
- package/src/directives.mjs +1 -0
- package/src/event-store.mjs +25 -2
- package/src/extensions.mjs +5 -1
- package/src/ficha.mjs +158 -0
- package/src/files.mjs +36 -2
- package/src/image-studio.mjs +13 -3
- package/src/install-metrics.mjs +9 -3
- package/src/lease.mjs +6 -1
- package/src/looks.mjs +4 -1
- package/src/market-check.mjs +1 -1
- package/src/market-remote.mjs +135 -1
- package/src/mcp/image-server.mjs +59 -90
- package/src/mcp/memory-server.mjs +10 -0
- package/src/memory-tools.mjs +3 -0
- package/src/memory.mjs +29 -4
- package/src/models.mjs +21 -3
- package/src/modules/ahp.mjs +10 -4
- package/src/modules/bishop-exam.mjs +41 -12
- package/src/modules/bishop.mjs +2 -2
- package/src/modules/choices.mjs +12 -10
- package/src/modules/fetch-alone.mjs +7 -0
- package/src/modules/github.mjs +6 -2
- package/src/modules/helpers.mjs +23 -5
- package/src/modules/image-providers.mjs +281 -0
- package/src/modules/image-studio.mjs +106 -39
- package/src/modules/index.mjs +61 -12
- package/src/modules/intents-observe.mjs +3 -1
- package/src/modules/isolated.mjs +160 -0
- package/src/modules/ollama.mjs +35 -6
- package/src/modules/playwright.mjs +78 -20
- package/src/modules/reminders.mjs +42 -2
- package/src/modules/ripley.mjs +2 -1
- package/src/modules/run-alone.mjs +122 -0
- package/src/modules/runs.mjs +11 -8
- package/src/modules/sdk.mjs +10 -3
- package/src/notices-key.mjs +8 -0
- package/src/notices.mjs +185 -0
- package/src/ollama.mjs +57 -15
- package/src/opencode-health.mjs +1 -1
- package/src/outbound.mjs +124 -13
- package/src/quota-sources.mjs +148 -3
- package/src/review-ask.mjs +55 -31
- package/src/room/archivist.mjs +30 -5
- package/src/room/busy.mjs +16 -0
- package/src/room/changes.mjs +79 -0
- package/src/room/control.mjs +36 -6
- package/src/room/economy.mjs +1 -1
- package/src/room/guard.mjs +39 -2
- package/src/room/prompt.mjs +49 -6
- package/src/room/vectors.mjs +7 -1
- package/src/room.mjs +181 -49
- package/src/router.mjs +1 -1
- package/src/runs.mjs +39 -0
- package/src/runtime-detection.mjs +46 -6
- package/src/salas.mjs +181 -18
- package/src/server.mjs +1101 -118
- package/src/service.mjs +116 -0
- package/src/setup-trouble.mjs +20 -1
- package/src/setup.mjs +1 -1
- package/src/skill-check.mjs +269 -0
- package/src/skills-import.mjs +128 -0
- package/src/skills.mjs +502 -0
- package/src/terms.mjs +23 -5
- package/src/tour.mjs +31 -5
- package/src/updates.mjs +47 -4
- package/src/web-preview.mjs +181 -0
- package/src/whats-new.mjs +121 -1
- package/src/rumbo.mjs +0 -337
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BUSL-1.1
|
|
2
|
+
// MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
|
|
3
|
+
// THE WELCOME'S STAGE (1.1, 2026-11-08, docs/private/BIENVENIDA-1.1.md): one abstract picture above
|
|
4
|
+
// every step, so the welcome reads as one story and not as six forms. No words, no logos, no
|
|
5
|
+
// drawings of things: a field of points of light that takes a new shape at each step, and MADRE's
|
|
6
|
+
// DOT (the logo's, «MADRE is ready») at the centre of it all.
|
|
7
|
+
//
|
|
8
|
+
// The same points travel from one step to the next — they are never thrown away and made again —
|
|
9
|
+
// so every change of step is the field rearranging itself, not a cut:
|
|
10
|
+
//
|
|
11
|
+
// hello a cloud the computer is read through: a soft wave crosses it; once read, it settles
|
|
12
|
+
// into a calm halo round the dot
|
|
13
|
+
// use five nebulae round the dot; the ones the person marks grow, brighten and come closer
|
|
14
|
+
// agents one small constellation per AI, round the dot; a connected one sends light to it
|
|
15
|
+
// project threads from the edge, one per folder chosen, gathering into a ring round the dot
|
|
16
|
+
// ai the points fall in a slow spiral into a core while it downloads, a fine arc saying how
|
|
17
|
+
// much; once there, they settle in three quiet orbits
|
|
18
|
+
// ready the points draw the logo's M, whole, above the dot, fed from the edge; then a
|
|
19
|
+
// message bubble opens beside the dot and its words are written in, the caret waiting
|
|
20
|
+
//
|
|
21
|
+
// MADRE's own style, from its brand book (madre-landing/brand-kit): the phosphor is the only colour
|
|
22
|
+
// and means something; nothing spins fast, bounces or glows like neon; changes take about 0.4 s and
|
|
23
|
+
// settle softly. It follows the look the person has on — light or dark, as their system or their
|
|
24
|
+
// Settings say (`data-scheme` on the page) — and changes with it. A person who asked for less
|
|
25
|
+
// motion gets each picture still, in its final shape.
|
|
26
|
+
|
|
27
|
+
const N = 220;
|
|
28
|
+
const RIPPLE = 2.6; // s between two heartbeats of the dot
|
|
29
|
+
|
|
30
|
+
const clamp01 = (x) => Math.max(0, Math.min(1, x));
|
|
31
|
+
const frac = (x) => x - Math.floor(x);
|
|
32
|
+
const easeInOut = (x) => { const v = clamp01(x); return v < 0.5 ? 4 * v * v * v : 1 - Math.pow(-2 * v + 2, 3) / 2; };
|
|
33
|
+
const hash = (n) => frac(Math.sin(n * 127.1 + 311.7) * 43758.5453);
|
|
34
|
+
|
|
35
|
+
const bezier = (a, c, b, q) => (1 - q) * (1 - q) * a + 2 * (1 - q) * q * c + q * q * b;
|
|
36
|
+
|
|
37
|
+
// The two looks. In the dark the light adds up, as light does; in the light the points are ink.
|
|
38
|
+
const LOOKS = {
|
|
39
|
+
dark: { ground: [5, 6, 5], ink: [52, 211, 153], soft: [238, 241, 234], glow: 0.075, scan: 0.03, blend: 'lighter', halo: 0.34 },
|
|
40
|
+
light: { ground: [238, 240, 234], ink: [5, 150, 105], soft: [18, 21, 18], glow: 0.06, scan: 0, blend: 'source-over', halo: 0.18 },
|
|
41
|
+
};
|
|
42
|
+
const rgba = ([r, g, b], a) => `rgba(${r},${g},${b},${clamp01(a)})`;
|
|
43
|
+
|
|
44
|
+
// One point of light, drawn once and stamped: a solid core and a short soft halo, never a blur.
|
|
45
|
+
function spriteOf(ink, halo) {
|
|
46
|
+
const size = 64;
|
|
47
|
+
const canvas = document.createElement('canvas');
|
|
48
|
+
canvas.width = size;
|
|
49
|
+
canvas.height = size;
|
|
50
|
+
const ctx = canvas.getContext('2d');
|
|
51
|
+
if (!ctx) return canvas;
|
|
52
|
+
const g = ctx.createRadialGradient(size / 2, size / 2, 0, size / 2, size / 2, size / 2);
|
|
53
|
+
g.addColorStop(0, rgba(ink, 1));
|
|
54
|
+
g.addColorStop(0.18, rgba(ink, 1));
|
|
55
|
+
g.addColorStop(0.3, rgba(ink, halo));
|
|
56
|
+
g.addColorStop(1, rgba(ink, 0));
|
|
57
|
+
ctx.fillStyle = g;
|
|
58
|
+
ctx.fillRect(0, 0, size, size);
|
|
59
|
+
return canvas;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function createScene({ still = globalThis.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false } = {}) {
|
|
63
|
+
const node = document.createElement('figure');
|
|
64
|
+
node.className = 'wl-scene';
|
|
65
|
+
node.setAttribute('aria-hidden', 'true');
|
|
66
|
+
const canvas = document.createElement('canvas');
|
|
67
|
+
const caption = document.createElement('figcaption');
|
|
68
|
+
caption.className = 'wl-scene-cap';
|
|
69
|
+
const words = document.createElement('span');
|
|
70
|
+
caption.append(words);
|
|
71
|
+
node.append(canvas, caption);
|
|
72
|
+
const ctx = canvas.getContext?.('2d') ?? null;
|
|
73
|
+
|
|
74
|
+
let w = 0;
|
|
75
|
+
let h = 0;
|
|
76
|
+
let dpr = 1;
|
|
77
|
+
let frame = 0;
|
|
78
|
+
let scene = { id: 'hello', data: () => ({}), since: 0 };
|
|
79
|
+
const dot = { a: 0, r: 4.5 }; // the dot, eased like the points
|
|
80
|
+
let look = null;
|
|
81
|
+
let ground = null; // the ground's colour now, eased between looks
|
|
82
|
+
let sprite = null;
|
|
83
|
+
const parts = Array.from({ length: N }, (_, i) => ({
|
|
84
|
+
i, seed: hash(i + 1), seed2: hash(i + 1000), z: 0.35 + 0.65 * hash(i + 2000),
|
|
85
|
+
x: 0, y: 0, vx: 0, vy: 0, a: 0, s: 1,
|
|
86
|
+
}));
|
|
87
|
+
let placed = false;
|
|
88
|
+
|
|
89
|
+
const readLook = () => {
|
|
90
|
+
const next = LOOKS[document.documentElement.dataset.scheme === 'light' ? 'light' : 'dark'];
|
|
91
|
+
if (next === look) return;
|
|
92
|
+
look = next;
|
|
93
|
+
ground ??= [...look.ground];
|
|
94
|
+
sprite = spriteOf(look.ink, look.halo);
|
|
95
|
+
};
|
|
96
|
+
readLook();
|
|
97
|
+
// The look changes when the person or their system changes it: the picture goes with it.
|
|
98
|
+
const watcher = typeof MutationObserver === 'function' ? new MutationObserver(() => { readLook(); redraw(); }) : null;
|
|
99
|
+
watcher?.observe(document.documentElement, { attributes: true, attributeFilter: ['data-scheme'] });
|
|
100
|
+
|
|
101
|
+
function fit() {
|
|
102
|
+
const box = node.getBoundingClientRect();
|
|
103
|
+
if (!box.width) return;
|
|
104
|
+
dpr = Math.min(2, globalThis.devicePixelRatio || 1);
|
|
105
|
+
w = box.width;
|
|
106
|
+
h = box.height;
|
|
107
|
+
canvas.width = Math.round(w * dpr);
|
|
108
|
+
canvas.height = Math.round(h * dpr);
|
|
109
|
+
if (!placed) {
|
|
110
|
+
for (const p of parts) { p.x = w / 2 + (p.seed - 0.5) * w * 0.9; p.y = h / 2 + (p.seed2 - 0.5) * h * 0.8; }
|
|
111
|
+
placed = true;
|
|
112
|
+
}
|
|
113
|
+
redraw();
|
|
114
|
+
}
|
|
115
|
+
const observer = typeof ResizeObserver === 'function' ? new ResizeObserver(fit) : null;
|
|
116
|
+
observer?.observe(node);
|
|
117
|
+
|
|
118
|
+
// ---- Where each point wants to be in each picture: [x, y, brightness, size]. Every picture keeps
|
|
119
|
+
// the dot in the same place, a little above the middle, so the eye has one place to rest.
|
|
120
|
+
const centre = () => ({ cx: w * 0.5, cy: h * 0.44, R: Math.min(h * 0.32, w * 0.16) });
|
|
121
|
+
const drift = (p, t, k = 1) => [Math.sin(t * 0.5 + p.seed * 40) * 3 * k * p.z, Math.cos(t * 0.42 + p.seed2 * 40) * 2.4 * k * p.z];
|
|
122
|
+
// The `ready` picture's line: flat, then the logo's M (the rebranding, 2026-11-13), its right leg
|
|
123
|
+
// ending just above the dot, as in the logo. `at(u)` walks it by its length.
|
|
124
|
+
const ON_LINE = 204;
|
|
125
|
+
const cub = (a, b, c, d, n) => Array.from({ length: n }, (_, i) => { const q = (i + 1) / n, r = 1 - q; return [r * r * r * a[0] + 3 * r * r * q * b[0] + 3 * r * q * q * c[0] + q * q * q * d[0], r * r * r * a[1] + 3 * r * r * q * b[1] + 3 * r * q * q * c[1] + q * q * q * d[1]]; });
|
|
126
|
+
const M_POINTS = [[20, 82], [20, 42], ...cub([20, 42], [20, 21], [41, 21], [46, 39], 12), [50, 52], [54, 39], ...cub([54, 39], [59, 21], [80, 21], [80, 42], 12), [80, 60]];
|
|
127
|
+
function pulseLine() {
|
|
128
|
+
const { cx, cy } = centre();
|
|
129
|
+
const x0 = Math.max(18, w * 0.07);
|
|
130
|
+
// The M's top (its arches, 55 above the dot) stays inside the picture with room to spare: sized
|
|
131
|
+
// by the width alone it rose out of the card (2026-11-13).
|
|
132
|
+
const k = Math.min((cy - 16) / 55, (cx - x0) * 0.9 / 61);
|
|
133
|
+
const place = ([mx, my]) => [cx + (mx - 80) * k, cy + (my - 81) * k];
|
|
134
|
+
const m = M_POINTS.map(place);
|
|
135
|
+
const bx = m[0][0];
|
|
136
|
+
const points = [[x0, m[0][1]], ...m];
|
|
137
|
+
const lengths = [0];
|
|
138
|
+
for (let i = 1; i < points.length; i += 1) lengths.push(lengths[i - 1] + Math.hypot(points[i][0] - points[i - 1][0], points[i][1] - points[i - 1][1]));
|
|
139
|
+
const total = lengths[lengths.length - 1] || 1;
|
|
140
|
+
const at = (u) => {
|
|
141
|
+
const d = clamp01(u) * total;
|
|
142
|
+
let i = 1;
|
|
143
|
+
while (i < lengths.length - 1 && lengths[i] < d) i += 1;
|
|
144
|
+
const q = (d - lengths[i - 1]) / ((lengths[i] - lengths[i - 1]) || 1);
|
|
145
|
+
return [points[i - 1][0] + (points[i][0] - points[i - 1][0]) * q, points[i - 1][1] + (points[i][1] - points[i - 1][1]) * q];
|
|
146
|
+
};
|
|
147
|
+
return { x0, x1: m[m.length - 1][0], bx, cy: m[0][1], at };
|
|
148
|
+
}
|
|
149
|
+
// The first message, after the line reaches the dot: a bubble opens to the right of it and its
|
|
150
|
+
// words are written in, as the shape of text (never letters), with a caret that waits at the end.
|
|
151
|
+
// Its words' widths are fixed once, so the message is always the same shape.
|
|
152
|
+
const NOTE_WORDS = [0, 1, 2].map((row) => Array.from({ length: 9 }, (_, k) => 16 + Math.round(hash(row * 31 + k + 7) * 38)));
|
|
153
|
+
function paintNote(data, age) {
|
|
154
|
+
if (scene.id !== 'ready' || !data.note) return;
|
|
155
|
+
const { cx, cy } = centre();
|
|
156
|
+
const open = still ? 1 : easeInOut((age - 1.35) / 0.55);
|
|
157
|
+
if (open <= 0) return;
|
|
158
|
+
const left = cx + 22;
|
|
159
|
+
const right = Math.min(w - 18, left + Math.max(140, w * 0.38));
|
|
160
|
+
const rows = [0.92, 0.74, 0.46];
|
|
161
|
+
const lineH = Math.min(15, h * 0.1);
|
|
162
|
+
const top = cy - lineH * 1.5 - 9;
|
|
163
|
+
const height = lineH * 3 + 18;
|
|
164
|
+
const width = (right - left) * (0.35 + 0.65 * open);
|
|
165
|
+
// The bubble: a fine edge and the faintest fill, its corner nearest the dot pointing at it.
|
|
166
|
+
ctx.globalAlpha = open;
|
|
167
|
+
ctx.fillStyle = rgba(look.ink, look === LOOKS.light ? 0.05 : 0.06);
|
|
168
|
+
ctx.strokeStyle = rgba(look.ink, 0.32);
|
|
169
|
+
ctx.lineWidth = 1;
|
|
170
|
+
const r = 10;
|
|
171
|
+
ctx.beginPath();
|
|
172
|
+
ctx.moveTo(left + 4, cy);
|
|
173
|
+
ctx.lineTo(left + 4, top + r);
|
|
174
|
+
ctx.quadraticCurveTo(left + 4, top, left + 4 + r, top);
|
|
175
|
+
ctx.lineTo(left + width - r, top);
|
|
176
|
+
ctx.quadraticCurveTo(left + width, top, left + width, top + r);
|
|
177
|
+
ctx.lineTo(left + width, top + height - r);
|
|
178
|
+
ctx.quadraticCurveTo(left + width, top + height, left + width - r, top + height);
|
|
179
|
+
ctx.lineTo(left + 4 + r, top + height);
|
|
180
|
+
ctx.quadraticCurveTo(left + 4, top + height, left + 4, top + height - r);
|
|
181
|
+
ctx.lineTo(left + 4, cy + 5);
|
|
182
|
+
ctx.lineTo(left - 2, cy);
|
|
183
|
+
ctx.closePath();
|
|
184
|
+
ctx.fill();
|
|
185
|
+
ctx.stroke();
|
|
186
|
+
// The words, written in one after another.
|
|
187
|
+
const room = width - 28;
|
|
188
|
+
const total = rows.reduce((sum, share) => sum + share * room, 0);
|
|
189
|
+
let written = (still ? 1 : easeInOut((age - 1.75) / 1.9)) * total;
|
|
190
|
+
let caret = null;
|
|
191
|
+
ctx.lineCap = 'round';
|
|
192
|
+
ctx.lineWidth = Math.max(3, lineH * 0.34);
|
|
193
|
+
rows.forEach((share, row) => {
|
|
194
|
+
const y = top + 9 + lineH * (row + 0.5);
|
|
195
|
+
let x = left + 18;
|
|
196
|
+
const end = left + 18 + share * room;
|
|
197
|
+
for (const word of NOTE_WORDS[row]) {
|
|
198
|
+
if (x >= end || written <= 0) break;
|
|
199
|
+
const full = Math.min(word, end - x);
|
|
200
|
+
const len = Math.min(full, written);
|
|
201
|
+
ctx.strokeStyle = rgba(look.soft, 0.22);
|
|
202
|
+
ctx.beginPath(); ctx.moveTo(x, y); ctx.lineTo(x + Math.max(0.1, len), y); ctx.stroke();
|
|
203
|
+
written -= full + 7;
|
|
204
|
+
caret = [x + len + 5, y];
|
|
205
|
+
x += full + 7;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
// The caret waits where the writing stopped: the person only has to send it.
|
|
209
|
+
if (caret && (still || frac(age * 0.9) < 0.6)) {
|
|
210
|
+
ctx.strokeStyle = rgba(look.ink, 0.9);
|
|
211
|
+
ctx.lineWidth = 1.6;
|
|
212
|
+
ctx.beginPath(); ctx.moveTo(caret[0], caret[1] - lineH * 0.45); ctx.lineTo(caret[0], caret[1] + lineH * 0.45); ctx.stroke();
|
|
213
|
+
}
|
|
214
|
+
ctx.globalAlpha = 1;
|
|
215
|
+
ctx.lineCap = 'butt';
|
|
216
|
+
}
|
|
217
|
+
const PICTURES = {
|
|
218
|
+
hello(p, t, data) {
|
|
219
|
+
const { cx, cy, R } = centre();
|
|
220
|
+
const [dx, dy] = drift(p, t);
|
|
221
|
+
if (!data.scanned) {
|
|
222
|
+
// A wide soft cloud, and a wave that crosses it, as if the computer were read line by line.
|
|
223
|
+
const ang = p.seed * Math.PI * 2;
|
|
224
|
+
const rad = Math.sqrt(p.seed2);
|
|
225
|
+
const x = cx + Math.cos(ang) * rad * w * 0.36;
|
|
226
|
+
const y = cy + Math.sin(ang) * rad * R * 1.25;
|
|
227
|
+
const sweep = w * (0.08 + 0.84 * frac(t * 0.24));
|
|
228
|
+
const near = Math.exp(-(((x - sweep) / 46) ** 2));
|
|
229
|
+
return [x + dx, y + dy - near * 7, 0.14 + 0.7 * near, 1 + near * 0.9];
|
|
230
|
+
}
|
|
231
|
+
// Read: the cloud gathers into a calm halo round the dot.
|
|
232
|
+
const ang = p.seed * Math.PI * 2 + t * 0.04;
|
|
233
|
+
const ring = R * (1.05 + (p.seed2 - 0.5) ** 2 * 2);
|
|
234
|
+
return [cx + Math.cos(ang) * ring * 1.9 + dx, cy + Math.sin(ang) * ring * 0.62 + dy, 0.22 + 0.45 * (1 - p.seed2), 1];
|
|
235
|
+
},
|
|
236
|
+
use(p, t, data) {
|
|
237
|
+
const { cx, cy, R } = centre();
|
|
238
|
+
const items = data.items ?? [];
|
|
239
|
+
const k = items.length ? p.i % items.length : 0;
|
|
240
|
+
const on = Boolean(items[k]?.on);
|
|
241
|
+
// Five nebulae on an ellipse round the dot; a marked one comes a third of the way in.
|
|
242
|
+
const ang = -Math.PI / 2 + ((k + 0.5) / Math.max(1, items.length)) * Math.PI * 2;
|
|
243
|
+
const pull = on ? 0.66 : 1;
|
|
244
|
+
const nx = cx + Math.cos(ang) * w * 0.34 * pull;
|
|
245
|
+
const ny = cy + Math.sin(ang) * R * 1.05 * pull;
|
|
246
|
+
// A few points of a marked nebula carry light to the dot.
|
|
247
|
+
if (on && p.seed < 0.16) {
|
|
248
|
+
const q = frac(t * 0.3 + p.seed2 * 3);
|
|
249
|
+
const bend = (p.seed2 - 0.5) * 40;
|
|
250
|
+
return [bezier(nx, (nx + cx) / 2 + bend, cx, easeInOut(q)), bezier(ny, (ny + cy) / 2 - bend, cy, easeInOut(q)), 0.9 * Math.sin(q * Math.PI), 1.1];
|
|
251
|
+
}
|
|
252
|
+
const [dx, dy] = drift(p, t, on ? 1.4 : 0.8);
|
|
253
|
+
const spread = (on ? 26 : 14) * Math.sqrt(p.seed2);
|
|
254
|
+
const a2 = p.seed2 * 40 + t * (on ? 0.12 : 0.05);
|
|
255
|
+
return [nx + Math.cos(a2) * spread * 1.3 + dx, ny + Math.sin(a2) * spread + dy, on ? 0.45 + 0.45 * (1 - p.seed2) : 0.13, on ? 1.15 : 0.85];
|
|
256
|
+
},
|
|
257
|
+
agents(p, t, data) {
|
|
258
|
+
const { cx, cy, R } = centre();
|
|
259
|
+
const items = data.items ?? [];
|
|
260
|
+
const n = Math.max(1, items.length);
|
|
261
|
+
const k = p.i % n;
|
|
262
|
+
const on = Boolean(items[k]?.on);
|
|
263
|
+
const ang = -Math.PI / 2 + ((k + 0.25) / n) * Math.PI * 2;
|
|
264
|
+
const nx = cx + Math.cos(ang) * w * 0.38;
|
|
265
|
+
const ny = cy + Math.sin(ang) * R * 1.1;
|
|
266
|
+
// A connected AI sends a stream of light along a gentle curve into the dot.
|
|
267
|
+
if (on && p.seed < 0.42) {
|
|
268
|
+
const q = frac(t * 0.26 + p.seed2 * 2);
|
|
269
|
+
const bend = Math.cos(ang) * 26;
|
|
270
|
+
return [bezier(nx, (nx + cx) / 2, cx, easeInOut(q)), bezier(ny, (ny + cy) / 2 + bend, cy, easeInOut(q)), 0.75 * Math.sin(q * Math.PI) ** 0.7, 0.95];
|
|
271
|
+
}
|
|
272
|
+
const [dx, dy] = drift(p, t, 0.7);
|
|
273
|
+
const spread = (on ? 13 : 8) * Math.sqrt(p.seed2);
|
|
274
|
+
const a2 = p.seed2 * 40 + t * 0.1;
|
|
275
|
+
return [nx + Math.cos(a2) * spread + dx, ny + Math.sin(a2) * spread * 0.8 + dy, on ? 0.6 + 0.3 * (1 - p.seed2) : 0.14, on ? 1.1 : 0.8];
|
|
276
|
+
},
|
|
277
|
+
project(p, t, data) {
|
|
278
|
+
const { cx, cy, R } = centre();
|
|
279
|
+
const n = Math.min(8, data.count ?? 0);
|
|
280
|
+
// The ring round the dot: fuller with every folder that comes.
|
|
281
|
+
const ringShare = 0.12 + 0.07 * n;
|
|
282
|
+
const ringAng = p.seed * Math.PI * 2 + t * 0.06;
|
|
283
|
+
const ringR = R * (0.9 + 0.22 * (p.seed2 - 0.5));
|
|
284
|
+
const ring = [cx + Math.cos(ringAng) * ringR * 1.75, cy + Math.sin(ringAng) * ringR * 0.55];
|
|
285
|
+
if (!n) { const [dx, dy] = drift(p, t); return [ring[0] + dx * 3, ring[1] + dy * 3, p.seed2 < 0.4 ? 0.14 : 0, 0.8]; }
|
|
286
|
+
if (p.seed2 < ringShare) return [ring[0], ring[1], 0.28 + 0.4 * p.z, 0.95];
|
|
287
|
+
// Threads: one from each folder chosen, coming in from the left edge, joining the ring.
|
|
288
|
+
const k = p.i % n;
|
|
289
|
+
const sy = h * (0.14 + (n === 1 ? 0.3 : (k / (n - 1)) * 0.6));
|
|
290
|
+
const q = frac(t * 0.17 + p.seed * 1.7);
|
|
291
|
+
const ex = cx - ringR * 1.75 * 0.98;
|
|
292
|
+
return [bezier(-10, w * 0.22, ex, easeInOut(q)), bezier(sy, sy, cy, easeInOut(q)), 0.62 * Math.sin(q * Math.PI) ** 0.6, 0.9];
|
|
293
|
+
},
|
|
294
|
+
ai(p, t, data) {
|
|
295
|
+
const { cx, cy, R } = centre();
|
|
296
|
+
const pct = clamp01((data.pct ?? 0) / 100);
|
|
297
|
+
if (data.state === 'ready') {
|
|
298
|
+
// Three quiet orbits, each a little more tilted, slower further out.
|
|
299
|
+
const shell = p.i % 3;
|
|
300
|
+
const r = R * (0.5 + shell * 0.26);
|
|
301
|
+
const ang = p.seed * Math.PI * 2 + t * (0.11 - shell * 0.025) * (shell === 1 ? -1 : 1);
|
|
302
|
+
const tilt = [0.32, 0.48, 0.62][shell];
|
|
303
|
+
return [cx + Math.cos(ang) * r * 1.6, cy + Math.sin(ang) * r * tilt, 0.25 + 0.5 * (0.5 + 0.5 * Math.sin(ang * 2 + t * 0.6)) * p.z, 0.95];
|
|
304
|
+
}
|
|
305
|
+
if (data.state === 'downloading') {
|
|
306
|
+
// Falling in, slowly, along a spiral: faster as more has arrived.
|
|
307
|
+
const q = frac(t * (0.12 + 0.18 * pct) + p.seed);
|
|
308
|
+
const r = R * (2.1 * (1 - q) + 0.28);
|
|
309
|
+
const ang = p.seed2 * Math.PI * 2 + q * 3.2;
|
|
310
|
+
return [cx + Math.cos(ang) * r * 1.5, cy + Math.sin(ang) * r * 0.6, 0.1 + 0.7 * q ** 1.4, 0.7 + 0.5 * q];
|
|
311
|
+
}
|
|
312
|
+
// Waiting, or left for later: a loose quiet disc.
|
|
313
|
+
const [dx, dy] = drift(p, t);
|
|
314
|
+
const ang = p.seed * Math.PI * 2;
|
|
315
|
+
const r = R * (0.6 + 1.3 * Math.sqrt(p.seed2));
|
|
316
|
+
return [cx + Math.cos(ang) * r * 1.6 + dx, cy + Math.sin(ang) * r * 0.55 + dy, data.state === 'skip' ? 0.07 : 0.15, 0.8];
|
|
317
|
+
},
|
|
318
|
+
ready(p, t, data, age) {
|
|
319
|
+
// The logo's M, whole and continuous: almost every point is on it, laid by its length so the
|
|
320
|
+
// steep strokes are as full as the flat ones. It draws itself from the left into the
|
|
321
|
+
// dot; a few points keep arriving along it from the edge — the AIs feeding the project — and a
|
|
322
|
+
// soft brightness runs along it the way a heartbeat travels. Then the first message (paintNote).
|
|
323
|
+
const line = pulseLine();
|
|
324
|
+
const drawn = still ? 1 : easeInOut(age / 1.5);
|
|
325
|
+
if (p.i >= ON_LINE) {
|
|
326
|
+
// The stream: from beyond the left edge, along the flat, into the start of the line.
|
|
327
|
+
const q = frac(t * 0.21 + p.seed * 1.9);
|
|
328
|
+
const x = line.x0 - w * 0.08 + (w * 0.08 + (line.bx - line.x0) * 0.9) * easeInOut(q);
|
|
329
|
+
return [x, line.cy + (p.seed2 - 0.5) * 6 * (1 - q), drawn * 0.7 * Math.sin(q * Math.PI) ** 0.8, 0.8];
|
|
330
|
+
}
|
|
331
|
+
const u = p.i / (ON_LINE - 1);
|
|
332
|
+
if (u > drawn) { const [x, y] = line.at(0); return [x, y, 0, 0.6]; }
|
|
333
|
+
const [x, y] = line.at(u);
|
|
334
|
+
const runner = Math.exp(-(((u - frac(t * 0.24)) / 0.05) ** 2));
|
|
335
|
+
return [x, y, 0.42 + 0.55 * runner, 0.62 + 0.38 * runner];
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
const dotOf = (id, data) => {
|
|
339
|
+
if (id === 'hello') return data.scanned ? 1 : 0;
|
|
340
|
+
if (id === 'use' || id === 'agents') return (data.items ?? []).some((one) => one.on) ? 1 : 0.45;
|
|
341
|
+
if (id === 'project') return data.count ? 1 : 0.45;
|
|
342
|
+
if (id === 'ai') return data.state === 'ready' ? 1 : data.state === 'downloading' ? 0.7 : data.state === 'skip' ? 0.3 : 0.5;
|
|
343
|
+
return 1;
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
// ---- Drawing.
|
|
347
|
+
function paintGround() {
|
|
348
|
+
ground = ground.map((v, i) => v + (look.ground[i] - v) * (still ? 1 : 0.12));
|
|
349
|
+
ctx.fillStyle = `rgb(${ground.map(Math.round).join(',')})`;
|
|
350
|
+
ctx.fillRect(0, 0, w, h);
|
|
351
|
+
const { cx, cy } = centre();
|
|
352
|
+
const glow = ctx.createRadialGradient(cx, cy, 0, cx, cy, Math.max(w, h) * 0.55);
|
|
353
|
+
glow.addColorStop(0, rgba(look.ink, look.glow));
|
|
354
|
+
glow.addColorStop(1, rgba(look.ink, 0));
|
|
355
|
+
ctx.fillStyle = glow;
|
|
356
|
+
ctx.fillRect(0, 0, w, h);
|
|
357
|
+
if (look.scan) { ctx.fillStyle = rgba(look.ink, look.scan); for (let y = 0; y < h; y += 4) ctx.fillRect(0, y, w, 1); }
|
|
358
|
+
}
|
|
359
|
+
function paintDot(t) {
|
|
360
|
+
if (dot.a < 0.01) return;
|
|
361
|
+
const { cx, cy } = centre();
|
|
362
|
+
// Its heartbeat: a fine ring that leaves it and fades, every few seconds.
|
|
363
|
+
if (!still) {
|
|
364
|
+
const beat = frac(t / RIPPLE);
|
|
365
|
+
ctx.strokeStyle = rgba(look.ink, dot.a * 0.45 * (1 - beat));
|
|
366
|
+
ctx.lineWidth = 1.2;
|
|
367
|
+
ctx.beginPath(); ctx.arc(cx, cy, dot.r + 4 + easeInOut(beat) * 26, 0, Math.PI * 2); ctx.stroke();
|
|
368
|
+
}
|
|
369
|
+
const r = dot.r * (1 + (still ? 0 : 0.16 * Math.exp(-(((frac(t / RIPPLE) * RIPPLE) / 0.25) ** 2))));
|
|
370
|
+
ctx.globalAlpha = dot.a;
|
|
371
|
+
ctx.drawImage(sprite, cx - r * 3.6, cy - r * 3.6, r * 7.2, r * 7.2);
|
|
372
|
+
ctx.globalAlpha = 1;
|
|
373
|
+
}
|
|
374
|
+
// The download's arc: a fine track round the core and how much of it is done.
|
|
375
|
+
function paintArc(data) {
|
|
376
|
+
if (scene.id !== 'ai' || data.state !== 'downloading') return;
|
|
377
|
+
const { cx, cy, R } = centre();
|
|
378
|
+
const r = R * 0.62;
|
|
379
|
+
ctx.lineWidth = 1.4;
|
|
380
|
+
ctx.lineCap = 'round';
|
|
381
|
+
ctx.strokeStyle = rgba(look.soft, 0.1);
|
|
382
|
+
ctx.beginPath(); ctx.arc(cx, cy, r, 0, Math.PI * 2); ctx.stroke();
|
|
383
|
+
ctx.strokeStyle = rgba(look.ink, 0.9);
|
|
384
|
+
ctx.beginPath(); ctx.arc(cx, cy, r, -Math.PI / 2, -Math.PI / 2 + Math.PI * 2 * clamp01((data.pct ?? 0) / 100)); ctx.stroke();
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function draw(nowMs) {
|
|
388
|
+
frame = 0;
|
|
389
|
+
if (!node.isConnected || !ctx) return;
|
|
390
|
+
if (!w) { fit(); if (!w) return; }
|
|
391
|
+
const now = nowMs / 1000;
|
|
392
|
+
const t = still ? 2 : now;
|
|
393
|
+
const age = still ? 99 : now - scene.since;
|
|
394
|
+
const data = scene.data() ?? {};
|
|
395
|
+
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
396
|
+
paintGround();
|
|
397
|
+
const want = PICTURES[scene.id] ?? PICTURES.hello;
|
|
398
|
+
ctx.globalCompositeOperation = look.blend;
|
|
399
|
+
for (const p of parts) {
|
|
400
|
+
const [tx, ty, ta, ts] = want(p, t, data, age);
|
|
401
|
+
if (still) { p.x = tx; p.y = ty; p.a = ta; p.s = ts; } else {
|
|
402
|
+
// A soft spring: the points arrive and settle, never snap or bounce.
|
|
403
|
+
p.vx = (p.vx + (tx - p.x) * 0.032) * 0.84;
|
|
404
|
+
p.vy = (p.vy + (ty - p.y) * 0.032) * 0.84;
|
|
405
|
+
p.x += p.vx;
|
|
406
|
+
p.y += p.vy;
|
|
407
|
+
p.a += (ta - p.a) * 0.07;
|
|
408
|
+
p.s += (ts - p.s) * 0.07;
|
|
409
|
+
}
|
|
410
|
+
const alpha = p.a * (0.45 + 0.55 * p.z);
|
|
411
|
+
if (alpha < 0.01) continue;
|
|
412
|
+
const r = (0.75 + 1.05 * p.z) * p.s;
|
|
413
|
+
ctx.globalAlpha = clamp01(alpha);
|
|
414
|
+
ctx.drawImage(sprite, p.x - r * 3.2, p.y - r * 3.2, r * 6.4, r * 6.4);
|
|
415
|
+
}
|
|
416
|
+
ctx.globalAlpha = 1;
|
|
417
|
+
ctx.globalCompositeOperation = 'source-over';
|
|
418
|
+
paintArc(data);
|
|
419
|
+
paintNote(data, age);
|
|
420
|
+
const target = dotOf(scene.id, data);
|
|
421
|
+
dot.a = still ? target : dot.a + (target - dot.a) * 0.06;
|
|
422
|
+
paintDot(t);
|
|
423
|
+
if (!still) frame = requestAnimationFrame(draw);
|
|
424
|
+
}
|
|
425
|
+
function redraw() { if (!frame) frame = requestAnimationFrame(draw); }
|
|
426
|
+
|
|
427
|
+
return {
|
|
428
|
+
node,
|
|
429
|
+
// A step's picture: its id and a function that says, each time it is drawn, what it shows now.
|
|
430
|
+
show(id, data = () => ({})) {
|
|
431
|
+
if (scene.id !== id) scene = { id, data, since: (globalThis.performance?.now() ?? Date.now()) / 1000 };
|
|
432
|
+
else scene.data = data;
|
|
433
|
+
redraw();
|
|
434
|
+
},
|
|
435
|
+
// The line under the picture: what is happening now, in a few words.
|
|
436
|
+
say(text) {
|
|
437
|
+
if (words.textContent === text) return;
|
|
438
|
+
words.textContent = text;
|
|
439
|
+
if (!still) { caption.classList.remove('new'); void caption.offsetWidth; caption.classList.add('new'); }
|
|
440
|
+
redraw();
|
|
441
|
+
},
|
|
442
|
+
// What it shows changed (a still picture is drawn again; a moving one already is).
|
|
443
|
+
redraw,
|
|
444
|
+
stop() { if (frame) cancelAnimationFrame(frame); frame = 0; observer?.disconnect(); watcher?.disconnect(); },
|
|
445
|
+
};
|
|
446
|
+
}
|