@unisim/sdk 0.118.0 → 0.118.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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type RefObject } from 'react';
|
|
2
1
|
/**
|
|
3
2
|
* The landing-illustration clock, shared by every app that has one.
|
|
4
3
|
*
|
|
@@ -39,8 +38,17 @@ import { type RefObject } from 'react';
|
|
|
39
38
|
* carry the whole gap and jump the loop forward.
|
|
40
39
|
*
|
|
41
40
|
* @example
|
|
42
|
-
* const ref =
|
|
41
|
+
* const ref = useRef<HTMLDivElement>(null)
|
|
42
|
+
* useIllustrationClock(ref, { sweepMs: 5200 })
|
|
43
43
|
* return <div ref={ref} className="vid-illu">…</div>
|
|
44
|
+
*
|
|
45
|
+
* ⚠️ It TAKES a ref rather than returning one, and that is about React
|
|
46
|
+
* versions rather than taste. This package builds against React 19's types,
|
|
47
|
+
* where `useRef<T>(null)` is `RefObject<T | null>`; every consuming app is on
|
|
48
|
+
* React 18, where a `ref` prop wants `RefObject<T>`. A returned ref therefore
|
|
49
|
+
* failed to typecheck in all five apps at once. Taking `{ current: T | null }`
|
|
50
|
+
* — structural, not React's own type — lets each app create the ref with its
|
|
51
|
+
* own React and hand it over.
|
|
44
52
|
*/
|
|
45
53
|
export interface IllustrationClockOptions {
|
|
46
54
|
/**
|
|
@@ -52,7 +60,9 @@ export interface IllustrationClockOptions {
|
|
|
52
60
|
/** Milliseconds for the glide back to frame 0 on hover. */
|
|
53
61
|
returnMs?: number;
|
|
54
62
|
}
|
|
55
|
-
export declare function useIllustrationClock<T extends HTMLElement =
|
|
63
|
+
export declare function useIllustrationClock<T extends HTMLElement = HTMLElement>(ref: {
|
|
64
|
+
current: T | null;
|
|
65
|
+
}, { sweepMs, returnMs }?: IllustrationClockOptions): void;
|
|
56
66
|
/** Ease in and out. The clock is linear; this is what makes the motion not. */
|
|
57
67
|
export declare const smoothstep: (x: number) => number;
|
|
58
68
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"illustrationClock.d.ts","sourceRoot":"","sources":["../src/illustrationClock.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"illustrationClock.d.ts","sourceRoot":"","sources":["../src/illustrationClock.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EACtE,GAAG,EAAE;IAAE,OAAO,EAAE,CAAC,GAAG,IAAI,CAAA;CAAE,EAC1B,EAAE,OAAc,EAAE,QAAc,EAAE,GAAE,wBAA6B,GAChE,IAAI,CAoFN;AAED,+EAA+E;AAC/E,eAAO,MAAM,UAAU,GAAI,GAAG,MAAM,WAAwB,CAAA;AAE5D;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,YAAY,GAAI,GAAG,MAAM,WAGrC,CAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useEffect, useRef } from 'react';
|
|
3
|
-
export function useIllustrationClock({ sweepMs = 5200, returnMs = 480
|
|
4
|
-
const ref = useRef(null);
|
|
3
|
+
export function useIllustrationClock(ref, { sweepMs = 5200, returnMs = 480 } = {}) {
|
|
5
4
|
// Read through refs inside the effect so changing a duration re-paces the
|
|
6
5
|
// running loop instead of tearing it down and restarting the sweep from 0.
|
|
7
6
|
const sweep = useRef(sweepMs);
|
|
@@ -80,8 +79,7 @@ export function useIllustrationClock({ sweepMs = 5200, returnMs = 480, } = {}) {
|
|
|
80
79
|
el.removeEventListener('pointerleave', onLeave);
|
|
81
80
|
}
|
|
82
81
|
};
|
|
83
|
-
}, []);
|
|
84
|
-
return ref;
|
|
82
|
+
}, [ref]);
|
|
85
83
|
}
|
|
86
84
|
/** Ease in and out. The clock is linear; this is what makes the motion not. */
|
|
87
85
|
export const smoothstep = (x) => x * x * (3 - 2 * x);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"illustrationClock.js","sourceRoot":"","sources":["../src/illustrationClock.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"illustrationClock.js","sourceRoot":"","sources":["../src/illustrationClock.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAiEzC,MAAM,UAAU,oBAAoB,CAClC,GAA0B,EAC1B,EAAE,OAAO,GAAG,IAAI,EAAE,QAAQ,GAAG,GAAG,KAA+B,EAAE;IAEjE,0EAA0E;IAC1E,2EAA2E;IAC3E,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;IAC7B,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC7B,KAAK,CAAC,OAAO,GAAG,OAAO,CAAA;IACvB,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAA;IAEvB,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAA;QACtB,IAAI,CAAC,EAAE;YAAE,OAAM;QACf,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;QAEpE,IAAI,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,EAAE,CAAC;YAClE,GAAG,CAAC,CAAC,CAAC,CAAA;YACN,OAAM;QACR,CAAC;QAED,IAAI,GAAG,GAAG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