@openmarketsai/order-sheet 0.1.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 (65) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +5 -0
  3. package/README.md +183 -0
  4. package/dist/auth.d.ts +24 -0
  5. package/dist/auth.js +36 -0
  6. package/dist/auth.js.map +1 -0
  7. package/dist/client.d.ts +158 -0
  8. package/dist/client.js +253 -0
  9. package/dist/client.js.map +1 -0
  10. package/dist/errors.d.ts +34 -0
  11. package/dist/errors.js +34 -0
  12. package/dist/errors.js.map +1 -0
  13. package/dist/generated/contract.d.ts +28 -0
  14. package/dist/generated/contract.js +176 -0
  15. package/dist/generated/contract.js.map +1 -0
  16. package/dist/http.d.ts +19 -0
  17. package/dist/http.js +58 -0
  18. package/dist/http.js.map +1 -0
  19. package/dist/index.cjs +1742 -0
  20. package/dist/index.d.ts +41 -0
  21. package/dist/index.js +31 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/math.d.ts +22 -0
  24. package/dist/math.js +55 -0
  25. package/dist/math.js.map +1 -0
  26. package/dist/messages.d.ts +21 -0
  27. package/dist/messages.js +97 -0
  28. package/dist/messages.js.map +1 -0
  29. package/dist/odds.d.ts +12 -0
  30. package/dist/odds.js +33 -0
  31. package/dist/odds.js.map +1 -0
  32. package/dist/quote.d.ts +20 -0
  33. package/dist/quote.js +117 -0
  34. package/dist/quote.js.map +1 -0
  35. package/dist/react.cjs +2137 -0
  36. package/dist/react.d.ts +157 -0
  37. package/dist/react.js +297 -0
  38. package/dist/react.js.map +1 -0
  39. package/dist/sheet.d.ts +77 -0
  40. package/dist/sheet.js +648 -0
  41. package/dist/sheet.js.map +1 -0
  42. package/dist/stream.d.ts +71 -0
  43. package/dist/stream.js +160 -0
  44. package/dist/stream.js.map +1 -0
  45. package/dist/types.d.ts +287 -0
  46. package/dist/types.js +2 -0
  47. package/dist/types.js.map +1 -0
  48. package/dist/ui/styles.css +284 -0
  49. package/dist/ui/theme.d.ts +108 -0
  50. package/dist/ui/theme.js +180 -0
  51. package/dist/ui/theme.js.map +1 -0
  52. package/dist/ui.cjs +2606 -0
  53. package/dist/ui.d.ts +124 -0
  54. package/dist/ui.js +154 -0
  55. package/dist/ui.js.map +1 -0
  56. package/dist/validate.d.ts +20 -0
  57. package/dist/validate.js +126 -0
  58. package/dist/validate.js.map +1 -0
  59. package/dist/venues.d.ts +19 -0
  60. package/dist/venues.js +103 -0
  61. package/dist/venues.js.map +1 -0
  62. package/dist/wire.d.ts +382 -0
  63. package/dist/wire.js +2 -0
  64. package/dist/wire.js.map +1 -0
  65. package/package.json +78 -0
@@ -0,0 +1,157 @@
1
+ /**
2
+ * @openmarketsai/order-sheet/react — hooks + UNSTYLED primitives.
3
+ *
4
+ * const h = useOrderSheet(om, { liquidityHash }) // subscribes; re-renders on state
5
+ * <OrderSheet.Root handle={h}>
6
+ * <OrderSheet.Venues /> <OrderSheet.Mode /> <OrderSheet.Stake />
7
+ * <OrderSheet.Quote /> <OrderSheet.Issues /> <OrderSheet.Submit />
8
+ * </OrderSheet.Root>
9
+ *
10
+ * Every primitive renders a plain element carrying `data-oms-part="…"` plus state
11
+ * attributes (`data-phase`, `data-mode`, `data-state`, `data-best`, …) and no
12
+ * class of its own, so a Tailwind user styles them with
13
+ * `[data-oms-part=submit][data-mode=real]:bg-red-600`. Each takes `className`,
14
+ * spreads the rest onto its element, and accepts `render` / `children` to swap
15
+ * the markup while keeping the wiring.
16
+ */
17
+ import { type ComponentPropsWithoutRef, type ReactNode } from 'react';
18
+ import type { OrderSheetClient } from './client.js';
19
+ import { type Sheet, type SheetInit } from './sheet.js';
20
+ import type { AccountFacts, Issue, MoneyMode, OrderType, PlaceOutcome, PositionRef, PreflightSnapshot, SheetPatch, SheetState, StakeUnit, VenueOption } from './types.js';
21
+ import type { OrderSheetError } from './errors.js';
22
+ export * from './index.js';
23
+ export declare function OrderSheetProvider({ client, children }: {
24
+ client: OrderSheetClient;
25
+ children: ReactNode;
26
+ }): import("react/jsx-runtime").JSX.Element;
27
+ export declare function useOrderSheetClient(): OrderSheetClient;
28
+ export interface OrderSheetHandle extends SheetState {
29
+ sheet: Sheet;
30
+ select: (partnerId: string | null) => void;
31
+ set: (patch: SheetPatch) => void;
32
+ setStake: (value: number | null, unit?: StakeUnit) => void;
33
+ setMode: (mode: MoneyMode) => void;
34
+ setOrderType: (t: OrderType) => void;
35
+ setMaxPrice: (p: number | null) => void;
36
+ place: (opts?: Parameters<Sheet['place']>[0]) => Promise<PlaceOutcome>;
37
+ confirm: () => Promise<PlaceOutcome>;
38
+ cancelConfirm: () => void;
39
+ cancel: () => Promise<{
40
+ cancelled: string[];
41
+ skipped: string[];
42
+ }>;
43
+ /** Ask the server for exact fees / fill / checks now (the state's `preflight` is the last answer). */
44
+ runPreflight: (opts?: {
45
+ verifyLiquidity?: boolean;
46
+ }) => Promise<PreflightSnapshot | null>;
47
+ reset: () => void;
48
+ refresh: () => Promise<void>;
49
+ }
50
+ /** Subscribe to a sheet's state. */
51
+ export declare function useSheetState(sheet: Sheet): SheetState;
52
+ export declare function isSheet(x: unknown): x is Sheet;
53
+ /**
54
+ * Open a sheet for a position and follow it. One sheet per (client, position);
55
+ * re-keyed when the position changes; destroyed on unmount.
56
+ *
57
+ * The sheet is opened in an EFFECT, never during render: rendering has no side
58
+ * effects, so server rendering fetches nothing and starts no timer, and a render
59
+ * React discards (concurrent rendering, Suspense retries) leaves nothing behind.
60
+ * Until the effect runs the handle is an inert `loading` sheet whose actions are
61
+ * no-ops (placing answers `not_ready`). StrictMode's mount → unmount → mount
62
+ * opens, destroys and re-opens — the surviving sheet is the second one.
63
+ *
64
+ * Pass an existing `Sheet` instead of a ref to follow one you opened yourself
65
+ * (it is then yours to destroy).
66
+ */
67
+ export declare function useOrderSheet(client: OrderSheetClient | null | undefined, ref: PositionRef | Sheet, init?: SheetInit): OrderSheetHandle;
68
+ /** The account's money modes, practice wallet and policy — for a mode switch before any position is open. */
69
+ export declare function useOrderSheetAccount(client?: OrderSheetClient | null): {
70
+ account: AccountFacts | null;
71
+ loading: boolean;
72
+ error: OrderSheetError | null;
73
+ refresh: () => Promise<void>;
74
+ };
75
+ export declare function useOrderSheetHandle(): OrderSheetHandle;
76
+ type DivProps = ComponentPropsWithoutRef<'div'>;
77
+ type FormProps = ComponentPropsWithoutRef<'form'>;
78
+ export interface RootProps extends Omit<FormProps, 'onSubmit'> {
79
+ handle: OrderSheetHandle;
80
+ /** Called after a successful submit (the default onSubmit places the order). */
81
+ onOutcome?: (outcome: PlaceOutcome) => void;
82
+ onPlaceError?: (error: OrderSheetError) => void;
83
+ }
84
+ export interface VenuesProps extends Omit<DivProps, 'children'> {
85
+ /** Replace the row markup; the wiring (select on click, data attributes) stays on the wrapper. */
86
+ render?: (venue: VenueOption, handle: OrderSheetHandle) => ReactNode;
87
+ /** Hide venues the current mode cannot use (default: show them, blocked, with the reason). */
88
+ hideBlocked?: boolean;
89
+ }
90
+ /**
91
+ * Which venue a key press moves to: arrows step through the ENABLED venues
92
+ * (wrapping), Home/End jump to the first/last. From no selection, forward keys
93
+ * land on the first enabled venue and backward keys on the last. Null = no move.
94
+ */
95
+ export declare function venueKeyTarget(key: string, venues: VenueOption[], fromPartnerId: string | null): VenueOption | null;
96
+ /** The one venue in the tab order: the selected one, else the first enabled one (else the first). */
97
+ export declare function tabbableVenueId(venues: VenueOption[]): string | null;
98
+ declare function Venues({ render, hideBlocked, ...rest }: VenuesProps): import("react/jsx-runtime").JSX.Element;
99
+ export interface ModeProps extends DivProps {
100
+ labels?: {
101
+ paper?: string;
102
+ real?: string;
103
+ };
104
+ }
105
+ declare function Mode({ labels, ...rest }: ModeProps): import("react/jsx-runtime").JSX.Element;
106
+ declare function OrderTypeToggle(props: DivProps): import("react/jsx-runtime").JSX.Element;
107
+ export interface StakeProps extends Omit<ComponentPropsWithoutRef<'input'>, 'value' | 'onChange'> {
108
+ label?: string;
109
+ /** Show the $ / shares unit toggle. */
110
+ unitToggle?: boolean;
111
+ /** Render only the <input> (you supply the label). */
112
+ bare?: boolean;
113
+ }
114
+ declare function Stake({ label, unitToggle, bare, id, ...rest }: StakeProps): import("react/jsx-runtime").JSX.Element;
115
+ export interface PriceProps extends Omit<ComponentPropsWithoutRef<'input'>, 'value' | 'onChange'> {
116
+ label?: string;
117
+ /** Render only the <input> (you supply the label and the reset). */
118
+ bare?: boolean;
119
+ }
120
+ /** The limit / max price, in probability (0.01–0.99). Shown for limit orders; for market orders it is the auto ceiling. */
121
+ declare function Price({ label, bare, id, ...rest }: PriceProps): import("react/jsx-runtime").JSX.Element;
122
+ export interface QuoteProps extends DivProps {
123
+ render?: (handle: OrderSheetHandle) => ReactNode;
124
+ }
125
+ declare function Quote({ render, ...rest }: QuoteProps): import("react/jsx-runtime").JSX.Element;
126
+ export interface IssuesProps extends DivProps {
127
+ /** Which severities to show (default: all). */
128
+ severities?: Array<Issue['severity']>;
129
+ render?: (issue: Issue, handle: OrderSheetHandle) => ReactNode;
130
+ }
131
+ declare function Issues({ severities, render, ...rest }: IssuesProps): import("react/jsx-runtime").JSX.Element;
132
+ export interface SubmitProps extends Omit<ComponentPropsWithoutRef<'button'>, 'children'> {
133
+ children?: ReactNode | ((handle: OrderSheetHandle) => ReactNode);
134
+ }
135
+ declare function Submit({ children, ...rest }: SubmitProps): import("react/jsx-runtime").JSX.Element;
136
+ export interface HintProps extends DivProps {
137
+ render?: (venue: VenueOption, handle: OrderSheetHandle) => ReactNode;
138
+ }
139
+ /** "Better price on X — switch?" — a suggestion the USER acts on; the sheet never auto-switches. */
140
+ declare function Hint({ render, ...rest }: HintProps): import("react/jsx-runtime").JSX.Element | null;
141
+ export interface OutcomeProps extends DivProps {
142
+ render?: (handle: OrderSheetHandle) => ReactNode;
143
+ }
144
+ declare function Outcome({ render, ...rest }: OutcomeProps): import("react/jsx-runtime").JSX.Element | null;
145
+ export declare const OrderSheet: {
146
+ Root: import("react").ForwardRefExoticComponent<RootProps & import("react").RefAttributes<HTMLFormElement>>;
147
+ Venues: typeof Venues;
148
+ Mode: typeof Mode;
149
+ OrderType: typeof OrderTypeToggle;
150
+ Stake: typeof Stake;
151
+ Price: typeof Price;
152
+ Quote: typeof Quote;
153
+ Issues: typeof Issues;
154
+ Submit: typeof Submit;
155
+ Hint: typeof Hint;
156
+ Outcome: typeof Outcome;
157
+ };
package/dist/react.js ADDED
@@ -0,0 +1,297 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * @openmarketsai/order-sheet/react — hooks + UNSTYLED primitives.
4
+ *
5
+ * const h = useOrderSheet(om, { liquidityHash }) // subscribes; re-renders on state
6
+ * <OrderSheet.Root handle={h}>
7
+ * <OrderSheet.Venues /> <OrderSheet.Mode /> <OrderSheet.Stake />
8
+ * <OrderSheet.Quote /> <OrderSheet.Issues /> <OrderSheet.Submit />
9
+ * </OrderSheet.Root>
10
+ *
11
+ * Every primitive renders a plain element carrying `data-oms-part="…"` plus state
12
+ * attributes (`data-phase`, `data-mode`, `data-state`, `data-best`, …) and no
13
+ * class of its own, so a Tailwind user styles them with
14
+ * `[data-oms-part=submit][data-mode=real]:bg-red-600`. Each takes `className`,
15
+ * spreads the rest onto its element, and accepts `render` / `children` to swap
16
+ * the markup while keeping the wiring.
17
+ */
18
+ import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useMemo, useRef, useState, useSyncExternalStore, } from 'react';
19
+ import { createInertSheet } from './sheet.js';
20
+ export * from './index.js';
21
+ // ─── Client context ────────────────────────────────────────────────────────────
22
+ const ClientContext = createContext(null);
23
+ export function OrderSheetProvider({ client, children }) {
24
+ return _jsx(ClientContext.Provider, { value: client, children: children });
25
+ }
26
+ export function useOrderSheetClient() {
27
+ const c = useContext(ClientContext);
28
+ if (!c)
29
+ throw new Error('useOrderSheetClient: wrap the tree in <OrderSheetProvider client={…}> or pass a client explicitly.');
30
+ return c;
31
+ }
32
+ function refKey(ref) {
33
+ if ('position' in ref)
34
+ return `pos:${ref.position.position_hash}:${ref.partnerId ?? ''}`;
35
+ if ('liquidityHash' in ref)
36
+ return `lh:${ref.liquidityHash}`;
37
+ return `ph:${ref.positionHash}:${ref.partnerId ?? ''}`;
38
+ }
39
+ /** Subscribe to a sheet's state. */
40
+ export function useSheetState(sheet) {
41
+ return useSyncExternalStore(sheet.subscribe, sheet.getState, sheet.getState);
42
+ }
43
+ export function isSheet(x) {
44
+ return typeof x === 'object' && x !== null && typeof x.getState === 'function' && typeof x.subscribe === 'function';
45
+ }
46
+ /**
47
+ * Open a sheet for a position and follow it. One sheet per (client, position);
48
+ * re-keyed when the position changes; destroyed on unmount.
49
+ *
50
+ * The sheet is opened in an EFFECT, never during render: rendering has no side
51
+ * effects, so server rendering fetches nothing and starts no timer, and a render
52
+ * React discards (concurrent rendering, Suspense retries) leaves nothing behind.
53
+ * Until the effect runs the handle is an inert `loading` sheet whose actions are
54
+ * no-ops (placing answers `not_ready`). StrictMode's mount → unmount → mount
55
+ * opens, destroys and re-opens — the surviving sheet is the second one.
56
+ *
57
+ * Pass an existing `Sheet` instead of a ref to follow one you opened yourself
58
+ * (it is then yours to destroy).
59
+ */
60
+ export function useOrderSheet(client, ref, init) {
61
+ const ctx = useContext(ClientContext);
62
+ const om = client ?? ctx;
63
+ const given = isSheet(ref) ? ref : null;
64
+ if (!om && !given)
65
+ throw new Error('useOrderSheet: pass a client or wrap the tree in <OrderSheetProvider>.');
66
+ const key = given ? 'given' : refKey(ref);
67
+ // Track the ref/init for the next opening without re-opening on identity changes.
68
+ const latest = useRef({ ref, init });
69
+ latest.current = { ref, init };
70
+ const [opened, setOpened] = useState(null);
71
+ useEffect(() => {
72
+ if (given || !om)
73
+ return;
74
+ const sheet = om.openSheet(latest.current.ref, latest.current.init);
75
+ setOpened({ key, om, sheet });
76
+ return () => {
77
+ sheet.destroy();
78
+ setOpened((cur) => (cur?.sheet === sheet ? null : cur));
79
+ };
80
+ }, [key, om, given]);
81
+ // Before the effect (and on the server): an inert placeholder for this key.
82
+ const inert = useMemo(() => (given || !om ? null : createInertSheet(om.options, latest.current.ref, latest.current.init)),
83
+ // eslint-disable-next-line react-hooks/exhaustive-deps
84
+ [key, om, given]);
85
+ const live = opened && opened.key === key && opened.om === om ? opened.sheet : null;
86
+ const sheet = given ?? live ?? inert;
87
+ const state = useSyncExternalStore(sheet.subscribe, sheet.getState, sheet.getState);
88
+ return useMemo(() => ({
89
+ ...state,
90
+ sheet,
91
+ select: sheet.select,
92
+ set: sheet.set,
93
+ setStake: (value, unit) => sheet.set({ stake: value == null ? null : (unit ?? state.stake.unit) === 'shares' ? { shares: value } : { amount: value } }),
94
+ setMode: (mode) => sheet.set({ mode }),
95
+ setOrderType: (orderType) => sheet.set({ orderType }),
96
+ setMaxPrice: (maxPrice) => sheet.set({ maxPrice }),
97
+ place: sheet.place,
98
+ confirm: sheet.confirm,
99
+ cancelConfirm: sheet.cancelConfirm,
100
+ cancel: sheet.cancel,
101
+ runPreflight: sheet.preflight,
102
+ reset: sheet.reset,
103
+ refresh: sheet.refresh,
104
+ }), [state, sheet]);
105
+ }
106
+ /** The account's money modes, practice wallet and policy — for a mode switch before any position is open. */
107
+ export function useOrderSheetAccount(client) {
108
+ const ctx = useContext(ClientContext);
109
+ const om = client ?? ctx;
110
+ const [account, setAccount] = useState(null);
111
+ const [loading, setLoading] = useState(true);
112
+ const [error, setError] = useState(null);
113
+ const refresh = useCallback(async () => {
114
+ if (!om)
115
+ return;
116
+ setLoading(true);
117
+ try {
118
+ setAccount(await om.account({ force: true }));
119
+ setError(null);
120
+ }
121
+ catch (e) {
122
+ setError(e);
123
+ }
124
+ finally {
125
+ setLoading(false);
126
+ }
127
+ }, [om]);
128
+ useEffect(() => {
129
+ let alive = true;
130
+ if (!om)
131
+ return;
132
+ om.account().then((a) => { if (alive) {
133
+ setAccount(a);
134
+ setError(null);
135
+ } }).catch((e) => { if (alive)
136
+ setError(e); }).finally(() => { if (alive)
137
+ setLoading(false); });
138
+ const off = om.events.on('constraints', (c) => { if (alive && c)
139
+ setAccount(om.accountFromConstraints(c)); });
140
+ return () => { alive = false; off(); };
141
+ }, [om]);
142
+ return { account, loading, error, refresh };
143
+ }
144
+ // ─── Unstyled primitives ───────────────────────────────────────────────────────
145
+ const HandleContext = createContext(null);
146
+ export function useOrderSheetHandle() {
147
+ const h = useContext(HandleContext);
148
+ if (!h)
149
+ throw new Error('OrderSheet.* must be rendered inside <OrderSheet.Root handle={…}>.');
150
+ return h;
151
+ }
152
+ const Root = forwardRef(function Root({ handle, onOutcome, onPlaceError, children, ...rest }, ref) {
153
+ return (_jsx(HandleContext.Provider, { value: handle, children: _jsx("form", { ref: ref, "data-oms-part": "root", "data-phase": handle.phase, "data-mode": handle.mode, "data-order-type": handle.orderType, "data-loading": handle.loading || undefined, noValidate: true, onSubmit: (e) => {
154
+ e.preventDefault();
155
+ handle.place().then((o) => onOutcome?.(o)).catch((err) => onPlaceError?.(err));
156
+ }, ...rest, children: children }) }));
157
+ });
158
+ /** The keys a radio group answers to (WAI-ARIA radio group pattern). */
159
+ const VENUE_KEYS = new Set(['ArrowRight', 'ArrowDown', 'ArrowLeft', 'ArrowUp', 'Home', 'End']);
160
+ const isEnabledVenue = (v) => v.eligibility.status !== 'blocked';
161
+ /**
162
+ * Which venue a key press moves to: arrows step through the ENABLED venues
163
+ * (wrapping), Home/End jump to the first/last. From no selection, forward keys
164
+ * land on the first enabled venue and backward keys on the last. Null = no move.
165
+ */
166
+ export function venueKeyTarget(key, venues, fromPartnerId) {
167
+ const enabled = venues.filter(isEnabledVenue);
168
+ if (enabled.length === 0 || !VENUE_KEYS.has(key))
169
+ return null;
170
+ if (key === 'Home')
171
+ return enabled[0];
172
+ if (key === 'End')
173
+ return enabled[enabled.length - 1];
174
+ const forward = key === 'ArrowRight' || key === 'ArrowDown';
175
+ const at = fromPartnerId == null ? -1 : venues.findIndex((v) => v.partnerId === fromPartnerId);
176
+ if (at < 0)
177
+ return forward ? enabled[0] : enabled[enabled.length - 1];
178
+ const n = venues.length;
179
+ for (let step = 1; step <= n; step++) {
180
+ const v = venues[(at + (forward ? step : -step) + n * step) % n];
181
+ if (isEnabledVenue(v))
182
+ return v;
183
+ }
184
+ return null;
185
+ }
186
+ /** The one venue in the tab order: the selected one, else the first enabled one (else the first). */
187
+ export function tabbableVenueId(venues) {
188
+ return (venues.find((v) => v.selected) ?? venues.find(isEnabledVenue) ?? venues[0])?.partnerId ?? null;
189
+ }
190
+ function Venues({ render, hideBlocked, ...rest }) {
191
+ const h = useOrderSheetHandle();
192
+ const venues = hideBlocked ? h.venues.filter(isEnabledVenue) : h.venues;
193
+ const nodes = useRef(new Map());
194
+ const tabbable = tabbableVenueId(venues);
195
+ const move = (key, from) => {
196
+ const target = venueKeyTarget(key, venues, from);
197
+ if (!target)
198
+ return false;
199
+ h.select(target.partnerId);
200
+ nodes.current.get(target.partnerId)?.focus();
201
+ return true;
202
+ };
203
+ return (_jsx("div", { "data-oms-part": "venues", role: "radiogroup", "aria-label": "Venue", ...rest, children: venues.map((v) => (_jsx("div", { ref: (el) => { if (el)
204
+ nodes.current.set(v.partnerId, el);
205
+ else
206
+ nodes.current.delete(v.partnerId); }, "data-oms-part": "venue", "data-state": v.eligibility.status, "data-selected": v.selected || undefined, "data-best": v.best || undefined, "data-connected": v.account.connected || undefined, role: "radio", "aria-checked": v.selected, "aria-disabled": v.eligibility.status === 'blocked' || undefined, tabIndex: v.partnerId === tabbable ? 0 : -1, onClick: () => h.select(v.partnerId), onKeyDown: (e) => {
207
+ if (e.key === 'Enter' || e.key === ' ') {
208
+ e.preventDefault();
209
+ h.select(v.partnerId);
210
+ return;
211
+ }
212
+ // The focused radio is the anchor (with roving focus it is the selected one).
213
+ if (move(e.key, v.partnerId))
214
+ e.preventDefault();
215
+ }, children: render ? render(v, h) : (_jsxs(_Fragment, { children: [_jsx("span", { "data-oms-part": "venue-name", children: v.name }), _jsx("span", { "data-oms-part": "venue-price", children: v.display.price }), v.best && _jsx("span", { "data-oms-part": "venue-best", children: "best" }), v.eligibility.issues[0] && _jsx("span", { "data-oms-part": "venue-reason", children: v.eligibility.issues[0].message })] })) }, v.partnerId))) }));
216
+ }
217
+ function Mode({ labels, ...rest }) {
218
+ const h = useOrderSheetHandle();
219
+ const modes = ['paper', 'real'];
220
+ const available = h.account?.moneyModes ?? ['paper'];
221
+ return (_jsx("div", { "data-oms-part": "mode", role: "group", "aria-label": "Money mode", ...rest, children: modes.map((m) => (_jsx("button", { type: "button", "data-oms-part": "mode-option", "data-mode": m, "data-available": available.includes(m) || undefined, "aria-pressed": h.mode === m, disabled: h.phase === 'placing', onClick: () => h.setMode(m), children: m === 'paper' ? (labels?.paper ?? 'Practice') : (labels?.real ?? 'Real money') }, m))) }));
222
+ }
223
+ function OrderTypeToggle(props) {
224
+ const h = useOrderSheetHandle();
225
+ const types = ['market', 'limit'];
226
+ const supported = h.venue?.supports.orderTypes ?? ['market'];
227
+ return (_jsx("div", { "data-oms-part": "order-type", role: "group", "aria-label": "Order type", ...props, children: types.map((t) => (_jsx("button", { type: "button", "data-oms-part": "order-type-option", "data-order-type": t, "data-available": (supported.includes(t) && !(h.mode === 'paper' && t === 'limit')) || undefined, "aria-pressed": h.orderType === t, disabled: h.phase === 'placing', onClick: () => h.setOrderType(t), children: t === 'market' ? 'Market' : 'Limit' }, t))) }));
228
+ }
229
+ function Stake({ label, unitToggle = true, bare, id, ...rest }) {
230
+ const h = useOrderSheetHandle();
231
+ const auto = useId();
232
+ const inputId = id ?? auto;
233
+ const unit = h.stake.unit;
234
+ const input = (_jsx("input", { id: inputId, "data-oms-part": "stake-input", "data-unit": unit, type: "number", inputMode: "decimal", min: 0, step: unit === 'amount' ? 0.01 : (h.venue?.constraints?.size.whole_contracts ? 1 : 0.01), value: h.stake.value ?? '', disabled: h.phase === 'placing', onChange: (e) => { const n = e.target.valueAsNumber; h.setStake(Number.isFinite(n) ? n : null); }, "aria-invalid": h.validation.blocking.some((i) => i.fix === 'raise_stake' || i.fix === 'lower_stake' || i.fix === 'round_stake') || undefined, ...rest }));
235
+ if (bare)
236
+ return input;
237
+ return (_jsxs("div", { "data-oms-part": "stake", "data-unit": unit, children: [_jsx("label", { "data-oms-part": "stake-label", htmlFor: inputId, children: label ?? (unit === 'amount' ? 'Stake' : 'Contracts') }), input, unitToggle && (_jsx("div", { "data-oms-part": "stake-unit", role: "group", "aria-label": "Stake unit", children: ['amount', 'shares'].map((u) => (_jsx("button", { type: "button", "data-oms-part": "stake-unit-option", "data-unit": u, "aria-pressed": unit === u, onClick: () => h.setStake(h.stake.value, u), children: u === 'amount' ? (h.quote?.currency === 'USD' || !h.quote ? '$' : h.quote.currency) : 'contracts' }, u))) }))] }));
238
+ }
239
+ /** The limit / max price, in probability (0.01–0.99). Shown for limit orders; for market orders it is the auto ceiling. */
240
+ function Price({ label, bare, id, ...rest }) {
241
+ const h = useOrderSheetHandle();
242
+ const auto = useId();
243
+ const inputId = id ?? auto;
244
+ const tick = h.venue?.constraints?.price.tick ?? 0.01;
245
+ const input = (_jsx("input", { id: inputId, "data-oms-part": "price-input", "data-auto": h.maxPriceIsAuto || undefined, type: "number", inputMode: "decimal", min: h.venue?.constraints?.price.min ?? 0.01, max: h.venue?.constraints?.price.max ?? 0.99, step: tick, value: h.maxPrice ?? '', disabled: h.phase === 'placing', onChange: (e) => { const n = e.target.valueAsNumber; h.setMaxPrice(Number.isFinite(n) ? n : null); }, ...rest }));
246
+ if (bare)
247
+ return input;
248
+ return (_jsxs("div", { "data-oms-part": "price", "data-auto": h.maxPriceIsAuto || undefined, "data-order-type": h.orderType, children: [_jsx("label", { "data-oms-part": "price-label", htmlFor: inputId, children: label ?? (h.orderType === 'limit' ? 'Limit price' : 'Max price') }), input, !h.maxPriceIsAuto && _jsx("button", { type: "button", "data-oms-part": "price-reset", onClick: () => h.setMaxPrice(null), children: "auto" })] }));
249
+ }
250
+ function Quote({ render, ...rest }) {
251
+ const h = useOrderSheetHandle();
252
+ const q = h.quote;
253
+ return (_jsx("div", { "data-oms-part": "quote", "data-freshness": q?.freshness, "aria-live": "polite", ...rest, children: render ? render(h) : q ? (_jsxs("dl", { children: [_jsx("dt", { children: "Price" }), _jsx("dd", { "data-oms-part": "quote-price", children: q.display.price }), _jsx("dt", { children: "Cost" }), _jsx("dd", { "data-oms-part": "quote-cost", children: q.display.cost }), _jsx("dt", { children: "Contracts" }), _jsx("dd", { "data-oms-part": "quote-contracts", children: q.contracts }), _jsx("dt", { children: "To win" }), _jsx("dd", { "data-oms-part": "quote-payout", children: q.display.payout }), q.fee && _jsxs(_Fragment, { children: [_jsx("dt", { children: "Fee" }), _jsx("dd", { "data-oms-part": "quote-fee", children: q.display.fee })] }), _jsx("dt", { children: "Profit" }), _jsx("dd", { "data-oms-part": "quote-profit", children: q.display.profit })] })) : null }));
254
+ }
255
+ function Issues({ severities, render, ...rest }) {
256
+ const h = useOrderSheetHandle();
257
+ const list = h.validation.all.filter((i) => !severities || severities.includes(i.severity));
258
+ const hasBlock = list.some((i) => i.severity === 'block');
259
+ return (
260
+ // polite, not assertive: a blocking issue can change on every keystroke of the
261
+ // stake, and an assertive region would interrupt the user each time.
262
+ _jsx("div", { "data-oms-part": "issues", role: "status", "aria-live": "polite", "data-blocking": hasBlock || undefined, ...rest, children: list.map((i) => (_jsx("div", { "data-oms-part": "issue", "data-severity": i.severity, "data-code": i.code, "data-fix": i.fix, "data-source": i.source, children: render ? render(i, h) : i.message }, `${i.scope}:${i.code}`))) }));
263
+ }
264
+ function Submit({ children, ...rest }) {
265
+ const h = useOrderSheetHandle();
266
+ return (_jsx("button", { type: "submit", "data-oms-part": "submit", "data-mode": h.mode, "data-phase": h.phase, disabled: !h.canPlace, "aria-busy": h.phase === 'placing' || undefined, ...rest, children: typeof children === 'function' ? children(h) : children ?? h.confirmLabel }));
267
+ }
268
+ /** "Better price on X — switch?" — a suggestion the USER acts on; the sheet never auto-switches. */
269
+ function Hint({ render, ...rest }) {
270
+ const h = useOrderSheetHandle();
271
+ if (!h.hint)
272
+ return null;
273
+ const v = h.hint.venue;
274
+ return (_jsx("div", { "data-oms-part": "hint", ...rest, children: render ? render(v, h) : (_jsx("button", { type: "button", "data-oms-part": "hint-switch", onClick: () => h.select(v.partnerId), children: h.hint.message })) }));
275
+ }
276
+ function Outcome({ render, ...rest }) {
277
+ const h = useOrderSheetHandle();
278
+ const r = h.result;
279
+ if (!r)
280
+ return null;
281
+ const leg = r.legs[0];
282
+ return (_jsx("div", { "data-oms-part": "outcome", "data-summary": r.summary, "data-phase": h.phase, "aria-live": "polite", ...rest, children: render ? render(h) : (_jsxs(_Fragment, { children: [_jsx("span", { "data-oms-part": "outcome-summary", children: h.phase }), leg?.issue && _jsx("span", { "data-oms-part": "outcome-issue", children: leg.issue.message }), leg && leg.fill.shares > 0 && _jsxs("span", { "data-oms-part": "outcome-fill", children: [leg.fill.shares, " @ ", leg.fill.avgPrice ?? '—'] }), leg?.substituted && _jsx("span", { "data-oms-part": "outcome-substituted", children: "Filled on a different venue than requested \u2014 report this." })] })) }));
283
+ }
284
+ export const OrderSheet = {
285
+ Root,
286
+ Venues,
287
+ Mode,
288
+ OrderType: OrderTypeToggle,
289
+ Stake,
290
+ Price,
291
+ Quote,
292
+ Issues,
293
+ Submit,
294
+ Hint,
295
+ Outcome,
296
+ };
297
+ //# sourceMappingURL=react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EACH,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAC/F,oBAAoB,GACvB,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,gBAAgB,EAA8B,MAAM,YAAY,CAAA;AAIzE,cAAc,YAAY,CAAA;AAE1B,kFAAkF;AAElF,MAAM,aAAa,GAAG,aAAa,CAA0B,IAAI,CAAC,CAAA;AAElE,MAA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AA;IAC/B,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAA;IAClB,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAA;IACnB,MAAM,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACrB,OAAO,CACH,+BAAmB,SAAS,kBAAe,CAAC,CAAC,OAAO,gBAAc,CAAC,CAAC,KAAK,eAAY,QAAQ,KAAK,IAAI,YACjG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAClB,8BACI,gCAAoB,iBAAiB,YAAE,CAAC,CAAC,KAAK,GAAQ,EACrD,GAAG,EAAE,KAAK,IAAI,gCAAoB,eAAe,YAAE,GAAG,CAAC,KAAK,CAAC,OAAO,GAAQ,EAC5E,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,iCAAoB,cAAc,aAAE,GAAG,CAAC,IAAI,CAAC,MAAM,SAAK,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,GAAG,IAAQ,EACtH,GAAG,EAAE,WAAW,IAAI,gCAAoB,qBAAqB,+EAAiE,IAChI,CACN,GACC,CACT,CAAA;AACL,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,IAAI;IACJ,MAAM;IACN,IAAI;IACJ,SAAS,EAAE,eAAe;IAC1B,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;IACN,IAAI;IACJ,OAAO;CACV,CAAA"}
@@ -0,0 +1,77 @@
1
+ import type { AccountFacts, PlaceLeg, PlaceOutcome, PlaceResult, PlaceSummary, PositionRef, PreflightSnapshot, SheetPatch, SheetPhase, SheetState, TrackedOrder, VenueOption, MoneyMode, OrderType } from './types.js';
2
+ import type { OddsFormat } from './odds.js';
3
+ import type { BuyResponse, StreamOrderSettled, StreamOrderUpdate } from './wire.js';
4
+ import type { OrderSheetClient, ResolvedClientOptions } from './client.js';
5
+ export interface SheetInit {
6
+ mode?: MoneyMode;
7
+ orderType?: OrderType;
8
+ stake?: {
9
+ amount: number;
10
+ } | {
11
+ shares: number;
12
+ };
13
+ maxPrice?: number;
14
+ oddsFormat?: OddsFormat;
15
+ slippage?: number;
16
+ /** Pre-select this venue (defaults to the venue named by the ref, e.g. the clicked cell). */
17
+ partnerId?: string;
18
+ }
19
+ export interface Sheet {
20
+ getState(): SheetState;
21
+ subscribe(listener: (state: SheetState) => void): () => void;
22
+ /** Pick the venue. The only way a venue is ever chosen. */
23
+ select(partnerId: string | null): void;
24
+ set(patch: SheetPatch): void;
25
+ /** Re-read the position and the constraints. */
26
+ refresh(): Promise<void>;
27
+ /** Ask the server for the exact fees, fill and every pre-placement check for the current inputs. */
28
+ preflight(opts?: {
29
+ verifyLiquidity?: boolean;
30
+ }): Promise<PreflightSnapshot | null>;
31
+ /**
32
+ * Place the order. Throws OrderSheetError on a transport/4xx failure only.
33
+ * A real-money order (with `realMoney.confirm`, the default) returns
34
+ * `confirm_required` first; calling `place()` again while `phase ===
35
+ * 'confirming'` with the SAME inputs is the confirm click. While a placement
36
+ * is in flight, every further call returns that same promise.
37
+ */
38
+ place(opts?: {
39
+ idempotencyKey?: string;
40
+ verifyLiquidity?: boolean;
41
+ }): Promise<PlaceOutcome>;
42
+ /**
43
+ * Second click of the real-money confirm step. Places only when `phase ===
44
+ * 'confirming'` AND the inputs are exactly the ones confirmed; any edit after
45
+ * `confirm_required` clears the confirmation, and `confirm()` then returns
46
+ * `blocked` with `confirm_expired` — call `place()` again for a fresh confirm.
47
+ */
48
+ confirm(): Promise<PlaceOutcome>;
49
+ cancelConfirm(): void;
50
+ /** Cancel the resting order(s) this sheet placed. */
51
+ cancel(): Promise<{
52
+ cancelled: string[];
53
+ skipped: string[];
54
+ }>;
55
+ /** Back to an empty slip on the same position. */
56
+ reset(): void;
57
+ destroy(): void;
58
+ /** Test hook / host-owned sockets: feed an order frame in. */
59
+ ingestOrderUpdate(frame: StreamOrderUpdate): void;
60
+ ingestOrderSettled(frame: StreamOrderSettled): void;
61
+ }
62
+ /** The snapshot a sheet starts from, before anything has loaded. Pure — no I/O. */
63
+ export declare function initialSheetState(o: ResolvedClientOptions, ref: PositionRef, init?: SheetInit): SheetState;
64
+ /**
65
+ * A sheet that does nothing: no fetch, no timer, no listener on the client.
66
+ * What `useOrderSheet` renders with on the server and before its effect has
67
+ * opened the real sheet. Every action is a no-op; placing answers `not_ready`.
68
+ */
69
+ export declare function createInertSheet(o: ResolvedClientOptions, ref: PositionRef, init?: SheetInit): Sheet;
70
+ export declare function createSheet(client: OrderSheetClient, ref: PositionRef, init?: SheetInit): Sheet;
71
+ export declare function newIdempotencyKey(): string;
72
+ export declare function phaseFromSummary(summary: PlaceSummary): SheetPhase;
73
+ /** Fold every tracked order's fill state into one phase. */
74
+ export declare function phaseFromOrders(orders: TrackedOrder[], current: SheetPhase): SheetPhase;
75
+ export declare function toPlaceResult(raw: BuyResponse, venue: VenueOption, account: AccountFacts | null, idempotencyKey: string, now: number): PlaceResult;
76
+ export declare function summarize(legs: PlaceLeg[]): PlaceSummary;
77
+ export declare function describeCost(n: number, currency: string): string;