Comparing version 0.3.0 to 0.4.0
@@ -1,2 +0,61 @@ | ||
var e,n,r=["startTour","advanceTour","cancelTour","identify","anonymous","on","off","openLauncher","closeLauncher"];module.exports=function(o){if("string"!=typeof o||""===o)throw new Error("Invalid HelpHero App ID: "+o);if(null!=e&&e!==o)throw new Error('HelpHero does not support initializing multiple Apps on the same page. Trying to initialize with App ID "'+e+'" which is different from previously used App ID "'+o+'"');if(null!=n)return n;var t=window,i=[],p=function(){i.push(arguments)};p.q=i,t.HelpHero=p;var l=document.createElement("script");return l.src="//app.helphero.co/embed/"+o,l.async=!0,document.body.appendChild(l),e=o,n=Object.create(null),r.forEach(function(e){n[e]=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return t.HelpHero.apply(null,[e].concat(n))}}),n}; | ||
//# sourceMappingURL=helphero.js.map | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global.helphero = factory()); | ||
}(this, (function () { 'use strict'; | ||
var initializedAppId; | ||
var instance; | ||
var methods = [ | ||
"startTour", | ||
"advanceTour", | ||
"cancelTour", | ||
"identify", | ||
"anonymous", | ||
"on", | ||
"off", | ||
"openLauncher", | ||
"closeLauncher" | ||
]; | ||
function initHelpHero(appId) { | ||
if (typeof appId !== "string" || appId === "") { | ||
throw new Error("Invalid HelpHero App ID: " + appId); | ||
} | ||
if (initializedAppId != null && initializedAppId !== appId) { | ||
throw new Error("HelpHero does not support initializing multiple Apps on the same page. Trying to initialize with App ID \"" + initializedAppId + "\" which is different from previously used App ID \"" + appId + "\""); | ||
} | ||
if (instance != null) { | ||
return instance; | ||
} | ||
// @ts-ignore | ||
var _window = window; | ||
// create temporary buffer | ||
var queue = []; | ||
var buffer = function () { | ||
queue.push(arguments); | ||
}; | ||
buffer.q = queue; | ||
_window.HelpHero = buffer; | ||
// add script to page | ||
var script = document.createElement("script"); | ||
script.src = "//app.helphero.co/embed/" + appId; | ||
script.async = true; | ||
document.body.appendChild(script); | ||
// return API wrapper | ||
initializedAppId = appId; | ||
instance = Object.create(null); | ||
methods.forEach(function (method) { | ||
instance[method] = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
return _window.HelpHero.apply(null, [method].concat(args)); | ||
}; | ||
}); | ||
return instance; | ||
} | ||
return initHelpHero; | ||
}))); |
{ | ||
"name": "helphero", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Offical HelpHero SDK for browsers", | ||
@@ -13,11 +13,10 @@ "repository": "git://github.com/HelpHero/helphero-javascript.git", | ||
"main": "dist/helphero.js", | ||
"umd:main": "dist/helphero.umd.js", | ||
"module": "dist/helphero.mjs", | ||
"types": "dist/helphero.d.ts", | ||
"scripts": { | ||
"build": "microbundle --entry src/helphero.ts", | ||
"clean": "del .rpt2_cache dist", | ||
"build": "rollup -c", | ||
"flowgen": "flowgen dist/helphero.d.ts -o dist/helphero.flow.js", | ||
"prettier-fix": "prettier --write 'src/**/*.ts'", | ||
"prettier-check": "prettier-check 'src/**/*.ts'", | ||
"dev": "yarn build watch", | ||
"prepare": "yarn prettier-check && yarn build" | ||
"prepare": "yarn prettier-check && yarn clean && yarn build && yarn flowgen" | ||
}, | ||
@@ -29,7 +28,10 @@ "files": [ | ||
"devDependencies": { | ||
"microbundle": "git://github.com/developit/microbundle.git#3d4d09f", | ||
"del-cli": "^1.1.0", | ||
"flowgen": "^1.2.3", | ||
"prettier": "^1.14.2", | ||
"prettier-check": "^2.0.0", | ||
"rollup": "^0.65.2", | ||
"rollup-plugin-typescript2": "^0.17.0", | ||
"typescript": "^3.0.3" | ||
} | ||
} |
143
7297
7
6