@idle-screens/savers-classic 1.0.0 → 2.0.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.
@@ -1,18 +1,1356 @@
1
1
  import {
2
+ fluid,
3
+ flurry,
2
4
  globe,
3
5
  hardRain,
6
+ mystify,
7
+ pipes,
4
8
  rainstorm,
9
+ reactionDiffusion,
5
10
  spotlight,
6
11
  warp
7
- } from "./chunk-5EPTQV3C.js";
12
+ } from "./chunk-MIVXP2IL.js";
8
13
 
9
14
  // src/idle-worker.ts
10
15
  import { runIdleWorker } from "@idle-screens/core";
11
- runIdleWorker({
12
- [warp.manifest.id]: warp,
13
- [hardRain.manifest.id]: hardRain,
14
- [rainstorm.manifest.id]: rainstorm,
15
- [globe.manifest.id]: globe,
16
- [spotlight.manifest.id]: spotlight
17
- });
16
+
17
+ // ../schema/dist/index.js
18
+ import {
19
+ createRng
20
+ } from "@idle-screens/core";
21
+ var SCHEMA_VERSION = 1;
22
+ var LIMITS = {
23
+ maxPerLayer: 400,
24
+ maxTotal: 800,
25
+ maxLayers: 36,
26
+ maxSpeed: 4e3,
27
+ // px/sec — bounds motion so nothing teleports
28
+ maxPulseAmp: 0.5,
29
+ // opacity breathing amplitude cap
30
+ minPulsePeriod: 500
31
+ // ms — caps pulse at 2 Hz (WCAG flash threshold is 3 Hz)
32
+ };
33
+ var HEX = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
34
+ var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
35
+ var isStr = (v) => typeof v === "string";
36
+ var isNum = (v) => typeof v === "number" && Number.isFinite(v);
37
+ var isRange = (v) => Array.isArray(v) && v.length === 2 && isNum(v[0]) && isNum(v[1]) && v[0] <= v[1];
38
+ function validateSpec(spec) {
39
+ const errors = [];
40
+ const err = (path, message) => void errors.push({ path, message });
41
+ if (!isObj(spec)) return { valid: false, errors: [{ path: "", message: "spec must be an object" }] };
42
+ if (spec.schemaVersion !== SCHEMA_VERSION) err("schemaVersion", `must be ${SCHEMA_VERSION}`);
43
+ if (!isStr(spec.id) || spec.id.trim() === "") err("id", "must be a non-empty string");
44
+ if (!isStr(spec.label) || spec.label.trim() === "") err("label", "must be a non-empty string");
45
+ if (spec.seed !== void 0 && !isNum(spec.seed)) err("seed", "must be a number");
46
+ if (spec.motionIntensity !== void 0 && !["calm", "moderate", "energetic"].includes(spec.motionIntensity)) {
47
+ err("motionIntensity", "must be calm | moderate | energetic");
48
+ }
49
+ if (spec.background !== void 0) validateBackground(spec.background, err);
50
+ if (!Array.isArray(spec.layers) || spec.layers.length === 0) {
51
+ err("layers", "must be a non-empty array");
52
+ } else {
53
+ if (spec.layers.length > LIMITS.maxLayers) err("layers", `at most ${LIMITS.maxLayers} layers`);
54
+ let total = 0;
55
+ spec.layers.forEach((layer, i) => {
56
+ total += isObj(layer) && isNum(layer.count) ? layer.count : 0;
57
+ validateLayer(layer, `layers[${i}]`, err);
58
+ });
59
+ if (total > LIMITS.maxTotal) err("layers", `total entities ${total} exceeds cap ${LIMITS.maxTotal}`);
60
+ }
61
+ return { valid: errors.length === 0, errors };
62
+ }
63
+ function color(v, path, err) {
64
+ if (!isStr(v) || !HEX.test(v)) err(path, "must be a hex colour like #0a3a52");
65
+ }
66
+ function validateBackground(bg, err) {
67
+ if (!isObj(bg)) return err("background", "must be an object");
68
+ if (bg.type === "solid") {
69
+ color(bg.color, "background.color", err);
70
+ } else if (bg.type === "gradient") {
71
+ if (!Array.isArray(bg.stops) || bg.stops.length < 2) {
72
+ err("background.stops", "gradient needs at least 2 stops");
73
+ } else {
74
+ bg.stops.forEach((s, i) => {
75
+ if (!isObj(s) || !isNum(s.at) || s.at < 0 || s.at > 1) err(`background.stops[${i}].at`, "must be 0..1");
76
+ color(isObj(s) ? s.color : void 0, `background.stops[${i}].color`, err);
77
+ });
78
+ }
79
+ if (bg.band !== void 0) {
80
+ if (!isObj(bg.band)) err("background.band", "must be an object");
81
+ else {
82
+ color(bg.band.color, "background.band.color", err);
83
+ if (!isNum(bg.band.height) || bg.band.height <= 0) err("background.band.height", "must be > 0");
84
+ }
85
+ }
86
+ } else {
87
+ err("background.type", "must be solid | gradient");
88
+ }
89
+ }
90
+ function validateLayer(layer, path, err) {
91
+ if (!isObj(layer)) return err(path, "must be an object");
92
+ if (!isNum(layer.count) || !Number.isInteger(layer.count) || layer.count < 1) {
93
+ err(`${path}.count`, "must be a positive integer");
94
+ } else if (layer.count > LIMITS.maxPerLayer) {
95
+ err(`${path}.count`, `at most ${LIMITS.maxPerLayer} per layer`);
96
+ }
97
+ if (layer.size !== void 0 && (!isRange(layer.size) || layer.size[0] <= 0)) {
98
+ err(`${path}.size`, "must be a [min,max] range of positive px");
99
+ }
100
+ if (layer.wrap !== void 0 && typeof layer.wrap !== "boolean") err(`${path}.wrap`, "must be a boolean");
101
+ if (layer.flip !== void 0 && typeof layer.flip !== "boolean") err(`${path}.flip`, "must be a boolean");
102
+ if (layer.alpha !== void 0 && (!isRange(layer.alpha) || layer.alpha[0] < 0 || layer.alpha[1] > 1)) {
103
+ err(`${path}.alpha`, "must be a [min,max] range within 0..1");
104
+ }
105
+ if (layer.blend !== void 0 && layer.blend !== "lighter") err(`${path}.blend`, "must be 'lighter' when set");
106
+ if (layer.key !== void 0 && (!isStr(layer.key) || layer.key.trim() === "")) {
107
+ err(`${path}.key`, "must be a non-empty string");
108
+ }
109
+ if (layer.position !== void 0) {
110
+ if (!isObj(layer.position) || !isNum(layer.position.x) || !isNum(layer.position.y)) {
111
+ err(`${path}.position`, "must be {x, y} with numbers 0..1");
112
+ } else {
113
+ if (layer.position.x < 0 || layer.position.x > 1) err(`${path}.position.x`, "must be 0..1");
114
+ if (layer.position.y < 0 || layer.position.y > 1) err(`${path}.position.y`, "must be 0..1");
115
+ if (isNum(layer.count) && layer.count !== 1) err(`${path}.position`, "position requires count: 1");
116
+ }
117
+ }
118
+ if (layer.region !== void 0) {
119
+ if (!isObj(layer.region)) err(`${path}.region`, "must be an object");
120
+ else {
121
+ for (const axis of ["x", "y"]) {
122
+ const r = layer.region[axis];
123
+ if (r !== void 0 && (!isRange(r) || r[0] < 0 || r[1] > 1)) {
124
+ err(`${path}.region.${axis}`, "must be a [min,max] range within 0..1");
125
+ }
126
+ }
127
+ }
128
+ }
129
+ if (layer.pulse !== void 0) {
130
+ if (!isObj(layer.pulse)) err(`${path}.pulse`, "must be an object");
131
+ else {
132
+ if (!isNum(layer.pulse.amp) || layer.pulse.amp <= 0 || layer.pulse.amp > LIMITS.maxPulseAmp) {
133
+ err(`${path}.pulse.amp`, `must be within 0..${LIMITS.maxPulseAmp}`);
134
+ }
135
+ if (!isNum(layer.pulse.period) || layer.pulse.period < LIMITS.minPulsePeriod) {
136
+ err(`${path}.pulse.period`, `must be >= ${LIMITS.minPulsePeriod} ms (flash-safety floor)`);
137
+ }
138
+ }
139
+ }
140
+ validateSprite(layer.sprite, `${path}.sprite`, err);
141
+ validateMotion(layer.motion, `${path}.motion`, err);
142
+ }
143
+ function validateSprite(sprite, path, err) {
144
+ if (!isObj(sprite)) return err(path, "must be an object");
145
+ if (sprite.kind === "emoji") {
146
+ if (!Array.isArray(sprite.glyphs) || sprite.glyphs.length === 0 || !sprite.glyphs.every(isStr)) {
147
+ err(`${path}.glyphs`, "must be a non-empty array of strings");
148
+ }
149
+ } else if (sprite.kind === "text") {
150
+ if (!Array.isArray(sprite.strings) || sprite.strings.length === 0 || !sprite.strings.every(isStr)) {
151
+ err(`${path}.strings`, "must be a non-empty array of strings");
152
+ }
153
+ if (sprite.color !== void 0) color(sprite.color, `${path}.color`, err);
154
+ if (sprite.align !== void 0 && !["left", "center", "right"].includes(sprite.align)) {
155
+ err(`${path}.align`, "must be left | center | right");
156
+ }
157
+ if (sprite.baseline !== void 0 && !["top", "middle", "bottom"].includes(sprite.baseline)) {
158
+ err(`${path}.baseline`, "must be top | middle | bottom");
159
+ }
160
+ if (sprite.maxWidth !== void 0 && (!isNum(sprite.maxWidth) || sprite.maxWidth <= 0)) {
161
+ err(`${path}.maxWidth`, "must be a positive number");
162
+ }
163
+ } else if (sprite.kind === "circle") {
164
+ if (!isRange(sprite.radius) || sprite.radius[0] <= 0) err(`${path}.radius`, "must be a [min,max] range of positive px");
165
+ color(sprite.color, `${path}.color`, err);
166
+ if (sprite.soft !== void 0 && typeof sprite.soft !== "boolean") err(`${path}.soft`, "must be a boolean");
167
+ } else {
168
+ err(`${path}.kind`, "must be emoji | text | circle");
169
+ }
170
+ }
171
+ function validateMotion(motion, path, err) {
172
+ if (!isObj(motion)) return err(path, "must be an object");
173
+ const speedOk = (v, p) => {
174
+ if (!isRange(v)) err(p, "must be a [min,max] range");
175
+ else if (v[1] > LIMITS.maxSpeed) err(p, `speed exceeds cap ${LIMITS.maxSpeed} px/sec`);
176
+ };
177
+ if (motion.type === "drift") {
178
+ speedOk(motion.speed, `${path}.speed`);
179
+ if (motion.angle !== void 0 && !isNum(motion.angle)) err(`${path}.angle`, "must be a number (degrees)");
180
+ if (motion.bidirectional !== void 0 && typeof motion.bidirectional !== "boolean") err(`${path}.bidirectional`, "must be a boolean");
181
+ if (motion.bob !== void 0 && !isNum(motion.bob)) err(`${path}.bob`, "must be a number");
182
+ } else if (motion.type === "rise") {
183
+ speedOk(motion.speed, `${path}.speed`);
184
+ if (motion.sway !== void 0 && !isNum(motion.sway)) err(`${path}.sway`, "must be a number");
185
+ } else if (motion.type === "bounce") {
186
+ speedOk(motion.speed, `${path}.speed`);
187
+ } else if (motion.type === "static") {
188
+ } else {
189
+ err(`${path}.type`, "must be drift | rise | bounce | static");
190
+ }
191
+ }
192
+ function assertValidSpec(spec) {
193
+ const r = validateSpec(spec);
194
+ if (!r.valid) {
195
+ throw new Error(`invalid saver spec:
196
+ ${r.errors.map((e) => ` ${e.path || "<root>"}: ${e.message}`).join("\n")}`);
197
+ }
198
+ return spec;
199
+ }
200
+ function spriteVariants(sprite) {
201
+ if (sprite.kind === "emoji") return sprite.glyphs.length;
202
+ if (sprite.kind === "text") return sprite.strings.length;
203
+ return 1;
204
+ }
205
+ function buildEntities(layer, rng, w, h) {
206
+ const [smin, smax] = layer.size ?? [20, 40];
207
+ const variants = spriteVariants(layer.sprite);
208
+ const out = [];
209
+ for (let i = 0; i < layer.count; i++) {
210
+ const size = layer.sprite.kind === "circle" ? rng.range(layer.sprite.radius[0], layer.sprite.radius[1]) * 2 : rng.range(smin, smax);
211
+ let vx = 0;
212
+ let vy = 0;
213
+ let bob = 0;
214
+ let motion = "drift";
215
+ const m = layer.motion;
216
+ if (m.type === "static") {
217
+ motion = "static";
218
+ } else if (m.type === "drift") {
219
+ const s = rng.range(m.speed[0], m.speed[1]);
220
+ let angle = (m.angle ?? 0) * Math.PI / 180;
221
+ if (m.bidirectional && rng.next() < 0.5) angle = Math.PI - angle;
222
+ vx = s * Math.cos(angle);
223
+ vy = s * Math.sin(angle);
224
+ bob = m.bob ?? 0;
225
+ } else if (m.type === "rise") {
226
+ motion = "rise";
227
+ vy = -rng.range(m.speed[0], m.speed[1]);
228
+ bob = m.sway ?? 0;
229
+ } else {
230
+ motion = "bounce";
231
+ const s = rng.range(m.speed[0], m.speed[1]);
232
+ const a = rng.range(0, Math.PI * 2);
233
+ vx = s * Math.cos(a);
234
+ vy = s * Math.sin(a);
235
+ }
236
+ let x0;
237
+ let y0;
238
+ if (layer.position && layer.count === 1) {
239
+ x0 = layer.position.x * w;
240
+ y0 = layer.position.y * h;
241
+ } else {
242
+ const [rx0, rx1] = layer.region?.x ?? [0, 1];
243
+ const [ry0, ry1] = layer.region?.y ?? [0, 1];
244
+ x0 = rng.range(rx0 * w, rx1 * w);
245
+ y0 = rng.range(ry0 * h, ry1 * h);
246
+ }
247
+ out.push({
248
+ x0,
249
+ y0,
250
+ size,
251
+ spriteIndex: variants > 1 ? rng.int(0, variants - 1) : 0,
252
+ phase: rng.range(0, Math.PI * 2),
253
+ vx,
254
+ vy,
255
+ bob,
256
+ motion,
257
+ headingLeft: vx < 0,
258
+ alpha: layer.alpha ? rng.range(layer.alpha[0], layer.alpha[1]) : 1,
259
+ pulseAmp: layer.pulse?.amp ?? 0,
260
+ pulsePeriod: layer.pulse?.period ?? 1e3,
261
+ pulsePhase: layer.pulse ? rng.range(0, Math.PI * 2) : 0
262
+ });
263
+ }
264
+ return out;
265
+ }
266
+ function alphaAt(e, t) {
267
+ if (!e.pulseAmp) return e.alpha;
268
+ const a = e.alpha + e.pulseAmp * Math.sin(t * 2 * Math.PI / e.pulsePeriod + e.pulsePhase);
269
+ return a < 0 ? 0 : a > 1 ? 1 : a;
270
+ }
271
+ function wrap(v, min, max) {
272
+ const range = max - min;
273
+ return ((v - min) % range + range) % range + min;
274
+ }
275
+ function reflect(v, min, max) {
276
+ const range = max - min;
277
+ if (range <= 0) return min;
278
+ const period = 2 * range;
279
+ const p = ((v - min) % period + period) % period;
280
+ return min + (p < range ? p : period - p);
281
+ }
282
+ function positionAt(e, t, w, h) {
283
+ if (e.motion === "static") return { x: e.x0, y: e.y0, flip: false };
284
+ const dt = t / 1e3;
285
+ const m = e.size;
286
+ if (e.motion === "bounce") {
287
+ return {
288
+ x: reflect(e.x0 + e.vx * dt, m / 2, w - m / 2),
289
+ y: reflect(e.y0 + e.vy * dt, m / 2, h - m / 2),
290
+ flip: false
291
+ };
292
+ }
293
+ if (e.motion === "rise") {
294
+ return {
295
+ x: e.x0 + (e.bob ? e.bob * Math.sin(t / 700 + e.phase) : 0),
296
+ y: wrap(e.y0 + e.vy * dt, -m, h + m),
297
+ flip: false
298
+ };
299
+ }
300
+ const x = wrap(e.x0 + e.vx * dt, -m, w + m);
301
+ let y = e.vy !== 0 ? wrap(e.y0 + e.vy * dt, -m, h + m) : e.y0;
302
+ if (e.bob) y += e.bob * Math.sin(t / 500 + e.phase);
303
+ return { x, y, flip: e.headingLeft };
304
+ }
305
+ var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
306
+ function resolveSpecPath(spec, path) {
307
+ if (!spec || typeof spec !== "object" || !path) return null;
308
+ const parts = path.split(".");
309
+ if (parts.some((p) => UNSAFE_KEYS.has(p))) return null;
310
+ const s = spec;
311
+ if (parts[0] !== "layers" && parts[0] !== "background" && Array.isArray(s.layers)) {
312
+ const idx = s.layers.findIndex((l) => l && l.key === parts[0]);
313
+ if (idx === -1) return null;
314
+ parts.splice(0, 1, "layers", String(idx));
315
+ }
316
+ let node = spec;
317
+ for (let i = 0; i < parts.length - 1; i++) {
318
+ if (node === null || typeof node !== "object") return null;
319
+ node = node[parts[i]];
320
+ }
321
+ if (node === null || typeof node !== "object") return null;
322
+ const last = parts[parts.length - 1];
323
+ const key = Array.isArray(node) ? Number(last) : last;
324
+ const exists = Array.isArray(node) ? Number.isInteger(key) && key >= 0 && key < node.length : last in node;
325
+ return exists ? { parent: node, key } : null;
326
+ }
327
+ function applyDeltasToSpec(spec, deltas) {
328
+ const copy = JSON.parse(JSON.stringify(spec));
329
+ for (const d of deltas) {
330
+ const loc = resolveSpecPath(copy, d.path);
331
+ if (loc) loc.parent[loc.key] = d.value;
332
+ }
333
+ return copy;
334
+ }
335
+ var HEX2 = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
336
+ function hexToRgb(hex) {
337
+ const h = hex.length === 4 ? `#${hex[1]}${hex[1]}${hex[2]}${hex[2]}${hex[3]}${hex[3]}` : hex;
338
+ const n = parseInt(h.slice(1), 16);
339
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
340
+ }
341
+ function lerpHex(a, b, k) {
342
+ const ca = hexToRgb(a);
343
+ const cb = hexToRgb(b);
344
+ const mix = ca.map((v, i) => Math.round(v + (cb[i] - v) * k));
345
+ return `#${mix.map((v) => v.toString(16).padStart(2, "0")).join("")}`;
346
+ }
347
+ function lerpSpec(from, to, k) {
348
+ const kk = Math.max(0, Math.min(1, k));
349
+ const walk = (a, b, key) => {
350
+ if (typeof a === "number" && typeof b === "number") {
351
+ const v = a + (b - a) * kk;
352
+ return key === "count" ? Math.max(1, Math.round(v)) : v;
353
+ }
354
+ if (typeof a === "string" && typeof b === "string" && HEX2.test(a) && HEX2.test(b)) {
355
+ return lerpHex(a, b, kk);
356
+ }
357
+ if (Array.isArray(a) && Array.isArray(b) && a.length === b.length) {
358
+ return b.map((bv, i) => walk(a[i], bv, i));
359
+ }
360
+ if (a && b && typeof a === "object" && typeof b === "object" && !Array.isArray(a) && !Array.isArray(b)) {
361
+ const out = {};
362
+ for (const kName of Object.keys(b)) {
363
+ out[kName] = walk(a[kName], b[kName], kName);
364
+ }
365
+ return out;
366
+ }
367
+ return kk > 0 ? b : a;
368
+ };
369
+ return walk(from, to);
370
+ }
371
+ function easeSmooth(k) {
372
+ const c = Math.max(0, Math.min(1, k));
373
+ return c * c * (3 - 2 * c);
374
+ }
375
+ function structuralSignature(spec) {
376
+ return JSON.stringify(
377
+ spec.layers.map((l) => [
378
+ l.count,
379
+ l.size,
380
+ l.region,
381
+ l.position,
382
+ l.motion,
383
+ l.wrap,
384
+ l.flip,
385
+ l.alpha,
386
+ l.pulse,
387
+ l.sprite.kind,
388
+ l.sprite.kind === "circle" ? l.sprite.radius : void 0,
389
+ l.sprite.kind === "emoji" ? l.sprite.glyphs.length : l.sprite.kind === "text" ? l.sprite.strings.length : void 0
390
+ ])
391
+ );
392
+ }
393
+ var DEFAULT_STEER_DUR = 1e3;
394
+ function hexToRgba(hex, alpha) {
395
+ const h = hex.length === 4 ? `#${hex[1]}${hex[1]}${hex[2]}${hex[2]}${hex[3]}${hex[3]}` : hex;
396
+ const n = parseInt(h.slice(1), 16);
397
+ return `rgba(${n >> 16 & 255},${n >> 8 & 255},${n & 255},${alpha})`;
398
+ }
399
+ function manifestFor(spec) {
400
+ const total = spec.layers.reduce((n, l) => n + l.count, 0);
401
+ const costTier = total < 30 ? "idle" : total < 150 ? "low" : total < 400 ? "medium" : "high";
402
+ return {
403
+ id: spec.id,
404
+ label: spec.label,
405
+ passthrough: false,
406
+ minBackend: "canvas2d",
407
+ costTier,
408
+ motionIntensity: spec.motionIntensity ?? "moderate",
409
+ reducedMotionFallback: "static",
410
+ // Flash-safe by construction: static background + bounded sprites, no strobe
411
+ // primitive. Proven by sampling a compiled spec through @idle-screens/validator.
412
+ a11y: { flashSafe: true },
413
+ workerReady: true
414
+ };
415
+ }
416
+ var SpecInstance = class {
417
+ constructor(spec, ctx) {
418
+ this.spec = spec;
419
+ this.effSpec = spec;
420
+ this.saverCtx = ctx;
421
+ this.seed = (spec.seed ?? ctx.seed) >>> 0 || 1;
422
+ let canvas;
423
+ if (ctx.surface) {
424
+ canvas = ctx.surface;
425
+ } else {
426
+ const el = document.createElement("canvas");
427
+ el.style.cssText = "display:block;width:100%;height:100%";
428
+ el.setAttribute("aria-hidden", "true");
429
+ ctx.host.appendChild(el);
430
+ canvas = el;
431
+ }
432
+ this.canvas = canvas;
433
+ const c2d = canvas.getContext("2d", { alpha: false });
434
+ if (!c2d) throw new Error("schema saver: no 2d context");
435
+ this.ctx = c2d;
436
+ this.w = ctx.width;
437
+ this.h = ctx.height;
438
+ this.sizeCanvas();
439
+ this.rebuild();
440
+ this.paused = ctx.reducedMotion;
441
+ if (this.paused) this.renderFrame(0, this.seed);
442
+ else this.start();
443
+ }
444
+ spec;
445
+ canvas;
446
+ ctx;
447
+ saverCtx;
448
+ seed;
449
+ w;
450
+ h;
451
+ layers = [];
452
+ frameId = null;
453
+ paused = false;
454
+ startT = 0;
455
+ baseT = 0;
456
+ // elapsed logical time carried across pause/resume
457
+ lastT = 0;
458
+ /** The spec currently being rendered (base spec + any applied steering). */
459
+ effSpec;
460
+ /** Active glide between two resolved specs (live setParam/applyTrack). */
461
+ transition = null;
462
+ lastStructural = "";
463
+ sizeCanvas() {
464
+ const dpr = Math.min(this.saverCtx.dpr, 2);
465
+ this.canvas.width = Math.max(1, Math.round(this.w * dpr));
466
+ this.canvas.height = Math.max(1, Math.round(this.h * dpr));
467
+ this.ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
468
+ }
469
+ /** (Re)seed and place all entities — deterministic for the seed + size. */
470
+ rebuild() {
471
+ const rng = createRng(this.seed);
472
+ this.layers = this.effSpec.layers.map((layer) => ({ layer, entities: buildEntities(layer, rng, this.w, this.h) }));
473
+ this.lastStructural = structuralSignature(this.effSpec);
474
+ }
475
+ start() {
476
+ if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
477
+ this.startT = 0;
478
+ this.frameId = requestAnimationFrame((now) => this.loop(now));
479
+ }
480
+ stop() {
481
+ if (this.frameId !== null) {
482
+ cancelAnimationFrame(this.frameId);
483
+ this.frameId = null;
484
+ }
485
+ this.baseT = this.lastT;
486
+ }
487
+ loop(now) {
488
+ this.frameId = requestAnimationFrame((n) => this.loop(n));
489
+ if (this.startT === 0) this.startT = now;
490
+ this.lastT = now - this.startT + this.baseT;
491
+ this.renderFrame(this.lastT, this.seed);
492
+ }
493
+ drawBackground() {
494
+ const { ctx, w, h } = this;
495
+ const bg = this.effSpec.background;
496
+ if (!bg || bg.type === "solid") {
497
+ ctx.fillStyle = bg?.color ?? "#05050a";
498
+ ctx.fillRect(0, 0, w, h);
499
+ return;
500
+ }
501
+ const g = ctx.createLinearGradient(0, 0, 0, h);
502
+ for (const s of bg.stops) g.addColorStop(Math.max(0, Math.min(1, s.at)), s.color);
503
+ ctx.fillStyle = g;
504
+ ctx.fillRect(0, 0, w, h);
505
+ if (bg.band) {
506
+ ctx.fillStyle = bg.band.color;
507
+ ctx.fillRect(0, h - bg.band.height, w, bg.band.height);
508
+ }
509
+ }
510
+ drawEntity(built, e, t) {
511
+ const { ctx } = this;
512
+ const p = positionAt(e, t, this.w, this.h);
513
+ const sprite = built.layer.sprite;
514
+ ctx.globalAlpha = alphaAt(e, t);
515
+ if (sprite.kind === "circle") {
516
+ const r = e.size / 2;
517
+ if (sprite.soft) {
518
+ const g = ctx.createRadialGradient(p.x, p.y, 0, p.x, p.y, r);
519
+ g.addColorStop(0, sprite.color);
520
+ g.addColorStop(0.35, hexToRgba(sprite.color, 0.75));
521
+ g.addColorStop(1, hexToRgba(sprite.color, 0));
522
+ ctx.fillStyle = g;
523
+ } else {
524
+ ctx.fillStyle = sprite.color;
525
+ }
526
+ ctx.beginPath();
527
+ ctx.arc(p.x, p.y, r, 0, Math.PI * 2);
528
+ ctx.fill();
529
+ return;
530
+ }
531
+ ctx.save();
532
+ ctx.translate(p.x, p.y);
533
+ if (p.flip && built.layer.flip) ctx.scale(-1, 1);
534
+ ctx.textAlign = "center";
535
+ ctx.textBaseline = "middle";
536
+ if (sprite.kind === "emoji") {
537
+ ctx.font = `${e.size}px serif`;
538
+ ctx.fillText(sprite.glyphs[e.spriteIndex] ?? sprite.glyphs[0], 0, 0);
539
+ } else {
540
+ ctx.textAlign = sprite.align ?? "center";
541
+ ctx.textBaseline = sprite.baseline ?? "middle";
542
+ ctx.font = sprite.font ?? `${e.size}px system-ui, sans-serif`;
543
+ ctx.fillStyle = sprite.color ?? "#e6e8ef";
544
+ const text = sprite.strings[e.spriteIndex] ?? sprite.strings[0];
545
+ if (sprite.maxWidth) ctx.fillText(text, 0, 0, sprite.maxWidth);
546
+ else ctx.fillText(text, 0, 0);
547
+ }
548
+ ctx.restore();
549
+ }
550
+ /** Advance any live steering glide; rebuild entities on structural change. */
551
+ stepTransition(t) {
552
+ const tr = this.transition;
553
+ if (!tr) return;
554
+ const k = tr.dur <= 0 ? 1 : (t - tr.startT) / tr.dur;
555
+ this.effSpec = k >= 1 ? tr.to : lerpSpec(tr.from, tr.to, easeSmooth(k));
556
+ if (k >= 1) this.transition = null;
557
+ const sig = structuralSignature(this.effSpec);
558
+ if (sig !== this.lastStructural) this.rebuild();
559
+ else this.layers.forEach((b, i) => {
560
+ b.layer = this.effSpec.layers[i] ?? b.layer;
561
+ });
562
+ }
563
+ /**
564
+ * Live steering: glide from what's currently rendered to the track's target
565
+ * state (deltas applied last-wins). Duration = the longest delta `dur`.
566
+ */
567
+ applyTrack(track) {
568
+ const deltas = track?.deltas ?? [];
569
+ const target = applyDeltasToSpec(this.effSpec, deltas);
570
+ if (!validateSpec(target).valid) return;
571
+ const dur = deltas.length ? deltas.reduce((m, d) => Math.max(m, d.dur ?? DEFAULT_STEER_DUR), 0) : DEFAULT_STEER_DUR;
572
+ this.transition = {
573
+ from: JSON.parse(JSON.stringify(this.effSpec)),
574
+ to: target,
575
+ startT: this.lastT,
576
+ dur
577
+ };
578
+ if (this.paused) {
579
+ this.transition = null;
580
+ this.effSpec = target;
581
+ if (structuralSignature(this.effSpec) !== this.lastStructural) this.rebuild();
582
+ else this.layers.forEach((b, i) => {
583
+ b.layer = this.effSpec.layers[i] ?? b.layer;
584
+ });
585
+ this.renderFrame(this.lastT, this.seed);
586
+ }
587
+ }
588
+ /** Deterministic, frame-addressable render (shared by the rAF loop). */
589
+ renderFrame(t, _seed) {
590
+ this.stepTransition(t);
591
+ const { ctx } = this;
592
+ ctx.globalAlpha = 1;
593
+ ctx.globalCompositeOperation = "source-over";
594
+ this.drawBackground();
595
+ for (const built of this.layers) {
596
+ ctx.globalCompositeOperation = built.layer.blend ?? "source-over";
597
+ for (const e of built.entities) this.drawEntity(built, e, t);
598
+ }
599
+ ctx.globalAlpha = 1;
600
+ ctx.globalCompositeOperation = "source-over";
601
+ }
602
+ setPaused(paused) {
603
+ this.paused = paused;
604
+ if (paused) {
605
+ this.stop();
606
+ } else {
607
+ this.start();
608
+ }
609
+ }
610
+ resize(width, height, dpr) {
611
+ this.w = width;
612
+ this.h = height;
613
+ if (dpr !== void 0) this.saverCtx.dpr = dpr;
614
+ this.sizeCanvas();
615
+ this.rebuild();
616
+ if (this.paused) this.renderFrame(0, this.seed);
617
+ }
618
+ dispose() {
619
+ this.stop();
620
+ if (typeof HTMLCanvasElement !== "undefined" && this.canvas instanceof HTMLCanvasElement) this.canvas.remove();
621
+ }
622
+ };
623
+ function compileSaver(spec) {
624
+ const valid = assertValidSpec(spec);
625
+ return {
626
+ manifest: manifestFor(valid),
627
+ mount: (ctx) => new SpecInstance(valid, ctx),
628
+ spec: valid
629
+ };
630
+ }
631
+ var AQUARIUM_SPEC = {
632
+ schemaVersion: 1,
633
+ id: "aquarium",
634
+ label: "Aquarium",
635
+ seed: 42,
636
+ motionIntensity: "calm",
637
+ background: {
638
+ type: "gradient",
639
+ stops: [
640
+ { at: 0, color: "#0a3a52" },
641
+ { at: 0.6, color: "#062534" },
642
+ { at: 1, color: "#02141d" }
643
+ ],
644
+ band: { color: "#0b1a12", height: 24 }
645
+ },
646
+ layers: [
647
+ {
648
+ count: 14,
649
+ sprite: { kind: "emoji", glyphs: ["\u{1F41F}", "\u{1F420}", "\u{1F421}", "\u{1F988}", "\u{1F419}"] },
650
+ size: [34, 72],
651
+ motion: { type: "drift", speed: [30, 110], bidirectional: true, bob: 6 },
652
+ flip: true
653
+ },
654
+ {
655
+ count: 22,
656
+ sprite: { kind: "circle", radius: [2, 7], color: "#c8ebff" },
657
+ motion: { type: "rise", speed: [24, 78], sway: 8 }
658
+ }
659
+ ]
660
+ };
661
+ var DASHBOARD_SPEC = {
662
+ schemaVersion: 1,
663
+ id: "dev-dashboard",
664
+ label: "Dev Dashboard",
665
+ seed: 256,
666
+ motionIntensity: "calm",
667
+ background: {
668
+ type: "gradient",
669
+ stops: [
670
+ { at: 0, color: "#06060c" },
671
+ { at: 0.5, color: "#0a0a14" },
672
+ { at: 1, color: "#0c0c18" }
673
+ ]
674
+ },
675
+ layers: [
676
+ // --- ambient depth ---
677
+ {
678
+ count: 50,
679
+ sprite: { kind: "circle", radius: [0.2, 0.8], color: "#1a2538" },
680
+ alpha: [0.1, 0.25],
681
+ motion: { type: "drift", speed: [0.3, 1.2], bob: 0.3 }
682
+ },
683
+ {
684
+ count: 12,
685
+ sprite: { kind: "circle", radius: [1, 2.5], color: "#1a3050", soft: true },
686
+ alpha: [0.08, 0.18],
687
+ blend: "lighter",
688
+ pulse: { amp: 0.08, period: 4e3 },
689
+ motion: { type: "drift", speed: [0.5, 1.5], bob: 0.5 }
690
+ },
691
+ // --- header ---
692
+ {
693
+ key: "title",
694
+ count: 1,
695
+ position: { x: 0.5, y: 0.04 },
696
+ sprite: {
697
+ kind: "text",
698
+ strings: ["DEV PULSE"],
699
+ color: "#556677",
700
+ font: "600 13px 'SF Mono', monospace",
701
+ align: "center"
702
+ },
703
+ motion: { type: "static" }
704
+ },
705
+ {
706
+ key: "status",
707
+ count: 1,
708
+ position: { x: 0.92, y: 0.04 },
709
+ sprite: {
710
+ kind: "text",
711
+ strings: ["\u25CF ACTIVE"],
712
+ color: "#44cc66",
713
+ font: "bold 10px monospace",
714
+ align: "right"
715
+ },
716
+ motion: { type: "static" }
717
+ },
718
+ {
719
+ key: "uptime",
720
+ count: 1,
721
+ position: { x: 0.08, y: 0.04 },
722
+ sprite: {
723
+ kind: "text",
724
+ strings: ["up 2h 14m"],
725
+ color: "#445566",
726
+ font: "10px monospace",
727
+ align: "left"
728
+ },
729
+ motion: { type: "static" }
730
+ },
731
+ // --- left column: metrics ---
732
+ {
733
+ key: "tools-label",
734
+ count: 1,
735
+ position: { x: 0.06, y: 0.12 },
736
+ sprite: {
737
+ kind: "text",
738
+ strings: ["TOOL CALLS"],
739
+ color: "#445566",
740
+ font: "9px monospace",
741
+ align: "left",
742
+ baseline: "top"
743
+ },
744
+ motion: { type: "static" }
745
+ },
746
+ {
747
+ key: "tools-value",
748
+ count: 1,
749
+ position: { x: 0.06, y: 0.16 },
750
+ sprite: {
751
+ kind: "text",
752
+ strings: ["147"],
753
+ color: "#44aaff",
754
+ font: "bold 28px monospace",
755
+ align: "left",
756
+ baseline: "top"
757
+ },
758
+ motion: { type: "static" }
759
+ },
760
+ {
761
+ key: "reads-label",
762
+ count: 1,
763
+ position: { x: 0.06, y: 0.26 },
764
+ sprite: {
765
+ kind: "text",
766
+ strings: ["READS"],
767
+ color: "#445566",
768
+ font: "9px monospace",
769
+ align: "left",
770
+ baseline: "top"
771
+ },
772
+ motion: { type: "static" }
773
+ },
774
+ {
775
+ key: "reads-value",
776
+ count: 1,
777
+ position: { x: 0.06, y: 0.3 },
778
+ sprite: {
779
+ kind: "text",
780
+ strings: ["89"],
781
+ color: "#44ddcc",
782
+ font: "bold 28px monospace",
783
+ align: "left",
784
+ baseline: "top"
785
+ },
786
+ motion: { type: "static" }
787
+ },
788
+ {
789
+ key: "edits-label",
790
+ count: 1,
791
+ position: { x: 0.06, y: 0.4 },
792
+ sprite: {
793
+ kind: "text",
794
+ strings: ["EDITS"],
795
+ color: "#445566",
796
+ font: "9px monospace",
797
+ align: "left",
798
+ baseline: "top"
799
+ },
800
+ motion: { type: "static" }
801
+ },
802
+ {
803
+ key: "edits-value",
804
+ count: 1,
805
+ position: { x: 0.06, y: 0.44 },
806
+ sprite: {
807
+ kind: "text",
808
+ strings: ["34"],
809
+ color: "#ff8844",
810
+ font: "bold 28px monospace",
811
+ align: "left",
812
+ baseline: "top"
813
+ },
814
+ motion: { type: "static" }
815
+ },
816
+ {
817
+ key: "errors-label",
818
+ count: 1,
819
+ position: { x: 0.06, y: 0.54 },
820
+ sprite: {
821
+ kind: "text",
822
+ strings: ["ERRORS"],
823
+ color: "#445566",
824
+ font: "9px monospace",
825
+ align: "left",
826
+ baseline: "top"
827
+ },
828
+ motion: { type: "static" }
829
+ },
830
+ {
831
+ key: "errors-value",
832
+ count: 1,
833
+ position: { x: 0.06, y: 0.58 },
834
+ sprite: {
835
+ kind: "text",
836
+ strings: ["2"],
837
+ color: "#ff4455",
838
+ font: "bold 28px monospace",
839
+ align: "left",
840
+ baseline: "top"
841
+ },
842
+ motion: { type: "static" }
843
+ },
844
+ // --- center column: system gauges ---
845
+ {
846
+ key: "cpu-label",
847
+ count: 1,
848
+ position: { x: 0.38, y: 0.12 },
849
+ sprite: {
850
+ kind: "text",
851
+ strings: ["CPU"],
852
+ color: "#445566",
853
+ font: "9px monospace",
854
+ align: "center"
855
+ },
856
+ motion: { type: "static" }
857
+ },
858
+ {
859
+ key: "cpu-value",
860
+ count: 1,
861
+ position: { x: 0.38, y: 0.22 },
862
+ sprite: {
863
+ kind: "text",
864
+ strings: ["73%"],
865
+ color: "#44ff88",
866
+ font: "bold 36px monospace",
867
+ align: "center"
868
+ },
869
+ motion: { type: "static" }
870
+ },
871
+ {
872
+ key: "mem-label",
873
+ count: 1,
874
+ position: { x: 0.38, y: 0.36 },
875
+ sprite: {
876
+ kind: "text",
877
+ strings: ["MEMORY"],
878
+ color: "#445566",
879
+ font: "9px monospace",
880
+ align: "center"
881
+ },
882
+ motion: { type: "static" }
883
+ },
884
+ {
885
+ key: "mem-value",
886
+ count: 1,
887
+ position: { x: 0.38, y: 0.46 },
888
+ sprite: {
889
+ kind: "text",
890
+ strings: ["4.2 GB"],
891
+ color: "#ddcc44",
892
+ font: "bold 36px monospace",
893
+ align: "center"
894
+ },
895
+ motion: { type: "static" }
896
+ },
897
+ {
898
+ key: "tokens-label",
899
+ count: 1,
900
+ position: { x: 0.38, y: 0.58 },
901
+ sprite: {
902
+ kind: "text",
903
+ strings: ["TOKENS"],
904
+ color: "#445566",
905
+ font: "9px monospace",
906
+ align: "center"
907
+ },
908
+ motion: { type: "static" }
909
+ },
910
+ {
911
+ key: "tokens-value",
912
+ count: 1,
913
+ position: { x: 0.38, y: 0.66 },
914
+ sprite: {
915
+ kind: "text",
916
+ strings: ["128k"],
917
+ color: "#aa88ff",
918
+ font: "bold 28px monospace",
919
+ align: "center"
920
+ },
921
+ motion: { type: "static" }
922
+ },
923
+ // --- right column: recent files ---
924
+ {
925
+ key: "files-label",
926
+ count: 1,
927
+ position: { x: 0.62, y: 0.12 },
928
+ sprite: {
929
+ kind: "text",
930
+ strings: ["RECENT FILES"],
931
+ color: "#445566",
932
+ font: "9px monospace",
933
+ align: "left",
934
+ baseline: "top"
935
+ },
936
+ motion: { type: "static" }
937
+ },
938
+ {
939
+ key: "file-1",
940
+ count: 1,
941
+ position: { x: 0.62, y: 0.17 },
942
+ sprite: {
943
+ kind: "text",
944
+ strings: ["src/worker.ts"],
945
+ color: "#8899aa",
946
+ font: "11px monospace",
947
+ align: "left",
948
+ baseline: "top",
949
+ maxWidth: 280
950
+ },
951
+ motion: { type: "static" }
952
+ },
953
+ {
954
+ key: "file-2",
955
+ count: 1,
956
+ position: { x: 0.62, y: 0.21 },
957
+ sprite: {
958
+ kind: "text",
959
+ strings: ["site/src/App.tsx"],
960
+ color: "#778899",
961
+ font: "11px monospace",
962
+ align: "left",
963
+ baseline: "top",
964
+ maxWidth: 280
965
+ },
966
+ motion: { type: "static" }
967
+ },
968
+ {
969
+ key: "file-3",
970
+ count: 1,
971
+ position: { x: 0.62, y: 0.25 },
972
+ sprite: {
973
+ kind: "text",
974
+ strings: ["packages/schema/compile.ts"],
975
+ color: "#667788",
976
+ font: "11px monospace",
977
+ align: "left",
978
+ baseline: "top",
979
+ maxWidth: 280
980
+ },
981
+ motion: { type: "static" }
982
+ },
983
+ {
984
+ key: "file-4",
985
+ count: 1,
986
+ position: { x: 0.62, y: 0.29 },
987
+ sprite: {
988
+ kind: "text",
989
+ strings: ["docs/dashboard-spec.md"],
990
+ color: "#556677",
991
+ font: "11px monospace",
992
+ align: "left",
993
+ baseline: "top",
994
+ maxWidth: 280
995
+ },
996
+ motion: { type: "static" }
997
+ },
998
+ {
999
+ key: "file-5",
1000
+ count: 1,
1001
+ position: { x: 0.62, y: 0.33 },
1002
+ sprite: {
1003
+ kind: "text",
1004
+ strings: ["packages/core/types.ts"],
1005
+ color: "#445566",
1006
+ font: "11px monospace",
1007
+ align: "left",
1008
+ baseline: "top",
1009
+ maxWidth: 280
1010
+ },
1011
+ motion: { type: "static" }
1012
+ },
1013
+ // --- right column: session info ---
1014
+ {
1015
+ key: "session-label",
1016
+ count: 1,
1017
+ position: { x: 0.62, y: 0.42 },
1018
+ sprite: {
1019
+ kind: "text",
1020
+ strings: ["SESSION"],
1021
+ color: "#445566",
1022
+ font: "9px monospace",
1023
+ align: "left",
1024
+ baseline: "top"
1025
+ },
1026
+ motion: { type: "static" }
1027
+ },
1028
+ {
1029
+ key: "session-model",
1030
+ count: 1,
1031
+ position: { x: 0.62, y: 0.47 },
1032
+ sprite: {
1033
+ kind: "text",
1034
+ strings: ["claude-opus-4-6"],
1035
+ color: "#8888aa",
1036
+ font: "11px monospace",
1037
+ align: "left",
1038
+ baseline: "top"
1039
+ },
1040
+ motion: { type: "static" }
1041
+ },
1042
+ {
1043
+ key: "session-cost",
1044
+ count: 1,
1045
+ position: { x: 0.62, y: 0.51 },
1046
+ sprite: {
1047
+ kind: "text",
1048
+ strings: ["$2.47 this session"],
1049
+ color: "#667788",
1050
+ font: "11px monospace",
1051
+ align: "left",
1052
+ baseline: "top"
1053
+ },
1054
+ motion: { type: "static" }
1055
+ },
1056
+ // --- bottom: event log ---
1057
+ {
1058
+ key: "log-label",
1059
+ count: 1,
1060
+ position: { x: 0.06, y: 0.76 },
1061
+ sprite: {
1062
+ kind: "text",
1063
+ strings: ["EVENT LOG"],
1064
+ color: "#445566",
1065
+ font: "9px monospace",
1066
+ align: "left",
1067
+ baseline: "top"
1068
+ },
1069
+ motion: { type: "static" }
1070
+ },
1071
+ {
1072
+ key: "log-1",
1073
+ count: 1,
1074
+ position: { x: 0.06, y: 0.8 },
1075
+ sprite: {
1076
+ kind: "text",
1077
+ strings: ["14:07 Edit compile.ts +18 -3"],
1078
+ color: "#667766",
1079
+ font: "10px monospace",
1080
+ align: "left",
1081
+ baseline: "top",
1082
+ maxWidth: 600
1083
+ },
1084
+ motion: { type: "static" }
1085
+ },
1086
+ {
1087
+ key: "log-2",
1088
+ count: 1,
1089
+ position: { x: 0.06, y: 0.84 },
1090
+ sprite: {
1091
+ kind: "text",
1092
+ strings: ["14:06 Bash pnpm test \u2713 125 passed"],
1093
+ color: "#556655",
1094
+ font: "10px monospace",
1095
+ align: "left",
1096
+ baseline: "top",
1097
+ maxWidth: 600
1098
+ },
1099
+ motion: { type: "static" }
1100
+ },
1101
+ {
1102
+ key: "log-3",
1103
+ count: 1,
1104
+ position: { x: 0.06, y: 0.88 },
1105
+ sprite: {
1106
+ kind: "text",
1107
+ strings: ["14:05 Read types.ts (121 lines)"],
1108
+ color: "#4d5e4d",
1109
+ font: "10px monospace",
1110
+ align: "left",
1111
+ baseline: "top",
1112
+ maxWidth: 600
1113
+ },
1114
+ motion: { type: "static" }
1115
+ },
1116
+ {
1117
+ key: "log-4",
1118
+ count: 1,
1119
+ position: { x: 0.06, y: 0.92 },
1120
+ sprite: {
1121
+ kind: "text",
1122
+ strings: ["14:03 Edit examples/dev-dashboard.ts +84 -1"],
1123
+ color: "#445544",
1124
+ font: "10px monospace",
1125
+ align: "left",
1126
+ baseline: "top",
1127
+ maxWidth: 600
1128
+ },
1129
+ motion: { type: "static" }
1130
+ },
1131
+ {
1132
+ key: "log-5",
1133
+ count: 1,
1134
+ position: { x: 0.06, y: 0.96 },
1135
+ sprite: {
1136
+ kind: "text",
1137
+ strings: ["14:01 Bash pnpm build \u2713 6 packages"],
1138
+ color: "#3d4e3d",
1139
+ font: "10px monospace",
1140
+ align: "left",
1141
+ baseline: "top",
1142
+ maxWidth: 600
1143
+ },
1144
+ motion: { type: "static" }
1145
+ }
1146
+ ]
1147
+ };
1148
+ var LANTERNS_SPEC = {
1149
+ schemaVersion: 1,
1150
+ id: "lanterns",
1151
+ label: "Night Lanterns",
1152
+ seed: 88,
1153
+ motionIntensity: "calm",
1154
+ background: {
1155
+ type: "gradient",
1156
+ stops: [
1157
+ { at: 0, color: "#04060f" },
1158
+ { at: 0.55, color: "#0b1026" },
1159
+ { at: 0.85, color: "#251731" },
1160
+ { at: 1, color: "#472518" }
1161
+ ]
1162
+ },
1163
+ layers: [
1164
+ {
1165
+ count: 60,
1166
+ sprite: { kind: "circle", radius: [0.5, 1.4], color: "#8fa0c8" },
1167
+ alpha: [0.35, 1],
1168
+ region: { y: [0, 0.62] },
1169
+ motion: { type: "drift", speed: [0.5, 2], bob: 1 }
1170
+ },
1171
+ {
1172
+ count: 36,
1173
+ sprite: {
1174
+ kind: "circle",
1175
+ radius: [1.5, 3],
1176
+ color: "#b06a2a",
1177
+ soft: true
1178
+ },
1179
+ alpha: [0.5, 0.9],
1180
+ blend: "lighter",
1181
+ pulse: { amp: 0.18, period: 2800 },
1182
+ motion: { type: "rise", speed: [6, 14], sway: 4 }
1183
+ },
1184
+ {
1185
+ count: 14,
1186
+ sprite: {
1187
+ kind: "circle",
1188
+ radius: [3.5, 6.5],
1189
+ color: "#e08a34",
1190
+ soft: true
1191
+ },
1192
+ alpha: [0.6, 1],
1193
+ blend: "lighter",
1194
+ pulse: { amp: 0.22, period: 3400 },
1195
+ motion: { type: "rise", speed: [16, 28], sway: 7 }
1196
+ },
1197
+ {
1198
+ count: 8,
1199
+ sprite: { kind: "emoji", glyphs: ["\u{1F3EE}"] },
1200
+ size: [26, 44],
1201
+ alpha: [0.85, 1],
1202
+ motion: { type: "rise", speed: [30, 48], sway: 10 }
1203
+ },
1204
+ {
1205
+ count: 4,
1206
+ sprite: { kind: "emoji", glyphs: ["\u{1F3EE}"] },
1207
+ size: [58, 84],
1208
+ motion: { type: "rise", speed: [52, 74], sway: 14 }
1209
+ },
1210
+ {
1211
+ count: 12,
1212
+ sprite: { kind: "circle", radius: [2, 5], color: "#e08a34", soft: true },
1213
+ alpha: [0.12, 0.35],
1214
+ blend: "lighter",
1215
+ region: { y: [0.93, 1] },
1216
+ pulse: { amp: 0.1, period: 2200 },
1217
+ motion: { type: "drift", speed: [2, 6], bob: 2 }
1218
+ }
1219
+ ]
1220
+ };
1221
+ var RAIN_SPEC = {
1222
+ schemaVersion: 1,
1223
+ id: "rain",
1224
+ label: "Rain",
1225
+ seed: 7,
1226
+ motionIntensity: "moderate",
1227
+ background: { type: "solid", color: "#05070a" },
1228
+ layers: [
1229
+ {
1230
+ count: 140,
1231
+ sprite: { kind: "text", strings: ["\u2502"], color: "#9fd0ff" },
1232
+ size: [12, 26],
1233
+ motion: { type: "drift", angle: 90, speed: [520, 900] }
1234
+ }
1235
+ ]
1236
+ };
1237
+ var SAKURA_SPEC = {
1238
+ schemaVersion: 1,
1239
+ id: "sakura",
1240
+ label: "Sakura Drift",
1241
+ seed: 314,
1242
+ motionIntensity: "calm",
1243
+ background: {
1244
+ type: "gradient",
1245
+ stops: [
1246
+ { at: 0, color: "#1b1d38" },
1247
+ { at: 0.45, color: "#3a2645" },
1248
+ { at: 0.8, color: "#7d3d4e" },
1249
+ { at: 1, color: "#0f140d" }
1250
+ ],
1251
+ band: { color: "#0c140d", height: 44 }
1252
+ },
1253
+ layers: [
1254
+ {
1255
+ count: 60,
1256
+ sprite: { kind: "circle", radius: [0.6, 1.6], color: "#ffe3ec", soft: true },
1257
+ alpha: [0.3, 0.9],
1258
+ blend: "lighter",
1259
+ region: { y: [0, 0.72] },
1260
+ pulse: { amp: 0.22, period: 3e3 },
1261
+ motion: { type: "drift", speed: [0.3, 1.2], bob: 1 }
1262
+ },
1263
+ {
1264
+ count: 28,
1265
+ sprite: { kind: "emoji", glyphs: ["\u{1F338}"] },
1266
+ size: [13, 20],
1267
+ alpha: [0.5, 0.8],
1268
+ motion: { type: "drift", speed: [12, 26], angle: 100, bob: 3 }
1269
+ },
1270
+ {
1271
+ count: 18,
1272
+ sprite: { kind: "emoji", glyphs: ["\u{1F338}"] },
1273
+ size: [20, 32],
1274
+ alpha: [0.7, 0.95],
1275
+ motion: { type: "drift", speed: [24, 44], angle: 100, bob: 6 }
1276
+ },
1277
+ {
1278
+ count: 10,
1279
+ sprite: { kind: "emoji", glyphs: ["\u{1F338}"] },
1280
+ size: [34, 54],
1281
+ alpha: [0.85, 1],
1282
+ motion: { type: "drift", speed: [42, 68], angle: 100, bob: 11 }
1283
+ },
1284
+ {
1285
+ count: 16,
1286
+ sprite: { kind: "circle", radius: [1.5, 4], color: "#ff9bb5", soft: true },
1287
+ alpha: [0.1, 0.3],
1288
+ blend: "lighter",
1289
+ region: { y: [0.9, 1] },
1290
+ pulse: { amp: 0.15, period: 2600 },
1291
+ motion: { type: "drift", speed: [0.3, 1.5], angle: 180, bob: 1 }
1292
+ }
1293
+ ]
1294
+ };
1295
+ var SNOWFALL_SPEC = {
1296
+ schemaVersion: 1,
1297
+ id: "snowfall",
1298
+ label: "Snowfall",
1299
+ seed: 12,
1300
+ motionIntensity: "calm",
1301
+ background: {
1302
+ type: "gradient",
1303
+ stops: [
1304
+ { at: 0, color: "#0a1628" },
1305
+ { at: 0.7, color: "#0d1f3c" },
1306
+ { at: 1, color: "#121212" }
1307
+ ]
1308
+ },
1309
+ layers: [
1310
+ {
1311
+ count: 50,
1312
+ sprite: { kind: "circle", radius: [1, 2.5], color: "#8899aa" },
1313
+ motion: { type: "drift", angle: 90, speed: [15, 40], bob: 3 }
1314
+ },
1315
+ {
1316
+ count: 35,
1317
+ sprite: { kind: "circle", radius: [2, 4.5], color: "#c0cdd8" },
1318
+ motion: { type: "drift", angle: 85, speed: [35, 80], bob: 6 }
1319
+ },
1320
+ {
1321
+ count: 15,
1322
+ sprite: { kind: "circle", radius: [3.5, 7], color: "#e8eff5" },
1323
+ motion: { type: "drift", angle: 82, speed: [55, 120], bob: 10 }
1324
+ }
1325
+ ]
1326
+ };
1327
+ var SCHEMA_EXAMPLES = [
1328
+ { id: "aquarium", label: "Aquarium", spec: AQUARIUM_SPEC },
1329
+ { id: "rain", label: "Rain", spec: RAIN_SPEC },
1330
+ { id: "snowfall", label: "Snowfall", spec: SNOWFALL_SPEC },
1331
+ { id: "lanterns", label: "Night Lanterns", spec: LANTERNS_SPEC },
1332
+ { id: "sakura", label: "Sakura Drift", spec: SAKURA_SPEC },
1333
+ { id: "dev-dashboard", label: "Dev Dashboard", spec: DASHBOARD_SPEC }
1334
+ ];
1335
+ var EXAMPLE_SPECS = SCHEMA_EXAMPLES.map((e) => e.spec);
1336
+ var EXAMPLE_BY_ID = Object.fromEntries(
1337
+ SCHEMA_EXAMPLES.map((e) => [e.id, e.spec])
1338
+ );
1339
+
1340
+ // src/idle-worker.ts
1341
+ runIdleWorker(
1342
+ {
1343
+ [warp.manifest.id]: warp,
1344
+ [hardRain.manifest.id]: hardRain,
1345
+ [rainstorm.manifest.id]: rainstorm,
1346
+ [globe.manifest.id]: globe,
1347
+ [spotlight.manifest.id]: spotlight,
1348
+ [mystify.manifest.id]: mystify,
1349
+ [pipes.manifest.id]: pipes,
1350
+ [flurry.manifest.id]: flurry,
1351
+ [fluid.manifest.id]: fluid,
1352
+ [reactionDiffusion.manifest.id]: reactionDiffusion
1353
+ },
1354
+ { compiler: compileSaver }
1355
+ );
18
1356
  //# sourceMappingURL=idle-worker.js.map