Comparing version 6.2.0 to 6.2.1
@@ -15,5 +15,3 @@ var utils = require('./utils'); | ||
function AnsiSerializer(theme) { | ||
this.theme = theme; | ||
} | ||
function AnsiSerializer() {} | ||
@@ -97,3 +95,3 @@ AnsiSerializer.prototype = new TextSerializer(); | ||
AnsiSerializer.prototype.text = function (options) { | ||
AnsiSerializer.prototype.text = function (options, themes) { | ||
var content = String(options.content); | ||
@@ -104,3 +102,3 @@ if (content === '') { | ||
var styles = themeMapper(this.theme, options.styles); | ||
var styles = themeMapper(themes.ansi || {}, options.styles); | ||
@@ -107,0 +105,0 @@ if (styles.length > 0) { |
@@ -6,5 +6,3 @@ var cssStyles = require('./cssStyles'); | ||
function ColoredConsoleSerializer(theme) { | ||
this.theme = theme; | ||
} | ||
function ColoredConsoleSerializer() {} | ||
@@ -42,3 +40,3 @@ ColoredConsoleSerializer.prototype.format = 'coloredConsole'; | ||
if (this[outputEntry.style]) { | ||
result.push(this[outputEntry.style](outputEntry.args)); | ||
result.push(this[outputEntry.style](outputEntry.args, outputEntry.themes)); | ||
} | ||
@@ -53,3 +51,3 @@ }, this); | ||
ColoredConsoleSerializer.prototype.text = function (options) { | ||
ColoredConsoleSerializer.prototype.text = function (options, themes) { | ||
var content = String(options.content); | ||
@@ -60,3 +58,3 @@ if (content === '') { | ||
var styles = themeMapper(this.theme, options.styles); | ||
var styles = themeMapper(themes.coloredConsole || {}, options.styles); | ||
@@ -63,0 +61,0 @@ var result = ['%c' + content.replace(/%/g, '%%')]; |
var utils = require('./utils'); | ||
var duplicateText = require('./duplicateText'); | ||
function createPadding(length) { | ||
return { style: 'text', args: { content: duplicateText(' ', length), styles: [] } }; | ||
function createPadding(length, themes) { | ||
return { | ||
style: 'text', | ||
args: { | ||
content: duplicateText(' ', length), | ||
styles: [] | ||
}, | ||
themes: themes | ||
}; | ||
} | ||
@@ -23,3 +30,3 @@ | ||
var args = { content: line, styles: outputEntry.args.styles }; | ||
return [{ style: 'text', args: args }]; | ||
return [{ style: 'text', args: args, themes: outputEntry.themes }]; | ||
}); | ||
@@ -63,3 +70,3 @@ case 'block': return flattenBlocksInLines(outputEntry.args); | ||
var paddingLength = startIndex - linesLengths[index]; | ||
resultLine.push(createPadding(paddingLength)); | ||
resultLine.push(createPadding(paddingLength, outputEntry.themes)); | ||
Array.prototype.push.apply(resultLine, blockLine); | ||
@@ -66,0 +73,0 @@ linesLengths[index] = startIndex + blockLinesLengths[index]; |
@@ -5,5 +5,3 @@ var cssStyles = require('./cssStyles'); | ||
function HtmlSerializer(theme) { | ||
this.theme = theme; | ||
} | ||
function HtmlSerializer() {} | ||
@@ -25,3 +23,3 @@ HtmlSerializer.prototype.format = 'html'; | ||
return this[outputEntry.style] ? | ||
this[outputEntry.style](outputEntry.args) : | ||
this[outputEntry.style](outputEntry.args, outputEntry.themes) : | ||
''; | ||
@@ -37,3 +35,3 @@ }, this); | ||
HtmlSerializer.prototype.text = function (options) { | ||
HtmlSerializer.prototype.text = function (options, themes) { | ||
var content = String(options.content); | ||
@@ -52,5 +50,4 @@ | ||
var styles = themeMapper(themes.html || {}, options.styles); | ||
var styles = themeMapper(this.theme, options.styles); | ||
if (styles.length > 0) { | ||
@@ -57,0 +54,0 @@ var styleProperties = []; |
@@ -47,3 +47,3 @@ /*global window*/ | ||
if (typeof exports === 'object' && typeof exports.nodeName !== 'string' && require('./supportsColor').stdout) { | ||
MagicPen.defaultFormat = 'ansi'; // colored console | ||
MagicPen.defaultFormat = 'ansi'; | ||
} else if (typeof window !== 'undefined' && typeof window.navigator !== 'undefined') { | ||
@@ -89,3 +89,3 @@ if (window._phantom || window.mochaPhantomJS || (window.__karma__ && window.__karma__.config.captureConsole)) { | ||
return utils.arrayEquals(a.args.styles, b.args.styles); | ||
return utils.arrayEquals(a.args.styles, b.args.styles) && a.themes === b.themes; | ||
} | ||
@@ -105,3 +105,2 @@ | ||
} | ||
if (hasSameTextStyling(lastEntry, entry)) { | ||
@@ -113,3 +112,4 @@ result[result.length - 1] = { | ||
styles: lastEntry.args.styles | ||
} | ||
}, | ||
themes: lastEntry.themes | ||
}; | ||
@@ -137,3 +137,4 @@ } else { | ||
styles: lastEntry.args.styles | ||
} | ||
}, | ||
themes: this._themes | ||
}; | ||
@@ -201,3 +202,3 @@ } else { | ||
var theme = this._themes[format] || {}; | ||
var serializer = new MagicPen.serializers[format](theme); | ||
var serializer = new MagicPen.serializers[format](); | ||
return serializer.serialize(this.output); | ||
@@ -224,3 +225,4 @@ }; | ||
style: 'text', | ||
args: { content: lineContent, styles: styles } | ||
args: { content: lineContent, styles: styles }, | ||
themes: this._themes | ||
}); | ||
@@ -236,3 +238,4 @@ } | ||
style: 'text', | ||
args: { content: content, styles: styles } | ||
args: { content: content, styles: styles }, | ||
themes: this._themes | ||
}); | ||
@@ -247,3 +250,3 @@ } | ||
return outputEntry.style === 'text' ? | ||
{ style: 'text', args: { content: outputEntry.args.content, styles: [] } } : | ||
{ style: 'text', args: { content: outputEntry.args.content, styles: [] }, themes: outputEntry.themes } : | ||
outputEntry; | ||
@@ -308,4 +311,5 @@ })); | ||
}); | ||
return this.write({ style: 'block', args: blockOutput }); | ||
return this.write({ style: 'block', args: blockOutput, themes: this._themes }); | ||
}; | ||
function isRawOutput(options) { | ||
@@ -324,3 +328,3 @@ return options && | ||
if (!format) { | ||
throw new Error('The alt method is only supported on pen where the format has already been set'); | ||
throw new Error('The alt method is only supported on a pen where the format has already been set'); | ||
} | ||
@@ -349,13 +353,17 @@ | ||
if (!format) { | ||
throw new Error('The alt method is only supported on pen where the format has already been set'); | ||
throw new Error('The raw method is only supported on a pen where the format has already been set'); | ||
} | ||
if (typeof options === 'string') { | ||
return this.write({ style: 'raw', args: { | ||
height: 0, | ||
width: 0, | ||
content: function () { | ||
return options; | ||
} | ||
}}); | ||
return this.write({ | ||
style: 'raw', | ||
args: { | ||
height: 0, | ||
width: 0, | ||
content: function () { | ||
return options; | ||
} | ||
}, | ||
themes: this._themes | ||
}); | ||
} | ||
@@ -372,3 +380,3 @@ | ||
return this.write({ style: 'raw', args: options }); | ||
return this.write({ style: 'raw', args: options, themes: this._themes }); | ||
} | ||
@@ -389,3 +397,4 @@ | ||
style: 'block', | ||
args: amend(lastEntry.args, pen) | ||
args: amend(lastEntry.args, pen), | ||
themes: pen._themes | ||
}; | ||
@@ -588,3 +597,4 @@ newOutput[output.length - 1] = lastLine; | ||
style: 'block', | ||
args: replaceText(output.clone(), outputEntry.args, regexp, cb) | ||
args: replaceText(output.clone(), outputEntry.args, regexp, cb), | ||
themes: outputEntry.themes | ||
}); | ||
@@ -591,0 +601,0 @@ } else if (outputEntry.style !== 'text') { |
@@ -15,3 +15,3 @@ var flattenBlocksInLines = require('./flattenBlocksInLines'); | ||
return this[outputEntry.style] ? | ||
String(this[outputEntry.style](outputEntry.args)) : | ||
String(this[outputEntry.style](outputEntry.args, outputEntry.themes)) : | ||
''; | ||
@@ -18,0 +18,0 @@ }, this).join(''); |
{ | ||
"name": "magicpen", | ||
"version": "6.2.0", | ||
"version": "6.2.1", | ||
"description": "Styled output in both consoles and browsers", | ||
@@ -5,0 +5,0 @@ "main": "./lib/MagicPen.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
515905
29
5210