@whop/embedded-components-react-js 1.1.1 → 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/CHANGELOG.md +11 -0
- package/dist/chat/elements/chat.d.ts +1 -1
- package/dist/chat/elements/dms-list.d.ts +1 -1
- package/dist/chat/elements/index.d.ts +2 -2
- package/dist/chat/elements/search-element.d.ts +1 -1
- package/dist/chat/index.d.ts +2 -2
- package/dist/chat/with-fallback.d.ts +6 -47
- package/dist/chat/with-fallback.js +2 -59
- package/dist/chat/with-fallback.js.map +1 -1
- package/dist/chat/with-fallback.mjs +2 -54
- package/dist/chat/with-fallback.mjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/lib/create-with-fallback.d.ts +51 -0
- package/dist/lib/create-with-fallback.js +89 -0
- package/dist/lib/create-with-fallback.js.map +1 -0
- package/dist/lib/create-with-fallback.mjs +59 -0
- package/dist/lib/create-with-fallback.mjs.map +1 -0
- package/dist/payouts/elements/add-payout-method.d.ts +1 -1
- package/dist/payouts/elements/automatic-withdraw.d.ts +1 -1
- package/dist/payouts/elements/available-cash-breakdown.d.ts +1 -1
- package/dist/payouts/elements/balance.d.ts +1 -1
- package/dist/payouts/elements/balances.d.ts +1 -1
- package/dist/payouts/elements/change-account-country.d.ts +1 -1
- package/dist/payouts/elements/generate-withdrawal-receipt.d.ts +1 -1
- package/dist/payouts/elements/index.d.ts +2 -2
- package/dist/payouts/elements/pending-breakdown.d.ts +1 -1
- package/dist/payouts/elements/reserve-breakdown.d.ts +1 -1
- package/dist/payouts/elements/reset-account.d.ts +1 -1
- package/dist/payouts/elements/treasury-breakdown.d.ts +1 -1
- package/dist/payouts/elements/verify.d.ts +1 -1
- package/dist/payouts/elements/withdraw-button.d.ts +1 -1
- package/dist/payouts/elements/withdraw.d.ts +1 -1
- package/dist/payouts/elements/withdrawal-breakdown.d.ts +1 -1
- package/dist/payouts/elements/withdrawals.d.ts +1 -1
- package/dist/payouts/index.d.ts +1 -1
- package/dist/payouts/with-fallback.d.ts +6 -47
- package/dist/payouts/with-fallback.js +2 -59
- package/dist/payouts/with-fallback.js.map +1 -1
- package/dist/payouts/with-fallback.mjs +2 -54
- package/dist/payouts/with-fallback.mjs.map +1 -1
- package/dist/wallet/elements/deposit.d.ts +11 -0
- package/dist/wallet/elements/deposit.js +30 -0
- package/dist/wallet/elements/deposit.js.map +1 -0
- package/dist/wallet/elements/deposit.mjs +8 -0
- package/dist/wallet/elements/deposit.mjs.map +1 -0
- package/dist/wallet/elements/index.d.ts +4 -0
- package/dist/wallet/elements/index.js +25 -0
- package/dist/wallet/elements/index.js.map +1 -0
- package/dist/wallet/elements/index.mjs +3 -0
- package/dist/wallet/elements/index.mjs.map +1 -0
- package/dist/wallet/index.d.ts +3 -1
- package/dist/wallet/index.js +1 -0
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +1 -0
- package/dist/wallet/index.mjs.map +1 -1
- package/dist/wallet/with-fallback.d.ts +14 -0
- package/dist/wallet/with-fallback.js +28 -0
- package/dist/wallet/with-fallback.js.map +1 -0
- package/dist/wallet/with-fallback.mjs +6 -0
- package/dist/wallet/with-fallback.mjs.map +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @whop/embedded-components-react-js
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 4e3a97c: New wallet deposit element: `session.createElement("deposit-element")` / `session.showDepositModal()` on the wallet session, and `<DepositElement />` in the React package. Renders the whop.com deposit flow inline — amount entry, bank transfer instructions, and per-network crypto deposit addresses.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [4e3a97c]
|
|
12
|
+
- @whop/embedded-components-vanilla-js@1.2.0
|
|
13
|
+
|
|
3
14
|
## 1.1.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsRequired } from '
|
|
1
|
+
import { WithFallbackPropsRequired } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsOptional } from '
|
|
1
|
+
import { WithFallbackPropsOptional } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ChatElement } from './chat.js';
|
|
2
2
|
export { DmsListElement } from './dms-list.js';
|
|
3
3
|
export { SearchElement } from './search-element.js';
|
|
4
|
-
import '
|
|
5
|
-
import '@whop/embedded-components-vanilla-js/types';
|
|
4
|
+
import '../../lib/create-with-fallback.js';
|
|
6
5
|
import 'react';
|
|
6
|
+
import '@whop/embedded-components-vanilla-js/types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsOptional } from '
|
|
1
|
+
import { WithFallbackPropsOptional } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
package/dist/chat/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export { ChatElement } from './elements/chat.js';
|
|
|
2
2
|
export { DmsListElement } from './elements/dms-list.js';
|
|
3
3
|
export { SearchElement } from './elements/search-element.js';
|
|
4
4
|
export { ChatSession, useChatSession } from './session.js';
|
|
5
|
-
import '
|
|
6
|
-
import '@whop/embedded-components-vanilla-js/types';
|
|
5
|
+
import '../lib/create-with-fallback.js';
|
|
7
6
|
import 'react';
|
|
7
|
+
import '@whop/embedded-components-vanilla-js/types';
|
|
@@ -1,55 +1,14 @@
|
|
|
1
|
+
import { WithFallbackPropsRequired, WithFallbackPropsOptional } from '../lib/create-with-fallback.js';
|
|
1
2
|
import { ChatSessionElements } from '@whop/embedded-components-vanilla-js/types';
|
|
2
|
-
import
|
|
3
|
+
import 'react';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
* Valid element type strings that can be passed to createElement.
|
|
6
|
-
*/
|
|
7
|
-
type ElementType = keyof ChatSessionElements;
|
|
8
|
-
/**
|
|
9
|
-
* Extract the options type for a given element type using indexed access.
|
|
10
|
-
* PayoutsSessionElements maps element types to [Options, Element] tuples.
|
|
11
|
-
*/
|
|
12
|
-
type ElementOptionsFor<T extends ElementType> = ChatSessionElements[T][0];
|
|
13
|
-
/**
|
|
14
|
-
* Component definition with a constrained element type.
|
|
15
|
-
* The type must be a valid element type from the SDK.
|
|
16
|
-
*/
|
|
17
|
-
interface ElementComponentDefinition<T extends ElementType = ElementType> {
|
|
5
|
+
declare const withFallback: <const T extends "chat-element" | "dms-list-element" | "search-element", TRequired extends boolean = false>(Component: {
|
|
18
6
|
displayName: string;
|
|
19
7
|
type: T;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
className?: string;
|
|
23
|
-
style?: React__default.CSSProperties;
|
|
24
|
-
onReady?: () => void;
|
|
25
|
-
fallback?: React__default.ReactNode;
|
|
26
|
-
}
|
|
27
|
-
interface WithFallbackPropsRequired<TOptions> extends WithFallbackPropsBase {
|
|
28
|
-
options: TOptions;
|
|
29
|
-
}
|
|
30
|
-
interface WithFallbackPropsOptional<TOptions> extends WithFallbackPropsBase {
|
|
31
|
-
options?: TOptions;
|
|
32
|
-
}
|
|
33
|
-
type WithFallbackComponent<TOptions, TRequired extends boolean> = {
|
|
34
|
-
(props: TRequired extends true ? WithFallbackPropsRequired<TOptions> : WithFallbackPropsOptional<TOptions>): React__default.ReactNode;
|
|
8
|
+
}) => {
|
|
9
|
+
(props: TRequired extends true ? WithFallbackPropsRequired<ChatSessionElements[T][0]> : WithFallbackPropsOptional<ChatSessionElements[T][0]>): React.ReactNode;
|
|
35
10
|
displayName: string;
|
|
36
11
|
type: string;
|
|
37
12
|
};
|
|
38
|
-
/**
|
|
39
|
-
* Creates a React component that wraps an embedded element with fallback support.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```tsx
|
|
43
|
-
* // Type-safe: options type is inferred from the element type
|
|
44
|
-
* export const ChatElement = withFallback({
|
|
45
|
-
* displayName: "ChatElement",
|
|
46
|
-
* type: "chat-element",
|
|
47
|
-
* } as const);
|
|
48
|
-
*
|
|
49
|
-
* // Usage - TypeScript knows the correct options type
|
|
50
|
-
* <ChatElement options={{ channelId: "channel_xxx" }} />
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
declare function withFallback<const T extends ElementType, TRequired extends boolean = false>(Component: ElementComponentDefinition<T>): WithFallbackComponent<ElementOptionsFor<T>, TRequired>;
|
|
54
13
|
|
|
55
|
-
export {
|
|
14
|
+
export { WithFallbackPropsOptional, WithFallbackPropsRequired, withFallback };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
|
-
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
7
|
var __export = (target, all) => {
|
|
10
8
|
for (var name in all)
|
|
@@ -18,68 +16,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
16
|
}
|
|
19
17
|
return to;
|
|
20
18
|
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
20
|
var with_fallback_exports = {};
|
|
31
21
|
__export(with_fallback_exports, {
|
|
32
22
|
withFallback: () => withFallback
|
|
33
23
|
});
|
|
34
24
|
module.exports = __toCommonJS(with_fallback_exports);
|
|
35
|
-
var
|
|
36
|
-
var import_use_element_snapshot = require("../lib/use-element-snapshot");
|
|
25
|
+
var import_create_with_fallback = require("../lib/create-with-fallback");
|
|
37
26
|
var import_session = require("./session");
|
|
38
|
-
|
|
39
|
-
function WrappedElement({
|
|
40
|
-
options,
|
|
41
|
-
className,
|
|
42
|
-
style,
|
|
43
|
-
onReady,
|
|
44
|
-
fallback
|
|
45
|
-
}) {
|
|
46
|
-
const chatSession = (0, import_session.useChatSession)();
|
|
47
|
-
const ref = (0, import_react.useRef)(null);
|
|
48
|
-
const element = (0, import_react.useMemo)(() => {
|
|
49
|
-
if (!chatSession) return null;
|
|
50
|
-
return chatSession.createElement(Component, options ?? {});
|
|
51
|
-
}, [chatSession]);
|
|
52
|
-
const elementSnapshot = (0, import_use_element_snapshot.useElementSnapshot)(element);
|
|
53
|
-
const isReady = elementSnapshot?.state === "ready";
|
|
54
|
-
(0, import_react.useEffect)(() => {
|
|
55
|
-
if (!element) return;
|
|
56
|
-
element.updateOptions(options ?? {});
|
|
57
|
-
}, [options, element]);
|
|
58
|
-
(0, import_react.useEffect)(() => {
|
|
59
|
-
if (!element || !onReady) return;
|
|
60
|
-
element.on("ready", onReady);
|
|
61
|
-
return () => {
|
|
62
|
-
element.off("ready", onReady);
|
|
63
|
-
};
|
|
64
|
-
}, [element, onReady]);
|
|
65
|
-
(0, import_react.useLayoutEffect)(() => {
|
|
66
|
-
if (!element || !ref.current) return;
|
|
67
|
-
element.mount(ref.current);
|
|
68
|
-
return () => {
|
|
69
|
-
element.unmount();
|
|
70
|
-
};
|
|
71
|
-
}, [element, ref.current]);
|
|
72
|
-
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
|
|
73
|
-
"div",
|
|
74
|
-
{
|
|
75
|
-
style: { ...style, visibility: isReady ? void 0 : "hidden" },
|
|
76
|
-
className,
|
|
77
|
-
ref
|
|
78
|
-
}
|
|
79
|
-
), !isReady && (fallback ?? null));
|
|
80
|
-
}
|
|
81
|
-
WrappedElement.displayName = Component.displayName;
|
|
82
|
-
WrappedElement.type = Component.type;
|
|
83
|
-
return WrappedElement;
|
|
84
|
-
}
|
|
27
|
+
const withFallback = (0, import_create_with_fallback.createWithFallback)(import_session.useChatSession);
|
|
85
28
|
//# sourceMappingURL=with-fallback.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/chat/with-fallback.tsx"],"sourcesContent":["\"use client\";\n\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/chat/with-fallback.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ChatSessionElements } from \"@whop/embedded-components-vanilla-js/types\";\n\nimport { createWithFallback } from \"../lib/create-with-fallback\";\nimport { useChatSession } from \"./session\";\n\nexport type {\n\tWithFallbackPropsOptional,\n\tWithFallbackPropsRequired,\n} from \"../lib/create-with-fallback\";\n\nexport const withFallback =\n\tcreateWithFallback<ChatSessionElements>(useChatSession);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kCAAmC;AACnC,qBAA+B;AAOxB,MAAM,mBACZ,gDAAwC,6BAAc;","names":[]}
|
|
@@ -1,58 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../chunk-NSSMTXJJ.mjs";
|
|
3
|
-
import
|
|
4
|
-
import { useElementSnapshot } from "../lib/use-element-snapshot.mjs";
|
|
3
|
+
import { createWithFallback } from "../lib/create-with-fallback.mjs";
|
|
5
4
|
import { useChatSession } from "./session.mjs";
|
|
6
|
-
|
|
7
|
-
function WrappedElement({ options, className, style, onReady, fallback }) {
|
|
8
|
-
const chatSession = useChatSession();
|
|
9
|
-
const ref = useRef(null);
|
|
10
|
-
const element = useMemo(()=>{
|
|
11
|
-
if (!chatSession) return null;
|
|
12
|
-
return chatSession.createElement(Component, options ?? {});
|
|
13
|
-
}, [
|
|
14
|
-
chatSession
|
|
15
|
-
]);
|
|
16
|
-
const elementSnapshot = useElementSnapshot(element);
|
|
17
|
-
const isReady = elementSnapshot?.state === "ready";
|
|
18
|
-
useEffect(()=>{
|
|
19
|
-
if (!element) return;
|
|
20
|
-
element.updateOptions(options ?? {});
|
|
21
|
-
}, [
|
|
22
|
-
options,
|
|
23
|
-
element
|
|
24
|
-
]);
|
|
25
|
-
useEffect(()=>{
|
|
26
|
-
if (!element || !onReady) return;
|
|
27
|
-
element.on("ready", onReady);
|
|
28
|
-
return ()=>{
|
|
29
|
-
element.off("ready", onReady);
|
|
30
|
-
};
|
|
31
|
-
}, [
|
|
32
|
-
element,
|
|
33
|
-
onReady
|
|
34
|
-
]);
|
|
35
|
-
useLayoutEffect(()=>{
|
|
36
|
-
if (!element || !ref.current) return;
|
|
37
|
-
element.mount(ref.current);
|
|
38
|
-
return ()=>{
|
|
39
|
-
element.unmount();
|
|
40
|
-
};
|
|
41
|
-
}, [
|
|
42
|
-
element,
|
|
43
|
-
ref.current
|
|
44
|
-
]);
|
|
45
|
-
return React.createElement(React.Fragment, null, React.createElement("div", {
|
|
46
|
-
style: {
|
|
47
|
-
...style,
|
|
48
|
-
visibility: isReady ? void 0 : "hidden"
|
|
49
|
-
},
|
|
50
|
-
className,
|
|
51
|
-
ref
|
|
52
|
-
}), !isReady && (fallback ?? null));
|
|
53
|
-
}
|
|
54
|
-
WrappedElement.displayName = Component.displayName;
|
|
55
|
-
WrappedElement.type = Component.type;
|
|
56
|
-
return WrappedElement;
|
|
57
|
-
}
|
|
5
|
+
const withFallback = createWithFallback(useChatSession);
|
|
58
6
|
export { withFallback };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/chat/with-fallback.tsx"],"sourcesContent":["\"use client\";\n\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/chat/with-fallback.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ChatSessionElements } from \"@whop/embedded-components-vanilla-js/types\";\n\nimport { createWithFallback } from \"../lib/create-with-fallback\";\nimport { useChatSession } from \"./session\";\n\nexport type {\n\tWithFallbackPropsOptional,\n\tWithFallbackPropsRequired,\n} from \"../lib/create-with-fallback\";\n\nexport const withFallback =\n\tcreateWithFallback<ChatSessionElements>(useChatSession);\n"],"mappings":";;AAIA,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAOxB,MAAM,eACZ,mBAAwC,cAAc;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -22,10 +22,10 @@ export { DmsListElement } from './chat/elements/dms-list.js';
|
|
|
22
22
|
export { SearchElement } from './chat/elements/search-element.js';
|
|
23
23
|
export { ChatSession, useChatSession } from './chat/session.js';
|
|
24
24
|
export { useChatSessionRef } from './chat/use-session-ref.js';
|
|
25
|
+
export { DepositElement } from './wallet/elements/deposit.js';
|
|
25
26
|
export { WalletSession, useWalletSession } from './wallet/session.js';
|
|
26
27
|
export { useWalletSessionRef } from './wallet/use-session-ref.js';
|
|
27
28
|
export { Elements, useElements } from './provider.js';
|
|
28
29
|
import '@whop/embedded-components-vanilla-js/types';
|
|
29
30
|
import 'react';
|
|
30
|
-
import './
|
|
31
|
-
import './chat/with-fallback.js';
|
|
31
|
+
import './lib/create-with-fallback.js';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The minimal session surface the wrapper needs — the registry-typed
|
|
5
|
+
* createElement every session exposes.
|
|
6
|
+
*/
|
|
7
|
+
interface SessionLike<Registry extends Record<string, [unknown, unknown]>> {
|
|
8
|
+
createElement<T extends keyof Registry>(type: T | {
|
|
9
|
+
type: T;
|
|
10
|
+
}, options: Registry[T][0]): unknown;
|
|
11
|
+
}
|
|
12
|
+
interface WithFallbackPropsBase {
|
|
13
|
+
className?: string;
|
|
14
|
+
style?: React__default.CSSProperties;
|
|
15
|
+
onReady?: () => void;
|
|
16
|
+
fallback?: React__default.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
interface WithFallbackPropsRequired<TOptions> extends WithFallbackPropsBase {
|
|
19
|
+
options: TOptions;
|
|
20
|
+
}
|
|
21
|
+
interface WithFallbackPropsOptional<TOptions> extends WithFallbackPropsBase {
|
|
22
|
+
options?: TOptions;
|
|
23
|
+
}
|
|
24
|
+
type WithFallbackComponent<TOptions, TRequired extends boolean> = {
|
|
25
|
+
(props: TRequired extends true ? WithFallbackPropsRequired<TOptions> : WithFallbackPropsOptional<TOptions>): React__default.ReactNode;
|
|
26
|
+
displayName: string;
|
|
27
|
+
type: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Builds a namespace-specific `withFallback` from that namespace's session
|
|
31
|
+
* hook. The returned helper creates a React component that wraps an embedded
|
|
32
|
+
* element with fallback support.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* // src/wallet/with-fallback.tsx
|
|
37
|
+
* export const withFallback = createWithFallback<WalletSessionElements>(useWalletSession);
|
|
38
|
+
*
|
|
39
|
+
* // src/wallet/elements/deposit.tsx — options type inferred from the element type
|
|
40
|
+
* export const DepositElement = withFallback({
|
|
41
|
+
* displayName: "DepositElement",
|
|
42
|
+
* type: "deposit-element",
|
|
43
|
+
* } as const);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare function createWithFallback<Registry extends Record<string, [unknown, unknown]>>(useSession: () => SessionLike<Registry> | null): <const T extends keyof Registry & string, TRequired extends boolean = false>(Component: {
|
|
47
|
+
displayName: string;
|
|
48
|
+
type: T;
|
|
49
|
+
}) => WithFallbackComponent<Registry[T][0], TRequired>;
|
|
50
|
+
|
|
51
|
+
export { type WithFallbackPropsOptional, type WithFallbackPropsRequired, createWithFallback };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var create_with_fallback_exports = {};
|
|
31
|
+
__export(create_with_fallback_exports, {
|
|
32
|
+
createWithFallback: () => createWithFallback
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(create_with_fallback_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_use_element_snapshot = require("./use-element-snapshot");
|
|
37
|
+
function createWithFallback(useSession) {
|
|
38
|
+
return function withFallback(Component) {
|
|
39
|
+
function WrappedElement({
|
|
40
|
+
options,
|
|
41
|
+
className,
|
|
42
|
+
style,
|
|
43
|
+
onReady,
|
|
44
|
+
fallback
|
|
45
|
+
}) {
|
|
46
|
+
const session = useSession();
|
|
47
|
+
const ref = (0, import_react.useRef)(null);
|
|
48
|
+
const element = (0, import_react.useMemo)(() => {
|
|
49
|
+
if (!session) return null;
|
|
50
|
+
return session.createElement(
|
|
51
|
+
Component,
|
|
52
|
+
options ?? {}
|
|
53
|
+
);
|
|
54
|
+
}, [session]);
|
|
55
|
+
const elementSnapshot = (0, import_use_element_snapshot.useElementSnapshot)(element);
|
|
56
|
+
const isReady = elementSnapshot?.state === "ready";
|
|
57
|
+
(0, import_react.useEffect)(() => {
|
|
58
|
+
if (!element) return;
|
|
59
|
+
element.updateOptions(options ?? {});
|
|
60
|
+
}, [options, element]);
|
|
61
|
+
(0, import_react.useEffect)(() => {
|
|
62
|
+
if (!element || !onReady) return;
|
|
63
|
+
element.on("ready", onReady);
|
|
64
|
+
return () => {
|
|
65
|
+
element.off("ready", onReady);
|
|
66
|
+
};
|
|
67
|
+
}, [element, onReady]);
|
|
68
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
69
|
+
if (!element || !ref.current) return;
|
|
70
|
+
element.mount(ref.current);
|
|
71
|
+
return () => {
|
|
72
|
+
element.unmount();
|
|
73
|
+
};
|
|
74
|
+
}, [element, ref.current]);
|
|
75
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
|
|
76
|
+
"div",
|
|
77
|
+
{
|
|
78
|
+
style: { ...style, visibility: isReady ? void 0 : "hidden" },
|
|
79
|
+
className,
|
|
80
|
+
ref
|
|
81
|
+
}
|
|
82
|
+
), !isReady && (fallback ?? null));
|
|
83
|
+
}
|
|
84
|
+
WrappedElement.displayName = Component.displayName;
|
|
85
|
+
WrappedElement.type = Component.type;
|
|
86
|
+
return WrappedElement;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=create-with-fallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/create-with-fallback.tsx"],"sourcesContent":["\"use client\";\n\nimport type { WhopElement } from \"@whop/embedded-components-vanilla-js/types\";\nimport React, { useEffect, useLayoutEffect, useMemo, useRef } from \"react\";\nimport { useElementSnapshot } from \"./use-element-snapshot\";\n\n/**\n * Base element type that all created elements conform to.\n * Using WhopElement<any, any, any> gives us access to common methods\n * (mount, unmount, on, off, updateOptions) without union type issues.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype BaseElement = WhopElement<any, any, any>;\n\n/**\n * The minimal session surface the wrapper needs — the registry-typed\n * createElement every session exposes.\n */\ninterface SessionLike<Registry extends Record<string, [unknown, unknown]>> {\n\tcreateElement<T extends keyof Registry>(\n\t\ttype: T | { type: T },\n\t\toptions: Registry[T][0],\n\t): unknown;\n}\n\ninterface WithFallbackPropsBase {\n\tclassName?: string;\n\tstyle?: React.CSSProperties;\n\tonReady?: () => void;\n\tfallback?: React.ReactNode;\n}\n\nexport interface WithFallbackPropsRequired<\n\tTOptions,\n> extends WithFallbackPropsBase {\n\toptions: TOptions;\n}\n\nexport interface WithFallbackPropsOptional<\n\tTOptions,\n> extends WithFallbackPropsBase {\n\toptions?: TOptions;\n}\n\ntype WithFallbackComponent<TOptions, TRequired extends boolean> = {\n\t(\n\t\tprops: TRequired extends true\n\t\t\t? WithFallbackPropsRequired<TOptions>\n\t\t\t: WithFallbackPropsOptional<TOptions>,\n\t): React.ReactNode;\n\tdisplayName: string;\n\ttype: string;\n};\n\n/**\n * Builds a namespace-specific `withFallback` from that namespace's session\n * hook. The returned helper creates a React component that wraps an embedded\n * element with fallback support.\n *\n * @example\n * ```tsx\n * // src/wallet/with-fallback.tsx\n * export const withFallback = createWithFallback<WalletSessionElements>(useWalletSession);\n *\n * // src/wallet/elements/deposit.tsx — options type inferred from the element type\n * export const DepositElement = withFallback({\n * displayName: \"DepositElement\",\n * type: \"deposit-element\",\n * } as const);\n * ```\n */\nexport function createWithFallback<\n\tRegistry extends Record<string, [unknown, unknown]>,\n>(useSession: () => SessionLike<Registry> | null) {\n\treturn function withFallback<\n\t\tconst T extends keyof Registry & string,\n\t\tTRequired extends boolean = false,\n\t>(Component: {\n\t\tdisplayName: string;\n\t\ttype: T;\n\t}): WithFallbackComponent<Registry[T][0], TRequired> {\n\t\ttype TOptions = Registry[T][0];\n\n\t\tfunction WrappedElement({\n\t\t\toptions,\n\t\t\tclassName,\n\t\t\tstyle,\n\t\t\tonReady,\n\t\t\tfallback,\n\t\t}: WithFallbackPropsOptional<TOptions>) {\n\t\t\tconst session = useSession();\n\t\t\tconst ref = useRef<HTMLDivElement>(null);\n\n\t\t\tconst element = useMemo((): BaseElement | null => {\n\t\t\t\tif (!session) return null;\n\t\t\t\t// Safe: T is constrained to valid element types, and options matches T\n\t\t\t\treturn session.createElement(\n\t\t\t\t\tComponent,\n\t\t\t\t\toptions ?? ({} as TOptions),\n\t\t\t\t) as BaseElement;\n\t\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- element is created once per session; options updates flow through updateOptions below\n\t\t\t}, [session]);\n\n\t\t\tconst elementSnapshot = useElementSnapshot(element);\n\n\t\t\tconst isReady = elementSnapshot?.state === \"ready\";\n\n\t\t\tuseEffect(() => {\n\t\t\t\tif (!element) return;\n\t\t\t\telement.updateOptions(options ?? {});\n\t\t\t}, [options, element]);\n\n\t\t\tuseEffect(() => {\n\t\t\t\tif (!element || !onReady) return;\n\t\t\t\telement.on(\"ready\", onReady);\n\t\t\t\treturn () => {\n\t\t\t\t\telement.off(\"ready\", onReady);\n\t\t\t\t};\n\t\t\t}, [element, onReady]);\n\n\t\t\tuseLayoutEffect(() => {\n\t\t\t\tif (!element || !ref.current) return;\n\t\t\t\telement.mount(ref.current);\n\t\t\t\treturn () => {\n\t\t\t\t\telement.unmount();\n\t\t\t\t};\n\t\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- ref.current intentionally re-runs the mount when the container attaches\n\t\t\t}, [element, ref.current]);\n\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tstyle={{ ...style, visibility: isReady ? undefined : \"hidden\" }}\n\t\t\t\t\t\tclassName={className}\n\t\t\t\t\t\tref={ref}\n\t\t\t\t\t/>\n\t\t\t\t\t{!isReady && (fallback ?? null)}\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\n\t\tWrappedElement.displayName = Component.displayName;\n\t\tWrappedElement.type = Component.type;\n\n\t\treturn WrappedElement as WithFallbackComponent<TOptions, TRequired>;\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAmE;AACnE,kCAAmC;AAmE5B,SAAS,mBAEd,YAAgD;AACjD,SAAO,SAAS,aAGd,WAGmD;AAGpD,aAAS,eAAe;AAAA,MACvB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,GAAwC;AACvC,YAAM,UAAU,WAAW;AAC3B,YAAM,UAAM,qBAAuB,IAAI;AAEvC,YAAM,cAAU,sBAAQ,MAA0B;AACjD,YAAI,CAAC,QAAS,QAAO;AAErB,eAAO,QAAQ;AAAA,UACd;AAAA,UACA,WAAY,CAAC;AAAA,QACd;AAAA,MAED,GAAG,CAAC,OAAO,CAAC;AAEZ,YAAM,sBAAkB,gDAAmB,OAAO;AAElD,YAAM,UAAU,iBAAiB,UAAU;AAE3C,kCAAU,MAAM;AACf,YAAI,CAAC,QAAS;AACd,gBAAQ,cAAc,WAAW,CAAC,CAAC;AAAA,MACpC,GAAG,CAAC,SAAS,OAAO,CAAC;AAErB,kCAAU,MAAM;AACf,YAAI,CAAC,WAAW,CAAC,QAAS;AAC1B,gBAAQ,GAAG,SAAS,OAAO;AAC3B,eAAO,MAAM;AACZ,kBAAQ,IAAI,SAAS,OAAO;AAAA,QAC7B;AAAA,MACD,GAAG,CAAC,SAAS,OAAO,CAAC;AAErB,wCAAgB,MAAM;AACrB,YAAI,CAAC,WAAW,CAAC,IAAI,QAAS;AAC9B,gBAAQ,MAAM,IAAI,OAAO;AACzB,eAAO,MAAM;AACZ,kBAAQ,QAAQ;AAAA,QACjB;AAAA,MAED,GAAG,CAAC,SAAS,IAAI,OAAO,CAAC;AAEzB,aACC,6BAAAA,QAAA,2BAAAA,QAAA,gBACC,6BAAAA,QAAA;AAAA,QAAC;AAAA;AAAA,UACA,OAAO,EAAE,GAAG,OAAO,YAAY,UAAU,SAAY,SAAS;AAAA,UAC9D;AAAA,UACA;AAAA;AAAA,MACD,GACC,CAAC,YAAY,YAAY,KAC3B;AAAA,IAEF;AAEA,mBAAe,cAAc,UAAU;AACvC,mBAAe,OAAO,UAAU;AAEhC,WAAO;AAAA,EACR;AACD;","names":["React"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../chunk-NSSMTXJJ.mjs";
|
|
3
|
+
import React, { useEffect, useLayoutEffect, useMemo, useRef } from "react";
|
|
4
|
+
import { useElementSnapshot } from "./use-element-snapshot.mjs";
|
|
5
|
+
function createWithFallback(useSession) {
|
|
6
|
+
return function withFallback(Component) {
|
|
7
|
+
function WrappedElement({ options, className, style, onReady, fallback }) {
|
|
8
|
+
const session = useSession();
|
|
9
|
+
const ref = useRef(null);
|
|
10
|
+
const element = useMemo(()=>{
|
|
11
|
+
if (!session) return null;
|
|
12
|
+
return session.createElement(Component, options ?? {});
|
|
13
|
+
}, [
|
|
14
|
+
session
|
|
15
|
+
]);
|
|
16
|
+
const elementSnapshot = useElementSnapshot(element);
|
|
17
|
+
const isReady = elementSnapshot?.state === "ready";
|
|
18
|
+
useEffect(()=>{
|
|
19
|
+
if (!element) return;
|
|
20
|
+
element.updateOptions(options ?? {});
|
|
21
|
+
}, [
|
|
22
|
+
options,
|
|
23
|
+
element
|
|
24
|
+
]);
|
|
25
|
+
useEffect(()=>{
|
|
26
|
+
if (!element || !onReady) return;
|
|
27
|
+
element.on("ready", onReady);
|
|
28
|
+
return ()=>{
|
|
29
|
+
element.off("ready", onReady);
|
|
30
|
+
};
|
|
31
|
+
}, [
|
|
32
|
+
element,
|
|
33
|
+
onReady
|
|
34
|
+
]);
|
|
35
|
+
useLayoutEffect(()=>{
|
|
36
|
+
if (!element || !ref.current) return;
|
|
37
|
+
element.mount(ref.current);
|
|
38
|
+
return ()=>{
|
|
39
|
+
element.unmount();
|
|
40
|
+
};
|
|
41
|
+
}, [
|
|
42
|
+
element,
|
|
43
|
+
ref.current
|
|
44
|
+
]);
|
|
45
|
+
return React.createElement(React.Fragment, null, React.createElement("div", {
|
|
46
|
+
style: {
|
|
47
|
+
...style,
|
|
48
|
+
visibility: isReady ? void 0 : "hidden"
|
|
49
|
+
},
|
|
50
|
+
className,
|
|
51
|
+
ref
|
|
52
|
+
}), !isReady && (fallback ?? null));
|
|
53
|
+
}
|
|
54
|
+
WrappedElement.displayName = Component.displayName;
|
|
55
|
+
WrappedElement.type = Component.type;
|
|
56
|
+
return WrappedElement;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export { createWithFallback };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/create-with-fallback.tsx"],"sourcesContent":["\"use client\";\n\nimport type { WhopElement } from \"@whop/embedded-components-vanilla-js/types\";\nimport React, { useEffect, useLayoutEffect, useMemo, useRef } from \"react\";\nimport { useElementSnapshot } from \"./use-element-snapshot\";\n\n/**\n * Base element type that all created elements conform to.\n * Using WhopElement<any, any, any> gives us access to common methods\n * (mount, unmount, on, off, updateOptions) without union type issues.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype BaseElement = WhopElement<any, any, any>;\n\n/**\n * The minimal session surface the wrapper needs — the registry-typed\n * createElement every session exposes.\n */\ninterface SessionLike<Registry extends Record<string, [unknown, unknown]>> {\n\tcreateElement<T extends keyof Registry>(\n\t\ttype: T | { type: T },\n\t\toptions: Registry[T][0],\n\t): unknown;\n}\n\ninterface WithFallbackPropsBase {\n\tclassName?: string;\n\tstyle?: React.CSSProperties;\n\tonReady?: () => void;\n\tfallback?: React.ReactNode;\n}\n\nexport interface WithFallbackPropsRequired<\n\tTOptions,\n> extends WithFallbackPropsBase {\n\toptions: TOptions;\n}\n\nexport interface WithFallbackPropsOptional<\n\tTOptions,\n> extends WithFallbackPropsBase {\n\toptions?: TOptions;\n}\n\ntype WithFallbackComponent<TOptions, TRequired extends boolean> = {\n\t(\n\t\tprops: TRequired extends true\n\t\t\t? WithFallbackPropsRequired<TOptions>\n\t\t\t: WithFallbackPropsOptional<TOptions>,\n\t): React.ReactNode;\n\tdisplayName: string;\n\ttype: string;\n};\n\n/**\n * Builds a namespace-specific `withFallback` from that namespace's session\n * hook. The returned helper creates a React component that wraps an embedded\n * element with fallback support.\n *\n * @example\n * ```tsx\n * // src/wallet/with-fallback.tsx\n * export const withFallback = createWithFallback<WalletSessionElements>(useWalletSession);\n *\n * // src/wallet/elements/deposit.tsx — options type inferred from the element type\n * export const DepositElement = withFallback({\n * displayName: \"DepositElement\",\n * type: \"deposit-element\",\n * } as const);\n * ```\n */\nexport function createWithFallback<\n\tRegistry extends Record<string, [unknown, unknown]>,\n>(useSession: () => SessionLike<Registry> | null) {\n\treturn function withFallback<\n\t\tconst T extends keyof Registry & string,\n\t\tTRequired extends boolean = false,\n\t>(Component: {\n\t\tdisplayName: string;\n\t\ttype: T;\n\t}): WithFallbackComponent<Registry[T][0], TRequired> {\n\t\ttype TOptions = Registry[T][0];\n\n\t\tfunction WrappedElement({\n\t\t\toptions,\n\t\t\tclassName,\n\t\t\tstyle,\n\t\t\tonReady,\n\t\t\tfallback,\n\t\t}: WithFallbackPropsOptional<TOptions>) {\n\t\t\tconst session = useSession();\n\t\t\tconst ref = useRef<HTMLDivElement>(null);\n\n\t\t\tconst element = useMemo((): BaseElement | null => {\n\t\t\t\tif (!session) return null;\n\t\t\t\t// Safe: T is constrained to valid element types, and options matches T\n\t\t\t\treturn session.createElement(\n\t\t\t\t\tComponent,\n\t\t\t\t\toptions ?? ({} as TOptions),\n\t\t\t\t) as BaseElement;\n\t\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- element is created once per session; options updates flow through updateOptions below\n\t\t\t}, [session]);\n\n\t\t\tconst elementSnapshot = useElementSnapshot(element);\n\n\t\t\tconst isReady = elementSnapshot?.state === \"ready\";\n\n\t\t\tuseEffect(() => {\n\t\t\t\tif (!element) return;\n\t\t\t\telement.updateOptions(options ?? {});\n\t\t\t}, [options, element]);\n\n\t\t\tuseEffect(() => {\n\t\t\t\tif (!element || !onReady) return;\n\t\t\t\telement.on(\"ready\", onReady);\n\t\t\t\treturn () => {\n\t\t\t\t\telement.off(\"ready\", onReady);\n\t\t\t\t};\n\t\t\t}, [element, onReady]);\n\n\t\t\tuseLayoutEffect(() => {\n\t\t\t\tif (!element || !ref.current) return;\n\t\t\t\telement.mount(ref.current);\n\t\t\t\treturn () => {\n\t\t\t\t\telement.unmount();\n\t\t\t\t};\n\t\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- ref.current intentionally re-runs the mount when the container attaches\n\t\t\t}, [element, ref.current]);\n\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tstyle={{ ...style, visibility: isReady ? undefined : \"hidden\" }}\n\t\t\t\t\t\tclassName={className}\n\t\t\t\t\t\tref={ref}\n\t\t\t\t\t/>\n\t\t\t\t\t{!isReady && (fallback ?? null)}\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\n\t\tWrappedElement.displayName = Component.displayName;\n\t\tWrappedElement.type = Component.type;\n\n\t\treturn WrappedElement as WithFallbackComponent<TOptions, TRequired>;\n\t};\n}\n"],"mappings":";;AAGA,OAAO,SAAS,WAAW,iBAAiB,SAAS,cAAc;AACnE,SAAS,0BAA0B;AAmE5B,SAAS,mBAEd,YAAgD;AACjD,SAAO,SAAS,aAGd,WAGmD;AAGpD,aAAS,eAAe;AAAA,MACvB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,GAAwC;AACvC,YAAM,UAAU,WAAW;AAC3B,YAAM,MAAM,OAAuB,IAAI;AAEvC,YAAM,UAAU,QAAQ,MAA0B;AACjD,YAAI,CAAC,QAAS,QAAO;AAErB,eAAO,QAAQ;AAAA,UACd;AAAA,UACA,WAAY,CAAC;AAAA,QACd;AAAA,MAED,GAAG,CAAC,OAAO,CAAC;AAEZ,YAAM,kBAAkB,mBAAmB,OAAO;AAElD,YAAM,UAAU,iBAAiB,UAAU;AAE3C,gBAAU,MAAM;AACf,YAAI,CAAC,QAAS;AACd,gBAAQ,cAAc,WAAW,CAAC,CAAC;AAAA,MACpC,GAAG,CAAC,SAAS,OAAO,CAAC;AAErB,gBAAU,MAAM;AACf,YAAI,CAAC,WAAW,CAAC,QAAS;AAC1B,gBAAQ,GAAG,SAAS,OAAO;AAC3B,eAAO,MAAM;AACZ,kBAAQ,IAAI,SAAS,OAAO;AAAA,QAC7B;AAAA,MACD,GAAG,CAAC,SAAS,OAAO,CAAC;AAErB,sBAAgB,MAAM;AACrB,YAAI,CAAC,WAAW,CAAC,IAAI,QAAS;AAC9B,gBAAQ,MAAM,IAAI,OAAO;AACzB,eAAO,MAAM;AACZ,kBAAQ,QAAQ;AAAA,QACjB;AAAA,MAED,GAAG,CAAC,SAAS,IAAI,OAAO,CAAC;AAEzB,aACC,0DACC;AAAA,QAAC;AAAA;AAAA,UACA,OAAO,EAAE,GAAG,OAAO,YAAY,UAAU,SAAY,SAAS;AAAA,UAC9D;AAAA,UACA;AAAA;AAAA,MACD,GACC,CAAC,YAAY,YAAY,KAC3B;AAAA,IAEF;AAEA,mBAAe,cAAc,UAAU;AACvC,mBAAe,OAAO,UAAU;AAEhC,WAAO;AAAA,EACR;AACD;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsOptional } from '
|
|
1
|
+
import { WithFallbackPropsOptional } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsOptional } from '
|
|
1
|
+
import { WithFallbackPropsOptional } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsOptional } from '
|
|
1
|
+
import { WithFallbackPropsOptional } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsOptional } from '
|
|
1
|
+
import { WithFallbackPropsOptional } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsOptional } from '
|
|
1
|
+
import { WithFallbackPropsOptional } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsOptional } from '
|
|
1
|
+
import { WithFallbackPropsOptional } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsRequired } from '
|
|
1
|
+
import { WithFallbackPropsRequired } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -15,6 +15,6 @@ export { WithdrawElement } from './withdraw.js';
|
|
|
15
15
|
export { WithdrawButtonElement } from './withdraw-button.js';
|
|
16
16
|
export { WithdrawalBreakdownElement } from './withdrawal-breakdown.js';
|
|
17
17
|
export { WithdrawalsElement } from './withdrawals.js';
|
|
18
|
-
import '
|
|
19
|
-
import '@whop/embedded-components-vanilla-js/types';
|
|
18
|
+
import '../../lib/create-with-fallback.js';
|
|
20
19
|
import 'react';
|
|
20
|
+
import '@whop/embedded-components-vanilla-js/types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsOptional } from '
|
|
1
|
+
import { WithFallbackPropsOptional } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsOptional } from '
|
|
1
|
+
import { WithFallbackPropsOptional } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsOptional } from '
|
|
1
|
+
import { WithFallbackPropsOptional } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsOptional } from '
|
|
1
|
+
import { WithFallbackPropsOptional } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsOptional } from '
|
|
1
|
+
import { WithFallbackPropsOptional } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsOptional } from '
|
|
1
|
+
import { WithFallbackPropsOptional } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsOptional } from '
|
|
1
|
+
import { WithFallbackPropsOptional } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsRequired } from '
|
|
1
|
+
import { WithFallbackPropsRequired } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WithFallbackPropsOptional } from '
|
|
1
|
+
import { WithFallbackPropsOptional } from '../../lib/create-with-fallback.js';
|
|
2
2
|
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
package/dist/payouts/index.d.ts
CHANGED
|
@@ -18,4 +18,4 @@ export { WithdrawalBreakdownElement } from './elements/withdrawal-breakdown.js';
|
|
|
18
18
|
export { WithdrawalsElement } from './elements/withdrawals.js';
|
|
19
19
|
import '@whop/embedded-components-vanilla-js/types';
|
|
20
20
|
import 'react';
|
|
21
|
-
import '
|
|
21
|
+
import '../lib/create-with-fallback.js';
|
|
@@ -1,55 +1,14 @@
|
|
|
1
|
+
import { WithFallbackPropsRequired, WithFallbackPropsOptional } from '../lib/create-with-fallback.js';
|
|
1
2
|
import { PayoutsSessionElements } from '@whop/embedded-components-vanilla-js/types';
|
|
2
|
-
import
|
|
3
|
+
import 'react';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
* Valid element type strings that can be passed to createElement.
|
|
6
|
-
*/
|
|
7
|
-
type ElementType = keyof PayoutsSessionElements;
|
|
8
|
-
/**
|
|
9
|
-
* Extract the options type for a given element type using indexed access.
|
|
10
|
-
* PayoutsSessionElements maps element types to [Options, Element] tuples.
|
|
11
|
-
*/
|
|
12
|
-
type ElementOptionsFor<T extends ElementType> = PayoutsSessionElements[T][0];
|
|
13
|
-
/**
|
|
14
|
-
* Component definition with a constrained element type.
|
|
15
|
-
* The type must be a valid element type from the SDK.
|
|
16
|
-
*/
|
|
17
|
-
interface ElementComponentDefinition<T extends ElementType = ElementType> {
|
|
5
|
+
declare const withFallback: <const T extends "add-payout-method-element" | "available-cash-breakdown-element" | "balance-element" | "withdraw-button-element" | "withdraw-element" | "automatic-withdraw-element" | "verify-element" | "withdrawals-element" | "withdrawal-breakdown-element" | "change-account-country-element" | "reset-account-element" | "generate-withdrawal-receipt-element" | "status-banner-element" | "balances-element" | "pending-breakdown-element" | "reserve-breakdown-element" | "treasury-breakdown-element", TRequired extends boolean = false>(Component: {
|
|
18
6
|
displayName: string;
|
|
19
7
|
type: T;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
className?: string;
|
|
23
|
-
style?: React__default.CSSProperties;
|
|
24
|
-
onReady?: () => void;
|
|
25
|
-
fallback?: React__default.ReactNode;
|
|
26
|
-
}
|
|
27
|
-
interface WithFallbackPropsRequired<TOptions> extends WithFallbackPropsBase {
|
|
28
|
-
options: TOptions;
|
|
29
|
-
}
|
|
30
|
-
interface WithFallbackPropsOptional<TOptions> extends WithFallbackPropsBase {
|
|
31
|
-
options?: TOptions;
|
|
32
|
-
}
|
|
33
|
-
type WithFallbackComponent<TOptions, TRequired extends boolean> = {
|
|
34
|
-
(props: TRequired extends true ? WithFallbackPropsRequired<TOptions> : WithFallbackPropsOptional<TOptions>): React__default.ReactNode;
|
|
8
|
+
}) => {
|
|
9
|
+
(props: TRequired extends true ? WithFallbackPropsRequired<PayoutsSessionElements[T][0]> : WithFallbackPropsOptional<PayoutsSessionElements[T][0]>): React.ReactNode;
|
|
35
10
|
displayName: string;
|
|
36
11
|
type: string;
|
|
37
12
|
};
|
|
38
|
-
/**
|
|
39
|
-
* Creates a React component that wraps an embedded element with fallback support.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```tsx
|
|
43
|
-
* // Type-safe: options type is inferred from the element type
|
|
44
|
-
* export const BalanceElement = withFallback({
|
|
45
|
-
* displayName: "BalanceElement",
|
|
46
|
-
* type: "balance-element",
|
|
47
|
-
* } as const);
|
|
48
|
-
*
|
|
49
|
-
* // Usage - TypeScript knows the correct options type
|
|
50
|
-
* <BalanceElement options={{ hidePendingBalance: true }} />
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
declare function withFallback<const T extends ElementType, TRequired extends boolean = false>(Component: ElementComponentDefinition<T>): WithFallbackComponent<ElementOptionsFor<T>, TRequired>;
|
|
54
13
|
|
|
55
|
-
export {
|
|
14
|
+
export { WithFallbackPropsOptional, WithFallbackPropsRequired, withFallback };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
|
-
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
7
|
var __export = (target, all) => {
|
|
10
8
|
for (var name in all)
|
|
@@ -18,68 +16,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
16
|
}
|
|
19
17
|
return to;
|
|
20
18
|
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
20
|
var with_fallback_exports = {};
|
|
31
21
|
__export(with_fallback_exports, {
|
|
32
22
|
withFallback: () => withFallback
|
|
33
23
|
});
|
|
34
24
|
module.exports = __toCommonJS(with_fallback_exports);
|
|
35
|
-
var
|
|
36
|
-
var import_use_element_snapshot = require("../lib/use-element-snapshot");
|
|
25
|
+
var import_create_with_fallback = require("../lib/create-with-fallback");
|
|
37
26
|
var import_session = require("./session");
|
|
38
|
-
|
|
39
|
-
function WrappedElement({
|
|
40
|
-
options,
|
|
41
|
-
className,
|
|
42
|
-
style,
|
|
43
|
-
onReady,
|
|
44
|
-
fallback
|
|
45
|
-
}) {
|
|
46
|
-
const payoutsSession = (0, import_session.usePayoutsSession)();
|
|
47
|
-
const ref = (0, import_react.useRef)(null);
|
|
48
|
-
const element = (0, import_react.useMemo)(() => {
|
|
49
|
-
if (!payoutsSession) return null;
|
|
50
|
-
return payoutsSession.createElement(Component, options ?? {});
|
|
51
|
-
}, [payoutsSession]);
|
|
52
|
-
const elementSnapshot = (0, import_use_element_snapshot.useElementSnapshot)(element);
|
|
53
|
-
const isReady = elementSnapshot?.state === "ready";
|
|
54
|
-
(0, import_react.useEffect)(() => {
|
|
55
|
-
if (!element) return;
|
|
56
|
-
element.updateOptions(options ?? {});
|
|
57
|
-
}, [options, element]);
|
|
58
|
-
(0, import_react.useEffect)(() => {
|
|
59
|
-
if (!element || !onReady) return;
|
|
60
|
-
element.on("ready", onReady);
|
|
61
|
-
return () => {
|
|
62
|
-
element.off("ready", onReady);
|
|
63
|
-
};
|
|
64
|
-
}, [element, onReady]);
|
|
65
|
-
(0, import_react.useLayoutEffect)(() => {
|
|
66
|
-
if (!element || !ref.current) return;
|
|
67
|
-
element.mount(ref.current);
|
|
68
|
-
return () => {
|
|
69
|
-
element.unmount();
|
|
70
|
-
};
|
|
71
|
-
}, [element, ref.current]);
|
|
72
|
-
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
|
|
73
|
-
"div",
|
|
74
|
-
{
|
|
75
|
-
style: { ...style, visibility: isReady ? void 0 : "hidden" },
|
|
76
|
-
className,
|
|
77
|
-
ref
|
|
78
|
-
}
|
|
79
|
-
), !isReady && (fallback ?? null));
|
|
80
|
-
}
|
|
81
|
-
WrappedElement.displayName = Component.displayName;
|
|
82
|
-
WrappedElement.type = Component.type;
|
|
83
|
-
return WrappedElement;
|
|
84
|
-
}
|
|
27
|
+
const withFallback = (0, import_create_with_fallback.createWithFallback)(import_session.usePayoutsSession);
|
|
85
28
|
//# sourceMappingURL=with-fallback.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/payouts/with-fallback.tsx"],"sourcesContent":["\"use client\";\n\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/payouts/with-fallback.tsx"],"sourcesContent":["\"use client\";\n\nimport type { PayoutsSessionElements } from \"@whop/embedded-components-vanilla-js/types\";\n\nimport { createWithFallback } from \"../lib/create-with-fallback\";\nimport { usePayoutsSession } from \"./session\";\n\nexport type {\n\tWithFallbackPropsOptional,\n\tWithFallbackPropsRequired,\n} from \"../lib/create-with-fallback\";\n\nexport const withFallback =\n\tcreateWithFallback<PayoutsSessionElements>(usePayoutsSession);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kCAAmC;AACnC,qBAAkC;AAO3B,MAAM,mBACZ,gDAA2C,gCAAiB;","names":[]}
|
|
@@ -1,58 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../chunk-NSSMTXJJ.mjs";
|
|
3
|
-
import
|
|
4
|
-
import { useElementSnapshot } from "../lib/use-element-snapshot.mjs";
|
|
3
|
+
import { createWithFallback } from "../lib/create-with-fallback.mjs";
|
|
5
4
|
import { usePayoutsSession } from "./session.mjs";
|
|
6
|
-
|
|
7
|
-
function WrappedElement({ options, className, style, onReady, fallback }) {
|
|
8
|
-
const payoutsSession = usePayoutsSession();
|
|
9
|
-
const ref = useRef(null);
|
|
10
|
-
const element = useMemo(()=>{
|
|
11
|
-
if (!payoutsSession) return null;
|
|
12
|
-
return payoutsSession.createElement(Component, options ?? {});
|
|
13
|
-
}, [
|
|
14
|
-
payoutsSession
|
|
15
|
-
]);
|
|
16
|
-
const elementSnapshot = useElementSnapshot(element);
|
|
17
|
-
const isReady = elementSnapshot?.state === "ready";
|
|
18
|
-
useEffect(()=>{
|
|
19
|
-
if (!element) return;
|
|
20
|
-
element.updateOptions(options ?? {});
|
|
21
|
-
}, [
|
|
22
|
-
options,
|
|
23
|
-
element
|
|
24
|
-
]);
|
|
25
|
-
useEffect(()=>{
|
|
26
|
-
if (!element || !onReady) return;
|
|
27
|
-
element.on("ready", onReady);
|
|
28
|
-
return ()=>{
|
|
29
|
-
element.off("ready", onReady);
|
|
30
|
-
};
|
|
31
|
-
}, [
|
|
32
|
-
element,
|
|
33
|
-
onReady
|
|
34
|
-
]);
|
|
35
|
-
useLayoutEffect(()=>{
|
|
36
|
-
if (!element || !ref.current) return;
|
|
37
|
-
element.mount(ref.current);
|
|
38
|
-
return ()=>{
|
|
39
|
-
element.unmount();
|
|
40
|
-
};
|
|
41
|
-
}, [
|
|
42
|
-
element,
|
|
43
|
-
ref.current
|
|
44
|
-
]);
|
|
45
|
-
return React.createElement(React.Fragment, null, React.createElement("div", {
|
|
46
|
-
style: {
|
|
47
|
-
...style,
|
|
48
|
-
visibility: isReady ? void 0 : "hidden"
|
|
49
|
-
},
|
|
50
|
-
className,
|
|
51
|
-
ref
|
|
52
|
-
}), !isReady && (fallback ?? null));
|
|
53
|
-
}
|
|
54
|
-
WrappedElement.displayName = Component.displayName;
|
|
55
|
-
WrappedElement.type = Component.type;
|
|
56
|
-
return WrappedElement;
|
|
57
|
-
}
|
|
5
|
+
const withFallback = createWithFallback(usePayoutsSession);
|
|
58
6
|
export { withFallback };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/payouts/with-fallback.tsx"],"sourcesContent":["\"use client\";\n\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/payouts/with-fallback.tsx"],"sourcesContent":["\"use client\";\n\nimport type { PayoutsSessionElements } from \"@whop/embedded-components-vanilla-js/types\";\n\nimport { createWithFallback } from \"../lib/create-with-fallback\";\nimport { usePayoutsSession } from \"./session\";\n\nexport type {\n\tWithFallbackPropsOptional,\n\tWithFallbackPropsRequired,\n} from \"../lib/create-with-fallback\";\n\nexport const withFallback =\n\tcreateWithFallback<PayoutsSessionElements>(usePayoutsSession);\n"],"mappings":";;AAIA,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAO3B,MAAM,eACZ,mBAA2C,iBAAiB;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WithFallbackPropsOptional } from '../../lib/create-with-fallback.js';
|
|
2
|
+
import * as _whop_embedded_components_vanilla_js_types from '@whop/embedded-components-vanilla-js/types';
|
|
3
|
+
import 'react';
|
|
4
|
+
|
|
5
|
+
declare const DepositElement: {
|
|
6
|
+
(props: WithFallbackPropsOptional<_whop_embedded_components_vanilla_js_types.DepositElementOptions>): React.ReactNode;
|
|
7
|
+
displayName: string;
|
|
8
|
+
type: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { DepositElement };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var deposit_exports = {};
|
|
21
|
+
__export(deposit_exports, {
|
|
22
|
+
DepositElement: () => DepositElement
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(deposit_exports);
|
|
25
|
+
var import_with_fallback = require("../with-fallback");
|
|
26
|
+
const DepositElement = (0, import_with_fallback.withFallback)({
|
|
27
|
+
displayName: "DepositElement",
|
|
28
|
+
type: "deposit-element"
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=deposit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/wallet/elements/deposit.tsx"],"sourcesContent":["\"use client\";\n\nimport { withFallback } from \"../with-fallback\";\n\nexport const DepositElement = withFallback({\n\tdisplayName: \"DepositElement\",\n\ttype: \"deposit-element\",\n} as const);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,2BAA6B;AAEtB,MAAM,qBAAiB,mCAAa;AAAA,EAC1C,aAAa;AAAA,EACb,MAAM;AACP,CAAU;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/wallet/elements/deposit.tsx"],"sourcesContent":["\"use client\";\n\nimport { withFallback } from \"../with-fallback\";\n\nexport const DepositElement = withFallback({\n\tdisplayName: \"DepositElement\",\n\ttype: \"deposit-element\",\n} as const);\n"],"mappings":";;AAEA,SAAS,oBAAoB;AAEtB,MAAM,iBAAiB,aAAa;AAAA,EAC1C,aAAa;AAAA,EACb,MAAM;AACP,CAAU;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var elements_exports = {};
|
|
20
|
+
__export(elements_exports, {
|
|
21
|
+
DepositElement: () => import_deposit.DepositElement
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(elements_exports);
|
|
24
|
+
var import_deposit = require("./deposit");
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/wallet/elements/index.tsx"],"sourcesContent":["export { DepositElement } from \"./deposit\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+B;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/wallet/elements/index.tsx"],"sourcesContent":["export { DepositElement } from \"./deposit\";\n"],"mappings":";AAAA,SAAS,sBAAsB;","names":[]}
|
package/dist/wallet/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { DepositElement } from './elements/deposit.js';
|
|
1
2
|
export { WalletSession, useWalletSession } from './session.js';
|
|
2
|
-
import '
|
|
3
|
+
import '../lib/create-with-fallback.js';
|
|
3
4
|
import 'react';
|
|
5
|
+
import '@whop/embedded-components-vanilla-js/types';
|
package/dist/wallet/index.js
CHANGED
|
@@ -15,5 +15,6 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var wallet_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(wallet_exports);
|
|
18
|
+
__reExport(wallet_exports, require("./elements"), module.exports);
|
|
18
19
|
__reExport(wallet_exports, require("./session"), module.exports);
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
package/dist/wallet/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/wallet/index.tsx"],"sourcesContent":["export * from \"./session\";\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,2BAAc,
|
|
1
|
+
{"version":3,"sources":["../../src/wallet/index.tsx"],"sourcesContent":["export * from \"./elements\";\nexport * from \"./session\";\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,2BAAc,uBAAd;AACA,2BAAc,sBADd;","names":[]}
|
package/dist/wallet/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/wallet/index.tsx"],"sourcesContent":["export * from \"./session\";\n"],"mappings":"AAAA,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/wallet/index.tsx"],"sourcesContent":["export * from \"./elements\";\nexport * from \"./session\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { WithFallbackPropsRequired, WithFallbackPropsOptional } from '../lib/create-with-fallback.js';
|
|
2
|
+
import { WalletSessionElements } from '@whop/embedded-components-vanilla-js/types';
|
|
3
|
+
import 'react';
|
|
4
|
+
|
|
5
|
+
declare const withFallback: <const T extends "deposit-element", TRequired extends boolean = false>(Component: {
|
|
6
|
+
displayName: string;
|
|
7
|
+
type: T;
|
|
8
|
+
}) => {
|
|
9
|
+
(props: TRequired extends true ? WithFallbackPropsRequired<WalletSessionElements[T][0]> : WithFallbackPropsOptional<WalletSessionElements[T][0]>): React.ReactNode;
|
|
10
|
+
displayName: string;
|
|
11
|
+
type: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { WithFallbackPropsOptional, WithFallbackPropsRequired, withFallback };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var with_fallback_exports = {};
|
|
21
|
+
__export(with_fallback_exports, {
|
|
22
|
+
withFallback: () => withFallback
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(with_fallback_exports);
|
|
25
|
+
var import_create_with_fallback = require("../lib/create-with-fallback");
|
|
26
|
+
var import_session = require("./session");
|
|
27
|
+
const withFallback = (0, import_create_with_fallback.createWithFallback)(import_session.useWalletSession);
|
|
28
|
+
//# sourceMappingURL=with-fallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/wallet/with-fallback.tsx"],"sourcesContent":["\"use client\";\n\nimport type { WalletSessionElements } from \"@whop/embedded-components-vanilla-js/types\";\n\nimport { createWithFallback } from \"../lib/create-with-fallback\";\nimport { useWalletSession } from \"./session\";\n\nexport type {\n\tWithFallbackPropsOptional,\n\tWithFallbackPropsRequired,\n} from \"../lib/create-with-fallback\";\n\nexport const withFallback =\n\tcreateWithFallback<WalletSessionElements>(useWalletSession);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kCAAmC;AACnC,qBAAiC;AAO1B,MAAM,mBACZ,gDAA0C,+BAAgB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/wallet/with-fallback.tsx"],"sourcesContent":["\"use client\";\n\nimport type { WalletSessionElements } from \"@whop/embedded-components-vanilla-js/types\";\n\nimport { createWithFallback } from \"../lib/create-with-fallback\";\nimport { useWalletSession } from \"./session\";\n\nexport type {\n\tWithFallbackPropsOptional,\n\tWithFallbackPropsRequired,\n} from \"../lib/create-with-fallback\";\n\nexport const withFallback =\n\tcreateWithFallback<WalletSessionElements>(useWalletSession);\n"],"mappings":";;AAIA,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AAO1B,MAAM,eACZ,mBAA0C,gBAAgB;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whop/embedded-components-react-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "React components for Whop.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"React",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": ">=16.8.0 <20.0.0",
|
|
24
24
|
"react-dom": ">=16.8.0 <20.0.0",
|
|
25
|
-
"@whop/embedded-components-vanilla-js": "^1.
|
|
25
|
+
"@whop/embedded-components-vanilla-js": "^1.2.0"
|
|
26
26
|
},
|
|
27
27
|
"typing": "dist/index.d.ts"
|
|
28
28
|
}
|