@whop/embedded-components-vanilla-js 1.0.0-beta.11 → 1.1.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/CHANGELOG.md +23 -0
- package/dist/lib/index.d.ts +169 -8
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @whop/embedded-components-vanilla-js
|
|
2
2
|
|
|
3
|
+
## 1.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b282677: add messageDeleted event to ChatElement
|
|
8
|
+
|
|
9
|
+
## 1.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 76d83c4: Add i18n translation support with 10 new locales (es, zh, nl, pt, de, it, fr, ja, pl, tr)
|
|
14
|
+
|
|
15
|
+
## 1.0.0
|
|
16
|
+
|
|
17
|
+
### Major Changes
|
|
18
|
+
|
|
19
|
+
- ea27ce0: New train: apollo
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 15f8c67: standardize embedded components class names for better styling capabilities
|
|
24
|
+
- @whop-core/embeddable-components@0.0.13
|
|
25
|
+
|
|
3
26
|
## 1.0.0-beta.11
|
|
4
27
|
|
|
5
28
|
### Major Changes
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const locales: readonly ["en"];
|
|
1
|
+
declare const locales: readonly ["en", "es", "zh", "nl", "pt", "de", "it", "fr", "ja", "pl", "tr"];
|
|
2
2
|
type I18nSupportedLocale = (typeof locales)[number];
|
|
3
3
|
|
|
4
4
|
type CustomEventDetail<F> = F extends (ev: CustomEvent<infer D>) => void ? D : never;
|
|
@@ -318,11 +318,19 @@ interface ChatElementEvents {
|
|
|
318
318
|
}>) => void;
|
|
319
319
|
/**
|
|
320
320
|
* Emitted when the user sends a message.
|
|
321
|
-
* @param ev - The event containing the `id` and `
|
|
321
|
+
* @param ev - The event containing the `id`, `content`, and `channelId` in `ev.detail`.
|
|
322
322
|
*/
|
|
323
323
|
messageSent: (ev: CustomEvent<{
|
|
324
324
|
id: string;
|
|
325
325
|
content: string;
|
|
326
|
+
channelId: string;
|
|
327
|
+
}>) => void;
|
|
328
|
+
/**
|
|
329
|
+
* Emitted when the user deletes a message.
|
|
330
|
+
* @param ev - The event containing the `id` in `ev.detail`.
|
|
331
|
+
*/
|
|
332
|
+
messageDeleted: (ev: CustomEvent<{
|
|
333
|
+
id: string;
|
|
326
334
|
}>) => void;
|
|
327
335
|
/**
|
|
328
336
|
* Emitted when the user clicks on an experience mention.
|
|
@@ -348,7 +356,7 @@ interface AttachmentClickEventAttachment {
|
|
|
348
356
|
width?: number;
|
|
349
357
|
height?: number;
|
|
350
358
|
}
|
|
351
|
-
declare const createTypedEvent$1: TypedEventCreatorFn<ChatElementEvents, "profileClick" | "linkClick" | "messageSent" | "experienceClick" | "attachmentClick">;
|
|
359
|
+
declare const createTypedEvent$1: TypedEventCreatorFn<ChatElementEvents, "profileClick" | "linkClick" | "messageSent" | "messageDeleted" | "experienceClick" | "attachmentClick">;
|
|
352
360
|
type ChatElementEvent = InferEvent<typeof createTypedEvent$1>;
|
|
353
361
|
/**
|
|
354
362
|
* Configuration options for the ChatElement.
|
|
@@ -365,7 +373,7 @@ type ChatElementEvent = InferEvent<typeof createTypedEvent$1>;
|
|
|
365
373
|
*/
|
|
366
374
|
interface ChatElementOptions {
|
|
367
375
|
/**
|
|
368
|
-
* The ID of the chat
|
|
376
|
+
* The ID of the channel, DM, or support chat to connect to.
|
|
369
377
|
*/
|
|
370
378
|
channelId: string;
|
|
371
379
|
/**
|
|
@@ -477,7 +485,11 @@ interface ChatElementSnapshot {
|
|
|
477
485
|
* });
|
|
478
486
|
*
|
|
479
487
|
* element.on("messageSent", (ev) => {
|
|
480
|
-
* console.log("Message sent:", ev.detail.id, ev.detail.content);
|
|
488
|
+
* console.log("Message sent:", ev.detail.id, ev.detail.content, ev.detail.channelId);
|
|
489
|
+
* });
|
|
490
|
+
*
|
|
491
|
+
* element.on("messageDeleted", (ev) => {
|
|
492
|
+
* console.log("Message deleted:", ev.detail.id);
|
|
481
493
|
* });
|
|
482
494
|
*
|
|
483
495
|
* element.on("experienceClick", (ev) => {
|
|
@@ -669,7 +681,7 @@ interface SearchElementOptions {
|
|
|
669
681
|
*/
|
|
670
682
|
companyId?: string;
|
|
671
683
|
/**
|
|
672
|
-
* The ID of the chat
|
|
684
|
+
* The ID of the channel, DM, or support chat to search messages in.
|
|
673
685
|
*/
|
|
674
686
|
channelId?: string;
|
|
675
687
|
/**
|
|
@@ -708,7 +720,7 @@ interface SearchElementSnapshot {
|
|
|
708
720
|
state: "loading" | "ready";
|
|
709
721
|
}
|
|
710
722
|
/**
|
|
711
|
-
* A UI element that allows users to search for messages in a chat
|
|
723
|
+
* A UI element that allows users to search for messages in a channel, DM, or support chat.
|
|
712
724
|
*
|
|
713
725
|
* @example Basic usage
|
|
714
726
|
* ```typescript
|
|
@@ -3727,6 +3739,145 @@ interface PayoutsSession extends TypedEmitter<PayoutsSessionEvents> {
|
|
|
3727
3739
|
showTreasuryBreakdownModal: <Force extends boolean = false>(options?: TreasuryBreakdownElementOptions | ((modal: ModalContainer) => TreasuryBreakdownElementOptions), force?: Force) => Force extends true ? ModalContainer : ModalContainer | undefined;
|
|
3728
3740
|
}
|
|
3729
3741
|
|
|
3742
|
+
interface WalletSessionOptions {
|
|
3743
|
+
/**
|
|
3744
|
+
* The token to use for the session. If a function is provided, it will be called and awaited to get the token.
|
|
3745
|
+
* When a function is provided, the token will be refreshed automatically before it expires.
|
|
3746
|
+
*
|
|
3747
|
+
* if a string is provided, it will be used as the token and not refreshed automatically. However you can update the token at runtime by
|
|
3748
|
+
* calling `updateOptions` with a new token.
|
|
3749
|
+
*
|
|
3750
|
+
* For v1, mint this token from your backend with the existing `whop.accessTokens.create({ company_id })` call —
|
|
3751
|
+
* the same approach used by `PayoutsSession`. A dedicated `wallet:*` scope set is on the roadmap.
|
|
3752
|
+
*
|
|
3753
|
+
* @example
|
|
3754
|
+
* ```ts
|
|
3755
|
+
* // with a static token
|
|
3756
|
+
* async function createWalletSession() {
|
|
3757
|
+
* const token = await fetch("/api/token")
|
|
3758
|
+
* .then(res => res.json())
|
|
3759
|
+
* .then(data => data.token)
|
|
3760
|
+
* return whopElements.createWalletSession({ token, companyId })
|
|
3761
|
+
* }
|
|
3762
|
+
*
|
|
3763
|
+
* // with a dynamic function
|
|
3764
|
+
* function createWalletSession() {
|
|
3765
|
+
* return whopElements.createWalletSession({
|
|
3766
|
+
* companyId,
|
|
3767
|
+
* token: () => fetch("/api/token")
|
|
3768
|
+
* .then(res => res.json())
|
|
3769
|
+
* .then(data => data.token),
|
|
3770
|
+
* })
|
|
3771
|
+
* }
|
|
3772
|
+
* ```
|
|
3773
|
+
*/
|
|
3774
|
+
token: Token | GetToken;
|
|
3775
|
+
/**
|
|
3776
|
+
* The company ID that owns the wallet.
|
|
3777
|
+
*
|
|
3778
|
+
* Accepts a `biz_*` ID. The wallet's underlying ledger account is resolved server-side from this value.
|
|
3779
|
+
* (A polymorphic `ledger_account_id` parameter is on the roadmap once `wallet:session:create` ships.)
|
|
3780
|
+
*/
|
|
3781
|
+
companyId: string;
|
|
3782
|
+
/**
|
|
3783
|
+
* The currency to format display amounts in.
|
|
3784
|
+
*
|
|
3785
|
+
* @default "USD"
|
|
3786
|
+
*/
|
|
3787
|
+
currency?: string;
|
|
3788
|
+
}
|
|
3789
|
+
interface ExpandedWalletSessionOptions extends WalletSessionOptions {
|
|
3790
|
+
}
|
|
3791
|
+
/**
|
|
3792
|
+
* Events emitted by the WalletSession.
|
|
3793
|
+
*
|
|
3794
|
+
* Listen to these events using the `on()` method.
|
|
3795
|
+
*/
|
|
3796
|
+
interface WalletSessionEvents {
|
|
3797
|
+
/**
|
|
3798
|
+
* Emitted when the session options are updated via `updateOptions()`.
|
|
3799
|
+
* @param options - The updated options object
|
|
3800
|
+
*/
|
|
3801
|
+
optionsUpdated: (options: ExpandedWalletSessionOptions) => void;
|
|
3802
|
+
/**
|
|
3803
|
+
* Emitted when the authentication token is refreshed.
|
|
3804
|
+
* @param token - The new token
|
|
3805
|
+
*/
|
|
3806
|
+
tokenRefreshed: (token: string) => void;
|
|
3807
|
+
/**
|
|
3808
|
+
* Emitted when token refresh fails.
|
|
3809
|
+
* @param error - The error that occurred
|
|
3810
|
+
*/
|
|
3811
|
+
tokenRefreshError: (error: unknown) => void;
|
|
3812
|
+
/**
|
|
3813
|
+
* Emitted when an error occurs during session operation.
|
|
3814
|
+
* @param error - The error that occurred
|
|
3815
|
+
*/
|
|
3816
|
+
error: (error: unknown) => void;
|
|
3817
|
+
/**
|
|
3818
|
+
* Emitted when the session is ready and authenticated.
|
|
3819
|
+
*/
|
|
3820
|
+
ready: () => void;
|
|
3821
|
+
}
|
|
3822
|
+
/**
|
|
3823
|
+
* Element registry for WalletSession.
|
|
3824
|
+
*
|
|
3825
|
+
* Empty for the foundation scaffold — wallet-element, send-element, onramp-element, convert-element
|
|
3826
|
+
* are added in follow-up PRs. Each entry is `[Options, ElementInstance]`.
|
|
3827
|
+
*/
|
|
3828
|
+
type WalletSessionElements = {};
|
|
3829
|
+
/**
|
|
3830
|
+
* Manages authentication and creates wallet elements.
|
|
3831
|
+
*
|
|
3832
|
+
* The WalletSession handles token management, element creation, and provides
|
|
3833
|
+
* convenience methods for showing wallet elements in modals.
|
|
3834
|
+
*
|
|
3835
|
+
* For v1, mint the token via the existing `whop.accessTokens.create({ company_id })` flow —
|
|
3836
|
+
* the same backend mutation that powers `PayoutsSession`. No new mutation is required.
|
|
3837
|
+
*
|
|
3838
|
+
* @example Basic usage
|
|
3839
|
+
* ```typescript
|
|
3840
|
+
* const session = whopElements.createWalletSession({
|
|
3841
|
+
* companyId: "biz_xxx",
|
|
3842
|
+
* token: async () => {
|
|
3843
|
+
* const response = await fetch("/api/wallet-token");
|
|
3844
|
+
* const data = await response.json();
|
|
3845
|
+
* return data.token;
|
|
3846
|
+
* },
|
|
3847
|
+
* });
|
|
3848
|
+
*
|
|
3849
|
+
* session.on("ready", () => {
|
|
3850
|
+
* console.log("Wallet session is ready");
|
|
3851
|
+
* });
|
|
3852
|
+
* ```
|
|
3853
|
+
*/
|
|
3854
|
+
interface WalletSession extends TypedEmitter<WalletSessionEvents> {
|
|
3855
|
+
/**
|
|
3856
|
+
* Update the session options after initialization.
|
|
3857
|
+
*
|
|
3858
|
+
* Changes will be propagated to all active elements.
|
|
3859
|
+
*
|
|
3860
|
+
* @param options - Partial options object with the values to update
|
|
3861
|
+
*/
|
|
3862
|
+
updateOptions: (options: Partial<WalletSessionOptions>) => void;
|
|
3863
|
+
/**
|
|
3864
|
+
* Destroy the session and clean up all mounted elements.
|
|
3865
|
+
*
|
|
3866
|
+
* Call this when you no longer need the session to free up resources.
|
|
3867
|
+
*/
|
|
3868
|
+
destroy: () => void;
|
|
3869
|
+
/**
|
|
3870
|
+
* Create a new element instance.
|
|
3871
|
+
*
|
|
3872
|
+
* @param type - The element type
|
|
3873
|
+
* @param options - Element-specific configuration options
|
|
3874
|
+
* @returns The created element instance
|
|
3875
|
+
*/
|
|
3876
|
+
createElement<T extends keyof WalletSessionElements>(type: T | {
|
|
3877
|
+
type: T;
|
|
3878
|
+
}, options: WalletSessionElements[T] extends [infer O, unknown] ? O : never): WalletSessionElements[T] extends [unknown, infer E] ? E : never;
|
|
3879
|
+
}
|
|
3880
|
+
|
|
3730
3881
|
declare global {
|
|
3731
3882
|
interface Window {
|
|
3732
3883
|
WhopElements: WhopElementsConstructor;
|
|
@@ -3848,6 +3999,16 @@ interface WhopElements extends TypedEmitter<WhopElementsEvents> {
|
|
|
3848
3999
|
* @returns A ChatSession instance for creating chat elements
|
|
3849
4000
|
*/
|
|
3850
4001
|
createChatSession: (options: ChatSessionOptions) => ChatSession;
|
|
4002
|
+
/**
|
|
4003
|
+
* Create a new wallet session for managing wallet elements.
|
|
4004
|
+
*
|
|
4005
|
+
* The session handles authentication and provides methods to create
|
|
4006
|
+
* wallet-related elements like balance displays, send/receive flows, and conversions.
|
|
4007
|
+
*
|
|
4008
|
+
* @param options - Configuration options for the wallet session
|
|
4009
|
+
* @returns A WalletSession instance for creating wallet elements
|
|
4010
|
+
*/
|
|
4011
|
+
createWalletSession: (options: WalletSessionOptions) => WalletSession;
|
|
3851
4012
|
/**
|
|
3852
4013
|
* Update the WhopElements configuration after initialization.
|
|
3853
4014
|
*
|
|
@@ -3875,4 +4036,4 @@ interface WhopElementsEvents {
|
|
|
3875
4036
|
optionsUpdated: (options: WhopElementsOptions) => void;
|
|
3876
4037
|
}
|
|
3877
4038
|
|
|
3878
|
-
export { type AddPayoutMethodElement, type AddPayoutMethodElementOptions, type AddPayoutMethodElementSnapshot, type Appearance, type AutomaticWithdrawElement, type AutomaticWithdrawElementOptions, type AutomaticWithdrawElementSnapshot, type AvailableCashBreakdownElement, type AvailableCashBreakdownElementOptions, type AvailableCashBreakdownElementSnapshot, type BalanceElement, type BalanceElementOptions, type BalanceElementSnapshot, type BalancesElement, type BalancesElementOptions, type BalancesElementSnapshot, type ChangeAccountCountryElement, type ChangeAccountCountryElementOptions, type ChangeAccountCountryElementSnapshot, type ChatElement, type ChatElementEvent, type ChatElementOptions, type ChatElementSnapshot, type ChatSession, type ChatSessionElements, type ChatSessionEvents, type ChatSessionOptions, type DmsListElement, type DmsListElementEvent, type DmsListElementOptions, type DmsListElementSnapshot, type ExpandedChatSessionOptions, type ExpandedPayoutsSessionOptions, type GenerateWithdrawalReceiptElement, type GenerateWithdrawalReceiptElementOptions, type GenerateWithdrawalReceiptElementSnapshot, type I18nSupportedLocale, type PayoutsSession, type PayoutsSessionElements, type PayoutsSessionEvents, type PayoutsSessionOptions, type PendingBreakdownElement, type PendingBreakdownElementOptions, type PendingBreakdownElementSnapshot, type ReserveBreakdownElement, type ReserveBreakdownElementOptions, type ReserveBreakdownElementSnapshot, type ResetAccountElement, type ResetAccountElementOptions, type ResetAccountElementSnapshot, type SearchElement, type SearchElementOptions, type SearchElementSnapshot, type StatusBannerElement, type StatusBannerElementOptions, type StatusBannerElementSnapshot, type StatusBannerType, type TreasuryBreakdownElement, type TreasuryBreakdownElementOptions, type TreasuryBreakdownElementSnapshot, type VerifyElement, type VerifyElementOptions, type VerifyElementSnapshot, type WhopElement, WhopElementError, type WhopElementErrorCode, type WhopElements, type WhopElementsConstructor, type WhopElementsEnvironment, type WhopElementsEvents, type WhopElementsOptions, type WithdrawButtonElement, type WithdrawButtonElementOptions, type WithdrawElement, type WithdrawElementOptions, type WithdrawElementSnapshot, type WithdrawalBreakdownElement, type WithdrawalBreakdownElementOptions, type WithdrawalBreakdownElementSnapshot, type WithdrawalsElement, type WithdrawalsElementOptions, type WithdrawalsElementSnapshot };
|
|
4039
|
+
export { type AddPayoutMethodElement, type AddPayoutMethodElementOptions, type AddPayoutMethodElementSnapshot, type Appearance, type AutomaticWithdrawElement, type AutomaticWithdrawElementOptions, type AutomaticWithdrawElementSnapshot, type AvailableCashBreakdownElement, type AvailableCashBreakdownElementOptions, type AvailableCashBreakdownElementSnapshot, type BalanceElement, type BalanceElementOptions, type BalanceElementSnapshot, type BalancesElement, type BalancesElementOptions, type BalancesElementSnapshot, type ChangeAccountCountryElement, type ChangeAccountCountryElementOptions, type ChangeAccountCountryElementSnapshot, type ChatElement, type ChatElementEvent, type ChatElementOptions, type ChatElementSnapshot, type ChatSession, type ChatSessionElements, type ChatSessionEvents, type ChatSessionOptions, type DmsListElement, type DmsListElementEvent, type DmsListElementOptions, type DmsListElementSnapshot, type ExpandedChatSessionOptions, type ExpandedPayoutsSessionOptions, type ExpandedWalletSessionOptions, type GenerateWithdrawalReceiptElement, type GenerateWithdrawalReceiptElementOptions, type GenerateWithdrawalReceiptElementSnapshot, type I18nSupportedLocale, type PayoutsSession, type PayoutsSessionElements, type PayoutsSessionEvents, type PayoutsSessionOptions, type PendingBreakdownElement, type PendingBreakdownElementOptions, type PendingBreakdownElementSnapshot, type ReserveBreakdownElement, type ReserveBreakdownElementOptions, type ReserveBreakdownElementSnapshot, type ResetAccountElement, type ResetAccountElementOptions, type ResetAccountElementSnapshot, type SearchElement, type SearchElementOptions, type SearchElementSnapshot, type StatusBannerElement, type StatusBannerElementOptions, type StatusBannerElementSnapshot, type StatusBannerType, type TreasuryBreakdownElement, type TreasuryBreakdownElementOptions, type TreasuryBreakdownElementSnapshot, type VerifyElement, type VerifyElementOptions, type VerifyElementSnapshot, type WalletSession, type WalletSessionElements, type WalletSessionEvents, type WalletSessionOptions, type WhopElement, WhopElementError, type WhopElementErrorCode, type WhopElements, type WhopElementsConstructor, type WhopElementsEnvironment, type WhopElementsEvents, type WhopElementsOptions, type WithdrawButtonElement, type WithdrawButtonElementOptions, type WithdrawElement, type WithdrawElementOptions, type WithdrawElementSnapshot, type WithdrawalBreakdownElement, type WithdrawalBreakdownElementOptions, type WithdrawalBreakdownElementSnapshot, type WithdrawalsElement, type WithdrawalsElementOptions, type WithdrawalsElementSnapshot };
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whop/embedded-components-vanilla-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Whop Elements loading utility",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.mjs",
|
|
7
|
-
"jsnext:main": "dist/index.mjs",
|
|
8
|
-
"types": "dist/index.d.ts",
|
|
9
|
-
"typing": "dist/index.d.ts",
|
|
10
5
|
"keywords": [
|
|
6
|
+
"Elements",
|
|
11
7
|
"Whop",
|
|
12
8
|
"Whop.js",
|
|
13
|
-
"Elements",
|
|
14
9
|
"embedded",
|
|
15
10
|
"payments",
|
|
16
11
|
"payouts"
|
|
17
12
|
],
|
|
18
|
-
"author": "Whop (https://whop.com)",
|
|
19
13
|
"license": "MIT",
|
|
14
|
+
"author": "Whop (https://whop.com)",
|
|
15
|
+
"main": "dist/index.js",
|
|
16
|
+
"module": "dist/index.mjs",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"jsnext:main": "dist/index.mjs",
|
|
20
19
|
"publishConfig": {
|
|
21
20
|
"access": "public"
|
|
22
|
-
}
|
|
21
|
+
},
|
|
22
|
+
"typing": "dist/index.d.ts"
|
|
23
23
|
}
|