@kameleoon/react-sdk 2.1.0 → 4.0.1
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/README.md +252 -51
- package/dist/Feature.js +2 -2
- package/dist/Feature.js.map +1 -1
- package/dist/KameleoonError.d.ts +5 -0
- package/dist/KameleoonError.js +31 -0
- package/dist/KameleoonError.js.map +1 -0
- package/dist/compose.d.ts +1 -1
- package/dist/compose.js +27 -2
- package/dist/compose.js.map +1 -1
- package/dist/constants.d.ts +10 -0
- package/dist/constants.js +12 -1
- package/dist/constants.js.map +1 -1
- package/dist/getKameleoonException.d.ts +2 -0
- package/dist/getKameleoonException.js +34 -0
- package/dist/getKameleoonException.js.map +1 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/stories/Form.d.ts +15 -8
- package/dist/stories/Form.js +82 -21
- package/dist/stories/Form.js.map +1 -1
- package/dist/stories/FormHOC.js +1 -1
- package/dist/stories/FormHOC.js.map +1 -1
- package/dist/stories/FormHook.js +14 -8
- package/dist/stories/FormHook.js.map +1 -1
- package/dist/stories/constants.d.ts +1 -0
- package/dist/stories/constants.js +2 -1
- package/dist/stories/constants.js.map +1 -1
- package/dist/types.d.ts +14 -6
- package/dist/types.js.map +1 -1
- package/dist/useActivateFeature.d.ts +3 -1
- package/dist/useActivateFeature.js +15 -3
- package/dist/useActivateFeature.js.map +1 -1
- package/dist/useAddData.js +17 -1
- package/dist/useAddData.js.map +1 -1
- package/dist/useDevice.d.ts +12 -0
- package/dist/useDevice.js +16 -0
- package/dist/useDevice.js.map +1 -0
- package/dist/useError.d.ts +7 -0
- package/dist/useError.js +34 -0
- package/dist/useError.js.map +1 -0
- package/dist/useErrors.d.ts +7 -0
- package/dist/useErrors.js +42 -0
- package/dist/useErrors.js.map +1 -0
- package/dist/useFeature.js +30 -9
- package/dist/useFeature.js.map +1 -1
- package/dist/useFeatureVariable.d.ts +2 -0
- package/dist/useFeatureVariable.js +11 -6
- package/dist/useFeatureVariable.js.map +1 -1
- package/dist/useRetrieveDataFromRemoteSource.d.ts +2 -2
- package/dist/useRetrieveDataFromRemoteSource.js +8 -5
- package/dist/useRetrieveDataFromRemoteSource.js.map +1 -1
- package/dist/useRunWhenReady.d.ts +14 -0
- package/dist/useRunWhenReady.js +23 -0
- package/dist/useRunWhenReady.js.map +1 -0
- package/dist/useTriggerExperiment.d.ts +2 -0
- package/dist/useTriggerExperiment.js +12 -2
- package/dist/useTriggerExperiment.js.map +1 -1
- package/dist/useVariationAssociatedData.d.ts +4 -2
- package/dist/useVariationAssociatedData.js +11 -2
- package/dist/useVariationAssociatedData.js.map +1 -1
- package/dist/withActivateFeature.d.ts +3 -1
- package/dist/withActivateFeature.js +3 -11
- package/dist/withActivateFeature.js.map +1 -1
- package/dist/withAddData.js +17 -1
- package/dist/withAddData.js.map +1 -1
- package/dist/withDevice.d.ts +15 -0
- package/dist/{withInterest.js → withDevice.js} +7 -9
- package/dist/withDevice.js.map +1 -0
- package/dist/withFeature.js +2 -2
- package/dist/withFeature.js.map +1 -1
- package/dist/withFeatureVariable.d.ts +2 -0
- package/dist/withFeatureVariable.js +2 -2
- package/dist/withFeatureVariable.js.map +1 -1
- package/dist/withRunWhenReady.d.ts +16 -0
- package/dist/withRunWhenReady.js +28 -0
- package/dist/withRunWhenReady.js.map +1 -0
- package/dist/withTriggerExperiment.d.ts +2 -0
- package/dist/withTriggerExperiment.js +3 -11
- package/dist/withTriggerExperiment.js.map +1 -1
- package/dist/withVariationAssociatedData.d.ts +4 -2
- package/dist/withVariationAssociatedData.js +3 -11
- package/dist/withVariationAssociatedData.js.map +1 -1
- package/package.json +2 -2
- package/CHANGELOG.md +0 -69
- package/dist/useInterest.d.ts +0 -12
- package/dist/useInterest.js +0 -16
- package/dist/useInterest.js.map +0 -1
- package/dist/withInterest.d.ts +0 -15
- package/dist/withInterest.js.map +0 -1
|
@@ -13,23 +13,15 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.withActivateFeature = void 0;
|
|
15
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
-
var
|
|
17
|
-
var KameleoonContext_1 = require("./KameleoonContext");
|
|
18
|
-
var ProviderError_1 = require("./ProviderError");
|
|
16
|
+
var useActivateFeature_1 = require("./useActivateFeature");
|
|
19
17
|
/**
|
|
20
18
|
* A React HOC that gives a wrapped component access to callback
|
|
21
19
|
* function which activates a feature toggle
|
|
22
20
|
*/
|
|
23
21
|
function withActivateFeature(Component) {
|
|
24
22
|
return function WrappedComponent(props) {
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
if (!client) {
|
|
28
|
-
throw new ProviderError_1.ProviderError('withActivateFeature');
|
|
29
|
-
}
|
|
30
|
-
return client.activateFeature(visitorCode, featureKey);
|
|
31
|
-
}, [client]);
|
|
32
|
-
return (0, jsx_runtime_1.jsx)(Component, __assign({ hasFeature: hasFeature }, props), void 0);
|
|
23
|
+
var _a = (0, useActivateFeature_1.useActivateFeature)(), hasFeature = _a.hasFeature, activateFeatureError = _a.error;
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(Component, __assign({ hasFeature: hasFeature, activateFeatureError: activateFeatureError }, props), void 0));
|
|
33
25
|
};
|
|
34
26
|
}
|
|
35
27
|
exports.withActivateFeature = withActivateFeature;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withActivateFeature.js","sourceRoot":"","sources":["../src/withActivateFeature.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"withActivateFeature.js","sourceRoot":"","sources":["../src/withActivateFeature.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,2DAA0D;AAY1D;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QACrC,IAAA,KAA8C,IAAA,uCAAkB,GAAE,EAAhE,UAAU,gBAAA,EAAS,oBAAoB,WAAyB,CAAC;QAEzE,OAAO,CACL,uBAAC,SAAS,aACR,UAAU,EAAE,UAAU,EACtB,oBAAoB,EAAE,oBAAoB,IACrC,KAAe,UACpB,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAdD,kDAcC"}
|
package/dist/withAddData.js
CHANGED
|
@@ -10,6 +10,22 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
+
if (!m) return o;
|
|
16
|
+
var i = m.call(o), r, ar = [], e;
|
|
17
|
+
try {
|
|
18
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
+
}
|
|
20
|
+
catch (error) { e = { error: error }; }
|
|
21
|
+
finally {
|
|
22
|
+
try {
|
|
23
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
+
}
|
|
25
|
+
finally { if (e) throw e.error; }
|
|
26
|
+
}
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
13
29
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
30
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
31
|
if (ar || !(i in from)) {
|
|
@@ -40,7 +56,7 @@ function withAddData(Component) {
|
|
|
40
56
|
if (!client) {
|
|
41
57
|
throw new ProviderError_1.ProviderError('withAddData');
|
|
42
58
|
}
|
|
43
|
-
return client.addData.apply(client, __spreadArray([visitorCode], dataTypes, false));
|
|
59
|
+
return client.addData.apply(client, __spreadArray([visitorCode], __read(dataTypes), false));
|
|
44
60
|
}, [client]);
|
|
45
61
|
return (0, jsx_runtime_1.jsx)(Component, __assign({ addData: addData }, props), void 0);
|
|
46
62
|
};
|
package/dist/withAddData.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withAddData.js","sourceRoot":"","sources":["../src/withAddData.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"withAddData.js","sourceRoot":"","sources":["../src/withAddData.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAuD;AAGvD,uDAAsD;AACtD,iDAAgD;AAUhD;;;GAGG;AACH,SAAgB,WAAW,CACzB,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,mCAAgB,CAAC,CAAC;QAE5C,IAAM,OAAO,GAAG,IAAA,mBAAW,EACzB,UAAC,WAAmB;YAAE,mBAAqB;iBAArB,UAAqB,EAArB,qBAAqB,EAArB,IAAqB;gBAArB,kCAAqB;;YACzC,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,6BAAa,CAAC,aAAa,CAAC,CAAC;aACxC;YAED,OAAO,MAAM,CAAC,OAAO,OAAd,MAAM,iBAAS,WAAW,UAAK,SAAS,WAAE;QACnD,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;QAEF,OAAO,uBAAC,SAAS,aAAC,OAAO,EAAE,OAAO,IAAO,KAAe,UAAI,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC;AAnBD,kCAmBC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Device as IDevice, DeviceType } from 'kameleoon-client-javascript/dist/data';
|
|
3
|
+
import { UnknownPropsType, Without } from './types';
|
|
4
|
+
interface IWithDevice {
|
|
5
|
+
/**
|
|
6
|
+
* @param device - device types: Phone, Tablet, Desktop
|
|
7
|
+
*/
|
|
8
|
+
addDevice: (device: DeviceType) => IDevice;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A React HOC that gives a wrapped component access to callback function
|
|
12
|
+
* which adds device type
|
|
13
|
+
*/
|
|
14
|
+
export declare function withDevice<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithDevice>>;
|
|
15
|
+
export {};
|
|
@@ -11,21 +11,19 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.
|
|
14
|
+
exports.withDevice = void 0;
|
|
15
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
16
|
var react_1 = require("react");
|
|
17
17
|
var kameleoon_client_javascript_1 = require("kameleoon-client-javascript");
|
|
18
18
|
/**
|
|
19
19
|
* A React HOC that gives a wrapped component access to callback function
|
|
20
|
-
* which adds
|
|
20
|
+
* which adds device type
|
|
21
21
|
*/
|
|
22
|
-
function
|
|
22
|
+
function withDevice(Component) {
|
|
23
23
|
return function WrappedComponent(props) {
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
}, []);
|
|
27
|
-
return (0, jsx_runtime_1.jsx)(Component, __assign({ addInterest: addInterest }, props), void 0);
|
|
24
|
+
var addDevice = (0, react_1.useCallback)(function (device) { return new kameleoon_client_javascript_1.KameleoonData.Device(device); }, []);
|
|
25
|
+
return (0, jsx_runtime_1.jsx)(Component, __assign({ addDevice: addDevice }, props), void 0);
|
|
28
26
|
};
|
|
29
27
|
}
|
|
30
|
-
exports.
|
|
31
|
-
//# sourceMappingURL=
|
|
28
|
+
exports.withDevice = withDevice;
|
|
29
|
+
//# sourceMappingURL=withDevice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withDevice.js","sourceRoot":"","sources":["../src/withDevice.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAA2C;AAK3C,2EAA4D;AAU5D;;;GAGG;AACH,SAAgB,UAAU,CACxB,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,SAAS,GAAG,IAAA,mBAAW,EAC3B,UAAC,MAAkB,IAAc,OAAA,IAAI,2CAAa,CAAC,MAAM,CAAC,MAAM,CAAC,EAAhC,CAAgC,EACjE,EAAE,CACH,CAAC;QAEF,OAAO,uBAAC,SAAS,aAAC,SAAS,EAAE,SAAS,IAAO,KAAe,UAAI,CAAC;IACnE,CAAC,CAAC;AACJ,CAAC;AAXD,gCAWC"}
|
package/dist/withFeature.js
CHANGED
|
@@ -22,8 +22,8 @@ function withFeature(args) {
|
|
|
22
22
|
// e.g. withFeature(...args)(Component)
|
|
23
23
|
return function callbackWithArgs(Component) {
|
|
24
24
|
return function WrappedComponent(props) {
|
|
25
|
-
var
|
|
26
|
-
return (0, jsx_runtime_1.jsx)(Component, __assign({ feature: feature }, props), void 0);
|
|
25
|
+
var _a = (0, useFeature_1.useFeature)(__assign({}, args)), feature = _a.feature, featureErrors = _a.errors;
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(Component, __assign({ feature: feature, featureErrors: featureErrors }, props), void 0));
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
29
|
}
|
package/dist/withFeature.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withFeature.js","sourceRoot":"","sources":["../src/withFeature.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,2CAA0C;AAE1C;;GAEG;AACH,SAAgB,WAAW,CAAC,IAAoB;IAC9C,oEAAoE;IACpE,uCAAuC;IACvC,OAAO,SAAS,gBAAgB,CAC9B,SAAqC;QAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;
|
|
1
|
+
{"version":3,"file":"withFeature.js","sourceRoot":"","sources":["../src/withFeature.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,2CAA0C;AAE1C;;GAEG;AACH,SAAgB,WAAW,CAAC,IAAoB;IAC9C,oEAAoE;IACpE,uCAAuC;IACvC,OAAO,SAAS,gBAAgB,CAC9B,SAAqC;QAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;YACrC,IAAA,KAAqC,IAAA,uBAAU,eAAM,IAAI,EAAG,EAA1D,OAAO,aAAA,EAAU,aAAa,YAA4B,CAAC;YAEnE,OAAO,CACL,uBAAC,SAAS,aACR,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,IACvB,KAAe,UACpB,CACH,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAlBD,kCAkBC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { KameleoonError } from './KameleoonError';
|
|
2
3
|
import { FeatureFlagVariableType, UnknownPropsType, Without } from './types';
|
|
3
4
|
interface IWithFeatureVariable {
|
|
4
5
|
/**
|
|
@@ -6,6 +7,7 @@ interface IWithFeatureVariable {
|
|
|
6
7
|
* @param variableKey - key of the variable
|
|
7
8
|
*/
|
|
8
9
|
getFeatureVariable: (featureKey: string | number, variableKey: string) => FeatureFlagVariableType;
|
|
10
|
+
featureVariableError: KameleoonError | null;
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
13
|
* A React HOC that gives a wrapped component access to callback function
|
|
@@ -20,8 +20,8 @@ var useFeatureVariable_1 = require("./useFeatureVariable");
|
|
|
20
20
|
*/
|
|
21
21
|
function withFeatureVariable(Component) {
|
|
22
22
|
return function WrappedComponent(props) {
|
|
23
|
-
var
|
|
24
|
-
return ((0, jsx_runtime_1.jsx)(Component, __assign({ getFeatureVariable: getFeatureVariable }, props), void 0));
|
|
23
|
+
var _a = (0, useFeatureVariable_1.useFeatureVariable)(), getFeatureVariable = _a.getFeatureVariable, featureVariableError = _a.error;
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(Component, __assign({ getFeatureVariable: getFeatureVariable, featureVariableError: featureVariableError }, props), void 0));
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
exports.withFeatureVariable = withFeatureVariable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withFeatureVariable.js","sourceRoot":"","sources":["../src/withFeatureVariable.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"withFeatureVariable.js","sourceRoot":"","sources":["../src/withFeatureVariable.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,2DAA0D;AAc1D;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QACrC,IAAA,KACJ,IAAA,uCAAkB,GAAE,EADd,kBAAkB,wBAAA,EAAS,oBAAoB,WACjC,CAAC;QAEvB,OAAO,CACL,uBAAC,SAAS,aACR,kBAAkB,EAAE,kBAAkB,EACtC,oBAAoB,EAAE,oBAAoB,IACrC,KAAe,UACpB,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAfD,kDAeC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { UnknownPropsType, Without } from './types';
|
|
3
|
+
interface IWithRunWhenReadyData {
|
|
4
|
+
/**
|
|
5
|
+
* @param successCallback - callback which will be executed on successful client initialization
|
|
6
|
+
* @param errorCallback - callback which will be executed if client wasn't able to initialize during the timeout
|
|
7
|
+
* @param timeout - timeout which is given to perform HTTP call for initialization in ms (by default: 2 seconds)
|
|
8
|
+
*/
|
|
9
|
+
runWhenReady: (successCallback: () => void, errorCallback: () => void, timeout?: number) => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A React HOC that gives a wrapped component access to callback function which makes sure that
|
|
13
|
+
* Kameleoon Client will be initialized properly using HTTP call within the specified timeout
|
|
14
|
+
*/
|
|
15
|
+
export declare function withRunWhenReady<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithRunWhenReadyData>>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.withRunWhenReady = void 0;
|
|
15
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
var useRunWhenReady_1 = require("./useRunWhenReady");
|
|
17
|
+
/**
|
|
18
|
+
* A React HOC that gives a wrapped component access to callback function which makes sure that
|
|
19
|
+
* Kameleoon Client will be initialized properly using HTTP call within the specified timeout
|
|
20
|
+
*/
|
|
21
|
+
function withRunWhenReady(Component) {
|
|
22
|
+
return function WrappedComponent(props) {
|
|
23
|
+
var runWhenReady = (0, useRunWhenReady_1.useRunWhenReady)().runWhenReady;
|
|
24
|
+
return (0, jsx_runtime_1.jsx)(Component, __assign({ runWhenReady: runWhenReady }, props), void 0);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.withRunWhenReady = withRunWhenReady;
|
|
28
|
+
//# sourceMappingURL=withRunWhenReady.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withRunWhenReady.js","sourceRoot":"","sources":["../src/withRunWhenReady.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,qDAAoD;AAepD;;;GAGG;AACH,SAAgB,gBAAgB,CAC9B,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QACnC,IAAA,YAAY,GAAK,IAAA,iCAAe,GAAE,aAAtB,CAAuB;QAE3C,OAAO,uBAAC,SAAS,aAAC,YAAY,EAAE,YAAY,IAAO,KAAe,UAAI,CAAC;IACzE,CAAC,CAAC;AACJ,CAAC;AARD,4CAQC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { KameleoonError } from './KameleoonError';
|
|
2
3
|
import { UnknownPropsType, Without } from './types';
|
|
3
4
|
interface IWithTriggerExperiment {
|
|
4
5
|
/**
|
|
@@ -6,6 +7,7 @@ interface IWithTriggerExperiment {
|
|
|
6
7
|
* @param experimentId - unique identifier of the experiment you want to expose to a user
|
|
7
8
|
*/
|
|
8
9
|
getVariationId: (visitorCode: string, experimentId: number) => number;
|
|
10
|
+
triggerExperimentError: KameleoonError | null;
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
13
|
* A React HOC that gives a wrapped component access to callback function which triggers experiment
|
|
@@ -13,9 +13,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.withTriggerExperiment = void 0;
|
|
15
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
-
var
|
|
17
|
-
var KameleoonContext_1 = require("./KameleoonContext");
|
|
18
|
-
var ProviderError_1 = require("./ProviderError");
|
|
16
|
+
var useTriggerExperiment_1 = require("./useTriggerExperiment");
|
|
19
17
|
/**
|
|
20
18
|
* A React HOC that gives a wrapped component access to callback function which triggers experiment
|
|
21
19
|
* If such a user has never been associated with any variation, the SDK returns a randomly selected variation.
|
|
@@ -24,14 +22,8 @@ var ProviderError_1 = require("./ProviderError");
|
|
|
24
22
|
*/
|
|
25
23
|
function withTriggerExperiment(Component) {
|
|
26
24
|
return function WrappedComponent(props) {
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
if (!client) {
|
|
30
|
-
throw new ProviderError_1.ProviderError('withTriggerExperiment');
|
|
31
|
-
}
|
|
32
|
-
return client.triggerExperiment(visitorCode, experimentId);
|
|
33
|
-
}, [client]);
|
|
34
|
-
return (0, jsx_runtime_1.jsx)(Component, __assign({ getVariationId: getVariationId }, props), void 0);
|
|
25
|
+
var _a = (0, useTriggerExperiment_1.useTriggerExperiment)(), getVariationId = _a.getVariationId, triggerExperimentError = _a.error;
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(Component, __assign({ getVariationId: getVariationId, triggerExperimentError: triggerExperimentError }, props), void 0));
|
|
35
27
|
};
|
|
36
28
|
}
|
|
37
29
|
exports.withTriggerExperiment = withTriggerExperiment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withTriggerExperiment.js","sourceRoot":"","sources":["../src/withTriggerExperiment.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"withTriggerExperiment.js","sourceRoot":"","sources":["../src/withTriggerExperiment.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,+DAA8D;AAW9D;;;;;GAKG;AACH,SAAgB,qBAAqB,CACnC,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QACrC,IAAA,KACJ,IAAA,2CAAoB,GAAE,EADhB,cAAc,oBAAA,EAAS,sBAAsB,WAC7B,CAAC;QAEzB,OAAO,CACL,uBAAC,SAAS,aACR,cAAc,EAAE,cAAc,EAC9B,sBAAsB,EAAE,sBAAsB,IACzC,KAAe,UACpB,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAfD,sDAeC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { UnknownPropsType, Without,
|
|
2
|
+
import { UnknownPropsType, Without, VariationAssociatedDataType } from './types';
|
|
3
|
+
import { KameleoonError } from './KameleoonError';
|
|
3
4
|
interface IWithVariationAssociatedData {
|
|
4
5
|
/**
|
|
5
6
|
* @param variationId - unique identifier of the variation you want to obtain associated data for
|
|
6
7
|
*/
|
|
7
|
-
getVariationAssociatedData: (variationId: number) =>
|
|
8
|
+
getVariationAssociatedData: (variationId: number) => VariationAssociatedDataType;
|
|
9
|
+
variationAssociatedDataError: KameleoonError | null;
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
12
|
* A React HOC that gives a wrapped component access to callback function which
|
|
@@ -13,9 +13,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.withVariationAssociatedData = void 0;
|
|
15
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
-
var
|
|
17
|
-
var KameleoonContext_1 = require("./KameleoonContext");
|
|
18
|
-
var ProviderError_1 = require("./ProviderError");
|
|
16
|
+
var useVariationAssociatedData_1 = require("./useVariationAssociatedData");
|
|
19
17
|
/**
|
|
20
18
|
* A React HOC that gives a wrapped component access to callback function which
|
|
21
19
|
* retrieves JSON data associated with a variation.
|
|
@@ -24,14 +22,8 @@ var ProviderError_1 = require("./ProviderError");
|
|
|
24
22
|
*/
|
|
25
23
|
function withVariationAssociatedData(Component) {
|
|
26
24
|
return function WrappedComponent(props) {
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
if (!client) {
|
|
30
|
-
throw new ProviderError_1.ProviderError('withVariationAssociatedData');
|
|
31
|
-
}
|
|
32
|
-
return client.obtainVariationAssociatedData(variationId);
|
|
33
|
-
}, [client]);
|
|
34
|
-
return ((0, jsx_runtime_1.jsx)(Component, __assign({ getVariationAssociatedData: getVariationAssociatedData }, props), void 0));
|
|
25
|
+
var _a = (0, useVariationAssociatedData_1.useVariationAssociatedData)(), getVariationAssociatedData = _a.getVariationAssociatedData, variationAssociatedDataError = _a.error;
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(Component, __assign({ getVariationAssociatedData: getVariationAssociatedData, variationAssociatedDataError: variationAssociatedDataError }, props), void 0));
|
|
35
27
|
};
|
|
36
28
|
}
|
|
37
29
|
exports.withVariationAssociatedData = withVariationAssociatedData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withVariationAssociatedData.js","sourceRoot":"","sources":["../src/withVariationAssociatedData.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"withVariationAssociatedData.js","sourceRoot":"","sources":["../src/withVariationAssociatedData.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMA,2EAA0E;AAa1E;;;;;GAKG;AACH,SAAgB,2BAA2B,CACzC,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QACrC,IAAA,KACJ,IAAA,uDAA0B,GAAE,EADtB,0BAA0B,gCAAA,EAAS,4BAA4B,WACzC,CAAC;QAE/B,OAAO,CACL,uBAAC,SAAS,aACR,0BAA0B,EAAE,0BAA0B,EACtD,4BAA4B,EAAE,4BAA4B,IACrD,KAAe,UACpB,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAfD,kEAeC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kameleoon/react-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Kameleoon React SDK",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@types/validator": "^13.6.3",
|
|
38
|
-
"kameleoon-client-javascript": "^1.0.
|
|
38
|
+
"kameleoon-client-javascript": "^1.0.9",
|
|
39
39
|
"validator": "^13.6.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
package/CHANGELOG.md
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
[Project Homepage](https://developers.kameleoon.com/react-js-sdk.html)
|
|
7
|
-
|
|
8
|
-
# 2.1.0 (2022-04-18)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Features
|
|
12
|
-
|
|
13
|
-
* retrieve data from remote source
|
|
14
|
-
|
|
15
|
-
# 2.0.0 (2022-02-24)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### Features
|
|
19
|
-
|
|
20
|
-
* add multi environment support
|
|
21
|
-
|
|
22
|
-
### Breaking change
|
|
23
|
-
|
|
24
|
-
* variableKeys became an object and no longer can be used as an array or a string
|
|
25
|
-
|
|
26
|
-
# 1.2.2 (2022-02-06)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
### Bug fixes
|
|
30
|
-
|
|
31
|
-
* bundle source and internal changelog
|
|
32
|
-
|
|
33
|
-
# 1.2.1 (2022-02-06)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
### Bug fixes
|
|
37
|
-
|
|
38
|
-
* decrease bundle size
|
|
39
|
-
|
|
40
|
-
# 1.2.0 (2022-01-27)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
### Bug Fixes
|
|
44
|
-
|
|
45
|
-
* linting issues
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
# 1.1.0 (2022-01-26)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
### Bug Fixes
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* package json
|
|
55
|
-
|
|
56
|
-
# 1.0.0 (2022-01-20)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
### Bug Fixes
|
|
60
|
-
|
|
61
|
-
* linting and addData
|
|
62
|
-
|
|
63
|
-
### Features
|
|
64
|
-
|
|
65
|
-
* add HOCs
|
|
66
|
-
* add render props
|
|
67
|
-
* test react sdk methods
|
|
68
|
-
* complete the documentation
|
|
69
|
-
* add createClient, provider and hooks
|
package/dist/useInterest.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Interest } from 'kameleoon-client-javascript/dist/data';
|
|
2
|
-
interface InterestHookResult {
|
|
3
|
-
/**
|
|
4
|
-
* @param index - index of interest
|
|
5
|
-
*/
|
|
6
|
-
addInterest: (index: number) => Interest;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* A React Hook that returns callback function which adds interest
|
|
10
|
-
*/
|
|
11
|
-
export declare function useInterest(): InterestHookResult;
|
|
12
|
-
export {};
|
package/dist/useInterest.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useInterest = void 0;
|
|
4
|
-
var react_1 = require("react");
|
|
5
|
-
var kameleoon_client_javascript_1 = require("kameleoon-client-javascript");
|
|
6
|
-
/**
|
|
7
|
-
* A React Hook that returns callback function which adds interest
|
|
8
|
-
*/
|
|
9
|
-
function useInterest() {
|
|
10
|
-
var addInterest = (0, react_1.useCallback)(function (index) { return new kameleoon_client_javascript_1.KameleoonData.Interest(index); }, []);
|
|
11
|
-
return {
|
|
12
|
-
addInterest: addInterest,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
exports.useInterest = useInterest;
|
|
16
|
-
//# sourceMappingURL=useInterest.js.map
|
package/dist/useInterest.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInterest.js","sourceRoot":"","sources":["../src/useInterest.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,2EAA4D;AAU5D;;GAEG;AACH,SAAgB,WAAW;IACzB,IAAM,WAAW,GAAG,IAAA,mBAAW,EAC7B,UAAC,KAAa,IAAe,OAAA,IAAI,2CAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAjC,CAAiC,EAC9D,EAAE,CACH,CAAC;IAEF,OAAO;QACL,WAAW,aAAA;KACZ,CAAC;AACJ,CAAC;AATD,kCASC"}
|
package/dist/withInterest.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Interest } from 'kameleoon-client-javascript/dist/data';
|
|
3
|
-
import { UnknownPropsType, Without } from './types';
|
|
4
|
-
interface IWithInterest {
|
|
5
|
-
/**
|
|
6
|
-
* @param index - index of interest
|
|
7
|
-
*/
|
|
8
|
-
addInterest: (index: number) => Interest;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* A React HOC that gives a wrapped component access to callback function
|
|
12
|
-
* which adds interest
|
|
13
|
-
*/
|
|
14
|
-
export declare function withInterest<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithInterest>>;
|
|
15
|
-
export {};
|
package/dist/withInterest.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withInterest.js","sourceRoot":"","sources":["../src/withInterest.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAA2C;AAE3C,2EAA4D;AAU5D;;;GAGG;AACH,SAAgB,YAAY,CAC1B,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,WAAW,GAAG,IAAA,mBAAW,EAAC,UAAC,KAAa;YAC5C,OAAO,IAAI,2CAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC3C,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,OAAO,uBAAC,SAAS,aAAC,WAAW,EAAE,WAAW,IAAO,KAAe,UAAI,CAAC;IACvE,CAAC,CAAC;AACJ,CAAC;AAVD,oCAUC"}
|