@whop/embedded-components-react-js 0.0.4-beta.0 → 0.0.4

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.
@@ -2,7 +2,7 @@ import { PayoutsSession as PayoutsSession$1, PayoutsSessionOptions } from '@whop
2
2
  import React__default, { PropsWithChildren } from 'react';
3
3
 
4
4
  declare function usePayoutsSession(): PayoutsSession$1 | null;
5
- declare function PayoutsSession({ children, currency, companyId, token, ref, }: PropsWithChildren<PayoutsSessionOptions & {
5
+ declare function PayoutsSession({ children, currency, companyId, token, redirectUrl, ref, }: PropsWithChildren<PayoutsSessionOptions & {
6
6
  ref?: React__default.RefObject<{
7
7
  payoutsSession: PayoutsSession$1 | null;
8
8
  } | null>;
@@ -34,11 +34,10 @@ __export(session_exports, {
34
34
  });
35
35
  module.exports = __toCommonJS(session_exports);
36
36
  var import_react = __toESM(require("react"));
37
- var import_react2 = require("react");
38
37
  var import_provider = require("../provider");
39
- const PayoutsSessionContext = (0, import_react2.createContext)(null);
38
+ const PayoutsSessionContext = (0, import_react.createContext)(null);
40
39
  function usePayoutsSession() {
41
- const ctx = (0, import_react2.useContext)(PayoutsSessionContext);
40
+ const ctx = (0, import_react.useContext)(PayoutsSessionContext);
42
41
  if (!ctx) {
43
42
  throw new Error(
44
43
  "usePayoutsSession must be used within a PayoutsSessionProvider"
@@ -51,26 +50,29 @@ function PayoutsSession({
51
50
  currency,
52
51
  companyId,
53
52
  token,
53
+ redirectUrl,
54
54
  ref
55
55
  }) {
56
56
  const elements = (0, import_provider.useElements)();
57
- const payoutsSession = (0, import_react2.useMemo)(() => {
57
+ const payoutsSession = (0, import_react.useMemo)(() => {
58
58
  if (!elements) return null;
59
59
  return elements.createPayoutsSession({
60
60
  token,
61
61
  currency,
62
- companyId
62
+ companyId,
63
+ redirectUrl
63
64
  });
64
65
  }, [elements]);
65
- (0, import_react2.useEffect)(() => {
66
+ (0, import_react.useEffect)(() => {
66
67
  if (!payoutsSession) return;
67
68
  payoutsSession.updateOptions({
68
69
  token,
69
70
  currency,
70
- companyId
71
+ companyId,
72
+ redirectUrl
71
73
  });
72
- }, [payoutsSession, currency, token, companyId]);
73
- const value = (0, import_react2.useMemo)(
74
+ }, [payoutsSession, currency, token, companyId, redirectUrl]);
75
+ const value = (0, import_react.useMemo)(
74
76
  () => ({
75
77
  payoutsSession
76
78
  }),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/payouts/session.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n\tPayoutsSessionOptions,\n\tPayoutsSession as PayoutsSessionType,\n} from \"@whop/embedded-components-vanilla-js/types\";\nimport type { PropsWithChildren } from \"react\";\n\nimport React, { useImperativeHandle } from \"react\";\nimport { createContext, useContext, useEffect, useMemo } from \"react\";\nimport { useElements } from \"../provider\";\n\ninterface ContextState {\n\tpayoutsSession: PayoutsSessionType | null;\n}\n\nconst PayoutsSessionContext = createContext<ContextState | null>(null);\n\nexport function usePayoutsSession() {\n\tconst ctx = useContext(PayoutsSessionContext);\n\tif (!ctx) {\n\t\tthrow new Error(\n\t\t\t\"usePayoutsSession must be used within a PayoutsSessionProvider\",\n\t\t);\n\t}\n\treturn ctx.payoutsSession;\n}\n\nexport function PayoutsSession({\n\tchildren,\n\tcurrency,\n\tcompanyId,\n\ttoken,\n\tref,\n}: PropsWithChildren<\n\tPayoutsSessionOptions & {\n\t\tref?: React.RefObject<{\n\t\t\tpayoutsSession: PayoutsSessionType | null;\n\t\t} | null>;\n\t}\n>) {\n\tconst elements = useElements();\n\n\tconst payoutsSession = useMemo(() => {\n\t\tif (!elements) return null;\n\t\treturn elements.createPayoutsSession({\n\t\t\ttoken,\n\t\t\tcurrency,\n\t\t\tcompanyId,\n\t\t});\n\t}, [elements]);\n\n\tuseEffect(() => {\n\t\tif (!payoutsSession) return;\n\n\t\tpayoutsSession.updateOptions({\n\t\t\ttoken,\n\t\t\tcurrency,\n\t\t\tcompanyId,\n\t\t});\n\t}, [payoutsSession, currency, token, companyId]);\n\n\tconst value: ContextState = useMemo(\n\t\t() => ({\n\t\t\tpayoutsSession,\n\t\t}),\n\t\t[payoutsSession],\n\t);\n\n\tuseImperativeHandle(ref, () => ({ payoutsSession }), [payoutsSession]);\n\n\treturn (\n\t\t<PayoutsSessionContext.Provider value={value}>\n\t\t\t{children}\n\t\t</PayoutsSessionContext.Provider>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,mBAA2C;AAC3C,IAAAA,gBAA8D;AAC9D,sBAA4B;AAM5B,MAAM,4BAAwB,6BAAmC,IAAI;AAE9D,SAAS,oBAAoB;AACnC,QAAM,UAAM,0BAAW,qBAAqB;AAC5C,MAAI,CAAC,KAAK;AACT,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,SAAO,IAAI;AACZ;AAEO,SAAS,eAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAMG;AACF,QAAM,eAAW,6BAAY;AAE7B,QAAM,qBAAiB,uBAAQ,MAAM;AACpC,QAAI,CAAC,SAAU,QAAO;AACtB,WAAO,SAAS,qBAAqB;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAC;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AAEb,+BAAU,MAAM;AACf,QAAI,CAAC,eAAgB;AAErB,mBAAe,cAAc;AAAA,MAC5B;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAC;AAAA,EACF,GAAG,CAAC,gBAAgB,UAAU,OAAO,SAAS,CAAC;AAE/C,QAAM,YAAsB;AAAA,IAC3B,OAAO;AAAA,MACN;AAAA,IACD;AAAA,IACA,CAAC,cAAc;AAAA,EAChB;AAEA,wCAAoB,KAAK,OAAO,EAAE,eAAe,IAAI,CAAC,cAAc,CAAC;AAErE,SACC,6BAAAC,QAAA,cAAC,sBAAsB,UAAtB,EAA+B,SAC9B,QACF;AAEF;","names":["import_react","React"]}
1
+ {"version":3,"sources":["../../src/payouts/session.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n\tPayoutsSessionOptions,\n\tPayoutsSession as PayoutsSessionType,\n} from \"@whop/embedded-components-vanilla-js/types\";\nimport type { PropsWithChildren } from \"react\";\n\nimport React, {\n\tcreateContext,\n\tuseContext,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseMemo,\n} from \"react\";\nimport { useElements } from \"../provider\";\n\ninterface ContextState {\n\tpayoutsSession: PayoutsSessionType | null;\n}\n\nconst PayoutsSessionContext = createContext<ContextState | null>(null);\n\nexport function usePayoutsSession() {\n\tconst ctx = useContext(PayoutsSessionContext);\n\tif (!ctx) {\n\t\tthrow new Error(\n\t\t\t\"usePayoutsSession must be used within a PayoutsSessionProvider\",\n\t\t);\n\t}\n\treturn ctx.payoutsSession;\n}\n\nexport function PayoutsSession({\n\tchildren,\n\tcurrency,\n\tcompanyId,\n\ttoken,\n\tredirectUrl,\n\tref,\n}: PropsWithChildren<\n\tPayoutsSessionOptions & {\n\t\tref?: React.RefObject<{\n\t\t\tpayoutsSession: PayoutsSessionType | null;\n\t\t} | null>;\n\t}\n>) {\n\tconst elements = useElements();\n\n\tconst payoutsSession = useMemo(() => {\n\t\tif (!elements) return null;\n\t\treturn elements.createPayoutsSession({\n\t\t\ttoken,\n\t\t\tcurrency,\n\t\t\tcompanyId,\n\t\t\tredirectUrl,\n\t\t});\n\t}, [elements]);\n\n\tuseEffect(() => {\n\t\tif (!payoutsSession) return;\n\n\t\tpayoutsSession.updateOptions({\n\t\t\ttoken,\n\t\t\tcurrency,\n\t\t\tcompanyId,\n\t\t\tredirectUrl,\n\t\t});\n\t}, [payoutsSession, currency, token, companyId, redirectUrl]);\n\n\tconst value: ContextState = useMemo(\n\t\t() => ({\n\t\t\tpayoutsSession,\n\t\t}),\n\t\t[payoutsSession],\n\t);\n\n\tuseImperativeHandle(ref, () => ({ payoutsSession }), [payoutsSession]);\n\n\treturn (\n\t\t<PayoutsSessionContext.Provider value={value}>\n\t\t\t{children}\n\t\t</PayoutsSessionContext.Provider>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,mBAMO;AACP,sBAA4B;AAM5B,MAAM,4BAAwB,4BAAmC,IAAI;AAE9D,SAAS,oBAAoB;AACnC,QAAM,UAAM,yBAAW,qBAAqB;AAC5C,MAAI,CAAC,KAAK;AACT,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,SAAO,IAAI;AACZ;AAEO,SAAS,eAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAMG;AACF,QAAM,eAAW,6BAAY;AAE7B,QAAM,qBAAiB,sBAAQ,MAAM;AACpC,QAAI,CAAC,SAAU,QAAO;AACtB,WAAO,SAAS,qBAAqB;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAC;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AAEb,8BAAU,MAAM;AACf,QAAI,CAAC,eAAgB;AAErB,mBAAe,cAAc;AAAA,MAC5B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAC;AAAA,EACF,GAAG,CAAC,gBAAgB,UAAU,OAAO,WAAW,WAAW,CAAC;AAE5D,QAAM,YAAsB;AAAA,IAC3B,OAAO;AAAA,MACN;AAAA,IACD;AAAA,IACA,CAAC,cAAc;AAAA,EAChB;AAEA,wCAAoB,KAAK,OAAO,EAAE,eAAe,IAAI,CAAC,cAAc,CAAC;AAErE,SACC,6BAAAA,QAAA,cAAC,sBAAsB,UAAtB,EAA+B,SAC9B,QACF;AAEF;","names":["React"]}
@@ -1,7 +1,6 @@
1
1
  "use client";
2
2
  import "../chunk-NSSMTXJJ.mjs";
3
- import React, { useImperativeHandle } from "react";
4
- import { createContext, useContext, useEffect, useMemo } from "react";
3
+ import React, { createContext, useContext, useEffect, useImperativeHandle, useMemo } from "react";
5
4
  import { useElements } from "../provider.mjs";
6
5
  const PayoutsSessionContext = createContext(null);
7
6
  function usePayoutsSession() {
@@ -11,14 +10,15 @@ function usePayoutsSession() {
11
10
  }
12
11
  return ctx.payoutsSession;
13
12
  }
14
- function PayoutsSession({ children, currency, companyId, token, ref }) {
13
+ function PayoutsSession({ children, currency, companyId, token, redirectUrl, ref }) {
15
14
  const elements = useElements();
16
15
  const payoutsSession = useMemo(()=>{
17
16
  if (!elements) return null;
18
17
  return elements.createPayoutsSession({
19
18
  token,
20
19
  currency,
21
- companyId
20
+ companyId,
21
+ redirectUrl
22
22
  });
23
23
  }, [
24
24
  elements
@@ -28,13 +28,15 @@ function PayoutsSession({ children, currency, companyId, token, ref }) {
28
28
  payoutsSession.updateOptions({
29
29
  token,
30
30
  currency,
31
- companyId
31
+ companyId,
32
+ redirectUrl
32
33
  });
33
34
  }, [
34
35
  payoutsSession,
35
36
  currency,
36
37
  token,
37
- companyId
38
+ companyId,
39
+ redirectUrl
38
40
  ]);
39
41
  const value = useMemo(()=>({
40
42
  payoutsSession
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/payouts/session.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n\tPayoutsSessionOptions,\n\tPayoutsSession as PayoutsSessionType,\n} from \"@whop/embedded-components-vanilla-js/types\";\nimport type { PropsWithChildren } from \"react\";\n\nimport React, { useImperativeHandle } from \"react\";\nimport { createContext, useContext, useEffect, useMemo } from \"react\";\nimport { useElements } from \"../provider\";\n\ninterface ContextState {\n\tpayoutsSession: PayoutsSessionType | null;\n}\n\nconst PayoutsSessionContext = createContext<ContextState | null>(null);\n\nexport function usePayoutsSession() {\n\tconst ctx = useContext(PayoutsSessionContext);\n\tif (!ctx) {\n\t\tthrow new Error(\n\t\t\t\"usePayoutsSession must be used within a PayoutsSessionProvider\",\n\t\t);\n\t}\n\treturn ctx.payoutsSession;\n}\n\nexport function PayoutsSession({\n\tchildren,\n\tcurrency,\n\tcompanyId,\n\ttoken,\n\tref,\n}: PropsWithChildren<\n\tPayoutsSessionOptions & {\n\t\tref?: React.RefObject<{\n\t\t\tpayoutsSession: PayoutsSessionType | null;\n\t\t} | null>;\n\t}\n>) {\n\tconst elements = useElements();\n\n\tconst payoutsSession = useMemo(() => {\n\t\tif (!elements) return null;\n\t\treturn elements.createPayoutsSession({\n\t\t\ttoken,\n\t\t\tcurrency,\n\t\t\tcompanyId,\n\t\t});\n\t}, [elements]);\n\n\tuseEffect(() => {\n\t\tif (!payoutsSession) return;\n\n\t\tpayoutsSession.updateOptions({\n\t\t\ttoken,\n\t\t\tcurrency,\n\t\t\tcompanyId,\n\t\t});\n\t}, [payoutsSession, currency, token, companyId]);\n\n\tconst value: ContextState = useMemo(\n\t\t() => ({\n\t\t\tpayoutsSession,\n\t\t}),\n\t\t[payoutsSession],\n\t);\n\n\tuseImperativeHandle(ref, () => ({ payoutsSession }), [payoutsSession]);\n\n\treturn (\n\t\t<PayoutsSessionContext.Provider value={value}>\n\t\t\t{children}\n\t\t</PayoutsSessionContext.Provider>\n\t);\n}\n"],"mappings":";;AAQA,OAAO,SAAS,2BAA2B;AAC3C,SAAS,eAAe,YAAY,WAAW,eAAe;AAC9D,SAAS,mBAAmB;AAM5B,MAAM,wBAAwB,cAAmC,IAAI;AAE9D,SAAS,oBAAoB;AACnC,QAAM,MAAM,WAAW,qBAAqB;AAC5C,MAAI,CAAC,KAAK;AACT,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,SAAO,IAAI;AACZ;AAEO,SAAS,eAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAMG;AACF,QAAM,WAAW,YAAY;AAE7B,QAAM,iBAAiB,QAAQ,MAAM;AACpC,QAAI,CAAC,SAAU,QAAO;AACtB,WAAO,SAAS,qBAAqB;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAC;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AAEb,YAAU,MAAM;AACf,QAAI,CAAC,eAAgB;AAErB,mBAAe,cAAc;AAAA,MAC5B;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAC;AAAA,EACF,GAAG,CAAC,gBAAgB,UAAU,OAAO,SAAS,CAAC;AAE/C,QAAM,QAAsB;AAAA,IAC3B,OAAO;AAAA,MACN;AAAA,IACD;AAAA,IACA,CAAC,cAAc;AAAA,EAChB;AAEA,sBAAoB,KAAK,OAAO,EAAE,eAAe,IAAI,CAAC,cAAc,CAAC;AAErE,SACC,oCAAC,sBAAsB,UAAtB,EAA+B,SAC9B,QACF;AAEF;","names":[]}
1
+ {"version":3,"sources":["../../src/payouts/session.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n\tPayoutsSessionOptions,\n\tPayoutsSession as PayoutsSessionType,\n} from \"@whop/embedded-components-vanilla-js/types\";\nimport type { PropsWithChildren } from \"react\";\n\nimport React, {\n\tcreateContext,\n\tuseContext,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseMemo,\n} from \"react\";\nimport { useElements } from \"../provider\";\n\ninterface ContextState {\n\tpayoutsSession: PayoutsSessionType | null;\n}\n\nconst PayoutsSessionContext = createContext<ContextState | null>(null);\n\nexport function usePayoutsSession() {\n\tconst ctx = useContext(PayoutsSessionContext);\n\tif (!ctx) {\n\t\tthrow new Error(\n\t\t\t\"usePayoutsSession must be used within a PayoutsSessionProvider\",\n\t\t);\n\t}\n\treturn ctx.payoutsSession;\n}\n\nexport function PayoutsSession({\n\tchildren,\n\tcurrency,\n\tcompanyId,\n\ttoken,\n\tredirectUrl,\n\tref,\n}: PropsWithChildren<\n\tPayoutsSessionOptions & {\n\t\tref?: React.RefObject<{\n\t\t\tpayoutsSession: PayoutsSessionType | null;\n\t\t} | null>;\n\t}\n>) {\n\tconst elements = useElements();\n\n\tconst payoutsSession = useMemo(() => {\n\t\tif (!elements) return null;\n\t\treturn elements.createPayoutsSession({\n\t\t\ttoken,\n\t\t\tcurrency,\n\t\t\tcompanyId,\n\t\t\tredirectUrl,\n\t\t});\n\t}, [elements]);\n\n\tuseEffect(() => {\n\t\tif (!payoutsSession) return;\n\n\t\tpayoutsSession.updateOptions({\n\t\t\ttoken,\n\t\t\tcurrency,\n\t\t\tcompanyId,\n\t\t\tredirectUrl,\n\t\t});\n\t}, [payoutsSession, currency, token, companyId, redirectUrl]);\n\n\tconst value: ContextState = useMemo(\n\t\t() => ({\n\t\t\tpayoutsSession,\n\t\t}),\n\t\t[payoutsSession],\n\t);\n\n\tuseImperativeHandle(ref, () => ({ payoutsSession }), [payoutsSession]);\n\n\treturn (\n\t\t<PayoutsSessionContext.Provider value={value}>\n\t\t\t{children}\n\t\t</PayoutsSessionContext.Provider>\n\t);\n}\n"],"mappings":";;AAQA,OAAO;AAAA,EACN;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,mBAAmB;AAM5B,MAAM,wBAAwB,cAAmC,IAAI;AAE9D,SAAS,oBAAoB;AACnC,QAAM,MAAM,WAAW,qBAAqB;AAC5C,MAAI,CAAC,KAAK;AACT,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,SAAO,IAAI;AACZ;AAEO,SAAS,eAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAMG;AACF,QAAM,WAAW,YAAY;AAE7B,QAAM,iBAAiB,QAAQ,MAAM;AACpC,QAAI,CAAC,SAAU,QAAO;AACtB,WAAO,SAAS,qBAAqB;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAC;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AAEb,YAAU,MAAM;AACf,QAAI,CAAC,eAAgB;AAErB,mBAAe,cAAc;AAAA,MAC5B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAC;AAAA,EACF,GAAG,CAAC,gBAAgB,UAAU,OAAO,WAAW,WAAW,CAAC;AAE5D,QAAM,QAAsB;AAAA,IAC3B,OAAO;AAAA,MACN;AAAA,IACD;AAAA,IACA,CAAC,cAAc;AAAA,EAChB;AAEA,sBAAoB,KAAK,OAAO,EAAE,eAAe,IAAI,CAAC,cAAc,CAAC;AAErE,SACC,oCAAC,sBAAsB,UAAtB,EAA+B,SAC9B,QACF;AAEF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whop/embedded-components-react-js",
3
- "version": "0.0.4-beta.0",
3
+ "version": "0.0.4",
4
4
  "description": "React components for Whop.js",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -21,7 +21,7 @@
21
21
  "access": "public"
22
22
  },
23
23
  "peerDependencies": {
24
- "@whop/embedded-components-vanilla-js": "^0.0.4-beta.0",
24
+ "@whop/embedded-components-vanilla-js": "^0.0.4",
25
25
  "react": ">=16.8.0 <20.0.0",
26
26
  "react-dom": ">=16.8.0 <20.0.0"
27
27
  }
package/package.json.temp CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@whop/embedded-components-react-js",
3
3
  "private": true,
4
- "version": "0.0.4-beta.0",
4
+ "version": "0.0.4",
5
5
  "description": "React components for Whop.js",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",