Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
init({ locales, lang }) {
if (didInit) {
logger.warn('Looks like i18n locales are already inited. Changing locales now may lead to inconsistent translations.');
}
didInit = true;
this.text = getTranslator(locales, lang);
this.price = getPriceFormatter(lang);
this.date = getDateFormatter(lang);
this.time = getTimeFormatter(lang);
this.number = getNumberFormatter(lang);
// If component decides to act accordingly this information should be exposed.
this.ready = true;
},
text: notReadyCb,
Object.keys(src).forEach((key) => {
const keyPath = `${path}.${key}`.replace(/^\./, '');
const prop = src[key];
if (!isObjectOrArray(dest[key]) || !isObjectOrArray(prop)) {
// output a warning if only one of both is an object (undefined dest is fine -> no warning)
if (warn && dest[key] !== undefined
&& (!isObjectOrArray(dest[key]) ? isObjectOrArray(prop) : !isObjectOrArray(prop))) {
logger.warn('Trying to merge object properties with mixed object types: ', prop, dest[key]);
}
// Overwrite always if one of the props is not an object or array
dest[key] = prop;
return;
}
// Both structures are objects but one or both can be an array
if (isArray(prop) && isArray(dest[key])) {
// Try to keep reference of as many array items as possible
prop.forEach((element, destIndex) => {
const itemPath = `${keyPath}.${destIndex}`;
// Check if a maching array item exists for merging
const existing = dest[key].find((prev, prevIndex) =>
arrayComparator(itemPath, prev, element, prevIndex, destIndex));
constructor(props) {
super(props);
logger.warn('===== RangeSlider deprecated =====\nThe RangeSlider component and it\'s related components (@shopgate/pwa-common/component/RangeSlider) are deprecated and will be removed in @shopgate/engage v7.0.0.\nPlease use: import { RangeSlider } from \'@shopgate/engage/components\'.\n===================================');
this.draggedHandle = null; // 0 for left handle, 1 for right handle or null
this.domElement = null;
this.touchOffset = 0;
this.draggedHandlePixelOffset = 0; // The absolute pixel delta of the last handle move event.
this.state = this.getRange(props);
}
registerHelper(callback, eventName, options = {}) {
const defaults = {
trackerName: '',
page: null,
merchant: true,
shopgate: true,
options: {},
};
const pluginOptions = {
...defaults,
...options,
};
if (!pluginOptions.trackerName) {
logger.warn(`'SgTrackingCore': Attempt to register for event "${eventName}" by a nameless tracker`);
}
// Get the correct store
const store = this.getEventStore(eventName, pluginOptions.page);
// Add the callback to queue
const index = store.push({
callback,
trackerName: pluginOptions.trackerName,
useNativeSdk: pluginOptions.options.useNativeSdk,
overrideUnified: pluginOptions.options.overrideUnified,
merchant: pluginOptions.merchant,
shopgate: pluginOptions.shopgate,
}) - 1;
// Provide handle back for removal of event
constructor(options) {
const trackerName = 'facebookPixel';
const extendedDefaults = {
config: {
pixelIds: [],
},
};
super(trackerName, options, extendedDefaults);
if (this.options.useNativeSdk) {
logger.warn('SgFbPixelTracking: no native SDK support for this plugin');
return;
}
if (!this.options.config.pixelIds.length) {
logger.warn('SgFbPixelTracking: pixels missing');
return;
}
this.initPlugin();
}
handleLegacyLink({
targetTab: 'main',
location: '/register/guest',
historyAction,
});
break;
case LEGACY_LINK_CONNECT_REGISTER:
handleLegacyLink({
location: `/${LEGACY_LINK_CONNECT_REGISTER}`,
targetTab: 'main',
backCallback: 'SGAction.popTabToRoot(); SGAction.showTab({ targetTab: "main" });',
historyAction,
}, state);
break;
default:
logger.warn(`openLegacyLink not handled: ${location}`);
break;
}
};
addLinkAction(action, opt) {
if (!actions[action]) {
logger.warn(`Tried to add invalid url action: ${action}`);
return;
}
this.actions.push({
action,
options: opt,
});
}
export const track = (eventName, data, state) => {
if (typeof core.track[eventName] !== 'function') {
logger.warn('Unknown tracking event:', eventName);
return false;
}
try {
core.track[eventName](data, undefined, undefined, state);
} catch (e) {
logger.error(e);
}
return core;
};
(products, props) => {
if (typeof props !== 'object') {
logger.warn('Invocation of getProductById() with a productId will be deprecated soon. Please provide a props object.');
return products[props] || null;
}
if (!props.productId) {
return null;
}
return products[props.productId] || null;
}
);
(products, props) => {
if (typeof props !== 'object') {
logger.warn('Invocation of getProductById() with a productId will be deprecated soon. Use a props object instead.');
return products[props] || null;
}
if (!props.productId) {
return null;
}
return products[props.productId] || null;
}
);