@moonpay/platform-sdk-core 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -116,6 +116,27 @@ interface UrlBuilderOptions {
116
116
  }
117
117
  /** Build a frame URL with query parameters. */
118
118
  declare function buildFrameUrl(path: string, query?: Record<string, unknown>, options?: UrlBuilderOptions): string;
119
+ /** Theming options honoured by every visible MoonPay frame. */
120
+ interface ThemeOptions {
121
+ /**
122
+ * Frame appearance. Emitted as the `theme` query param that MoonPay frames
123
+ * read to render in light or dark mode. Defaults to the customer's system
124
+ * preference when omitted.
125
+ */
126
+ appearance?: 'light' | 'dark';
127
+ }
128
+ /**
129
+ * Query params for a theme, mapping `appearance` → the `theme` param the
130
+ * frames actually read. Returns `{}` when no appearance is set, so it spreads
131
+ * cleanly into a frame URL's query object.
132
+ */
133
+ declare function themeParams(theme?: ThemeOptions): Record<string, string>;
134
+ /**
135
+ * Set the `theme` query param on an already-built frame URL from a
136
+ * client-level theme — unless the URL already carries one, so a per-frame
137
+ * (or partner-embedded) theme always wins over the client default.
138
+ */
139
+ declare function applyThemeParam(url: string, theme?: ThemeOptions): string;
119
140
 
120
141
  interface CoreClientOptions extends ClientContextOptions, UrlBuilderOptions {
121
142
  /**
@@ -214,4 +235,4 @@ interface FrameHandle {
214
235
  */
215
236
  declare function createFrameOrchestrator(options: FrameOrchestratorOptions): Promise<FrameHandle>;
216
237
 
217
- export { type ClientContext, type ClientContextOptions, type CoreClient, type CoreClientOptions, FRAME_PATHS, type FrameHandle, type FrameOptions, type FrameOrchestratorOptions, type FrameTransport, type KeyPair, type ListTransactionsParams, type UrlBuilderOptions, apiFetch, buildFrameUrl, createClientContext, createClientCore, createFrameOrchestrator, createIdentity, decryptCredentials, deletePaymentMethod, generateKeyPair, getIdentity, getIdentityUploadUrl, getPaymentMethods, getQuote, getTransaction, listTransactions, submitIdentityFiles, updateIdentity, verifyIdentity };
238
+ export { type ClientContext, type ClientContextOptions, type CoreClient, type CoreClientOptions, FRAME_PATHS, type FrameHandle, type FrameOptions, type FrameOrchestratorOptions, type FrameTransport, type KeyPair, type ListTransactionsParams, type ThemeOptions, type UrlBuilderOptions, apiFetch, applyThemeParam, buildFrameUrl, createClientContext, createClientCore, createFrameOrchestrator, createIdentity, decryptCredentials, deletePaymentMethod, generateKeyPair, getIdentity, getIdentityUploadUrl, getPaymentMethods, getQuote, getTransaction, listTransactions, submitIdentityFiles, themeParams, updateIdentity, verifyIdentity };
package/dist/index.d.ts CHANGED
@@ -116,6 +116,27 @@ interface UrlBuilderOptions {
116
116
  }
117
117
  /** Build a frame URL with query parameters. */
118
118
  declare function buildFrameUrl(path: string, query?: Record<string, unknown>, options?: UrlBuilderOptions): string;
119
+ /** Theming options honoured by every visible MoonPay frame. */
120
+ interface ThemeOptions {
121
+ /**
122
+ * Frame appearance. Emitted as the `theme` query param that MoonPay frames
123
+ * read to render in light or dark mode. Defaults to the customer's system
124
+ * preference when omitted.
125
+ */
126
+ appearance?: 'light' | 'dark';
127
+ }
128
+ /**
129
+ * Query params for a theme, mapping `appearance` → the `theme` param the
130
+ * frames actually read. Returns `{}` when no appearance is set, so it spreads
131
+ * cleanly into a frame URL's query object.
132
+ */
133
+ declare function themeParams(theme?: ThemeOptions): Record<string, string>;
134
+ /**
135
+ * Set the `theme` query param on an already-built frame URL from a
136
+ * client-level theme — unless the URL already carries one, so a per-frame
137
+ * (or partner-embedded) theme always wins over the client default.
138
+ */
139
+ declare function applyThemeParam(url: string, theme?: ThemeOptions): string;
119
140
 
120
141
  interface CoreClientOptions extends ClientContextOptions, UrlBuilderOptions {
121
142
  /**
@@ -214,4 +235,4 @@ interface FrameHandle {
214
235
  */
215
236
  declare function createFrameOrchestrator(options: FrameOrchestratorOptions): Promise<FrameHandle>;
216
237
 
217
- export { type ClientContext, type ClientContextOptions, type CoreClient, type CoreClientOptions, FRAME_PATHS, type FrameHandle, type FrameOptions, type FrameOrchestratorOptions, type FrameTransport, type KeyPair, type ListTransactionsParams, type UrlBuilderOptions, apiFetch, buildFrameUrl, createClientContext, createClientCore, createFrameOrchestrator, createIdentity, decryptCredentials, deletePaymentMethod, generateKeyPair, getIdentity, getIdentityUploadUrl, getPaymentMethods, getQuote, getTransaction, listTransactions, submitIdentityFiles, updateIdentity, verifyIdentity };
238
+ export { type ClientContext, type ClientContextOptions, type CoreClient, type CoreClientOptions, FRAME_PATHS, type FrameHandle, type FrameOptions, type FrameOrchestratorOptions, type FrameTransport, type KeyPair, type ListTransactionsParams, type ThemeOptions, type UrlBuilderOptions, apiFetch, applyThemeParam, buildFrameUrl, createClientContext, createClientCore, createFrameOrchestrator, createIdentity, decryptCredentials, deletePaymentMethod, generateKeyPair, getIdentity, getIdentityUploadUrl, getPaymentMethods, getQuote, getTransaction, listTransactions, submitIdentityFiles, themeParams, updateIdentity, verifyIdentity };
package/dist/index.js CHANGED
@@ -1585,9 +1585,22 @@ function buildFrameUrl(path, query = {}, options = {}) {
1585
1585
  }
1586
1586
  return url.href;
1587
1587
  }
1588
+ function themeParams(theme) {
1589
+ return theme?.appearance ? { theme: theme.appearance } : {};
1590
+ }
1591
+ function applyThemeParam(url, theme) {
1592
+ if (!theme?.appearance)
1593
+ return url;
1594
+ const parsed = new URL(url);
1595
+ if (!parsed.searchParams.has("theme")) {
1596
+ parsed.searchParams.set("theme", theme.appearance);
1597
+ }
1598
+ return parsed.href;
1599
+ }
1588
1600
  export {
1589
1601
  FRAME_PATHS,
1590
1602
  apiFetch,
1603
+ applyThemeParam,
1591
1604
  buildFrameUrl,
1592
1605
  createClientContext,
1593
1606
  createClientCore,
@@ -1603,6 +1616,7 @@ export {
1603
1616
  getTransaction,
1604
1617
  listTransactions,
1605
1618
  submitIdentityFiles,
1619
+ themeParams,
1606
1620
  updateIdentity,
1607
1621
  verifyIdentity
1608
1622
  };