@statsig/expo-bindings 2.2.0-beta.1 → 2.2.0-beta.5

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/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@statsig/expo-bindings",
3
- "version": "2.2.0-beta.1",
3
+ "version": "2.2.0-beta.5",
4
4
  "dependencies": {
5
- "@statsig/client-core": "2.2.0-beta.1",
6
- "@statsig/js-client": "2.2.0-beta.1",
7
- "@statsig/react-bindings": "2.2.0-beta.1",
8
- "@statsig/react-native-core": "2.2.0-beta.1"
5
+ "@statsig/client-core": "2.2.0-beta.5",
6
+ "@statsig/js-client": "2.2.0-beta.5",
7
+ "@statsig/react-bindings": "2.2.0-beta.5",
8
+ "@statsig/react-native-core": "2.2.0-beta.5"
9
9
  },
10
10
  "peerDependencies": {
11
+ "react": "^16.6.3 || ^17.0.0 || ^18.0.0",
11
12
  "react-native": "0.*",
12
13
  "expo-application": "5.*",
13
14
  "expo-device": "5.* || 6.*"
@@ -1,5 +1,6 @@
1
1
  import { StatsigOptions, StatsigUser } from '@statsig/js-client';
2
2
  import { StatsigClientReactNativeBase } from '@statsig/react-native-core';
3
3
  export declare class StatsigClientExpo extends StatsigClientReactNativeBase {
4
+ __isExpoClient: boolean;
4
5
  constructor(sdkKey: string, user: StatsigUser, options?: StatsigOptions | null);
5
6
  }
@@ -6,6 +6,7 @@ const StatsigMetadataAdditions_1 = require("./StatsigMetadataAdditions");
6
6
  class StatsigClientExpo extends react_native_core_1.StatsigClientReactNativeBase {
7
7
  constructor(sdkKey, user, options = null) {
8
8
  super(sdkKey, user, options, 'expo', (0, StatsigMetadataAdditions_1.GetStatsigMetadataAdditions)());
9
+ this.__isExpoClient = true;
9
10
  }
10
11
  }
11
12
  exports.StatsigClientExpo = StatsigClientExpo;
@@ -1,4 +1,5 @@
1
1
  import { StatsigProviderProps } from '@statsig/react-bindings';
2
- type Props = StatsigProviderProps;
2
+ import { StatsigClientExpo } from './StatsigClientExpo';
3
+ type Props = StatsigProviderProps<StatsigClientExpo>;
3
4
  export declare function StatsigProviderExpo(props: Props): JSX.Element | null;
4
5
  export {};
@@ -2,19 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StatsigProviderExpo = void 0;
4
4
  const react_1 = require("react");
5
+ const client_core_1 = require("@statsig/client-core");
5
6
  const react_bindings_1 = require("@statsig/react-bindings");
6
- const react_native_core_1 = require("@statsig/react-native-core");
7
- const StatsigMetadataAdditions_1 = require("./StatsigMetadataAdditions");
7
+ const StatsigClientExpo_1 = require("./StatsigClientExpo");
8
+ function useClientFactory(sdkKey, initialUser, statsigOptions = null) {
9
+ const [client] = (0, react_1.useState)(() => {
10
+ const client = new StatsigClientExpo_1.StatsigClientExpo(sdkKey, initialUser, statsigOptions);
11
+ client.initializeAsync().catch(client_core_1.Log.error);
12
+ return client;
13
+ });
14
+ return client;
15
+ }
8
16
  function StatsigProviderExpo(props) {
9
- const options = (0, react_1.useMemo)(() => {
10
- var _a;
11
- if ('client' in props) {
12
- return undefined;
13
- }
14
- const opts = (_a = props.options) !== null && _a !== void 0 ? _a : {};
15
- (0, react_native_core_1._setupStatsigForReactNative)('expo', (0, StatsigMetadataAdditions_1.GetStatsigMetadataAdditions)(), opts);
16
- return opts;
17
- }, [props]);
18
- return (0, react_bindings_1.StatsigProvider)(Object.assign(Object.assign({}, props), { options }));
17
+ const { children, loadingComponent } = props;
18
+ const client = 'client' in props
19
+ ? props.client
20
+ : useClientFactory(props.sdkKey, props.user, props.options);
21
+ return (0, react_bindings_1.StatsigProvider)({ children, loadingComponent, client });
19
22
  }
20
23
  exports.StatsigProviderExpo = StatsigProviderExpo;
package/src/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
1
  export * from '@statsig/react-bindings';
2
+ declare const StatsigProvider: never;
3
+ declare const StatsigClient: never;
4
+ export { StatsigProvider, StatsigClient };
2
5
  export { StatsigClientExpo } from './StatsigClientExpo';
3
6
  export { StatsigProviderExpo } from './StatsigProviderExpo';
package/src/index.js CHANGED
@@ -14,8 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.StatsigProviderExpo = exports.StatsigClientExpo = void 0;
17
+ exports.StatsigProviderExpo = exports.StatsigClientExpo = exports.StatsigClient = exports.StatsigProvider = void 0;
18
18
  __exportStar(require("@statsig/react-bindings"), exports);
19
+ // Expo environments should use the Expo specific variants
20
+ const StatsigProvider = undefined;
21
+ exports.StatsigProvider = StatsigProvider;
22
+ const StatsigClient = undefined;
23
+ exports.StatsigClient = StatsigClient;
19
24
  var StatsigClientExpo_1 = require("./StatsigClientExpo");
20
25
  Object.defineProperty(exports, "StatsigClientExpo", { enumerable: true, get: function () { return StatsigClientExpo_1.StatsigClientExpo; } });
21
26
  var StatsigProviderExpo_1 = require("./StatsigProviderExpo");