@simple-parlay/components 2.1.0 → 2.2.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 (33) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.mjs +687 -658
  4. package/dist/react/components/EntryRulePicks.d.ts +62 -0
  5. package/dist/react/components/GameEntries.d.ts +1 -1
  6. package/dist/react/components/GameShowcaseCatalogue.d.ts +2 -1
  7. package/dist/react/components/PlaceEntryProvider.d.ts +11 -2
  8. package/dist/react/components/SelectionVariantList.d.ts +18 -0
  9. package/dist/react/components/ShelfKit.d.ts +1 -1
  10. package/dist/react/components/YesNoMultiLogo.d.ts +5 -2
  11. package/dist/react/components/_primitives/index.d.ts +4 -2
  12. package/dist/react/index.cjs +1 -1
  13. package/dist/react/index.d.ts +2 -0
  14. package/dist/react/index.mjs +687 -658
  15. package/dist/react/types/index.d.ts +1 -1
  16. package/dist/react-native/components/EntryRulePicks.d.ts +66 -0
  17. package/dist/react-native/components/GameEntries.d.ts +1 -1
  18. package/dist/react-native/components/HowToPlayButton.d.ts +5 -0
  19. package/dist/react-native/components/PlaceEntryProvider.d.ts +11 -2
  20. package/dist/react-native/components/SelectionVariantList.d.ts +40 -0
  21. package/dist/react-native/components/ShelfKit.d.ts +1 -1
  22. package/dist/react-native/components/_primitives/index.d.ts +3 -1
  23. package/dist/react-native/index.cjs +1 -1
  24. package/dist/react-native/index.d.ts +2 -0
  25. package/dist/react-native/index.mjs +543 -517
  26. package/dist/react-native/types/index.d.ts +1 -1
  27. package/dist/shared/api-client.d.ts +7 -1
  28. package/dist/shared/entry-features.d.ts +34 -0
  29. package/dist/shared/entry-rules.d.ts +178 -0
  30. package/dist/shared/shelf-covers.d.ts +0 -2
  31. package/dist/shared/shelf-ui.d.ts +2 -1
  32. package/dist/shared/types.d.ts +90 -0
  33. package/package.json +1 -1
@@ -1 +1 @@
1
- export type { BladeTheme, BladeThemeSet, ColorScheme, ScreenSize, RuleExpressionObject, Game, GameAllocation, SportSummary, Proposition, GameEntry, PlaceEntryFlowProps, GameSelectorProps, EntrySubmissionProps, SelectionReviewProps, GameEntriesProps, EvaluateRuleRequest, EvaluateRuleResponse, CalculatePayoutRequest, CalculatePayoutResponse, EntryPreviewRequest, EntryPreviewResponse, TopPayoutEntry, TopPayoutsResponse, ResolvedEntryData, ShareData, PendingBet, QuickPickResult, } from '../../shared/types';
1
+ export type { GameFeatureId, EntryRuleAction, EntryFeatureClient, EntryFeatureOffer, EntryFeatureQuote, EntryFeatureQuoteInput, BladeTheme, BladeThemeSet, ColorScheme, ScreenSize, RuleExpressionObject, Game, GameAllocation, SportSummary, Proposition, GameEntry, PlaceEntryFlowProps, GameSelectorProps, EntrySubmissionProps, SelectionReviewProps, GameEntriesProps, EvaluateRuleRequest, EvaluateRuleResponse, CalculatePayoutRequest, CalculatePayoutResponse, EntryPreviewRequest, EntryPreviewResponse, TopPayoutEntry, TopPayoutsResponse, ResolvedEntryData, ShareData, PendingBet, QuickPickResult, } from '../../shared/types';
@@ -1,4 +1,4 @@
1
- import { Game, Proposition, SportSummary, GameEntry, TopPayoutsResponse, EvaluateRuleRequest, EvaluateRuleResponse, CalculatePayoutRequest, CalculatePayoutResponse, EntryPreviewRequest, EntryPreviewResponse, GameCategory } from './types';
1
+ import { Game, Proposition, SportSummary, GameEntry, EntryFeatureOffer, EntryFeatureQuote, EntryFeatureQuoteInput, TopPayoutsResponse, EvaluateRuleRequest, EvaluateRuleResponse, CalculatePayoutRequest, CalculatePayoutResponse, EntryPreviewRequest, EntryPreviewResponse, GameCategory } from './types';
2
2
  export interface GamesListResponse {
3
3
  payload: Game[];
4
4
  how_to_play_markdown?: string | null;
@@ -69,6 +69,12 @@ export declare class BladeApiClient {
69
69
  getGameMaxPayout(gameId: number, betAmount?: number): Promise<TopPayoutsResponse>;
70
70
  getGamesMaxPayouts(ids: number[], betAmount?: number): Promise<Record<number, TopPayoutsResponse>>;
71
71
  getCorrelationSuggestions(gameId: number, data: import('./correlation-steering').CorrelationRequest, signal?: AbortSignal): Promise<import('./correlation-steering').CorrelationSuggestions>;
72
+ /** Game features this entry can use now, with BLADE's reason when one can't. */
73
+ getEntryFeatures(entryId: number): Promise<EntryFeatureOffer[]>;
74
+ /** Price a feature for this entry. BLADE holds the quote for a few seconds; accept it to commit. */
75
+ quoteEntryFeature(entryId: number, input: EntryFeatureQuoteInput): Promise<EntryFeatureQuote>;
76
+ /** Commit a quote. The same idempotency key always returns the same action. */
77
+ acceptEntryFeature(entryId: number, actionId: string, idempotencyKey: string): Promise<EntryFeatureQuote>;
72
78
  getEntryPreview(gameId: number, data: EntryPreviewRequest): Promise<EntryPreviewResponse>;
73
79
  evaluateRule(gameId: number, data: EvaluateRuleRequest): Promise<EvaluateRuleResponse>;
74
80
  calculatePayout(gameId: number, data: CalculatePayoutRequest): Promise<CalculatePayoutResponse>;
@@ -0,0 +1,34 @@
1
+ import { EntryFeatureClient, EntryFeatureOffer, EntryFeatureQuote, EntryFeatureQuoteInput, GameFeatureId } from './types';
2
+ /**
3
+ * Game features are priced and committed by BLADE (`/game-entries/{id}/features`,
4
+ * `/feature-quotes`, `/feature-actions/{id}/accept`); nothing here prices anything.
5
+ * Each feature maps to the BLADE effect it runs on. Press is BLADE's `risk_winnings`;
6
+ * the others are effects BLADE has yet to add, so until it does they come back unavailable.
7
+ */
8
+ export declare const BLADE_EFFECT: Record<GameFeatureId, string>;
9
+ export type FeaturePicks = {
10
+ propositionId: number;
11
+ answer: 'yes' | 'no';
12
+ }[];
13
+ /** The quote body for a feature: which pick it changes, and the picks it lands on. */
14
+ export declare function featureQuoteInput(rule: GameFeatureId, offer: EntryFeatureOffer, { dropId, picks, winnings }: {
15
+ dropId?: number;
16
+ picks: FeaturePicks;
17
+ winnings?: number;
18
+ }): EntryFeatureQuoteInput;
19
+ export interface FeatureQuoteState {
20
+ /** BLADE's quote for the picks as they stand; null while it's being fetched or can't be priced. */
21
+ quote: EntryFeatureQuote | null;
22
+ pending: boolean;
23
+ /** Why BLADE can't price or commit this right now, in its words. */
24
+ error: string | null;
25
+ cost: number;
26
+ maximumReturn: number;
27
+ /** Commit the current quote; re-quotes first when it has expired. Resolves with the accepted action. */
28
+ accept: () => Promise<EntryFeatureQuote | null>;
29
+ }
30
+ /**
31
+ * Keep a live BLADE quote for one feature on one entry. `input` is null until the picks are complete;
32
+ * every change re-quotes (debounced), and the quote refreshes itself just before BLADE expires it.
33
+ */
34
+ export declare function useEntryFeatureQuote(client: EntryFeatureClient | null, entryId: number, rule: GameFeatureId, buildInput: (offer: EntryFeatureOffer) => EntryFeatureQuoteInput | null, inputKey: string): FeatureQuoteState;
@@ -0,0 +1,178 @@
1
+ import { GameEntry, GameFeatureId, Proposition } from './types';
2
+ /**
3
+ * After-placement game features, read off a settled or live entry:
4
+ * - Double Down: lost by exactly one call → buy a reroll of that call, for the card's full prize.
5
+ * - Press: won → roll the winnings onto a fresh 3-call card.
6
+ * - Late Swap / Second Thoughts: change a pick until shortly before its match.
7
+ * - Hot Hand: a three-in-a-row side bet, added before the first match.
8
+ * BLADE prices and commits every one of them (see `entry-features.ts`); these helpers
9
+ * only decide what to offer. Nothing here computes a payout.
10
+ */
11
+ /** Legs on the card a Press rolls onto. */
12
+ export declare const PRESS_LEGS = 3;
13
+ /** Calls in a row Hot Hand needs. */
14
+ export declare const HOT_HAND_RUN = 3;
15
+ /** Late Swap and Second Thoughts close this long before a pick's match, so late team news can't be traded on. */
16
+ export declare const CHANGE_CUTOFF_MINUTES = 30;
17
+ export interface EntryLeg {
18
+ prop: Proposition;
19
+ answer?: 'yes' | 'no';
20
+ }
21
+ export declare const hasFeature: (game: {
22
+ features?: GameFeatureId[];
23
+ } | undefined, id: GameFeatureId) => boolean;
24
+ /** The one call that sank a settled entry, or null when it lost by more (or wasn't lost). */
25
+ export declare function doubleDownMiss(entry: GameEntry, legs: EntryLeg[]): EntryLeg | null;
26
+ /** Winnings a Press can roll, or 0. */
27
+ export declare function pressStake(entry: GameEntry): number;
28
+ /** Legs that can still be changed: the entry is before play, and the leg's match is more than the cutoff away. */
29
+ export declare function swappableLegs(entry: GameEntry, legs: EntryLeg[], now?: number): EntryLeg[];
30
+ /** Hot Hand is added before play: a live entry none of whose matches has started. */
31
+ export declare function hotHandOpen(entry: GameEntry, legs: EntryLeg[], now?: number): boolean;
32
+ /**
33
+ * Open calls a swap, reroll or press can land on: not already on the entry, nothing settled, past the cutoff,
34
+ * and not from a match already on the entry (BLADE refuses correlated replacements).
35
+ */
36
+ export declare function replacementOptions(pool: Proposition[], entry: GameEntry, now?: number, limit?: number): Proposition[];
37
+ /** Longest run of right calls so far, in pick order. */
38
+ export declare function longestRun(legs: EntryLeg[]): number;
39
+ /** Second Thoughts: picks on a live entry that can still be flipped (same cutoff as Late Swap). */
40
+ export declare const flippableLegs: typeof swappableLegs;
41
+ /**
42
+ * Words, glyph and explainer for each feature, shared by web and native.
43
+ * Icons are 24-box stroke paths. `cost` says what the player gives up; BLADE's quote has the amounts.
44
+ */
45
+ export declare const ENTRY_RULE_COPY: {
46
+ readonly double_down: {
47
+ readonly name: "Double Down";
48
+ readonly title: "Reroll your miss";
49
+ readonly cta: "Reroll pick";
50
+ readonly confirm: "Confirm reroll";
51
+ readonly done: "Rerolled";
52
+ readonly icon: readonly ["M20 11a8 8 0 1 0-2.34 5.66", "M20 4v7h-7"];
53
+ readonly summary: "Missed by one? Buy a second shot at that pick, for the full prize.";
54
+ readonly steps: readonly [{
55
+ readonly title: "Play your card";
56
+ readonly detail: "Every pick but one lands.";
57
+ }, {
58
+ readonly title: "Buy a reroll";
59
+ readonly detail: "Pick a fresh YES or NO call from another match.";
60
+ }, {
61
+ readonly title: "Land it and win";
62
+ readonly detail: "If it's right, your card pays its full prize.";
63
+ }];
64
+ readonly cost: {
65
+ readonly label: "Quoted for your call";
66
+ readonly detail: "A likelier call costs more. You see the exact price before you confirm.";
67
+ };
68
+ };
69
+ readonly press: {
70
+ readonly name: "Press";
71
+ readonly title: "Let it ride";
72
+ readonly cta: "Let it ride";
73
+ readonly confirm: "Confirm press";
74
+ readonly done: "Riding";
75
+ readonly icon: readonly ["M7 17 17 7", "M8 7h9v9"];
76
+ readonly summary: "Won? Roll your winnings onto three more picks.";
77
+ readonly steps: readonly [{
78
+ readonly title: "Win your entry";
79
+ readonly detail: "Your winnings are ready to collect.";
80
+ }, {
81
+ readonly title: "Pick three more";
82
+ readonly detail: "YES or NO on three fresh calls.";
83
+ }, {
84
+ readonly title: "All three land";
85
+ readonly detail: "The payout depends on the three picks you choose.";
86
+ }];
87
+ readonly cost: {
88
+ readonly label: "Your winnings";
89
+ readonly detail: "Miss one and the winnings you pressed are gone.";
90
+ };
91
+ };
92
+ readonly late_swap: {
93
+ readonly name: "Late Swap";
94
+ readonly title: "Swap a pick";
95
+ readonly cta: "Swap pick";
96
+ readonly confirm: "Confirm swap";
97
+ readonly done: "Swapped";
98
+ readonly icon: readonly ["M7 4 3 8l4 4", "M3 8h13", "M17 20l4-4-4-4", "M21 16H8"];
99
+ readonly summary: "Change a pick for a call from another match, before your first match starts.";
100
+ readonly steps: readonly [{
101
+ readonly title: "Find a pick to change";
102
+ readonly detail: "Before your first match, and 30 minutes before that pick's match.";
103
+ }, {
104
+ readonly title: "Choose a new call";
105
+ readonly detail: "YES or NO on an open call from a different match.";
106
+ }, {
107
+ readonly title: "Check the price";
108
+ readonly detail: "Your payout is re-quoted for the new pick.";
109
+ }];
110
+ readonly cost: {
111
+ readonly label: "Free";
112
+ readonly detail: "No extra stake. The payout follows the new pick.";
113
+ };
114
+ };
115
+ readonly hot_hand: {
116
+ readonly name: "Hot Hand";
117
+ readonly title: "Three in a row";
118
+ readonly cta: "Add Hot Hand";
119
+ readonly confirm: "Confirm Hot Hand";
120
+ readonly done: "Hot Hand";
121
+ readonly icon: readonly ["M12 10.94c2.33-3.3.17-7.82-1-8.94 0 3.4-2.24 5.3-3.67 6.7C5.9 10.12 5 12.33 5 14.3 5 18 8.13 21 12 21s7-3 7-6.7c0-1.71-1.23-4.4-2.33-5.59-2.09 3.35-3.26 3.35-4.67 2.24z"];
122
+ readonly summary: "A side bet: any three picks right in a row pays, even if the card misses.";
123
+ readonly steps: readonly [{
124
+ readonly title: "Add it before kick-off";
125
+ readonly detail: "From your entry, before the first match starts.";
126
+ }, {
127
+ readonly title: "Get three in a row";
128
+ readonly detail: "Three picks right back to back, in the order you made them.";
129
+ }, {
130
+ readonly title: "Collect on the side";
131
+ readonly detail: "Paid on top of your entry, win or lose.";
132
+ }];
133
+ readonly cost: {
134
+ readonly label: "One more stake";
135
+ readonly detail: "Quoted before you confirm.";
136
+ };
137
+ };
138
+ readonly second_thoughts: {
139
+ readonly name: "Second Thoughts";
140
+ readonly title: "Flip a pick";
141
+ readonly cta: "Flip pick";
142
+ readonly confirm: "Confirm flip";
143
+ readonly done: "Flipped";
144
+ readonly icon: readonly ["M8 20V4", "M4 8l4-4 4 4", "M16 4v16", "M12 16l4 4 4-4"];
145
+ readonly summary: "One free change of mind: flip a YES to NO, or NO to YES.";
146
+ readonly steps: readonly [{
147
+ readonly title: "Pick one to flip";
148
+ readonly detail: "Before your first match, and 30 minutes before that pick's match.";
149
+ }, {
150
+ readonly title: "Flip it";
151
+ readonly detail: "YES becomes NO, or NO becomes YES.";
152
+ }, {
153
+ readonly title: "Free, once";
154
+ readonly detail: "One flip per entry. Your payout is re-quoted.";
155
+ }];
156
+ readonly cost: {
157
+ readonly label: "Free";
158
+ readonly detail: "No extra stake. The payout follows the flipped pick.";
159
+ };
160
+ };
161
+ };
162
+ export type EntryRuleId = keyof typeof ENTRY_RULE_COPY;
163
+ /** What a used feature left on the entry: the new picks and what they pay. */
164
+ export interface EntryRuleResult {
165
+ rule: EntryRuleId;
166
+ /** The pick a reroll or swap took off the card. */
167
+ dropPropositionId?: number;
168
+ picks: {
169
+ prop: Proposition;
170
+ answer: 'yes' | 'no';
171
+ }[];
172
+ /** BLADE's maximum return on the accepted action. */
173
+ prize: number;
174
+ /** "if it's right", "if all 6 right". */
175
+ payWhen: string;
176
+ }
177
+ /** When the feature's prize pays: a reroll is the last call, a swap needs the whole card, a press is its own card. */
178
+ export declare function rulePayWhen(rule: EntryRuleId, entryLegs: number): string;
@@ -88,5 +88,3 @@ export declare function drawnCover(style: DrawnCoverStyle, raw: string, { ink, g
88
88
  * its citron accent; a single-colour glyph (a category's) all in citron, like the lockups' pills.
89
89
  */
90
90
  export declare function brandCover(raw: string, ink?: string, accent?: string): DrawnCover;
91
- /** Web: an icon's markup sized to fill its box, for drawing inline (lettering then takes the page's fonts). */
92
- export declare function fillBox(xml: string): string;
@@ -44,4 +44,5 @@ export declare const SHELF_UI: {
44
44
  readonly tag: 12;
45
45
  };
46
46
  };
47
- export type ShelfPipState = 'right' | 'miss' | 'open';
47
+ /** `chance`: a miss a game feature can still undo (Double Down's reroll). */
48
+ export type ShelfPipState = 'right' | 'miss' | 'open' | 'chance';
@@ -32,6 +32,8 @@ export interface RuleExpressionObject {
32
32
  }
33
33
  /** The game categories BLADE files a game under. */
34
34
  export type GameCategory = 'sports' | 'casino' | 'racing' | 'prediction' | 'fantasy';
35
+ /** After-placement rules a game can carry; see `entry-rules.ts`. */
36
+ export type GameFeatureId = 'double_down' | 'press' | 'late_swap' | 'hot_hand' | 'second_thoughts';
35
37
  export interface Game {
36
38
  id: number;
37
39
  game_name: string;
@@ -105,6 +107,8 @@ export interface Game {
105
107
  default_rule_id?: number | null;
106
108
  permitted_rule_ids?: number[];
107
109
  permitted_rules?: GamePermittedRule[];
110
+ /** After-placement rules BLADE switches on for this game (rendered on its entry cards). */
111
+ features?: GameFeatureId[];
108
112
  created_at?: string;
109
113
  updated_at?: string;
110
114
  }
@@ -212,6 +216,8 @@ export interface GameEntry {
212
216
  updated_at?: string;
213
217
  game_rule?: string;
214
218
  color?: string;
219
+ /** Game features active on this entry (Hot Hand). */
220
+ features?: GameFeatureId[];
215
221
  }
216
222
  /** Enriched entry data passed to `onSelectEntry` callbacks. */
217
223
  export interface ResolvedEntryData {
@@ -468,7 +474,91 @@ export interface GameEntriesProps {
468
474
  colorScheme?: ColorScheme;
469
475
  renderTeamLogo?: RenderTeamLogo;
470
476
  filterSport?: string;
477
+ /** Called once BLADE has accepted a game feature on an entry (status `awaiting_funding` until the host funds a cost). */
478
+ onEntryRule?: (action: EntryRuleAction) => void | Promise<void>;
479
+ /** Overrides the BLADE calls behind game features (the playground's demo pricer). Defaults to the API client. */
480
+ entryFeatureClient?: EntryFeatureClient;
471
481
  }
482
+ /** What BLADE offers on one entry (`GET /game-entries/{id}/features`). */
483
+ export interface EntryFeatureOffer {
484
+ assignment_id: number;
485
+ feature_id: number;
486
+ name: string;
487
+ description?: string;
488
+ /** BLADE's effect: `risk_winnings` (Press), or the effect a feature is built on. */
489
+ effect: string;
490
+ available: boolean;
491
+ unavailability_reason?: string | null;
492
+ config?: {
493
+ destination_game_ids?: number[];
494
+ [key: string]: unknown;
495
+ };
496
+ }
497
+ /** A priced, time-limited offer from BLADE (`POST /game-entries/{id}/feature-quotes`); accept it to commit. */
498
+ export interface EntryFeatureQuote {
499
+ id: string;
500
+ entry_id: number;
501
+ status: string;
502
+ /** Money is decimal strings, exactly as BLADE settles it. */
503
+ terms: {
504
+ cost: string;
505
+ maximum_return: string;
506
+ payout_table?: Record<string, string>;
507
+ destination_basis?: Record<string, string>;
508
+ [key: string]: unknown;
509
+ };
510
+ expires_at: string;
511
+ }
512
+ /** The body BLADE's quote endpoint takes (its schema forbids extra fields). */
513
+ export interface EntryFeatureQuoteInput {
514
+ assignment_id: number;
515
+ selection_id?: number | null;
516
+ amount?: number | null;
517
+ mode?: 'event' | 'instant';
518
+ destination?: {
519
+ game_id?: number;
520
+ propositions: {
521
+ proposition_id: number;
522
+ user_prediction: 'yes' | 'no';
523
+ }[];
524
+ } | null;
525
+ }
526
+ /** The three BLADE calls a feature needs. `BladeApiClient` implements it; the playground passes a demo one. */
527
+ export interface EntryFeatureClient {
528
+ getEntryFeatures(entryId: number): Promise<EntryFeatureOffer[]>;
529
+ quoteEntryFeature(entryId: number, input: EntryFeatureQuoteInput): Promise<EntryFeatureQuote>;
530
+ acceptEntryFeature(entryId: number, actionId: string, idempotencyKey: string): Promise<EntryFeatureQuote>;
531
+ }
532
+ /** A player's use of a game feature on one entry. */
533
+ export type EntryRuleAction = {
534
+ rule: 'double_down' | 'late_swap';
535
+ entry: GameEntry;
536
+ dropPropositionId: number;
537
+ replacement: {
538
+ propositionId: number;
539
+ answer: 'yes' | 'no';
540
+ };
541
+ accepted: EntryFeatureQuote;
542
+ } | {
543
+ rule: 'press';
544
+ entry: GameEntry;
545
+ winnings: number;
546
+ picks: {
547
+ propositionId: number;
548
+ answer: 'yes' | 'no';
549
+ }[];
550
+ accepted: EntryFeatureQuote;
551
+ } | {
552
+ rule: 'second_thoughts';
553
+ entry: GameEntry;
554
+ propositionId: number;
555
+ answer: 'yes' | 'no';
556
+ accepted: EntryFeatureQuote;
557
+ } | {
558
+ rule: 'hot_hand';
559
+ entry: GameEntry;
560
+ accepted: EntryFeatureQuote;
561
+ };
472
562
  export interface EvaluateRuleRequest {
473
563
  actual: number;
474
564
  predicted: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simple-parlay/components",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "UI components, hooks, and utilities for React and React Native",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",