@fanfare-io/fanfare-sdk-solid 0.10.0 → 0.12.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.
Files changed (29) hide show
  1. package/dist/components/checkout/checkout-processing-panel.d.ts +10 -0
  2. package/dist/components/checkout/create-payment-challenge.d.ts +33 -0
  3. package/dist/components/checkout/create-payment-method-selection.d.ts +9 -0
  4. package/dist/components/checkout/index.d.ts +4 -0
  5. package/dist/components/checkout/payment-collection-panel.d.ts +18 -0
  6. package/dist/components/checkout/receipt-panel.d.ts +10 -0
  7. package/dist/components/checkout/reservation-checkout-panel.d.ts +18 -0
  8. package/dist/components/checkout/stripe-card-field.d.ts +20 -0
  9. package/dist/components/checkout/stripe-client.d.ts +71 -0
  10. package/dist/components/module/index.d.ts +1 -1
  11. package/dist/components/module/outcome-reason.d.ts +10 -1
  12. package/dist/components/widgets/experience-widget.d.ts +77 -1
  13. package/dist/components/widgets/index.d.ts +1 -1
  14. package/dist/hooks/index.d.ts +2 -0
  15. package/dist/hooks/use-auth.d.ts +1 -0
  16. package/dist/hooks/use-beacon-tracker.d.ts +28 -0
  17. package/dist/hooks/use-experience-journey.d.ts +2 -0
  18. package/dist/hooks/use-sdk-event.d.ts +19 -0
  19. package/dist/index.d.ts +3 -2
  20. package/dist/index.js +3790 -2393
  21. package/dist/lib/currency.d.ts +10 -0
  22. package/dist/styles/base.css +1 -1
  23. package/package.json +18 -14
  24. package/dist/components/widgets/draw/draw-actions.d.ts +0 -22
  25. package/dist/components/widgets/draw/index.d.ts +0 -6
  26. package/dist/components/widgets/queue/index.d.ts +0 -6
  27. package/dist/components/widgets/queue/queue-actions.d.ts +0 -20
  28. package/dist/components/widgets/timed-release/index.d.ts +0 -6
  29. package/dist/components/widgets/timed-release/timed-release-actions.d.ts +0 -21
@@ -0,0 +1,10 @@
1
+ import { JSX } from 'solid-js';
2
+ import { CheckoutProcessingSlotProps } from '../widgets/experience-widget';
3
+ /**
4
+ * Default processing panel shown for the gap between a submitted reservation checkout and the
5
+ * server's confirmation.
6
+ *
7
+ * The consumer must not navigate away while the payment settles, so the wait is announced rather
8
+ * than shown only as motion.
9
+ */
10
+ export declare function CheckoutProcessingPanel(_props: CheckoutProcessingSlotProps): JSX.Element;
@@ -0,0 +1,33 @@
1
+ import { Accessor } from 'solid-js';
2
+ import { StripeClientConfig } from './stripe-client';
3
+ /** `idle` covers both "no challenge yet" and "this attempt has settled". */
4
+ export type PaymentChallengePhase = "idle" | "challenging" | "resuming";
5
+ /**
6
+ * How the last attempt ended, when it ended badly — the fact a panel needs to offer the right way
7
+ * out, which the error copy alone cannot carry.
8
+ *
9
+ * - `cancelled` — the prompt ended without the card being refused: the consumer dismissed it, or the
10
+ * authentication behind it failed. Reopening that same prompt is the recovery.
11
+ * - `declined` — the card was refused, or the prompt could not be opened at all. That secret is
12
+ * spent; only a fresh submission can produce another.
13
+ * - `resume_failed` — the prompt succeeded and the operation behind it did not. The challenge is
14
+ * answered, so the recovery is to run that operation again, never to reopen the prompt.
15
+ */
16
+ export type PaymentChallengeRecovery = "cancelled" | "declined" | "resume_failed";
17
+ export interface PaymentChallenge {
18
+ phase: Accessor<PaymentChallengePhase>;
19
+ /** Localized copy for the attempt that produced it; terminal until another attempt starts. */
20
+ error: Accessor<string | null>;
21
+ /** Set together with `error`, and cleared when the next attempt starts. */
22
+ recovery: Accessor<PaymentChallengeRecovery | null>;
23
+ /**
24
+ * Open the bank prompt for `clientSecret`. Once per secret per instance: a repeat call carrying a
25
+ * secret this instance already launched is a no-op, and a genuinely new secret launches again.
26
+ */
27
+ launch: (clientSecret: string, resume: () => Promise<void>) => void;
28
+ /** Reopen the same prompt on the consumer's own instruction, then run the same resume. */
29
+ retry: (clientSecret: string, resume: () => Promise<void>) => void;
30
+ }
31
+ /** Test-only seam. Never exported from the adapter's public entry. */
32
+ export declare function resetPaymentChallengeState(): void;
33
+ export declare function createPaymentChallenge(config: Accessor<StripeClientConfig | null>): PaymentChallenge;
@@ -0,0 +1,9 @@
1
+ import { PaymentMethodSummary } from '@fanfare-io/fanfare-sdk-core/experiences';
2
+ import { Accessor, Setter } from 'solid-js';
3
+ /**
4
+ * Tracks the selected saved payment method for a checkout panel. The list can still be loading on
5
+ * mount (nothing selected yet) or a previously selected card can be removed out from under the
6
+ * panel — falls back to the default method, else the first, else `undefined`, both on initial
7
+ * mount and whenever the list changes, so submit never carries a stale/deleted `paymentMethodId`.
8
+ */
9
+ export declare function createPaymentMethodSelection(savedPaymentMethods: Accessor<PaymentMethodSummary[]>): [Accessor<string | undefined>, Setter<string | undefined>];
@@ -0,0 +1,4 @@
1
+ export { CheckoutProcessingPanel } from './checkout-processing-panel';
2
+ export { PaymentCollectionPanel } from './payment-collection-panel';
3
+ export { ReceiptPanel } from './receipt-panel';
4
+ export { ReservationCheckoutPanel } from './reservation-checkout-panel';
@@ -0,0 +1,18 @@
1
+ import { JSX } from 'solid-js';
2
+ import { PaymentCollectionSlotProps } from '../widgets/experience-widget';
3
+ /**
4
+ * Default payment-collection panel for pre-auth distributions, rendered both when the consumer is
5
+ * about to enter and when a failed authorization leaves a retry open.
6
+ *
7
+ * The hold amount is rendered from the view's own figure — the client never derives one.
8
+ *
9
+ * The configuration block reaches this panel on the entry mount only. A retry is offered from an
10
+ * ended view, which carries none, so that mount renders payment as unavailable and a consumer with
11
+ * a saved method submits without needing Stripe.js at all.
12
+ *
13
+ * Entry has no server-side resume: a paused authorization is carried forward by submitting the
14
+ * identical payment input again, held here from the first submit, so exactly one payment method is
15
+ * minted across the whole flow. An ended view carries no pending action, so the retry mount reaches
16
+ * none of this.
17
+ */
18
+ export declare function PaymentCollectionPanel(props: PaymentCollectionSlotProps): JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { JSX } from 'solid-js';
2
+ import { ReceiptSlotProps } from '../widgets/experience-widget';
3
+ /**
4
+ * Default panel for a completed Fanfare-managed payment.
5
+ *
6
+ * The order reference is the outcome. An admission credential appears only on the arm that carries
7
+ * one, and stays subordinate to the purchase: payment is terminal, so a receipt must never read as
8
+ * the thing that admits its holder.
9
+ */
10
+ export declare function ReceiptPanel(props: ReceiptSlotProps): JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { JSX } from 'solid-js';
2
+ import { ReservationCheckoutSlotProps } from '../widgets/experience-widget';
3
+ /**
4
+ * Default reservation-checkout panel for post-win checkout flows.
5
+ *
6
+ * `Countdown`'s `onComplete` is a no-op: the journey machine owns the reservation's expiry (it
7
+ * arms its own timer and transitions the sequence to `ended` when the deadline passes), so the
8
+ * panel never disables itself locally — it simply stops being rendered once the phase changes.
9
+ *
10
+ * Elements renders only on the internal-processor arm. The discriminator is `processor`; an absent
11
+ * configuration block on that arm means the configuration read failed, which is a retryable outage
12
+ * inside a ticking window — never a signal that another processor is in play.
13
+ *
14
+ * A pending action adds visible substates over the same screen rather than replacing it: the card
15
+ * field stays mounted through the whole challenge, because a consumer whose bank prompt failed may
16
+ * need to submit again with the card they already typed.
17
+ */
18
+ export declare function ReservationCheckoutPanel(props: ReservationCheckoutSlotProps): JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { JSX } from 'solid-js';
2
+ import { StripeClientConfig } from './stripe-client';
3
+ export interface StripeCardController {
4
+ /** Resolves the `pm_…` id, or rejects with an `Error` carrying already-localized copy. */
5
+ createPaymentMethod: () => Promise<string>;
6
+ }
7
+ export interface StripeCardFieldProps {
8
+ config: StripeClientConfig;
9
+ onController: (controller: StripeCardController | null) => void;
10
+ onChange?: (state: {
11
+ complete: boolean;
12
+ errorMessage: string | null;
13
+ }) => void;
14
+ /**
15
+ * The owning panel's account of everything it renders above this field. Its value carries no
16
+ * meaning; a change to it means the anchor may have moved and the portal frame needs re-measuring.
17
+ */
18
+ reflowKey?: string;
19
+ }
20
+ export declare function StripeCardField(props: StripeCardFieldProps): JSX.Element;
@@ -0,0 +1,71 @@
1
+ import { ReservationPaymentAffordance } from '@fanfare-io/fanfare-sdk-core/experiences';
2
+ import { Stripe, StripeConstructor, StripeElementStyle } from '@stripe/stripe-js';
3
+ /**
4
+ * The wire block a checkout-capable view carries, reached through the adapter's declared
5
+ * dependency on `fanfare-sdk-core` rather than the contracts package: core re-exports the contract
6
+ * types so adapter modules never resolve `@fanfare-io/fanfare-sdk-contracts` directly.
7
+ */
8
+ type PaymentProviderConfig = NonNullable<ReservationPaymentAffordance["paymentProvider"]>;
9
+ declare global {
10
+ interface Window {
11
+ Stripe?: StripeConstructor;
12
+ }
13
+ }
14
+ export interface StripeClientConfig {
15
+ publishableKey: string;
16
+ stripeAccount?: string;
17
+ }
18
+ /**
19
+ * Loads Stripe.js once per page. A failure is never retained: a memoized rejection would strand
20
+ * every subsequent payer on the page, not just the one whose load failed. Retry is the caller's
21
+ * decision — this module never schedules one.
22
+ */
23
+ export declare function loadStripeJs(): Promise<StripeConstructor>;
24
+ /**
25
+ * One Stripe client per (publishable key, connected account). A construction that rejects drops
26
+ * its cache entry for the same reason the loader does.
27
+ */
28
+ export declare function getStripe(config: StripeClientConfig): Promise<Stripe>;
29
+ /**
30
+ * Re-serializes a theme color into the spelling a CSS color parser produces.
31
+ *
32
+ * Custom properties are untyped, so a theme color arrives from `getComputedStyle` as whatever token
33
+ * stream the stylesheet declared — and a minifier is free to rewrite `oklch(0.63 0.24 25)` as
34
+ * `oklch(63% .24 25)`. Stripe's element options go through a stricter parser than CSS's: a spelling
35
+ * every browser accepts can still be rejected there, and the rejection is silent — the element
36
+ * mounts a frame that never renders its input. The invariant this restores is that colors reach
37
+ * Stripe in the serialization its parser accepts.
38
+ *
39
+ * `null` means the value is not a color the parser recognizes, and the caller must omit the key
40
+ * rather than guess: assigning an unparsable value leaves `fillStyle` on its previous one, so
41
+ * emitting the read-back would emit some other color entirely. Where no parser exists — server
42
+ * rendering, or a DOM without canvas — the value passes through: the mismatch only arises where a
43
+ * real browser serializes computed styles.
44
+ */
45
+ export declare function normalizeCssColor(value: string): string | null;
46
+ /**
47
+ * Maps the SDK theme's resolved custom properties onto the Card Element's `style` option. Stripe's
48
+ * `Appearance` API governs the Elements group Payment Element consumes and does not reach the
49
+ * legacy Card Element, so `style` is the only theming path — there is deliberately no second one.
50
+ *
51
+ * Property names are the values of `THEME_CSS_VARS` (the adapter's `theme/theme.types.ts`), spelled
52
+ * literally here because this file must stay identical across adapters. `--ff-color-primary` and
53
+ * `--ff-color-background` have no Card Element equivalent: the element's background is the host
54
+ * page's, supplied by the panel around the iframe.
55
+ *
56
+ * Every color is re-serialized on the way out; a color the parser rejects is omitted, which leaves
57
+ * Stripe on its own default for that slot. The font stack is not a color and is forwarded as read.
58
+ */
59
+ export declare function deriveStripeCardStyle(root: HTMLElement): StripeElementStyle;
60
+ /**
61
+ * The one binding between a view's wire configuration and a Stripe client.
62
+ *
63
+ * `null` means no usable Stripe client configuration reached this view. On a checkout-capable arm
64
+ * that has exactly one cause — the configuration read failed — because the processor discriminator
65
+ * is the `processor` field (reserved) or `checkoutMode` (enterable), never the presence of this
66
+ * block. The condition is transient and retryable.
67
+ */
68
+ export declare function resolveStripeClientConfig(source: PaymentProviderConfig | undefined): StripeClientConfig | null;
69
+ /** Test-only seam over every memo this module holds. Never exported from an adapter's public entry. */
70
+ export declare function resetStripeClientCache(): void;
71
+ export {};
@@ -1,5 +1,5 @@
1
1
  export { AlertPanel, type AlertPanelProps } from './alert-panel';
2
2
  export { InfoPanel, type InfoPanelProps } from './info-panel';
3
- export { normalizeOutcomeReason, type OutcomeReason } from './outcome-reason';
3
+ export { normalizeOutcomeReason, normalizeSequenceOutcomeReason, type OutcomeReason } from './outcome-reason';
4
4
  export { PanelHeading, type PanelHeadingProps, type PanelHeadingVariant } from './panel-heading';
5
5
  export { PanelBody, PanelFooter, PanelLayout, type PanelBodyProps, type PanelFooterProps, type PanelLayoutProps, } from './panel-layout';
@@ -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;
@@ -1,5 +1,5 @@
1
1
  import { BotMitigationState, RoutingChallenge } from '@fanfare-io/fanfare-sdk-core/challenges';
2
- import { JourneyHandle, JourneySnapshot, JourneyView, SequenceView } from '@fanfare-io/fanfare-sdk-core/experiences';
2
+ import { CheckoutNextAction, CheckoutProcessor, FanfareCheckoutResult, JourneyHandle, JourneySnapshot, JourneyView, PaymentInput, PaymentMethodSummary, ReservationPaymentAffordance, SequenceView } from '@fanfare-io/fanfare-sdk-core/experiences';
3
3
  import { BrandTheme } from '@fanfare-io/fanfare-sdk-core/theme';
4
4
  import { JSX } from 'solid-js';
5
5
  import { WidgetVariant } from '../../theme';
@@ -59,6 +59,74 @@ export interface GrantedSlotProps extends SlotProps {
59
59
  grant?: string;
60
60
  expiresAt?: number;
61
61
  }
62
+ export interface PaymentCollectionSlotProps extends SlotProps {
63
+ preAuthAmount: string;
64
+ preAuthCurrencyCode: string;
65
+ savedPaymentMethods: PaymentMethodSummary[];
66
+ /** Rejects on a recoverable payment failure (e.g. a declined card) — the panel owns recovery UI for its own submit. */
67
+ onEnter: (paymentInput: PaymentInput) => Promise<void>;
68
+ isEntering: boolean;
69
+ /** "enter" collects payment before first entry; "reenter" collects payment to retry after a failed or expired authorization hold. */
70
+ intent: "enter" | "reenter";
71
+ /**
72
+ * Client configuration for the processor authorizing this entry, as the server supplied it.
73
+ * Carried by the enterable arm only — a retry is offered from an ended view, which holds no
74
+ * configuration.
75
+ */
76
+ paymentProvider?: PaymentProviderConfig;
77
+ /** Present while the processor is waiting on an out-of-band action; re-submitting entry resolves it. */
78
+ pendingAction?: CheckoutNextAction;
79
+ /**
80
+ * Re-reads the consumer's journeys from the server so a provider configuration that was missing
81
+ * or unreadable at render can arrive. This is the panel's only recovery when `paymentProvider` is
82
+ * absent — the value is a prop, so nothing the panel does to its own state can produce it.
83
+ */
84
+ onRetryPaymentConfig?: () => Promise<void>;
85
+ }
86
+ /**
87
+ * The processor's client configuration block, named through the affordance that carries it: core
88
+ * re-exports the affordance but not the contract's own name for this shape.
89
+ */
90
+ type PaymentProviderConfig = NonNullable<ReservationPaymentAffordance["paymentProvider"]>;
91
+ export interface ReservationCheckoutSlotProps extends SlotProps {
92
+ reservation: {
93
+ token: string;
94
+ expiresAt: number;
95
+ };
96
+ savedPaymentMethods: PaymentMethodSummary[];
97
+ /** Which processor executes this reservation's payment leg; narrow before rendering processor-specific UI. */
98
+ processor: CheckoutProcessor;
99
+ /** Client configuration for the processor settling this reservation, as the server supplied it. */
100
+ paymentProvider?: PaymentProviderConfig;
101
+ /** Present while the processor is waiting on an out-of-band action; complete it, then call `onResume`. */
102
+ pendingAction?: CheckoutNextAction;
103
+ /** Rejects on a recoverable payment failure (e.g. a declined card) — the panel owns recovery UI for its own submit. */
104
+ onConfirm: (paymentInput: PaymentInput) => Promise<void>;
105
+ /** Re-submits the paused checkout after `pendingAction` has been completed. Idempotent server-side. */
106
+ onResume: () => Promise<void>;
107
+ isConfirming: boolean;
108
+ /**
109
+ * Re-reads the consumer's journeys from the server so a provider configuration that was missing
110
+ * or unreadable at render can arrive. This is the panel's only recovery when `paymentProvider` is
111
+ * absent — the value is a prop, so nothing the panel does to its own state can produce it.
112
+ */
113
+ onRetryPaymentConfig?: () => Promise<void>;
114
+ }
115
+ export type CheckoutProcessingSlotProps = SlotProps;
116
+ /**
117
+ * A Fanfare-managed payment is terminal: it produces a receipt, never an admission credential. The
118
+ * `grant` arm carries the credential the mechanism itself issued alongside the payment; a purchase
119
+ * that ends the journey has no credential to carry, so the arms are discriminated rather than
120
+ * making the grant optional — a slot implementation can never read one that does not exist.
121
+ */
122
+ export type ReceiptSlotProps = SlotProps & ({
123
+ kind: "grant";
124
+ admissionGrant: string;
125
+ checkout: FanfareCheckoutResult;
126
+ } | {
127
+ kind: "purchase";
128
+ checkout: FanfareCheckoutResult;
129
+ });
62
130
  export interface ExpiredSlotProps extends SlotProps {
63
131
  reason: string;
64
132
  endedAt?: Date;
@@ -92,6 +160,10 @@ export interface ExperienceWidgetSlots {
92
160
  enterable?: (props: EnterableSlotProps) => JSX.Element;
93
161
  participating?: (props: ParticipatingSlotProps) => JSX.Element;
94
162
  granted?: (props: GrantedSlotProps) => JSX.Element;
163
+ paymentCollection?: (props: PaymentCollectionSlotProps) => JSX.Element;
164
+ reservationCheckout?: (props: ReservationCheckoutSlotProps) => JSX.Element;
165
+ checkoutProcessing?: (props: CheckoutProcessingSlotProps) => JSX.Element;
166
+ receipt?: (props: ReceiptSlotProps) => JSX.Element;
95
167
  expired?: (props: ExpiredSlotProps) => JSX.Element;
96
168
  ended?: (props: EndedSlotProps) => JSX.Element;
97
169
  error?: (props: ErrorSlotProps) => JSX.Element;
@@ -116,6 +188,10 @@ export interface ExperienceWidgetProps {
116
188
  checkoutUrl?: string;
117
189
  onJourneyChange?: (snapshot: JourneySnapshot) => void;
118
190
  onGranted?: (grant: string) => void;
191
+ /** Called when a Fanfare-managed checkout completes (pre-auth capture or post-win reservation checkout) */
192
+ onFanfareCheckout?: (result: FanfareCheckoutResult) => void;
193
+ /** Called when the consumer wins a `post_win` distribution and must complete checkout before `expiresAt` */
194
+ onReserved?: (expiresAt: number) => void;
119
195
  onError?: (error: Error) => void;
120
196
  class?: string;
121
197
  className?: string;
@@ -6,6 +6,6 @@
6
6
  *
7
7
  * @packageDocumentation
8
8
  */
9
- export { ExperienceWidget, type AccessCodeSlotProps, type AuthSlotProps, type ChallengeSlotProps, type EndedSlotProps, type EnterableSlotProps, type ErrorSlotProps, type ExperienceRenderProps, type ExperienceWidgetProps, type ExperienceWidgetSlots, type ExpiredSlotProps, type GrantedSlotProps, type LoadingSlotProps, type ParticipatingSlotProps, type SlotProps, type StartSlotProps, type UpcomingSlotProps, type WaitlistSlotProps, } from './experience-widget';
9
+ export { ExperienceWidget, type AccessCodeSlotProps, type AuthSlotProps, type ChallengeSlotProps, type CheckoutProcessingSlotProps, type EndedSlotProps, type EnterableSlotProps, type ErrorSlotProps, type ExperienceRenderProps, type ExperienceWidgetProps, type ExperienceWidgetSlots, type ExpiredSlotProps, type GrantedSlotProps, type LoadingSlotProps, type ParticipatingSlotProps, type PaymentCollectionSlotProps, type ReceiptSlotProps, type ReservationCheckoutSlotProps, type SlotProps, type StartSlotProps, type UpcomingSlotProps, type WaitlistSlotProps, } from './experience-widget';
10
10
  export { LoadingView, StartView, UpcomingModule, WaitlistView, type LoadingViewProps, type StartViewProps, type UpcomingModuleProps, type WaitlistViewProps, } from '../internal';
11
11
  export { AppointmentModule, AuctionModule, DrawModule, QueueModule, TimedReleaseModule, type AppointmentModuleProps, type AuctionModuleProps, type DrawModuleProps, type QueueModuleProps, type TimedReleaseModuleProps, } from '../internal';
@@ -6,7 +6,9 @@
6
6
  * @packageDocumentation
7
7
  */
8
8
  export { useFanfareAuth } from './use-auth';
9
+ export { createBeaconTracker } from './use-beacon-tracker';
9
10
  export { useExperienceJourney } from './use-experience-journey';
10
11
  export type { ExperienceJourneyOptions, UseExperienceJourneyOptions, UseExperienceJourneyResult, } from './use-experience-journey';
11
12
  export { useJourneySnapshot } from './use-journey-snapshot';
12
13
  export { useNanostore } from './use-nanostore';
14
+ export { useSdkEvent } from './use-sdk-event';
@@ -4,6 +4,7 @@ export declare function useFanfareAuth(): {
4
4
  isAuthenticated: import('solid-js').Accessor<boolean>;
5
5
  isGuest: import('solid-js').Accessor<boolean | undefined>;
6
6
  session: import('solid-js').Accessor<import('@fanfare-io/fanfare-sdk-core/auth').Session | undefined>;
7
+ identityExpiresAt: import('solid-js').Accessor<string | undefined>;
7
8
  guest: () => Promise<import('@fanfare-io/fanfare-sdk-core/auth').GuestSession>;
8
9
  requestOtp: (options: OtpRequest) => Promise<void>;
9
10
  verifyOtp: (options: OtpVerify) => Promise<import('@fanfare-io/fanfare-sdk-core/auth').AuthenticatedSession>;
@@ -0,0 +1,28 @@
1
+ import { BoundBeaconTracker } from '@fanfare-io/fanfare-sdk-core/beacon';
2
+ import { Accessor } from 'solid-js';
3
+ /**
4
+ * Experience currently rendering around the consumer, as an accessor.
5
+ * `ExperienceWidget` publishes its `experienceId` here so descendants (slots,
6
+ * render-prop children, storefront components) can attribute beacon events
7
+ * without threading the id through props. It is an accessor, not a bare string,
8
+ * because Solid runs component setup once: a tracker must read the value at
9
+ * track time so a later change to the widget's `experienceId` prop is honored.
10
+ * Returns `null` outside any experience.
11
+ */
12
+ export declare const ExperienceIdContext: import('solid-js').Context<Accessor<string | null>>;
13
+ /**
14
+ * Creates a beacon tracker scoped to an experience.
15
+ *
16
+ * With no argument the tracker binds to the enclosing `ExperienceWidget`'s
17
+ * experience; pass an `experienceId` to bind explicitly (an override, or for use
18
+ * outside a widget). Called with neither an argument nor a surrounding
19
+ * experience, it throws rather than silently emitting unattributed events.
20
+ *
21
+ * The bound experience is resolved at each `track`/`trackBatch` call, so if the
22
+ * enclosing widget's `experienceId` changes, subsequent events follow it.
23
+ *
24
+ * @param experienceId - Experience to bind to; defaults to the enclosing widget's
25
+ * @returns A tracker whose `track`/`trackBatch` stamp events with the experience
26
+ * and, once routed, the sequence
27
+ */
28
+ export declare function createBeaconTracker(experienceId?: string): BoundBeaconTracker;
@@ -1,3 +1,4 @@
1
+ import { FanfareError } from '@fanfare-io/fanfare-sdk-core/errors';
1
2
  import { JourneyHandle, JourneySnapshot, JourneyView } from '@fanfare-io/fanfare-sdk-core/experiences';
2
3
  import { MaybeAccessor } from '../utils/to-accessor';
3
4
  export interface ExperienceJourneyOptions {
@@ -12,6 +13,7 @@ export interface UseExperienceJourneyResult {
12
13
  view: () => JourneyView | null;
13
14
  snapshot: () => JourneySnapshot | null;
14
15
  error: () => string | null;
16
+ fanfareError: () => FanfareError | null;
15
17
  start: (options?: ExperienceJourneyOptions) => Promise<JourneyView>;
16
18
  }
17
19
  export declare function useExperienceJourney(experienceId: MaybeAccessor<string | undefined>, options?: UseExperienceJourneyOptions): UseExperienceJourneyResult;
@@ -0,0 +1,19 @@
1
+ import { SDKEvents } from '@fanfare-io/fanfare-sdk-core/events';
2
+ type SDKEventKey = keyof SDKEvents;
3
+ /**
4
+ * Subscribe to a typed Fanfare SDK event for the lifetime of the owning scope.
5
+ *
6
+ * The SDK instance, the event name and the handler are all captured once at
7
+ * setup: the subscription is not re-established if the provider later swaps the
8
+ * SDK instance, `event` is read as a plain value rather than an accessor, and
9
+ * the handler passed on the first call is the one invoked for every delivery —
10
+ * unlike the React adapter, which reads its handler from a ref refreshed each
11
+ * render. Read reactive values inside the handler body, and call the hook again
12
+ * from a fresh scope to listen for a different event.
13
+ *
14
+ * The subscription attaches inside a `createEffect`, so events emitted between
15
+ * the hook call and the effect flush are not delivered, and under the server
16
+ * build — where effects never run — the hook is a no-op.
17
+ */
18
+ export declare function useSdkEvent<K extends SDKEventKey>(event: K, handler: (data: SDKEvents[K]) => void): void;
19
+ export {};
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  */
8
8
  export { FanfareProvider, useFanfare } from './components/provider';
9
9
  export type { FanfareProviderProps } from './components/provider';
10
- export { useExperienceJourney, useFanfareAuth, useJourneySnapshot, useNanostore } from './hooks';
10
+ export { createBeaconTracker, useExperienceJourney, useFanfareAuth, useJourneySnapshot, useNanostore, useSdkEvent, } from './hooks';
11
11
  export { I18nProvider, RTL_LOCALES, isRTLLocale, useTranslations } from './i18n';
12
12
  export type { I18nConfig, I18nProviderProps, Locale, PartialTranslationMessages, RTLLocale, TextDirection, TranslateFunction, TranslateOptions, TranslationKey, TranslationMessageKey, TranslationMessages, } from './i18n';
13
13
  export { THEME_CSS_VARS, ThemeProvider, buildThemeCssVars } from './theme';
@@ -21,7 +21,8 @@ export type { InfoPanelProps, OutcomeReason, PanelBodyProps, PanelFooterProps, P
21
21
  export { AccessCodeForm, ChallengeGate, EndedModule, ErrorView, GrantedPanel, OutcomePanel, } from './components/compositions';
22
22
  export type { AccessCodeFormProps, ChallengeGateProps, EndedModuleProps, ErrorViewProps, GrantedPanelProps, OutcomePanelProps, } from './components/compositions';
23
23
  export { ExperienceWidget } from './components/widgets';
24
- export type { AccessCodeSlotProps, AuthSlotProps, ChallengeSlotProps, EndedSlotProps, EnterableSlotProps, ErrorSlotProps, ExperienceRenderProps, ExperienceWidgetProps, ExperienceWidgetSlots, ExpiredSlotProps, GrantedSlotProps, LoadingSlotProps, ParticipatingSlotProps, SlotProps, StartSlotProps, UpcomingSlotProps, WaitlistSlotProps, } from './components/widgets';
24
+ export type { AccessCodeSlotProps, AuthSlotProps, ChallengeSlotProps, CheckoutProcessingSlotProps, EndedSlotProps, EnterableSlotProps, ErrorSlotProps, ExperienceRenderProps, ExperienceWidgetProps, ExperienceWidgetSlots, ExpiredSlotProps, GrantedSlotProps, LoadingSlotProps, ParticipatingSlotProps, PaymentCollectionSlotProps, ReceiptSlotProps, ReservationCheckoutSlotProps, SlotProps, StartSlotProps, UpcomingSlotProps, WaitlistSlotProps, } from './components/widgets';
25
+ export { CheckoutProcessingPanel, PaymentCollectionPanel, ReceiptPanel, ReservationCheckoutPanel, } from './components/checkout';
25
26
  export { LoadingView, StartView, UpcomingModule, WaitlistView } from './components/widgets';
26
27
  export type { LoadingViewProps, StartViewProps, UpcomingModuleProps, WaitlistViewProps } from './components/widgets';
27
28
  export { AuctionModule, DrawModule, QueueModule, TimedReleaseModule } from './components/widgets';