@kameleoon/react-sdk 1.2.2 → 3.0.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.
Files changed (104) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +315 -43
  3. package/dist/Feature.js +2 -2
  4. package/dist/Feature.js.map +1 -1
  5. package/dist/KameleoonError.d.ts +5 -0
  6. package/dist/KameleoonError.js +31 -0
  7. package/dist/KameleoonError.js.map +1 -0
  8. package/dist/compose.d.ts +1 -1
  9. package/dist/compose.js +27 -2
  10. package/dist/compose.js.map +1 -1
  11. package/dist/constants.d.ts +11 -0
  12. package/dist/constants.js +13 -1
  13. package/dist/constants.js.map +1 -1
  14. package/dist/getKameleoonException.d.ts +2 -0
  15. package/dist/getKameleoonException.js +34 -0
  16. package/dist/getKameleoonException.js.map +1 -0
  17. package/dist/index.d.ts +6 -1
  18. package/dist/index.js +21 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/stories/Form.d.ts +13 -5
  21. package/dist/stories/Form.js +154 -36
  22. package/dist/stories/Form.js.map +1 -1
  23. package/dist/stories/FormHOC.js +12 -7
  24. package/dist/stories/FormHOC.js.map +1 -1
  25. package/dist/stories/FormHook.js +34 -21
  26. package/dist/stories/FormHook.js.map +1 -1
  27. package/dist/stories/constants.d.ts +5 -2
  28. package/dist/stories/constants.js +11 -8
  29. package/dist/stories/constants.js.map +1 -1
  30. package/dist/types.d.ts +24 -7
  31. package/dist/types.js.map +1 -1
  32. package/dist/useActivateFeature.d.ts +2 -0
  33. package/dist/useActivateFeature.js +11 -2
  34. package/dist/useActivateFeature.js.map +1 -1
  35. package/dist/useAddData.js +17 -1
  36. package/dist/useAddData.js.map +1 -1
  37. package/dist/useConversion.d.ts +1 -1
  38. package/dist/useError.d.ts +7 -0
  39. package/dist/useError.js +34 -0
  40. package/dist/useError.js.map +1 -0
  41. package/dist/useErrors.d.ts +7 -0
  42. package/dist/useErrors.js +42 -0
  43. package/dist/useErrors.js.map +1 -0
  44. package/dist/useFeature.d.ts +1 -1
  45. package/dist/useFeature.js +42 -13
  46. package/dist/useFeature.js.map +1 -1
  47. package/dist/useFeatureVariable.d.ts +2 -0
  48. package/dist/useFeatureVariable.js +11 -2
  49. package/dist/useFeatureVariable.js.map +1 -1
  50. package/dist/useRetrieveDataFromRemoteSource.d.ts +12 -0
  51. package/dist/useRetrieveDataFromRemoteSource.js +79 -0
  52. package/dist/useRetrieveDataFromRemoteSource.js.map +1 -0
  53. package/dist/useRunWhenReady.d.ts +14 -0
  54. package/dist/useRunWhenReady.js +23 -0
  55. package/dist/useRunWhenReady.js.map +1 -0
  56. package/dist/useTriggerExperiment.d.ts +2 -0
  57. package/dist/useTriggerExperiment.js +12 -2
  58. package/dist/useTriggerExperiment.js.map +1 -1
  59. package/dist/useVariationAssociatedData.d.ts +6 -4
  60. package/dist/useVariationAssociatedData.js +11 -2
  61. package/dist/useVariationAssociatedData.js.map +1 -1
  62. package/dist/withActivateFeature.d.ts +2 -0
  63. package/dist/withActivateFeature.js +3 -12
  64. package/dist/withActivateFeature.js.map +1 -1
  65. package/dist/withAddData.js +17 -2
  66. package/dist/withAddData.js.map +1 -1
  67. package/dist/withBrowser.js +0 -1
  68. package/dist/withBrowser.js.map +1 -1
  69. package/dist/withConversion.d.ts +1 -1
  70. package/dist/withConversion.js +0 -1
  71. package/dist/withConversion.js.map +1 -1
  72. package/dist/withCustomData.js +0 -1
  73. package/dist/withCustomData.js.map +1 -1
  74. package/dist/withFeature.js +2 -3
  75. package/dist/withFeature.js.map +1 -1
  76. package/dist/withFeatureVariable.d.ts +2 -0
  77. package/dist/withFeatureVariable.js +2 -2
  78. package/dist/withFeatureVariable.js.map +1 -1
  79. package/dist/withFlush.js +0 -1
  80. package/dist/withFlush.js.map +1 -1
  81. package/dist/withInterest.js +0 -1
  82. package/dist/withInterest.js.map +1 -1
  83. package/dist/withKameleoon.js +0 -1
  84. package/dist/withKameleoon.js.map +1 -1
  85. package/dist/withPageView.js +0 -1
  86. package/dist/withPageView.js.map +1 -1
  87. package/dist/withRetrieveDataFromRemoteSource.d.ts +14 -0
  88. package/dist/withRetrieveDataFromRemoteSource.js +28 -0
  89. package/dist/withRetrieveDataFromRemoteSource.js.map +1 -0
  90. package/dist/withRunWhenReady.d.ts +16 -0
  91. package/dist/withRunWhenReady.js +28 -0
  92. package/dist/withRunWhenReady.js.map +1 -0
  93. package/dist/withTrackingConversion.d.ts +1 -1
  94. package/dist/withTrackingConversion.js +4 -6
  95. package/dist/withTrackingConversion.js.map +1 -1
  96. package/dist/withTriggerExperiment.d.ts +3 -1
  97. package/dist/withTriggerExperiment.js +4 -13
  98. package/dist/withTriggerExperiment.js.map +1 -1
  99. package/dist/withVariationAssociatedData.d.ts +4 -2
  100. package/dist/withVariationAssociatedData.js +3 -11
  101. package/dist/withVariationAssociatedData.js.map +1 -1
  102. package/dist/withVisitorCode.js +0 -1
  103. package/dist/withVisitorCode.js.map +1 -1
  104. package/package.json +3 -2
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.useRetrieveDataFromRemoteSource = void 0;
40
+ var react_1 = require("react");
41
+ var useKameleoon_1 = require("./useKameleoon");
42
+ var ProviderError_1 = require("./ProviderError");
43
+ var KameleoonError_1 = require("./KameleoonError");
44
+ var constants_1 = require("./constants");
45
+ /**
46
+ * A React Hook that returns asynchronous callback function which retrieves data from Kameleoon Data API
47
+ */
48
+ function useRetrieveDataFromRemoteSource() {
49
+ var _this = this;
50
+ var client = (0, useKameleoon_1.useKameleoon)().client;
51
+ var isObjectEmpty = (0, react_1.useCallback)(function (object) {
52
+ return (object &&
53
+ Object.keys(object).length === 0 &&
54
+ Object.getPrototypeOf(object) === Object.prototype);
55
+ }, []);
56
+ var retrieveDataFromRemoteSource = (0, react_1.useCallback)(function (key) { return __awaiter(_this, void 0, void 0, function () {
57
+ var resultData, error;
58
+ return __generator(this, function (_a) {
59
+ switch (_a.label) {
60
+ case 0: return [4 /*yield*/, client.retrieveDataFromRemoteSource(key)];
61
+ case 1:
62
+ resultData = (_a.sent());
63
+ if (isObjectEmpty(resultData)) {
64
+ error = new KameleoonError_1.KameleoonError(constants_1.KameleoonException.NoDataWasRetrievedFromRemoteServer);
65
+ return [2 /*return*/, { data: null, error: error }];
66
+ }
67
+ return [2 /*return*/, { data: resultData, error: null }];
68
+ }
69
+ });
70
+ }); }, [client, isObjectEmpty]);
71
+ if (!client) {
72
+ throw new ProviderError_1.ProviderError('useKameleoon');
73
+ }
74
+ return {
75
+ retrieveDataFromRemoteSource: retrieveDataFromRemoteSource,
76
+ };
77
+ }
78
+ exports.useRetrieveDataFromRemoteSource = useRetrieveDataFromRemoteSource;
79
+ //# sourceMappingURL=useRetrieveDataFromRemoteSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRetrieveDataFromRemoteSource.js","sourceRoot":"","sources":["../src/useRetrieveDataFromRemoteSource.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAoC;AACpC,+CAA8C;AAC9C,iDAAgD;AAEhD,mDAAkD;AAClD,yCAAiD;AAWjD;;GAEG;AACH,SAAgB,+BAA+B;IAA/C,iBAqCC;IApCS,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAElC,IAAM,aAAa,GAAG,IAAA,mBAAW,EAAC,UAAC,MAA4B;QAC7D,OAAO,CACL,MAAM;YACN,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC;YAChC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC,SAAS,CACnD,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAM,4BAA4B,GAAG,IAAA,mBAAW,EAC9C,UAAO,GAAW;;;;wBACI,qBAAM,MAAM,CAAC,4BAA4B,CAC3D,GAAG,CACJ,EAAA;;oBAFK,UAAU,GAAG,CAAC,SAEnB,CAAyB;oBAE1B,IAAI,aAAa,CAAC,UAAU,CAAC,EAAE;wBACvB,KAAK,GAAG,IAAI,+BAAc,CAC9B,8BAAkB,CAAC,kCAAkC,CACtD,CAAC;wBAEF,sBAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,OAAA,EAAE,EAAC;qBAC9B;oBAED,sBAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,EAAC;;;SAC1C,EACD,CAAC,MAAM,EAAE,aAAa,CAAC,CACxB,CAAC;IAEF,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,6BAAa,CAAC,cAAc,CAAC,CAAC;KACzC;IAED,OAAO;QACL,4BAA4B,8BAAA;KAC7B,CAAC;AACJ,CAAC;AArCD,0EAqCC"}
@@ -0,0 +1,14 @@
1
+ interface RunWhenReadyHookResult {
2
+ /**
3
+ * @param successCallback - callback which will be executed on successful client initialization
4
+ * @param errorCallback - callback which will be executed if client wasn't able to initialize during the timeout
5
+ * @param timeout - timeout which is given to perform HTTP call for initialization in ms (by default: 2 seconds)
6
+ */
7
+ runWhenReady: (successCallback: () => void, errorCallback: () => void, timeout?: number) => void;
8
+ }
9
+ /**
10
+ * A React Hook that returns callback function which makes sure that
11
+ * Kameleoon Client will be initialized properly using HTTP call within the specified timeout
12
+ */
13
+ export declare function useRunWhenReady(): RunWhenReadyHookResult;
14
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useRunWhenReady = void 0;
4
+ var react_1 = require("react");
5
+ var useKameleoon_1 = require("./useKameleoon");
6
+ var ProviderError_1 = require("./ProviderError");
7
+ /**
8
+ * A React Hook that returns callback function which makes sure that
9
+ * Kameleoon Client will be initialized properly using HTTP call within the specified timeout
10
+ */
11
+ function useRunWhenReady() {
12
+ var client = (0, useKameleoon_1.useKameleoon)().client;
13
+ var DEFAULT_TIMEOUT = 2000;
14
+ var runWhenReady = (0, react_1.useCallback)(function (successCallback, errorCallback, timeout) {
15
+ client.runWhenReady(successCallback, errorCallback, timeout !== null && timeout !== void 0 ? timeout : DEFAULT_TIMEOUT);
16
+ }, [client]);
17
+ if (!client) {
18
+ throw new ProviderError_1.ProviderError('useRunWhenReady');
19
+ }
20
+ return { runWhenReady: runWhenReady };
21
+ }
22
+ exports.useRunWhenReady = useRunWhenReady;
23
+ //# sourceMappingURL=useRunWhenReady.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRunWhenReady.js","sourceRoot":"","sources":["../src/useRunWhenReady.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAC9C,iDAAgD;AAehD;;;GAGG;AACH,SAAgB,eAAe;IACrB,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAClC,IAAM,eAAe,GAAG,IAAI,CAAC;IAE7B,IAAM,YAAY,GAAG,IAAA,mBAAW,EAC9B,UACE,eAA2B,EAC3B,aAAyB,EACzB,OAAgB;QAEhB,MAAM,CAAC,YAAY,CACjB,eAAe,EACf,aAAa,EACb,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,eAAe,CAC3B,CAAC;IACJ,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,6BAAa,CAAC,iBAAiB,CAAC,CAAC;KAC5C;IAED,OAAO,EAAE,YAAY,cAAA,EAAE,CAAC;AAC1B,CAAC;AAxBD,0CAwBC"}
@@ -1,9 +1,11 @@
1
+ import { KameleoonError } from './KameleoonError';
1
2
  interface IGetVariationIdHookResult {
2
3
  /**
3
4
  * @param visitorCode - unique identifier of the user
4
5
  * @param experimentId - unique identifier of the experiment you want to expose to a user
5
6
  */
6
7
  getVariationId: (visitorCode: string, experimentId: number) => number;
8
+ error: KameleoonError | null;
7
9
  }
8
10
  /**
9
11
  * A React Hook that returns callback function which triggers experiment.
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useTriggerExperiment = void 0;
4
4
  var react_1 = require("react");
5
5
  var useKameleoon_1 = require("./useKameleoon");
6
+ var useError_1 = require("./useError");
6
7
  /**
7
8
  * A React Hook that returns callback function which triggers experiment.
8
9
  * If such a user has never been associated with any variation, the SDK returns a randomly selected variation.
@@ -10,12 +11,21 @@ var useKameleoon_1 = require("./useKameleoon");
10
11
  * it will detect the previously registered variation and return the variationID
11
12
  */
12
13
  function useTriggerExperiment() {
14
+ var _a = (0, useError_1.useError)(), error = _a.error, setError = _a.setError;
13
15
  var client = (0, useKameleoon_1.useKameleoon)().client;
16
+ var DEFAULT_VARIATION_ID = 0;
14
17
  var getVariationId = (0, react_1.useCallback)(function (visitorCode, experimentId) {
15
- return client.triggerExperiment(visitorCode, experimentId);
16
- }, [client]);
18
+ try {
19
+ return client.triggerExperiment(visitorCode, experimentId);
20
+ }
21
+ catch (unknownError) {
22
+ setError(unknownError);
23
+ return DEFAULT_VARIATION_ID;
24
+ }
25
+ }, [client, setError]);
17
26
  return {
18
27
  getVariationId: getVariationId,
28
+ error: error,
19
29
  };
20
30
  }
21
31
  exports.useTriggerExperiment = useTriggerExperiment;
@@ -1 +1 @@
1
- {"version":3,"file":"useTriggerExperiment.js","sourceRoot":"","sources":["../src/useTriggerExperiment.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAU9C;;;;;GAKG;AACH,SAAgB,oBAAoB;IAC1B,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAElC,IAAM,cAAc,GAAG,IAAA,mBAAW,EAChC,UAAC,WAAmB,EAAE,YAAoB;QACxC,OAAA,MAAM,CAAC,iBAAiB,CAAC,WAAW,EAAE,YAAY,CAAC;IAAnD,CAAmD,EACrD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO;QACL,cAAc,gBAAA;KACf,CAAC;AACJ,CAAC;AAZD,oDAYC"}
1
+ {"version":3,"file":"useTriggerExperiment.js","sourceRoot":"","sources":["../src/useTriggerExperiment.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAE9C,uCAAsC;AAWtC;;;;;GAKG;AACH,SAAgB,oBAAoB;IAC5B,IAAA,KAAsB,IAAA,mBAAQ,GAAE,EAA9B,KAAK,WAAA,EAAE,QAAQ,cAAe,CAAC;IAC/B,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAClC,IAAM,oBAAoB,GAAG,CAAC,CAAC;IAE/B,IAAM,cAAc,GAAG,IAAA,mBAAW,EAChC,UAAC,WAAmB,EAAE,YAAoB;QACxC,IAAI;YACF,OAAO,MAAM,CAAC,iBAAiB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;SAC5D;QAAC,OAAO,YAAY,EAAE;YACrB,QAAQ,CAAC,YAAY,CAAC,CAAC;YAEvB,OAAO,oBAAoB,CAAC;SAC7B;IACH,CAAC,EACD,CAAC,MAAM,EAAE,QAAQ,CAAC,CACnB,CAAC;IAEF,OAAO;QACL,cAAc,gBAAA;QACd,KAAK,OAAA;KACN,CAAC;AACJ,CAAC;AAtBD,oDAsBC"}
@@ -1,14 +1,16 @@
1
- import { AnyType } from './types';
2
- interface VariationAssociatedDataHoolResult {
1
+ import { KameleoonError } from './KameleoonError';
2
+ import { VariationAssociatedDataType } from './types';
3
+ interface VariationAssociatedDataHookResult {
3
4
  /**
4
5
  * @param variationId - unique identifier of the variation you want to obtain associated data for
5
6
  */
6
- getVariationAssociatedData: (variationId: number) => AnyType;
7
+ getVariationAssociatedData: (variationId: number) => VariationAssociatedDataType;
8
+ error: KameleoonError | null;
7
9
  }
8
10
  /**
9
11
  * A React Hook that returns callback function which retrieves JSON data associated with a variation.
10
12
  * The JSON data usually represents some metadata of the variation,
11
13
  * and can be configured on our web application interface or via our Automation API.
12
14
  */
13
- export declare function useVariationAssociatedData(): VariationAssociatedDataHoolResult;
15
+ export declare function useVariationAssociatedData(): VariationAssociatedDataHookResult;
14
16
  export {};
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useVariationAssociatedData = void 0;
4
4
  var react_1 = require("react");
5
5
  var useKameleoon_1 = require("./useKameleoon");
6
+ var useError_1 = require("./useError");
6
7
  /**
7
8
  * A React Hook that returns callback function which retrieves JSON data associated with a variation.
8
9
  * The JSON data usually represents some metadata of the variation,
@@ -10,11 +11,19 @@ var useKameleoon_1 = require("./useKameleoon");
10
11
  */
11
12
  function useVariationAssociatedData() {
12
13
  var client = (0, useKameleoon_1.useKameleoon)().client;
14
+ var _a = (0, useError_1.useError)(), error = _a.error, setError = _a.setError;
13
15
  var getVariationAssociatedData = (0, react_1.useCallback)(function (variationId) {
14
- return client.obtainVariationAssociatedData(variationId);
15
- }, [client]);
16
+ try {
17
+ return client.obtainVariationAssociatedData(variationId);
18
+ }
19
+ catch (unknownError) {
20
+ setError(unknownError);
21
+ return null;
22
+ }
23
+ }, [client, setError]);
16
24
  return {
17
25
  getVariationAssociatedData: getVariationAssociatedData,
26
+ error: error,
18
27
  };
19
28
  }
20
29
  exports.useVariationAssociatedData = useVariationAssociatedData;
@@ -1 +1 @@
1
- {"version":3,"file":"useVariationAssociatedData.js","sourceRoot":"","sources":["../src/useVariationAssociatedData.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAU9C;;;;GAIG;AACH,SAAgB,0BAA0B;IAChC,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAElC,IAAM,0BAA0B,GAAG,IAAA,mBAAW,EAC5C,UAAC,WAAmB;QAClB,OAAA,MAAM,CAAC,6BAA6B,CAAC,WAAW,CAAC;IAAjD,CAAiD,EACnD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO;QACL,0BAA0B,4BAAA;KAC3B,CAAC;AACJ,CAAC;AAZD,gEAYC"}
1
+ {"version":3,"file":"useVariationAssociatedData.js","sourceRoot":"","sources":["../src/useVariationAssociatedData.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAG9C,uCAAsC;AAYtC;;;;GAIG;AACH,SAAgB,0BAA0B;IAChC,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAC5B,IAAA,KAAsB,IAAA,mBAAQ,GAAE,EAA9B,KAAK,WAAA,EAAE,QAAQ,cAAe,CAAC;IAEvC,IAAM,0BAA0B,GAAG,IAAA,mBAAW,EAC5C,UAAC,WAAmB;QAClB,IAAI;YACF,OAAO,MAAM,CAAC,6BAA6B,CAAC,WAAW,CAAC,CAAC;SAC1D;QAAC,OAAO,YAAY,EAAE;YACrB,QAAQ,CAAC,YAAY,CAAC,CAAC;YAEvB,OAAO,IAAI,CAAC;SACb;IACH,CAAC,EACD,CAAC,MAAM,EAAE,QAAQ,CAAC,CACnB,CAAC;IAEF,OAAO;QACL,0BAA0B,4BAAA;QAC1B,KAAK,OAAA;KACN,CAAC;AACJ,CAAC;AArBD,gEAqBC"}
@@ -1,11 +1,13 @@
1
1
  import React from 'react';
2
2
  import { UnknownPropsType, Without } from './types';
3
+ import { KameleoonError } from './KameleoonError';
3
4
  interface IWithHasFeature {
4
5
  /**
5
6
  * @param visitorCode - unique identifier of the user
6
7
  * @param featureKey - unique identifier or key of the feature you want to expose to a user
7
8
  */
8
9
  hasFeature: (visitorCode: string, featureKey: string | number) => boolean;
10
+ activateFeatureError: KameleoonError | null;
9
11
  }
10
12
  /**
11
13
  * A React HOC that gives a wrapped component access to callback
@@ -13,24 +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 react_1 = require("react");
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 client = (0, react_1.useContext)(KameleoonContext_1.KameleoonContext);
26
- var hasFeature = (0, react_1.useCallback)(function (visitorCode, featureKey) {
27
- if (!client) {
28
- throw new ProviderError_1.ProviderError('withActivateFeature');
29
- }
30
- return client.activateFeature(visitorCode, featureKey);
31
- }, [client]);
32
- // eslint-disable-next-line react/jsx-props-no-spreading
33
- 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));
34
25
  };
35
26
  }
36
27
  exports.withActivateFeature = withActivateFeature;
@@ -1 +1 @@
1
- {"version":3,"file":"withActivateFeature.js","sourceRoot":"","sources":["../src/withActivateFeature.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAAuD;AAEvD,uDAAsD;AACtD,iDAAgD;AAUhD;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,mCAAgB,CAAC,CAAC;QAE5C,IAAM,UAAU,GAAG,IAAA,mBAAW,EAC5B,UAAC,WAAmB,EAAE,UAA2B;YAC/C,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,6BAAa,CAAC,qBAAqB,CAAC,CAAC;aAChD;YAED,OAAO,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACzD,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;QAEF,wDAAwD;QACxD,OAAO,uBAAC,SAAS,aAAC,UAAU,EAAE,UAAU,IAAO,KAAe,UAAI,CAAC;IACrE,CAAC,CAAC;AACJ,CAAC;AApBD,kDAoBC"}
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"}
@@ -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,9 +56,8 @@ 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
- // eslint-disable-next-line react/jsx-props-no-spreading
46
61
  return (0, jsx_runtime_1.jsx)(Component, __assign({ addData: addData }, props), void 0);
47
62
  };
48
63
  }
@@ -1 +1 @@
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,GAAK,SAAS,UAAE;QACnD,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;QAEF,wDAAwD;QACxD,OAAO,uBAAC,SAAS,aAAC,OAAO,EAAE,OAAO,IAAO,KAAe,UAAI,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC;AApBD,kCAoBC"}
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"}
@@ -28,7 +28,6 @@ function withBrowser(Component) {
28
28
  var addBrowser = (0, react_1.useCallback)(function (browser) {
29
29
  return new kameleoon_client_javascript_1.KameleoonData.Browser(data_1.default.browsers[browser]);
30
30
  }, []);
31
- // eslint-disable-next-line react/jsx-props-no-spreading
32
31
  return (0, jsx_runtime_1.jsx)(Component, __assign({ addBrowser: addBrowser }, props), void 0);
33
32
  };
34
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"withBrowser.js","sourceRoot":"","sources":["../src/withBrowser.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAA2C;AAC3C,+EAE+C;AAC/C,2EAA4D;AAW5D;;;GAGG;AACH,SAAgB,WAAW,CACzB,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,UAAU,GAAG,IAAA,mBAAW,EAAC,UAAC,OAAgB;YAC9C,OAAO,IAAI,2CAAa,CAAC,OAAO,CAAC,cAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3D,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,wDAAwD;QACxD,OAAO,uBAAC,SAAS,aAAC,UAAU,EAAE,UAAU,IAAO,KAAe,UAAI,CAAC;IACrE,CAAC,CAAC;AACJ,CAAC;AAXD,kCAWC"}
1
+ {"version":3,"file":"withBrowser.js","sourceRoot":"","sources":["../src/withBrowser.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAA2C;AAC3C,+EAE+C;AAC/C,2EAA4D;AAW5D;;;GAGG;AACH,SAAgB,WAAW,CACzB,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,UAAU,GAAG,IAAA,mBAAW,EAAC,UAAC,OAAgB;YAC9C,OAAO,IAAI,2CAAa,CAAC,OAAO,CAAC,cAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3D,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,OAAO,uBAAC,SAAS,aAAC,UAAU,EAAE,UAAU,IAAO,KAAe,UAAI,CAAC;IACrE,CAAC,CAAC;AACJ,CAAC;AAVD,kCAUC"}
@@ -4,7 +4,7 @@ import { UnknownPropsType, Without } from './types';
4
4
  interface IWithConversion {
5
5
  /**
6
6
  * @param goalId - unique identifier of the goal
7
- * @param revenue - coversion revenue
7
+ * @param revenue - conversion revenue
8
8
  * @param negative - defines if the revenue is positive or negative
9
9
  */
10
10
  addConversion: (goalId: number, revenue?: number, negative?: boolean) => Conversion;
@@ -24,7 +24,6 @@ function withConversion(Component) {
24
24
  var addConversion = (0, react_1.useCallback)(function (goalId, revenue, negative) {
25
25
  return new kameleoon_client_javascript_1.KameleoonData.Conversion(goalId, revenue, negative);
26
26
  }, []);
27
- // eslint-disable-next-line react/jsx-props-no-spreading
28
27
  return (0, jsx_runtime_1.jsx)(Component, __assign({ addConversion: addConversion }, props), void 0);
29
28
  };
30
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"withConversion.js","sourceRoot":"","sources":["../src/withConversion.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAA2C;AAC3C,2EAA4D;AAiB5D;;;GAGG;AACH,SAAgB,cAAc,CAC5B,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,aAAa,GAAG,IAAA,mBAAW,EAC/B,UAAC,MAAc,EAAE,OAAgB,EAAE,QAAkB;YACnD,OAAO,IAAI,2CAAa,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACjE,CAAC,EACD,EAAE,CACH,CAAC;QAEF,wDAAwD;QACxD,OAAO,uBAAC,SAAS,aAAC,aAAa,EAAE,aAAa,IAAO,KAAe,UAAI,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC;AAdD,wCAcC"}
1
+ {"version":3,"file":"withConversion.js","sourceRoot":"","sources":["../src/withConversion.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAA2C;AAC3C,2EAA4D;AAiB5D;;;GAGG;AACH,SAAgB,cAAc,CAC5B,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,aAAa,GAAG,IAAA,mBAAW,EAC/B,UAAC,MAAc,EAAE,OAAgB,EAAE,QAAkB;YACnD,OAAO,IAAI,2CAAa,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACjE,CAAC,EACD,EAAE,CACH,CAAC;QAEF,OAAO,uBAAC,SAAS,aAAC,aAAa,EAAE,aAAa,IAAO,KAAe,UAAI,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC;AAbD,wCAaC"}
@@ -24,7 +24,6 @@ function withCustomData(Component) {
24
24
  var addCustomData = (0, react_1.useCallback)(function (goalId, revenue, negative) {
25
25
  return new kameleoon_client_javascript_1.KameleoonData.Conversion(goalId, revenue, negative);
26
26
  }, []);
27
- // eslint-disable-next-line react/jsx-props-no-spreading
28
27
  return (0, jsx_runtime_1.jsx)(Component, __assign({ addCustomData: addCustomData }, props), void 0);
29
28
  };
30
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"withCustomData.js","sourceRoot":"","sources":["../src/withCustomData.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAA2C;AAC3C,2EAA4D;AAY5D;;;GAGG;AACH,SAAgB,cAAc,CAC5B,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,aAAa,GAAG,IAAA,mBAAW,EAC/B,UAAC,MAAc,EAAE,OAAgB,EAAE,QAAkB;YACnD,OAAO,IAAI,2CAAa,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACjE,CAAC,EACD,EAAE,CACH,CAAC;QAEF,wDAAwD;QACxD,OAAO,uBAAC,SAAS,aAAC,aAAa,EAAE,aAAa,IAAO,KAAe,UAAI,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC;AAdD,wCAcC"}
1
+ {"version":3,"file":"withCustomData.js","sourceRoot":"","sources":["../src/withCustomData.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAA2C;AAC3C,2EAA4D;AAY5D;;;GAGG;AACH,SAAgB,cAAc,CAC5B,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,aAAa,GAAG,IAAA,mBAAW,EAC/B,UAAC,MAAc,EAAE,OAAgB,EAAE,QAAkB;YACnD,OAAO,IAAI,2CAAa,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACjE,CAAC,EACD,EAAE,CACH,CAAC;QAEF,OAAO,uBAAC,SAAS,aAAC,aAAa,EAAE,aAAa,IAAO,KAAe,UAAI,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC;AAbD,wCAaC"}
@@ -22,9 +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 feature = (0, useFeature_1.useFeature)(__assign({}, args));
26
- // eslint-disable-next-line react/jsx-props-no-spreading
27
- 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));
28
27
  };
29
28
  };
30
29
  }
@@ -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;YAC3C,IAAM,OAAO,GAAG,IAAA,uBAAU,eAAM,IAAI,EAAG,CAAC;YAExC,wDAAwD;YACxD,OAAO,uBAAC,SAAS,aAAC,OAAO,EAAE,OAAO,IAAO,KAAe,UAAI,CAAC;QAC/D,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAbD,kCAaC"}
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 getFeatureVariable = (0, useFeatureVariable_1.useFeatureVariable)().getFeatureVariable;
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":";;;;;;;;;;;;;;;AAEA,2DAA0D;AAa1D;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QACnC,IAAA,kBAAkB,GAAK,IAAA,uCAAkB,GAAE,mBAAzB,CAA0B;QAEpD,OAAO,CACL,uBAAC,SAAS,aACR,kBAAkB,EAAE,kBAAkB,IAEjC,KAAe,UACpB,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAdD,kDAcC"}
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"}
package/dist/withFlush.js CHANGED
@@ -29,7 +29,6 @@ function withFlush(Component) {
29
29
  }
30
30
  client.flush(visitorCode);
31
31
  }, [client]);
32
- // eslint-disable-next-line react/jsx-props-no-spreading
33
32
  return (0, jsx_runtime_1.jsx)(Component, __assign({ flush: flush }, props), void 0);
34
33
  };
35
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"withFlush.js","sourceRoot":"","sources":["../src/withFlush.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAAuD;AACvD,iDAAgD;AAEhD,uDAAsD;AAStD;;;GAGG;AACH,SAAgB,SAAS,CACvB,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,mCAAgB,CAAC,CAAC;QAE5C,IAAM,KAAK,GAAG,IAAA,mBAAW,EACvB,UAAC,WAAmB;YAClB,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,6BAAa,CAAC,WAAW,CAAC,CAAC;aACtC;YACD,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC5B,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;QAEF,wDAAwD;QACxD,OAAO,uBAAC,SAAS,aAAC,KAAK,EAAE,KAAK,IAAO,KAAe,UAAI,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC;AAnBD,8BAmBC"}
1
+ {"version":3,"file":"withFlush.js","sourceRoot":"","sources":["../src/withFlush.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAAuD;AACvD,iDAAgD;AAEhD,uDAAsD;AAStD;;;GAGG;AACH,SAAgB,SAAS,CACvB,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,mCAAgB,CAAC,CAAC;QAE5C,IAAM,KAAK,GAAG,IAAA,mBAAW,EACvB,UAAC,WAAmB;YAClB,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,6BAAa,CAAC,WAAW,CAAC,CAAC;aACtC;YACD,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC5B,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;QAEF,OAAO,uBAAC,SAAS,aAAC,KAAK,EAAE,KAAK,IAAO,KAAe,UAAI,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC;AAlBD,8BAkBC"}
@@ -24,7 +24,6 @@ function withInterest(Component) {
24
24
  var addInterest = (0, react_1.useCallback)(function (index) {
25
25
  return new kameleoon_client_javascript_1.KameleoonData.Interest(index);
26
26
  }, []);
27
- // eslint-disable-next-line react/jsx-props-no-spreading
28
27
  return (0, jsx_runtime_1.jsx)(Component, __assign({ addInterest: addInterest }, props), void 0);
29
28
  };
30
29
  }
@@ -1 +1 @@
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,wDAAwD;QACxD,OAAO,uBAAC,SAAS,aAAC,WAAW,EAAE,WAAW,IAAO,KAAe,UAAI,CAAC;IACvE,CAAC,CAAC;AACJ,CAAC;AAXD,oCAWC"}
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"}
@@ -26,7 +26,6 @@ function withKameleoon(Component) {
26
26
  if (!client) {
27
27
  throw new ProviderError_1.ProviderError('withKameleoon');
28
28
  }
29
- // eslint-disable-next-line react/jsx-props-no-spreading
30
29
  return (0, jsx_runtime_1.jsx)(Component, __assign({ client: client }, props), void 0);
31
30
  };
32
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"withKameleoon.js","sourceRoot":"","sources":["../src/withKameleoon.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAA0C;AAE1C,uDAAsD;AACtD,iDAAgD;AAQhD;;;GAGG;AACH,SAAgB,aAAa,CAC3B,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,mCAAgB,CAAC,CAAC;QAE5C,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,6BAAa,CAAC,eAAe,CAAC,CAAC;SAC1C;QAED,wDAAwD;QACxD,OAAO,uBAAC,SAAS,aAAC,MAAM,EAAE,MAAM,IAAO,KAAe,UAAI,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC;AAbD,sCAaC"}
1
+ {"version":3,"file":"withKameleoon.js","sourceRoot":"","sources":["../src/withKameleoon.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAA0C;AAE1C,uDAAsD;AACtD,iDAAgD;AAQhD;;;GAGG;AACH,SAAgB,aAAa,CAC3B,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,mCAAgB,CAAC,CAAC;QAE5C,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,6BAAa,CAAC,eAAe,CAAC,CAAC;SAC1C;QAED,OAAO,uBAAC,SAAS,aAAC,MAAM,EAAE,MAAM,IAAO,KAAe,UAAI,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC;AAZD,sCAYC"}
@@ -24,7 +24,6 @@ function withPageView(Component) {
24
24
  var addPageView = (0, react_1.useCallback)(function (url, title, referrer) {
25
25
  return new kameleoon_client_javascript_1.KameleoonData.PageView(url, title, referrer);
26
26
  }, []);
27
- // eslint-disable-next-line react/jsx-props-no-spreading
28
27
  return (0, jsx_runtime_1.jsx)(Component, __assign({ addPageView: addPageView }, props), void 0);
29
28
  };
30
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"withPageView.js","sourceRoot":"","sources":["../src/withPageView.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAA2C;AAE3C,2EAA4D;AAY5D;;;GAGG;AACH,SAAgB,YAAY,CAC1B,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,WAAW,GAAG,IAAA,mBAAW,EAC7B,UAAC,GAAW,EAAE,KAAa,EAAE,QAAiB;YAC5C,OAAO,IAAI,2CAAa,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC1D,CAAC,EACD,EAAE,CACH,CAAC;QAEF,wDAAwD;QACxD,OAAO,uBAAC,SAAS,aAAC,WAAW,EAAE,WAAW,IAAO,KAAe,UAAI,CAAC;IACvE,CAAC,CAAC;AACJ,CAAC;AAdD,oCAcC"}
1
+ {"version":3,"file":"withPageView.js","sourceRoot":"","sources":["../src/withPageView.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAA2C;AAE3C,2EAA4D;AAY5D;;;GAGG;AACH,SAAgB,YAAY,CAC1B,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,WAAW,GAAG,IAAA,mBAAW,EAC7B,UAAC,GAAW,EAAE,KAAa,EAAE,QAAiB;YAC5C,OAAO,IAAI,2CAAa,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC1D,CAAC,EACD,EAAE,CACH,CAAC;QAEF,OAAO,uBAAC,SAAS,aAAC,WAAW,EAAE,WAAW,IAAO,KAAe,UAAI,CAAC;IACvE,CAAC,CAAC;AACJ,CAAC;AAbD,oCAaC"}
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { UnknownPropsType, Without, RemoteSourceDataType } from './types';
3
+ interface IWithRetrieveDataFromRemoteSource {
4
+ /**
5
+ * @param key - unique key for data defined for Kameleoon Data API
6
+ */
7
+ retrieveDataFromRemoteSource: (key: string) => Promise<RemoteSourceDataType>;
8
+ }
9
+ /**
10
+ * A React HOC that gives a wrapped component access to callback function
11
+ * which retrieves data from Kameleoon Data API
12
+ */
13
+ export declare function withRetrieveDataFromRemoteSource<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithRetrieveDataFromRemoteSource>>;
14
+ 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.withRetrieveDataFromRemoteSource = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var useRetrieveDataFromRemoteSource_1 = require("./useRetrieveDataFromRemoteSource");
17
+ /**
18
+ * A React HOC that gives a wrapped component access to callback function
19
+ * which retrieves data from Kameleoon Data API
20
+ */
21
+ function withRetrieveDataFromRemoteSource(Component) {
22
+ return function WrappedComponent(props) {
23
+ var retrieveDataFromRemoteSource = (0, useRetrieveDataFromRemoteSource_1.useRetrieveDataFromRemoteSource)().retrieveDataFromRemoteSource;
24
+ return ((0, jsx_runtime_1.jsx)(Component, __assign({ retrieveDataFromRemoteSource: retrieveDataFromRemoteSource }, props), void 0));
25
+ };
26
+ }
27
+ exports.withRetrieveDataFromRemoteSource = withRetrieveDataFromRemoteSource;
28
+ //# sourceMappingURL=withRetrieveDataFromRemoteSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withRetrieveDataFromRemoteSource.js","sourceRoot":"","sources":["../src/withRetrieveDataFromRemoteSource.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,qFAAoF;AASpF;;;GAGG;AACH,SAAgB,gCAAgC,CAG9C,SAAqC;IAIrC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QACnC,IAAA,4BAA4B,GAAK,IAAA,iEAA+B,GAAE,6BAAtC,CAAuC;QAE3E,OAAO,CACL,uBAAC,SAAS,aACR,4BAA4B,EAAE,4BAA4B,IACrD,KAAe,UACpB,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAjBD,4EAiBC"}
@@ -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"}
@@ -9,7 +9,7 @@ interface IWithTrackingConversion {
9
9
  trackConversion: (visitorCode: string, goalId: number, revenue?: number) => void;
10
10
  }
11
11
  /**
12
- * A React HOC that gives a wrapped component access access to callback function
12
+ * A React HOC that gives a wrapped component access to callback function
13
13
  * which tracks conversion
14
14
  */
15
15
  export declare function withTrackingConversion<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithTrackingConversion>>;