kameleoon-react-sdk
Advanced tools
Comparing version 1.0.0 to 1.1.0
import * as react_jsx_runtime from 'react/jsx-runtime'; | ||
import * as _kameleoon_javascript_sdk from '@kameleoon/javascript-sdk'; | ||
import { SDKParameters } from '@kameleoon/javascript-sdk'; | ||
export { ApplicationVersion, Browser, BrowserType, Conversion, ConversionParametersType, Cookie, CookieType, CustomData, Device, DeviceType, GeolocationData, GeolocationInfoType, OperatingSystem, OperatingSystemType, PageView, PageViewParametersType, UserAgent } from '@kameleoon/javascript-sdk'; | ||
@@ -9,4 +10,5 @@ | ||
siteCode: string; | ||
config?: Omit<SDKParameters, 'siteCode'>; | ||
} | ||
declare function KameleoonProvider({ children, enabled, siteCode }: KameleoonProviderProps): react_jsx_runtime.JSX.Element; | ||
declare function KameleoonProvider({ children, enabled, siteCode, config }: KameleoonProviderProps): react_jsx_runtime.JSX.Element; | ||
@@ -13,0 +15,0 @@ interface KameleoonScriptProps extends React.ScriptHTMLAttributes<HTMLScriptElement> { |
@@ -1,2 +0,2 @@ | ||
"use strict";var m=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var P=(n,o)=>{for(var r in o)m(n,r,{get:o[r],enumerable:!0})},h=(n,o,r,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of x(o))!T.call(n,a)&&a!==r&&m(n,a,{get:()=>o[a],enumerable:!(t=w(o,a))||t.enumerable});return n};var k=n=>h(m({},"__esModule",{value:!0}),n);var S={};P(S,{ApplicationVersion:()=>e.ApplicationVersion,Browser:()=>e.Browser,BrowserType:()=>e.BrowserType,Conversion:()=>e.Conversion,ConversionParametersType:()=>e.ConversionParametersType,Cookie:()=>e.Cookie,CookieType:()=>e.CookieType,CustomData:()=>e.CustomData,Device:()=>e.Device,DeviceType:()=>e.DeviceType,GeolocationData:()=>e.GeolocationData,GeolocationInfoType:()=>e.GeolocationInfoType,KameleoonProvider:()=>F,KameleoonScript:()=>v,OperatingSystem:()=>e.OperatingSystem,OperatingSystemType:()=>e.OperatingSystemType,PageView:()=>e.PageView,PageViewParametersType:()=>e.PageViewParametersType,UserAgent:()=>e.UserAgent,useKameleoon:()=>E});module.exports=k(S);var i=require("react");var c=require("react");function D(){return typeof navigator!="undefined"&&typeof navigator.onLine=="boolean"?navigator.onLine:!0}function p(){let[n,o]=(0,c.useState)(()=>D());return(0,c.useEffect)(()=>(window.addEventListener("online",()=>o(!0)),window.addEventListener("offline",()=>o(!1)),()=>{window.removeEventListener("online",()=>o(!0)),window.removeEventListener("offline",()=>o(!1))}),[]),n}var d=require("@kameleoon/javascript-sdk"),K=require("react/jsx-runtime"),f=(0,i.createContext)(null);function F({children:n,enabled:o,siteCode:r}){let[t,a]=(0,i.useState)(null),l=p(),g=(0,i.useRef)({trackConversion:[],addData:[],flush:[],setLegalConsent:[]});return(0,i.useEffect)(()=>{o&&(async()=>{let u=new d.KameleoonClient({siteCode:r});await u.initialize(),a(u)})()},[o,r]),(0,i.useEffect)(()=>{t&&l&&(Object.entries(g.current).forEach(([C,u])=>{u.forEach(b=>t[C](...b))}),g.current={trackConversion:[],addData:[],flush:[],setLegalConsent:[]})},[t,l]),(0,K.jsx)(f.Provider,{value:{client:t,queueRef:g},children:n})}var y=require("react/jsx-runtime");function v({siteCode:n,component:o,...r}){let t=`//${n}.kameleoon.io/kameleoon.js`;return o?o(t):(0,y.jsx)("script",{src:t,async:!0,crossOrigin:"anonymous",referrerPolicy:"no-referrer",...r})}var s=require("react");var V=require("@kameleoon/javascript-sdk");function R(n,o,r,t=!1){return(...a)=>{if(!n&&t&&o.current[r].push(a),n)try{return n[r](...a)}catch(l){l instanceof V.KameleoonError?console.error(`Kameleoon error: ${l.message}`):console.error(`Error in Kameleoon method '${r}':`,l)}}}function E(){let n=(0,s.useContext)(f);if(!n)throw new Error("useKameleoon must be used within a KameleoonProvider");let{client:o,queueRef:r}=n,t=(0,s.useCallback)((a,l=!1)=>R(o,r,a,l),[o,r]);return(0,s.useMemo)(()=>({isFeatureFlagActive:t("isFeatureFlagActive"),getFeatureFlagVariationKey:t("getFeatureFlagVariationKey"),getFeatureFlags:t("getFeatureFlags"),getVisitorFeatureFlags:t("getVisitorFeatureFlags"),getActiveFeatureFlags:t("getActiveFeatureFlags"),getFeatureFlagVariable:t("getFeatureFlagVariable"),getFeatureFlagVariables:t("getFeatureFlagVariables"),getVisitorCode:t("getVisitorCode"),addData:t("addData",!0),flush:t("flush",!0),getRemoteData:t("getRemoteData"),getRemoteVisitorData:t("getRemoteVisitorData"),getVisitorWarehouseAudience:t("getVisitorWarehouseAudience"),setLegalConsent:t("setLegalConsent",!0),trackConversion:t("trackConversion",!0),getEngineTrackingCode:t("getEngineTrackingCode"),onEvent:t("onEvent")}),[t])}var e=require("@kameleoon/javascript-sdk");0&&(module.exports={ApplicationVersion,Browser,BrowserType,Conversion,ConversionParametersType,Cookie,CookieType,CustomData,Device,DeviceType,GeolocationData,GeolocationInfoType,KameleoonProvider,KameleoonScript,OperatingSystem,OperatingSystemType,PageView,PageViewParametersType,UserAgent,useKameleoon}); | ||
"use strict";var g=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var S=(n,o)=>{for(var r in o)g(n,r,{get:o[r],enumerable:!0})},h=(n,o,r,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of T(o))!D.call(n,a)&&a!==r&&g(n,a,{get:()=>o[a],enumerable:!(t=x(o,a))||t.enumerable});return n};var k=n=>h(g({},"__esModule",{value:!0}),n);var O={};S(O,{ApplicationVersion:()=>e.ApplicationVersion,Browser:()=>e.Browser,BrowserType:()=>e.BrowserType,Conversion:()=>e.Conversion,ConversionParametersType:()=>e.ConversionParametersType,Cookie:()=>e.Cookie,CookieType:()=>e.CookieType,CustomData:()=>e.CustomData,Device:()=>e.Device,DeviceType:()=>e.DeviceType,GeolocationData:()=>e.GeolocationData,GeolocationInfoType:()=>e.GeolocationInfoType,KameleoonProvider:()=>F,KameleoonScript:()=>y,OperatingSystem:()=>e.OperatingSystem,OperatingSystemType:()=>e.OperatingSystemType,PageView:()=>e.PageView,PageViewParametersType:()=>e.PageViewParametersType,UserAgent:()=>e.UserAgent,useKameleoon:()=>P});module.exports=k(O);var K=require("@kameleoon/javascript-sdk"),i=require("react");var m=require("react");function L(){return typeof navigator!="undefined"&&typeof navigator.onLine=="boolean"?navigator.onLine:!0}function d(){let[n,o]=(0,m.useState)(()=>L());return(0,m.useEffect)(()=>(window.addEventListener("online",()=>o(!0)),window.addEventListener("offline",()=>o(!1)),()=>{window.removeEventListener("online",()=>o(!0)),window.removeEventListener("offline",()=>o(!1))}),[]),n}var v=require("react/jsx-runtime"),f=(0,i.createContext)(null);function F({children:n,enabled:o,siteCode:r,config:t={}}){let[a,l]=(0,i.useState)(null),C=d(),b=(0,i.useMemo)(()=>({siteCode:r,...t}),[r,t]),c=(0,i.useRef)({trackConversion:[],addData:[],flush:[],setLegalConsent:[]});return(0,i.useEffect)(()=>{o&&(async()=>{let u=new K.KameleoonClient(b);await u.initialize(),l(u)})()},[o]),(0,i.useEffect)(()=>{a&&C&&(Object.entries(c.current).forEach(([p,u])=>{u.forEach(w=>a[p](...w))}),c.current={trackConversion:[],addData:[],flush:[],setLegalConsent:[]})},[a,C]),(0,v.jsx)(f.Provider,{value:{client:a,queueRef:c},children:n})}var V=require("react/jsx-runtime");function y({siteCode:n,component:o,...r}){let t=`//${n}.kameleoon.io/kameleoon.js`;return o?o(t):(0,V.jsx)("script",{src:t,async:!0,crossOrigin:"anonymous",referrerPolicy:"no-referrer",...r})}var s=require("react");var R=require("@kameleoon/javascript-sdk");function E(n,o,r,t=!1){return(...a)=>{if(!n&&t&&o.current[r].push(a),n)try{return n[r](...a)}catch(l){l instanceof R.KameleoonError?console.error(`Kameleoon error: ${l.message}`):console.error(`Error in Kameleoon method '${r}':`,l)}}}function P(){let n=(0,s.useContext)(f);if(!n)throw new Error("useKameleoon must be used within a KameleoonProvider");let{client:o,queueRef:r}=n,t=(0,s.useCallback)((a,l=!1)=>E(o,r,a,l),[o,r]);return(0,s.useMemo)(()=>({isFeatureFlagActive:t("isFeatureFlagActive"),getFeatureFlagVariationKey:t("getFeatureFlagVariationKey"),getFeatureFlags:t("getFeatureFlags"),getVisitorFeatureFlags:t("getVisitorFeatureFlags"),getActiveFeatureFlags:t("getActiveFeatureFlags"),getFeatureFlagVariable:t("getFeatureFlagVariable"),getFeatureFlagVariables:t("getFeatureFlagVariables"),getVisitorCode:t("getVisitorCode"),addData:t("addData",!0),flush:t("flush",!0),getRemoteData:t("getRemoteData"),getRemoteVisitorData:t("getRemoteVisitorData"),getVisitorWarehouseAudience:t("getVisitorWarehouseAudience"),setLegalConsent:t("setLegalConsent",!0),trackConversion:t("trackConversion",!0),getEngineTrackingCode:t("getEngineTrackingCode"),onEvent:t("onEvent")}),[t])}var e=require("@kameleoon/javascript-sdk");0&&(module.exports={ApplicationVersion,Browser,BrowserType,Conversion,ConversionParametersType,Cookie,CookieType,CustomData,Device,DeviceType,GeolocationData,GeolocationInfoType,KameleoonProvider,KameleoonScript,OperatingSystem,OperatingSystemType,PageView,PageViewParametersType,UserAgent,useKameleoon}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "kameleoon-react-sdk", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A better Kameleoon.com React SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -1,4 +0,4 @@ | ||
# React Kameleoon SDK | ||
# Kameleoon React SDK | ||
[![npm version](https://img.shields.io/npm/v/react-kameleoon-sdk.svg)](https://www.npmjs.com/package/react-kameleoon-sdk) | ||
[![npm version](https://img.shields.io/npm/v/kameleoon-react-sdk.svg)](https://www.npmjs.com/package/kameleoon-react-sdk) | ||
[![Coverage Status](https://coveralls.io/repos/github/orafaelfragoso/kameleoon-react-sdk/badge.svg?branch=main)](https://coveralls.io/github/orafaelfragoso/kameleoon-react-sdk?branch=main) | ||
@@ -36,3 +36,3 @@ | ||
```bash | ||
npm install react-kameleoon-sdk | ||
npm install kameleoon-react-sdk | ||
``` | ||
@@ -43,3 +43,3 @@ | ||
```bash | ||
yarn add react-kameleoon-sdk | ||
yarn add kameleoon-react-sdk | ||
``` | ||
@@ -50,3 +50,3 @@ | ||
```bash | ||
pnpm add react-kameleoon-sdk | ||
pnpm add kameleoon-react-sdk | ||
``` | ||
@@ -65,3 +65,3 @@ | ||
```jsx | ||
import { KameleoonProvider } from 'react-kameleoon-sdk'; | ||
import { KameleoonProvider } from 'kameleoon-react-sdk'; | ||
@@ -86,3 +86,3 @@ function MyApp({ Component, pageProps }) { | ||
```jsx | ||
import { useKameleoon } from 'react-kameleoon-sdk'; | ||
import { useKameleoon } from 'kameleoon-react-sdk'; | ||
@@ -107,3 +107,3 @@ function MyComponent() { | ||
```jsx | ||
import { KameleoonScript } from 'react-kameleoon-sdk'; | ||
import { KameleoonScript } from 'kameleoon-react-sdk'; | ||
import Script from 'next/script'; | ||
@@ -110,0 +110,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43205
66