@kameleoon/react-sdk 4.1.1 → 6.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.
- package/README.md +62 -1456
- package/dist/KameleoonContext.d.ts +2 -2
- package/dist/KameleoonContext.js.map +1 -1
- package/dist/KameleoonError.d.ts +1 -1
- package/dist/KameleoonProvider.d.ts +5 -5
- package/dist/KameleoonProvider.js +1 -1
- package/dist/KameleoonProvider.js.map +1 -1
- package/dist/constants.d.ts +1 -24
- package/dist/constants.js +2 -28
- package/dist/constants.js.map +1 -1
- package/dist/eventSource/browserEventSource.d.ts +4 -0
- package/dist/eventSource/browserEventSource.js +38 -0
- package/dist/eventSource/browserEventSource.js.map +1 -0
- package/dist/eventSource/index.d.ts +2 -0
- package/dist/eventSource/index.js +8 -0
- package/dist/eventSource/index.js.map +1 -0
- package/dist/eventSource/nativeEventSource.d.ts +4 -0
- package/dist/eventSource/nativeEventSource.js +39 -0
- package/dist/eventSource/nativeEventSource.js.map +1 -0
- package/dist/index.d.ts +16 -42
- package/dist/index.js +34 -92
- package/dist/index.js.map +1 -1
- package/dist/kameleoonClient.d.ts +4 -13
- package/dist/kameleoonClient.js +18 -72
- package/dist/kameleoonClient.js.map +1 -1
- package/dist/kameleoonUtils/browserUtils.d.ts +13 -0
- package/dist/kameleoonUtils/browserUtils.js +72 -0
- package/dist/kameleoonUtils/browserUtils.js.map +1 -0
- package/dist/kameleoonUtils/nativeUtils.d.ts +12 -0
- package/dist/kameleoonUtils/nativeUtils.js +68 -0
- package/dist/kameleoonUtils/nativeUtils.js.map +1 -0
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.js +8 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/localStorage.d.ts +4 -0
- package/dist/storage/localStorage.js +44 -0
- package/dist/storage/localStorage.js.map +1 -0
- package/dist/storage/nativeStorage.d.ts +4 -0
- package/dist/storage/nativeStorage.js +41 -0
- package/dist/storage/nativeStorage.js.map +1 -0
- package/dist/useAddData.d.ts +14 -9
- package/dist/useAddData.js +14 -5
- package/dist/useAddData.js.map +1 -1
- package/dist/useBrowserVisitorCode.d.ts +17 -0
- package/dist/useBrowserVisitorCode.js +20 -0
- package/dist/useBrowserVisitorCode.js.map +1 -0
- package/dist/useConfigurationUpdate.d.ts +17 -0
- package/dist/useConfigurationUpdate.js +29 -0
- package/dist/useConfigurationUpdate.js.map +1 -0
- package/dist/useError.d.ts +1 -1
- package/dist/useError.js +1 -3
- package/dist/useError.js.map +1 -1
- package/dist/useErrors.d.ts +2 -2
- package/dist/useExperiments.d.ts +18 -0
- package/dist/useExperiments.js +30 -0
- package/dist/useExperiments.js.map +1 -0
- package/dist/useFeatureFlagActive.d.ts +19 -0
- package/dist/useFeatureFlagActive.js +30 -0
- package/dist/useFeatureFlagActive.js.map +1 -0
- package/dist/useFeatureFlagVariationKey.d.ts +19 -0
- package/dist/useFeatureFlagVariationKey.js +30 -0
- package/dist/useFeatureFlagVariationKey.js.map +1 -0
- package/dist/useFeatureFlags.d.ts +18 -0
- package/dist/useFeatureFlags.js +30 -0
- package/dist/useFeatureFlags.js.map +1 -0
- package/dist/useFeatureVariable.d.ts +12 -8
- package/dist/useFeatureVariable.js +7 -18
- package/dist/useFeatureVariable.js.map +1 -1
- package/dist/useFlushData.d.ts +14 -0
- package/dist/useFlushData.js +21 -0
- package/dist/useFlushData.js.map +1 -0
- package/dist/useInitialize.d.ts +15 -0
- package/dist/{useAsyncVisitorCode.js → useInitialize.js} +28 -10
- package/dist/useInitialize.js.map +1 -0
- package/dist/useKameleoon.d.ts +8 -7
- package/dist/useKameleoon.js +3 -1
- package/dist/useKameleoon.js.map +1 -1
- package/dist/useNativeVisitorCode.d.ts +16 -0
- package/dist/useNativeVisitorCode.js +20 -0
- package/dist/useNativeVisitorCode.js.map +1 -0
- package/dist/useRemoteData.d.ts +19 -0
- package/dist/{useRetrieveDataFromRemoteSource.js → useRemoteData.js} +25 -28
- package/dist/useRemoteData.js.map +1 -0
- package/dist/useTrackConversion.d.ts +18 -0
- package/dist/useTrackConversion.js +29 -0
- package/dist/useTrackConversion.js.map +1 -0
- package/dist/useTriggerExperiment.d.ts +12 -10
- package/dist/useTriggerExperiment.js +8 -9
- package/dist/useTriggerExperiment.js.map +1 -1
- package/dist/useVisitorExperiments.d.ts +20 -0
- package/dist/useVisitorExperiments.js +30 -0
- package/dist/useVisitorExperiments.js.map +1 -0
- package/dist/useVisitorFeatureFlags.d.ts +19 -0
- package/dist/useVisitorFeatureFlags.js +30 -0
- package/dist/useVisitorFeatureFlags.js.map +1 -0
- package/package.json +10 -5
- package/dist/Feature.d.ts +0 -11
- package/dist/Feature.js +0 -26
- package/dist/Feature.js.map +0 -1
- package/dist/compose.d.ts +0 -8
- package/dist/compose.js +0 -58
- package/dist/compose.js.map +0 -1
- package/dist/getKameleoonException.d.ts +0 -2
- package/dist/getKameleoonException.js +0 -34
- package/dist/getKameleoonException.js.map +0 -1
- package/dist/types.d.ts +0 -37
- package/dist/types.js +0 -4
- package/dist/types.js.map +0 -1
- package/dist/useActivateFeature.d.ts +0 -14
- package/dist/useActivateFeature.js +0 -33
- package/dist/useActivateFeature.js.map +0 -1
- package/dist/useAsyncVisitorCode.d.ts +0 -12
- package/dist/useAsyncVisitorCode.js.map +0 -1
- package/dist/useBrowser.d.ts +0 -13
- package/dist/useBrowser.js +0 -22
- package/dist/useBrowser.js.map +0 -1
- package/dist/useConversion.d.ts +0 -14
- package/dist/useConversion.js +0 -18
- package/dist/useConversion.js.map +0 -1
- package/dist/useCustomData.d.ts +0 -13
- package/dist/useCustomData.js +0 -18
- package/dist/useCustomData.js.map +0 -1
- package/dist/useDevice.d.ts +0 -12
- package/dist/useDevice.js +0 -16
- package/dist/useDevice.js.map +0 -1
- package/dist/useFeature.d.ts +0 -5
- package/dist/useFeature.js +0 -101
- package/dist/useFeature.js.map +0 -1
- package/dist/useFlush.d.ts +0 -11
- package/dist/useFlush.js +0 -19
- package/dist/useFlush.js.map +0 -1
- package/dist/usePageView.d.ts +0 -14
- package/dist/usePageView.js +0 -18
- package/dist/usePageView.js.map +0 -1
- package/dist/useRetrieveDataFromRemoteSource.d.ts +0 -12
- package/dist/useRetrieveDataFromRemoteSource.js.map +0 -1
- package/dist/useRunWhenReady.d.ts +0 -14
- package/dist/useRunWhenReady.js +0 -23
- package/dist/useRunWhenReady.js.map +0 -1
- package/dist/useTrackingConversion.d.ts +0 -13
- package/dist/useTrackingConversion.js +0 -19
- package/dist/useTrackingConversion.js.map +0 -1
- package/dist/useVariationAssociatedData.d.ts +0 -16
- package/dist/useVariationAssociatedData.js +0 -30
- package/dist/useVariationAssociatedData.js.map +0 -1
- package/dist/useVisitorCode.d.ts +0 -12
- package/dist/useVisitorCode.js +0 -19
- package/dist/useVisitorCode.js.map +0 -1
- package/dist/withActivateFeature.d.ts +0 -17
- package/dist/withActivateFeature.js +0 -28
- package/dist/withActivateFeature.js.map +0 -1
- package/dist/withAddData.d.ts +0 -16
- package/dist/withAddData.js +0 -28
- package/dist/withAddData.js.map +0 -1
- package/dist/withAsyncVisitorCode.d.ts +0 -15
- package/dist/withAsyncVisitorCode.js +0 -75
- package/dist/withAsyncVisitorCode.js.map +0 -1
- package/dist/withBrowser.d.ts +0 -16
- package/dist/withBrowser.js +0 -35
- package/dist/withBrowser.js.map +0 -1
- package/dist/withConversion.d.ts +0 -17
- package/dist/withConversion.js +0 -31
- package/dist/withConversion.js.map +0 -1
- package/dist/withCustomData.d.ts +0 -16
- package/dist/withCustomData.js +0 -31
- package/dist/withCustomData.js.map +0 -1
- package/dist/withDevice.d.ts +0 -15
- package/dist/withDevice.js +0 -29
- package/dist/withDevice.js.map +0 -1
- package/dist/withFeature.d.ts +0 -6
- package/dist/withFeature.js +0 -31
- package/dist/withFeature.js.map +0 -1
- package/dist/withFeatureVariable.d.ts +0 -17
- package/dist/withFeatureVariable.js +0 -28
- package/dist/withFeatureVariable.js.map +0 -1
- package/dist/withFlush.d.ts +0 -14
- package/dist/withFlush.js +0 -36
- package/dist/withFlush.js.map +0 -1
- package/dist/withKameleoon.d.ts +0 -13
- package/dist/withKameleoon.js +0 -33
- package/dist/withKameleoon.js.map +0 -1
- package/dist/withPageView.d.ts +0 -17
- package/dist/withPageView.js +0 -31
- package/dist/withPageView.js.map +0 -1
- package/dist/withRetrieveDataFromRemoteSource.d.ts +0 -14
- package/dist/withRetrieveDataFromRemoteSource.js +0 -28
- package/dist/withRetrieveDataFromRemoteSource.js.map +0 -1
- package/dist/withRunWhenReady.d.ts +0 -16
- package/dist/withRunWhenReady.js +0 -28
- package/dist/withRunWhenReady.js.map +0 -1
- package/dist/withTrackingConversion.d.ts +0 -16
- package/dist/withTrackingConversion.js +0 -36
- package/dist/withTrackingConversion.js.map +0 -1
- package/dist/withTriggerExperiment.d.ts +0 -19
- package/dist/withTriggerExperiment.js +0 -30
- package/dist/withTriggerExperiment.js.map +0 -1
- package/dist/withVariationAssociatedData.d.ts +0 -18
- package/dist/withVariationAssociatedData.js +0 -30
- package/dist/withVariationAssociatedData.js.map +0 -1
- package/dist/withVisitorCode.d.ts +0 -15
- package/dist/withVisitorCode.js +0 -36
- package/dist/withVisitorCode.js.map +0 -1
package/dist/useFeature.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.useFeature = void 0;
|
|
31
|
-
var react_1 = require("react");
|
|
32
|
-
var useActivateFeature_1 = require("./useActivateFeature");
|
|
33
|
-
var useFeatureVariable_1 = require("./useFeatureVariable");
|
|
34
|
-
var constants_1 = require("./constants");
|
|
35
|
-
var useKameleoon_1 = require("./useKameleoon");
|
|
36
|
-
var useErrors_1 = require("./useErrors");
|
|
37
|
-
/**
|
|
38
|
-
* A React Hook that returns the status of a feature flag and specified variables
|
|
39
|
-
*/
|
|
40
|
-
function useFeature(_a) {
|
|
41
|
-
var _b;
|
|
42
|
-
var featureKey = _a.featureKey, variableKeys = _a.variableKeys, visitorCode = _a.visitorCode;
|
|
43
|
-
var _c = (0, useActivateFeature_1.useActivateFeature)(), hasFeature = _c.hasFeature, activateFeatureError = _c.error;
|
|
44
|
-
var _d = (0, useFeatureVariable_1.useFeatureVariable)(), getFeatureVariable = _d.getFeatureVariable, featureVariableError = _d.error;
|
|
45
|
-
var client = (0, useKameleoon_1.useKameleoon)().client;
|
|
46
|
-
var _e = __read((0, react_1.useState)((_b = {},
|
|
47
|
-
_b[constants_1.FeatureResultField.IsActive] = false,
|
|
48
|
-
_b[constants_1.FeatureResultField.Variables] = [],
|
|
49
|
-
_b)), 2), feature = _e[0], setFeature = _e[1];
|
|
50
|
-
var _f = (0, useErrors_1.useErrors)(), errors = _f.errors, setErrors = _f.setErrors;
|
|
51
|
-
function getVariableObject(key, value) {
|
|
52
|
-
var _a;
|
|
53
|
-
if (value) {
|
|
54
|
-
return _a = {},
|
|
55
|
-
_a[key] = value,
|
|
56
|
-
_a;
|
|
57
|
-
}
|
|
58
|
-
return {};
|
|
59
|
-
}
|
|
60
|
-
var getVariablesArray = (0, react_1.useCallback)(function (environment) {
|
|
61
|
-
var variablesArray = [];
|
|
62
|
-
var environmentVariableKeys = variableKeys[environment];
|
|
63
|
-
if (Array.isArray(environmentVariableKeys)) {
|
|
64
|
-
environmentVariableKeys.forEach(function (key) {
|
|
65
|
-
variablesArray.push(getVariableObject(key, getFeatureVariable(featureKey, key)));
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
variablesArray.push(getVariableObject(environmentVariableKeys, getFeatureVariable(featureKey, environmentVariableKeys)));
|
|
70
|
-
}
|
|
71
|
-
return variablesArray;
|
|
72
|
-
}, [variableKeys, getFeatureVariable, featureKey]);
|
|
73
|
-
(0, react_1.useEffect)(function () {
|
|
74
|
-
var _a;
|
|
75
|
-
var _b, _c, _d, _e;
|
|
76
|
-
var featureFlagArray = (_b = client.configurations) === null || _b === void 0 ? void 0 : _b.configuration.featureFlags.filter(function (item) {
|
|
77
|
-
return item.identificationKey === featureKey;
|
|
78
|
-
});
|
|
79
|
-
if (Array.isArray(featureFlagArray) && featureFlagArray.length) {
|
|
80
|
-
var currentEnvironment = (_e = (_d = (_c = featureFlagArray[0]) === null || _c === void 0 ? void 0 : _c.environment) === null || _d === void 0 ? void 0 : _d.key) !== null && _e !== void 0 ? _e : constants_1.PRODUCTION;
|
|
81
|
-
setFeature((_a = {},
|
|
82
|
-
_a[constants_1.FeatureResultField.IsActive] = hasFeature(featureKey, visitorCode),
|
|
83
|
-
_a[constants_1.FeatureResultField.Variables] = getVariablesArray(currentEnvironment),
|
|
84
|
-
_a));
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
setFeature(function (prevFeature) {
|
|
88
|
-
var _a;
|
|
89
|
-
return (__assign(__assign({}, prevFeature), (_a = {}, _a[constants_1.FeatureResultField.IsActive] = false, _a)));
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
// getVariablesArray put in dependencies creates an infinite loop
|
|
93
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
94
|
-
}, [visitorCode, featureKey, hasFeature]);
|
|
95
|
-
(0, react_1.useEffect)(function () {
|
|
96
|
-
setErrors([activateFeatureError === null || activateFeatureError === void 0 ? void 0 : activateFeatureError.type, featureVariableError === null || featureVariableError === void 0 ? void 0 : featureVariableError.type]);
|
|
97
|
-
}, [activateFeatureError, featureVariableError, setErrors]);
|
|
98
|
-
return { feature: feature, errors: errors };
|
|
99
|
-
}
|
|
100
|
-
exports.useFeature = useFeature;
|
|
101
|
-
//# sourceMappingURL=useFeature.js.map
|
package/dist/useFeature.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFeature.js","sourceRoot":"","sources":["../src/useFeature.ts"],"names":[],"mappings":"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"}
|
package/dist/useFlush.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
interface FlushHookResult {
|
|
2
|
-
/**
|
|
3
|
-
* @param visitorCode - unique identifier of the user
|
|
4
|
-
*/
|
|
5
|
-
flush: (visitorCode: string) => void;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* A React Hook that returns callback function which allows to flush data to servers
|
|
9
|
-
*/
|
|
10
|
-
export declare function useFlush(): FlushHookResult;
|
|
11
|
-
export {};
|
package/dist/useFlush.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useFlush = void 0;
|
|
4
|
-
var react_1 = require("react");
|
|
5
|
-
var useKameleoon_1 = require("./useKameleoon");
|
|
6
|
-
/**
|
|
7
|
-
* A React Hook that returns callback function which allows to flush data to servers
|
|
8
|
-
*/
|
|
9
|
-
function useFlush() {
|
|
10
|
-
var client = (0, useKameleoon_1.useKameleoon)().client;
|
|
11
|
-
var flush = (0, react_1.useCallback)(function (visitorCode) {
|
|
12
|
-
client.flush(visitorCode);
|
|
13
|
-
}, [client]);
|
|
14
|
-
return {
|
|
15
|
-
flush: flush,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
exports.useFlush = useFlush;
|
|
19
|
-
//# sourceMappingURL=useFlush.js.map
|
package/dist/useFlush.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFlush.js","sourceRoot":"","sources":["../src/useFlush.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAS9C;;GAEG;AACH,SAAgB,QAAQ;IACd,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAElC,IAAM,KAAK,GAAG,IAAA,mBAAW,EACvB,UAAC,WAAmB;QAClB,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC5B,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO;QACL,KAAK,OAAA;KACN,CAAC;AACJ,CAAC;AAbD,4BAaC"}
|
package/dist/usePageView.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { PageView } from '@kameleoon/javascript-sdk-core/dist/data';
|
|
2
|
-
interface PageViewHookResult {
|
|
3
|
-
/**
|
|
4
|
-
* @param url - URL of the page viewed
|
|
5
|
-
* @param title - title of the page viewed
|
|
6
|
-
* @param referrer - referrer of the page viewed
|
|
7
|
-
*/
|
|
8
|
-
addPageView: (url: string, title: string, referrer?: number) => PageView;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* A React Hook that returns callback function which adds page view
|
|
12
|
-
*/
|
|
13
|
-
export declare function usePageView(): PageViewHookResult;
|
|
14
|
-
export {};
|
package/dist/usePageView.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.usePageView = void 0;
|
|
4
|
-
var react_1 = require("react");
|
|
5
|
-
var javascript_sdk_core_1 = require("@kameleoon/javascript-sdk-core");
|
|
6
|
-
/**
|
|
7
|
-
* A React Hook that returns callback function which adds page view
|
|
8
|
-
*/
|
|
9
|
-
function usePageView() {
|
|
10
|
-
var addPageView = (0, react_1.useCallback)(function (url, title, referrer) {
|
|
11
|
-
return new javascript_sdk_core_1.KameleoonData.PageView(url, title, referrer);
|
|
12
|
-
}, []);
|
|
13
|
-
return {
|
|
14
|
-
addPageView: addPageView,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
exports.usePageView = usePageView;
|
|
18
|
-
//# sourceMappingURL=usePageView.js.map
|
package/dist/usePageView.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePageView.js","sourceRoot":"","sources":["../src/usePageView.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,sEAA+D;AAY/D;;GAEG;AACH,SAAgB,WAAW;IACzB,IAAM,WAAW,GAAG,IAAA,mBAAW,EAC7B,UAAC,GAAW,EAAE,KAAa,EAAE,QAAiB;QAC5C,OAAA,IAAI,mCAAa,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC;IAAhD,CAAgD,EAClD,EAAE,CACH,CAAC;IAEF,OAAO;QACL,WAAW,aAAA;KACZ,CAAC;AACJ,CAAC;AAVD,kCAUC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { RemoteSourceResultType } from './types';
|
|
2
|
-
interface RetrieveDataFromRemoteSourceHookResult {
|
|
3
|
-
/**
|
|
4
|
-
* @param key - unique key for data defined for Kameleoon Data API
|
|
5
|
-
*/
|
|
6
|
-
retrieveDataFromRemoteSource: (key: string) => Promise<RemoteSourceResultType>;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* A React Hook that returns asynchronous callback function which retrieves data from Kameleoon Data API
|
|
10
|
-
*/
|
|
11
|
-
export declare function useRetrieveDataFromRemoteSource(): RetrieveDataFromRemoteSourceHookResult;
|
|
12
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,14 +0,0 @@
|
|
|
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 {};
|
package/dist/useRunWhenReady.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,13 +0,0 @@
|
|
|
1
|
-
interface TrackingConversionHookResult {
|
|
2
|
-
/**
|
|
3
|
-
* @param visitorCode - unique identifier of the user
|
|
4
|
-
* @param goalId - unique identifier of the goal
|
|
5
|
-
* @param revenue - revenue of the conversion
|
|
6
|
-
*/
|
|
7
|
-
trackConversion: (visitorCode: string, goalId: number, revenue?: number) => void;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* A React Hook that returns callback function which tracks conversion
|
|
11
|
-
*/
|
|
12
|
-
export declare function useTrackingConversion(): TrackingConversionHookResult;
|
|
13
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useTrackingConversion = void 0;
|
|
4
|
-
var react_1 = require("react");
|
|
5
|
-
var useKameleoon_1 = require("./useKameleoon");
|
|
6
|
-
/**
|
|
7
|
-
* A React Hook that returns callback function which tracks conversion
|
|
8
|
-
*/
|
|
9
|
-
function useTrackingConversion() {
|
|
10
|
-
var client = (0, useKameleoon_1.useKameleoon)().client;
|
|
11
|
-
var trackConversion = (0, react_1.useCallback)(function (visitorCode, goalId, revenue) {
|
|
12
|
-
client.trackConversion(visitorCode, goalId, revenue);
|
|
13
|
-
}, [client]);
|
|
14
|
-
return {
|
|
15
|
-
trackConversion: trackConversion,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
exports.useTrackingConversion = useTrackingConversion;
|
|
19
|
-
//# sourceMappingURL=useTrackingConversion.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTrackingConversion.js","sourceRoot":"","sources":["../src/useTrackingConversion.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAe9C;;GAEG;AACH,SAAgB,qBAAqB;IAC3B,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAElC,IAAM,eAAe,GAAG,IAAA,mBAAW,EACjC,UAAC,WAAmB,EAAE,MAAc,EAAE,OAAgB;QACpD,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO;QACL,eAAe,iBAAA;KAChB,CAAC;AACJ,CAAC;AAbD,sDAaC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { KameleoonError } from './KameleoonError';
|
|
2
|
-
import { VariationAssociatedDataType } from './types';
|
|
3
|
-
interface VariationAssociatedDataHookResult {
|
|
4
|
-
/**
|
|
5
|
-
* @param variationId - unique identifier of the variation you want to obtain associated data for
|
|
6
|
-
*/
|
|
7
|
-
getVariationAssociatedData: (variationId: number) => VariationAssociatedDataType;
|
|
8
|
-
error: KameleoonError | null;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* A React Hook that returns callback function which retrieves JSON data associated with a variation.
|
|
12
|
-
* The JSON data usually represents some metadata of the variation,
|
|
13
|
-
* and can be configured on our web application interface or via our Automation API.
|
|
14
|
-
*/
|
|
15
|
-
export declare function useVariationAssociatedData(): VariationAssociatedDataHookResult;
|
|
16
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useVariationAssociatedData = void 0;
|
|
4
|
-
var react_1 = require("react");
|
|
5
|
-
var useKameleoon_1 = require("./useKameleoon");
|
|
6
|
-
var useError_1 = require("./useError");
|
|
7
|
-
/**
|
|
8
|
-
* A React Hook that returns callback function which retrieves JSON data associated with a variation.
|
|
9
|
-
* The JSON data usually represents some metadata of the variation,
|
|
10
|
-
* and can be configured on our web application interface or via our Automation API.
|
|
11
|
-
*/
|
|
12
|
-
function useVariationAssociatedData() {
|
|
13
|
-
var client = (0, useKameleoon_1.useKameleoon)().client;
|
|
14
|
-
var _a = (0, useError_1.useError)(), error = _a.error, setError = _a.setError;
|
|
15
|
-
var getVariationAssociatedData = (0, react_1.useCallback)(function (variationId) {
|
|
16
|
-
try {
|
|
17
|
-
return client.obtainVariationAssociatedData(variationId);
|
|
18
|
-
}
|
|
19
|
-
catch (unknownError) {
|
|
20
|
-
setError(unknownError);
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
}, [client, setError]);
|
|
24
|
-
return {
|
|
25
|
-
getVariationAssociatedData: getVariationAssociatedData,
|
|
26
|
-
error: error,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
exports.useVariationAssociatedData = useVariationAssociatedData;
|
|
30
|
-
//# sourceMappingURL=useVariationAssociatedData.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/useVisitorCode.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
interface VisitorCodeHookResult {
|
|
2
|
-
/**
|
|
3
|
-
* @param topLevelDomain - current top level domain for the concerned site
|
|
4
|
-
* @param defaultVisitorCode - this parameter will be used as the visitorCode
|
|
5
|
-
*/
|
|
6
|
-
getVisitorCode: (topLevelDomain: string, defaultVisitorCode?: string) => string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* A React Hook that returns callback function which obtains the Kameleoon visitorCode for the current visitor
|
|
10
|
-
*/
|
|
11
|
-
export declare function useVisitorCode(): VisitorCodeHookResult;
|
|
12
|
-
export {};
|
package/dist/useVisitorCode.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useVisitorCode = void 0;
|
|
4
|
-
var react_1 = require("react");
|
|
5
|
-
var useKameleoon_1 = require("./useKameleoon");
|
|
6
|
-
/**
|
|
7
|
-
* A React Hook that returns callback function which obtains the Kameleoon visitorCode for the current visitor
|
|
8
|
-
*/
|
|
9
|
-
function useVisitorCode() {
|
|
10
|
-
var client = (0, useKameleoon_1.useKameleoon)().client;
|
|
11
|
-
var getVisitorCode = (0, react_1.useCallback)(function (topLevelDomain, defaultVisitorCode) {
|
|
12
|
-
return client.obtainVisitorCode(topLevelDomain, defaultVisitorCode);
|
|
13
|
-
}, [client]);
|
|
14
|
-
return {
|
|
15
|
-
getVisitorCode: getVisitorCode,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
exports.useVisitorCode = useVisitorCode;
|
|
19
|
-
//# sourceMappingURL=useVisitorCode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useVisitorCode.js","sourceRoot":"","sources":["../src/useVisitorCode.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAa9C;;GAEG;AACH,SAAgB,cAAc;IACpB,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAElC,IAAM,cAAc,GAAG,IAAA,mBAAW,EAChC,UAAC,cAAsB,EAAE,kBAA2B;QAClD,OAAA,MAAM,CAAC,iBAAiB,CAAC,cAAc,EAAE,kBAAkB,CAAC;IAA5D,CAA4D,EAC9D,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO;QACL,cAAc,gBAAA;KACf,CAAC;AACJ,CAAC;AAZD,wCAYC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { UnknownPropsType, Without } from './types';
|
|
3
|
-
import { KameleoonError } from './KameleoonError';
|
|
4
|
-
interface IWithHasFeature {
|
|
5
|
-
/**
|
|
6
|
-
* @param visitorCode - unique identifier of the user
|
|
7
|
-
* @param featureKey - unique identifier or key of the feature you want to expose to a user
|
|
8
|
-
*/
|
|
9
|
-
hasFeature: (featureKey: string | number, visitorCode?: string) => boolean;
|
|
10
|
-
activateFeatureError: KameleoonError | null;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* A React HOC that gives a wrapped component access to callback
|
|
14
|
-
* function which activates a feature toggle
|
|
15
|
-
*/
|
|
16
|
-
export declare function withActivateFeature<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithHasFeature>>;
|
|
17
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { DataInterface as IData } from '@kameleoon/javascript-sdk-core/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 {};
|
package/dist/withAddData.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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.withAddData = void 0;
|
|
15
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
-
var useAddData_1 = require("./useAddData");
|
|
17
|
-
/**
|
|
18
|
-
* A React HOC that gives a wrapped component access to callback function
|
|
19
|
-
* which adds various data to associate this data with the current user
|
|
20
|
-
*/
|
|
21
|
-
function withAddData(Component) {
|
|
22
|
-
return function WrappedComponent(props) {
|
|
23
|
-
var addData = (0, useAddData_1.useAddData)().addData;
|
|
24
|
-
return (0, jsx_runtime_1.jsx)(Component, __assign({ addData: addData }, props), void 0);
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
exports.withAddData = withAddData;
|
|
28
|
-
//# sourceMappingURL=withAddData.js.map
|
package/dist/withAddData.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withAddData.js","sourceRoot":"","sources":["../src/withAddData.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,2CAA0C;AAU1C;;;GAGG;AACH,SAAgB,WAAW,CACzB,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QACnC,IAAA,OAAO,GAAK,IAAA,uBAAU,GAAE,QAAjB,CAAkB;QAEjC,OAAO,uBAAC,SAAS,aAAC,OAAO,EAAE,OAAO,IAAO,KAAe,UAAI,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC;AARD,kCAQC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { UnknownPropsType, Without } from './types';
|
|
3
|
-
interface IWithAsyncVisitorCode {
|
|
4
|
-
/**
|
|
5
|
-
* @param topLevelDomain - current top level domain for the concerned site
|
|
6
|
-
* @param defaultVisitorCode - this parameter will be used as the visitorCode
|
|
7
|
-
*/
|
|
8
|
-
getAsyncVisitorCode: (topLevelDomain: string, defaultVisitorCode?: string) => Promise<string>;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* A React HOC that gives a wrapped component access to callback function
|
|
12
|
-
* which obtains the Kameleoon visitorCode asynchronously for the current visitor
|
|
13
|
-
*/
|
|
14
|
-
export declare function withAsyncVisitorCode<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithAsyncVisitorCode>>;
|
|
15
|
-
export {};
|
|
@@ -1,75 +0,0 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
29
|
-
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;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.withAsyncVisitorCode = void 0;
|
|
51
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
52
|
-
var react_1 = require("react");
|
|
53
|
-
var KameleoonContext_1 = require("./KameleoonContext");
|
|
54
|
-
var ProviderError_1 = require("./ProviderError");
|
|
55
|
-
/**
|
|
56
|
-
* A React HOC that gives a wrapped component access to callback function
|
|
57
|
-
* which obtains the Kameleoon visitorCode asynchronously for the current visitor
|
|
58
|
-
*/
|
|
59
|
-
function withAsyncVisitorCode(Component) {
|
|
60
|
-
return function WrappedComponent(props) {
|
|
61
|
-
var _this = this;
|
|
62
|
-
var client = (0, react_1.useContext)(KameleoonContext_1.KameleoonContext);
|
|
63
|
-
var getAsyncVisitorCode = (0, react_1.useCallback)(function (topLevelDomain, defaultVisitorCode) { return __awaiter(_this, void 0, void 0, function () {
|
|
64
|
-
return __generator(this, function (_a) {
|
|
65
|
-
if (!client) {
|
|
66
|
-
throw new ProviderError_1.ProviderError('withAsyncVisitorCode');
|
|
67
|
-
}
|
|
68
|
-
return [2 /*return*/, client.obtainAsyncVisitorCode(topLevelDomain, defaultVisitorCode)];
|
|
69
|
-
});
|
|
70
|
-
}); }, [client]);
|
|
71
|
-
return ((0, jsx_runtime_1.jsx)(Component, __assign({ getAsyncVisitorCode: getAsyncVisitorCode }, props), void 0));
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
exports.withAsyncVisitorCode = withAsyncVisitorCode;
|
|
75
|
-
//# sourceMappingURL=withAsyncVisitorCode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withAsyncVisitorCode.js","sourceRoot":"","sources":["../src/withAsyncVisitorCode.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAuD;AAEvD,uDAAsD;AACtD,iDAAgD;AAahD;;;GAGG;AACH,SAAgB,oBAAoB,CAClC,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAAtC,iBA0BN;QAzBC,IAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,mCAAgB,CAAC,CAAC;QAE5C,IAAM,mBAAmB,GAAG,IAAA,mBAAW,EACrC,UACE,cAAsB,EACtB,kBAA2B;;gBAE3B,IAAI,CAAC,MAAM,EAAE;oBACX,MAAM,IAAI,6BAAa,CAAC,sBAAsB,CAAC,CAAC;iBACjD;gBAED,sBAAO,MAAM,CAAC,sBAAsB,CAClC,cAAc,EACd,kBAAkB,CACnB,EAAC;;aACH,EACD,CAAC,MAAM,CAAC,CACT,CAAC;QAEF,OAAO,CACL,uBAAC,SAAS,aACR,mBAAmB,EAAE,mBAAmB,IACnC,KAAe,UACpB,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AA9BD,oDA8BC"}
|
package/dist/withBrowser.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Browser as IBrowser } from '@kameleoon/javascript-sdk-core/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 {};
|
package/dist/withBrowser.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
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/javascript-sdk-core/dist/data"));
|
|
21
|
-
var javascript_sdk_core_1 = require("@kameleoon/javascript-sdk-core");
|
|
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 javascript_sdk_core_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
|
package/dist/withBrowser.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withBrowser.js","sourceRoot":"","sources":["../src/withBrowser.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAA2C;AAC3C,kFAAqF;AACrF,sEAA+D;AAW/D;;;GAGG;AACH,SAAgB,WAAW,CACzB,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,UAAU,GAAG,IAAA,mBAAW,EAAC,UAAC,OAAgB;YAC9C,OAAO,IAAI,mCAAa,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"}
|