@idle-screens/savers-classic 2.0.1 → 3.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.
@@ -177,6 +177,11 @@ var hardRainManifest = {
177
177
  costTier: "low",
178
178
  motionIntensity: "moderate",
179
179
  reducedMotionFallback: "static",
180
+ attribution: {
181
+ source: 'After Dark "Hard Rain" \u2014 concept by Berkeley Systems',
182
+ license: "MIT port; reference CSS MIT (Bryan Braun)",
183
+ url: "https://github.com/bryanbraun/after-dark-css"
184
+ },
180
185
  a11y: { flashSafe: true, notes: "Slow-expanding coloured rings on black; no flashing." },
181
186
  workerReady: true
182
187
  };
@@ -463,6 +468,11 @@ var rainstormManifest = {
463
468
  costTier: "low",
464
469
  motionIntensity: "moderate",
465
470
  reducedMotionFallback: "static",
471
+ attribution: {
472
+ source: 'After Dark "Rainstorm" \u2014 concept by Berkeley Systems',
473
+ license: "MIT port; reference CSS MIT (Bryan Braun)",
474
+ url: "https://github.com/bryanbraun/after-dark-css"
475
+ },
466
476
  a11y: { flashSafe: true, notes: "Rain streaks over a dark sky; the lightning is a brief, gentle brightening (no rapid strobe)." },
467
477
  workerReady: true
468
478
  };
@@ -639,6 +649,11 @@ var globeManifest = {
639
649
  costTier: "low",
640
650
  motionIntensity: "calm",
641
651
  reducedMotionFallback: "static",
652
+ attribution: {
653
+ source: 'After Dark "Globe" \u2014 concept by Berkeley Systems',
654
+ license: "MIT port; reference CSS MIT (Bryan Braun)",
655
+ url: "https://github.com/bryanbraun/after-dark-css"
656
+ },
642
657
  a11y: { flashSafe: true, notes: "A slowly spinning dotted globe drifting on black; no flashing." },
643
658
  workerReady: true
644
659
  };
@@ -842,6 +857,11 @@ var spotlightManifest = {
842
857
  costTier: "low",
843
858
  motionIntensity: "calm",
844
859
  reducedMotionFallback: "static",
860
+ attribution: {
861
+ source: 'After Dark "Spotlight" \u2014 concept by Berkeley Systems',
862
+ license: "MIT port; reference CSS MIT (Bryan Braun)",
863
+ url: "https://github.com/bryanbraun/after-dark-css"
864
+ },
845
865
  a11y: { flashSafe: true, notes: "A soft light circle drifting over the live page; no flashing." },
846
866
  workerReady: true
847
867
  };
@@ -886,12 +906,12 @@ var SpotlightInstance = class {
886
906
  this.c2d.setTransform(dpr, 0, 0, dpr, 0, 0);
887
907
  }
888
908
  centre() {
889
- const tri = (t, period) => {
909
+ const tri2 = (t, period) => {
890
910
  const p = (t % (period * 2) + period * 2) % (period * 2);
891
911
  return p < period ? p / period : 2 - p / period;
892
912
  };
893
- const kx = tri(this.clock, SPEED_X);
894
- const ky = tri(this.clock, SPEED_Y);
913
+ const kx = tri2(this.clock, SPEED_X);
914
+ const ky = tri2(this.clock, SPEED_Y);
895
915
  const x = HOLE_RADIUS + kx * (this.w - HOLE_RADIUS * 2);
896
916
  const y = HOLE_RADIUS + ky * (this.h - HOLE_RADIUS * 2);
897
917
  return [x, y];
@@ -976,6 +996,10 @@ var mystifyManifest = {
976
996
  costTier: "low",
977
997
  motionIntensity: "moderate",
978
998
  reducedMotionFallback: "static",
999
+ attribution: {
1000
+ source: 'Windows "Mystify" \u2014 concept only; clean-room reimplementation',
1001
+ license: "MIT (original code)"
1002
+ },
979
1003
  a11y: { flashSafe: true, notes: "Slow-fade polygon trails on black; no strobing." },
980
1004
  workerReady: true
981
1005
  };
@@ -3217,6 +3241,224 @@ var reactionDiffusion = {
3217
3241
  }
3218
3242
  };
3219
3243
 
3244
+ // src/messages.ts
3245
+ import {
3246
+ sampleTrack,
3247
+ defaultParams
3248
+ } from "@idle-screens/core";
3249
+ var PHRASES = {
3250
+ "out-to-lunch": "OUT TO LUNCH",
3251
+ "staring": "Why are you staring at my Macintosh?",
3252
+ "brb": "BE RIGHT BACK",
3253
+ "gone-idle": "gone idle \u2014 leave a message",
3254
+ "ship-it": "SHIP IT IN THE MORNING"
3255
+ };
3256
+ var PARAM_SPACE = {
3257
+ /** Which line the screen mutters. */
3258
+ phrase: { type: "enum", default: "out-to-lunch", options: Object.keys(PHRASES) },
3259
+ /** 'marquee' = the Out-to-Lunch crawl (steps down the page);
3260
+ * 'drift' = the Macintosh corner-to-corner wander. */
3261
+ mode: { type: "enum", default: "marquee", options: ["marquee", "drift"] },
3262
+ speed: { type: "number", default: 1, min: 0.25, max: 3, ease: "smooth" },
3263
+ /** Text size multiplier on the short-edge-relative base. */
3264
+ textScale: { type: "number", default: 1, min: 0.5, max: 2.6, ease: "smooth" },
3265
+ ink: { type: "color", default: "#e8ecf4" },
3266
+ /** Phosphor glow around the letters. */
3267
+ glow: { type: "number", default: 0.4, min: 0, max: 1, ease: "smooth" },
3268
+ /** Ghost trail of previous instants. */
3269
+ trail: { type: "number", default: 0.25, min: 0, max: 1, ease: "smooth" }
3270
+ };
3271
+ var messagesManifest = {
3272
+ id: "messages",
3273
+ label: "Messages",
3274
+ passthrough: false,
3275
+ minBackend: "canvas2d",
3276
+ costTier: "low",
3277
+ motionIntensity: "calm",
3278
+ reducedMotionFallback: "static",
3279
+ paramSpace: PARAM_SPACE,
3280
+ attribution: {
3281
+ source: 'After Dark "Messages" \u2014 concepts by Berkeley Systems',
3282
+ license: "MIT port; reference CSS MIT (Bryan Braun)",
3283
+ url: "https://github.com/bryanbraun/after-dark-css"
3284
+ },
3285
+ a11y: { flashSafe: true, notes: "A single line of text moving smoothly; no flashing." },
3286
+ workerReady: true
3287
+ };
3288
+ var tri = (t, p) => {
3289
+ const k = (t % (p * 2) + p * 2) % (p * 2);
3290
+ return k < p ? k / p : 2 - k / p;
3291
+ };
3292
+ var MessagesInstance = class {
3293
+ ctxSaver;
3294
+ canvas;
3295
+ c2d;
3296
+ w = 0;
3297
+ h = 0;
3298
+ frameId = null;
3299
+ paused = false;
3300
+ startT = 0;
3301
+ t = 0;
3302
+ params = defaultParams(PARAM_SPACE);
3303
+ track = null;
3304
+ constructor(ctx) {
3305
+ this.ctxSaver = ctx;
3306
+ if (ctx.surface) {
3307
+ this.canvas = ctx.surface;
3308
+ } else {
3309
+ const el = document.createElement("canvas");
3310
+ el.style.cssText = "display:block;width:100%;height:100%;background:#04050a";
3311
+ ctx.host.appendChild(el);
3312
+ this.canvas = el;
3313
+ }
3314
+ const c2d = this.canvas.getContext("2d", { alpha: false });
3315
+ if (!c2d) throw new Error("messages: no 2d context");
3316
+ this.c2d = c2d;
3317
+ this.w = ctx.width;
3318
+ this.h = ctx.height;
3319
+ this.sizeCanvas();
3320
+ this.paused = ctx.reducedMotion;
3321
+ if (this.paused) this.renderStill();
3322
+ else this.start();
3323
+ }
3324
+ applyParams(t) {
3325
+ const p = this.track ? sampleTrack(PARAM_SPACE, this.track, t) : this.params;
3326
+ for (const k of Object.keys(PARAM_SPACE)) {
3327
+ const v = p[k];
3328
+ if (v !== void 0) this.params[k] = v;
3329
+ }
3330
+ }
3331
+ sizeCanvas() {
3332
+ const dpr = Math.min(this.ctxSaver.dpr, 2);
3333
+ this.canvas.width = Math.max(1, Math.round(this.w * dpr));
3334
+ this.canvas.height = Math.max(1, Math.round(this.h * dpr));
3335
+ this.c2d.setTransform(dpr, 0, 0, dpr, 0, 0);
3336
+ }
3337
+ // ---- closed-form placement ----
3338
+ fontPx() {
3339
+ return Math.max(14, Math.min(this.w, this.h) * 0.05 * this.params.textScale);
3340
+ }
3341
+ font() {
3342
+ return `500 ${this.fontPx().toFixed(1)}px ui-rounded, "Avenir Next", "Segoe UI Variable Display", system-ui, sans-serif`;
3343
+ }
3344
+ /** Position of the line's left baseline at time `t`. Pure. */
3345
+ place(t, textW) {
3346
+ const p = this.params;
3347
+ const fs = this.fontPx();
3348
+ if (p.mode === "marquee") {
3349
+ const crawl = 1e4 / p.speed;
3350
+ const k = (t % crawl + crawl) % crawl;
3351
+ const x2 = this.w - k / crawl * (this.w + textW * 1.5);
3352
+ const stepPhase = (t % (crawl * 3) + crawl * 3) % (crawl * 3);
3353
+ const row = Math.floor(stepPhase / crawl);
3354
+ const y2 = this.h * 0.22 + row * this.h * 0.27 + fs * 0.5;
3355
+ return [x2, y2];
3356
+ }
3357
+ const x = tri(t, 8e3 / p.speed) * Math.max(0, this.w - textW);
3358
+ const y = fs + tri(t, 17300 / p.speed) * Math.max(0, this.h - fs * 1.6);
3359
+ return [x, y];
3360
+ }
3361
+ // ---- loop ----
3362
+ start() {
3363
+ if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
3364
+ this.startT = 0;
3365
+ this.frameId = requestAnimationFrame((now) => this.loop(now));
3366
+ }
3367
+ stop() {
3368
+ if (this.frameId !== null) {
3369
+ cancelAnimationFrame(this.frameId);
3370
+ this.frameId = null;
3371
+ }
3372
+ }
3373
+ loop(now) {
3374
+ this.frameId = requestAnimationFrame((n) => this.loop(n));
3375
+ if (this.startT === 0) this.startT = now;
3376
+ this.renderFrame(now - this.startT, this.ctxSaver.seed);
3377
+ }
3378
+ renderStill() {
3379
+ this.renderFrame(this.t, this.ctxSaver.seed);
3380
+ }
3381
+ render(t) {
3382
+ const ctx = this.c2d;
3383
+ const p = this.params;
3384
+ ctx.fillStyle = "#04050a";
3385
+ ctx.fillRect(0, 0, this.w, this.h);
3386
+ ctx.font = this.font();
3387
+ ctx.textBaseline = "alphabetic";
3388
+ const text = PHRASES[p.phrase] ?? PHRASES["out-to-lunch"];
3389
+ const textW = ctx.measureText(text).width;
3390
+ if (p.trail > 0.02) {
3391
+ for (let k = 4; k >= 1; k--) {
3392
+ const [gx, gy] = this.place(t - k * 90, textW);
3393
+ ctx.globalAlpha = p.trail * 0.16 * (1 - k / 5);
3394
+ ctx.fillStyle = p.ink;
3395
+ ctx.fillText(text, gx, gy);
3396
+ }
3397
+ ctx.globalAlpha = 1;
3398
+ }
3399
+ const [x, y] = this.place(t, textW);
3400
+ if (p.glow > 0.02) {
3401
+ ctx.shadowColor = p.ink;
3402
+ ctx.shadowBlur = this.fontPx() * 0.55 * p.glow;
3403
+ }
3404
+ ctx.fillStyle = p.ink;
3405
+ ctx.fillText(text, x, y);
3406
+ ctx.shadowBlur = 0;
3407
+ }
3408
+ // ---- SaverInstance ----
3409
+ setPaused(paused) {
3410
+ this.paused = paused;
3411
+ if (paused) {
3412
+ this.stop();
3413
+ this.renderStill();
3414
+ } else {
3415
+ this.start();
3416
+ }
3417
+ }
3418
+ resize(width, height, dpr) {
3419
+ this.w = width;
3420
+ this.h = height;
3421
+ if (dpr !== void 0) this.ctxSaver.dpr = dpr;
3422
+ this.sizeCanvas();
3423
+ if (this.paused) this.renderStill();
3424
+ }
3425
+ applyTrack(track) {
3426
+ this.track = track;
3427
+ if (this.paused) this.renderStill();
3428
+ }
3429
+ /** Pure, frame-addressable render at logical time `t`. */
3430
+ renderFrame(t, _seed) {
3431
+ this.t = t;
3432
+ this.applyParams(t);
3433
+ this.render(t);
3434
+ }
3435
+ dispose() {
3436
+ this.stop();
3437
+ if (typeof HTMLCanvasElement !== "undefined" && this.canvas instanceof HTMLCanvasElement) this.canvas.remove();
3438
+ }
3439
+ };
3440
+ var messages = {
3441
+ manifest: messagesManifest,
3442
+ mount: (ctx) => new MessagesInstance(ctx)
3443
+ };
3444
+ var messagesDemoTrack = {
3445
+ program: "messages",
3446
+ seed: 2,
3447
+ duration: 2e4,
3448
+ loop: true,
3449
+ deltas: [
3450
+ { t: 0, path: "mode", value: "marquee" },
3451
+ { t: 1e4, path: "mode", value: "drift" },
3452
+ { t: 0, path: "phrase", value: "out-to-lunch" },
3453
+ { t: 1e4, path: "phrase", value: "staring" },
3454
+ { t: 0, path: "glow", value: 0.2 },
3455
+ { t: 5e3, path: "glow", value: 0.7, ease: "smooth" },
3456
+ { t: 1e4, path: "glow", value: 0.2, ease: "smooth" },
3457
+ { t: 15e3, path: "glow", value: 0.7, ease: "smooth" },
3458
+ { t: 2e4, path: "glow", value: 0.2, ease: "smooth" }
3459
+ ]
3460
+ };
3461
+
3220
3462
  export {
3221
3463
  warp,
3222
3464
  hardRain,
@@ -3227,6 +3469,8 @@ export {
3227
3469
  pipes,
3228
3470
  flurry,
3229
3471
  fluid,
3230
- reactionDiffusion
3472
+ reactionDiffusion,
3473
+ messages,
3474
+ messagesDemoTrack
3231
3475
  };
3232
- //# sourceMappingURL=chunk-MIVXP2IL.js.map
3476
+ //# sourceMappingURL=chunk-RMW74SYX.js.map