@kameleoon/react-sdk 4.0.0 → 4.0.3

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 (143) hide show
  1. package/README.md +17 -20
  2. package/dist/Feature.d.ts +11 -0
  3. package/dist/Feature.js +26 -0
  4. package/dist/Feature.js.map +1 -0
  5. package/dist/KameleoonContext.d.ts +3 -0
  6. package/dist/KameleoonContext.js +6 -0
  7. package/dist/KameleoonContext.js.map +1 -0
  8. package/dist/KameleoonError.d.ts +5 -0
  9. package/dist/KameleoonError.js +31 -0
  10. package/dist/KameleoonError.js.map +1 -0
  11. package/dist/KameleoonProvider.d.ts +14 -0
  12. package/dist/KameleoonProvider.js +25 -0
  13. package/dist/KameleoonProvider.js.map +1 -0
  14. package/dist/ProviderError.d.ts +3 -0
  15. package/dist/ProviderError.js +29 -0
  16. package/dist/ProviderError.js.map +1 -0
  17. package/dist/compose.d.ts +8 -0
  18. package/dist/compose.js +58 -0
  19. package/dist/compose.js.map +1 -0
  20. package/dist/constants.d.ts +24 -0
  21. package/dist/constants.js +31 -0
  22. package/dist/constants.js.map +1 -0
  23. package/dist/getKameleoonException.d.ts +2 -0
  24. package/dist/getKameleoonException.js +34 -0
  25. package/dist/getKameleoonException.js.map +1 -0
  26. package/dist/index.d.ts +42 -0
  27. package/dist/index.js +106 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/kameleoonClient.d.ts +16 -0
  30. package/dist/kameleoonClient.js +17 -0
  31. package/dist/kameleoonClient.js.map +1 -0
  32. package/dist/types.d.ts +37 -0
  33. package/dist/types.js +4 -0
  34. package/dist/types.js.map +1 -0
  35. package/dist/useActivateFeature.d.ts +14 -0
  36. package/dist/useActivateFeature.js +35 -0
  37. package/dist/useActivateFeature.js.map +1 -0
  38. package/dist/useAddData.d.ts +14 -0
  39. package/dist/useAddData.js +49 -0
  40. package/dist/useAddData.js.map +1 -0
  41. package/dist/useBrowser.d.ts +13 -0
  42. package/dist/useBrowser.js +22 -0
  43. package/dist/useBrowser.js.map +1 -0
  44. package/dist/useConversion.d.ts +14 -0
  45. package/dist/useConversion.js +18 -0
  46. package/dist/useConversion.js.map +1 -0
  47. package/dist/useCustomData.d.ts +13 -0
  48. package/dist/useCustomData.js +18 -0
  49. package/dist/useCustomData.js.map +1 -0
  50. package/dist/useDevice.d.ts +12 -0
  51. package/dist/useDevice.js +16 -0
  52. package/dist/useDevice.js.map +1 -0
  53. package/dist/useError.d.ts +7 -0
  54. package/dist/useError.js +18 -0
  55. package/dist/useError.js.map +1 -0
  56. package/dist/useErrors.d.ts +7 -0
  57. package/dist/useErrors.js +42 -0
  58. package/dist/useErrors.js.map +1 -0
  59. package/dist/useFeature.d.ts +5 -0
  60. package/dist/useFeature.js +104 -0
  61. package/dist/useFeature.js.map +1 -0
  62. package/dist/useFeatureVariable.d.ts +15 -0
  63. package/dist/useFeatureVariable.js +41 -0
  64. package/dist/useFeatureVariable.js.map +1 -0
  65. package/dist/useFlush.d.ts +11 -0
  66. package/dist/useFlush.js +19 -0
  67. package/dist/useFlush.js.map +1 -0
  68. package/dist/useKameleoon.d.ts +10 -0
  69. package/dist/useKameleoon.js +20 -0
  70. package/dist/useKameleoon.js.map +1 -0
  71. package/dist/usePageView.d.ts +14 -0
  72. package/dist/usePageView.js +18 -0
  73. package/dist/usePageView.js.map +1 -0
  74. package/dist/useRetrieveDataFromRemoteSource.d.ts +12 -0
  75. package/dist/useRetrieveDataFromRemoteSource.js +79 -0
  76. package/dist/useRetrieveDataFromRemoteSource.js.map +1 -0
  77. package/dist/useRunWhenReady.d.ts +14 -0
  78. package/dist/useRunWhenReady.js +23 -0
  79. package/dist/useRunWhenReady.js.map +1 -0
  80. package/dist/useTrackingConversion.d.ts +13 -0
  81. package/dist/useTrackingConversion.js +19 -0
  82. package/dist/useTrackingConversion.js.map +1 -0
  83. package/dist/useTriggerExperiment.d.ts +17 -0
  84. package/dist/useTriggerExperiment.js +32 -0
  85. package/dist/useTriggerExperiment.js.map +1 -0
  86. package/dist/useVariationAssociatedData.d.ts +16 -0
  87. package/dist/useVariationAssociatedData.js +30 -0
  88. package/dist/useVariationAssociatedData.js.map +1 -0
  89. package/dist/useVisitorCode.d.ts +12 -0
  90. package/dist/useVisitorCode.js +19 -0
  91. package/dist/useVisitorCode.js.map +1 -0
  92. package/dist/withActivateFeature.d.ts +17 -0
  93. package/dist/withActivateFeature.js +28 -0
  94. package/dist/withActivateFeature.js.map +1 -0
  95. package/dist/withAddData.d.ts +16 -0
  96. package/dist/withAddData.js +65 -0
  97. package/dist/withAddData.js.map +1 -0
  98. package/dist/withBrowser.d.ts +16 -0
  99. package/dist/withBrowser.js +35 -0
  100. package/dist/withBrowser.js.map +1 -0
  101. package/dist/withConversion.d.ts +17 -0
  102. package/dist/withConversion.js +31 -0
  103. package/dist/withConversion.js.map +1 -0
  104. package/dist/withCustomData.d.ts +16 -0
  105. package/dist/withCustomData.js +31 -0
  106. package/dist/withCustomData.js.map +1 -0
  107. package/dist/withDevice.d.ts +15 -0
  108. package/dist/withDevice.js +29 -0
  109. package/dist/withDevice.js.map +1 -0
  110. package/dist/withFeature.d.ts +6 -0
  111. package/dist/withFeature.js +31 -0
  112. package/dist/withFeature.js.map +1 -0
  113. package/dist/withFeatureVariable.d.ts +17 -0
  114. package/dist/withFeatureVariable.js +28 -0
  115. package/dist/withFeatureVariable.js.map +1 -0
  116. package/dist/withFlush.d.ts +14 -0
  117. package/dist/withFlush.js +36 -0
  118. package/dist/withFlush.js.map +1 -0
  119. package/dist/withKameleoon.d.ts +13 -0
  120. package/dist/withKameleoon.js +33 -0
  121. package/dist/withKameleoon.js.map +1 -0
  122. package/dist/withPageView.d.ts +17 -0
  123. package/dist/withPageView.js +31 -0
  124. package/dist/withPageView.js.map +1 -0
  125. package/dist/withRetrieveDataFromRemoteSource.d.ts +14 -0
  126. package/dist/withRetrieveDataFromRemoteSource.js +28 -0
  127. package/dist/withRetrieveDataFromRemoteSource.js.map +1 -0
  128. package/dist/withRunWhenReady.d.ts +16 -0
  129. package/dist/withRunWhenReady.js +28 -0
  130. package/dist/withRunWhenReady.js.map +1 -0
  131. package/dist/withTrackingConversion.d.ts +16 -0
  132. package/dist/withTrackingConversion.js +36 -0
  133. package/dist/withTrackingConversion.js.map +1 -0
  134. package/dist/withTriggerExperiment.d.ts +19 -0
  135. package/dist/withTriggerExperiment.js +30 -0
  136. package/dist/withTriggerExperiment.js.map +1 -0
  137. package/dist/withVariationAssociatedData.d.ts +18 -0
  138. package/dist/withVariationAssociatedData.js +30 -0
  139. package/dist/withVariationAssociatedData.js.map +1 -0
  140. package/dist/withVisitorCode.d.ts +15 -0
  141. package/dist/withVisitorCode.js +36 -0
  142. package/dist/withVisitorCode.js.map +1 -0
  143. package/package.json +3 -2
@@ -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.withActivateFeature = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var useActivateFeature_1 = require("./useActivateFeature");
17
+ /**
18
+ * A React HOC that gives a wrapped component access to callback
19
+ * function which activates a feature toggle
20
+ */
21
+ function withActivateFeature(Component) {
22
+ return function WrappedComponent(props) {
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));
25
+ };
26
+ }
27
+ exports.withActivateFeature = withActivateFeature;
28
+ //# sourceMappingURL=withActivateFeature.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { DataInterface as IData } from 'kameleoon-client-javascript/dist/interfaces/interfaces';
3
+ import { UnknownPropsType, Without } from './types';
4
+ interface IWithAddData {
5
+ /**
6
+ * @param visitorCode - unique identifier of the user
7
+ * @param dataTypes - custom data types which may be passed separated by a comma
8
+ */
9
+ addData: (visitorCode: string, ...dataTypes: IData[]) => void;
10
+ }
11
+ /**
12
+ * A React HOC that gives a wrapped component access to callback function
13
+ * which adds various data to associate this data with the current user
14
+ */
15
+ export declare function withAddData<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithAddData>>;
16
+ export {};
@@ -0,0 +1,65 @@
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
+ 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
+ };
29
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
30
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
31
+ if (ar || !(i in from)) {
32
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
33
+ ar[i] = from[i];
34
+ }
35
+ }
36
+ return to.concat(ar || Array.prototype.slice.call(from));
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.withAddData = void 0;
40
+ var jsx_runtime_1 = require("react/jsx-runtime");
41
+ var react_1 = require("react");
42
+ var KameleoonContext_1 = require("./KameleoonContext");
43
+ var ProviderError_1 = require("./ProviderError");
44
+ /**
45
+ * A React HOC that gives a wrapped component access to callback function
46
+ * which adds various data to associate this data with the current user
47
+ */
48
+ function withAddData(Component) {
49
+ return function WrappedComponent(props) {
50
+ var client = (0, react_1.useContext)(KameleoonContext_1.KameleoonContext);
51
+ var addData = (0, react_1.useCallback)(function (visitorCode) {
52
+ var dataTypes = [];
53
+ for (var _i = 1; _i < arguments.length; _i++) {
54
+ dataTypes[_i - 1] = arguments[_i];
55
+ }
56
+ if (!client) {
57
+ throw new ProviderError_1.ProviderError('withAddData');
58
+ }
59
+ return client.addData.apply(client, __spreadArray([visitorCode], __read(dataTypes), false));
60
+ }, [client]);
61
+ return (0, jsx_runtime_1.jsx)(Component, __assign({ addData: addData }, props), void 0);
62
+ };
63
+ }
64
+ exports.withAddData = withAddData;
65
+ //# sourceMappingURL=withAddData.js.map
@@ -0,0 +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,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,16 @@
1
+ import React from 'react';
2
+ import { Browser as IBrowser } from 'kameleoon-client-javascript/dist/data';
3
+ import { Browser } from './constants';
4
+ import { UnknownPropsType, Without } from './types';
5
+ interface IWithBrowser {
6
+ /**
7
+ * @param browser - browser types: CHROME, INTERNET_EXPLORER, FIREFOX, SAFARI, OPERA, OTHER
8
+ */
9
+ addBrowser: (browser: Browser) => IBrowser;
10
+ }
11
+ /**
12
+ * A React HOC that gives a wrapped component access to callback function
13
+ * which adds browser type
14
+ */
15
+ export declare function withBrowser<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithBrowser>>;
16
+ export {};
@@ -0,0 +1,35 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.withBrowser = void 0;
18
+ var jsx_runtime_1 = require("react/jsx-runtime");
19
+ var react_1 = require("react");
20
+ var data_1 = __importDefault(require("kameleoon-client-javascript/dist/data"));
21
+ var kameleoon_client_javascript_1 = require("kameleoon-client-javascript");
22
+ /**
23
+ * A React HOC that gives a wrapped component access to callback function
24
+ * which adds browser type
25
+ */
26
+ function withBrowser(Component) {
27
+ return function WrappedComponent(props) {
28
+ var addBrowser = (0, react_1.useCallback)(function (browser) {
29
+ return new kameleoon_client_javascript_1.KameleoonData.Browser(data_1.default.browsers[browser]);
30
+ }, []);
31
+ return (0, jsx_runtime_1.jsx)(Component, __assign({ addBrowser: addBrowser }, props), void 0);
32
+ };
33
+ }
34
+ exports.withBrowser = withBrowser;
35
+ //# sourceMappingURL=withBrowser.js.map
@@ -0,0 +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,OAAO,uBAAC,SAAS,aAAC,UAAU,EAAE,UAAU,IAAO,KAAe,UAAI,CAAC;IACrE,CAAC,CAAC;AACJ,CAAC;AAVD,kCAUC"}
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { Conversion } from 'kameleoon-client-javascript/dist/data';
3
+ import { UnknownPropsType, Without } from './types';
4
+ interface IWithConversion {
5
+ /**
6
+ * @param goalId - unique identifier of the goal
7
+ * @param revenue - conversion revenue
8
+ * @param negative - defines if the revenue is positive or negative
9
+ */
10
+ addConversion: (goalId: number, revenue?: number, negative?: boolean) => Conversion;
11
+ }
12
+ /**
13
+ * A React HOC that gives a wrapped component access to callback function
14
+ * which adds conversion
15
+ */
16
+ export declare function withConversion<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithConversion>>;
17
+ export {};
@@ -0,0 +1,31 @@
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.withConversion = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var react_1 = require("react");
17
+ var kameleoon_client_javascript_1 = require("kameleoon-client-javascript");
18
+ /**
19
+ * A React HOC that gives a wrapped component access to callback function
20
+ * which adds conversion
21
+ */
22
+ function withConversion(Component) {
23
+ return function WrappedComponent(props) {
24
+ var addConversion = (0, react_1.useCallback)(function (goalId, revenue, negative) {
25
+ return new kameleoon_client_javascript_1.KameleoonData.Conversion(goalId, revenue, negative);
26
+ }, []);
27
+ return (0, jsx_runtime_1.jsx)(Component, __assign({ addConversion: addConversion }, props), void 0);
28
+ };
29
+ }
30
+ exports.withConversion = withConversion;
31
+ //# sourceMappingURL=withConversion.js.map
@@ -0,0 +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,OAAO,uBAAC,SAAS,aAAC,aAAa,EAAE,aAAa,IAAO,KAAe,UAAI,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC;AAbD,wCAaC"}
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { CustomData } from 'kameleoon-client-javascript/dist/data';
3
+ import { UnknownPropsType, Without } from './types';
4
+ interface IWithCustomData {
5
+ /**
6
+ * @param index - index or unique identifier of the custom data to be stored
7
+ * @param value - value of the custom data to be stored
8
+ */
9
+ addCustomData: (index: number, value: string) => CustomData;
10
+ }
11
+ /**
12
+ * A React HOC that gives a wrapped component access to callback function
13
+ * which adds custom data
14
+ */
15
+ export declare function withCustomData<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithCustomData>>;
16
+ export {};
@@ -0,0 +1,31 @@
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.withCustomData = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var react_1 = require("react");
17
+ var kameleoon_client_javascript_1 = require("kameleoon-client-javascript");
18
+ /**
19
+ * A React HOC that gives a wrapped component access to callback function
20
+ * which adds custom data
21
+ */
22
+ function withCustomData(Component) {
23
+ return function WrappedComponent(props) {
24
+ var addCustomData = (0, react_1.useCallback)(function (goalId, revenue, negative) {
25
+ return new kameleoon_client_javascript_1.KameleoonData.Conversion(goalId, revenue, negative);
26
+ }, []);
27
+ return (0, jsx_runtime_1.jsx)(Component, __assign({ addCustomData: addCustomData }, props), void 0);
28
+ };
29
+ }
30
+ exports.withCustomData = withCustomData;
31
+ //# sourceMappingURL=withCustomData.js.map
@@ -0,0 +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,OAAO,uBAAC,SAAS,aAAC,aAAa,EAAE,aAAa,IAAO,KAAe,UAAI,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC;AAbD,wCAaC"}
@@ -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 {};
@@ -0,0 +1,29 @@
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.withDevice = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var react_1 = require("react");
17
+ var kameleoon_client_javascript_1 = require("kameleoon-client-javascript");
18
+ /**
19
+ * A React HOC that gives a wrapped component access to callback function
20
+ * which adds device type
21
+ */
22
+ function withDevice(Component) {
23
+ return function WrappedComponent(props) {
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);
26
+ };
27
+ }
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"}
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { Without, IFeatureParams, UnknownPropsType } from './types';
3
+ /**
4
+ * A React HOC that gives a wrapped component access to the status of a feature flag and its variables
5
+ */
6
+ export declare function withFeature(args: IFeatureParams): <Props extends UnknownPropsType>(Component: React.ComponentType<Props>) => React.ComponentType<Props & Without<Props, IFeatureParams>>;
@@ -0,0 +1,31 @@
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.withFeature = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var useFeature_1 = require("./useFeature");
17
+ /**
18
+ * A React HOC that gives a wrapped component access to the status of a feature flag and its variables
19
+ */
20
+ function withFeature(args) {
21
+ // Returns curried function that can be used with the specified args
22
+ // e.g. withFeature(...args)(Component)
23
+ return function callbackWithArgs(Component) {
24
+ return function WrappedComponent(props) {
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
+ };
28
+ };
29
+ }
30
+ exports.withFeature = withFeature;
31
+ //# sourceMappingURL=withFeature.js.map
@@ -0,0 +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;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"}
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { KameleoonError } from './KameleoonError';
3
+ import { FeatureFlagVariableType, UnknownPropsType, Without } from './types';
4
+ interface IWithFeatureVariable {
5
+ /**
6
+ * @param featureKey - unique identifier or key of the feature you want to obtain to a user
7
+ * @param variableKey - key of the variable
8
+ */
9
+ getFeatureVariable: (featureKey: string | number, variableKey: string) => FeatureFlagVariableType;
10
+ featureVariableError: KameleoonError | null;
11
+ }
12
+ /**
13
+ * A React HOC that gives a wrapped component access to callback function
14
+ * which retrieves a feature variable
15
+ */
16
+ export declare function withFeatureVariable<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithFeatureVariable>>;
17
+ 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.withFeatureVariable = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var useFeatureVariable_1 = require("./useFeatureVariable");
17
+ /**
18
+ * A React HOC that gives a wrapped component access to callback function
19
+ * which retrieves a feature variable
20
+ */
21
+ function withFeatureVariable(Component) {
22
+ return function WrappedComponent(props) {
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
+ };
26
+ }
27
+ exports.withFeatureVariable = withFeatureVariable;
28
+ //# sourceMappingURL=withFeatureVariable.js.map
@@ -0,0 +1 @@
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,14 @@
1
+ import React from 'react';
2
+ import { UnknownPropsType, Without } from './types';
3
+ interface IWithFlush {
4
+ /**
5
+ * @param visitorCode - unique identifier of the user
6
+ */
7
+ flush: (visitorCode: string) => void;
8
+ }
9
+ /**
10
+ * A React HOC that gives a wrapped component access to callback function
11
+ * which allows to flush data to servers
12
+ */
13
+ export declare function withFlush<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithFlush>>;
14
+ export {};
@@ -0,0 +1,36 @@
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.withFlush = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var react_1 = require("react");
17
+ var ProviderError_1 = require("./ProviderError");
18
+ var KameleoonContext_1 = require("./KameleoonContext");
19
+ /**
20
+ * A React HOC that gives a wrapped component access to callback function
21
+ * which allows to flush data to servers
22
+ */
23
+ function withFlush(Component) {
24
+ return function WrappedComponent(props) {
25
+ var client = (0, react_1.useContext)(KameleoonContext_1.KameleoonContext);
26
+ var flush = (0, react_1.useCallback)(function (visitorCode) {
27
+ if (!client) {
28
+ throw new ProviderError_1.ProviderError('withFlush');
29
+ }
30
+ client.flush(visitorCode);
31
+ }, [client]);
32
+ return (0, jsx_runtime_1.jsx)(Component, __assign({ flush: flush }, props), void 0);
33
+ };
34
+ }
35
+ exports.withFlush = withFlush;
36
+ //# sourceMappingURL=withFlush.js.map
@@ -0,0 +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,OAAO,uBAAC,SAAS,aAAC,KAAK,EAAE,KAAK,IAAO,KAAe,UAAI,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC;AAlBD,8BAkBC"}
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { KameleoonClient } from 'kameleoon-client-javascript';
3
+ import { UnknownPropsType, Without } from './types';
4
+ interface IWithKameleoonProps {
5
+ /** An instance of KameleoonClient */
6
+ client: KameleoonClient;
7
+ }
8
+ /**
9
+ * A React HOC that gives a wrapped component direct access
10
+ * to Kameleoon client via props
11
+ */
12
+ export declare function withKameleoon<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithKameleoonProps>>;
13
+ export {};
@@ -0,0 +1,33 @@
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.withKameleoon = void 0;
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");
19
+ /**
20
+ * A React HOC that gives a wrapped component direct access
21
+ * to Kameleoon client via props
22
+ */
23
+ function withKameleoon(Component) {
24
+ return function WrappedComponent(props) {
25
+ var client = (0, react_1.useContext)(KameleoonContext_1.KameleoonContext);
26
+ if (!client) {
27
+ throw new ProviderError_1.ProviderError('withKameleoon');
28
+ }
29
+ return (0, jsx_runtime_1.jsx)(Component, __assign({ client: client }, props), void 0);
30
+ };
31
+ }
32
+ exports.withKameleoon = withKameleoon;
33
+ //# sourceMappingURL=withKameleoon.js.map
@@ -0,0 +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,OAAO,uBAAC,SAAS,aAAC,MAAM,EAAE,MAAM,IAAO,KAAe,UAAI,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC;AAZD,sCAYC"}
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { PageView } from 'kameleoon-client-javascript/dist/data';
3
+ import { UnknownPropsType, Without } from './types';
4
+ interface IWithPageView {
5
+ /**
6
+ * @param url - URL of the page viewed
7
+ * @param title - title of the page viewed
8
+ * @param referrer - referrer of the page viewed
9
+ */
10
+ addPageView: (url: string, title: string, referrer?: number) => PageView;
11
+ }
12
+ /**
13
+ * A React HOC that gives a wrapped component access to callback function
14
+ * which adds page view
15
+ */
16
+ export declare function withPageView<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithPageView>>;
17
+ export {};
@@ -0,0 +1,31 @@
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.withPageView = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var react_1 = require("react");
17
+ var kameleoon_client_javascript_1 = require("kameleoon-client-javascript");
18
+ /**
19
+ * A React HOC that gives a wrapped component access to callback function
20
+ * which adds page view
21
+ */
22
+ function withPageView(Component) {
23
+ return function WrappedComponent(props) {
24
+ var addPageView = (0, react_1.useCallback)(function (url, title, referrer) {
25
+ return new kameleoon_client_javascript_1.KameleoonData.PageView(url, title, referrer);
26
+ }, []);
27
+ return (0, jsx_runtime_1.jsx)(Component, __assign({ addPageView: addPageView }, props), void 0);
28
+ };
29
+ }
30
+ exports.withPageView = withPageView;
31
+ //# sourceMappingURL=withPageView.js.map
@@ -0,0 +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,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"}