@whop/elements 1.0.0-beta.4 → 1.0.0-beta.6

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/index.d.cts CHANGED
@@ -6,6 +6,7 @@ import type { AdsHandle, AdsOptions, AdsStatics } from "./ads.js";
6
6
  import type { TrackingHandle, TrackingOptions, TrackingStatics } from "./tracking.js";
7
7
  import type { WalletHandle, WalletOptions, WalletStatics } from "./wallet.js";
8
8
  import type { WebsitesHandle, WebsitesOptions, WebsitesStatics } from "./websites.js";
9
+ import type { DashboardHandle, DashboardOptions, DashboardStatics } from "./dashboard.js";
9
10
 
10
11
  /** Global configuration for `WhopElements(config)`, inherited by every namespace handle (`appearance`, `locale`, …). */
11
12
  export interface WhopGlobalConfig extends FrameworkGlobals {}
@@ -13,7 +14,7 @@ export interface WhopGlobalConfig extends FrameworkGlobals {}
13
14
  /** The configured instance: one accessor per namespace, each carrying `create()` plus that namespace's static actions. */
14
15
  export interface Whop {
15
16
  /**
16
- * Browse account payments with PaymentsElement, collect a payment from a `plan_` ID or inline currency and amount, or save a payment method without charging with `mode: "setup"`. Mount PaymentElement, CardElement, or CardFields, then call `payments.createConfirmationToken` with billing details. Wallet selections open their sheet automatically. Confirm the token server-side, then pass the payment's or setup intent's `client_secret` to `handleNextAction` for any pending step.
17
+ * Collect a payment from a `plan_` ID or inline currency and amount, or save a payment method without charging with `mode: "setup"`. Mount PaymentElement, CardElement, or CardFields, then call `payments.createConfirmationToken` with billing details. Wallet selections open their sheet automatically. Confirm the token server-side, then pass the payment's or setup intent's `client_secret` to `handleNextAction` for any pending step.
17
18
  */
18
19
  payments: { create(options: PaymentsOptions): PaymentsHandle } & PaymentsStatics;
19
20
  /**
@@ -21,7 +22,7 @@ export interface Whop {
21
22
  */
22
23
  verifications: { create(options: VerificationsOptions): VerificationsHandle } & VerificationsStatics;
23
24
  /**
24
- * Drives a full hosted checkout for one plan — price summary, promo codes, the currency the buyer pays in, and the whole payment collection surface (the payments elements, composed inside) — against the Whop checkout sessions API. Mount it with a `plan` (or a `checkoutConfiguration` you authored) and the element opens the checkout session itself; the session credential never leaves the element. A setup-mode checkout configuration mounts the same element as a payment-method save: nothing is charged, the buyer’s method is stored for you to charge later, and the finished checkout redirects with `setup_intent_id`. The buyer pays inside the element, and a finished checkout redirects the current tab to `returnUrl`, including the page that contains the element. Fulfill from webhooks rather than a browser callback. Without a `returnUrl`, the buyer rests on the element’s own success face. The element automatically drives an off-site payment step, such as 3DS or a bank page. On whop.com, it brings the buyer back into the restored checkout; in an embed, the buyer returns to the same `returnUrl`. A failed payment reopens the same checkout with the reason shown, so the buyer can pay again. Every option is set at creation: the element mints a checkout session from these values when it mounts. Changing one later with `update()` or new React props fails instead of changing the existing order. Mount a new checkout to change the purchase.
25
+ * Drives a full hosted checkout for one or more plans — itemized price summary, promo codes, the currency the buyer pays in, and the whole payment collection surface (the payments elements, composed inside) — against the Whop checkout sessions API. Mount it with `items`, a single `plan`, or a `checkoutConfiguration` you authored and the element opens the checkout session itself; the session credential never leaves the element. A setup-mode checkout configuration mounts the same element as a payment-method save: nothing is charged, the buyer’s method is stored for you to charge later, and the finished checkout redirects with `setup_intent_id`. The buyer pays inside the element, and a finished checkout redirects the current tab to `returnUrl`, including the page that contains the element. Fulfill from webhooks rather than a browser callback. Without a `returnUrl`, the buyer rests on the element’s own success face. The element automatically drives an off-site payment step, such as 3DS or a bank page. On whop.com, it brings the buyer back into the restored checkout; in an embed, the buyer returns to the same `returnUrl`. A failed payment reopens the same checkout with the reason shown, so the buyer can pay again. Every option is set at creation: the element mints a checkout session from these values when it mounts. Changing one later with `update()` or new React props fails instead of changing the existing order. Mount a new checkout to change what is being purchased.
25
26
  */
26
27
  checkout: { create(options: CheckoutOptions): CheckoutHandle } & CheckoutStatics;
27
28
  /**
@@ -33,13 +34,17 @@ export interface Whop {
33
34
  */
34
35
  tracking: { create(options: TrackingOptions): TrackingHandle } & TrackingStatics;
35
36
  /**
36
- * Drives an account's money surfaces. `required-actions` is the outstanding-action bar from Whop's balance dashboard. `actions` renders the Deposit, Accept, Send, and Convert controls: Deposit, Send, and Convert open their Wallet overlays, while Accept opens Whop's checkout-link creator for a business account or company creation for a personal account. `deposit` returns live funding rails; `convert` swaps USD with Gold or Bitcoin and exposes FX currencies when the host enables `fxEnabled`; `send` moves money to a recipient or creates a public claim link; `withdraw` lists payout methods and creates the payout when the host does not already drive that API; `balances` holds two faces — the holdings list, and the balance block drawing value over a window; `cards` is the compact issued-card list; `cardsTable` renders the full sortable card roster; `cardsChart` plots card spend; `whopCard` renders one revealable card; `activity` lists ledger movements; `activityDetail` renders a prefetched movement, or retrieves one by activity ID or card transaction ID, in a standalone drawer; and `verification` is the identity-only nudge. Every data-backed surface can use the viewer's session when no token is provided.
37
+ * Drives an account's money surfaces. `actions` renders the Deposit, Accept, Send, and Convert controls: Deposit, Send, and Convert open their Wallet overlays, while Accept opens Whop's checkout-link creator for a business account or company creation for a personal account. `deposit` returns live funding rails; `convert` swaps USD with Gold or Bitcoin and exposes FX currencies when the host enables `fxEnabled`; `send` moves money to a recipient or creates a public claim link; `withdraw` lists payout methods and creates the payout when the host does not already drive that API; `balances` holds two faces — the holdings list, and the balance block drawing value over a window; `cards` is the compact issued-card list; `cardsTable` renders the full sortable card roster; `cardsChart` plots card spend; `whopCard` renders one revealable card; `activity` lists ledger movements; `activityDetail` renders a prefetched movement, or retrieves one by activity ID or card transaction ID, in a standalone drawer. The outstanding-action bar and the identity nudge live on the `dashboard` controller. Every data-backed surface can use the viewer's session when no token is provided.
37
38
  */
38
39
  wallet: { create(options: WalletOptions): WalletHandle } & WalletStatics;
39
40
  /**
40
41
  * An account's websites: every site built on whop.site plus every domain the Whop Pixel reports, with traffic and attributed revenue per domain. Mount `websites` and it lists them with visitors, page views, sales, revenue, trend, and most-viewed pages. Mount `pixel-setup` alongside it and a site whose pixel the wizard just proved live gets a waiting row automatically, because its first events take a few minutes to reach the stats API and the site would otherwise look lost — you wire nothing up for that, and the row is kept on your page so it is still there if the merchant reloads. Reading stats is privileged, so it needs an `accessToken` — except inside Whop's own app, where the viewer's session carries the read.
41
42
  */
42
43
  websites: { create(options: WebsitesOptions): WebsitesHandle } & WebsitesStatics;
44
+ /**
45
+ * An account's own dashboard surfaces, embedded on your site. Scope it to an account with `accountId`, then mount `paymentsTable` for the account's payments, `paymentDetail` for one payment, `required-actions` for the outstanding-action banners Whop's own dashboard shows above the balance — identity verification, deposits, tax, and the rest — and `verification` for the identity-only nudge. Every surface reads with the same credential, so two side by side always show the same account. The banners render nothing once the account has nothing outstanding, so they can sit permanently in a layout, and they report the presses they cannot answer themselves — Add money and Verify — so the host mounts its own deposit or verification flow, such as the `wallet` controller's `deposit` element or the `verifications` controller's `kyc` element.
46
+ */
47
+ dashboard: { create(options: DashboardOptions): DashboardHandle } & DashboardStatics;
43
48
  }
44
49
 
45
50
  /** The global `window.WhopElements`. Call it with the global config to get a `Whop` instance. */
@@ -50,8 +55,11 @@ export interface WhopConstructor {
50
55
  /** The hosted SDK bundle `loadWhop()` loads. The URL carries the release train, so it follows this package's major. */
51
56
  export declare const SDK_URL: string;
52
57
 
53
- /** Load the hosted SDK: injects the `<script data-whop-elements>` tag once and resolves the global constructor. Safe to call any number of times: one script, one shared promise. */
54
- export declare function loadWhop(): Promise<WhopConstructor>;
58
+ /** The promise `loadWhop()` returns: the load itself, plus `retry()`, which starts a fresh load after a failure. While a load is in flight or has succeeded, `retry()` is that same load. */
59
+ export type WhopLoad = Promise<WhopConstructor> & { retry(): WhopLoad };
60
+
61
+ /** Load the hosted SDK: injects the `<script data-whop-elements>` tag once and resolves the global constructor. Safe to call any number of times: one script, one shared promise. A failed load is held, so every later call returns the same rejected promise and nothing retries on its own; call `retry()` on it to load again. */
62
+ export declare function loadWhop(): WhopLoad;
55
63
 
56
64
  /** Resource hints (preconnect/preload) for the hosted SDK. Render them into `<head>` to start the fetch before `loadWhop()` runs. */
57
65
  export declare function preloadHints(): { rel: string; href: string; as?: string }[];
package/index.d.ts CHANGED
@@ -6,6 +6,7 @@ import type { AdsHandle, AdsOptions, AdsStatics } from "./ads.js";
6
6
  import type { TrackingHandle, TrackingOptions, TrackingStatics } from "./tracking.js";
7
7
  import type { WalletHandle, WalletOptions, WalletStatics } from "./wallet.js";
8
8
  import type { WebsitesHandle, WebsitesOptions, WebsitesStatics } from "./websites.js";
9
+ import type { DashboardHandle, DashboardOptions, DashboardStatics } from "./dashboard.js";
9
10
 
10
11
  /** Global configuration for `WhopElements(config)`, inherited by every namespace handle (`appearance`, `locale`, …). */
11
12
  export interface WhopGlobalConfig extends FrameworkGlobals {}
@@ -13,7 +14,7 @@ export interface WhopGlobalConfig extends FrameworkGlobals {}
13
14
  /** The configured instance: one accessor per namespace, each carrying `create()` plus that namespace's static actions. */
14
15
  export interface Whop {
15
16
  /**
16
- * Browse account payments with PaymentsElement, collect a payment from a `plan_` ID or inline currency and amount, or save a payment method without charging with `mode: "setup"`. Mount PaymentElement, CardElement, or CardFields, then call `payments.createConfirmationToken` with billing details. Wallet selections open their sheet automatically. Confirm the token server-side, then pass the payment's or setup intent's `client_secret` to `handleNextAction` for any pending step.
17
+ * Collect a payment from a `plan_` ID or inline currency and amount, or save a payment method without charging with `mode: "setup"`. Mount PaymentElement, CardElement, or CardFields, then call `payments.createConfirmationToken` with billing details. Wallet selections open their sheet automatically. Confirm the token server-side, then pass the payment's or setup intent's `client_secret` to `handleNextAction` for any pending step.
17
18
  */
18
19
  payments: { create(options: PaymentsOptions): PaymentsHandle } & PaymentsStatics;
19
20
  /**
@@ -21,7 +22,7 @@ export interface Whop {
21
22
  */
22
23
  verifications: { create(options: VerificationsOptions): VerificationsHandle } & VerificationsStatics;
23
24
  /**
24
- * Drives a full hosted checkout for one plan — price summary, promo codes, the currency the buyer pays in, and the whole payment collection surface (the payments elements, composed inside) — against the Whop checkout sessions API. Mount it with a `plan` (or a `checkoutConfiguration` you authored) and the element opens the checkout session itself; the session credential never leaves the element. A setup-mode checkout configuration mounts the same element as a payment-method save: nothing is charged, the buyer’s method is stored for you to charge later, and the finished checkout redirects with `setup_intent_id`. The buyer pays inside the element, and a finished checkout redirects the current tab to `returnUrl`, including the page that contains the element. Fulfill from webhooks rather than a browser callback. Without a `returnUrl`, the buyer rests on the element’s own success face. The element automatically drives an off-site payment step, such as 3DS or a bank page. On whop.com, it brings the buyer back into the restored checkout; in an embed, the buyer returns to the same `returnUrl`. A failed payment reopens the same checkout with the reason shown, so the buyer can pay again. Every option is set at creation: the element mints a checkout session from these values when it mounts. Changing one later with `update()` or new React props fails instead of changing the existing order. Mount a new checkout to change the purchase.
25
+ * Drives a full hosted checkout for one or more plans — itemized price summary, promo codes, the currency the buyer pays in, and the whole payment collection surface (the payments elements, composed inside) — against the Whop checkout sessions API. Mount it with `items`, a single `plan`, or a `checkoutConfiguration` you authored and the element opens the checkout session itself; the session credential never leaves the element. A setup-mode checkout configuration mounts the same element as a payment-method save: nothing is charged, the buyer’s method is stored for you to charge later, and the finished checkout redirects with `setup_intent_id`. The buyer pays inside the element, and a finished checkout redirects the current tab to `returnUrl`, including the page that contains the element. Fulfill from webhooks rather than a browser callback. Without a `returnUrl`, the buyer rests on the element’s own success face. The element automatically drives an off-site payment step, such as 3DS or a bank page. On whop.com, it brings the buyer back into the restored checkout; in an embed, the buyer returns to the same `returnUrl`. A failed payment reopens the same checkout with the reason shown, so the buyer can pay again. Every option is set at creation: the element mints a checkout session from these values when it mounts. Changing one later with `update()` or new React props fails instead of changing the existing order. Mount a new checkout to change what is being purchased.
25
26
  */
26
27
  checkout: { create(options: CheckoutOptions): CheckoutHandle } & CheckoutStatics;
27
28
  /**
@@ -33,13 +34,17 @@ export interface Whop {
33
34
  */
34
35
  tracking: { create(options: TrackingOptions): TrackingHandle } & TrackingStatics;
35
36
  /**
36
- * Drives an account's money surfaces. `required-actions` is the outstanding-action bar from Whop's balance dashboard. `actions` renders the Deposit, Accept, Send, and Convert controls: Deposit, Send, and Convert open their Wallet overlays, while Accept opens Whop's checkout-link creator for a business account or company creation for a personal account. `deposit` returns live funding rails; `convert` swaps USD with Gold or Bitcoin and exposes FX currencies when the host enables `fxEnabled`; `send` moves money to a recipient or creates a public claim link; `withdraw` lists payout methods and creates the payout when the host does not already drive that API; `balances` holds two faces — the holdings list, and the balance block drawing value over a window; `cards` is the compact issued-card list; `cardsTable` renders the full sortable card roster; `cardsChart` plots card spend; `whopCard` renders one revealable card; `activity` lists ledger movements; `activityDetail` renders a prefetched movement, or retrieves one by activity ID or card transaction ID, in a standalone drawer; and `verification` is the identity-only nudge. Every data-backed surface can use the viewer's session when no token is provided.
37
+ * Drives an account's money surfaces. `actions` renders the Deposit, Accept, Send, and Convert controls: Deposit, Send, and Convert open their Wallet overlays, while Accept opens Whop's checkout-link creator for a business account or company creation for a personal account. `deposit` returns live funding rails; `convert` swaps USD with Gold or Bitcoin and exposes FX currencies when the host enables `fxEnabled`; `send` moves money to a recipient or creates a public claim link; `withdraw` lists payout methods and creates the payout when the host does not already drive that API; `balances` holds two faces — the holdings list, and the balance block drawing value over a window; `cards` is the compact issued-card list; `cardsTable` renders the full sortable card roster; `cardsChart` plots card spend; `whopCard` renders one revealable card; `activity` lists ledger movements; `activityDetail` renders a prefetched movement, or retrieves one by activity ID or card transaction ID, in a standalone drawer. The outstanding-action bar and the identity nudge live on the `dashboard` controller. Every data-backed surface can use the viewer's session when no token is provided.
37
38
  */
38
39
  wallet: { create(options: WalletOptions): WalletHandle } & WalletStatics;
39
40
  /**
40
41
  * An account's websites: every site built on whop.site plus every domain the Whop Pixel reports, with traffic and attributed revenue per domain. Mount `websites` and it lists them with visitors, page views, sales, revenue, trend, and most-viewed pages. Mount `pixel-setup` alongside it and a site whose pixel the wizard just proved live gets a waiting row automatically, because its first events take a few minutes to reach the stats API and the site would otherwise look lost — you wire nothing up for that, and the row is kept on your page so it is still there if the merchant reloads. Reading stats is privileged, so it needs an `accessToken` — except inside Whop's own app, where the viewer's session carries the read.
41
42
  */
42
43
  websites: { create(options: WebsitesOptions): WebsitesHandle } & WebsitesStatics;
44
+ /**
45
+ * An account's own dashboard surfaces, embedded on your site. Scope it to an account with `accountId`, then mount `paymentsTable` for the account's payments, `paymentDetail` for one payment, `required-actions` for the outstanding-action banners Whop's own dashboard shows above the balance — identity verification, deposits, tax, and the rest — and `verification` for the identity-only nudge. Every surface reads with the same credential, so two side by side always show the same account. The banners render nothing once the account has nothing outstanding, so they can sit permanently in a layout, and they report the presses they cannot answer themselves — Add money and Verify — so the host mounts its own deposit or verification flow, such as the `wallet` controller's `deposit` element or the `verifications` controller's `kyc` element.
46
+ */
47
+ dashboard: { create(options: DashboardOptions): DashboardHandle } & DashboardStatics;
43
48
  }
44
49
 
45
50
  /** The global `window.WhopElements`. Call it with the global config to get a `Whop` instance. */
@@ -50,8 +55,11 @@ export interface WhopConstructor {
50
55
  /** The hosted SDK bundle `loadWhop()` loads. The URL carries the release train, so it follows this package's major. */
51
56
  export declare const SDK_URL: string;
52
57
 
53
- /** Load the hosted SDK: injects the `<script data-whop-elements>` tag once and resolves the global constructor. Safe to call any number of times: one script, one shared promise. */
54
- export declare function loadWhop(): Promise<WhopConstructor>;
58
+ /** The promise `loadWhop()` returns: the load itself, plus `retry()`, which starts a fresh load after a failure. While a load is in flight or has succeeded, `retry()` is that same load. */
59
+ export type WhopLoad = Promise<WhopConstructor> & { retry(): WhopLoad };
60
+
61
+ /** Load the hosted SDK: injects the `<script data-whop-elements>` tag once and resolves the global constructor. Safe to call any number of times: one script, one shared promise. A failed load is held, so every later call returns the same rejected promise and nothing retries on its own; call `retry()` on it to load again. */
62
+ export declare function loadWhop(): WhopLoad;
55
63
 
56
64
  /** Resource hints (preconnect/preload) for the hosted SDK. Render them into `<head>` to start the fetch before `loadWhop()` runs. */
57
65
  export declare function preloadHints(): { rel: string; href: string; as?: string }[];
package/index.js CHANGED
@@ -2,50 +2,103 @@
2
2
  var define_WHOP_ELEMENTS_LOCALES_default = ["en", "es", "zh", "nl", "pt", "de", "hu", "it", "fr", "ja", "pl", "tr"];
3
3
 
4
4
  // ../../packages/elements-codegen/src/cli/build/npm-loader.ts
5
- var ORIGIN = "https://js.whop.cloud";
6
- var SDK_URL = "https://js.whop.cloud/elements/amber/elements.js";
5
+ var ORIGIN = "https://cdn.whop.com";
6
+ var SDK_URL = "https://cdn.whop.com/elements/amber/elements.js";
7
7
  var WHOP_ELEMENTS_LOCALES = define_WHOP_ELEMENTS_LOCALES_default;
8
+ var TAG = "script[data-whop-elements]";
9
+ var resolved = null;
10
+ function withRetry(promise) {
11
+ return Object.assign(promise, { retry: retryWhop });
12
+ }
8
13
  function loadWhop() {
9
- if (typeof window === "undefined") return Promise.reject(new Error("WhopElements requires a browser environment"));
14
+ if (typeof window === "undefined") return withRetry(Promise.reject(new Error("WhopElements requires a browser environment")));
10
15
  const w = window;
11
- if (w.WhopElements) return Promise.resolve(w.WhopElements);
12
- let s = document.querySelector("script[data-whop-elements]");
13
- const created = !s;
14
- if (!s) {
15
- s = document.createElement("script");
16
- s.src = SDK_URL;
17
- s.async = true;
18
- s.setAttribute("data-whop-elements", "");
16
+ const existing = document.querySelector(TAG);
17
+ if (existing?.__whopReady) return cached(existing);
18
+ if (w.WhopElements) return resolved ??= withRetry(Promise.resolve(w.WhopElements));
19
+ return watch(w, existing ?? inject(), !existing);
20
+ }
21
+ function cached(script) {
22
+ const ready = script.__whopReady;
23
+ if (typeof ready.retry !== "function") {
24
+ let settled = false;
25
+ ready.then(
26
+ () => {
27
+ settled = true;
28
+ },
29
+ () => {
30
+ settled = true;
31
+ script.__whopFailed = true;
32
+ }
33
+ );
34
+ Object.assign(ready, {
35
+ retry: () => settled ? retryWhop() : withRetry(ready.then((value) => value, () => retryWhop()))
36
+ });
37
+ }
38
+ return ready;
39
+ }
40
+ function retryWhop() {
41
+ if (typeof window === "undefined") return loadWhop();
42
+ const dead = document.querySelector(TAG);
43
+ if (!dead?.__whopFailed) return loadWhop();
44
+ return watch(window, inject(dead), true);
45
+ }
46
+ function inject(replacing) {
47
+ const s = document.createElement("script");
48
+ s.src = replacing?.src || SDK_URL;
49
+ s.async = true;
50
+ s.setAttribute("data-whop-elements", "");
51
+ if (replacing) {
52
+ if (replacing.nonce) s.nonce = replacing.nonce;
53
+ if (replacing.crossOrigin) s.crossOrigin = replacing.crossOrigin;
54
+ if (replacing.integrity) s.integrity = replacing.integrity;
55
+ if (replacing.referrerPolicy) s.referrerPolicy = replacing.referrerPolicy;
56
+ replacing.replaceWith(s);
57
+ } else {
19
58
  document.head.appendChild(s);
20
59
  }
21
- const script = s;
60
+ return s;
61
+ }
62
+ function measured(src) {
63
+ const entry = performance.getEntriesByName(src).pop();
64
+ if (!entry) return "";
65
+ const after = `after ${Math.round(entry.duration)}ms`;
66
+ return entry.responseStatus ? ` (HTTP ${entry.responseStatus} ${after})` : ` (${after}, no status visible)`;
67
+ }
68
+ function watch(w, script, created) {
22
69
  if (!script.__whopReady) {
23
- script.__whopReady = new Promise((resolve, reject) => {
24
- let timer = null;
25
- function settle(fn, v) {
26
- if (timer !== null) {
27
- clearInterval(timer);
28
- timer = null;
29
- }
30
- fn(v);
31
- }
32
- script.addEventListener("load", () => {
33
- if (w.WhopElements) settle(resolve, w.WhopElements);
34
- else settle(reject, new Error("WhopElements loaded but did not initialize"));
35
- });
36
- script.addEventListener("error", () => settle(reject, new Error("Failed to load " + SDK_URL)));
37
- if (!created) {
38
- let waited = 0;
39
- timer = setInterval(() => {
40
- if (w.WhopElements) {
41
- settle(resolve, w.WhopElements);
42
- return;
70
+ script.__whopReady = withRetry(
71
+ new Promise((resolve, reject) => {
72
+ let timer = null;
73
+ function settle(fn, v) {
74
+ if (timer !== null) {
75
+ clearInterval(timer);
76
+ timer = null;
43
77
  }
44
- waited += 200;
45
- if (waited >= 1e4) settle(reject, new Error("existing data-whop-elements script did not initialize within 10s \u2014 if its network load already failed before loadWhop() ran (check the console/CSP), no load/error event will ever fire on it"));
46
- }, 200);
47
- }
48
- });
78
+ fn(v);
79
+ }
80
+ function fail(message) {
81
+ script.__whopFailed = true;
82
+ settle(reject, new Error(message));
83
+ }
84
+ script.addEventListener("load", () => {
85
+ if (w.WhopElements) settle(resolve, w.WhopElements);
86
+ else fail("WhopElements loaded but did not initialize");
87
+ });
88
+ script.addEventListener("error", () => fail("Failed to load " + script.src + measured(script.src)));
89
+ if (!created) {
90
+ let waited = 0;
91
+ timer = setInterval(() => {
92
+ if (w.WhopElements) {
93
+ settle(resolve, w.WhopElements);
94
+ return;
95
+ }
96
+ waited += 200;
97
+ if (waited >= 1e4) fail("existing data-whop-elements script did not initialize within 10s \u2014 if its network load already failed before loadWhop() ran (check the console/CSP), no load/error event will ever fire on it");
98
+ }, 200);
99
+ }
100
+ })
101
+ );
49
102
  }
50
103
  return script.__whopReady;
51
104
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whop/elements",
3
- "version": "1.0.0-beta.4",
3
+ "version": "1.0.0-beta.6",
4
4
  "description": "Whop Elements — vanilla-js loader + types. Loads the hosted SDK and exposes the typed WhopElements factory.",
5
5
  "keywords": [
6
6
  "checkout",
@@ -87,7 +87,15 @@
87
87
  "require": {
88
88
  "types": "./websites.d.cts"
89
89
  }
90
+ },
91
+ "./dashboard": {
92
+ "import": {
93
+ "types": "./dashboard.d.ts"
94
+ },
95
+ "require": {
96
+ "types": "./dashboard.d.cts"
97
+ }
90
98
  }
91
99
  },
92
- "whopElementsApiHash": "643973a360d415d99bd6cf95211709b03ca2dc4b79002d7cd3539f367cd4ca71"
100
+ "whopElementsApiHash": "b72556969cd0639197c9f12264ddcba29ea3d8eb58dc91408ec30dff9fbea805"
93
101
  }