@stridge/pay-kit 0.0.0-stage → 0.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +339 -2
  3. package/dist/account.d.ts +4 -0
  4. package/dist/account.js +1 -0
  5. package/dist/channel/createAppChannel.js +1 -0
  6. package/dist/channel/createDialogAriaHiddenIntent.js +1 -0
  7. package/dist/channel/createDialogHost.js +1 -0
  8. package/dist/channel/createScrollLock.js +2 -0
  9. package/dist/channel/iframeTransport.js +1 -0
  10. package/dist/channel/popupTransport.js +1 -0
  11. package/dist/channel/presentation.js +1 -0
  12. package/dist/channel/types.d.ts +225 -0
  13. package/dist/core/buildElementUrl.js +1 -0
  14. package/dist/core/createElementClient.js +1 -0
  15. package/dist/core/createElementHandle.js +1 -0
  16. package/dist/core/createElementLedger.js +1 -0
  17. package/dist/core/createElementLifetimeBridge.js +1 -0
  18. package/dist/core/elementClientTypes.d.ts +20 -0
  19. package/dist/core/elementGeometry.js +1 -0
  20. package/dist/core/elementLoadState.d.ts +1 -0
  21. package/dist/core/elementLoadState.js +1 -0
  22. package/dist/core/elementSizing.js +1 -0
  23. package/dist/core/elementStartGate.js +1 -0
  24. package/dist/core/types.d.ts +1 -0
  25. package/dist/errors/PayError.d.ts +37 -0
  26. package/dist/errors/PayError.js +1 -0
  27. package/dist/hooks/keypairState.js +1 -0
  28. package/dist/hooks/types.d.ts +104 -0
  29. package/dist/hooks/usePayAccount.d.ts +16 -0
  30. package/dist/hooks/usePayAccount.js +1 -0
  31. package/dist/hooks/usePaySnapshot.d.ts +13 -0
  32. package/dist/hooks/usePaySnapshot.js +1 -0
  33. package/dist/index.d.ts +10 -0
  34. package/dist/index.js +1 -0
  35. package/dist/provider/PayProvider.d.ts +47 -0
  36. package/dist/provider/PayProvider.js +1 -0
  37. package/dist/provider/context.js +1 -0
  38. package/dist/provider/createProviderLifetime.js +1 -0
  39. package/dist/provider/elementContext.js +1 -0
  40. package/dist/provider/hubAddress.js +1 -0
  41. package/dist/provider/types.d.ts +73 -0
  42. package/dist/react/ElementDefault.d.ts +23 -0
  43. package/dist/react/ElementDefault.js +1 -0
  44. package/dist/react/ElementHost.js +1 -0
  45. package/dist/react/ElementLanes.js +1 -0
  46. package/dist/react/PayElement.d.ts +13 -0
  47. package/dist/react/PayElement.js +1 -0
  48. package/dist/react/compileElementOptions.js +1 -0
  49. package/dist/react/compilePayRequest.js +1 -0
  50. package/dist/react/elementDefaultStyles.d.ts +15 -0
  51. package/dist/react/elementDefaultStyles.js +69 -0
  52. package/dist/react/elementSwap.js +1 -0
  53. package/dist/react/payEvents.d.ts +139 -0
  54. package/dist/react/payEvents.js +1 -0
  55. package/dist/react/presentElement.js +1 -0
  56. package/dist/react/stridgeLockup.js +1 -0
  57. package/dist/react/types.d.ts +118 -0
  58. package/dist/react/useElementHandle.js +1 -0
  59. package/dist/shared/presentation/hubWindow.js +1 -0
  60. package/dist/shared/presentation/subscribeToNothing.js +1 -0
  61. package/package.json +124 -3
@@ -0,0 +1 @@
1
+ "use client";import{createContext as e}from"react";const t=e(null);t.displayName=`PayChannelContext`;export{t as PayChannelContext};
@@ -0,0 +1 @@
1
+ const e=new WeakMap,t=e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)};function n(n){let{channel:r,finalize:i}=n,a=n.schedule??t,o=0,s=0,c=!1,l=!1,u=null,d=null,f={leased:()=>o>0,dispose:h};function p(){let e=d;d=null,e?.()}function m(){c=!0,n.dialogAriaHiddenIntent?.retire(),s+=1,o=0;let t=d;d=null;let r=u;u=null,r!==null&&e.get(r)===f&&e.delete(r);let a=!1;return()=>{if(a)return;a=!0;let e=[];for(let r of[()=>t?.(),()=>i?.(),()=>n.dialogAriaHiddenIntent?.cleanup()])try{r()}catch(t){e.push(t)}if(e.length>0)throw e[0]}}n.disposalBridge?.bind(m);function h(){if(c)return;if(n.disposalBridge!==void 0){r.dispose();return}let e=m(),t=[];for(let n of[()=>r.dispose(),e])try{n()}catch(e){t.push(e)}if(t.length>0)throw t[0]}return{channel:r,get disposed(){return c},acquire(){if(c)throw Error(`PayProvider: this provider lifetime already ended`);if(l)throw Error(`PayProvider: acquire() during an active acquisition`);l=!0;let t=!1;try{let i=u??n.document??globalThis.document,l=e.get(i);for(;l!==void 0&&l!==f;){if(l.leased())throw Error(`PayProvider: only one PayProvider may be mounted on a page, and another one already owns its hub frame. Mount one PayProvider around the whole app.`);if(l.dispose(),c)throw Error(`PayProvider: this provider lifetime already ended`);l=e.get(i)}if(c)throw Error(`PayProvider: this provider lifetime already ended`);e.set(i,f),u=i,t=!0;let m=()=>{if(c||e.get(i)!==f)throw Error(`PayProvider: this provider lifetime already ended`)};s+=1,p(),m(),o+=1,n.dialogAriaHiddenIntent?.activate(h),m(),o===1&&r.iframe===null&&r.mount(i.body),m();let g=!1;return()=>{if(g||c||(g=!0,--o,o>0))return;let e=s;p(),!(c||e!==s||o!==0)&&(d=a(()=>{!c&&e===s&&o===0&&h()}))}}catch(e){if(t)try{h()}catch{}throw e}finally{l=!1}},dispose:h}}function r(){let e=!1,t=!1,n=null;return{bind(t){if(e)throw Error(`PayProvider: disposal bridge already bound`);e=!0,n=t},begin(){if(!e)throw Error(`PayProvider: disposal bridge is not bound`);if(t)return()=>{};t=!0;let r=n;return n=null,r()}}}export{r as createProviderChannelDisposalBridge,n as createProviderLifetime};
@@ -0,0 +1 @@
1
+ "use client";import{createContext as e}from"react";const t=e(void 0);t.displayName=`PayElementClientContext`;const n=e(null);n.displayName=`PayElementFrameContext`;const r=e(`light`);r.displayName=`PayElementThemeContext`;export{t as PayElementClientContext,n as PayElementFrameContext,r as PayElementThemeContext};
@@ -0,0 +1 @@
1
+ "use client";import{createContext as e}from"react";const t={sandbox:`https://universal.stridge.dev/`,live:null},n=e(null);n.displayName=`HubAddressOverrideContext`;function r(e,n){if(e!==`sandbox`&&e!==`live`)throw TypeError(`PayProvider: environment must be "sandbox" or "live".`);let r=t[e];if(r===null)throw TypeError(`PayProvider: the "${e}" environment has no hub yet. Use environment="sandbox".`);return n??r}export{t as HUB_ADDRESSES,n as HubAddressOverrideContext,r as resolveHubAddress};
@@ -0,0 +1,73 @@
1
+ import { PayConnectedEvent } from "../core/elementClientTypes.js";
2
+ import { ReactNode } from "react";
3
+ import { HubTheme } from "@stridge/pay-sdk";
4
+ //#region src/provider/types.d.ts
5
+ /**
6
+ * The colour scheme a consumer picks: `"dark"`, `"light"`, or `"system"` to follow the browser's
7
+ * `prefers-color-scheme`. The provider resolves `"system"` to dark or light; only dark or light reaches the hub.
8
+ */
9
+ type PayProviderTheme = HubTheme | "system";
10
+ /**
11
+ * Props of `PayProvider`. Theme configures the hub and every PayElement.
12
+ *
13
+ * Headless hooks report the provider's own hub frame and the Stridge windows opened by its app channel. Element
14
+ * connected notices notify `onConnected` without mirroring into headless status or account. Draw the connected
15
+ * state with the elements, and call `usePayAccount().sign(message)` from a user's click without requiring signed-in status.
16
+ */
17
+ interface PayProviderProps {
18
+ /**
19
+ * Observe allowlisted status from the provider frame. Defaults to false. Does not enable hub capability.
20
+ *
21
+ * @internal
22
+ */
23
+ diagnostics?: boolean;
24
+ /**
25
+ * The Stridge environment the provider connects to: `"sandbox"` or `"live"`. `"live"` has no hub yet and throws a
26
+ * configuration error; use `"sandbox"`.
27
+ */
28
+ environment: "sandbox" | "live";
29
+ /**
30
+ * The app id the backend issued for this app. A change replaces the provider lifetime.
31
+ */
32
+ appId: string;
33
+ /**
34
+ * The color scheme for the hub and every PayElement. `"system"` follows the browser's `prefers-color-scheme` and
35
+ * changes with it; the server render and the first render of a hydrating page use the dark scheme, and the
36
+ * browser's scheme applies right after. Defaults to `"dark"`. Changes are sent as appearance messages, never as
37
+ * element config revisions.
38
+ */
39
+ theme?: PayProviderTheme;
40
+ /**
41
+ * Called once for each distinct address observed through an authenticated element connected notice or a
42
+ * successful app-owned `usePayAccount().signIn()`, including an element that starts connected. Both sources share one
43
+ * distinct-address set for this provider's lifetime. Several elements, StrictMode replay and reconnection of the
44
+ * same address do not repeat it. This notification is not proof of a live signing session; headless hooks do not
45
+ * mirror element notices.
46
+ */
47
+ onConnected?: (event: PayConnectedEvent) => void;
48
+ /**
49
+ * One stable host modal adapter for exact aria-hidden restoration on the owned dialog. It registers an explicit
50
+ * initial state once after commit and returns synchronous cleanup. Signals update aggregate host intent without
51
+ * hiding the presenting dialog. Omission keeps captured/observed DOM compatibility, including invisible no-op
52
+ * removals. Changing this function requires a new provider key or hub/app identity.
53
+ */
54
+ dialogAriaHiddenAdapter?: PayDialogAriaHiddenAdapter;
55
+ /**
56
+ * The consumer's tree; the hooks and every PayElement work anywhere inside it.
57
+ */
58
+ children: ReactNode;
59
+ }
60
+ /** Exact desired aria-hidden state after the owned dialog releases presentation. */
61
+ type PayDialogAriaHiddenState = null | "false" | "true";
62
+ /**
63
+ * Commits each valid call, including an identical value. Returns false after permanent disposal before validating
64
+ * the value. Active invalid values throw TypeError. Closed calls update stored intent without writing the DOM.
65
+ */
66
+ type PayDialogAriaHiddenSignal = (value: PayDialogAriaHiddenState) => boolean;
67
+ /**
68
+ * Registers one explicit initial intent synchronously and returns synchronous subscription cleanup. One adapter
69
+ * aggregates all host modals; setup that throws before returning cleanup must release its own host resources.
70
+ */
71
+ type PayDialogAriaHiddenAdapter = (register: (initial: PayDialogAriaHiddenState) => PayDialogAriaHiddenSignal) => () => void;
72
+ //#endregion
73
+ export { PayDialogAriaHiddenAdapter, PayDialogAriaHiddenSignal, PayDialogAriaHiddenState, PayProviderProps, PayProviderTheme };
@@ -0,0 +1,23 @@
1
+ import { ReactElement } from "react";
2
+ import { HubTheme } from "@stridge/pay-sdk";
3
+ //#region src/react/ElementDefault.d.ts
4
+ /**
5
+ * Which default view shows: `failed`, the frame never answered; `connecting`, the app's page retries it.
6
+ */
7
+ type ElementDefaultFace = "failed" | "connecting";
8
+ /**
9
+ * Props of {@link ElementDefault}.
10
+ */
11
+ interface ElementDefaultProps {
12
+ readonly face: ElementDefaultFace;
13
+ readonly theme: HubTheme;
14
+ readonly retry: () => void;
15
+ }
16
+ /**
17
+ * The kit's default view in the app's page for a Stridge Wallet element whose frame never answered, drawn like the
18
+ * hub's own in-frame failure bar: 62 px with the mark, the title over its subline, and the Try again pill. The Pay
19
+ * card draws its failure in its lanes instead (`ElementLanesFailure`).
20
+ */
21
+ declare function ElementDefault({ face, theme, retry }: ElementDefaultProps): ReactElement;
22
+ //#endregion
23
+ export { ElementDefault, ElementDefaultFace, ElementDefaultProps };
@@ -0,0 +1 @@
1
+ "use client";import{DEFAULT_CLASS as e,ELEMENT_DEFAULT_GEOMETRY as t}from"./elementDefaultStyles.js";import{useEffect as n,useId as r,useState as i}from"react";import"@stridge/pay-sdk";import{Fragment as a,jsx as o,jsxs as s}from"react/jsx-runtime";const c={failed:{title:`Stridge Wallet didn’t load`,description:`Check your connection and retry`},connecting:{title:`Connecting to Stridge Wallet`,description:`This can take a few seconds`}};function l(){return o(`span`,{"aria-hidden":`true`,className:`${e}__mark`,children:o(`svg`,{focusable:`false`,viewBox:`0 0 256 256`,children:o(`path`,{d:`M21.12 82.85C26.99 68.97 35.27 56.68 45.97 45.98C56.68 35.27 68.97 26.99 82.84 21.12C97.22 15.04 112.27 12 128 12C143.73 12 158.78 15.04 173.16 21.12C187.03 26.99 199.32 35.28 210.03 45.98C220.73 56.68 229.01 68.97 234.88 82.85C240.96 97.22 244 112.27 244 128C244 143.73 240.96 158.78 234.88 173.15C229.01 187.03 220.73 199.32 210.03 210.02C199.32 220.73 187.03 229.01 173.16 234.88C158.78 240.96 143.73 244 128 244C112.27 244 97.22 240.96 82.84 234.88C68.97 229.01 56.68 220.73 45.97 210.02C35.27 199.32 26.99 187.03 21.12 173.15C15.04 158.78 12 143.73 12 128C12 112.27 15.04 97.22 21.12 82.85ZM181.23 57.56C176.03 53.62 170.39 50.27 164.33 47.53C152.83 42.33 140.72 39.73 128 39.73C104.88 39.73 85.3 46.83 69.25 61.02C54.83 73.76 45.98 89.35 42.69 107.79C39.43 126.01 42.61 141.39 52.23 153.94C62.9 167.85 79.51 174.81 102.05 174.81C120.34 174.81 135.79 168.18 148.42 154.91C149.05 154.25 149.6 153.65 150.07 153.11C150.16 153 150.27 152.9 150.37 152.81C153.8 149.85 157.73 148.8 162.16 149.66C162.27 149.69 162.38 149.71 162.49 149.74C168.15 150.94 171.68 154.38 173.08 160.05C174.06 164.02 173.41 167.71 171.14 171.11C171.07 171.21 171 171.31 170.92 171.4C170.2 172.23 169.4 173.11 168.53 174.03C160.01 182.99 150.11 189.94 138.84 194.88C127.17 199.99 114.91 202.54 102.06 202.54C92.61 202.54 83.51 201.18 74.77 198.44C79.98 202.39 85.61 205.73 91.67 208.47C103.17 213.67 115.28 216.27 128.01 216.27C151.13 216.27 170.71 209.17 186.76 194.98C201.18 182.24 210.03 166.65 213.32 148.22C216.57 130 213.39 114.61 203.77 102.07C193.1 88.15 176.49 81.19 153.95 81.19C135.65 81.19 120.2 87.82 107.6 101.07C106.84 101.87 106.29 102.48 105.93 102.89C105.84 103 105.73 103.1 105.63 103.19C102.2 106.15 98.27 107.2 93.84 106.34C87.99 105.2 84.35 101.74 82.93 95.96C81.95 92 82.59 88.31 84.86 84.89C84.93 84.78 85.01 84.68 85.1 84.57C86.04 83.52 86.83 82.65 87.48 81.97C96 73.02 105.89 66.07 117.17 61.14C128.84 56.02 141.1 53.47 153.95 53.47C163.4 53.47 172.5 54.83 181.23 57.56Z`})})})}function u({size:n}){let{stroke:r}=t.spinner,i=n/2,a=(n-r)/2;return o(`span`,{"aria-hidden":`true`,className:`${e}__spinner`,children:s(`svg`,{focusable:`false`,fill:`none`,width:n,height:n,viewBox:`0 0 ${n} ${n}`,children:[o(`circle`,{className:`${e}__spinner-track`,cx:i,cy:i,r:a,strokeWidth:r}),o(`path`,{className:`${e}__spinner-arc`,d:`M${i} ${i-a}a${a} ${a} 0 0 1 ${a} ${a}`,strokeLinecap:`round`,strokeWidth:r})]})})}const d={pill:{className:`${e}__retry`,spinner:t.spinner.size},action:{className:`${e}__action`,spinner:t.spinner.actionSize}};function f({variant:t,face:n,retry:r,describedBy:i}){let a=n===`connecting`,c=d[t];return s(`button`,{type:`button`,className:c.className,"aria-busy":a?!0:void 0,"aria-disabled":a?!0:void 0,"aria-describedby":i,onClick:a?void 0:r,children:[o(`span`,{className:`${e}__retry-label`,children:`Try again`}),a?o(u,{size:c.spinner}):null]})}function p({face:t}){let r=c[t].title,[a,s]=i(``);return n(()=>{s(r)},[r]),o(`span`,{role:`status`,"aria-live":`polite`,className:`${e}__status`,children:a})}function m({face:t,theme:n,retry:i}){let u=r(),d=c[t];return s(a,{children:[o(`div`,{className:`${e} ${e}--card`,"data-theme":n,"data-face":t,children:s(`div`,{className:`${e}__line`,children:[o(l,{}),s(`span`,{className:`${e}__text`,children:[o(`span`,{id:u,className:`${e}__title`,children:d.title}),o(`span`,{className:`${e}__description`,children:d.description})]}),o(f,{variant:`pill`,face:t,retry:i,describedBy:u})]})}),o(p,{face:t})]})}export{c as COPY,m as ElementDefault,f as RetryButton,p as Status};
@@ -0,0 +1 @@
1
+ "use client";import{ELEMENT_CLASS as e,ELEMENT_DEFAULT_GEOMETRY as t,ensureElementStyles as n}from"./elementDefaultStyles.js";import{PayElementThemeContext as r}from"../provider/elementContext.js";import{ElementDefault as i}from"./ElementDefault.js";import{ElementLanesFailure as a,ElementSkeleton as o}from"./ElementLanes.js";import{useElementSwap as s}from"./elementSwap.js";import{presentElement as c}from"./presentElement.js";import{use as l,useLayoutEffect as u,useRef as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";const m=Object.freeze({position:`absolute`,insetInline:0,insetBlockStart:0,visibility:`hidden`,pointerEvents:`none`}),h=Object.freeze({minBlockSize:`${t.lanes.blockSize}px`});function g(e){return e.status===`failed`&&e.by===`hub`?e.reason:`unreachable`}function _(e,t,n){return typeof e==`function`?e({retry:n,reason:g(t)}):e}function v({element:t,shape:g,loading:v,fallback:y,className:b,style:x}){let S=l(r),C=d(null),w=d(null),T=d(!1),{hostRef:E,load:D,retry:O,focus:k}=t,A=g===`lanes`,j=c(D,{hasLoading:v!==void 0,hasFallback:y!==void 0,lanes:A}),M=s(j,A),N=M.phase===`wait`||M.phase===`skeleton`,P=M.phase===`swap`,F=j.overlay;N?F=`skeleton`:P&&(F=M.leaving);let I=N||!P&&j.frame===`hidden`;u(()=>{let e=C.current;e!==null&&n(e.ownerDocument)},[]),u(()=>{if(I||!T.current)return;T.current=!1;let e=C.current?.ownerDocument.activeElement??null;(e===null||e===e.ownerDocument.body||(w.current?.contains(e)??!1))&&k()},[I,k]);let L=null;return F===`loading`?L=v:F===`fallback`&&y!==void 0?L=_(y,D,O):F===`skeleton`?L=M.phase===`wait`?null:f(o,{theme:S}):(F===`failed`||F===`connecting`)&&A?L=f(a,{face:F,theme:S,retry:O}):(F===`failed`||F===`connecting`)&&(L=f(i,{face:F,theme:S,retry:O})),p(`div`,{ref:C,"data-stridge-pay-element":``,"data-shape":g,"data-view":P?`frame`:F??`frame`,"aria-busy":D.status===`loading`||N?!0:void 0,className:b===void 0?e:`${e} ${b}`,style:x,children:[f(`div`,{ref:E,className:`${e}__frame`,"data-entering":P?``:void 0,inert:I,style:I?m:void 0}),F===null?null:f(`div`,{ref:w,className:`${e}__overlay`,"data-leaving":P?``:void 0,"aria-hidden":P||F===`skeleton`?!0:void 0,inert:P||F===`skeleton`,style:M.phase===`wait`?h:void 0,onFocus:()=>{T.current=!0},onBlur:e=>{let t=e.relatedTarget;t!==null&&!e.currentTarget.contains(t)&&(T.current=!1)},children:L})]})}export{v as ElementHost};
@@ -0,0 +1 @@
1
+ "use client";import{DEFAULT_CLASS as e,ELEMENT_DEFAULT_GEOMETRY as t,LOCKUP_WIDTH as n}from"./elementDefaultStyles.js";import{COPY as r,RetryButton as i,Status as a}from"./ElementDefault.js";import{STRIDGE_LOCKUP as o}from"./stridgeLockup.js";import{useId as s}from"react";import"@stridge/pay-sdk";import{Fragment as c,jsx as l,jsxs as u}from"react/jsx-runtime";function d({face:t,theme:n,children:r}){return l(`div`,{className:`${e} ${e}--lanes`,"data-theme":n,"data-face":t,children:l(`div`,{className:`${e}__lanes`,children:r})})}function f(){return u(`svg`,{role:`img`,"aria-label":`Stridge`,focusable:`false`,width:n,height:t.lockup.height,viewBox:o.viewBox,children:[l(`path`,{d:o.mark}),l(`path`,{d:o.word})]})}function p({part:t}){return l(`span`,{className:`${e}__bar ${e}__bar--${t}`})}function m({theme:t}){return u(d,{face:`skeleton`,theme:t,children:[u(`div`,{className:`${e}__header`,children:[l(`span`,{className:`${e}__brand`,children:l(f,{})}),l(`span`,{className:`${e}__end`,children:l(p,{part:`end`})})]}),u(`div`,{className:`${e}__row`,children:[u(`span`,{className:`${e}__row-text`,children:[l(`span`,{className:`${e}__row-title`,children:l(p,{part:`title`})}),l(`span`,{className:`${e}__row-subline`,children:l(p,{part:`subline`})})]}),l(p,{part:`tile`})]}),l(p,{part:`action`})]})}function h({face:t,theme:n,retry:o}){let p=s(),m=r[t];return u(c,{children:[u(d,{face:t,theme:n,children:[l(`div`,{className:`${e}__header`,children:l(`span`,{className:`${e}__brand`,children:l(f,{})})}),l(`div`,{className:`${e}__row`,children:u(`span`,{className:`${e}__row-text`,children:[l(`span`,{id:p,className:`${e}__row-title`,children:m.title}),l(`span`,{className:`${e}__row-subline`,children:m.description})]})}),l(i,{variant:`action`,face:t,retry:o,describedBy:p})]}),l(a,{face:t})]})}export{h as ElementLanesFailure,m as ElementSkeleton};
@@ -0,0 +1,13 @@
1
+ import { PayElementProps } from "./types.js";
2
+ import { ReactElement } from "react";
3
+ //#region src/react/PayElement.d.ts
4
+ /**
5
+ * Frames the hub-owned card for one payment. A Pay and a Deposit load into the same 184 px card, so both take the Pay
6
+ * card's lanes shape: its skeleton holds the 184 px from the first frame.
7
+ */
8
+ declare function PayElement(props: PayElementProps): ReactElement;
9
+ declare namespace PayElement {
10
+ var displayName: string;
11
+ }
12
+ //#endregion
13
+ export { PayElement };
@@ -0,0 +1 @@
1
+ "use client";import{compilePayRequest as e}from"./compilePayRequest.js";import{ElementHost as t}from"./ElementHost.js";import{payEventCallbacks as n}from"./payEvents.js";import{useElementHandle as r}from"./useElementHandle.js";import{useMemo as i}from"react";import{jsx as a}from"react/jsx-runtime";function o(o){let{loading:s,fallback:c,className:l,style:u,...d}=o,f=e(d),{onEvent:p}=d;return a(t,{element:r(`PayElement`,f,i(()=>n(p),[p])),shape:`lanes`,loading:s,fallback:c,className:l,style:u})}o.displayName=`PayElement`;export{o as PayElement};
@@ -0,0 +1 @@
1
+ function e(e,t){let n=e,r=t,i=Object.keys(n).filter(e=>n[e]!==void 0),a=Object.keys(r).filter(e=>r[e]!==void 0);return i.length===a.length&&i.every(e=>n[e]===r[e])}function t(e,t){return e===null||t===null?e===t:e.attemptId===t.attemptId&&e.message===t.message&&e.label===t.label}function n(n,r){return e(n.labels,r.labels)?n.showBalance===r.showBalance&&t(n.action,r.action):!1}export{n as elementConfigsEqual};
@@ -0,0 +1 @@
1
+ import{isElementDepositRequestPayload as e,isElementPayRequestPayload as t,samePayDestinationAsk as n,samePayTerms as r}from"@stridge/pay-sdk";const i=new Set([`referenceId`,`mode`,`amount`,`min`,`max`,`firstStep`,`description`,`destination`,`onEvent`]);function a(n){for(let e of Object.keys(n))if(!i.has(e))throw TypeError(`PayElement does not take the prop "${e}"`);if(n.onEvent!==void 0&&typeof n.onEvent!=`function`)throw TypeError(`PayElement onEvent must be a function`);if(n.mode!==void 0&&n.mode!==`payment`&&n.mode!==`deposit`)throw TypeError(`PayElement mode must be "payment" or "deposit"`);if(n.description!==void 0&&typeof n.description!=`string`)throw TypeError(`PayElement description must be a string`);let r={paymentId:n.referenceId,currency:`USD`,item:n.description===void 0?null:n.description.trim(),...n.destination===void 0?{}:{destination:o(n.destination)}};if(n.amount===void 0){if(n.mode!==`deposit`)throw TypeError(`PayElement amount is required unless mode is "deposit"`);if(n.firstStep!==void 0&&n.firstStep!==`amount`&&n.firstStep!==`method`)throw TypeError(`PayElement firstStep must be "amount" or "method"`);let t={...r,...n.min===void 0?{}:{min:n.min},...n.max===void 0?{}:{max:n.max},...n.firstStep===`method`?{firstStep:n.firstStep}:{}};if(!e({...t,revision:1}))throw TypeError(`PayElement referenceId, min, max, description or destination is invalid`);return Object.freeze(t)}if(n.min!==void 0||n.max!==void 0)throw TypeError(`PayElement min and max apply only to a deposit with no amount`);if(n.firstStep!==void 0)throw TypeError(`PayElement firstStep applies only to a deposit with no amount`);let a={...r,job:n.mode===`deposit`?`deposit`:`pay`,amount:n.amount};if(!t({...a,revision:1}))throw TypeError(`PayElement referenceId, amount, description or destination is invalid`);return Object.freeze(a)}function o(e){return typeof e!=`object`||!e||Array.isArray(e)?e:Object.freeze({...e})}function s(e,t){return r(e,t)&&n(e,t)&&c(e)===c(t)}function c(e){return`firstStep`in e?e.firstStep:void 0}export{a as compilePayRequest,s as payRequestsEqual};
@@ -0,0 +1,15 @@
1
+ //#region src/react/elementDefaultStyles.d.ts
2
+ /**
3
+ * The stylesheet, built once from the copied values above. The outer node's layout sits in `:where()`, so an app's
4
+ * own class on it wins; the default views' rules use one kit class each, so they win over the app's element rules.
5
+ *
6
+ * The Pay card (`data-shape="lanes"`) reserves its 184 px; every other element its 62 px bar. In the swap the frame
7
+ * host fades in over the leaving view: opacity and a 0.99 scale from its top, no blur. The leaving view keeps its ink
8
+ * surface and fades and blurs only its lanes. It leaves the flow and is clipped to the box, so the box takes the
9
+ * frame's height in the swap's first frame: a face of another height changes it once, there. The frame already has
10
+ * its view's own height then, because the element counts a view as shown only after the size posted before it
11
+ * (`createElementHandle`). Under reduced motion nothing fades, blurs, scales or sweeps.
12
+ */
13
+ declare const ELEMENT_STYLES: string;
14
+ //#endregion
15
+ export { ELEMENT_STYLES };
@@ -0,0 +1,69 @@
1
+ const e=Object.freeze({surface:{token:`--stridge-sua-ink-surface`,light:`oklch(20.37% 0.011 260.67)`,dark:`oklch(20.37% 0.011 260.67)`},surfaceRaised:{token:`--stridge-sua-ink-surface-raised`,light:`oklch(25.51% 0.014 261.67)`,dark:`oklch(25.51% 0.014 261.67)`},skeleton:{token:`--stridge-sua-ink-skeleton`,light:`oklch(32.83% 0.015 264.34)`,dark:`oklch(32.83% 0.015 264.34)`},skeletonHighlight:{token:`--stridge-sua-ink-control-active`,light:`oklch(36.65% 0.017 262.28)`,dark:`oklch(36.65% 0.017 262.28)`},foreground:{token:`--stridge-sua-ink-foreground`,light:`oklch(97% 0.003 264.54)`,dark:`oklch(97% 0.003 264.54)`},mutedForeground:{token:`--stridge-sua-ink-muted-foreground`,light:`oklch(73.35% 0.017 262.73)`,dark:`oklch(73.35% 0.017 262.73)`},action:{token:`--stridge-sua-ink-action`,light:`oklch(97% 0.003 264.54)`,dark:`oklch(97% 0.003 264.54)`},actionForeground:{token:`--stridge-sua-ink-action-foreground`,light:`oklch(20.37% 0.011 260.67)`,dark:`oklch(20.37% 0.011 260.67)`},border:{token:`--stridge-sua-ink-border`,light:`transparent`,dark:`oklch(30.94% 0.012 243.23)`},shadow:{token:`--stridge-sua-ink-shadow`,light:`0 1px 2px oklch(20.37% 0.011 260.67 / 0.12), 0 8px 24px oklch(20.37% 0.011 260.67 / 0.14)`,dark:`0 1px 2px oklch(0% 0 0 / 0.4), 0 8px 24px oklch(0% 0 0 / 0.32)`},ring:{token:`--stridge-sua-ink-ring`,light:`oklch(97% 0.003 264.54 / 0.9)`,dark:`oklch(97% 0.003 264.54 / 0.9)`},actionRing:{token:`--stridge-sua-ink-action-ring`,light:`oklch(20.37% 0.011 260.67 / 0.9)`,dark:`oklch(20.37% 0.011 260.67 / 0.9)`},brandWhite:{token:`--stridge-sua-brand-white`,light:`#fafafa`,dark:`#fafafa`}}),t=Object.freeze({fontSans:{token:`--stridge-sua-font-sans`,value:`ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"`},textMeta:{token:`--stridge-sua-text-meta`,value:`13px`},textCallout:{token:`--stridge-sua-text-callout`,value:`15px`},weightMedium:{token:`--stridge-sua-font-weight-medium`,value:`500`},weightSemibold:{token:`--stridge-sua-font-weight-semibold`,value:`600`},trackingTight:{token:`--stridge-sua-tracking-tight`,value:`-0.01em`},space2:{token:`--stridge-sua-space-2`,value:`8px`},space3:{token:`--stridge-sua-space-3`,value:`12px`},space4:{token:`--stridge-sua-space-4`,value:`16px`},inkRadius:{token:`--stridge-sua-ink-radius`,value:`14px`},buttonRadius:{token:`--stridge-sua-button-radius`,value:`10px`},cardRadius:{token:`--stridge-sua-card-radius`,value:`12px`},actionHeight:{token:`--stridge-sua-ink-action-height`,value:`48px`},actionDisabledOpacity:{token:`--stridge-sua-action-disabled-opacity`,value:`0.6`},ringWidth:{token:`--stridge-sua-ring-width`,value:`3px`},radiusFull:{token:`--stridge-sua-radius-full`,value:`9999px`},durationFast:{token:`--stridge-sua-duration-fast`,value:`150ms`},easeOut:{token:`--stridge-sua-ease-out`,value:`cubic-bezier(0, 0, 0.2, 1)`},swapDuration:{token:`--stridge-sua-swap-duration`,value:`650ms`},easeSwap:{token:`--stridge-sua-ease-swap`,value:`linear( 0, 0.0141, 0.0494, 0.0976, 0.1529, 0.2114, 0.2705, 0.3284, 0.384, 0.4366, 0.4859 15.38%, 0.5938, 0.6811, 0.7505, 0.8052, 0.8481, 0.8816, 0.9077, 0.9281 46.15%, 0.9564, 0.9735, 0.984, 0.9903, 0.9941, 0.9964, 1 )`}}),n=Object.freeze({card:{blockSize:62,border:1,paddingBlock:8,paddingInline:7,lineMinBlockSize:44,lineGap:12,linePaddingStart:14,linePaddingEnd:7,markSlot:24,markSlotOffset:10,mark:20,textGap:2,titleLineHeight:22,descriptionLineHeight:18,pillBlockSize:32,pillPaddingInline:14},lanes:{blockSize:184,border:1,padding:7,gap:8,headerBlockSize:44,headerPaddingInline:8,headerGap:12,endBlockSize:28,endPaddingInline:10,rowBlockSize:60,rowGap:12,textGap:2,titleLineHeight:18,sublineLineHeight:16,tile:24,tileRadius:7},skeleton:{end:{inline:44,block:10},title:{inline:136,block:12},subline:{inline:104,block:10},band:140,cycleMs:2e3},lockup:{height:24,viewWidth:8438,viewHeight:2246},pill:{lineHeight:18,hoverRing:3,hoverRingPercent:18,pressScale:.96,hitOutset:4,focusOutline:3},spinner:{size:16,actionSize:20,stroke:2,trackPercent:20,turnMs:900},status:{size:1},leave:{blur:3}}),r=Object.freeze({delay:300,minimum:200,swap:650}),i=Math.round(n.lockup.height*n.lockup.viewWidth/n.lockup.viewHeight*100)/100,a=`stridge-pay-element`,o=`stridge-pay-element-default`,s=`data-stridge-pay-element-styles`,c=e,l=t,u=n,d=o;function f(e){return Object.entries(c).map(([t,n])=>`--${a}-${t}: ${n[e]};`).join(` `)}function p(e){return`var(--${a}-${e})`}const m=n.lanes,h=n.skeleton,g=a,_=`--${g}-sweep-offset`,v=`
2
+ :where(.${g}) { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); }
3
+ :where(.${g}[data-stridge-pay-element]:not([data-view="frame"])) { min-block-size: ${u.card.blockSize}px; }
4
+ :where(.${g}[data-shape="lanes"]:not([data-view="frame"])) { min-block-size: ${m.blockSize}px; }
5
+ .${g}__frame, .${g}__overlay { grid-area: 1 / 1; min-inline-size: 0; }
6
+ .${g}__overlay { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; }
7
+ .${g}__overlay[data-leaving] { position: absolute; inset: 0; overflow: clip; pointer-events: none; }
8
+ .${g}__overlay[data-leaving] .${d}__lanes { animation: ${g}-lanes-out ${l.swapDuration.value} ${l.easeSwap.value} forwards; }
9
+ .${g}__frame[data-entering] { position: relative; z-index: 1; transform-origin: top; animation: ${g}-frame-in ${l.swapDuration.value} ${l.easeSwap.value} both; }
10
+ .${d} { box-sizing: border-box; margin: 0; color: ${p(`foreground`)}; font-family: ${l.fontSans.value}; font-size: ${l.textMeta.value}; font-weight: 400; line-height: ${u.pill.lineHeight}px; letter-spacing: normal; text-align: start; text-transform: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
11
+ .${d} *, .${d} *::before, .${d} *::after { box-sizing: border-box; }
12
+ .${d}[data-theme="light"] { ${f(`light`)} }
13
+ .${d}[data-theme="dark"] { ${f(`dark`)} }
14
+ .${d}--card { border: ${u.card.border}px solid ${p(`border`)}; background-color: ${p(`surface`)}; box-shadow: ${p(`shadow`)}; }
15
+ .${d}--card { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 1fr; inline-size: 100%; padding-block: ${u.card.paddingBlock}px; padding-inline: ${u.card.paddingInline}px; border-radius: ${l.inkRadius.value}; }
16
+ .${d}__line { display: flex; align-items: center; gap: ${u.card.lineGap}px; min-inline-size: 0; min-block-size: ${u.card.lineMinBlockSize}px; padding-inline-start: ${u.card.linePaddingStart}px; padding-inline-end: ${u.card.linePaddingEnd}px; }
17
+ .${d}__mark { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
18
+ .${d}__mark svg { display: block; fill: ${p(`brandWhite`)}; }
19
+ .${d}--card .${d}__mark { align-self: flex-start; inline-size: ${u.card.markSlot}px; block-size: ${u.card.markSlot}px; margin-block-start: ${u.card.markSlotOffset}px; }
20
+ .${d}--card .${d}__mark svg { inline-size: ${u.card.mark}px; block-size: ${u.card.mark}px; }
21
+ .${d}__text { display: flex; flex-direction: column; gap: ${u.card.textGap}px; flex-grow: 1; min-inline-size: 0; }
22
+ .${d}__title { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: ${p(`foreground`)}; font-size: ${l.textCallout.value}; font-weight: ${l.weightSemibold.value}; letter-spacing: ${l.trackingTight.value}; line-height: ${u.card.titleLineHeight}px; }
23
+ .${d}__description { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: ${p(`mutedForeground`)}; font-size: ${l.textMeta.value}; line-height: ${u.card.descriptionLineHeight}px; }
24
+ .${d}__retry, .${d}__action { appearance: none; position: relative; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; margin: 0; padding-block: 0; border: 0; background-color: ${p(`action`)}; color: ${p(`actionForeground`)}; font-family: ${l.fontSans.value}; font-weight: ${l.weightSemibold.value}; line-height: ${u.pill.lineHeight}px; letter-spacing: normal; text-transform: none; white-space: nowrap; cursor: pointer; outline: none; transition-duration: ${l.durationFast.value}; transition-timing-function: ${l.easeOut.value}; }
25
+ .${d}__retry { border-radius: ${l.radiusFull.value}; font-size: ${l.textMeta.value}; transition-property: transform, box-shadow, opacity; }
26
+ .${d}__retry::before { content: ""; position: absolute; inset-inline: 0; inset-block: -${u.pill.hitOutset}px; }
27
+ @media (hover: hover) { .${d}__retry:hover:not([aria-disabled="true"]) { box-shadow: 0 0 0 ${u.pill.hoverRing}px color-mix(in oklab, ${p(`action`)} ${u.pill.hoverRingPercent}%, transparent); } }
28
+ .${d}__retry:active:not([aria-disabled="true"]), .${d}__action:active:not([aria-disabled="true"]) { transform: scale(${u.pill.pressScale}); }
29
+ .${d}__retry:focus-visible { box-shadow: 0 0 0 var(--stridge-pay-ring-width, ${u.pill.focusOutline}px) color-mix(in oklab, ${p(`ring`)} 50%, transparent); }
30
+ .${d}__retry[aria-disabled="true"], .${d}__action[aria-disabled="true"] { cursor: not-allowed; opacity: ${l.actionDisabledOpacity.value}; }
31
+ .${d}--card .${d}__retry { block-size: ${u.card.pillBlockSize}px; padding-inline: ${u.card.pillPaddingInline}px; }
32
+ .${d}__retry[aria-busy="true"] .${d}__retry-label, .${d}__action[aria-busy="true"] .${d}__retry-label { opacity: 0; }
33
+ .${d}__spinner { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
34
+ .${d}__spinner svg { display: block; animation: ${g}-spin ${u.spinner.turnMs}ms linear infinite; }
35
+ .${d}__spinner-track { stroke: color-mix(in oklab, ${p(`actionForeground`)} ${u.spinner.trackPercent}%, transparent); }
36
+ .${d}__spinner-arc { stroke: ${p(`actionForeground`)}; }
37
+ .${d}__status { position: absolute; inline-size: ${u.status.size}px; block-size: ${u.status.size}px; margin: -${u.status.size}px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
38
+ .${d}--lanes { display: flex; flex-direction: column; inline-size: 100%; padding: ${m.padding}px; border: ${m.border}px solid ${p(`border`)}; border-radius: ${l.inkRadius.value}; background-color: ${p(`surface`)}; container-type: inline-size; }
39
+ .${d}--lanes[data-face="skeleton"] { animation: ${g}-fade-in ${l.swapDuration.value} ${l.easeSwap.value} both; }
40
+ .${d}__lanes { display: flex; flex-direction: column; gap: ${m.gap}px; min-inline-size: 0; }
41
+ .${d}__header { display: flex; align-items: center; gap: ${m.headerGap}px; block-size: ${m.headerBlockSize}px; padding-inline: ${m.headerPaddingInline}px; }
42
+ .${d}__brand { display: flex; align-items: center; flex-grow: 1; min-inline-size: 0; }
43
+ .${d}__brand svg { display: block; flex-shrink: 0; fill: ${p(`brandWhite`)}; }
44
+ .${d}__end { display: flex; align-items: center; flex-shrink: 0; block-size: ${m.endBlockSize}px; padding-inline: ${m.endPaddingInline}px; }
45
+ .${d}__row { display: flex; align-items: center; gap: ${m.rowGap}px; min-block-size: ${m.rowBlockSize}px; padding-inline: ${l.space4.value}; border-radius: ${l.cardRadius.value}; background-color: ${p(`surfaceRaised`)}; }
46
+ .${d}__row-text { display: flex; flex-direction: column; gap: ${m.textGap}px; flex-grow: 1; min-inline-size: 0; }
47
+ .${d}__row-title { block-size: ${m.titleLineHeight}px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: ${p(`foreground`)}; font-size: ${l.textCallout.value}; font-weight: ${l.weightMedium.value}; line-height: ${m.titleLineHeight}px; }
48
+ .${d}__row-subline { block-size: ${m.sublineLineHeight}px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: ${p(`mutedForeground`)}; font-size: ${l.textMeta.value}; line-height: ${m.sublineLineHeight}px; }
49
+ .${d}__action { display: flex; inline-size: 100%; block-size: ${l.actionHeight.value}; padding-inline: ${l.space4.value}; border-radius: ${l.buttonRadius.value}; font-size: ${l.textCallout.value}; transition-property: transform, background-color, opacity; }
50
+ @media (hover: hover) { .${d}__action:hover:not([aria-disabled="true"]) { background-color: color-mix(in oklab, ${p(`action`)} 88%, ${p(`surface`)}); } }
51
+ .${d}__action:focus-visible { box-shadow: inset 0 0 0 ${l.ringWidth.value} color-mix(in oklab, ${p(`actionRing`)} 50%, transparent); }
52
+ .${d}__bar { display: block; flex-shrink: 0; border-radius: ${l.radiusFull.value}; background-color: ${p(`skeleton`)}; background-image: linear-gradient(in oklab 90deg, transparent 0%, ${p(`skeletonHighlight`)} 50%, transparent 100%); background-size: ${h.band}px 100%; background-repeat: no-repeat; background-position-x: calc(-${h.band}px - var(${_}, 0px)); animation: ${g}-sweep ${h.cycleMs}ms ease-in-out infinite; }
53
+ .${d}__bar--end { inline-size: ${h.end.inline}px; block-size: ${h.end.block}px; ${_}: calc(100cqi - ${m.headerPaddingInline+m.endPaddingInline+h.end.inline}px); }
54
+ .${d}__bar--title { inline-size: ${h.title.inline}px; block-size: ${h.title.block}px; margin-block: ${(m.titleLineHeight-h.title.block)/2}px; ${_}: ${l.space4.value}; }
55
+ .${d}__bar--subline { inline-size: ${h.subline.inline}px; block-size: ${h.subline.block}px; margin-block: ${(m.sublineLineHeight-h.subline.block)/2}px; ${_}: ${l.space4.value}; }
56
+ .${d}__bar--tile { inline-size: ${m.tile}px; block-size: ${m.tile}px; border-radius: ${m.tileRadius}px; ${_}: calc(100cqi - ${l.space4.value} - ${m.tile}px); }
57
+ .${d}__bar--action { inline-size: 100%; block-size: ${l.actionHeight.value}; border-radius: ${l.buttonRadius.value}; }
58
+ @keyframes ${g}-spin { to { transform: rotate(360deg); } }
59
+ @keyframes ${g}-fade-in { from { opacity: 0; } to { opacity: 1; } }
60
+ @keyframes ${g}-lanes-out { from { opacity: 1; filter: blur(0); } to { opacity: 0; filter: blur(${u.leave.blur}px); } }
61
+ @keyframes ${g}-frame-in { from { opacity: 0; transform: scale(0.99); } to { opacity: 1; transform: none; } }
62
+ @keyframes ${g}-sweep { 0% { background-position-x: calc(-${h.band}px - var(${_}, 0px)); } 80%, 100% { background-position-x: calc(100cqi - var(${_}, 0px)); } }
63
+ @media (prefers-reduced-motion: reduce) {
64
+ .${d}__retry, .${d}__action { transition-duration: 0ms; }
65
+ .${d}__spinner svg { animation-play-state: paused; }
66
+ .${d}--lanes[data-face="skeleton"], .${d}__bar, .${g}__frame[data-entering], .${g}__overlay[data-leaving] .${d}__lanes { animation: none; }
67
+ .${d}__bar { background-image: none; }
68
+ }
69
+ `;function y(e){if(e.querySelector(`style[data-stridge-pay-element-styles]`)!==null)return;let t=e.createElement(`style`);t.setAttribute(s,``),t.textContent=v,(e.head??e.documentElement).append(t)}export{o as DEFAULT_CLASS,a as ELEMENT_CLASS,e as ELEMENT_DEFAULT_COLORS,n as ELEMENT_DEFAULT_GEOMETRY,t as ELEMENT_DEFAULT_TOKENS,v as ELEMENT_STYLES,s as ELEMENT_STYLES_MARKER,r as ELEMENT_SWAP_TIMING,i as LOCKUP_WIDTH,y as ensureElementStyles};
@@ -0,0 +1 @@
1
+ "use client";import{ELEMENT_SWAP_TIMING as e}from"./elementDefaultStyles.js";import{useLayoutEffect as t,useState as n}from"react";function r(e,t,n,r){let i=t.overlay;if(i===`skeleton`)return e.phase===`wait`||e.phase===`skeleton`?e:{phase:`wait`,since:r};if(i===null){if(e.phase===`skeleton`||e.phase===`swap`)return e;if(e.phase===`idle`&&n&&e.shown===`connecting`)return{phase:`swap`,since:r,leaving:`connecting`}}return e.phase===`idle`&&e.shown===i?e:{phase:`idle`,shown:i}}function i(t,n){return t.phase===`wait`?{at:t.since+e.delay,next:e=>({phase:`skeleton`,since:e})}:t.phase===`skeleton`&&n?{at:t.since+e.minimum,next:e=>({phase:`swap`,since:e,leaving:`skeleton`})}:t.phase===`swap`?{at:t.since+e.swap,next:()=>({phase:`idle`,shown:null})}:null}function a(e,a){let[o,s]=n(()=>r({phase:`idle`,shown:null},e,a,Date.now())),c=r(o,e,a,Date.now());c!==o&&s(c);let l=e.overlay===null;return t(()=>{let e=i(c,l);if(e===null)return;let t=setTimeout(()=>s(t=>t===c?e.next(Date.now()):t),Math.max(0,e.at-Date.now()));return()=>clearTimeout(t)},[c,l]),c}export{r as stepSwap,i as timedSwap,a as useElementSwap};
@@ -0,0 +1,139 @@
1
+ import { PayError } from "../errors/PayError.js";
2
+ import "../core/elementClientTypes.js";
3
+ import "@stridge/pay-sdk";
4
+ //#region src/react/payEvents.d.ts
5
+ /**
6
+ * `payment.observed`: the hub observed a delivery for this payment, on a request with the same mode and amount. It is
7
+ * what this browser saw, never proof of payment: check the payment on your own server before you ship the order. It
8
+ * fires once for each payment while the page stays alive, and can fire again after a reload, so handle it once for each
9
+ * `referenceId`.
10
+ */
11
+ interface PaymentObservedEvent {
12
+ readonly type: "payment.observed";
13
+ /**
14
+ * Your own id for the payment, as the request gave it.
15
+ */
16
+ readonly referenceId: string;
17
+ /**
18
+ * The mode of the request the delivery answered.
19
+ */
20
+ readonly mode: "payment" | "deposit";
21
+ /**
22
+ * The request's amount in USD, as a decimal string ("24.00"). The amount the person chose for a Deposit with no
23
+ * fixed amount.
24
+ */
25
+ readonly amount: string;
26
+ /**
27
+ * How the person paid: an outside `wallet`, `cash` (card or bank), `account` (the Stridge Wallet) or `transfer` (a
28
+ * deposit address made for this one order).
29
+ */
30
+ readonly method: "wallet" | "cash" | "account" | "transfer";
31
+ /**
32
+ * The short code the person's receipt shows ("7Q2-K9F"): 1 to 32 characters of `[0-9A-Z-]`.
33
+ */
34
+ readonly receiptCode: string;
35
+ /**
36
+ * The delivery's transaction hash on the payout network, when one is known, else `null`.
37
+ */
38
+ readonly transactionHash: `0x${string}` | null;
39
+ /**
40
+ * What was delivered, as reported: the amount in the coin's base units as a decimal integer string, the coin's
41
+ * symbol, and the network id. Fees can make it less than the price.
42
+ */
43
+ readonly received: {
44
+ readonly amountBaseUnits: string;
45
+ readonly assetSymbol: string;
46
+ readonly networkId: string;
47
+ };
48
+ /**
49
+ * `true` when less than the payment's target arrived. A short delivery does not pay the order.
50
+ */
51
+ readonly short: boolean;
52
+ }
53
+ /**
54
+ * `checkout.closed`: the backend's checkout for this payment reached a final state. It is about the Coordinator's
55
+ * checkout (the route that pays your destination), not about the pay window, which can stay open or close on its own.
56
+ * It is never proof of payment: check the destination transactions on your own server. One payment can get more than
57
+ * one checkout; each `(referenceId, checkoutId, state)` fires once while the page stays alive, and again after a reload.
58
+ */
59
+ interface PayCheckoutClosedEvent {
60
+ readonly type: "checkout.closed";
61
+ /**
62
+ * Your own id for the payment, as the request gave it.
63
+ */
64
+ readonly referenceId: string;
65
+ /**
66
+ * The backend's id for this checkout: an opaque string. Never parse it.
67
+ */
68
+ readonly checkoutId: string;
69
+ /**
70
+ * The checkout's final state. `completed` can still be short: compare `deliveredBaseUnits` with
71
+ * `approvedBaseUnits`.
72
+ */
73
+ readonly state: "completed" | "failed" | "canceled" | "expired";
74
+ /**
75
+ * The approved amount, in the destination coin's base units, as a decimal integer string.
76
+ */
77
+ readonly approvedBaseUnits: string;
78
+ /**
79
+ * The delivered amount, in the destination coin's base units, as a decimal integer string. It can be less than
80
+ * `approvedBaseUnits`.
81
+ */
82
+ readonly deliveredBaseUnits: string;
83
+ /**
84
+ * The checkout's destination transactions, each one once. It can be empty, even when `state` is `completed`.
85
+ */
86
+ readonly destinationTxs: readonly string[];
87
+ }
88
+ /**
89
+ * `payment.on_hold`: the payment needs support and stays locked. Do not use its `referenceId` again: start a new order
90
+ * with a new `referenceId`.
91
+ */
92
+ interface PaymentOnHoldEvent {
93
+ readonly type: "payment.on_hold";
94
+ /**
95
+ * Your own id for the payment, as the request gave it.
96
+ */
97
+ readonly referenceId: string;
98
+ /**
99
+ * The short code the person's receipt shows, for support.
100
+ */
101
+ readonly receiptCode: string;
102
+ }
103
+ /**
104
+ * `payment.unconfirmed`: the wallet may have sent, and the hub cannot confirm it yet. Never retry this `referenceId`: a
105
+ * new order needs a new `referenceId`, and you check this one on your own server.
106
+ */
107
+ interface PaymentUnconfirmedEvent {
108
+ readonly type: "payment.unconfirmed";
109
+ /**
110
+ * Your own id for the payment, as the request gave it.
111
+ */
112
+ readonly referenceId: string;
113
+ /**
114
+ * The short code the person's receipt shows, for support.
115
+ */
116
+ readonly receiptCode: string;
117
+ }
118
+ /**
119
+ * `request.failed`: a request the element ran for the person failed. Today the element reports a failed sign-in and a
120
+ * failed fund request. It says nothing about the payment.
121
+ */
122
+ interface PayRequestFailedEvent {
123
+ readonly type: "request.failed";
124
+ /**
125
+ * The request that failed.
126
+ */
127
+ readonly request: "sign-in" | "sign-out" | "disconnect" | "fund" | "pay";
128
+ /**
129
+ * Why it failed: read its `code`; its `message` is the description.
130
+ */
131
+ readonly error: PayError;
132
+ }
133
+ /**
134
+ * One event of the pay element, as `onEvent` receives it. Narrow on `type`. No event proves that money arrived: your
135
+ * own server checks the payment before you ship the order.
136
+ */
137
+ type PayEvent = PaymentObservedEvent | PayCheckoutClosedEvent | PaymentOnHoldEvent | PaymentUnconfirmedEvent | PayRequestFailedEvent;
138
+ //#endregion
139
+ export { PayCheckoutClosedEvent, PayEvent, PayRequestFailedEvent, PaymentObservedEvent, PaymentOnHoldEvent, PaymentUnconfirmedEvent };
@@ -0,0 +1 @@
1
+ function e(e){return Object.freeze({type:`payment.observed`,referenceId:e.paymentId,mode:e.job===`deposit`?`deposit`:`payment`,amount:e.amount,method:e.method,receiptCode:e.reference,transactionHash:e.transactionHash,received:Object.freeze({amountBaseUnits:e.received.amountBaseUnits,assetSymbol:e.received.assetSymbol,networkId:e.received.networkId}),short:e.outcome===`short`})}function t(e){return Object.freeze({type:`checkout.closed`,referenceId:e.paymentId,checkoutId:e.id,state:e.state,approvedBaseUnits:e.amount,deliveredBaseUnits:e.delivered,destinationTxs:Object.freeze([...e.destinationTxs])})}function n(e,t){return Object.freeze({type:e,referenceId:t.paymentId,receiptCode:t.reference})}function r(e){return e.request===`sign`?null:Object.freeze({type:`request.failed`,request:e.request,error:e.error})}function i(i){return i===void 0?{}:Object.freeze({onPaid:t=>i(e(t)),onCheckoutResult:e=>i(t(e)),onHeld:e=>i(n(`payment.on_hold`,e)),onUnconfirmed:e=>i(n(`payment.unconfirmed`,e)),onFailed:e=>{let t=r(e);t!==null&&i(t)}})}export{t as checkoutClosed,i as payEventCallbacks,n as paymentNotice,e as paymentObserved,r as requestFailed};
@@ -0,0 +1 @@
1
+ const e=Object.freeze({frame:`visible`,overlay:null}),t=Object.freeze({loading:Object.freeze({frame:`hidden`,overlay:`loading`}),fallback:Object.freeze({frame:`hidden`,overlay:`fallback`}),failed:Object.freeze({frame:`hidden`,overlay:`failed`}),connecting:Object.freeze({frame:`hidden`,overlay:`connecting`}),skeleton:Object.freeze({frame:`hidden`,overlay:`skeleton`})});function n(n,{hasLoading:r,hasFallback:i,lanes:a}){switch(n.status){case`shown`:return e;case`loading`:return r?t.loading:n.retrying&&!i?t.connecting:a?t.skeleton:e;case`failed`:return i?t.fallback:n.by===`frame`?t.failed:e}}export{n as presentElement};
@@ -0,0 +1 @@
1
+ const e=Object.freeze({viewBox:`0 0 8438 2246`,mark:`M221 712C255 632 303 561 365 499C427 437 498 389 578 355C662 320 749 302 840 302C931 302 1018 320 1102 355C1182 389 1253 437 1315 499C1377 561 1425 632 1459 712C1494 796 1512 883 1512 974C1512 1065 1494 1152 1459 1236C1425 1316 1377 1387 1315 1449C1253 1511 1182 1559 1102 1593C1018 1628 931 1646 840 1646C749 1646 662 1628 578 1593C498 1559 427 1511 365 1449C303 1387 255 1316 221 1236C186 1152 168 1065 168 974C168 883 186 796 221 712ZM1148 566C1118 543 1086 524 1050 508C984 478 914 463 840 463C706 463 593 504 500 586C416 660 365 750 346 857C327 962 345 1052 401 1124C463 1205 559 1245 690 1245C796 1245 885 1207 958 1130C962 1126 965 1123 968 1119C968 1119 969 1118 970 1118C989 1101 1012 1094 1038 1099C1039 1100 1039 1100 1040 1100C1073 1107 1093 1127 1101 1160C1107 1183 1103 1204 1090 1224C1090 1224 1089 1225 1089 1225C1084 1230 1080 1235 1075 1241C1025 1293 968 1333 903 1361C835 1391 764 1406 690 1406C635 1406 582 1398 532 1382C562 1405 594 1424 630 1440C696 1470 766 1485 840 1485C974 1485 1087 1444 1180 1362C1264 1288 1315 1198 1334 1091C1353 986 1335 896 1279 824C1217 743 1121 703 990 703C884 703 795 741 722 818C717 823 714 826 712 829C712 829 711 830 710 830C691 847 668 854 642 849C608 842 587 822 579 788C573 765 577 744 590 724C590 724 591 723 591 722C597 716 601 711 605 707C655 655 712 615 777 587C845 557 916 542 990 542C1045 542 1098 550 1148 566Z`,word:`M6870 2029Q6987 1980 7052 1875Q7118 1770 7118 1602V590H6816V742H6815Q6782 684 6735 645Q6688 607 6630 587Q6572 568 6502 568Q6368 568 6266 637Q6163 707 6106 829Q6048 951 6048 1110Q6048 1266 6105 1387Q6161 1508 6264 1577Q6367 1645 6505 1645Q6574 1645 6633 1626Q6692 1608 6738 1568Q6785 1528 6815 1466H6816V1628Q6816 1740 6759 1798Q6702 1856 6596 1856Q6543 1856 6501 1842Q6459 1827 6431 1800Q6403 1773 6393 1735H6100Q6115 1837 6175 1915Q6234 1992 6339 2035Q6444 2078 6596 2078Q6752 2078 6870 2029ZM5634 736Q5601 679 5555 642Q5509 605 5451 586Q5394 568 5325 568Q5191 568 5088 638Q4986 707 4928 831Q4870 955 4870 1117Q4870 1283 4927 1407Q4984 1531 5087 1600Q5190 1669 5327 1669Q5397 1669 5456 1648Q5516 1628 5562 1587Q5609 1546 5638 1484H5640V1646H5940V302H5636V736H5634ZM3114 1363Q3114 1509 3197 1578Q3281 1646 3459 1646H3635V1408H3520Q3461 1408 3440 1388Q3418 1367 3418 1314V829H3750V1646H4054V1080Q4054 1002 4082 948Q4109 894 4156 866Q4204 839 4264 839Q4302 839 4339 841Q4376 842 4393 844V586Q4375 585 4353 584Q4331 584 4304 584Q4200 584 4138 629Q4076 675 4047 772H4044V590H3418V302H3114V590H2932V829H3114V1363ZM7757 1670Q7886 1670 7993 1625Q8100 1579 8170 1499Q8241 1418 8260 1313H7983Q7970 1353 7940 1382Q7910 1412 7866 1428Q7823 1444 7766 1444Q7689 1444 7634 1411Q7580 1379 7551 1319Q7525 1265 7522 1195H8270V1113Q8270 992 8232 892Q8195 792 8125 719Q8056 646 7960 606Q7864 566 7747 566Q7594 566 7477 637Q7359 708 7292 833Q7226 958 7226 1119Q7226 1279 7291 1404Q7357 1529 7477 1600Q7597 1670 7757 1670ZM2449 993Q2390 980 2356 955Q2323 930 2323 890Q2323 845 2365 814Q2408 783 2482 783Q2558 783 2607 824Q2655 865 2656 927H2938Q2935 816 2876 736Q2818 656 2715 612Q2612 568 2472 568Q2333 568 2232 610Q2130 651 2075 726Q2020 802 2020 903Q2020 1026 2100 1104Q2180 1181 2334 1211L2521 1246Q2585 1259 2620 1284Q2656 1309 2656 1349Q2656 1396 2610 1426Q2565 1456 2485 1456Q2401 1456 2352 1418Q2304 1380 2296 1313H1996Q2005 1426 2070 1506Q2135 1587 2243 1630Q2351 1672 2490 1672Q2630 1672 2737 1628Q2844 1585 2904 1506Q2964 1427 2964 1320Q2964 1204 2888 1133Q2812 1063 2651 1032L2449 993ZM4762 1646V590H4458V1646H4762ZM5206 953Q5235 885 5286 849Q5338 814 5408 814Q5480 814 5535 851Q5589 889 5620 957Q5650 1025 5650 1117Q5650 1209 5620 1278Q5589 1346 5535 1384Q5480 1422 5408 1422Q5338 1422 5286 1386Q5235 1350 5206 1282Q5178 1214 5178 1117Q5178 1020 5206 953ZM6464 1368Q6412 1333 6384 1266Q6356 1200 6356 1106Q6356 1011 6384 945Q6412 878 6464 844Q6516 809 6585 809Q6658 809 6712 845Q6767 882 6797 948Q6827 1015 6827 1106Q6827 1195 6797 1262Q6767 1330 6712 1366Q6658 1403 6585 1403Q6516 1403 6464 1368ZM4486 213Q4437 259 4437 328Q4437 397 4486 443Q4534 489 4609 489Q4684 489 4733 443Q4782 397 4782 328Q4782 259 4733 213Q4684 168 4609 168Q4534 168 4486 213ZM7550 914Q7579 857 7631 827Q7682 797 7754 797Q7826 797 7878 827Q7930 857 7958 914Q7978 953 7984 1003H7524Q7530 953 7550 914Z`});export{e as STRIDGE_LOCKUP};
@@ -0,0 +1,118 @@
1
+ import { PayConnectedEvent } from "../core/elementClientTypes.js";
2
+ import { PayProviderProps } from "../provider/types.js";
3
+ import { PayCheckoutClosedEvent, PayEvent, PayRequestFailedEvent, PaymentObservedEvent, PaymentOnHoldEvent, PaymentUnconfirmedEvent } from "./payEvents.js";
4
+ import { CSSProperties, ReactNode } from "react";
5
+ import { PayElementLoadFailureReason } from "@stridge/pay-sdk";
6
+ //#region src/react/types.d.ts
7
+ /**
8
+ * Why a PayElement shows its `fallback`: the reason Stridge gave for its own load failure (`"hub-frame"`, `"internal"`),
9
+ * or `"unreachable"` when the element's frame never answered.
10
+ */
11
+ type PayElementFallbackReason = PayElementLoadFailureReason | "unreachable";
12
+ /**
13
+ * What a `fallback` function receives.
14
+ */
15
+ interface PayElementFallbackContext {
16
+ /**
17
+ * Loads the PayElement again. It does nothing unless the element failed, so a stale call never reloads a working
18
+ * element.
19
+ */
20
+ readonly retry: () => void;
21
+ /**
22
+ * Why the element failed.
23
+ */
24
+ readonly reason: PayElementFallbackReason;
25
+ }
26
+ /**
27
+ * A PayElement's `fallback`: a node, or a function of the failure's {@link PayElementFallbackContext}.
28
+ */
29
+ type PayElementFallback = ReactNode | ((context: PayElementFallbackContext) => ReactNode);
30
+ /**
31
+ * The page-side presentation every PayElement takes. With none of them, the element shows Stridge's own placeholder from
32
+ * the first paint, Stridge's own failure view when Stridge can see the problem, and a default "Stridge Wallet didn’t
33
+ * load" view with a Try again when its frame never answers.
34
+ */
35
+ interface PayElementPresentationProps {
36
+ /**
37
+ * Shown in place of Stridge's placeholder while the element loads, a Try again included. The frame keeps loading
38
+ * under it.
39
+ */
40
+ loading?: ReactNode;
41
+ /**
42
+ * Shown in place of every failure view: Stridge's own and the default one for a frame that never answered. A
43
+ * function receives a `retry` and the failure's `reason`.
44
+ */
45
+ fallback?: PayElementFallback;
46
+ /**
47
+ * A class on the element's outer node, the one with `data-stridge-pay-element`. The kit reserves the element's
48
+ * default size there (the Pay card 184 px, every other element 62 px) in a rule any class overrides.
49
+ */
50
+ className?: string;
51
+ /**
52
+ * Inline styles on the element's outer node.
53
+ */
54
+ style?: CSSProperties;
55
+ }
56
+ /**
57
+ * How the request names its mode and amount, in USD. A payment (the default `mode`), and a deposit with an `amount`,
58
+ * ask a fixed amount. A deposit with no `amount` lets the user choose it in the window ("How much?"), within the app's
59
+ * optional `min` and `max` (decimal strings, as `amount`, up to $100,000).
60
+ */
61
+ type PayElementAmountProps = {
62
+ mode?: PayElementMode;
63
+ amount: string;
64
+ min?: never;
65
+ max?: never;
66
+ firstStep?: never;
67
+ } | {
68
+ mode: "deposit";
69
+ amount?: undefined;
70
+ min?: string;
71
+ max?: string;
72
+ /**
73
+ * Which question the window asks first. `"amount"` (the default) asks "How much?", then the way to pay.
74
+ * `"method"` opens on the ways to pay: a wallet connects first, then the amount screen shows that method and
75
+ * what it holds. Presentation only: it never changes the payment's terms, and only a Deposit with no
76
+ * `amount` takes it.
77
+ */
78
+ firstStep?: PayElementFirstStep;
79
+ };
80
+ /** The hub writes copy for this immutable payment request. */
81
+ type PayElementProps = PayElementRequestProps & PayElementAmountProps;
82
+ /** Every `PayElement` prop but the amount ones ({@link PayElementAmountProps}). */
83
+ interface PayElementRequestProps extends PayElementPresentationProps {
84
+ /**
85
+ * Your own id for this payment, stable for the order: 1 to 128 characters. The same `referenceId` with another
86
+ * mode, amount or description is refused; a new order needs a new `referenceId`.
87
+ */
88
+ referenceId: string;
89
+ /**
90
+ * The line the window shows for what the person pays for: trimmed, 1 to 64 code units, with no control
91
+ * characters. It is a term of the payment, so a changed `description` needs a new `referenceId`.
92
+ */
93
+ description?: string;
94
+ /**
95
+ * Where the payment goes. Without it, the hub pays the app's saved default checkout rule, and starts no payment
96
+ * for an app with no default. One of the app's checkout rules by id (`"ckr_…"`) pays that rule. An address with
97
+ * the CAIP-19 `eip155` asset it is paid in (`{ address: "0x…", asset: "eip155:8453/erc20:0x…" }`) pays only when
98
+ * it is one of the app's checkout rules, or for an app its app list marks as a test app. An address never goes
99
+ * without its asset. The default never replaces a destination named here: an answer for another rule, asset or
100
+ * address starts no payment. A changed destination takes effect with the next Pay of the same `referenceId`.
101
+ */
102
+ destination?: PayElementDestination;
103
+ /**
104
+ * Called with each event of the payment, frozen: `payment.observed`, `checkout.closed`, `payment.on_hold`,
105
+ * `payment.unconfirmed` or `request.failed`. Narrow on `type`. The events of a payment go to the `onEvent` the
106
+ * payment started with; an event can come again after a reload, so handle each one idempotently. No event proves
107
+ * that money arrived: check the payment on your own server before you ship the order.
108
+ */
109
+ onEvent?: (event: PayEvent) => void;
110
+ }
111
+ /** What the request is: a `"payment"` (the default) or a `"deposit"`. */
112
+ type PayElementMode = "payment" | "deposit";
113
+ /** Where a payment goes: a checkout rule id (`ckr_…`), or an address with its CAIP-19 `eip155` asset. */
114
+ type PayElementDestination = import("@stridge/pay-sdk").PayDestinationAsk;
115
+ /** A chosen-amount Deposit's first step: `"amount"` or `"method"`. */
116
+ type PayElementFirstStep = import("@stridge/pay-sdk").PayFirstStep;
117
+ //#endregion
118
+ export { type PayCheckoutClosedEvent, type PayConnectedEvent, PayElementAmountProps, PayElementDestination, PayElementFallback, PayElementFallbackContext, PayElementFallbackReason, PayElementFirstStep, PayElementMode, PayElementPresentationProps, PayElementProps, PayElementRequestProps, type PayEvent, type PayRequestFailedEvent, type PaymentObservedEvent, type PaymentOnHoldEvent, type PaymentUnconfirmedEvent };
@@ -0,0 +1 @@
1
+ "use client";import{INITIAL_ELEMENT_LOAD as e}from"../core/elementLoadState.js";import{PayElementClientContext as t,PayElementFrameContext as n}from"../provider/elementContext.js";import{payRequestsEqual as r}from"./compilePayRequest.js";import{elementConfigsEqual as i}from"./compileElementOptions.js";import{use as a,useLayoutEffect as o,useRef as s,useSyncExternalStore as c}from"react";function l(){let t={source:null,reserved:!1,container:null,handle:null,applied:null,disposal:null,generation:0,listeners:new Set,unwatch:null,subscribe(e){return t.listeners.add(e),()=>{t.listeners.delete(e)}},getLoadState:()=>t.handle?.getLoadState()??e,retry:()=>t.handle?.retry(),focus:()=>t.handle?.focus()};return t}function u(e,t){e.unwatch?.(),e.unwatch=null,e.handle=t,t!==null&&(e.unwatch=t.subscribeLoadState(()=>d(e))),d(e)}function d(e){let t=[...e.listeners];for(let e of t)e()}function f(e){let{handle:t}=e;e.applied=null,e.reserved=!1,u(e,null),t?.destroy()}function p(e,t,n,r){e.generation+=1,e.disposal!==null&&(clearTimeout(e.disposal),e.disposal=null),(e.handle===null||e.source!==t||e.container!==n)&&(f(e),e.source=t,e.container=n,u(e,r({container:n})))}function m(e){e.generation+=1;let t=e.generation;e.disposal=setTimeout(()=>{e.generation===t&&(e.disposal=null,f(e),e.source=null,e.container=null)},0)}function h(e,t,n,r,i){if(e.applied!==null&&v(e.applied,r)){t.setCallbacks(i);return}let a=t,o=y(a,r,i);if(o.status===`ignored`&&o.reason===`exhausted`&&e.container!==null&&(f(e),a=n.createHandle({container:e.container}),u(e,a),o=y(a,r,i)),o.status===`updated`){e.applied=r;return}if(o.reason!==`destroyed`)throw o.reason===`attempt-conflict`||o.reason===`payment-conflict`?TypeError(`PayElement reused a payment or attempt id with different data; use a new id`):TypeError(`The PayElement refused its config (${o.reason})`)}function g(e,r,i){let u=a(t),d=a(n);if(u===void 0)throw Error(`${e} must be used inside <PayProvider>`);let f=s(null),g=s(null);g.current??=l();let v=g.current,y=c(v.subscribe,v.getLoadState,_),{onSigned:b,onFailed:x,onCheckStatus:S,onCheckoutResult:C,onPaid:w,onHeld:T,onUnconfirmed:E}=i;return o(()=>{let e=f.current,t=d??u;if(e!==null&&t!==null)return p(v,t,e,e=>{if(u!==null)return u.createHandle(e);let t=d?.reserve(e)??null;return v.reserved=t!==null,t}),()=>m(v)},[v,d,u]),o(()=>{if(u===null||v.handle===null)return;let e=Object.freeze({...b===void 0?{}:{onSigned:b},...C===void 0?{}:{onCheckoutResult:C},...w===void 0?{}:{onPaid:w},...T===void 0?{}:{onHeld:T},...E===void 0?{}:{onUnconfirmed:E},...x===void 0?{}:{onFailed:x},...S===void 0?{}:{onCheckStatus:S}});v.reserved&&(v.reserved=!1,u.adopt?.(v.handle)),h(v,v.handle,u,r,e),v.handle?.start?.()}),{hostRef:f,load:y,retry:v.retry,focus:v.focus}}function _(){return e}function v(e,t){return`paymentId`in e?`paymentId`in t&&r(e,t):!(`paymentId`in t)&&i(e,t)}function y(e,t,n){if(`paymentId`in t){if(e.configurePay===void 0)throw TypeError(`The PayElement handle cannot accept a pay request`);return e.configurePay(t,n)}return e.configure(t,n)}export{g as useElementHandle};
@@ -0,0 +1 @@
1
+ import{HUB_SURFACE_POPUP as e,HUB_URL_PARAMS as t}from"@stridge/pay-sdk";function n(e,n){let r=new URL(e);return r.searchParams.set(t.theme,n.theme),r.searchParams.delete(`accent`),r}function r(e,r,i){let a=n(e,r);return a.searchParams.set(t.app,i),a.toString()}const i=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;function a(e,t,n){let r=t();if(typeof r!=`string`||!i.test(r))throw TypeError(`${n}: randomUUID must return a lowercase version 4 UUID`);return`${e}${r}`}function o(e=()=>globalThis.crypto.randomUUID()){return a(`stridge-pay-`,e,`createHubPopupName`)}function s(e=()=>globalThis.crypto.randomUUID()){return a(`stridge-pay-hub-`,e,`createHubFrameName`)}function c(r,i,a,o){let s=n(r,i);return s.searchParams.set(t.surface,e),s.searchParams.set(t.app,a),s.searchParams.set(t.origin,o),s.toString()}function l(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function u(e,t,n){return e===null||t===null||t<=0?null:Math.round(e+(t-n)/2)}function d(e){let t=[`popup=yes`,`width=420`,`height=640`],n=u(l(e.screenX),l(e.outerWidth),420),r=u(l(e.screenY),l(e.outerHeight),640);return n!==null&&t.push(`left=${n}`),r!==null&&t.push(`top=${r}`),t.join(`,`)}export{r as buildHubFrameUrl,c as buildHubPopupUrl,s as createHubFrameName,o as createHubPopupName,d as hubPopupFeatures};
@@ -0,0 +1 @@
1
+ function e(){return()=>void 0}export{e as subscribeToNothing};