Comparing version 3.2.3 to 3.2.4
@@ -1,597 +0,1 @@ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(); | ||
else if(typeof define === 'function' && define.amd) | ||
define([], factory); | ||
else if(typeof exports === 'object') | ||
exports["logdown"] = factory(); | ||
else | ||
root["logdown"] = factory(); | ||
})(this, function() { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var Logdown = __webpack_require__(1)() | ||
var markdown = __webpack_require__(3) | ||
var isColorSupported = __webpack_require__(5) | ||
var globalObject = __webpack_require__(8)() | ||
// | ||
// Static | ||
// | ||
// Tomorrow Night Eighties colors | ||
// https://github.com/chriskempson/tomorrow-theme#tomorrow-night-eighties | ||
Logdown.prefixColors = [ | ||
'#F2777A', | ||
'#F99157', | ||
'#FFCC66', | ||
'#99CC99', | ||
'#66CCCC', | ||
'#6699CC', | ||
'#CC99CC' | ||
] | ||
Logdown._setPrefixRegExps = function () { | ||
try { | ||
if ( | ||
globalObject.localStorage && | ||
typeof globalObject.localStorage.getItem('debug') === 'string' | ||
) { | ||
Logdown._prefixRegExps = [] | ||
globalObject.localStorage | ||
.getItem('debug') | ||
.split(',') | ||
.forEach(function (str) { | ||
str = str.trim() | ||
var type = 'enable' | ||
if (str[0] === '-') { | ||
str = str.substr(1) | ||
type = 'disable' | ||
} | ||
var regExp = Logdown._prepareRegExpForPrefixSearch(str) | ||
Logdown._prefixRegExps.push({ | ||
type: type, | ||
regExp: regExp | ||
}) | ||
}) | ||
} | ||
} catch (error) {} | ||
} | ||
Logdown._getNextPrefixColor = (function () { | ||
var lastUsed = 0 | ||
return function () { | ||
lastUsed += 1 | ||
return Logdown.prefixColors[lastUsed % Logdown.prefixColors.length] | ||
} | ||
})() | ||
// | ||
// Instance | ||
// | ||
Logdown.prototype._getDecoratedPrefix = function () { | ||
var decoratedPrefix = [] | ||
if (isColorSupported()) { | ||
decoratedPrefix.push('%c' + this.opts.prefix + '%c ') | ||
decoratedPrefix.push( | ||
'color:' + this.opts.prefixColor + '; font-weight:bold;', | ||
'' // Empty string resets style. | ||
) | ||
} else { | ||
decoratedPrefix.push('[' + this.opts.prefix + '] ') | ||
} | ||
return decoratedPrefix | ||
} | ||
Logdown.prototype._prepareOutput = function (args) { | ||
var preparedOutput = this._getDecoratedPrefix() | ||
var parsedMarkdown | ||
// Only first argument on `console` can have style. | ||
if (typeof args[0] === 'string') { | ||
if (this.opts.markdown && isColorSupported()) { | ||
parsedMarkdown = markdown.parse(args[0]) | ||
preparedOutput[0] = preparedOutput[0] + parsedMarkdown.text | ||
preparedOutput = preparedOutput.concat(parsedMarkdown.styles) | ||
} else { | ||
preparedOutput[0] = preparedOutput[0] + args[0] | ||
} | ||
} else { | ||
preparedOutput.push(args[0]) | ||
} | ||
if (args.length > 1) { | ||
preparedOutput = preparedOutput.concat(args.slice(1)) | ||
} | ||
return preparedOutput | ||
} | ||
// | ||
// API | ||
// | ||
Logdown._setPrefixRegExps() | ||
module.exports = Logdown | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var toArray = __webpack_require__(2) | ||
module.exports = function () { | ||
function Logdown (prefix, opts) { | ||
if (!(this instanceof Logdown)) { | ||
return new Logdown(prefix, opts) | ||
} | ||
if (Logdown._isPrefixAlreadyInUse(prefix)) { | ||
return Logdown._getInstanceByPrefix(prefix) | ||
} | ||
this.opts = Logdown._normalizeOpts(prefix, opts) | ||
this.state = Logdown._getInitialState(this.opts) | ||
Logdown._decorateLoggerMethods(this) | ||
Logdown._instances.push(this) | ||
return this | ||
} | ||
// | ||
// Static | ||
// | ||
Logdown.transports = [] | ||
Logdown._instances = [] | ||
Logdown._prefixRegExps = [] | ||
Logdown._prepareRegExpForPrefixSearch = function (str) { | ||
return new RegExp('^' + str.replace(/\*/g, '.*?') + '$') | ||
} | ||
Logdown._isPrefixAlreadyInUse = function (prefix) { | ||
return Logdown._instances.some(function (instance) { | ||
return (instance.opts.prefix === prefix) | ||
}) | ||
} | ||
Logdown._getInstanceByPrefix = function (prefix) { | ||
return Logdown._instances.filter(function (instanceCur) { | ||
return instanceCur.opts.prefix === prefix | ||
})[0] | ||
} | ||
Logdown._normalizeOpts = function (prefix, opts) { | ||
if (typeof prefix !== 'string') { | ||
throw new TypeError('prefix must be a string') | ||
} | ||
opts = opts || {} | ||
var markdown = opts.markdown === undefined ? true : Boolean(opts.markdown) | ||
var prefixColor = opts.prefixColor || Logdown._getNextPrefixColor() | ||
var logger = opts.logger || console | ||
return { | ||
logger: logger, | ||
markdown: markdown, | ||
prefix: prefix, | ||
prefixColor: prefixColor | ||
} | ||
} | ||
Logdown._getInitialState = function (opts) { | ||
return { | ||
isEnabled: Logdown._getEnableState(opts) | ||
} | ||
} | ||
Logdown._getEnableState = function (opts) { | ||
var isEnabled = false | ||
Logdown._prefixRegExps.forEach(function (filter) { | ||
if ( | ||
filter.type === 'enable' && | ||
filter.regExp.test(opts.prefix) | ||
) { | ||
isEnabled = true | ||
} else if ( | ||
filter.type === 'disable' && | ||
filter.regExp.test(opts.prefix) | ||
) { | ||
isEnabled = false | ||
} | ||
}) | ||
return isEnabled | ||
} | ||
Logdown._decorateLoggerMethods = function (instance) { | ||
var logger = instance.opts.logger | ||
var loggerMethods = Object | ||
.keys(logger) | ||
.filter(function (method) { return typeof logger[method] === 'function' }) | ||
// In old Safari and Chrome browsers, `console` methods are not iterable. | ||
// In that case, we provide a minimum API. | ||
if (loggerMethods.length === 0) { | ||
loggerMethods = ['log', 'warn', 'error'] | ||
} | ||
loggerMethods | ||
.forEach(function (method) { | ||
instance[method] = function () { | ||
var args = toArray(arguments) | ||
var instance = this.opts.prefix | ||
if (Logdown.transports.length) { | ||
var msg = '[' + instance + '] ' + | ||
args | ||
.filter(function (arg) { return typeof arg !== 'object' }) | ||
.join(' ') | ||
Logdown.transports.forEach(function (transport) { | ||
transport({ | ||
state: this.state, | ||
instance: instance, | ||
level: method, | ||
args: args, | ||
msg: msg | ||
}) | ||
}.bind(this)) | ||
} | ||
if (this.state.isEnabled) { | ||
var preparedOutput = this._prepareOutput(args, method) | ||
logger[method].apply(logger, preparedOutput) | ||
} | ||
} | ||
}) | ||
} | ||
return Logdown | ||
} | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports) { | ||
module.exports = function toArray (arg) { | ||
return Array.prototype.slice.call(arg, 0) | ||
} | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var Markdown = __webpack_require__(4) | ||
var styles = [] | ||
function createStyledRenderer (style) { | ||
return function (input) { | ||
styles.push(style) | ||
styles.push('') // Empty string resets style. | ||
return '%c' + input + '%c' | ||
} | ||
} | ||
var markdown = new Markdown({ | ||
renderer: { | ||
'*': createStyledRenderer('font-weight:bold;'), | ||
'_': createStyledRenderer('font-style:italic;'), | ||
'`': createStyledRenderer( | ||
'background-color:rgba(255,204,102, 0.1);' + | ||
'color:#FFCC66;' + | ||
'padding:2px 5px;' + | ||
'border-radius:2px;' | ||
) | ||
} | ||
}) | ||
function parse (text) { | ||
var result = { | ||
text: markdown.parse(text), | ||
styles: [].concat(styles) | ||
} | ||
styles.length = 0 | ||
return result | ||
} | ||
module.exports = { | ||
parse: parse | ||
} | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (function(module, exports) { | ||
var lexemeRe = /([_*`\\]|[^_*`\\]+)/g | ||
var mdTagRe = /[_*`]/ | ||
function Markdown (options) { | ||
this.renderer = options.renderer | ||
} | ||
function isMdTag (lexeme) { | ||
return mdTagRe.test(lexeme) | ||
} | ||
Markdown.prototype.parse = function (text) { | ||
var lexemes = text.match(lexemeRe) | ||
var render = this.renderer | ||
var formattedText = '' | ||
var currentScope | ||
var scopesStack = [] | ||
var activeScopes = {} | ||
var buffer | ||
var lexeme | ||
var cursor = 0 | ||
function drainTillLexeme (lexeme) { | ||
var buffer = '' | ||
while (currentScope && currentScope.tag !== lexeme) { | ||
buffer = currentScope.tag + currentScope.text + buffer | ||
activeScopes[currentScope.tag] = false | ||
currentScope = scopesStack.pop() | ||
} | ||
return buffer | ||
} | ||
while (lexeme = lexemes[cursor]) { // eslint-disable-line | ||
buffer = '' | ||
cursor++ | ||
if (isMdTag(lexeme)) { | ||
if (activeScopes[lexeme]) { | ||
// we've found matching closing tag | ||
// if we have some other unclosed tags in-between - treat them as a plain text | ||
buffer = drainTillLexeme(lexeme) | ||
// now currentScope holds the scope for the tag (`lexeme`) we are trying to close | ||
buffer = render[currentScope.tag](currentScope.text + buffer) | ||
activeScopes[lexeme] = false | ||
currentScope = scopesStack.pop() | ||
} else { | ||
var initialText = '' | ||
if (lexeme === '`') { | ||
// `code` according to spec has the highest priority | ||
// and does not allow nesting | ||
// looking if we can find the closing delimiter | ||
// NOTE: we have already incremented cursor, so we do not need to add 1 | ||
var newCursor = lexemes.indexOf(lexeme, cursor) | ||
if (newCursor !== -1) { | ||
formattedText += drainTillLexeme() // if we already have activeScopes, treat them as plain text | ||
initialText = lexemes.slice(cursor, newCursor).join('') | ||
cursor = newCursor // set cursor to the closing backticks | ||
} | ||
} | ||
if (currentScope) { | ||
scopesStack.push(currentScope) | ||
} | ||
activeScopes[lexeme] = true | ||
currentScope = { | ||
tag: lexeme, | ||
text: initialText | ||
} | ||
} | ||
} else { | ||
buffer = lexeme | ||
if (lexeme === '\\') { // process escaping | ||
var nextLexeme = lexemes[cursor] | ||
if (isMdTag(nextLexeme) || nextLexeme === '\\') { | ||
// ignore next md tag, because it is escaped | ||
buffer = nextLexeme | ||
cursor++ | ||
} | ||
} | ||
} | ||
if (buffer) { | ||
if (currentScope) { | ||
currentScope.text += buffer | ||
} else { | ||
formattedText += buffer | ||
} | ||
buffer = '' | ||
} | ||
} | ||
// get the rest of the unclosed tags | ||
formattedText += drainTillLexeme() | ||
return formattedText | ||
} | ||
module.exports = Markdown | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isWebkit = __webpack_require__(6) | ||
var isFirefox = __webpack_require__(7) | ||
module.exports = function isColorSupported () { | ||
return (isWebkit() || isFirefox()) | ||
} | ||
/***/ }), | ||
/* 6 */ | ||
/***/ (function(module, exports) { | ||
// Is webkit? http://stackoverflow.com/a/16459606/376773 | ||
module.exports = function isWebkit () { | ||
try { | ||
return ('WebkitAppearance' in document.documentElement.style) && !/Edge/.test(navigator.userAgent) | ||
} catch (error) { | ||
return false | ||
} | ||
} | ||
/***/ }), | ||
/* 7 */ | ||
/***/ (function(module, exports) { | ||
module.exports = function isFirefox () { | ||
try { | ||
return /firefox\/(\d+)/i.test(navigator.userAgent) | ||
} catch (error) { | ||
return false | ||
} | ||
} | ||
/***/ }), | ||
/* 8 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/* WEBPACK VAR INJECTION */(function(global) {/* eslint-disable no-new-func */ | ||
/* global self, global */ | ||
function getGlobal (slf, glb) { | ||
// Return the global object based on the environment presently in. | ||
// window for browser and global for node. | ||
// Ref from -> https://github.com/purposeindustries/window-or-global/blob/master/lib/index.js | ||
return ( | ||
(typeof slf === 'object' && slf.self === slf && slf) || | ||
(typeof glb === 'object' && glb.global === glb && glb) || | ||
this | ||
) | ||
} | ||
module.exports = getGlobal.bind(this, self, global) | ||
module.exports.getGlobal = getGlobal | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9))) | ||
/***/ }), | ||
/* 9 */ | ||
/***/ (function(module, exports) { | ||
var g; | ||
// This works in non-strict mode | ||
g = (function() { | ||
return this; | ||
})(); | ||
try { | ||
// This works if eval is allowed (see CSP) | ||
g = g || Function("return this")() || (1,eval)("this"); | ||
} catch(e) { | ||
// This works if the window reference is available | ||
if(typeof window === "object") | ||
g = window; | ||
} | ||
// g can still be undefined, but nothing to do about it... | ||
// We return undefined, instead of nothing here, so it's | ||
// easier to handle this case. if(!global) { ...} | ||
module.exports = g; | ||
/***/ }) | ||
/******/ ]); | ||
}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.logdown=e():t.logdown=e()}(window,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){var n=r(1)(),o=r(3),i=r(5),s=r(8)();n.prefixColors=["#F2777A","#F99157","#FFCC66","#99CC99","#66CCCC","#6699CC","#CC99CC"],n._setPrefixRegExps=function(){try{s.localStorage&&"string"==typeof s.localStorage.getItem("debug")&&(n._prefixRegExps=[],s.localStorage.getItem("debug").split(",").forEach(function(t){var e="enable";"-"===(t=t.trim())[0]&&(t=t.substr(1),e="disable");var r=n._prepareRegExpForPrefixSearch(t);n._prefixRegExps.push({type:e,regExp:r})}))}catch(t){}},n._getNextPrefixColor=function(){var t=0;return function(){return t+=1,n.prefixColors[t%n.prefixColors.length]}}(),n.prototype._getDecoratedPrefix=function(){var t=[];return i()?(t.push("%c"+this.opts.prefix+"%c "),t.push("color:"+this.opts.prefixColor+"; font-weight:bold;","")):t.push("["+this.opts.prefix+"] "),t},n.prototype._prepareOutput=function(t){var e,r=this._getDecoratedPrefix();return"string"==typeof t[0]?this.opts.markdown&&i()?(e=o.parse(t[0]),r[0]=r[0]+e.text,r=r.concat(e.styles)):r[0]=r[0]+t[0]:r.push(t[0]),t.length>1&&(r=r.concat(t.slice(1))),r},n._setPrefixRegExps(),t.exports=n},function(t,e,r){var n=r(2);t.exports=function(){function t(e,r){return this instanceof t?t._isPrefixAlreadyInUse(e)?t._getInstanceByPrefix(e):(this.opts=t._normalizeOpts(e,r),this.state=t._getInitialState(this.opts),t._decorateLoggerMethods(this),t._instances.push(this),this):new t(e,r)}return t.transports=[],t._instances=[],t._prefixRegExps=[],t._prepareRegExpForPrefixSearch=function(t){return new RegExp("^"+t.replace(/\*/g,".*?")+"$")},t._isPrefixAlreadyInUse=function(e){return t._instances.some(function(t){return t.opts.prefix===e})},t._getInstanceByPrefix=function(e){return t._instances.filter(function(t){return t.opts.prefix===e})[0]},t._normalizeOpts=function(e,r){if("string"!=typeof e)throw new TypeError("prefix must be a string");var n=void 0===(r=r||{}).markdown||Boolean(r.markdown),o=r.prefixColor||t._getNextPrefixColor();return{logger:r.logger||console,markdown:n,prefix:e,prefixColor:o}},t._getInitialState=function(e){return{isEnabled:t._getEnableState(e)}},t._getEnableState=function(e){var r=!1;return t._prefixRegExps.forEach(function(t){"enable"===t.type&&t.regExp.test(e.prefix)?r=!0:"disable"===t.type&&t.regExp.test(e.prefix)&&(r=!1)}),r},t._decorateLoggerMethods=function(e){var r=e.opts.logger,o=Object.keys(r).filter(function(t){return"function"==typeof r[t]});0===o.length&&(o=["log","warn","error"]),o.forEach(function(o){e[o]=function(){var e=n(arguments),i=this.opts.prefix;if(t.transports.length){var s="["+i+"] "+e.filter(function(t){return"object"!=typeof t}).join(" ");t.transports.forEach(function(t){t({state:this.state,instance:i,level:o,args:e,msg:s})}.bind(this))}if(this.state.isEnabled){var f=this._prepareOutput(e,o);r[o].apply(r,f)}}})},t}},function(t,e){t.exports=function(t){return Array.prototype.slice.call(t,0)}},function(t,e,r){var n=[];function o(t){return function(e){return n.push(t),n.push(""),"%c"+e+"%c"}}var i=new(r(4))({renderer:{"*":o("font-weight:bold;"),_:o("font-style:italic;"),"`":o("background-color:rgba(255,204,102, 0.1);color:#FFCC66;padding:2px 5px;border-radius:2px;")}});t.exports={parse:function(t){var e={text:i.parse(t),styles:[].concat(n)};return n.length=0,e}}},function(t,e){var r=/([_*`\\]|[^_*`\\]+)/g,n=/[_*`]/;function o(t){this.renderer=t.renderer}function i(t){return n.test(t)}o.prototype.parse=function(t){var e,n,o,s=t.match(r),f=this.renderer,u="",a=[],p={},c=0;function l(t){for(var r="";e&&e.tag!==t;)r=e.tag+e.text+r,p[e.tag]=!1,e=a.pop();return r}for(;o=s[c];){if(n="",c++,i(o))if(p[o])n=l(o),n=f[e.tag](e.text+n),p[o]=!1,e=a.pop();else{var g="";if("`"===o){var x=s.indexOf(o,c);-1!==x&&(u+=l(),g=s.slice(c,x).join(""),c=x)}e&&a.push(e),p[o]=!0,e={tag:o,text:g}}else if(n=o,"\\"===o){var d=s[c];(i(d)||"\\"===d)&&(n=d,c++)}n&&(e?e.text+=n:u+=n,n="")}return u+=l()},t.exports=o},function(t,e,r){var n=r(6),o=r(7);t.exports=function(){return n()||o()}},function(t,e){t.exports=function(){try{return"WebkitAppearance"in document.documentElement.style&&!/Edge/.test(navigator.userAgent)}catch(t){return!1}}},function(t,e){t.exports=function(){try{return/firefox\/(\d+)/i.test(navigator.userAgent)}catch(t){return!1}}},function(t,e,r){(function(e){function r(t,e){return"object"==typeof t&&t.self===t&&t||"object"==typeof e&&e.global===e&&e||this}t.exports=r.bind(this,self,e),t.exports.getGlobal=r}).call(this,r(9))},function(t,e){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(r=window)}t.exports=r}])}); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.logdown=e():t.logdown=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,r){var n=r(1)(),o=r(3),i=r(5),s=r(8)();n.prefixColors=["#F2777A","#F99157","#FFCC66","#99CC99","#66CCCC","#6699CC","#CC99CC"],n._setPrefixRegExps=function(){try{s.localStorage&&"string"==typeof s.localStorage.getItem("debug")&&(n._prefixRegExps=[],s.localStorage.getItem("debug").split(",").forEach(function(t){var e="enable";"-"===(t=t.trim())[0]&&(t=t.substr(1),e="disable");var r=n._prepareRegExpForPrefixSearch(t);n._prefixRegExps.push({type:e,regExp:r})}))}catch(t){}},n._getNextPrefixColor=function(){var t=0;return function(){return t+=1,n.prefixColors[t%n.prefixColors.length]}}(),n.prototype._getDecoratedPrefix=function(){var t=[];return i()?(t.push("%c"+this.opts.prefix+"%c "),t.push("color:"+this.opts.prefixColor+"; font-weight:bold;","")):t.push("["+this.opts.prefix+"] "),t},n.prototype._prepareOutput=function(t){var e,r=this._getDecoratedPrefix();return"string"==typeof t[0]?this.opts.markdown&&i()?(e=o.parse(t[0]),r[0]=r[0]+e.text,r=r.concat(e.styles)):r[0]=r[0]+t[0]:r.push(t[0]),t.length>1&&(r=r.concat(t.slice(1))),r},n._setPrefixRegExps(),t.exports=n},function(t,e,r){var n=r(2);t.exports=function(){function t(e,r){return this instanceof t?t._isPrefixAlreadyInUse(e)?t._getInstanceByPrefix(e):(this.opts=t._normalizeOpts(e,r),this.state=t._getInitialState(this.opts),t._decorateLoggerMethods(this),t._instances.push(this),this):new t(e,r)}return t.transports=[],t._instances=[],t._prefixRegExps=[],t._prepareRegExpForPrefixSearch=function(t){return new RegExp("^"+t.replace(/\*/g,".*?")+"$")},t._isPrefixAlreadyInUse=function(e){return t._instances.some(function(t){return t.opts.prefix===e})},t._getInstanceByPrefix=function(e){return t._instances.filter(function(t){return t.opts.prefix===e})[0]},t._normalizeOpts=function(e,r){if("string"!=typeof e)throw new TypeError("prefix must be a string");var n=void 0===(r=r||{}).markdown||Boolean(r.markdown),o=r.prefixColor||t._getNextPrefixColor();return{logger:r.logger||console,markdown:n,prefix:e,prefixColor:o}},t._getInitialState=function(e){return{isEnabled:t._getEnableState(e)}},t._getEnableState=function(e){var r=!1;return t._prefixRegExps.forEach(function(t){"enable"===t.type&&t.regExp.test(e.prefix)?r=!0:"disable"===t.type&&t.regExp.test(e.prefix)&&(r=!1)}),r},t._decorateLoggerMethods=function(e){var r=e.opts.logger,o=Object.keys(r).filter(function(t){return"function"==typeof r[t]});0===o.length&&(o=["log","warn","error"]),o.forEach(function(o){e[o]=function(){var e=n(arguments),i=this.opts.prefix;if(t.transports.length){var s="["+i+"] "+e.filter(function(t){return"object"!=typeof t}).join(" ");t.transports.forEach(function(t){t({state:this.state,instance:i,level:o,args:e,msg:s})}.bind(this))}if(this.state.isEnabled){var f=this._prepareOutput(e,o);r[o].apply(r,f)}}})},t}},function(t,e){t.exports=function(t){return Array.prototype.slice.call(t,0)}},function(t,e,r){function n(t){return function(e){return o.push(t),o.push(""),"%c"+e+"%c"}}var o=[],i=new(r(4))({renderer:{"*":n("font-weight:bold;"),_:n("font-style:italic;"),"`":n("background-color:rgba(255,204,102, 0.1);color:#FFCC66;padding:2px 5px;border-radius:2px;")}});t.exports={parse:function(t){var e={text:i.parse(t),styles:[].concat(o)};return o.length=0,e}}},function(t,e){function r(t){this.renderer=t.renderer}function n(t){return i.test(t)}var o=/([_*`\\]|[^_*`\\]+)/g,i=/[_*`]/;r.prototype.parse=function(t){function e(t){for(var e="";r&&r.tag!==t;)e=r.tag+r.text+e,u[r.tag]=!1,r=c.pop();return e}for(var r,i,s,f=t.match(o),p=this.renderer,a="",c=[],u={},l=0;s=f[l];){if(i="",l++,n(s))if(u[s])i=e(s),i=p[r.tag](r.text+i),u[s]=!1,r=c.pop();else{var x="";if("`"===s){var g=f.indexOf(s,l);-1!==g&&(a+=e(),x=f.slice(l,g).join(""),l=g)}r&&c.push(r),u[s]=!0,r={tag:s,text:x}}else if(i=s,"\\"===s){var h=f[l];(n(h)||"\\"===h)&&(i=h,l++)}i&&(r?r.text+=i:a+=i,i="")}return a+=e()},t.exports=r},function(t,e,r){var n=r(6),o=r(7);t.exports=function(){return n()||o()}},function(t,e){t.exports=function(){try{return"WebkitAppearance"in document.documentElement.style&&!/Edge/.test(navigator.userAgent)}catch(t){return!1}}},function(t,e){t.exports=function(){try{return/firefox\/(\d+)/i.test(navigator.userAgent)}catch(t){return!1}}},function(t,e,r){(function(e){function r(t,e){return"object"==typeof t&&t.self===t&&t||"object"==typeof e&&e.global===e&&e||this}t.exports=r.bind(this,self,e),t.exports.getGlobal=r}).call(e,r(9))},function(t,e){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(r=window)}t.exports=r}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.logdown=e():t.logdown=e()}(window,function(){return function(r){var n={};function o(t){if(n[t])return n[t].exports;var e=n[t]={i:t,l:!1,exports:{}};return r[t].call(e.exports,e,e.exports,o),e.l=!0,e.exports}return o.m=r,o.c=n,o.d=function(t,e,r){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(r,n,function(t){return e[t]}.bind(null,n));return r},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=0)}([function(t,e,r){var n,o=r(1)(),i=r(3),s=r(5),f=r(8)();o.prefixColors=["#F2777A","#F99157","#FFCC66","#99CC99","#66CCCC","#6699CC","#CC99CC"],o._setPrefixRegExps=function(){try{f.localStorage&&"string"==typeof f.localStorage.getItem("debug")&&(o._prefixRegExps=[],f.localStorage.getItem("debug").split(",").forEach(function(t){var e="enable";"-"===(t=t.trim())[0]&&(t=t.substr(1),e="disable");var r=o._prepareRegExpForPrefixSearch(t);o._prefixRegExps.push({type:e,regExp:r})}))}catch(t){}},o._getNextPrefixColor=(n=0,function(){return n+=1,o.prefixColors[n%o.prefixColors.length]}),o.prototype._getDecoratedPrefix=function(){var t=[];return s()?(t.push("%c"+this.opts.prefix+"%c "),t.push("color:"+this.opts.prefixColor+"; font-weight:bold;","")):t.push("["+this.opts.prefix+"] "),t},o.prototype._prepareOutput=function(t){var e,r=this._getDecoratedPrefix();return"string"==typeof t[0]?this.opts.markdown&&s()?(e=i.parse(t[0]),r[0]=r[0]+e.text,r=r.concat(e.styles)):r[0]=r[0]+t[0]:r.push(t[0]),1<t.length&&(r=r.concat(t.slice(1))),r},o._setPrefixRegExps(),t.exports=o},function(t,e,r){var f=r(2);t.exports=function(){function s(t,e){return this instanceof s?s._isPrefixAlreadyInUse(t)?s._getInstanceByPrefix(t):(this.opts=s._normalizeOpts(t,e),this.state=s._getInitialState(this.opts),s._decorateLoggerMethods(this),s._instances.push(this),this):new s(t,e)}return s.transports=[],s._instances=[],s._prefixRegExps=[],s._prepareRegExpForPrefixSearch=function(t){return new RegExp("^"+t.replace(/\*/g,".*?")+"$")},s._isPrefixAlreadyInUse=function(e){return s._instances.some(function(t){return t.opts.prefix===e})},s._getInstanceByPrefix=function(e){return s._instances.filter(function(t){return t.opts.prefix===e})[0]},s._normalizeOpts=function(t,e){if("string"!=typeof t)throw new TypeError("prefix must be a string");var r=void 0===(e=e||{}).markdown||Boolean(e.markdown),n=e.prefixColor||s._getNextPrefixColor();return{logger:e.logger||console,markdown:r,prefix:t,prefixColor:n}},s._getInitialState=function(t){return{isEnabled:s._getEnableState(t)}},s._getEnableState=function(e){var r=!1;return s._prefixRegExps.forEach(function(t){"enable"===t.type&&t.regExp.test(e.prefix)?r=!0:"disable"===t.type&&t.regExp.test(e.prefix)&&(r=!1)}),r},s._decorateLoggerMethods=function(t){var i=t.opts.logger,e=Object.keys(i).filter(function(t){return"function"==typeof i[t]});0===e.length&&(e=["log","warn","error"]),e.forEach(function(o){t[o]=function(){var e=f(arguments),r=this.opts.prefix;if(s.transports.length){var n="["+r+"] "+e.filter(function(t){return"object"!=typeof t}).join(" ");s.transports.forEach(function(t){t({state:this.state,instance:r,level:o,args:e,msg:n})}.bind(this))}if(this.state.isEnabled){var t=this._prepareOutput(e,o);i[o].apply(i,t)}}})},s}},function(t,e){t.exports=function(t){return Array.prototype.slice.call(t,0)}},function(t,e,r){var n=[];function o(e){return function(t){return n.push(e),n.push(""),"%c"+t+"%c"}}var i=new(r(4))({renderer:{"*":o("font-weight:bold;"),_:o("font-style:italic;"),"`":o("background-color:rgba(255,204,102, 0.1);color:#FFCC66;padding:2px 5px;border-radius:2px;")}});t.exports={parse:function(t){var e={text:i.parse(t),styles:[].concat(n)};return n.length=0,e}}},function(t,e){var x=/([_*`\\]|[^_*`\\]+)/g,r=/[_*`]/;function n(t){this.renderer=t.renderer}function d(t){return r.test(t)}n.prototype.parse=function(t){var r,e,n,o=t.match(x),i=this.renderer,s="",f=[],u={},a=0;function p(t){for(var e="";r&&r.tag!==t;)e=r.tag+r.text+e,u[r.tag]=!1,r=f.pop();return e}for(;n=o[a];){if(e="",a++,d(n))if(u[n])e=p(n),e=i[r.tag](r.text+e),u[n]=!1,r=f.pop();else{var c="";if("`"===n){var l=o.indexOf(n,a);-1!==l&&(s+=p(),c=o.slice(a,l).join(""),a=l)}r&&f.push(r),u[n]=!0,r={tag:n,text:c}}else if("\\"===(e=n)){var g=o[a];(d(g)||"\\"===g)&&(e=g,a++)}e&&(r?r.text+=e:s+=e,e="")}return s+p()},t.exports=n},function(t,e,r){var n=r(6),o=r(7);t.exports=function(){return n()||o()}},function(t,e){t.exports=function(){try{return"WebkitAppearance"in document.documentElement.style&&!/Edge/.test(navigator.userAgent)}catch(t){return!1}}},function(t,e){t.exports=function(){try{return/firefox\/(\d+)/i.test(navigator.userAgent)}catch(t){return!1}}},function(r,t,e){(function(t){function e(t,e){return"object"==typeof t&&t.self===t&&t||"object"==typeof e&&e.global===e&&e||this}r.exports=e.bind(this,self,t),r.exports.getGlobal=e}).call(this,e(9))},function(ob,pb){var qb;qb=function(){return this}();try{qb=qb||Function("return this")()||eval("this")}catch(ob){"object"==typeof window&&(qb=window)}ob.exports=qb}])}); |
{ | ||
"name": "logdown", | ||
"version": "3.2.3", | ||
"version": "3.2.4", | ||
"description": "Debug utility with markdown support that runs on browser and server", | ||
@@ -13,3 +13,3 @@ "main": "src/node.js", | ||
"scripts": { | ||
"build": "webpack && cp dist/logdown.js example/lib/logdown.js && uglifyjs --compress --mangle --screw-ie8 -- dist/logdown.js > dist/logdown.min.js && gzip dist/logdown.min.js --stdout --best > dist/logdown.min.js.gzip", | ||
"build": "webpack && cpx dist/logdown.js example/lib && uglifyjs --compress --mangle --screw-ie8 -- dist/logdown.js > dist/logdown.min.js && gzip dist/logdown.min.js --stdout --best > dist/logdown.min.js.gzip", | ||
"preversion": "npm run test", | ||
@@ -45,6 +45,8 @@ "test": "jest && npm run test:lint", | ||
"codecov": "^3.0.0", | ||
"jest": "^21.2.1", | ||
"cpx": "^1.5.0", | ||
"jest": "^23.0.1", | ||
"standard": "^10.0.3", | ||
"uglify-js": "3.3.7", | ||
"webpack": "3.10.0" | ||
"uglify-js": "3.4.3", | ||
"webpack": "4.16.2", | ||
"webpack-cli": "^3.1.0" | ||
}, | ||
@@ -51,0 +53,0 @@ "jest": { |
<img src="http://rawgit.com/caiogondim/logdown.js/master/img/icon.svg"> | ||
<h1 align="center">logdown.js</h1> | ||
<h1>logdown.js</h1> | ||
<div align="center"> | ||
<div> | ||
<a href="https://travis-ci.org/caiogondim/logdown.js?branch=master"><img src="http://travis-ci.org/caiogondim/logdown.js.svg?branch=master" alt="Travis CI" /></a> | ||
@@ -63,2 +63,10 @@ <img src="http://img.badgesize.io/caiogondim/logdown.js/master/dist/logdown.min.js?compression=gzip" alt="Lib Size" /> | ||
The corresponding command for browsers is: | ||
```js | ||
window.localStorage.debug = 'foo'; | ||
``` | ||
Multiple comma-separated logger names and wildcards can be specified as well. | ||
### Logging | ||
@@ -154,3 +162,3 @@ | ||
const errorOutput = fs.createWriteStream('./stderr.log'); | ||
const fileLogger = new Console(output, errorOutput) | ||
const fileLogger = new console.Console(output, errorOutput) | ||
@@ -280,2 +288,6 @@ const logger = logdown('foo', { | ||
## Plugins | ||
- [redux-logdown](https://github.com/caiogondim/redux-logdown.js/) | ||
- [logdown-cast](https://github.com/caiogondim/logdown-cast.js/) | ||
## FAQ | ||
@@ -282,0 +294,0 @@ |
@@ -11,3 +11,3 @@ /* eslint-env jest */ | ||
process.env = {} | ||
process.platform = 'jest' | ||
Object.defineProperty(process, 'platform', { value: 'jest' }) | ||
delete process.stdout | ||
@@ -19,3 +19,3 @@ }) | ||
process.stdout = origStdout | ||
process.platform = origPlatform | ||
Object.defineProperty(process, 'platform', { value: origPlatform }) | ||
}) | ||
@@ -41,3 +41,3 @@ | ||
it('should allow colors for win32', () => { | ||
process.platform = 'win32' | ||
Object.defineProperty(process, 'platform', { value: 'win32' }) | ||
expect(isColorSupported()).toBe(true) | ||
@@ -44,0 +44,0 @@ }) |
Sorry, the diff of this file is not supported yet
37
309
84800
8
1499