@kameleoon/react-sdk 8.3.0 → 8.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/kameleoonClient.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createClient=createClient;var _javascriptSdkCore=require("@kameleoon/javascript-sdk-core"),_eventSource=require("./eventSource"),_visitorCodeManager=require("./visitorCodeManager"),_storage=require("./storage"),_requester=require("./requester");function createClient(a){var b=a.siteCode,c=a.configuration,d="undefined"!=typeof window&&!!window.document,e=d?new _storage.LocalStorageConstructor:new _storage.NativeStorageConstructor,f=d?new _eventSource.BrowserEventSourceConstructor:new _eventSource.NativeEventSourceConstructor,g=new _requester.RequestDispatcher,h=d?new _visitorCodeManager.ReactVisitorCodeManagerConstructor(null===c||void 0===c?void 0:c.domain):new _visitorCodeManager.ReactNativeVisitorCodeManagerConstructor,i=new _javascriptSdkCore.KameleoonCore({siteCode:b,configuration:c,internalConfiguration:{externalStorage:e,externalEventSource:f,externalVisitorCodeManager:h,externalRequestDispatcher:g,externalPackageInfo:{type:_javascriptSdkCore.SdkLanguageType.REACT,version:"8.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createClient=createClient;var _javascriptSdkCore=require("@kameleoon/javascript-sdk-core"),_eventSource=require("./eventSource"),_visitorCodeManager=require("./visitorCodeManager"),_storage=require("./storage"),_requester=require("./requester");function createClient(a){var b=a.siteCode,c=a.configuration,d="undefined"!=typeof window&&!!window.document,e=d?new _storage.LocalStorageConstructor:new _storage.NativeStorageConstructor,f=d?new _eventSource.BrowserEventSourceConstructor:new _eventSource.NativeEventSourceConstructor,g=new _requester.RequestDispatcher,h=d?new _visitorCodeManager.ReactVisitorCodeManagerConstructor(null===c||void 0===c?void 0:c.domain):new _visitorCodeManager.ReactNativeVisitorCodeManagerConstructor,i=new _javascriptSdkCore.KameleoonCore({siteCode:b,configuration:c,internalConfiguration:{externalStorage:e,externalEventSource:f,externalVisitorCodeManager:h,externalRequestDispatcher:g,externalPackageInfo:{type:_javascriptSdkCore.SdkLanguageType.REACT,version:"8.4.1"}}});return{client:i,visitorCodeManager:h}}
|
|
2
2
|
//# sourceMappingURL=kameleoonClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kameleoonClient.js","names":["createClient","a","siteCode","configuration","isBrowser","window","document","storage","LocalStorageConstructor","NativeStorageConstructor","eventSource","BrowserEventSourceConstructor","NativeEventSourceConstructor","requestDispatcher","RequestDispatcher","visitorCodeManager","ReactVisitorCodeManagerConstructor","domain","ReactNativeVisitorCodeManagerConstructor","client","KameleoonCore","internalConfiguration","externalStorage","externalEventSource","externalVisitorCodeManager","externalRequestDispatcher","externalPackageInfo","type","SdkLanguageType","REACT","version"],"sources":["../src/kameleoonClient.ts"],"sourcesContent":["import {\n KameleoonCore,\n SdkLanguageType,\n IExternalStorageConstructor,\n IExternalEventSourceConstructor,\n} from '@kameleoon/javascript-sdk-core';\nimport {\n
|
|
1
|
+
{"version":3,"file":"kameleoonClient.js","names":["createClient","a","siteCode","configuration","isBrowser","window","document","storage","LocalStorageConstructor","NativeStorageConstructor","eventSource","BrowserEventSourceConstructor","NativeEventSourceConstructor","requestDispatcher","RequestDispatcher","visitorCodeManager","ReactVisitorCodeManagerConstructor","domain","ReactNativeVisitorCodeManagerConstructor","client","KameleoonCore","internalConfiguration","externalStorage","externalEventSource","externalVisitorCodeManager","externalRequestDispatcher","externalPackageInfo","type","SdkLanguageType","REACT","version"],"sources":["../src/kameleoonClient.ts"],"sourcesContent":["import {\n KameleoonCore,\n SdkLanguageType,\n IExternalStorageConstructor,\n IExternalEventSourceConstructor,\n} from '@kameleoon/javascript-sdk-core';\nimport {\n BrowserEventSourceConstructor,\n NativeEventSourceConstructor,\n} from './eventSource';\nimport {\n ReactVisitorCodeManagerConstructor,\n ReactNativeVisitorCodeManagerConstructor,\n} from './visitorCodeManager';\nimport { LocalStorageConstructor, NativeStorageConstructor } from './storage';\nimport { RequestDispatcher } from './requester';\nimport { KameleoonContextType, SDKParameters } from './types';\n\n/**\n * Creates an instance of KameleoonClient\n * @param {string} siteCode - client's siteCode defined on Kameleoon platform\n * @param {Partial<SDKConfigurationType> | undefined} configuration - client's configuration\n */\nexport function createClient({\n siteCode,\n configuration,\n}: SDKParameters): KameleoonContextType {\n const isBrowser = typeof window !== 'undefined' && Boolean(window.document);\n const storage: IExternalStorageConstructor = isBrowser\n ? new LocalStorageConstructor()\n : new NativeStorageConstructor();\n const eventSource: IExternalEventSourceConstructor = isBrowser\n ? new BrowserEventSourceConstructor()\n : new NativeEventSourceConstructor();\n const requestDispatcher = new RequestDispatcher();\n const visitorCodeManager = isBrowser\n ? new ReactVisitorCodeManagerConstructor(configuration?.domain)\n : new ReactNativeVisitorCodeManagerConstructor();\n\n const client = new KameleoonCore({\n siteCode,\n configuration,\n internalConfiguration: {\n externalStorage: storage,\n externalEventSource: eventSource,\n externalVisitorCodeManager: visitorCodeManager,\n externalRequestDispatcher: requestDispatcher,\n externalPackageInfo: {\n type: SdkLanguageType.REACT,\n version: process.env.npm_package_version as string,\n },\n },\n });\n\n return { client, visitorCodeManager };\n}\n"],"mappings":"iUAuBO,QAAS,CAAAA,YAAYA,CAAAC,CAAA,CAGY,IAFtC,CAAAC,CAAQ,CAAAD,CAAA,CAARC,QAAQ,CACRC,CAAa,CAAAF,CAAA,CAAbE,aAAa,CAEPC,CAAS,CAAqB,WAAW,EAA7B,MAAO,CAAAC,MAAsB,IAAYA,MAAM,CAACC,QAAS,CACrEC,CAAoC,CAAGH,CAAS,CAClD,GAAI,CAAAI,gCAAyB,CAC7B,GAAI,CAAAC,iCAA0B,CAC5BC,CAA4C,CAAGN,CAAS,CAC1D,GAAI,CAAAO,0CAA+B,CACnC,GAAI,CAAAC,yCAA8B,CAChCC,CAAiB,CAAG,GAAI,CAAAC,4BAAmB,CAC3CC,CAAkB,CAAGX,CAAS,CAChC,GAAI,CAAAY,sDAAkC,QAACb,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAEc,MAAM,CAAC,CAC7D,GAAI,CAAAC,4DAA0C,CAE5CC,CAAM,CAAG,GAAI,CAAAC,gCAAa,CAAC,CAC/BlB,QAAQ,CAARA,CAAQ,CACRC,aAAa,CAAbA,CAAa,CACbkB,qBAAqB,CAAE,CACrBC,eAAe,CAAEf,CAAO,CACxBgB,mBAAmB,CAAEb,CAAW,CAChCc,0BAA0B,CAAET,CAAkB,CAC9CU,yBAAyB,CAAEZ,CAAiB,CAC5Ca,mBAAmB,CAAE,CACnBC,IAAI,CAAEC,kCAAe,CAACC,KAAK,CAC3BC,OAAO,QACT,CACF,CACF,CAAC,CAAC,CAEF,MAAO,CAAEX,MAAM,CAANA,CAAM,CAAEJ,kBAAkB,CAAlBA,CAAmB,CACtC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FeatureFlagVariableType, GetFeatureFlagVariableParamsType } from '@kameleoon/javascript-sdk-core';
|
|
2
2
|
export interface IFeatureVariableHookResult {
|
|
3
3
|
/**
|
|
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 {
|
|
7
|
+
* @return {FeatureFlagVariableType} a variable object containing `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.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.
|
|
@@ -16,7 +16,7 @@ export interface IFeatureVariableHookResult {
|
|
|
16
16
|
* - `KameleoonException.JSONParse` - Couldn't pass JSON value.
|
|
17
17
|
* - `KameleoonException.NumberParse` - Couldn't pass Number value.
|
|
18
18
|
*/
|
|
19
|
-
getFeatureFlagVariable: (params: GetFeatureFlagVariableParamsType) =>
|
|
19
|
+
getFeatureFlagVariable: (params: GetFeatureFlagVariableParamsType) => FeatureFlagVariableType;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* A React Hook that returns `getFeatureFlagVariable` function which retrieves a feature variable.
|
|
@@ -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
|
|
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 FeatureFlagVariableType,\n GetFeatureFlagVariableParamsType,\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 {FeatureFlagVariableType} a variable object containing `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.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 ) => FeatureFlagVariableType;\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): FeatureFlagVariableType => {\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,CAIiE,IAH/D,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"}
|
|
@@ -5,7 +5,7 @@ export interface IFeatureVariablesHookResult {
|
|
|
5
5
|
*
|
|
6
6
|
* @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters.
|
|
7
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 `
|
|
8
|
+
* @return {FeatureVariableResultType[]} a list of variable objects containing `key`, `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.
|
|
9
9
|
* @throws `KameleoonError` with one of the following `type` s:
|
|
10
10
|
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
|
|
11
11
|
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
|
|
@@ -1 +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 `
|
|
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 `key`, `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.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"}
|