@ninetailed/experience.js-react 4.2.0-beta.3 → 4.2.0-beta.4

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/index.cjs CHANGED
@@ -7,20 +7,11 @@ var React = require('react');
7
7
  var experience_js = require('@ninetailed/experience.js');
8
8
  var reactIntersectionObserver = require('react-intersection-observer');
9
9
  var experience_jsShared = require('@ninetailed/experience.js-shared');
10
- var isEqual = require('lodash/isEqual');
11
- var has$1 = require('lodash/has');
12
- var _debounce = require('lodash/debounce');
13
- var values$1 = require('lodash/values');
14
- var get$1 = require('lodash/get');
10
+ var radash = require('radash');
15
11
 
16
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
13
 
18
14
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
19
- var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
20
- var has__default = /*#__PURE__*/_interopDefaultLegacy(has$1);
21
- var _debounce__default = /*#__PURE__*/_interopDefaultLegacy(_debounce);
22
- var values__default = /*#__PURE__*/_interopDefaultLegacy(values$1);
23
- var get__default = /*#__PURE__*/_interopDefaultLegacy(get$1);
24
15
 
25
16
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
26
17
 
@@ -1914,7 +1905,7 @@ const useProfile = () => {
1914
1905
  */
1915
1906
  React.useEffect(() => {
1916
1907
  ninetailed.onProfileChange(profileState => {
1917
- if (isEqual__default["default"](profileState, profileStateRef.current)) {
1908
+ if (radash.isEqual(profileState, profileStateRef.current)) {
1918
1909
  experience_jsShared.logger.debug('Profile State Did Not Change', profileState);
1919
1910
  return;
1920
1911
  } else {
@@ -2250,7 +2241,7 @@ const ESRLoadingComponent = _a => {
2250
2241
  const {
2251
2242
  experienceVariantsMap
2252
2243
  } = useESR();
2253
- const experience = experiences.find(experience => has__default["default"](experienceVariantsMap, experience.id));
2244
+ const experience = experiences.find(experience => Object.prototype.hasOwnProperty.call(experienceVariantsMap, experience.id));
2254
2245
  if (!experience) {
2255
2246
  return jsxRuntime.jsx(Component, Object.assign({}, passthroughProps, baseline, {
2256
2247
  ninetailed: {
@@ -2305,14 +2296,16 @@ const ESRLoadingComponent = _a => {
2305
2296
 
2306
2297
  const EXPERIENCE_TRAIT_PREFIX = 'nt_experiment_';
2307
2298
 
2308
- const debounce = (fn, wait, options) => {
2299
+ const debounce = (fn, wait) => {
2309
2300
  let debouncedArgs = [];
2310
- const debouncedFn = _debounce__default["default"](() => {
2301
+ const debouncedFn = radash.debounce({
2302
+ delay: wait !== null && wait !== void 0 ? wait : 0
2303
+ }, () => {
2311
2304
  fn.call(undefined, debouncedArgs);
2312
2305
  debouncedArgs = [];
2313
- }, wait, options);
2306
+ });
2314
2307
  return (...args) => {
2315
- debouncedArgs.push(values__default["default"](args));
2308
+ debouncedArgs.push(args);
2316
2309
  debouncedFn();
2317
2310
  };
2318
2311
  };
@@ -2516,11 +2509,11 @@ const generateSelectors = id => {
2516
2509
  };
2517
2510
  const selectValueFromProfile = (profile, id) => {
2518
2511
  const selectors = generateSelectors(id);
2519
- const matchingSelector = selectors.find(selector => get__default["default"](profile, selector));
2512
+ const matchingSelector = selectors.find(selector => radash.get(profile, selector));
2520
2513
  if (!matchingSelector) {
2521
2514
  return null;
2522
2515
  }
2523
- return get__default["default"](profile, matchingSelector);
2516
+ return radash.get(profile, matchingSelector);
2524
2517
  };
2525
2518
  const MergeTag = ({
2526
2519
  id
package/index.js CHANGED
@@ -3,11 +3,7 @@ import React, { createContext, useContext, useEffect, useState, useRef, useMemo,
3
3
  import { selectDistribution, selectHasExperienceVariants, selectActiveExperiments, selectExperience, selectExperienceVariant, makeExperienceSelectMiddleware, Ninetailed, selectVariant } from '@ninetailed/experience.js';
4
4
  import { useInView } from 'react-intersection-observer';
5
5
  import { isBrowser, logger } from '@ninetailed/experience.js-shared';
6
- import isEqual from 'lodash/isEqual';
7
- import has$1 from 'lodash/has';
8
- import _debounce from 'lodash/debounce';
9
- import values$1 from 'lodash/values';
10
- import get$1 from 'lodash/get';
6
+ import { isEqual, debounce as debounce$1, get as get$1 } from 'radash';
11
7
 
12
8
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
13
9
 
@@ -2237,7 +2233,7 @@ const ESRLoadingComponent = _a => {
2237
2233
  const {
2238
2234
  experienceVariantsMap
2239
2235
  } = useESR();
2240
- const experience = experiences.find(experience => has$1(experienceVariantsMap, experience.id));
2236
+ const experience = experiences.find(experience => Object.prototype.hasOwnProperty.call(experienceVariantsMap, experience.id));
2241
2237
  if (!experience) {
2242
2238
  return jsx(Component, Object.assign({}, passthroughProps, baseline, {
2243
2239
  ninetailed: {
@@ -2292,14 +2288,16 @@ const ESRLoadingComponent = _a => {
2292
2288
 
2293
2289
  const EXPERIENCE_TRAIT_PREFIX = 'nt_experiment_';
2294
2290
 
2295
- const debounce = (fn, wait, options) => {
2291
+ const debounce = (fn, wait) => {
2296
2292
  let debouncedArgs = [];
2297
- const debouncedFn = _debounce(() => {
2293
+ const debouncedFn = debounce$1({
2294
+ delay: wait !== null && wait !== void 0 ? wait : 0
2295
+ }, () => {
2298
2296
  fn.call(undefined, debouncedArgs);
2299
2297
  debouncedArgs = [];
2300
- }, wait, options);
2298
+ });
2301
2299
  return (...args) => {
2302
- debouncedArgs.push(values$1(args));
2300
+ debouncedArgs.push(args);
2303
2301
  debouncedFn();
2304
2302
  };
2305
2303
  };
package/lib/MergeTag.d.ts CHANGED
@@ -4,6 +4,6 @@ type MergeTagProps = {
4
4
  id: string;
5
5
  };
6
6
  export declare const generateSelectors: (id: string) => string[];
7
- export declare const selectValueFromProfile: (profile: Profile, id: string) => any;
7
+ export declare const selectValueFromProfile: (profile: Profile, id: string) => unknown;
8
8
  export declare const MergeTag: React.FC<React.PropsWithChildren<MergeTagProps>>;
9
9
  export {};
@@ -41,12 +41,7 @@ export declare const useProfile: () => {
41
41
  averageSessionLength: number;
42
42
  };
43
43
  };
44
- error: null; /**
45
- * This effect compares the old and new profile state before updating it.
46
- * We use a ref to avoid an infinite loop which can happen when an empty profile state was updated with no changes.
47
- * This behaviour occurred as the validation handling on the error property was not set properly in the "CreateProfile" and "UpdateProfile" endpoint types.
48
- * Furthermore, it was also observed, that it "only" occurred when the preview plugin was used in parallel.
49
- */
44
+ error: null;
50
45
  } | {
51
46
  loading: boolean;
52
47
  from: "api" | "hydrated";
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-react",
3
- "version": "4.2.0-beta.3",
3
+ "version": "4.2.0-beta.4",
4
4
  "peerDependencies": {
5
5
  "react": ">=16.8.0"
6
6
  },
7
7
  "dependencies": {
8
8
  "@analytics/google-analytics": "0.5.3",
9
9
  "react-visibility-sensor": "5.1.1",
10
- "lodash": "4.17.21",
11
- "@ninetailed/experience.js": "4.2.0-beta.3",
10
+ "@ninetailed/experience.js": "4.2.0-beta.4",
12
11
  "react-intersection-observer": "8.34.0",
13
- "@ninetailed/experience.js-shared": "4.2.0-beta.3",
12
+ "@ninetailed/experience.js-shared": "4.2.0-beta.4",
13
+ "radash": "10.9.0",
14
14
  "analytics": "0.8.1"
15
15
  },
16
16
  "module": "./index.js",