@folklore/tracking
Advanced tools
Comparing version 0.0.25 to 0.0.26
@@ -10,7 +10,2 @@ 'use strict'; | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes); | ||
/* eslint-disable class-methods-use-this */ | ||
@@ -150,10 +145,8 @@ class Tracking { | ||
} | ||
var Tracking$1 = Tracking; | ||
const TrackingContext = /*#__PURE__*/React__default["default"].createContext(); | ||
var TrackingContext$1 = TrackingContext; | ||
const TrackingContext = /*#__PURE__*/React.createContext(); | ||
const getDisplayName = WrappedComponent => WrappedComponent.displayName || WrappedComponent.name || 'Component'; | ||
const withTracking = WrappedComponent => { | ||
const WithTrackingComponent = props => /*#__PURE__*/jsxRuntime.jsx(TrackingContext$1.Consumer, { | ||
const WithTrackingComponent = props => /*#__PURE__*/jsxRuntime.jsx(TrackingContext.Consumer, { | ||
children: tracking => /*#__PURE__*/jsxRuntime.jsx(WrappedComponent, { | ||
@@ -167,12 +160,10 @@ tracking: tracking, | ||
}; | ||
var withTracking$1 = withTracking; | ||
const useTracking = () => React.useContext(TrackingContext$1); | ||
var useTracking$1 = useTracking; | ||
const useTracking = () => React.useContext(TrackingContext); | ||
const propTypes = { | ||
tracking: PropTypes__default["default"].instanceOf(Tracking$1), | ||
disabled: PropTypes__default["default"].bool, | ||
paused: PropTypes__default["default"].bool, | ||
children: PropTypes__default["default"].node | ||
tracking: PropTypes.instanceOf(Tracking), | ||
disabled: PropTypes.bool, | ||
paused: PropTypes.bool, | ||
children: PropTypes.node | ||
}; | ||
@@ -192,3 +183,3 @@ const defaultProps = { | ||
} = _ref; | ||
const finalTracking = React.useMemo(() => tracking || new Tracking$1({ | ||
const finalTracking = React.useMemo(() => tracking || new Tracking({ | ||
disabled, | ||
@@ -203,3 +194,3 @@ paused | ||
}, [tracking, disabled, paused]); | ||
return /*#__PURE__*/jsxRuntime.jsx(TrackingContext$1.Provider, { | ||
return /*#__PURE__*/jsxRuntime.jsx(TrackingContext.Provider, { | ||
value: finalTracking, | ||
@@ -225,3 +216,3 @@ children: children | ||
} = params || {}; | ||
const tracking = useTracking$1(); | ||
const tracking = useTracking(); | ||
const progressTrackedRef = React.useRef({}); | ||
@@ -309,8 +300,8 @@ const { | ||
exports.Tracking = Tracking$1; | ||
exports.Tracking = Tracking; | ||
exports.TrackingContainer = TrackingContainer; | ||
exports.TrackingContext = TrackingContext$1; | ||
exports["default"] = Tracking$1; | ||
exports.useTracking = useTracking$1; | ||
exports.TrackingContext = TrackingContext; | ||
exports.default = Tracking; | ||
exports.useTracking = useTracking; | ||
exports.useVideoTracking = useVideoTracking; | ||
exports.withTracking = withTracking$1; | ||
exports.withTracking = withTracking; |
@@ -140,10 +140,8 @@ import { v4 } from 'uuid'; | ||
} | ||
var Tracking$1 = Tracking; | ||
const TrackingContext = /*#__PURE__*/React.createContext(); | ||
var TrackingContext$1 = TrackingContext; | ||
const getDisplayName = WrappedComponent => WrappedComponent.displayName || WrappedComponent.name || 'Component'; | ||
const withTracking = WrappedComponent => { | ||
const WithTrackingComponent = props => /*#__PURE__*/jsx(TrackingContext$1.Consumer, { | ||
const WithTrackingComponent = props => /*#__PURE__*/jsx(TrackingContext.Consumer, { | ||
children: tracking => /*#__PURE__*/jsx(WrappedComponent, { | ||
@@ -157,9 +155,7 @@ tracking: tracking, | ||
}; | ||
var withTracking$1 = withTracking; | ||
const useTracking = () => useContext(TrackingContext$1); | ||
var useTracking$1 = useTracking; | ||
const useTracking = () => useContext(TrackingContext); | ||
const propTypes = { | ||
tracking: PropTypes.instanceOf(Tracking$1), | ||
tracking: PropTypes.instanceOf(Tracking), | ||
disabled: PropTypes.bool, | ||
@@ -182,3 +178,3 @@ paused: PropTypes.bool, | ||
} = _ref; | ||
const finalTracking = useMemo(() => tracking || new Tracking$1({ | ||
const finalTracking = useMemo(() => tracking || new Tracking({ | ||
disabled, | ||
@@ -193,3 +189,3 @@ paused | ||
}, [tracking, disabled, paused]); | ||
return /*#__PURE__*/jsx(TrackingContext$1.Provider, { | ||
return /*#__PURE__*/jsx(TrackingContext.Provider, { | ||
value: finalTracking, | ||
@@ -215,3 +211,3 @@ children: children | ||
} = params || {}; | ||
const tracking = useTracking$1(); | ||
const tracking = useTracking(); | ||
const progressTrackedRef = useRef({}); | ||
@@ -299,2 +295,2 @@ const { | ||
export { Tracking$1 as Tracking, TrackingContainer, TrackingContext$1 as TrackingContext, Tracking$1 as default, useTracking$1 as useTracking, useVideoTracking, withTracking$1 as withTracking }; | ||
export { Tracking, TrackingContainer, TrackingContext, Tracking as default, useTracking, useVideoTracking, withTracking }; |
{ | ||
"name": "@folklore/tracking", | ||
"version": "0.0.25", | ||
"version": "0.0.26", | ||
"description": "Tracking utilities", | ||
@@ -38,3 +38,3 @@ "keywords": [ | ||
"clean": "rm -rf dist", | ||
"build": "rollup --config ../../rollup.config.js", | ||
"build": "rollup --bundleConfigAsCjs --config ../../rollup.config.js", | ||
"prepare": "npm run clean && npm run build" | ||
@@ -55,3 +55,3 @@ }, | ||
}, | ||
"gitHead": "4c607d1f1a031278d3cf2249a84452a214af57b0" | ||
"gitHead": "c13ef70b8126b3182b3e3365f34f9231fa9b1535" | ||
} |
17934
574