@gooddata/js-utils
Advanced tools
Comparing version 3.4.0-tomsatgd-cleanup-2019-08-27T12-51-12-639Z to 3.4.0-tomsatgd-cleanup-2019-08-28T11-11-49-031Z
@@ -12,2 +12,2 @@ import * as stringUtils from './utils/string'; | ||
}; | ||
export { stringUtils as string, envUtils as env, cookiesUtils as cookies, postEventsUtils as postEvents, testUtils, walkMe, trialSnippet, translations }; | ||
export { stringUtils as string, envUtils as env, cookiesUtils as cookies, postEventsUtils as postEvents, testUtils, walkMe, trialSnippet, translations, }; |
@@ -0,12 +1,21 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// (C) 2007-2018 GoodData Corporation | ||
import * as stringUtils from './utils/string'; | ||
import * as envUtils from './utils/env'; | ||
import * as cookiesUtils from './utils/cookies'; | ||
import * as postEventsUtils from './utils/post-events'; | ||
import * as testUtils from './utils/testUtils'; | ||
import * as walkMe from './utils/walkme'; | ||
import * as translations from './utils/translations'; | ||
import { load } from './utils/trialSnippet'; | ||
var trialSnippet = { load: load }; | ||
export { stringUtils as string, envUtils as env, cookiesUtils as cookies, postEventsUtils as postEvents, testUtils, walkMe, trialSnippet, translations, }; | ||
var stringUtils = require("./utils/string"); | ||
exports.string = stringUtils; | ||
var envUtils = require("./utils/env"); | ||
exports.env = envUtils; | ||
var cookiesUtils = require("./utils/cookies"); | ||
exports.cookies = cookiesUtils; | ||
var postEventsUtils = require("./utils/post-events"); | ||
exports.postEvents = postEventsUtils; | ||
var testUtils = require("./utils/testUtils"); | ||
exports.testUtils = testUtils; | ||
var walkMe = require("./utils/walkme"); | ||
exports.walkMe = walkMe; | ||
var translations = require("./utils/translations"); | ||
exports.translations = translations; | ||
var trialSnippet_1 = require("./utils/trialSnippet"); | ||
var trialSnippet = { load: trialSnippet_1.load }; | ||
exports.trialSnippet = trialSnippet; | ||
//# sourceMappingURL=index.js.map |
@@ -0,4 +1,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// (C) 2007-2018 GoodData Corporation | ||
import * as Cookies from 'js-cookie'; | ||
import { get } from 'lodash'; | ||
var Cookies = require("js-cookie"); | ||
var lodash_1 = require("lodash"); | ||
var LOCALE_COOKIE_NAME = 'locale'; | ||
@@ -43,3 +45,3 @@ /** | ||
*/ | ||
export function syncCookieWithBootstrap(data, localeKeys, localeDefault, deps) { | ||
function syncCookieWithBootstrap(data, localeKeys, localeDefault, deps) { | ||
if (localeKeys === void 0) { localeKeys = []; } | ||
@@ -49,3 +51,3 @@ if (localeDefault === void 0) { localeDefault = 'en-US'; } | ||
var _a = deps.getLocaleCookie, getLocaleCookie = _a === void 0 ? getLocale : _a, _b = deps.setLocaleCookie, setLocaleCookie = _b === void 0 ? setLocale : _b, _c = deps.cookiesEnabled, cookiesEnabled = _c === void 0 ? areCookiesEnabled : _c; | ||
var localeBootstrap = get(data, ['bootstrapResource', 'accountSetting', 'language']); | ||
var localeBootstrap = lodash_1.get(data, ['bootstrapResource', 'accountSetting', 'language']); | ||
var localeCookie = getLocaleCookie(); | ||
@@ -57,2 +59,3 @@ var locale = localeKeys.includes(localeBootstrap) ? localeBootstrap : localeDefault; | ||
} | ||
exports.syncCookieWithBootstrap = syncCookieWithBootstrap; | ||
//# sourceMappingURL=cookies.js.map |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// (C) 2007-2018 GoodData Corporation | ||
@@ -7,3 +9,3 @@ /** | ||
*/ | ||
export function isProductionHostname(hostname) { | ||
function isProductionHostname(hostname) { | ||
return !(hostname === 'localhost' | ||
@@ -13,2 +15,3 @@ || /getgooddata\.com$/.test(hostname) | ||
} | ||
exports.isProductionHostname = isProductionHostname; | ||
//# sourceMappingURL=env.js.map |
@@ -0,3 +1,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// (C) 2007-2018 GoodData Corporation | ||
export function loadScript(url) { | ||
function loadScript(url) { | ||
if (scriptExists(url)) { | ||
@@ -11,3 +13,4 @@ return Promise.resolve(); | ||
} | ||
export function createScriptTag(url, onLoad, onError) { | ||
exports.loadScript = loadScript; | ||
function createScriptTag(url, onLoad, onError) { | ||
var script = document.createElement('script'); | ||
@@ -22,6 +25,8 @@ script.charset = 'utf-8'; | ||
} | ||
export function scriptExists(url) { | ||
exports.createScriptTag = createScriptTag; | ||
function scriptExists(url) { | ||
var script = url && document.querySelector('script[src=\'" + url + "\']'); | ||
return Boolean(script); | ||
} | ||
exports.scriptExists = scriptExists; | ||
//# sourceMappingURL=load-script.js.map |
@@ -0,3 +1,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// (C) 2007-2018 GoodData Corporation | ||
import { get } from 'lodash'; | ||
var lodash_1 = require("lodash"); | ||
var host; | ||
@@ -12,6 +14,6 @@ try { | ||
// enable unit testing | ||
export var setHost = function (h) { | ||
exports.setHost = function (h) { | ||
host = h; | ||
}; | ||
export var postEvent = function (product, name, data) { | ||
exports.postEvent = function (product, name, data) { | ||
if (!host.postMessage) { | ||
@@ -33,12 +35,13 @@ return; | ||
var receiveListener = function (listener) { return function (event) { | ||
return (get(event, 'data.gdc.product') === config.product && | ||
return (lodash_1.get(event, 'data.gdc.product') === config.product && | ||
// check for valid incoming command | ||
config.validReceivedPostEvents.includes(get(event, 'data.gdc.event.name')) | ||
config.validReceivedPostEvents.includes(lodash_1.get(event, 'data.gdc.event.name')) | ||
? listener(event) | ||
: false); | ||
}; }; | ||
export function setConfig(product, validReceivedPostEvents) { | ||
function setConfig(product, validReceivedPostEvents) { | ||
config = { product: product, validReceivedPostEvents: validReceivedPostEvents }; | ||
} | ||
export function addListener(listener, target) { | ||
exports.setConfig = setConfig; | ||
function addListener(listener, target) { | ||
if (target === void 0) { target = window; } | ||
@@ -49,3 +52,4 @@ var receiver = receiveListener(listener); | ||
} | ||
export function removeListener(listener, target) { | ||
exports.addListener = addListener; | ||
function removeListener(listener, target) { | ||
if (target === void 0) { target = window; } | ||
@@ -58,2 +62,3 @@ var receiverObj = receivers.find(function (r) { return r.listener === listener; }); | ||
} | ||
exports.removeListener = removeListener; | ||
//# sourceMappingURL=post-events.js.map |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
@@ -6,3 +8,3 @@ * @param {String} value string to be shortened | ||
*/ | ||
export function shortenText(value, options) { | ||
function shortenText(value, options) { | ||
if (options === void 0) { options = {}; } | ||
@@ -15,2 +17,3 @@ var maxLength = options.maxLength; | ||
} | ||
exports.shortenText = shortenText; | ||
/** | ||
@@ -21,5 +24,6 @@ * Escapes special characters used in regular expressions. | ||
*/ | ||
export function escapeRegExp(value) { | ||
function escapeRegExp(value) { | ||
return value.replace(/([.*+?^${}()|\[\]\/\\])/g, '\\$1'); | ||
} | ||
exports.escapeRegExp = escapeRegExp; | ||
/** | ||
@@ -30,3 +34,3 @@ * Generates pseudo-random string. | ||
*/ | ||
export function randomString(len) { | ||
function randomString(len) { | ||
var text = ''; | ||
@@ -39,2 +43,3 @@ var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; | ||
} | ||
exports.randomString = randomString; | ||
/** | ||
@@ -45,6 +50,7 @@ * Replaces non-alphanumerical characters with underscore. | ||
*/ | ||
export function simplifyText(value) { | ||
function simplifyText(value) { | ||
var s = value && value.toString ? value.toString() : ''; | ||
return s.replace(/[^a-zA-Z0-9]/g, '_').toLowerCase(); | ||
} | ||
exports.simplifyText = simplifyText; | ||
/** | ||
@@ -56,3 +62,3 @@ * Parse string in a form of [foo, bar] to an array of objects. | ||
*/ | ||
export function parseStringToArray(str) { | ||
function parseStringToArray(str) { | ||
if (str) { | ||
@@ -70,2 +76,3 @@ if (str.match(/^\[]$/)) { | ||
} | ||
exports.parseStringToArray = parseStringToArray; | ||
//# sourceMappingURL=string.js.map |
@@ -0,3 +1,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// (C) 2007-2018 GoodData Corporation | ||
export function delay(timeout) { | ||
function delay(timeout) { | ||
if (timeout === void 0) { timeout = 0; } | ||
@@ -10,2 +12,3 @@ return new Promise(function (resolve) { | ||
} | ||
exports.delay = delay; | ||
//# sourceMappingURL=testUtils.js.map |
@@ -0,3 +1,5 @@ | ||
"use strict"; | ||
// (C) 2007-2018 GoodData Corporation | ||
export function removeMetadata(translationsWithMetadata) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function removeMetadata(translationsWithMetadata) { | ||
var translations = {}; | ||
@@ -11,2 +13,3 @@ Object.keys(translationsWithMetadata).forEach(function (key) { | ||
} | ||
exports.removeMetadata = removeMetadata; | ||
//# sourceMappingURL=translations.js.map |
@@ -0,11 +1,13 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// (C) 2007-2018 GoodData Corporation | ||
import { loadScript } from './load-script'; | ||
export var DEVELOPMENT_SNIPPET = 'https://gd-trial-manager-dev.herokuapp.com/assets/scripts/trial.js'; | ||
export var PRODUCTION_SNIPPET = 'https://gd-trial-manager-prod.herokuapp.com/assets/scripts/trial.js'; | ||
var load_script_1 = require("./load-script"); | ||
exports.DEVELOPMENT_SNIPPET = 'https://gd-trial-manager-dev.herokuapp.com/assets/scripts/trial.js'; | ||
exports.PRODUCTION_SNIPPET = 'https://gd-trial-manager-prod.herokuapp.com/assets/scripts/trial.js'; | ||
function generateFinalUrl(environment) { | ||
if (environment === 'dev') { | ||
return DEVELOPMENT_SNIPPET; | ||
return exports.DEVELOPMENT_SNIPPET; | ||
} | ||
else if (environment === 'prod') { | ||
return PRODUCTION_SNIPPET; | ||
return exports.PRODUCTION_SNIPPET; | ||
} | ||
@@ -16,3 +18,3 @@ else { | ||
} | ||
export function load(environment) { | ||
function load(environment) { | ||
if (!environment) { | ||
@@ -25,3 +27,3 @@ return Promise.resolve(); | ||
} | ||
return loadScript(url) // load trial snippet script | ||
return load_script_1.loadScript(url) // load trial snippet script | ||
.catch(function () { | ||
@@ -32,2 +34,3 @@ // tslint:disable-next-line:no-console | ||
} | ||
exports.load = load; | ||
//# sourceMappingURL=trialSnippet.js.map |
@@ -0,5 +1,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// (C) 2007-2018 GoodData Corporation | ||
import { isProductionHostname } from './env'; | ||
import { loadScript } from './load-script'; | ||
export var GDC_WALKME_HASH = '325ea4b9b547463c991a62bf54090302'; | ||
var env_1 = require("./env"); | ||
var load_script_1 = require("./load-script"); | ||
exports.GDC_WALKME_HASH = '325ea4b9b547463c991a62bf54090302'; | ||
var GDC_WALKME_URL = 'https://cdn.walkme.com/users'; | ||
@@ -10,3 +12,3 @@ function getEnvironment(walkmeHashFromWhiteLabel, environment) { | ||
} | ||
else if (walkmeHashFromWhiteLabel === GDC_WALKME_HASH && !isProductionHostname(window.location.hostname)) { | ||
else if (walkmeHashFromWhiteLabel === exports.GDC_WALKME_HASH && !env_1.isProductionHostname(window.location.hostname)) { | ||
return 'test'; | ||
@@ -16,3 +18,3 @@ } | ||
} | ||
export function generateFinalUrl(walkmeHashFromWhiteLabel, environment) { | ||
function generateFinalUrl(walkmeHashFromWhiteLabel, environment) { | ||
var env = getEnvironment(walkmeHashFromWhiteLabel, environment); | ||
@@ -27,3 +29,4 @@ return [ | ||
} | ||
export function load(walkmeHash, walkMeEnvironment) { | ||
exports.generateFinalUrl = generateFinalUrl; | ||
function load(walkmeHash, walkMeEnvironment) { | ||
if (!walkmeHash) { | ||
@@ -34,3 +37,3 @@ return Promise.resolve(); | ||
window._walkmeConfig = { smartLoad: true }; | ||
return loadScript(url) // load walkme script | ||
return load_script_1.loadScript(url) // load walkme script | ||
.catch(function () { | ||
@@ -41,2 +44,3 @@ // tslint:disable-next-line:no-console | ||
} | ||
exports.load = load; | ||
//# sourceMappingURL=walkme.js.map |
{ | ||
"name": "@gooddata/js-utils", | ||
"version": "3.4.0-tomsatgd-cleanup-2019-08-27T12-51-12-639Z", | ||
"version": "3.4.0-tomsatgd-cleanup-2019-08-28T11-11-49-031Z", | ||
"description": "Various utils shared on GoodData frontend", | ||
@@ -37,9 +37,10 @@ "repository": { | ||
"devDependencies": { | ||
"@gooddata/tslint-config": "0.0.13", | ||
"@gooddata/tslint-config": "^1.0.0", | ||
"@types/jest": "22.2.3", | ||
"@types/js-cookie": "2.1.0", | ||
"@types/lodash": "^4.14.138", | ||
"jest": "22.4.3", | ||
"jest-junit": "3.0.0", | ||
"ts-jest": "22.4.5", | ||
"typescript": "2.8.3" | ||
"ts-jest": "^24.0.1", | ||
"typescript": "^3.3.4000" | ||
}, | ||
@@ -46,0 +47,0 @@ "dependencies": { |
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
55924
1114
8