expo-superwall 0.0.18 → 0.1.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b39e98e: feat: Remove the export of the internal SuperwallExpoModule Class,
8
+ this class should have not been used since it's an internal class and could break the state of the internal SuperwallStore.
9
+ If you have used in prior for a usecase that the current SDK doesn't support, please open an issue.
10
+
11
+ ### Patch Changes
12
+
13
+ - 32112a6: feat: handle deeplink automatically, no need for manual handling
14
+
3
15
  ## 0.0.18
4
16
 
5
17
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-superwall",
3
- "version": "0.0.18",
3
+ "version": "0.1.0",
4
4
  "description": "Offical Expo Integration for Superwall",
5
5
  "main": "build/src/index.js",
6
6
  "types": "build/src/index.d.ts",
@@ -1 +1 @@
1
- {"version":3,"file":"SuperwallProvider.d.ts","sourceRoot":"","sources":["../../src/SuperwallProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,OAAO,CAAA;AAMjD,UAAU,sBAAsB;IAC9B,6BAA6B;IAC7B,OAAO,EAAE;QACP,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,GAAG,CAAC,EAAE,MAAM,CAAA;KACb,CAAA;IACD,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC7B,4CAA4C;IAC5C,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,OAAO,EAEP,QAAQ,GACT,EAAE,sBAAsB,+BAiCxB"}
1
+ {"version":3,"file":"SuperwallProvider.d.ts","sourceRoot":"","sources":["../../src/SuperwallProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,OAAO,CAAA;AAOzD,UAAU,sBAAsB;IAC9B,6BAA6B;IAC7B,OAAO,EAAE;QACP,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,GAAG,CAAC,EAAE,MAAM,CAAA;KACb,CAAA;IACD,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC7B,4CAA4C;IAC5C,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,OAAO,EAEP,QAAQ,GACT,EAAE,sBAAsB,+BAyDxB"}
@@ -1,7 +1,8 @@
1
- import { useEffect } from "react";
2
- import { Platform } from "react-native";
1
+ import { useEffect, useRef } from "react";
2
+ import { Linking, Platform } from "react-native";
3
3
  import { useShallow } from "zustand/shallow";
4
4
  import { useCustomPurchaseController } from "./CustomPurchaseControllerProvider";
5
+ import SuperwallExpoModule from "./SuperwallExpoModule";
5
6
  import { SuperwallContext, useSuperwallStore } from "./useSuperwall";
6
7
  /**
7
8
  * @category Providers
@@ -25,6 +26,7 @@ import { SuperwallContext, useSuperwallStore } from "./useSuperwall";
25
26
  * ```
26
27
  */
27
28
  export function SuperwallProvider({ apiKeys, options, children, }) {
29
+ const deepLinkEventHandlerRef = useRef(null);
28
30
  const isUsingCustomPurchaseController = !!useCustomPurchaseController();
29
31
  const { isConfigured, isLoading, configure } = useSuperwallStore(useShallow((state) => ({
30
32
  isConfigured: state.isConfigured,
@@ -49,6 +51,24 @@ export function SuperwallProvider({ apiKeys, options, children, }) {
49
51
  const cleanup = useSuperwallStore.getState()._initListeners();
50
52
  return cleanup;
51
53
  }, []);
54
+ useEffect(() => {
55
+ const handleDeepLink = async () => {
56
+ await Linking.getInitialURL().then((url) => {
57
+ if (url) {
58
+ SuperwallExpoModule.handleDeepLink(url);
59
+ }
60
+ });
61
+ deepLinkEventHandlerRef.current = Linking.addEventListener("url", (event) => {
62
+ SuperwallExpoModule.handleDeepLink(event.url);
63
+ });
64
+ };
65
+ handleDeepLink();
66
+ return () => {
67
+ if (deepLinkEventHandlerRef.current) {
68
+ deepLinkEventHandlerRef.current.remove();
69
+ }
70
+ };
71
+ }, []);
52
72
  return <SuperwallContext.Provider value={true}>{children}</SuperwallContext.Provider>;
53
73
  }
54
74
  //# sourceMappingURL=SuperwallProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SuperwallProvider.js","sourceRoot":"","sources":["../../src/SuperwallProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,OAAO,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAA;AAChF,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAcpE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,OAAO,EACP,OAAO,EAEP,QAAQ,GACe;IACvB,MAAM,+BAA+B,GAAG,CAAC,CAAC,2BAA2B,EAAE,CAAA;IACvE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,iBAAiB,CAC9D,UAAU,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACrB,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;KAC3B,CAAC,CAAC,CACJ,CAAA;IAED,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,YAAY,IAAI,CAAC,SAAS,EAAE,CAAC;YAChC,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,EAA0B,CAAC,CAAA;YAC3D,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,IAAI,KAAK,CAAC,oCAAoC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAA;YACpE,CAAC;YAED,SAAS,CAAC,MAAM,EAAE;gBAChB,GAAG,OAAO;gBACV,uBAAuB,EAAE,+BAA+B;aACzD,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACf,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAA;YAClD,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC,EAAE,CAAC,YAAY,EAAE,+BAA+B,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAA;IAE3F,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,OAAO,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CAAC,cAAc,EAAE,CAAA;QAE7D,OAAO,OAAO,CAAA;IAChB,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAA;AACvF,CAAC","sourcesContent":["import { type ReactNode, useEffect } from \"react\"\nimport { Platform } from \"react-native\"\nimport { useShallow } from \"zustand/shallow\"\nimport { useCustomPurchaseController } from \"./CustomPurchaseControllerProvider\"\nimport { SuperwallContext, useSuperwallStore } from \"./useSuperwall\"\n\ninterface SuperwallProviderProps {\n /** Your Superwall API key */\n apiKeys: {\n android?: string\n ios?: string\n }\n /** Optional configuration options passed to the native SDK */\n options?: Record<string, any>\n /** App content to render once configured */\n children: ReactNode\n}\n\n/**\n * @category Providers\n * @since 0.0.15\n * Main provider component for the Superwall SDK.\n *\n * This component initializes the Superwall SDK with your API key and configuration options.\n * It should wrap the root of your application or the part of your app that requires Superwall functionality.\n * It also sets up necessary event listeners for the SDK.\n *\n * @param props - The properties for the SuperwallProvider.\n * @param props.apiKeys - An object containing your Superwall API keys for Android and iOS.\n * @param props.options - Optional configuration options to pass to the native Superwall SDK.\n * @param props.children - The child components of your application that will have access to Superwall features.\n *\n * Example:\n * ```tsx\n * <SuperwallProvider apiKeys={{ ios: \"YOUR_IOS_API_KEY\", android: \"YOUR_ANDROID_API_KEY\" }}>\n * <App />\n * </SuperwallProvider>\n * ```\n */\nexport function SuperwallProvider({\n apiKeys,\n options,\n\n children,\n}: SuperwallProviderProps) {\n const isUsingCustomPurchaseController = !!useCustomPurchaseController()\n const { isConfigured, isLoading, configure } = useSuperwallStore(\n useShallow((state) => ({\n isConfigured: state.isConfigured,\n isLoading: state.isLoading,\n configure: state.configure,\n })),\n )\n\n useEffect(() => {\n if (!isConfigured && !isLoading) {\n const apiKey = apiKeys[Platform.OS as keyof typeof apiKeys]\n if (!apiKey) {\n throw new Error(`No API key provided for platform ${Platform.OS}`)\n }\n\n configure(apiKey, {\n ...options,\n manualPurchaseManagment: isUsingCustomPurchaseController,\n }).catch((err) => {\n console.error(\"Superwall configure failed\", err)\n })\n }\n }, [isConfigured, isUsingCustomPurchaseController, isLoading, apiKeys, options, configure])\n\n useEffect(() => {\n const cleanup = useSuperwallStore.getState()._initListeners()\n\n return cleanup\n }, [])\n\n return <SuperwallContext.Provider value={true}>{children}</SuperwallContext.Provider>\n}\n"]}
1
+ {"version":3,"file":"SuperwallProvider.js","sourceRoot":"","sources":["../../src/SuperwallProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AACzD,OAAO,EAA4B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAA;AAChF,OAAO,mBAAmB,MAAM,uB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AO,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CAAC,cAAc,EAAE,CAAA;QAE7D,OAAO,OAAO,CAAA;IAChB,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,cAAc,GAAG,KAAK,IAAI,EAAE;YAChC,MAAM,OAAO,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;gBACzC,IAAI,GAAG,EAAE,CAAC;oBACR,mBAAmB,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;gBACzC,CAAC;YACH,CAAC,CAAC,CAAA;YAEF,uBAAuB,CAAC,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;gBAC1E,mBAAmB,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAC/C,CAAC,CAAC,CAAA;QACJ,CAAC,CAAA;QAED,cAAc,EAAE,CAAA;QAEhB,OAAO,GAAG,EAAE;YACV,IAAI,uBAAuB,CAAC,OAAO,EAAE,CAAC;gBACpC,uBAAuB,CAAC,OAAO,CAAC,MAAM,EAAE,CAAA;YAC1C,CAAC;QACH,CAAC,CAAA;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAA;AACvF,CAAC","sourcesContent":["import { type ReactNode, useEffect, useRef } from \"react\"\nimport { type EmitterSubscription, Linking, Platform } from \"react-native\"\nimport { useShallow } from \"zustand/shallow\"\nimport { useCustomPurchaseController } from \"./CustomPurchaseControllerProvider\"\nimport SuperwallExpoModule from \"./SuperwallExpoModule\"\nimport { SuperwallContext, useSuperwallStore } from \"./useSuperwall\"\n\ninterface SuperwallProviderProps {\n /** Your Superwall API key */\n apiKeys: {\n android?: string\n ios?: string\n }\n /** Optional configuration options passed to the native SDK */\n options?: Record<string, any>\n /** App content to render once configured */\n children: ReactNode\n}\n\n/**\n * @category Providers\n * @since 0.0.15\n * Main provider component for the Superwall SDK.\n *\n * This component initializes the Superwall SDK with your API key and configuration options.\n * It should wrap the root of your application or the part of your app that requires Superwall functionality.\n * It also sets up necessary event listeners for the SDK.\n *\n * @param props - The properties for the SuperwallProvider.\n * @param props.apiKeys - An object containing your Superwall API keys for Android and iOS.\n * @param props.options - Optional configuration options to pass to the native Superwall SDK.\n * @param props.children - The child components of your application that will have access to Superwall features.\n *\n * Example:\n * ```tsx\n * <SuperwallProvider apiKeys={{ ios: \"YOUR_IOS_API_KEY\", android: \"YOUR_ANDROID_API_KEY\" }}>\n * <App />\n * </SuperwallProvider>\n * ```\n */\nexport function SuperwallProvider({\n apiKeys,\n options,\n\n children,\n}: SuperwallProviderProps) {\n const deepLinkEventHandlerRef = useRef<EmitterSubscription>(null)\n const isUsingCustomPurchaseController = !!useCustomPurchaseController()\n\n const { isConfigured, isLoading, configure } = useSuperwallStore(\n useShallow((state) => ({\n isConfigured: state.isConfigured,\n isLoading: state.isLoading,\n configure: state.configure,\n })),\n )\n\n useEffect(() => {\n if (!isConfigured && !isLoading) {\n const apiKey = apiKeys[Platform.OS as keyof typeof apiKeys]\n if (!apiKey) {\n throw new Error(`No API key provided for platform ${Platform.OS}`)\n }\n\n configure(apiKey, {\n ...options,\n manualPurchaseManagment: isUsingCustomPurchaseController,\n }).catch((err) => {\n console.error(\"Superwall configure failed\", err)\n })\n }\n }, [isConfigured, isUsingCustomPurchaseController, isLoading, apiKeys, options, configure])\n\n useEffect(() => {\n const cleanup = useSuperwallStore.getState()._initListeners()\n\n return cleanup\n }, [])\n\n useEffect(() => {\n const handleDeepLink = async () => {\n await Linking.getInitialURL().then((url) => {\n if (url) {\n SuperwallExpoModule.handleDeepLink(url)\n }\n })\n\n deepLinkEventHandlerRef.current = Linking.addEventListener(\"url\", (event) => {\n SuperwallExpoModule.handleDeepLink(event.url)\n })\n }\n\n handleDeepLink()\n\n return () => {\n if (deepLinkEventHandlerRef.current) {\n deepLinkEventHandlerRef.current.remove()\n }\n }\n }, [])\n\n return <SuperwallContext.Provider value={true}>{children}</SuperwallContext.Provider>\n}\n"]}
@@ -1,6 +1,5 @@
1
1
  export * from "./CustomPurchaseControllerProvider";
2
2
  export * from "./components";
3
- export { default as SuperwallExpoModule } from "./SuperwallExpoModule";
4
3
  export * from "./SuperwallProvider";
5
4
  export * from "./usePlacement";
6
5
  export * from "./useSuperwall";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAA;AAClD,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AACtE,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAA;AAClD,cAAc,cAAc,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,WAAW,CAAA"}
@@ -1,6 +1,5 @@
1
1
  export * from "./CustomPurchaseControllerProvider";
2
2
  export * from "./components";
3
- export { default as SuperwallExpoModule } from "./SuperwallExpoModule";
4
3
  export * from "./SuperwallProvider";
5
4
  export * from "./usePlacement";
6
5
  export * from "./useSuperwall";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAA;AAClD,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AACtE,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,WAAW,CAAA","sourcesContent":["export * from \"./CustomPurchaseControllerProvider\"\nexport * from \"./components\"\nexport { default as SuperwallExpoModule } from \"./SuperwallExpoModule\"\nexport * from \"./SuperwallProvider\"\nexport * from \"./usePlacement\"\nexport * from \"./useSuperwall\"\nexport * from \"./useSuperwallEvents\"\nexport * from \"./useUser\"\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAA;AAClD,cAAc,cAAc,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,WAAW,CAAA","sourcesContent":["export * from \"./CustomPurchaseControllerProvider\"\nexport * from \"./components\"\nexport * from \"./SuperwallProvider\"\nexport * from \"./usePlacement\"\nexport * from \"./useSuperwall\"\nexport * from \"./useSuperwallEvents\"\nexport * from \"./useUser\"\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-superwall",
3
- "version": "0.0.18",
3
+ "version": "0.1.0",
4
4
  "description": "Offical Expo Integration for Superwall",
5
5
  "main": "build/src/index.js",
6
6
  "types": "build/src/index.d.ts",