@kameleoon/react-sdk 7.6.1 → 8.1.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 (111) hide show
  1. package/README.md +84 -10
  2. package/dist/KameleoonContext.js +1 -1
  3. package/dist/KameleoonContext.js.map +1 -1
  4. package/dist/KameleoonProvider.js +1 -3
  5. package/dist/KameleoonProvider.js.map +1 -1
  6. package/dist/cookieManager/browserCookie.d.ts +7 -0
  7. package/dist/cookieManager/browserCookie.js +2 -0
  8. package/dist/cookieManager/browserCookie.js.map +1 -0
  9. package/dist/cookieManager/index.d.ts +2 -0
  10. package/dist/cookieManager/index.js +2 -0
  11. package/dist/cookieManager/index.js.map +1 -0
  12. package/dist/cookieManager/nativeCookie.d.ts +7 -0
  13. package/dist/cookieManager/nativeCookie.js +2 -0
  14. package/dist/cookieManager/nativeCookie.js.map +1 -0
  15. package/dist/eventSource/browserEventSource.js +1 -6
  16. package/dist/eventSource/browserEventSource.js.map +1 -1
  17. package/dist/eventSource/nativeEventSource.js +1 -1
  18. package/dist/eventSource/nativeEventSource.js.map +1 -1
  19. package/dist/index.d.ts +6 -6
  20. package/dist/index.js +1 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/kameleoonClient.d.ts +3 -2
  23. package/dist/kameleoonClient.js +1 -5
  24. package/dist/kameleoonClient.js.map +1 -1
  25. package/dist/kameleoonUtils/browserUtils.js +1 -14
  26. package/dist/kameleoonUtils/browserUtils.js.map +1 -1
  27. package/dist/kameleoonUtils/nativeUtils.js +1 -12
  28. package/dist/kameleoonUtils/nativeUtils.js.map +1 -1
  29. package/dist/requester.js +1 -1
  30. package/dist/requester.js.map +1 -1
  31. package/dist/storage/localStorage.js +1 -1
  32. package/dist/storage/localStorage.js.map +1 -1
  33. package/dist/storage/nativeStorage.d.ts +11 -1
  34. package/dist/storage/nativeStorage.js +1 -1
  35. package/dist/storage/nativeStorage.js.map +1 -1
  36. package/dist/types.d.ts +20 -0
  37. package/dist/types.js +2 -0
  38. package/dist/types.js.map +1 -0
  39. package/dist/useAddData.d.ts +1 -1
  40. package/dist/useAddData.js +1 -5
  41. package/dist/useAddData.js.map +1 -1
  42. package/dist/useBrowserVisitorCode.d.ts +2 -1
  43. package/dist/useBrowserVisitorCode.js +1 -5
  44. package/dist/useBrowserVisitorCode.js.map +1 -1
  45. package/dist/useConfigurationUpdate.d.ts +1 -1
  46. package/dist/useConfigurationUpdate.js +1 -5
  47. package/dist/useConfigurationUpdate.js.map +1 -1
  48. package/dist/useEngineTrackingCode.js.map +1 -1
  49. package/dist/useFeatureFlagActive.d.ts +2 -2
  50. package/dist/useFeatureFlagActive.js +1 -5
  51. package/dist/useFeatureFlagActive.js.map +1 -1
  52. package/dist/useFeatureFlagVariationKey.d.ts +2 -2
  53. package/dist/useFeatureFlagVariationKey.js +1 -5
  54. package/dist/useFeatureFlagVariationKey.js.map +1 -1
  55. package/dist/useFeatureFlags.d.ts +1 -1
  56. package/dist/useFeatureFlags.js +1 -5
  57. package/dist/useFeatureFlags.js.map +1 -1
  58. package/dist/useFeatureVariable.d.ts +4 -4
  59. package/dist/useFeatureVariable.js +1 -5
  60. package/dist/useFeatureVariable.js.map +1 -1
  61. package/dist/useFeatureVariables.d.ts +25 -0
  62. package/dist/useFeatureVariables.js +2 -0
  63. package/dist/useFeatureVariables.js.map +1 -0
  64. package/dist/useFlush.d.ts +1 -1
  65. package/dist/useFlush.js +1 -5
  66. package/dist/useFlush.js.map +1 -1
  67. package/dist/useInitialize.d.ts +1 -0
  68. package/dist/useInitialize.js +1 -5
  69. package/dist/useInitialize.js.map +1 -1
  70. package/dist/useKameleoon.js +1 -6
  71. package/dist/useKameleoon.js.map +1 -1
  72. package/dist/useNativeVisitorCode.d.ts +2 -1
  73. package/dist/useNativeVisitorCode.js +1 -5
  74. package/dist/useNativeVisitorCode.js.map +1 -1
  75. package/dist/useReactNativeVisitorCode.d.ts +20 -0
  76. package/dist/useReactNativeVisitorCode.js +2 -0
  77. package/dist/useReactNativeVisitorCode.js.map +1 -0
  78. package/dist/useReactVisitorCode.d.ts +20 -0
  79. package/dist/useReactVisitorCode.js +2 -0
  80. package/dist/useReactVisitorCode.js.map +1 -0
  81. package/dist/useRemoteData.js +1 -5
  82. package/dist/useRemoteData.js.map +1 -1
  83. package/dist/useRemoteVisitorData.d.ts +7 -7
  84. package/dist/useRemoteVisitorData.js +1 -5
  85. package/dist/useRemoteVisitorData.js.map +1 -1
  86. package/dist/useSetLegalConsent.d.ts +23 -0
  87. package/dist/useSetLegalConsent.js +2 -0
  88. package/dist/useSetLegalConsent.js.map +1 -0
  89. package/dist/useTrackConversion.js +1 -5
  90. package/dist/useTrackConversion.js.map +1 -1
  91. package/dist/useVisitorFeatureFlags.d.ts +1 -1
  92. package/dist/useVisitorFeatureFlags.js +1 -5
  93. package/dist/useVisitorFeatureFlags.js.map +1 -1
  94. package/dist/useVisitorWarehouseAudience.js +1 -5
  95. package/dist/useVisitorWarehouseAudience.js.map +1 -1
  96. package/package.json +2 -2
  97. package/dist/useExperimentVariationData.d.ts +0 -21
  98. package/dist/useExperimentVariationData.js +0 -6
  99. package/dist/useExperimentVariationData.js.map +0 -1
  100. package/dist/useExperiments.d.ts +0 -18
  101. package/dist/useExperiments.js +0 -6
  102. package/dist/useExperiments.js.map +0 -1
  103. package/dist/useFlushData.d.ts +0 -19
  104. package/dist/useFlushData.js +0 -4
  105. package/dist/useFlushData.js.map +0 -1
  106. package/dist/useTriggerExperiment.d.ts +0 -24
  107. package/dist/useTriggerExperiment.js +0 -6
  108. package/dist/useTriggerExperiment.js.map +0 -1
  109. package/dist/useVisitorExperiments.d.ts +0 -22
  110. package/dist/useVisitorExperiments.js +0 -6
  111. package/dist/useVisitorExperiments.js.map +0 -1
@@ -6,7 +6,7 @@ export interface IFeatureFlagsHookResult {
6
6
  * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields.
7
7
  * @throws `KameleoonError` with one of the following `type` s:
8
8
  *
9
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.
9
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.
10
10
  */
11
11
  getFeatureFlags: () => FeatureFlagType[];
12
12
  }
@@ -1,6 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useFeatureFlags=useFeatureFlags;var _react=require("react"),_useKameleoon2=require("./useKameleoon");/**
2
- * A React Hook that returns `getFeatureFlags` function which returns a list of feature flags.
3
- *
4
- * @returns {IFeatureFlagsHookResult} an object containing the `getFeatureFlags` function.
5
- */function useFeatureFlags(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(){return b.getFeatureFlags()},[b]);return{getFeatureFlags:c}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useFeatureFlags=useFeatureFlags;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function useFeatureFlags(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(){return b.getFeatureFlags()},[b]);return{getFeatureFlags:c}}
6
2
  //# sourceMappingURL=useFeatureFlags.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFeatureFlags.js","names":["useFeatureFlags","a","useKameleoon","client","getFeatureFlags","useCallback"],"sources":["../src/useFeatureFlags.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { FeatureFlagType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IFeatureFlagsHookResult {\n /**\n * Returns a list of feature flags stored in the client configuration.\n *\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields.\n * @throws `KameleoonError` with one of the following `type` s:\n * \n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.\n */\n getFeatureFlags: () => FeatureFlagType[];\n}\n\n/**\n * A React Hook that returns `getFeatureFlags` function which returns a list of feature flags.\n *\n * @returns {IFeatureFlagsHookResult} an object containing the `getFeatureFlags` function.\n */\nexport function useFeatureFlags(): IFeatureFlagsHookResult {\n const { client } = useKameleoon();\n\n const getFeatureFlags = useCallback((): FeatureFlagType[] => {\n return client.getFeatureFlags();\n }, [client]);\n\n return {\n getFeatureFlags,\n };\n}\n"],"mappings":"iLAgBA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAA,eAAeA,CAAA,CAA4B,KAAAC,CAAA,CACtC,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAe,CAAG,GAAAC,kBAAW,EAAC,UAAyB,CAC3D,MAAO,CAAAF,CAAM,CAACC,eAAe,EAC/B,CAAC,CAAE,CAACD,CAAM,CAAC,CAAC,CAEZ,MAAO,CACLC,eAAe,CAAfA,CACF,CACF"}
1
+ {"version":3,"file":"useFeatureFlags.js","names":["useFeatureFlags","a","useKameleoon","client","getFeatureFlags","useCallback"],"sources":["../src/useFeatureFlags.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { FeatureFlagType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IFeatureFlagsHookResult {\n /**\n * Returns a list of feature flags stored in the client configuration.\n *\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields.\n * @throws `KameleoonError` with one of the following `type` s:\n * \n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.\n */\n getFeatureFlags: () => FeatureFlagType[];\n}\n\n/**\n * A React Hook that returns `getFeatureFlags` function which returns a list of feature flags.\n *\n * @returns {IFeatureFlagsHookResult} an object containing the `getFeatureFlags` function.\n */\nexport function useFeatureFlags(): IFeatureFlagsHookResult {\n const { client } = useKameleoon();\n\n const getFeatureFlags = useCallback((): FeatureFlagType[] => {\n return client.getFeatureFlags();\n }, [client]);\n\n return {\n getFeatureFlags,\n };\n}\n"],"mappings":"iLAqBO,QAAS,CAAAA,eAAeA,CAAA,CAA4B,KAAAC,CAAA,CACtC,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAe,CAAG,GAAAC,kBAAW,EAAC,UAAyB,CAC3D,MAAO,CAAAF,CAAM,CAACC,eAAe,EAC/B,CAAC,CAAE,CAACD,CAAM,CAAC,CAAC,CAEZ,MAAO,CACLC,eAAe,CAAfA,CACF,CACF"}
@@ -4,13 +4,13 @@ export interface IFeatureVariableHookResult {
4
4
  * Returns a variable for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request.
5
5
  *
6
6
  * @param {GetFeatureFlagVariableParamsType} params - `visitorCode`, `featureKey` and `variableKey` parameters to return variable.
7
- * @return {FeatureVariableResultType} a variable object containing `type` and `value` fields, `type` can be checked against `FeatureVariableType` enum, if the `type` is `FeatureVariableType.BOOLEAN` then the `value` type will be `boolean` and so on.
7
+ * @return {FeatureVariableResultType} a variable object containing `type` and `value` fields. You can check the `type` field against `FeatureVariableType` enum. For example, if the `type` is `FeatureVariableType.BOOLEAN` then `value` will be a `boolean` type.
8
8
  * @throws `KameleoonError` with one of the following `type` s:
9
9
  *
10
10
  * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.
11
11
  * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
12
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.
13
- * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `featureKey`.
12
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.
13
+ * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`.
14
14
  * - `KameleoonException.FeatureFlagVariableNotFound` - No feature variable was found for provided `visitorCode` and `variableKey`
15
15
  * - `KameleoonException.NotTargeted` - Current visitor is not targeted.
16
16
  * - `KameleoonException.JSONParse` - Couldn't pass JSON value.
@@ -21,6 +21,6 @@ export interface IFeatureVariableHookResult {
21
21
  /**
22
22
  * A React Hook that returns `getFeatureFlagVariable` function which retrieves a feature variable.
23
23
  *
24
- * @returns {IPageViewHookResult} an object containing the `getFeatureFlagVariable` function.
24
+ * @returns {IFeatureVariableHookResult} an object containing the `getFeatureFlagVariable` function.
25
25
  */
26
26
  export declare function useFeatureVariable(): IFeatureVariableHookResult;
@@ -1,6 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useFeatureVariable=useFeatureVariable;var _react=require("react"),_useKameleoon2=require("./useKameleoon");/**
2
- * A React Hook that returns `getFeatureFlagVariable` function which retrieves a feature variable.
3
- *
4
- * @returns {IPageViewHookResult} an object containing the `getFeatureFlagVariable` function.
5
- */function useFeatureVariable(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(a){var c=a.visitorCode,d=a.featureKey,e=a.variableKey;return b.getFeatureFlagVariable({visitorCode:c,featureKey:d,variableKey:e})},[b]);return{getFeatureFlagVariable:c}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useFeatureVariable=useFeatureVariable;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function useFeatureVariable(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(a){var c=a.visitorCode,d=a.featureKey,e=a.variableKey;return b.getFeatureFlagVariable({visitorCode:c,featureKey:d,variableKey:e})},[b]);return{getFeatureFlagVariable:c}}
6
2
  //# sourceMappingURL=useFeatureVariable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFeatureVariable.js","names":["useFeatureVariable","a","useKameleoon","client","getFeatureFlagVariable","useCallback","visitorCode","featureKey","variableKey"],"sources":["../src/useFeatureVariable.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport {\n GetFeatureFlagVariableParamsType,\n FeatureVariableResultType,\n} from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IFeatureVariableHookResult {\n /**\n * Returns a variable for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request.\n *\n * @param {GetFeatureFlagVariableParamsType} params - `visitorCode`, `featureKey` and `variableKey` parameters to return variable.\n * @return {FeatureVariableResultType} a variable object containing `type` and `value` fields, `type` can be checked against `FeatureVariableType` enum, if the `type` is `FeatureVariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `featureKey`.\n * - `KameleoonException.FeatureFlagVariableNotFound` - No feature variable was found for provided `visitorCode` and `variableKey`\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted.\n * - `KameleoonException.JSONParse` - Couldn't pass JSON value.\n * - `KameleoonException.NumberParse` - Couldn't pass Number value.\n */\n getFeatureFlagVariable: (\n params: GetFeatureFlagVariableParamsType,\n ) => FeatureVariableResultType;\n}\n\n/**\n * A React Hook that returns `getFeatureFlagVariable` function which retrieves a feature variable.\n *\n * @returns {IPageViewHookResult} an object containing the `getFeatureFlagVariable` function.\n */\nexport function useFeatureVariable(): IFeatureVariableHookResult {\n const { client } = useKameleoon();\n\n const getFeatureFlagVariable = useCallback(\n ({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType): FeatureVariableResultType => {\n return client.getFeatureFlagVariable({\n visitorCode,\n featureKey,\n variableKey,\n });\n },\n [client],\n );\n\n return {\n getFeatureFlagVariable,\n };\n}\n"],"mappings":"uLA6BA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAA,kBAAkBA,CAAA,CAA+B,KAAAC,CAAA,CAC5C,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAsB,CAAG,GAAAC,kBAAW,EACxC,SAAAJ,CAAA,CAImE,IAHjE,CAAAK,CAAW,CAAAL,CAAA,CAAXK,WAAW,CACXC,CAAU,CAAAN,CAAA,CAAVM,UAAU,CACVC,CAAW,CAAAP,CAAA,CAAXO,WAAW,CAEX,MAAO,CAAAL,CAAM,CAACC,sBAAsB,CAAC,CACnCE,WAAW,CAAXA,CAAW,CACXC,UAAU,CAAVA,CAAU,CACVC,WAAW,CAAXA,CACF,CAAC,CACH,CAAC,CACD,CAACL,CAAM,CAAC,CACT,CAED,MAAO,CACLC,sBAAsB,CAAtBA,CACF,CACF"}
1
+ {"version":3,"file":"useFeatureVariable.js","names":["useFeatureVariable","a","useKameleoon","client","getFeatureFlagVariable","useCallback","visitorCode","featureKey","variableKey"],"sources":["../src/useFeatureVariable.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport {\n GetFeatureFlagVariableParamsType,\n FeatureVariableResultType,\n} from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IFeatureVariableHookResult {\n /**\n * Returns a variable for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request.\n *\n * @param {GetFeatureFlagVariableParamsType} params - `visitorCode`, `featureKey` and `variableKey` parameters to return variable.\n * @return {FeatureVariableResultType} a variable object containing `type` and `value` fields. You can check the `type` field against `FeatureVariableType` enum. For example, if the `type` is `FeatureVariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`.\n * - `KameleoonException.FeatureFlagVariableNotFound` - No feature variable was found for provided `visitorCode` and `variableKey`\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted.\n * - `KameleoonException.JSONParse` - Couldn't pass JSON value.\n * - `KameleoonException.NumberParse` - Couldn't pass Number value.\n */\n getFeatureFlagVariable: (\n params: GetFeatureFlagVariableParamsType,\n ) => FeatureVariableResultType;\n}\n\n/**\n * A React Hook that returns `getFeatureFlagVariable` function which retrieves a feature variable.\n *\n * @returns {IFeatureVariableHookResult} an object containing the `getFeatureFlagVariable` function.\n */\nexport function useFeatureVariable(): IFeatureVariableHookResult {\n const { client } = useKameleoon();\n\n const getFeatureFlagVariable = useCallback(\n ({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType): FeatureVariableResultType => {\n return client.getFeatureFlagVariable({\n visitorCode,\n featureKey,\n variableKey,\n });\n },\n [client],\n );\n\n return {\n getFeatureFlagVariable,\n };\n}\n"],"mappings":"uLAkCO,QAAS,CAAAA,kBAAkBA,CAAA,CAA+B,KAAAC,CAAA,CAC5C,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAsB,CAAG,GAAAC,kBAAW,EACxC,SAAAJ,CAAA,CAImE,IAHjE,CAAAK,CAAW,CAAAL,CAAA,CAAXK,WAAW,CACXC,CAAU,CAAAN,CAAA,CAAVM,UAAU,CACVC,CAAW,CAAAP,CAAA,CAAXO,WAAW,CAEX,MAAO,CAAAL,CAAM,CAACC,sBAAsB,CAAC,CACnCE,WAAW,CAAXA,CAAW,CACXC,UAAU,CAAVA,CAAU,CACVC,WAAW,CAAXA,CACF,CAAC,CACH,CAAC,CACD,CAACL,CAAM,CAAC,CACT,CAED,MAAO,CACLC,sBAAsB,CAAtBA,CACF,CACF"}
@@ -0,0 +1,25 @@
1
+ import { FeatureVariableResultType } from '@kameleoon/javascript-sdk-core';
2
+ export interface IFeatureVariablesHookResult {
3
+ /**
4
+ * Returns a list of variables for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request.
5
+ *
6
+ * @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters.
7
+ * @param {string} featureKey - a unique key for feature flag.
8
+ * @return {FeatureVariableResultType[]} a list of variable objects containing `type` and `value` fields. You can check the `type` field against `FeatureVariableType` enum. For example, if the `type` is `FeatureVariableType.BOOLEAN` then `value` will be a `boolean` type.
9
+ * @throws `KameleoonError` with one of the following `type` s:
10
+ * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
11
+ * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
12
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
13
+ * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`
14
+ * - `KameleoonException.FeatureFlagVariationNotFound` - No feature variation was found for provided `visitorCode` and `variationKey`
15
+ * - `KameleoonException.JSONParse` - Couldn't pass JSON value
16
+ * - `KameleoonException.NumberParse` - Couldn't pass Number value
17
+ */
18
+ getFeatureFlagVariables: (visitorCode: string, featureKey: string) => FeatureVariableResultType[];
19
+ }
20
+ /**
21
+ * A React Hook that returns `getFeatureFlagVariables` function which retrieves a list of feature variables.
22
+ *
23
+ * @returns {IFeatureVariablesHookResult} an object containing the `getFeatureFlagVariables` function.
24
+ */
25
+ export declare function useFeatureVariables(): IFeatureVariablesHookResult;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useFeatureVariables=useFeatureVariables;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function useFeatureVariables(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(a,c){return b.getFeatureFlagVariables(a,c)},[b]);return{getFeatureFlagVariables:c}}
2
+ //# sourceMappingURL=useFeatureVariables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFeatureVariables.js","names":["useFeatureVariables","a","useKameleoon","client","getFeatureFlagVariables","useCallback","visitorCode","featureKey"],"sources":["../src/useFeatureVariables.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { FeatureVariableResultType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IFeatureVariablesHookResult {\n /**\n * Returns a list of variables for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request.\n *\n * @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters.\n * @param {string} featureKey - a unique key for feature flag.\n * @return {FeatureVariableResultType[]} a list of variable objects containing `type` and `value` fields. You can check the `type` field against `FeatureVariableType` enum. For example, if the `type` is `FeatureVariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagVariationNotFound` - No feature variation was found for provided `visitorCode` and `variationKey`\n * - `KameleoonException.JSONParse` - Couldn't pass JSON value\n * - `KameleoonException.NumberParse` - Couldn't pass Number value\n */\n getFeatureFlagVariables: (\n visitorCode: string,\n featureKey: string,\n ) => FeatureVariableResultType[];\n}\n\n/**\n * A React Hook that returns `getFeatureFlagVariables` function which retrieves a list of feature variables.\n *\n * @returns {IFeatureVariablesHookResult} an object containing the `getFeatureFlagVariables` function.\n */\nexport function useFeatureVariables(): IFeatureVariablesHookResult {\n const { client } = useKameleoon();\n\n const getFeatureFlagVariables = useCallback(\n (visitorCode, featureKey): FeatureVariableResultType[] => {\n return client.getFeatureFlagVariables(visitorCode, featureKey);\n },\n [client],\n );\n\n return {\n getFeatureFlagVariables,\n };\n}\n"],"mappings":"yLA+BO,QAAS,CAAAA,mBAAmBA,CAAA,CAAgC,KAAAC,CAAA,CAC9C,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAuB,CAAG,GAAAC,kBAAW,EACzC,SAACC,CAAW,CAAEC,CAAU,CAAkC,CACxD,MAAO,CAAAJ,CAAM,CAACC,uBAAuB,CAACE,CAAW,CAAEC,CAAU,CAC/D,CAAC,CACD,CAACJ,CAAM,CAAC,CACT,CAED,MAAO,CACLC,uBAAuB,CAAvBA,CACF,CACF"}
@@ -9,7 +9,7 @@ export interface IFlushHookResult {
9
9
  *
10
10
  * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
11
11
  * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
12
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.
12
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.
13
13
  */
14
14
  flush: (visitorCode: string) => void;
15
15
  }
package/dist/useFlush.js CHANGED
@@ -1,6 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useFlush=useFlush;var _react=require("react"),_useKameleoon2=require("./useKameleoon");/**
2
- * A React Hook that returns `flush` function
3
- *
4
- * @returns {IFlushHookResult} an object containing the `flush` function.
5
- */function useFlush(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(a){b.flush(a)},[b]);return{flush:c}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useFlush=useFlush;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function useFlush(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(a){b.flush(a)},[b]);return{flush:c}}
6
2
  //# sourceMappingURL=useFlush.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFlush.js","names":["useFlush","a","useKameleoon","client","flush","useCallback","visitorCode"],"sources":["../src/useFlush.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IFlushHookResult {\n /**\n * Takes visitor associated kameleoon data and sends the data tracking request with collected data sent data is removed from `KameleoonClient` instance but not from the storage for correct targeting checks.\n * If no visitor is passed, then data for all visitors is sent and removed from `KameleoonClient` instance. Moreover, regardless of visitor code input\n * execution starts with sending all previously failed tracking requests which were stored locally during the offline mode and then proceeds further.\n *\n * @param {string | undefined} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.\n */\n flush: (visitorCode: string) => void;\n}\n\n/**\n * A React Hook that returns `flush` function\n *\n * @returns {IFlushHookResult} an object containing the `flush` function.\n */\nexport function useFlush(): IFlushHookResult {\n const { client } = useKameleoon();\n\n const flush = useCallback(\n (visitorCode: string): void => {\n client.flush(visitorCode);\n },\n [client],\n );\n\n return {\n flush,\n };\n}\n"],"mappings":"mKAmBA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAA,QAAQA,CAAA,CAAqB,KAAAC,CAAA,CACxB,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAK,CAAG,GAAAC,kBAAW,EACvB,SAACC,CAAmB,CAAW,CAC7BH,CAAM,CAACC,KAAK,CAACE,CAAW,CAC1B,CAAC,CACD,CAACH,CAAM,CAAC,CACT,CAED,MAAO,CACLC,KAAK,CAALA,CACF,CACF"}
1
+ {"version":3,"file":"useFlush.js","names":["useFlush","a","useKameleoon","client","flush","useCallback","visitorCode"],"sources":["../src/useFlush.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IFlushHookResult {\n /**\n * Takes visitor associated kameleoon data and sends the data tracking request with collected data sent data is removed from `KameleoonClient` instance but not from the storage for correct targeting checks.\n * If no visitor is passed, then data for all visitors is sent and removed from `KameleoonClient` instance. Moreover, regardless of visitor code input\n * execution starts with sending all previously failed tracking requests which were stored locally during the offline mode and then proceeds further.\n *\n * @param {string | undefined} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.\n */\n flush: (visitorCode: string) => void;\n}\n\n/**\n * A React Hook that returns `flush` function\n *\n * @returns {IFlushHookResult} an object containing the `flush` function.\n */\nexport function useFlush(): IFlushHookResult {\n const { client } = useKameleoon();\n\n const flush = useCallback(\n (visitorCode: string): void => {\n client.flush(visitorCode);\n },\n [client],\n );\n\n return {\n flush,\n };\n}\n"],"mappings":"mKAwBO,QAAS,CAAAA,QAAQA,CAAA,CAAqB,KAAAC,CAAA,CACxB,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAK,CAAG,GAAAC,kBAAW,EACvB,SAACC,CAAmB,CAAW,CAC7BH,CAAM,CAACC,KAAK,CAACE,CAAW,CAC1B,CAAC,CACD,CAACH,CAAM,CAAC,CACT,CAED,MAAO,CACLC,KAAK,CAALA,CACF,CACF"}
@@ -6,6 +6,7 @@ export interface IInitializeHookResult {
6
6
  * @throws `KameleoonError` with one of the following `type` s:
7
7
  *
8
8
  * - `KameleoonException.StorageWrite` Couldn't update storage data.
9
+ * - `KameleoonException.StorageRead` - Couldn't read storage data.
9
10
  * - `KameleoonException.ClientConfiguration` Couldn't retrieve client configuration from Kameleoon Api.
10
11
  * - `KameleoonException.MaximumRetriesReached` Maximum retries reached, request failed
11
12
  */
@@ -1,6 +1,2 @@
1
- "use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.useInitialize=useInitialize;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}/**
2
- * A React Hook that returns asynchronous `initialize` function.
3
- *
4
- * @returns {IInitializeHookResult} an object containing the asynchronous `initialize` function.
5
- */function useInitialize(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a){return _regeneratorRuntime().wrap(function d(c){for(;1;)switch(c.prev=c.next){case 0:return c.next=2,b.initialize(a);case 2:return c.abrupt("return",c.sent);case 3:case"end":return c.stop();}},c)}));return function(b){return a.apply(this,arguments)}}(),[b]);return{initialize:c}}
1
+ "use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.useInitialize=useInitialize;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function _regeneratorRuntime(){"use strict";function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function useInitialize(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(){var a=_asyncToGenerator(_regeneratorRuntime().mark(function c(a){return _regeneratorRuntime().wrap(function d(c){for(;1;)switch(c.prev=c.next){case 0:return c.next=2,b.initialize(a);case 2:return c.abrupt("return",c.sent);case 3:case"end":return c.stop();}},c)}));return function(b){return a.apply(this,arguments)}}(),[b]);return{initialize:c}}
6
2
  //# sourceMappingURL=useInitialize.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useInitialize.js","names":["a","b","c","Object","defineProperty","value","enumerable","configurable","writable","e","f","prototype","d","g","create","h","m","s","i","type","arg","call","forEach","_invoke","j","k","_typeof","r","resolve","__await","then","Error","o","method","delegate","x","sent","_sent","dispatchException","abrupt","done","iterator","return","TypeError","resultName","next","nextLoc","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","l","completion","reset","n","u","isNaN","length","_regeneratorRuntime","p","q","hasOwnProperty","t","Symbol","v","asyncIterator","w","toStringTag","wrap","y","z","getPrototypeOf","A","B","displayName","isGeneratorFunction","constructor","name","mark","setPrototypeOf","__proto__","awrap","AsyncIterator","async","Promise","keys","reverse","pop","values","prev","charAt","slice","stop","rval","complete","finish","catch","_catch","delegateYield","asyncGeneratorStep","_asyncToGenerator","arguments","apply","useInitialize","useKameleoon","client","initialize","useCallback","useCache"],"sources":["../src/useInitialize.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IInitializeHookResult {\n /**\n * An asynchronous method for KameleoonClient initialization by fetching Kameleoon SDK related data from server or by retrieving data from local source if data is up-to-date or update interval has not been reached.\n *\n * @param {boolean | undefined} useCache - optional parameter for activating SDK offline mode, if `true` is passed failed polls will not return error and will use cached data if such data is available, default value is `false`. Note: if offline mode is on, SDK will still try to retrieve the latest data.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.StorageWrite` Couldn't update storage data.\n * - `KameleoonException.ClientConfiguration` Couldn't retrieve client configuration from Kameleoon Api.\n * - `KameleoonException.MaximumRetriesReached` Maximum retries reached, request failed\n */\n initialize: () => Promise<boolean>;\n}\n\n/**\n * A React Hook that returns asynchronous `initialize` function.\n *\n * @returns {IInitializeHookResult} an object containing the asynchronous `initialize` function.\n */\nexport function useInitialize(): IInitializeHookResult {\n const { client } = useKameleoon();\n\n const initialize = useCallback(\n async (useCache?: boolean): Promise<boolean> => {\n return await client.initialize(useCache);\n },\n [client],\n );\n\n return {\n initialize,\n };\n}\n"],"mappings":"2eACA,6JAAAA,GAAA,CAAAC,CAAA,CAAAC,CAAA,SAAAC,MAAA,CAAAC,cAAA,CAAAJ,CAAA,CAAAC,CAAA,EAAAI,KAAA,CAAAH,CAAA,CAAAI,UAAA,IAAAC,YAAA,IAAAC,QAAA,MAAAR,CAAA,CAAAC,CAAA,WAAAA,EAAAD,CAAA,CAAAC,CAAA,CAAAC,CAAA,CAAAO,CAAA,MAAAC,CAAA,CAAAT,CAAA,EAAAA,CAAA,CAAAU,SAAA,YAAAC,CAAA,CAAAX,CAAA,CAAAW,CAAA,CAAAC,CAAA,CAAAV,MAAA,CAAAW,MAAA,CAAAJ,CAAA,CAAAC,SAAA,EAAAI,CAAA,KAAAC,CAAA,CAAAP,CAAA,aAAAQ,CAAA,CAAAJ,CAAA,YAAAR,KAAA,CAAAa,CAAA,CAAAlB,CAAA,CAAAE,CAAA,CAAAa,CAAA,IAAAF,CAAA,UAAAX,EAAAF,CAAA,CAAAC,CAAA,CAAAC,CAAA,aAAAiB,IAAA,UAAAC,GAAA,CAAApB,CAAA,CAAAqB,IAAA,CAAApB,CAAA,CAAAC,CAAA,SAAAF,CAAA,SAAAmB,IAAA,SAAAC,GAAA,CAAApB,CAAA,YAAAY,EAAA,YAAAH,EAAA,YAAAC,EAAA,YAAAG,EAAAZ,CAAA,4BAAAqB,OAAA,UAAApB,CAAA,EAAAF,CAAA,CAAAC,CAAA,CAAAC,CAAA,UAAAF,CAAA,cAAAuB,OAAA,CAAArB,CAAA,CAAAF,CAAA,eAAAe,EAAAf,CAAA,CAAAC,CAAA,WAAAW,EAAAH,CAAA,CAAAC,CAAA,CAAAG,CAAA,CAAAE,CAAA,MAAAG,CAAA,CAAAhB,CAAA,CAAAF,CAAA,CAAAS,CAAA,EAAAT,CAAA,CAAAU,CAAA,eAAAQ,CAAA,CA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IAAA,GACV8D,CAAM,CAACC,UAAU,CAACE,CAAQ,CAAC,eAAA5G,CAAA,CAAAqC,MAAA,UAAArC,CAAA,CAAAkC,IAAA,0BAAAlC,CAAA,CAAA4F,IAAA,MAAA5F,CAAA,EACzC,mBAAAD,CAAA,SAAAD,CAAA,CAAAwG,KAAA,MAAAD,SAAA,MACD,CAACI,CAAM,CAAC,CACT,CAED,MAAO,CACLC,UAAU,CAAVA,CACF,CACF"}
1
+ {"version":3,"file":"useInitialize.js","names":["useInitialize","a","useKameleoon","client","initialize","useCallback","_asyncToGenerator","_regeneratorRuntime","mark","c","useCache","wrap","d","prev","next","abrupt","sent","stop","b","apply","arguments"],"sources":["../src/useInitialize.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IInitializeHookResult {\n /**\n * An asynchronous method for KameleoonClient initialization by fetching Kameleoon SDK related data from server or by retrieving data from local source if data is up-to-date or update interval has not been reached.\n *\n * @param {boolean | undefined} useCache - optional parameter for activating SDK offline mode, if `true` is passed failed polls will not return error and will use cached data if such data is available, default value is `false`. Note: if offline mode is on, SDK will still try to retrieve the latest data.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.StorageWrite` Couldn't update storage data.\n * - `KameleoonException.StorageRead` - Couldn't read storage data.\n * - `KameleoonException.ClientConfiguration` Couldn't retrieve client configuration from Kameleoon Api.\n * - `KameleoonException.MaximumRetriesReached` Maximum retries reached, request failed\n */\n initialize: () => Promise<boolean>;\n}\n\n/**\n * A React Hook that returns asynchronous `initialize` function.\n *\n * @returns {IInitializeHookResult} an object containing the asynchronous `initialize` function.\n */\nexport function useInitialize(): IInitializeHookResult {\n const { client } = useKameleoon();\n\n const initialize = useCallback(\n async (useCache?: boolean): Promise<boolean> => {\n return await client.initialize(useCache);\n },\n [client],\n );\n\n return {\n initialize,\n };\n}\n"],"mappings":"s0OAuBO,QAAS,CAAAA,aAAaA,CAAA,CAA0B,KAAAC,CAAA,CAClC,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAU,CAAG,GAAAC,kBAAW,iBAAAJ,CAAA,CAAAK,iBAAA,CAAAC,mBAAA,GAAAC,IAAA,CAC5B,SAAAC,EAAOC,CAAkB,SAAAH,mBAAA,GAAAI,IAAA,UAAAC,EAAAH,CAAA,iBAAAA,CAAA,CAAAI,IAAA,CAAAJ,CAAA,CAAAK,IAAA,gBAAAL,CAAA,CAAAK,IAAA,GACVX,CAAM,CAACC,UAAU,CAACM,CAAQ,CAAC,eAAAD,CAAA,CAAAM,MAAA,UAAAN,CAAA,CAAAO,IAAA,0BAAAP,CAAA,CAAAQ,IAAA,MAAAR,CAAA,EACzC,mBAAAS,CAAA,SAAAjB,CAAA,CAAAkB,KAAA,MAAAC,SAAA,MACD,CAACjB,CAAM,CAAC,CACT,CAED,MAAO,CACLC,UAAU,CAAVA,CACF,CACF"}
@@ -1,7 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useKameleoon=useKameleoon;var _react=require("react"),_KameleoonContext=require("./KameleoonContext");/**
2
- * A React Hook that validates if context is used within a KameleoonProvider and returns it.
3
- *
4
- * @returns {IKameleoonHookResult} an object containing the `client` field.
5
- * @throws useKameleoon must be used within a KameleoonProvider.
6
- */function useKameleoon(){var a=(0,_react.useContext)(_KameleoonContext.KameleoonContext);if(!a)throw new Error("useKameleoon must be used within a KameleoonProvider");return{client:a}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useKameleoon=useKameleoon;var _react=require("react"),_KameleoonContext=require("./KameleoonContext");function useKameleoon(){var a=(0,_react.useContext)(_KameleoonContext.KameleoonContext);if(!a)throw new Error("useKameleoon must be used within a KameleoonProvider");return{client:a}}
7
2
  //# sourceMappingURL=useKameleoon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useKameleoon.js","names":["useKameleoon","context","useContext","KameleoonContext","Error","client"],"sources":["../src/useKameleoon.ts"],"sourcesContent":["import { useContext } from 'react';\nimport { KameleoonCore } from '@kameleoon/javascript-sdk-core';\nimport { KameleoonContext } from './KameleoonContext';\n\nexport interface IKameleoonHookResult {\n /** An instance of KameleoonClient. */\n client: KameleoonCore;\n}\n\n/**\n * A React Hook that validates if context is used within a KameleoonProvider and returns it.\n *\n * @returns {IKameleoonHookResult} an object containing the `client` field.\n * @throws useKameleoon must be used within a KameleoonProvider.\n */\nexport function useKameleoon(): IKameleoonHookResult {\n const context = useContext(KameleoonContext);\n\n if (!context) {\n throw new Error('useKameleoon must be used within a KameleoonProvider');\n }\n\n return {\n client: context,\n };\n}\n"],"mappings":"kLASA;AACA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAA,YAAYA,CAAA,CAAyB,CACnD,GAAM,CAAAC,CAAO,CAAG,GAAAC,iBAAU,EAACC,kCAAgB,CAAC,CAE5C,GAAI,CAACF,CAAO,CACV,KAAM,IAAI,CAAAG,KAAK,CAAC,sDAAsD,CAAC,CAGzE,MAAO,CACLC,MAAM,CAAEJ,CACV,CACF"}
1
+ {"version":3,"file":"useKameleoon.js","names":["useKameleoon","context","useContext","KameleoonContext","Error","client"],"sources":["../src/useKameleoon.ts"],"sourcesContent":["import { useContext } from 'react';\nimport { KameleoonCore } from '@kameleoon/javascript-sdk-core';\nimport { KameleoonContext } from './KameleoonContext';\n\nexport interface IKameleoonHookResult {\n /** An instance of KameleoonClient. */\n client: KameleoonCore;\n}\n\n/**\n * A React Hook that validates if context is used within a KameleoonProvider and returns it.\n *\n * @returns {IKameleoonHookResult} an object containing the `client` field.\n * @throws useKameleoon must be used within a KameleoonProvider.\n */\nexport function useKameleoon(): IKameleoonHookResult {\n const context = useContext(KameleoonContext);\n\n if (!context) {\n throw new Error('useKameleoon must be used within a KameleoonProvider');\n }\n\n return {\n client: context,\n };\n}\n"],"mappings":"kLAeO,QAAS,CAAAA,YAAYA,CAAA,CAAyB,CACnD,GAAM,CAAAC,CAAO,CAAG,GAAAC,iBAAU,EAACC,kCAAgB,CAAC,CAE5C,GAAI,CAACF,CAAO,CACV,KAAM,IAAI,CAAAG,KAAK,CAAC,sDAAsD,CAAC,CAGzE,MAAO,CACLC,MAAM,CAAEJ,CACV,CACF"}
@@ -8,8 +8,9 @@ export interface INativeVisitorCodeHookResult {
8
8
  getNativeVisitorCode: (defaultVisitorCode?: string) => string;
9
9
  }
10
10
  /**
11
- * A React Hook that returns `getNativeVisitorCode function which obtains the Kameleoon visitorCode.
11
+ * @deprecated This hook is deprecated and will be removed in a future update. For handling legal consent, please use the `useReactNativeVisitorCode` hook instead. Note that legal consent functionality is exclusively available through `useReactNativeVisitorCode` and not via `useNativeVisitorCode`.
12
12
  *
13
+ * A React Hook that returns `getNativeVisitorCode function which obtains the Kameleoon visitorCode.
13
14
  * @returns {INativeVisitorCodeHookResult} an object containing the `getNativeVisitorCode` function.
14
15
  */
15
16
  export declare function useNativeVisitorCode(): INativeVisitorCodeHookResult;
@@ -1,6 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useNativeVisitorCode=useNativeVisitorCode;var _react=require("react"),_nativeUtils=require("./kameleoonUtils/nativeUtils");/**
2
- * A React Hook that returns `getNativeVisitorCode function which obtains the Kameleoon visitorCode.
3
- *
4
- * @returns {INativeVisitorCodeHookResult} an object containing the `getNativeVisitorCode` function.
5
- */function useNativeVisitorCode(){var a=(0,_react.useCallback)(function(a){return _nativeUtils.NativeUtils.getVisitorCode(a)},[]);return{getNativeVisitorCode:a}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useNativeVisitorCode=useNativeVisitorCode;var _react=require("react"),_nativeUtils=require("./kameleoonUtils/nativeUtils");function useNativeVisitorCode(){var a=(0,_react.useCallback)(function(a){return _nativeUtils.NativeUtils.getVisitorCode(a)},[]);return{getNativeVisitorCode:a}}
6
2
  //# sourceMappingURL=useNativeVisitorCode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useNativeVisitorCode.js","names":["useNativeVisitorCode","getNativeVisitorCode","useCallback","defaultVisitorCode","NativeUtils","getVisitorCode"],"sources":["../src/useNativeVisitorCode.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { NativeUtils } from './kameleoonUtils/nativeUtils';\n\nexport interface INativeVisitorCodeHookResult {\n /**\n * Obtains visitor code from the storage, if no visitor code exists returns a new random visitor code (or the specified default value).\n *\n * @param {string | undefined} defaultVisitorCode - visitor code to be used instead of randomly generated visitor code in case there is no visitor code saved in storage.\n * @returns {string} result visitor code.\n */\n getNativeVisitorCode: (defaultVisitorCode?: string) => string;\n}\n\n/**\n * A React Hook that returns `getNativeVisitorCode function which obtains the Kameleoon visitorCode.\n *\n * @returns {INativeVisitorCodeHookResult} an object containing the `getNativeVisitorCode` function.\n */\nexport function useNativeVisitorCode(): INativeVisitorCodeHookResult {\n const getNativeVisitorCode = useCallback(\n (defaultVisitorCode?: string): string => {\n return NativeUtils.getVisitorCode(defaultVisitorCode);\n },\n [],\n );\n\n return {\n getNativeVisitorCode,\n };\n}\n"],"mappings":"uMAaA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAA,oBAAoBA,CAAA,CAAiC,CACnE,GAAM,CAAAC,CAAoB,CAAG,GAAAC,kBAAW,EACtC,SAACC,CAA2B,CAAa,CACvC,MAAO,CAAAC,wBAAW,CAACC,cAAc,CAACF,CAAkB,CACtD,CAAC,CACD,EAAE,CACH,CAED,MAAO,CACLF,oBAAoB,CAApBA,CACF,CACF"}
1
+ {"version":3,"file":"useNativeVisitorCode.js","names":["useNativeVisitorCode","getNativeVisitorCode","useCallback","defaultVisitorCode","NativeUtils","getVisitorCode"],"sources":["../src/useNativeVisitorCode.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { NativeUtils } from './kameleoonUtils/nativeUtils';\n\nexport interface INativeVisitorCodeHookResult {\n /**\n * Obtains visitor code from the storage, if no visitor code exists returns a new random visitor code (or the specified default value).\n *\n * @param {string | undefined} defaultVisitorCode - visitor code to be used instead of randomly generated visitor code in case there is no visitor code saved in storage.\n * @returns {string} result visitor code.\n */\n getNativeVisitorCode: (defaultVisitorCode?: string) => string;\n}\n\n/**\n * @deprecated This hook is deprecated and will be removed in a future update. For handling legal consent, please use the `useReactNativeVisitorCode` hook instead. Note that legal consent functionality is exclusively available through `useReactNativeVisitorCode` and not via `useNativeVisitorCode`.\n *\n * A React Hook that returns `getNativeVisitorCode function which obtains the Kameleoon visitorCode.\n * @returns {INativeVisitorCodeHookResult} an object containing the `getNativeVisitorCode` function.\n */\nexport function useNativeVisitorCode(): INativeVisitorCodeHookResult {\n const getNativeVisitorCode = useCallback(\n (defaultVisitorCode?: string): string => {\n return NativeUtils.getVisitorCode(defaultVisitorCode);\n },\n [],\n );\n\n return {\n getNativeVisitorCode,\n };\n}\n"],"mappings":"uMAmBO,QAAS,CAAAA,oBAAoBA,CAAA,CAAiC,CACnE,GAAM,CAAAC,CAAoB,CAAG,GAAAC,kBAAW,EACtC,SAACC,CAA2B,CAAa,CACvC,MAAO,CAAAC,wBAAW,CAACC,cAAc,CAACF,CAAkB,CACtD,CAAC,CACD,EAAE,CACH,CAED,MAAO,CACLF,oBAAoB,CAApBA,CACF,CACF"}
@@ -0,0 +1,20 @@
1
+ export interface IReactNativeVisitorCodeHookResult {
2
+ /**
3
+ * Obtains visitor code from the storage, if no visitor code exists returns a new random visitor code (or the specified default value).
4
+ *
5
+ * @param {string | undefined} defaultVisitorCode - visitor code to be used instead of randomly generated visitor code in case there is no visitor code saved in storage.
6
+ * @returns {string} result visitor code.
7
+ * @throws `KameleoonError` with one of the following `type` s:
8
+ *
9
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.
10
+ * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
11
+ * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
12
+ */
13
+ getReactNativeVisitorCode: (defaultVisitorCode?: string) => string;
14
+ }
15
+ /**
16
+ * A React Hook that returns `getReactNativeVisitorCode function which obtains the Kameleoon visitorCode.
17
+ *
18
+ * @returns {IReactNativeVisitorCodeHookResult} an object containing the `getReactNativeVisitorCode` function.
19
+ */
20
+ export declare function useReactNativeVisitorCode(): IReactNativeVisitorCodeHookResult;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useReactNativeVisitorCode=useReactNativeVisitorCode;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function useReactNativeVisitorCode(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(a){return b.getVisitorCode({defaultVisitorCode:a})},[]);return{getReactNativeVisitorCode:c}}
2
+ //# sourceMappingURL=useReactNativeVisitorCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useReactNativeVisitorCode.js","names":["useReactNativeVisitorCode","a","useKameleoon","client","getReactNativeVisitorCode","useCallback","defaultVisitorCode","getVisitorCode"],"sources":["../src/useReactNativeVisitorCode.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IReactNativeVisitorCodeHookResult {\n /**\n * Obtains visitor code from the storage, if no visitor code exists returns a new random visitor code (or the specified default value).\n *\n * @param {string | undefined} defaultVisitorCode - visitor code to be used instead of randomly generated visitor code in case there is no visitor code saved in storage.\n * @returns {string} result visitor code.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n */\n getReactNativeVisitorCode: (defaultVisitorCode?: string) => string;\n}\n\n/**\n * A React Hook that returns `getReactNativeVisitorCode function which obtains the Kameleoon visitorCode.\n *\n * @returns {IReactNativeVisitorCodeHookResult} an object containing the `getReactNativeVisitorCode` function.\n */\nexport function useReactNativeVisitorCode(): IReactNativeVisitorCodeHookResult {\n const { client } = useKameleoon();\n\n const getReactNativeVisitorCode = useCallback(\n (defaultVisitorCode?: string): string => {\n return client.getVisitorCode({ defaultVisitorCode });\n },\n [],\n );\n\n return {\n getReactNativeVisitorCode,\n };\n}\n"],"mappings":"qMAuBO,QAAS,CAAAA,yBAAyBA,CAAA,CAAsC,KAAAC,CAAA,CAC1D,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAyB,CAAG,GAAAC,kBAAW,EAC3C,SAACC,CAA2B,CAAa,CACvC,MAAO,CAAAH,CAAM,CAACI,cAAc,CAAC,CAAED,kBAAkB,CAAlBA,CAAmB,CAAC,CACrD,CAAC,CACD,EAAE,CACH,CAED,MAAO,CACLF,yBAAyB,CAAzBA,CACF,CACF"}
@@ -0,0 +1,20 @@
1
+ export interface IReactVisitorCodeHookResult {
2
+ /**
3
+ * Obtains visitor code from browser cookie, if no cookie exists returns new random visitor code (or the specified default value).
4
+ *
5
+ * @param {string | undefined} defaultVisitorCode - visitor code to be used instead of randomly generated visitor code in case there is no visitor code saved in browser cookie.
6
+ * @returns {string} result visitor code.
7
+ * @throws `KameleoonError` with one of the following `type` s:
8
+ *
9
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.
10
+ * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
11
+ * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
12
+ */
13
+ getReactVisitorCode: (defaultVisitorCode?: string) => string;
14
+ }
15
+ /**
16
+ * A React Hook that returns `getReactVisitorCode` function which obtains the Kameleoon visitorCode.
17
+ *
18
+ * @returns {IReactVisitorCodeHookResult} an object containing the `getReactVisitorCode` function.
19
+ */
20
+ export declare function useReactVisitorCode(): IReactVisitorCodeHookResult;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useReactVisitorCode=useReactVisitorCode;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function useReactVisitorCode(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(a){return b.getVisitorCode({defaultVisitorCode:a})},[]);return{getReactVisitorCode:c}}
2
+ //# sourceMappingURL=useReactVisitorCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useReactVisitorCode.js","names":["useReactVisitorCode","a","useKameleoon","client","getReactVisitorCode","useCallback","defaultVisitorCode","getVisitorCode"],"sources":["../src/useReactVisitorCode.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IReactVisitorCodeHookResult {\n /**\n * Obtains visitor code from browser cookie, if no cookie exists returns new random visitor code (or the specified default value).\n *\n * @param {string | undefined} defaultVisitorCode - visitor code to be used instead of randomly generated visitor code in case there is no visitor code saved in browser cookie.\n * @returns {string} result visitor code.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n */\n getReactVisitorCode: (defaultVisitorCode?: string) => string;\n}\n\n/**\n * A React Hook that returns `getReactVisitorCode` function which obtains the Kameleoon visitorCode.\n *\n * @returns {IReactVisitorCodeHookResult} an object containing the `getReactVisitorCode` function.\n */\nexport function useReactVisitorCode(): IReactVisitorCodeHookResult {\n const { client } = useKameleoon();\n\n const getReactVisitorCode = useCallback(\n (defaultVisitorCode?: string): string => {\n return client.getVisitorCode({ defaultVisitorCode });\n },\n [],\n );\n\n return {\n getReactVisitorCode,\n };\n}\n"],"mappings":"yLAuBO,QAAS,CAAAA,mBAAmBA,CAAA,CAAgC,KAAAC,CAAA,CAC9C,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAmB,CAAG,GAAAC,kBAAW,EACrC,SAACC,CAA2B,CAAa,CACvC,MAAO,CAAAH,CAAM,CAACI,cAAc,CAAC,CAAED,kBAAkB,CAAlBA,CAAmB,CAAC,CACrD,CAAC,CACD,EAAE,CACH,CAED,MAAO,CACLF,mBAAmB,CAAnBA,CACF,CACF"}
@@ -1,6 +1,2 @@
1
- "use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.useRemoteData=useRemoteData;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}/**
2
- * A React Hook that returns asynchronous getRemoteData function which retrieves data from Kameleoon server.
3
- *
4
- * @returns {IRemoteDataHookResult} an object containing the `getRemoteData` function.
5
- */function useRemoteData(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a){return _regeneratorRuntime().wrap(function d(c){for(;1;)switch(c.prev=c.next){case 0:return c.next=2,b.getRemoteData(a);case 2:return c.abrupt("return",c.sent);case 3:case"end":return c.stop();}},c)}));return function(b){return a.apply(this,arguments)}}(),[b]);return{getRemoteData:c}}
1
+ "use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.useRemoteData=useRemoteData;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function _regeneratorRuntime(){"use strict";function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function useRemoteData(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(){var a=_asyncToGenerator(_regeneratorRuntime().mark(function c(a){return _regeneratorRuntime().wrap(function d(c){for(;1;)switch(c.prev=c.next){case 0:return c.next=2,b.getRemoteData(a);case 2:return c.abrupt("return",c.sent);case 3:case"end":return c.stop();}},c)}));return function(b){return a.apply(this,arguments)}}(),[b]);return{getRemoteData:c}}
6
2
  //# sourceMappingURL=useRemoteData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useRemoteData.js","names":["a","b","c","Object","defineProperty","value","enumerable","configurable","writable","e","f","prototype","d","g","create","h","m","s","i","type","arg","call","forEach","_invoke","j","k","_typeof","r","resolve","__await","then","Error","o","method","delegate","x","sent","_sent","dispatchException","abrupt","done","iterator","return","TypeError","resultName","next","nextLoc","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","l","completion","reset","n","u","isNaN","length","_regeneratorRuntime","p","q","hasOwnProperty","t","Symbol","v","asyncIterator","w","toStringTag","wrap","y","z","getPrototypeOf","A","B","displayName","isGeneratorFunction","constructor","name","mark","setPrototypeOf","__proto__","awrap","AsyncIterator","async","Promise","keys","reverse","pop","values","prev","charAt","slice","stop","rval","complete","finish","catch","_catch","delegateYield","asyncGeneratorStep","_asyncToGenerator","arguments","apply","useRemoteData","useKameleoon","client","getRemoteData","useCallback","key"],"sources":["../src/useRemoteData.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { JSONType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IRemoteDataHookResult {\n /**\n * Returns a data which is stored for specified siteCode on a remote Kameleoon server.\n *\n * @param {string} key - unique key that the data you try to get is associated with.\n * @returns {Promise<JSONType>} promise with retrieving data for specific key.\n * @throws `KameleoonError` with one of the following `type` s:\n * \n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server.\n */\n getRemoteData: (key: string) => Promise<JSONType>;\n}\n\n/**\n * A React Hook that returns asynchronous getRemoteData function which retrieves data from Kameleoon server.\n *\n * @returns {IRemoteDataHookResult} an object containing the `getRemoteData` function.\n */\nexport function useRemoteData(): IRemoteDataHookResult {\n const { client } = useKameleoon();\n\n const getRemoteData = useCallback(\n async (key: string): Promise<JSONType> => {\n return await client.getRemoteData(key);\n },\n [client],\n );\n\n return {\n getRemoteData,\n };\n}\n"],"mappings":"2eACA,6JAAAA,GAAA,CAAAC,CAAA,CAAAC,CAAA,SAAAC,MAAA,CAAAC,cAAA,CAAAJ,CAAA,CAAAC,CAAA,EAAAI,KAAA,CAAAH,CAAA,CAAAI,UAAA,IAAAC,YAAA,IAAAC,QAAA,MAAAR,CAAA,CAAAC,CAAA,WAAAA,EAAAD,CAAA,CAAAC,CAAA,CAAAC,CAAA,CAAAO,CAAA,MAAAC,CAAA,CAAAT,CAAA,EAAAA,CAAA,CAAAU,SAAA,YAAAC,CAAA,CAAAX,CAAA,CAAAW,CAAA,CAAAC,CAAA,CAAAV,MAAA,CAAAW,MAAA,CAAAJ,CAAA,CAAAC,SAAA,EAAAI,CAAA,KAAAC,CAAA,CAAAP,CAAA,aAAAQ,CAAA,CAAAJ,CAAA,YAAAR,KAAA,CAAAa,CAAA,CAAAlB,CAAA,CAAAE,CAAA,CAAAa,CAAA,IAAAF,CAAA,UAAAX,EAAAF,CAAA,CAAAC,CAAA,CAAAC,CAAA,aAAAiB,IAAA,UAAAC,GAAA,CAAApB,CAAA,CAAAqB,IAAA,CAAApB,CAAA,CAAAC,CAAA,SAAAF,CAAA,SAAAmB,IAAA,SAAAC,GAAA,CAAApB,CAAA,YAAAY,EAAA,YAAAH,EAAA,YAAAC,EAAA,YAAAG,EAAAZ,CAAA,4BAAAqB,OAAA,UAAApB,CAAA,EAAAF,CAAA,CAAAC,CAAA,CAAAC,CAAA,UAAAF,CAAA,cAAAuB,OAAA,CAAArB,CAAA,CAAAF,CAAA,eAAAe,EAAAf,CAAA,CAA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AA,CAC/B,SAAA9E,EAAO4G,CAAW,SAAAlD,mBAAA,GAAAU,IAAA,UAAA1D,EAAAV,CAAA,iBAAAA,CAAA,CAAAyF,IAAA,CAAAzF,CAAA,CAAA2C,IAAA,gBAAA3C,CAAA,CAAA2C,IAAA,GACH8D,CAAM,CAACC,aAAa,CAACE,CAAG,CAAC,eAAA5G,CAAA,CAAAqC,MAAA,UAAArC,CAAA,CAAAkC,IAAA,0BAAAlC,CAAA,CAAA4F,IAAA,MAAA5F,CAAA,EACvC,mBAAAD,CAAA,SAAAD,CAAA,CAAAwG,KAAA,MAAAD,SAAA,MACD,CAACI,CAAM,CAAC,CACT,CAED,MAAO,CACLC,aAAa,CAAbA,CACF,CACF"}
1
+ {"version":3,"file":"useRemoteData.js","names":["useRemoteData","a","useKameleoon","client","getRemoteData","useCallback","_asyncToGenerator","_regeneratorRuntime","mark","c","key","wrap","d","prev","next","abrupt","sent","stop","b","apply","arguments"],"sources":["../src/useRemoteData.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { JSONType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IRemoteDataHookResult {\n /**\n * Returns a data which is stored for specified siteCode on a remote Kameleoon server.\n *\n * @param {string} key - unique key that the data you try to get is associated with.\n * @returns {Promise<JSONType>} promise with retrieving data for specific key.\n * @throws `KameleoonError` with one of the following `type` s:\n * \n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server.\n */\n getRemoteData: (key: string) => Promise<JSONType>;\n}\n\n/**\n * A React Hook that returns asynchronous getRemoteData function which retrieves data from Kameleoon server.\n *\n * @returns {IRemoteDataHookResult} an object containing the `getRemoteData` function.\n */\nexport function useRemoteData(): IRemoteDataHookResult {\n const { client } = useKameleoon();\n\n const getRemoteData = useCallback(\n async (key: string): Promise<JSONType> => {\n return await client.getRemoteData(key);\n },\n [client],\n );\n\n return {\n getRemoteData,\n };\n}\n"],"mappings":"s0OAsBO,QAAS,CAAAA,aAAaA,CAAA,CAA0B,KAAAC,CAAA,CAClC,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAa,CAAG,GAAAC,kBAAW,iBAAAJ,CAAA,CAAAK,iBAAA,CAAAC,mBAAA,GAAAC,IAAA,CAC/B,SAAAC,EAAOC,CAAW,SAAAH,mBAAA,GAAAI,IAAA,UAAAC,EAAAH,CAAA,iBAAAA,CAAA,CAAAI,IAAA,CAAAJ,CAAA,CAAAK,IAAA,gBAAAL,CAAA,CAAAK,IAAA,GACHX,CAAM,CAACC,aAAa,CAACM,CAAG,CAAC,eAAAD,CAAA,CAAAM,MAAA,UAAAN,CAAA,CAAAO,IAAA,0BAAAP,CAAA,CAAAQ,IAAA,MAAAR,CAAA,EACvC,mBAAAS,CAAA,SAAAjB,CAAA,CAAAkB,KAAA,MAAAC,SAAA,MACD,CAACjB,CAAM,CAAC,CACT,CAED,MAAO,CACLC,aAAa,CAAbA,CACF,CACF"}
@@ -1,22 +1,22 @@
1
- import { KameleoonDataType } from '@kameleoon/javascript-sdk-core';
1
+ import { KameleoonDataType, RemoteVisitorDataParamsType } from '@kameleoon/javascript-sdk-core';
2
2
  export interface IRemoteVisitorDataHookResult {
3
3
  /**
4
4
  * An asynchronous method for retrieving custom data for the latest visit of `visitorCode` from Kameleoon Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.
5
5
  *
6
- * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
7
- * @param {boolean | undefined} shouldAddData - optional parameter for adding retrieved data to the storage like `addData` method does, default value is `true`
8
- *
9
- * @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances, only includes custom data
6
+ * @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData` and `filters` parameters
7
+ * @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances
10
8
  * @throws `KameleoonError` with one of the following `type` s:
11
9
  *
12
10
  * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
13
11
  * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
14
12
  * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server
13
+ * - `KameleoonException.VisitAmount` - Visit amount must be a number between 1 and 25
14
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
15
15
  */
16
- getRemoteVisitorData: (visitorCode: string, shouldAddData?: boolean) => Promise<KameleoonDataType[]>;
16
+ getRemoteVisitorData: ({ visitorCode, shouldAddData, filters, }: RemoteVisitorDataParamsType) => Promise<KameleoonDataType[]>;
17
17
  }
18
18
  /**
19
- * A React Hook that returns asynchronous getRemoteVisitorData function which retrieves custom data from Kameleoon server and optionally adds it to storage.
19
+ * A React Hook that returns asynchronous getRemoteVisitorData function which retrieves data from Kameleoon server and optionally adds it to storage.
20
20
  *
21
21
  * @returns {IRemoteVisitorDataHookResult} an object containing the `getRemoteVisitorData` function.
22
22
  */
@@ -1,6 +1,2 @@
1
- "use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.useRemoteVisitorData=useRemoteVisitorData;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}/**
2
- * A React Hook that returns asynchronous getRemoteVisitorData function which retrieves custom data from Kameleoon server and optionally adds it to storage.
3
- *
4
- * @returns {IRemoteVisitorDataHookResult} an object containing the `getRemoteVisitorData` function.
5
- */function useRemoteVisitorData(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function d(a,c){return _regeneratorRuntime().wrap(function e(d){for(;1;)switch(d.prev=d.next){case 0:return d.next=2,b.getRemoteVisitorData(a,c);case 2:return d.abrupt("return",d.sent);case 3:case"end":return d.stop();}},d)}));return function(b,c){return a.apply(this,arguments)}}(),[b]);return{getRemoteVisitorData:c}}
1
+ "use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.useRemoteVisitorData=useRemoteVisitorData;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function _regeneratorRuntime(){"use strict";function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function useRemoteVisitorData(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(){var a=_asyncToGenerator(_regeneratorRuntime().mark(function c(a){return _regeneratorRuntime().wrap(function d(c){for(;1;)switch(c.prev=c.next){case 0:return c.next=2,b.getRemoteVisitorData(a);case 2:return c.abrupt("return",c.sent);case 3:case"end":return c.stop();}},c)}));return function(b){return a.apply(this,arguments)}}(),[b]);return{getRemoteVisitorData:c}}
6
2
  //# sourceMappingURL=useRemoteVisitorData.js.map