@openreceive/elements 0.1.0 → 0.2.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.
- package/README.md +35 -0
- package/dist/chunk-46RMHGRA.js +2488 -0
- package/dist/define-elements-CX8Ml6J4.d.ts +108 -0
- package/dist/index.d.ts +41 -41
- package/dist/index.js +30 -781
- package/dist/styles.css +3 -1
- package/dist/wrapper-shared.d.ts +53 -0
- package/dist/wrapper-shared.js +86 -0
- package/package.json +51 -7
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Status, PaymentMethod, CheckoutPaymentMethod, CheckoutInvoiceSnapshot, SwapLimitContext, CheckoutState, QrEncoder, BrowserLoggerOption } from '@openreceive/browser/headless';
|
|
2
|
+
|
|
3
|
+
interface CheckoutView {
|
|
4
|
+
readonly invoice_id?: string;
|
|
5
|
+
readonly invoice: string;
|
|
6
|
+
readonly rail?: "lightning" | "swap" | "checkout_lock";
|
|
7
|
+
readonly payment_hash?: string;
|
|
8
|
+
readonly amount_msats?: number;
|
|
9
|
+
readonly fiat_quote?: {
|
|
10
|
+
readonly fiat?: {
|
|
11
|
+
readonly currency?: string;
|
|
12
|
+
readonly value?: string;
|
|
13
|
+
};
|
|
14
|
+
} | null;
|
|
15
|
+
readonly status?: Status;
|
|
16
|
+
readonly expires_at?: number;
|
|
17
|
+
readonly theme?: "light" | "dark";
|
|
18
|
+
readonly payment_wizard?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Base URL of a host-chosen bolt11 decoder, rendered as a "Decode" link.
|
|
21
|
+
* Omitted (the default), no link is rendered and the invoice — amount, payee,
|
|
22
|
+
* description, plus the payer's IP — never reaches a third party.
|
|
23
|
+
*/
|
|
24
|
+
readonly decodeLinkUrl?: string;
|
|
25
|
+
/**
|
|
26
|
+
* `false` when the shadow root adopts the compiled stylesheet instead of
|
|
27
|
+
* carrying an inline `<style>` (see element-styles.ts). Default `true` so a
|
|
28
|
+
* standalone caller still gets self-contained markup.
|
|
29
|
+
*/
|
|
30
|
+
readonly inlineStyles?: boolean;
|
|
31
|
+
/** False until the payer selects Bitcoin in create-mode (deferred Lightning mint). */
|
|
32
|
+
readonly lightningRequested?: boolean;
|
|
33
|
+
readonly wizard?: ElementsWizardView;
|
|
34
|
+
/**
|
|
35
|
+
* Live controller state, when the element has one. Preferred over the
|
|
36
|
+
* attribute-reconstructed state: after a swap re-key the attributes still
|
|
37
|
+
* describe the pre-swap Lightning attempt (or, in create mode, nothing).
|
|
38
|
+
*/
|
|
39
|
+
readonly liveState?: CheckoutState;
|
|
40
|
+
}
|
|
41
|
+
interface ElementsWizardView {
|
|
42
|
+
readonly selectedMethod?: PaymentMethod | null;
|
|
43
|
+
readonly selectedBitcoinRoute?: string | null;
|
|
44
|
+
readonly swapOptions?: readonly ElementsSwapOption[];
|
|
45
|
+
/**
|
|
46
|
+
* True until the first order-status response supplies `payment_methods` /
|
|
47
|
+
* `swap_pay_options` (provider catalog warm-up). Shows a loader tile.
|
|
48
|
+
*/
|
|
49
|
+
readonly currenciesLoading?: boolean;
|
|
50
|
+
/** Selected pay-in asset per multi-network coin label (e.g. USDT → USDT_TRON). */
|
|
51
|
+
readonly selectedSwapNetworks?: Readonly<Record<string, string>>;
|
|
52
|
+
/** Compact selector highlight: `method:bitcoin` or `swap:USDT`. */
|
|
53
|
+
readonly selectedPickerKey?: string | null;
|
|
54
|
+
/** Pay-in asset whose swap create is in flight — method tiles spin and disable. */
|
|
55
|
+
readonly startingSwapAsset?: string | null;
|
|
56
|
+
/** When set, the wizard shows the focused swap deposit flow for this pay-in asset. */
|
|
57
|
+
readonly selectedSwapAsset?: string | null;
|
|
58
|
+
/** Invoice amount + fiat, used to render fiat limit messages for out-of-range assets. */
|
|
59
|
+
readonly amountMsats?: number;
|
|
60
|
+
readonly fiat?: {
|
|
61
|
+
readonly currency?: string;
|
|
62
|
+
readonly value?: string;
|
|
63
|
+
};
|
|
64
|
+
readonly reference?: string;
|
|
65
|
+
readonly checkoutId?: string;
|
|
66
|
+
/** Display Lightning BOLT11 from the checkout (swap shadows may omit invoice). */
|
|
67
|
+
readonly lightningInvoice?: string;
|
|
68
|
+
/** Host-chosen bolt11 decoder base URL; omitted, the tutorial shows no decode link. */
|
|
69
|
+
readonly decodeLinkUrl?: string;
|
|
70
|
+
readonly paymentHash?: string;
|
|
71
|
+
readonly swapInvoice?: CheckoutInvoiceSnapshot;
|
|
72
|
+
readonly activeTutorialProviderId?: string | null;
|
|
73
|
+
readonly activeTutorialIndex?: number;
|
|
74
|
+
readonly activeTutorialCopied?: boolean;
|
|
75
|
+
/** Swap-start failure rendered inline in the deposit slot with a retry button. */
|
|
76
|
+
readonly swapStartError?: string;
|
|
77
|
+
/**
|
|
78
|
+
* The quote for the selected pay-in asset when it came back unavailable, so
|
|
79
|
+
* the deposit slot shows the accepted range instead of a generic error.
|
|
80
|
+
* Matches React's `renderSwapUnavailable` pane.
|
|
81
|
+
*/
|
|
82
|
+
readonly unavailableSwapQuote?: CheckoutPaymentMethod;
|
|
83
|
+
/** Checkout context the unavailable panel converts invoice-side limits with. */
|
|
84
|
+
readonly swapLimitContext?: SwapLimitContext;
|
|
85
|
+
/** Wizard-level failure (e.g. Lightning mint) rendered inline. */
|
|
86
|
+
readonly wizardError?: string;
|
|
87
|
+
}
|
|
88
|
+
type ElementsSwapOption = CheckoutPaymentMethod;
|
|
89
|
+
interface DefineElementsOptions {
|
|
90
|
+
readonly tagName?: string;
|
|
91
|
+
readonly themeToggleTagName?: string;
|
|
92
|
+
readonly registry?: CustomElementRegistry;
|
|
93
|
+
readonly qrEncoder?: QrEncoder;
|
|
94
|
+
readonly logger?: BrowserLoggerOption;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Register the OpenReceive custom elements with the browser's element
|
|
99
|
+
* registry. Until this runs, `<openreceive-checkout>` and
|
|
100
|
+
* `<openreceive-theme-toggle>` are unknown tags the browser renders as
|
|
101
|
+
* nothing; once it runs, every such tag on the page — already in the HTML or
|
|
102
|
+
* added later — upgrades into the live checkout / theme toggle. Call it once
|
|
103
|
+
* from your page's JS; order relative to the markup does not matter, and
|
|
104
|
+
* calling it again skips tags that are already defined.
|
|
105
|
+
*/
|
|
106
|
+
declare function defineElements(options?: DefineElementsOptions): void;
|
|
107
|
+
|
|
108
|
+
export { type CheckoutView as C, type DefineElementsOptions as D, type ElementsWizardView as E, defineElements as d };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
readonly status?: Status;
|
|
14
|
-
readonly expires_at?: number;
|
|
15
|
-
readonly theme?: "light" | "dark";
|
|
16
|
-
readonly payment_wizard?: boolean;
|
|
17
|
-
readonly wizard?: OpenReceiveElementsWizardView;
|
|
18
|
-
}
|
|
19
|
-
export interface OpenReceiveElementsWizardView {
|
|
20
|
-
readonly selectedMethod?: OpenReceivePaymentMethod | null;
|
|
21
|
-
readonly selectedCountryCode?: string;
|
|
22
|
-
readonly selectedBitcoinRoute?: string | null;
|
|
23
|
-
readonly selectedCryptoRoute?: string | null;
|
|
24
|
-
readonly selectedRegion?: OpenReceiveRegionId;
|
|
25
|
-
readonly countryPickerOpen?: boolean;
|
|
26
|
-
readonly activeTutorialProviderId?: string | null;
|
|
27
|
-
readonly activeTutorialIndex?: number;
|
|
28
|
-
readonly activeTutorialCopied?: boolean;
|
|
1
|
+
import { TransactionDetailsSource } from '@openreceive/browser/headless';
|
|
2
|
+
export { OPENRECEIVE_CHECKOUT_ELEMENT_ATTRIBUTES, OPENRECEIVE_CHECKOUT_ELEMENT_EVENTS, OPENRECEIVE_CHECKOUT_ELEMENT_TAG_NAME, OPENRECEIVE_THEME_TOGGLE_ELEMENT_ATTRIBUTES, OPENRECEIVE_THEME_TOGGLE_ELEMENT_EVENTS, OPENRECEIVE_THEME_TOGGLE_ELEMENT_TAG_NAME, TransactionDetailsSource, createThemeToggleElement } from '@openreceive/browser/headless';
|
|
3
|
+
import { C as CheckoutView } from './define-elements-CX8Ml6J4.js';
|
|
4
|
+
export { D as DefineElementsOptions, E as ElementsWizardView, d as defineElements } from './define-elements-CX8Ml6J4.js';
|
|
5
|
+
|
|
6
|
+
declare function renderCheckoutHtml(view: CheckoutView): string;
|
|
7
|
+
/**
|
|
8
|
+
* `false` when the caller adopts the compiled stylesheet into the shadow root
|
|
9
|
+
* instead (see element-styles.ts); the markup then carries no `<style>`.
|
|
10
|
+
*/
|
|
11
|
+
interface RenderOpenReceiveStyleOptions {
|
|
12
|
+
readonly inlineStyles?: boolean;
|
|
29
13
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
14
|
+
/**
|
|
15
|
+
* The element's ONE failure panel: inline message, never an endless spinner and
|
|
16
|
+
* never an empty shadow root.
|
|
17
|
+
*
|
|
18
|
+
* It shows the create-mode prepare failure, which is always re-runnable — the
|
|
19
|
+
* payer clicks and the element POSTs again — so the panel always carries the
|
|
20
|
+
* retry button.
|
|
21
|
+
*/
|
|
22
|
+
declare function renderCheckoutCreateErrorHtml(message: string, options?: RenderOpenReceiveStyleOptions & {
|
|
23
|
+
readonly theme?: "light" | "dark";
|
|
24
|
+
}): string;
|
|
25
|
+
declare function renderThemeToggleHtml(label: string, options?: RenderOpenReceiveStyleOptions): string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Collapsible transaction-details panel as an HTML string (vanilla / elements hosts).
|
|
29
|
+
* Uses the same row builder as React `<TransactionDetails>`.
|
|
30
|
+
*/
|
|
31
|
+
declare function renderTransactionDetailsHtml(source: TransactionDetailsSource, options?: {
|
|
32
|
+
readonly open?: boolean;
|
|
33
|
+
readonly className?: string;
|
|
34
|
+
}): string;
|
|
35
|
+
declare function createTransactionDetailsElement(source: TransactionDetailsSource, options?: {
|
|
36
|
+
readonly open?: boolean;
|
|
37
|
+
readonly className?: string;
|
|
38
|
+
readonly onCopyError?: (error: unknown) => void;
|
|
39
|
+
readonly document?: Document;
|
|
40
|
+
}): HTMLElement | null;
|
|
41
|
+
|
|
42
|
+
export { CheckoutView, createTransactionDetailsElement, renderCheckoutCreateErrorHtml, renderCheckoutHtml, renderThemeToggleHtml, renderTransactionDetailsHtml };
|