wolves-react-client 1.0.6 → 1.0.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"useClientAsyncInit.d.ts","sourceRoot":"","sources":["../../src/hooks/useClientAsyncInit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,kBAAkB,EAA0B,MAAM,kBAAkB,CAAC;AAI7H,MAAM,WAAW,yBAAyB;IACxC,2DAA2D;IAC3D,MAAM,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;IAClC,uCAAuC;IACvC,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,qDAAqD;IACrD,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACvD,4CAA4C;IAC5C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,wBAAwB;IACvC,qEAAqE;IACrE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,mDAAmD;IACnD,SAAS,EAAE,OAAO,CAAC;IACnB,wDAAwD;IACxD,aAAa,EAAE,OAAO,CAAC;IACvB,kDAAkD;IAClD,qBAAqB,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAClD,oDAAoD;IACpD,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,EAChB,OAAO,GAAE,yBAA8B,GACtC,wBAAwB,CAyE1B"}
1
+ {"version":3,"file":"useClientAsyncInit.d.ts","sourceRoot":"","sources":["../../src/hooks/useClientAsyncInit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,kBAAkB,EAA0B,MAAM,kBAAkB,CAAC;AAI7H,MAAM,WAAW,yBAAyB;IACxC,2DAA2D;IAC3D,MAAM,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;IAClC,uCAAuC;IACvC,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,qDAAqD;IACrD,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACvD,4CAA4C;IAC5C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,wBAAwB;IACvC,qEAAqE;IACrE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,mDAAmD;IACnD,SAAS,EAAE,OAAO,CAAC;IACnB,wDAAwD;IACxD,aAAa,EAAE,OAAO,CAAC;IACvB,kDAAkD;IAClD,qBAAqB,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAClD,oDAAoD;IACpD,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,EAChB,OAAO,GAAE,yBAA8B,GACtC,wBAAwB,CA6E1B"}
@@ -45,6 +45,7 @@ function useClientAsyncInit(sdkKey, user, options = {}) {
45
45
  const [initializationDetails, setInitializationDetails] = (0, react_1.useState)(null);
46
46
  const [error, setError] = (0, react_1.useState)(null);
47
47
  const initializingRef = (0, react_1.useRef)(false);
48
+ const clientRef = (0, react_1.useRef)(null);
48
49
  // Skip initialization on server
49
50
  const shouldInitialize = !(0, ssrHelpers_1.isServer)();
50
51
  (0, react_1.useEffect)(() => {
@@ -64,6 +65,7 @@ function useClientAsyncInit(sdkKey, user, options = {}) {
64
65
  const details = yield newClient.initializeAsync(options.asyncOptions);
65
66
  if (!isMounted)
66
67
  return;
68
+ clientRef.current = newClient;
67
69
  setClient(newClient);
68
70
  setInitializationDetails(details);
69
71
  setIsInitialized(true);
@@ -86,10 +88,12 @@ function useClientAsyncInit(sdkKey, user, options = {}) {
86
88
  initializeClient();
87
89
  return () => {
88
90
  isMounted = false;
89
- if (client) {
90
- client.shutdown().catch((e) => {
91
+ initializingRef.current = false; // Reset so it can re-initialize if needed
92
+ if (clientRef.current) {
93
+ clientRef.current.shutdown().catch((e) => {
91
94
  console.error('Failed to shutdown Wolves client:', e);
92
95
  });
96
+ clientRef.current = null;
93
97
  }
94
98
  };
95
99
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -1 +1 @@
1
- {"version":3,"file":"useClientSyncInit.d.ts","sourceRoot":"","sources":["../../src/hooks/useClientSyncInit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,iBAAiB,EAA0B,MAAM,kBAAkB,CAAC;AAI5H,MAAM,WAAW,wBAAwB;IACvC,2DAA2D;IAC3D,MAAM,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;IAClC,sCAAsC;IACtC,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,qDAAqD;IACrD,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACvD,4CAA4C;IAC5C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,uBAAuB;IACtC,qEAAqE;IACrE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,mDAAmD;IACnD,SAAS,EAAE,OAAO,CAAC;IACnB,wDAAwD;IACxD,aAAa,EAAE,OAAO,CAAC;IACvB,kDAAkD;IAClD,qBAAqB,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAClD,oDAAoD;IACpD,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,EAChB,OAAO,GAAE,wBAA6B,GACrC,uBAAuB,CAyEzB"}
1
+ {"version":3,"file":"useClientSyncInit.d.ts","sourceRoot":"","sources":["../../src/hooks/useClientSyncInit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,iBAAiB,EAA0B,MAAM,kBAAkB,CAAC;AAI5H,MAAM,WAAW,wBAAwB;IACvC,2DAA2D;IAC3D,MAAM,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;IAClC,sCAAsC;IACtC,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,qDAAqD;IACrD,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACvD,4CAA4C;IAC5C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,uBAAuB;IACtC,qEAAqE;IACrE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,mDAAmD;IACnD,SAAS,EAAE,OAAO,CAAC;IACnB,wDAAwD;IACxD,aAAa,EAAE,OAAO,CAAC;IACvB,kDAAkD;IAClD,qBAAqB,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAClD,oDAAoD;IACpD,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,EAChB,OAAO,GAAE,wBAA6B,GACrC,uBAAuB,CA6EzB"}
@@ -38,6 +38,7 @@ function useClientSyncInit(sdkKey, user, options = {}) {
38
38
  const [initializationDetails, setInitializationDetails] = (0, react_1.useState)(null);
39
39
  const [error, setError] = (0, react_1.useState)(null);
40
40
  const initializingRef = (0, react_1.useRef)(false);
41
+ const clientRef = (0, react_1.useRef)(null);
41
42
  // Skip initialization on server
42
43
  const shouldInitialize = !(0, ssrHelpers_1.isServer)();
43
44
  (0, react_1.useEffect)(() => {
@@ -57,6 +58,7 @@ function useClientSyncInit(sdkKey, user, options = {}) {
57
58
  const details = newClient.initializeSync(options.syncOptions);
58
59
  if (!isMounted)
59
60
  return;
61
+ clientRef.current = newClient;
60
62
  setClient(newClient);
61
63
  setInitializationDetails(details);
62
64
  setIsInitialized(true);
@@ -79,10 +81,12 @@ function useClientSyncInit(sdkKey, user, options = {}) {
79
81
  initializeClient();
80
82
  return () => {
81
83
  isMounted = false;
82
- if (client) {
83
- client.shutdown().catch((e) => {
84
+ initializingRef.current = false; // Reset so it can re-initialize if needed
85
+ if (clientRef.current) {
86
+ clientRef.current.shutdown().catch((e) => {
84
87
  console.error('Failed to shutdown Wolves client:', e);
85
88
  });
89
+ clientRef.current = null;
86
90
  }
87
91
  };
88
92
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -2,8 +2,8 @@
2
2
  * React SDK Metadata
3
3
  * This file defines the SDK version and type for the Wolves React SDK
4
4
  */
5
- export declare const REACT_SDK_VERSION = "1.0.6";
6
- export declare const REACT_SDK_TYPE = "wolves-react-client";
5
+ export declare const REACT_SDK_VERSION: string;
6
+ export declare const REACT_SDK_TYPE: string;
7
7
  /**
8
8
  * Get React SDK metadata to override the JS SDK metadata
9
9
  */
@@ -1 +1 @@
1
- {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,iBAAiB,UAAU,CAAC;AACzC,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;CAG9B,CAAC"}
1
+ {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,eAAO,MAAM,iBAAiB,QAAsB,CAAC;AACrD,eAAO,MAAM,cAAc,QAAmB,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;CAG9B,CAAC"}
package/dist/metadata.js CHANGED
@@ -3,10 +3,14 @@
3
3
  * React SDK Metadata
4
4
  * This file defines the SDK version and type for the Wolves React SDK
5
5
  */
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
6
9
  Object.defineProperty(exports, "__esModule", { value: true });
7
10
  exports.getReactSDKMetadata = exports.REACT_SDK_TYPE = exports.REACT_SDK_VERSION = void 0;
8
- exports.REACT_SDK_VERSION = '1.0.6';
9
- exports.REACT_SDK_TYPE = 'wolves-react-client';
11
+ const package_json_1 = __importDefault(require("../package.json"));
12
+ exports.REACT_SDK_VERSION = package_json_1.default.version;
13
+ exports.REACT_SDK_TYPE = package_json_1.default.name;
10
14
  /**
11
15
  * Get React SDK metadata to override the JS SDK metadata
12
16
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wolves-react-client",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "React SDK for Wolves A/B Testing Platform",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",