From ae75c9c717f70b72763234a8378fd5e814ee0b99 Mon Sep 17 00:00:00 2001 From: Mister Nemo Date: Thu, 28 May 2026 00:40:18 -0400 Subject: [PATCH] feat: honor cljs blink trigger randomness overrides --- scripts/smoke-cljs-blink.mjs | 19 ++++++++++++++++++- src-cljs/latticework/blink.cljs | 5 ++++- types/cljs.d.ts | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/scripts/smoke-cljs-blink.mjs b/scripts/smoke-cljs-blink.mjs index 592f09c..156070a 100644 --- a/scripts/smoke-cljs-blink.mjs +++ b/scripts/smoke-cljs-blink.mjs @@ -44,6 +44,13 @@ if (!Array.isArray(curve) || curve.length !== 7) { throw new Error(`Expected AU 43 curve with seven points, received ${curve?.length ?? 'none'}`); } +if (snippet.snippetCategory !== 'blink' || + snippet.snippetPriority !== 100 || + snippet.snippetPlaybackRate !== 1.0 || + snippet.snippetIntensityScale !== 1.0) { + throw new Error(`Expected blink snippet metadata to stay stable, received ${JSON.stringify(snippet)}`); +} + if (opts?.autoPlay !== true) { throw new Error('Expected blink snippet to request autoPlay'); } @@ -52,10 +59,20 @@ if (state.scheduledBlinkCount !== 1) { throw new Error(`Expected scheduledBlinkCount to be 1, received ${state.scheduledBlinkCount}`); } +agency.setRandomness(1); +agency.triggerBlink({ intensity: 0.4, duration: 0.2, randomness: 0 }); + +const overrideCurve = scheduled[1].snippet.curves?.['43']; +if (scheduled[1].snippet.maxTime !== 0.2 || overrideCurve?.[2]?.intensity !== 0.4) { + throw new Error(`Expected per-trigger blink overrides to ignore configured randomness, received ${JSON.stringify(scheduled[1])}`); +} + +const manualScheduledCount = scheduled.length; +agency.setRandomness(0); agency.enable(); await wait(1100); -if (scheduled.length < 2) { +if (scheduled.length <= manualScheduledCount) { throw new Error(`Expected automatic blink after enable, received ${scheduled.length} scheduled snippets`); } diff --git a/src-cljs/latticework/blink.cljs b/src-cljs/latticework/blink.cljs index fb95502..1d51cc9 100644 --- a/src-cljs/latticework/blink.cljs +++ b/src-cljs/latticework/blink.cljs @@ -112,7 +112,10 @@ 0.05 1.0 (protocol/maybe-number (:duration overrides) (:duration current))) - randomness (:randomness current) + randomness (protocol/clamp + 0 + 1 + (protocol/maybe-number (:randomness overrides) (:randomness current))) name (str "blink_" (.round js/Math (protocol/now-ms)))] {:name name :curves (build-blink-curves intensity duration randomness) diff --git a/types/cljs.d.ts b/types/cljs.d.ts index 3409cd0..ba8035d 100644 --- a/types/cljs.d.ts +++ b/types/cljs.d.ts @@ -248,6 +248,7 @@ export interface BlinkAgencyConfig { export interface BlinkTriggerOptions { intensity?: number; duration?: number; + randomness?: number; } export interface BlinkAgency {