@fanfare-io/fanfare-sdk-react 0.10.0 → 0.11.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.
@@ -0,0 +1,23 @@
1
+ /**
2
+ * A server-anchored clock for time-derived rendering (countdowns). `nowMs()`
3
+ * returns "now" corrected to the server's clock, so a skewed device clock
4
+ * doesn't shift what renders.
5
+ *
6
+ * Two phases, provided by `<FanfareProvider serverNow>`:
7
+ * - server render + the client's first paint use a CONSTANT anchor (`serverNow`
8
+ * itself), so both produce identical markup and hydration matches;
9
+ * - after the provider mounts, `nowMs()` advances with real time on a fixed
10
+ * server↔device offset, so a countdown mounted later (a routed view shown
11
+ * minutes after hydration) reads the current corrected time rather than the
12
+ * frozen render timestamp.
13
+ */
14
+ export interface FanfareClock {
15
+ nowMs(): number;
16
+ }
17
+ /** Constant-anchor clock for server render + first paint (deterministic). Null for an absent/invalid anchor. */
18
+ export declare function makeAnchorClock(serverNow: string | undefined): FanfareClock | null;
19
+ /** Live offset clock captured at provider mount: advances with real time, corrected for device skew. */
20
+ export declare function makeOffsetClock(serverNow: string, deviceNowMs: number): FanfareClock | null;
21
+ export declare const FanfareClockContext: import('react').Context<FanfareClock | null>;
22
+ /** The provided server-anchored clock, or null when no anchor is in scope. */
23
+ export declare function useClock(): FanfareClock | null;
@@ -15,5 +15,5 @@ export { InfoPanel } from './info-panel';
15
15
  export type { InfoPanelProps } from './info-panel';
16
16
  export { AlertPanel } from './alert-panel';
17
17
  export type { AlertPanelProps } from './alert-panel';
18
- export { normalizeOutcomeReason } from './outcome-reason';
18
+ export { normalizeOutcomeReason, normalizeSequenceOutcomeReason } from './outcome-reason';
19
19
  export type { OutcomeReason } from './outcome-reason';
@@ -16,8 +16,13 @@
16
16
  * queue_denied / draw_denied / denied / lost -> not_selected
17
17
  * timed_release_denied -> sold_out
18
18
  * outbid -> outbid
19
+ * floor_unsold -> floor_unsold
19
20
  * reserve_not_met -> reserve_not_met
20
21
  * completed / already_completed -> completed (a success terminal, not a loss)
22
+ * won -> won
23
+ * cancelled -> cancelled
24
+ * no_show -> no_show
25
+ * left -> left (voluntary exit: leave/withdraw)
21
26
  * closed / unknown / other -> ended
22
27
  *
23
28
  * The terminal projection carries the outcome TYPE (completed/denied/lost);
@@ -27,5 +32,9 @@
27
32
  * Static story lanes pass UI values directly (e.g. `"outbid"`); those
28
33
  * pass through unchanged.
29
34
  */
30
- export type OutcomeReason = "expired" | "not_selected" | "sold_out" | "outbid" | "reserve_not_met" | "completed" | "ended";
35
+ export type OutcomeReason = "expired" | "not_selected" | "sold_out" | "outbid" | "floor_unsold" | "reserve_not_met" | "completed" | "won" | "cancelled" | "no_show" | "left" | "ended";
31
36
  export declare function normalizeOutcomeReason(reason: string | undefined): OutcomeReason;
37
+ export declare function normalizeSequenceOutcomeReason(outcome: {
38
+ type: string;
39
+ reason?: string;
40
+ } | undefined, fallbackReason?: string): OutcomeReason;
@@ -12,7 +12,7 @@ export interface UpcomingModuleProps {
12
12
  description?: string;
13
13
  /** When the distribution starts */
14
14
  startsAt?: Date | number;
15
- /** Called when countdown completes */
15
+ /** Called once at gate-open time after the jitter window, not at visual countdown zero. */
16
16
  onCountdownComplete?: () => void;
17
17
  /** Whether entry is available */
18
18
  canEnter?: boolean;
@@ -7,6 +7,7 @@ export interface WaitlistViewProps {
7
7
  title?: string;
8
8
  description?: string;
9
9
  startsAt?: Date | number;
10
+ /** Called once at gate-open time after the jitter window, not at visual countdown zero. */
10
11
  onCountdownComplete?: () => void;
11
12
  onLeave?: () => void;
12
13
  isLeaving?: boolean;
@@ -19,4 +19,5 @@ export declare function useFanfareAuth(): {
19
19
  isAuthenticated: boolean;
20
20
  isGuest?: boolean;
21
21
  session?: import('@fanfare-io/fanfare-sdk-core/auth').Session;
22
+ identityExpiresAt?: string;
22
23
  };
@@ -0,0 +1,21 @@
1
+ import { BoundBeaconTracker } from '@fanfare-io/fanfare-sdk-core/beacon';
2
+ /**
3
+ * Experience currently rendering around the consumer. `ExperienceWidget`
4
+ * publishes its `experienceId` here so descendants (slots, render-prop children,
5
+ * storefront components) can attribute beacon events without threading the id
6
+ * through props. `null` outside any experience.
7
+ */
8
+ export declare const ExperienceIdContext: import('react').Context<string | null>;
9
+ /**
10
+ * Returns a beacon tracker scoped to an experience.
11
+ *
12
+ * With no argument the tracker binds to the enclosing `ExperienceWidget`'s
13
+ * experience; pass an `experienceId` to bind explicitly (an override, or for use
14
+ * outside a widget). Called with neither an argument nor a surrounding
15
+ * experience, it throws rather than silently emitting unattributed events.
16
+ *
17
+ * @param experienceId - Experience to bind to; defaults to the enclosing widget's
18
+ * @returns A tracker whose `track`/`trackBatch` stamp events with the experience
19
+ * and, once routed, the sequence
20
+ */
21
+ export declare function useBeaconTracker(experienceId?: string): BoundBeaconTracker;
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ export declare const GateOpenAttemptContext: React.Context<Map<number, number> | null>;
3
+ export declare function useGateOpen(opensAt: Date | string | number | null | undefined, onOpen: (() => void) | undefined, random?: () => number): void;
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@
8
8
  export { FanfareProvider } from './provider';
9
9
  export type { FanfareProviderProps } from './provider';
10
10
  export { useFanfareAuth } from './hooks/use-auth';
11
+ export { useBeaconTracker } from './hooks/use-beacon-tracker';
11
12
  export { useExperienceJourney } from './hooks/use-experience-journey';
12
13
  export { useFanfare } from './hooks/use-fanfare';
13
14
  export { useJourneySnapshot } from './hooks/use-journey-snapshot';