From b83d042a1cb6597803c3dfaf1a918c6fea4e255f Mon Sep 17 00:00:00 2001 From: Christoph Burgmer Date: Wed, 30 Oct 2013 19:02:33 +0100 Subject: [PATCH] Bump version --- bower.json | 2 +- dist/rasterizeHTML.allinone.js | 2 +- dist/rasterizeHTML.js | 2 +- dist/rasterizeHTML.min.js | 2 +- package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index 6fd8d640..66b2e8ac 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "rasterizeHTML.js", - "version": "0.4.1", + "version": "0.5.0", "main": [ "./dist/rasterizeHTML.js", "./dist/rasterizeHTML.allinone.js" diff --git a/dist/rasterizeHTML.allinone.js b/dist/rasterizeHTML.allinone.js index 73a28720..fccab693 100644 --- a/dist/rasterizeHTML.allinone.js +++ b/dist/rasterizeHTML.allinone.js @@ -1,4 +1,4 @@ -/*! rasterizeHTML.js - v0.4.1 - 2013-10-29 +/*! rasterizeHTML.js - v0.5.0 - 2013-10-30 * http://www.github.com/cburgmer/rasterizeHTML.js * Copyright (c) 2013 Christoph Burgmer; /* Integrated dependencies: diff --git a/dist/rasterizeHTML.js b/dist/rasterizeHTML.js index b2c54e5d..70f6cf1d 100644 --- a/dist/rasterizeHTML.js +++ b/dist/rasterizeHTML.js @@ -1,4 +1,4 @@ -/*! rasterizeHTML.js - v0.4.1 - 2013-10-29 +/*! rasterizeHTML.js - v0.5.0 - 2013-10-30 * http://www.github.com/cburgmer/rasterizeHTML.js * Copyright (c) 2013 Christoph Burgmer; Licensed MIT */ window.rasterizeHTMLInline = (function (module) { diff --git a/dist/rasterizeHTML.min.js b/dist/rasterizeHTML.min.js index 495ee200..ecc7a2af 100644 --- a/dist/rasterizeHTML.min.js +++ b/dist/rasterizeHTML.min.js @@ -1,4 +1,4 @@ -/*! rasterizeHTML.js - v0.4.1 - 2013-10-29 +/*! rasterizeHTML.js - v0.5.0 - 2013-10-30 * http://www.github.com/cburgmer/rasterizeHTML.js * Copyright (c) 2013 Christoph Burgmer; Licensed MIT */ window.rasterizeHTMLInline=function(a){"use strict";var b=function(b,c,d,e){var f=b.attributes.src?b.attributes.src.nodeValue:null,g=a.util.getDocumentBaseUrl(b.ownerDocument),h=a.util.clone(c);return null===f||a.util.isDataUri(f)?(d(),void 0):(!h.baseUrl&&g&&(h.baseUrl=g),a.util.getDataURIForImageURL(f,h,function(a){b.attributes.src.nodeValue=a,d()},function(){e(a.util.joinUrl(h.baseUrl,f))}),void 0)},c=function(a){var b=[];return Array.prototype.forEach.call(a,function(a){"image"===a.type&&b.push(a)}),b};a.loadAndInlineImages=function(d,e,f){var g=a.util.parseOptionalParameters(e,f),h=d.getElementsByTagName("img"),i=d.getElementsByTagName("input"),j=[],k=[];j=Array.prototype.slice.call(h),j=j.concat(c(i)),a.util.map(j,function(a,c){b(a,g.options,c,function(a){k.push({resourceType:"image",url:a,msg:"Unable to load image "+a}),c()})},function(){g.callback&&g.callback(k)})};var d=function(b){return a.util.joinUrl(b,".")},e=function(a,b,c){var e=d(b);if("object"!=typeof a)throw new Error("cacheBucket is not an object");return a.inlineCssCache=a.inlineCssCache||{},a.inlineCssCache[e]=a.inlineCssCache[e]||{},a.inlineCssCache[e][c]},f=function(a,b,c,e){var f=d(b);a.inlineCssCache=a.inlineCssCache||{},a.inlineCssCache[f]=a.inlineCssCache[f]||{},a.inlineCssCache[f][c]=e},g=function(b,c,d,e){var f=a.css.rulesForCssText(b);a.css.loadCSSImportsForRules(f,d,c,function(d,g){a.css.loadAndInlineCSSResourcesForRules(f,c,function(c,h){var i=g.concat(h),j=d||c;j&&(b=a.css.cssRulesToText(f)),e(j,b,i)})})},h=function(b,c,d,h){var i,j=b.textContent;return l(c)&&(i=e(c.cacheBucket,c.baseUrl,j))?(i.hasChanges&&(b.childNodes[0].nodeValue=i.content),h(i.errors),void 0):(g(j,c,d,function(d,e,g){d&&(b.childNodes[0].nodeValue=e),l(c)&&f(c.cacheBucket,c.baseUrl,j,{content:e,hasChanges:d,errors:a.util.cloneArray(g)}),h(g)}),void 0)},i=function(a){return Array.prototype.slice.call(a)},j=function(a){var b=i(a.getElementsByTagName("style")),c=[];return b.forEach(function(a){a.attributes.type&&"text/css"!==a.attributes.type.nodeValue||c.push(a)}),c};a.loadAndInlineStyles=function(b,c,d){var e,f=a.util.parseOptionalParameters(c,d),g=j(b),i=[],k=[];e=a.util.clone(f.options),e.baseUrl=e.baseUrl||a.util.getDocumentBaseUrl(b),a.util.map(g,function(a,b){h(a,e,k,function(a){i=i.concat(a),b()})},function(){f.callback(i)})};var k=function(a,b){var c,d=a.parentNode;b=b.trim(),b&&(c=a.ownerDocument.createElement("style"),c.type="text/css",c.appendChild(a.ownerDocument.createTextNode(b)),d.insertBefore(c,a)),d.removeChild(a)},l=function(a){return a.cache!==!1&&"none"!==a.cache&&a.cacheBucket},m=function(b,c,d){var e=a.util.joinUrl(c,d);if("object"!=typeof b)throw new Error("cacheBucket is not an object");return b.linkedCssCache=b.linkedCssCache||{},b.linkedCssCache[e]},n=function(b,c,d,e){var f=a.util.joinUrl(c,d);b.linkedCssCache=b.linkedCssCache||{},b.linkedCssCache[f]=e},o=function(b,c,d,e){a.util.ajax(b,c,function(e){var f,g=a.css.rulesForCssText(e);f=a.css.adjustPathsOfCssResources(b,g),a.css.loadCSSImportsForRules(g,[],c,function(b,h){a.css.loadAndInlineCSSResourcesForRules(g,c,function(c,i){var j=h.concat(i);(f||b||c)&&(e=a.css.cssRulesToText(g)),d(e,j)})})},e)},p=function(b,c,d,e){var f,g=b.attributes.href.nodeValue,h=a.util.getDocumentBaseUrl(b.ownerDocument),i=a.util.clone(c);return!i.baseUrl&&h&&(i.baseUrl=h),l(c)&&(f=m(c.cacheBucket,i.baseUrl,g))?(d(f.content,f.errors),void 0):(o(g,i,function(b,e){l(c)&&n(c.cacheBucket,i.baseUrl,g,{content:b,errors:a.util.cloneArray(e)}),d(b,e)},function(){e(a.util.joinUrl(i.baseUrl,g))}),void 0)};a.loadAndInlineCssLinks=function(b,c,d){var e=a.util.parseOptionalParameters(c,d),f=b.getElementsByTagName("link"),g=[];a.util.map(f,function(a,b){!a.attributes.rel||"stylesheet"!==a.attributes.rel.nodeValue||a.attributes.type&&"text/css"!==a.attributes.type.nodeValue?b():p(a,e.options,function(c,d){k(a,c+"\n"),g=g.concat(d),b()},function(a){g.push({resourceType:"stylesheet",url:a,msg:"Unable to load stylesheet "+a}),b()})},function(){e.callback&&e.callback(g)})};var q=function(b,c,d,e){var f=b.attributes.src.nodeValue,g=a.util.getDocumentBaseUrl(b.ownerDocument),h=a.util.clone(c);!h.baseUrl&&g&&(h.baseUrl=g),a.util.ajax(f,h,d,function(){e(a.util.joinUrl(h.baseUrl,f))})},r=function(a,b){var c=a.ownerDocument.createElement("script"),d=a.parentNode;a.attributes.type&&(c.type=a.attributes.type.nodeValue),c.appendChild(a.ownerDocument.createTextNode(b)),d.insertBefore(c,a),d.removeChild(a)};return a.loadAndInlineScript=function(b,c,d){var e=a.util.parseOptionalParameters(c,d),f=b.getElementsByTagName("script"),g=[];a.util.map(f,function(a,b){a.attributes.src?q(a,e.options,function(c){r(a,c),b()},function(a){g.push({resourceType:"script",url:a,msg:"Unable to load script "+a}),b()}):b()},function(){e.callback&&e.callback(g)})},a.inlineReferences=function(b,c,d){var e=[];a.loadAndInlineImages(b,c,function(f){e=e.concat(f),a.loadAndInlineStyles(b,c,function(f){e=e.concat(f),a.loadAndInlineCssLinks(b,c,function(f){e=e.concat(f),c.inlineScripts===!1?d(e):a.loadAndInlineScript(b,c,function(a){e=e.concat(a),d(e)})})})})},a}(window.rasterizeHTMLInline||{}),window.rasterizeHTMLInline=function(a,b,c){"use strict";a.css={};var d=function(a){return Array.prototype.slice.call(a)},e=function(a){var b,c=document.implementation.createHTMLDocument(""),e=document.createElement("style");return e.textContent=a,c.body.appendChild(e),b=e.sheet.cssRules,d(b)},f=function(){var a=e("a{background:url(i)}");return!a.length||a[0].cssText.indexOf("url()")>=0}();a.css.rulesForCssText=function(a){return f&&c.parse?c.parse(a).cssRules:e(a)};var g=function(a){var c=[];return a.forEach(function(a){a.type===b.CSSRule.STYLE_RULE&&(a.style.getPropertyValue("background-image")||a.style.getPropertyValue("background"))&&c.push(a)}),c},h=function(a){var c=[];return a.forEach(function(a){a.type===b.CSSRule.FONT_FACE_RULE&&a.style.getPropertyValue("src")&&c.push(a)}),c};a.css.cssRulesToText=function(a){var b="";return a.forEach(function(a){b+=a.cssText}),b};var i=function(a){var b=/^"(.*)"$/,c=/^'(.*)'$/;return b.test(a)?a.replace(b,"$1"):c.test(a)?a.replace(c,"$1"):a},j=function(a){var b=/^[\t\r\f\n ]*(.+?)[\t\r\f\n ]*$/;return a.replace(b,"$1")};a.css.extractCssUrl=function(a){var b,c=/^url\(([^\)]+)\)/;if(!c.test(a))throw new Error("Invalid url");return b=c.exec(a)[1],i(j(b))};var k=function(a){var b,c=/^format\(([^\)]+)\)/;return c.test(a)?(b=c.exec(a)[1],i(b)):null},l=function(b){var c,d=null;try{return c=a.css.extractCssUrl(b[0]),b[1]&&(d=k(b[1])),{url:c,format:d}}catch(e){}},m=function(a,b,c){var d=a.indexOf(b),e="@font-face { font-family: "+b.style.getPropertyValue("font-family")+"; src: "+c+"}",f=b.parentStyleSheet;f.insertRule(e,d+1),f.deleteRule(d),a[d]=f.cssRules[d]};a.css.adjustPathsOfCssResources=function(b,c){var d,e=!1;return g(c).forEach(function(c){var f=c.style.getPropertyValue("background-image")||c.style.getPropertyValue("background"),g=r(f),h=!1;g.forEach(function(c){var d,e=s(c);e&&!a.util.isDataUri(e.url)&&(d=a.util.joinUrl(b,e.url),c[e.idx]='url("'+d+'")',h=!0)}),d=t(g),c.style.getPropertyValue("background-image")?c.style.setProperty("background-image",d):c.style.setProperty("background",d),e=e||h}),h(c).forEach(function(d){var f=w(d.style.getPropertyValue("src")),g=!1;f.forEach(function(c){var d,e=l(c);e&&!a.util.isDataUri(e.url)&&(d=a.util.joinUrl(b,e.url),c[0]='url("'+d+'")',g=!0)}),g&&m(c,d,x(f)),e=e||g}),e};var n=function(a){var c=[];return a.forEach(function(a){a.type===b.CSSRule.IMPORT_RULE&&a.href&&c.push(a)}),c},o=function(a,b,c){var d=a.indexOf(b);a.splice(d,1),c.forEach(function(b,c){a.splice(d+c,0,b)})},p=function(a){var b=/^"(.*)"$/,c=/^'(.*)'$/;return b.test(a)||c.test(a)},q=function(b,c,d,e,f,g){var h,j=c.href;return p(j)&&(j=i(j)),h=a.util.joinUrl(e.baseUrl,j),d.indexOf(h)>=0?(o(b,c,[]),f([]),void 0):(d.push(h),a.util.ajax(j,e,function(g){var h=a.css.rulesForCssText(g);a.css.loadCSSImportsForRules(h,d,e,function(d,e){a.css.adjustPathsOfCssResources(j,h),o(b,c,h),f(e)})},function(){g(h)}),void 0)};a.css.loadCSSImportsForRules=function(b,c,d,e){var f,g=[];f=n(b),a.util.map(f,function(a,e){q(b,a,c,d,function(a){g=g.concat(a),e(!0)},function(a){g.push({resourceType:"stylesheet",url:a,msg:"Unable to load stylesheet "+a}),e(!1)})},function(a){var b=a.indexOf(!0)>=0;e(b,g)})};var r=function(a){var b,c="\\s*(?:\"[^\"]*\"|'[^']*'|[^\\(]+)\\s*",d="(url\\("+c+"\\)"+"|"+"[^,\\s]+"+")",e="(?:\\s*"+d+")+",f="^\\s*("+e+")"+"(?:\\s*,\\s*("+e+"))*"+"\\s*$",g=new RegExp(e,"g"),h=[],i=function(a){var b,c=new RegExp(d,"g"),e=[];for(b=c.exec(a);b;)e.push(b[1]),b=c.exec(a);return e};if(a.match(new RegExp(f))){for(b=g.exec(a);b;)h.push(i(b[0])),b=g.exec(a);return h}return[]},s=function(b){var c,d;for(c=0;c=0;c&&(f=t(e),b.style.getPropertyValue("background-image")?b.style.setProperty("background-image",f):b.style.setProperty("background",f)),d(c,g)})},v=function(b,c,d){var e,f=g(b),h=[];a.util.map(f,function(a,b){u(a,c,function(a,c){c.forEach(function(a){h.push({resourceType:"backgroundImage",url:a,msg:"Unable to load background-image "+a})}),b(a)})},function(a){e=a.indexOf(!0)>=0,d(e,h)})},w=function(a){var b,c="\\s*(?:\"[^\"]*\"|'[^']*'|[^\\(]+)\\s*",d="(local\\("+c+"\\))"+"|"+"(url\\("+c+"\\))"+"(?:\\s+(format\\("+c+"\\)))?",e="^\\s*("+d+")"+"(?:\\s*,\\s*("+d+"))*"+"\\s*$",f=new RegExp(d,"g"),g=[],h=function(a){var b=[];return a.slice(1).forEach(function(a){a&&b.push(a)}),b};if(a.match(new RegExp(e))){for(b=f.exec(a);b;)g.push(h(b)),b=f.exec(a);return g}return[]},x=function(a){var b=[];return a.forEach(function(a){b.push(a.join(" "))}),b.join(", ")},y=function(b,c,d,e){var f,g,h,i,j=[];f=w(c.style.getPropertyValue("src")),a.util.map(f,function(b,c){return g=l(b),!g||a.util.isDataUri(g.url)?(c(!1),void 0):(h=g.format||"woff",a.util.binaryAjax(g.url,d,function(a){i=btoa(a),b[0]='url("data:font/'+h+";base64,"+i+'")',c(!0)},function(){j.push(a.util.joinUrl(d.baseUrl,g.url)),c(!1)}),void 0)},function(a){var d=a.indexOf(!0)>=0;d&&m(b,c,x(f)),e(d,j)})},z=function(b,c,d){var e,f=h(b),g=[];a.util.map(f,function(a,d){y(b,a,c,function(a,b){b.forEach(function(a){g.push({resourceType:"fontFace",url:a,msg:"Unable to load font-face "+a})}),d(a)})},function(a){e=a.indexOf(!0)>=0,d(e,g)})};return a.css.loadAndInlineCSSResourcesForRules=function(a,b,c){v(a,b,function(d,e){z(a,b,function(a,b){var f=d||a;c(f,e.concat(b))})})},a}(window.rasterizeHTMLInline||{},window,window.CSSOM||{}),window.rasterizeHTMLInline=function(a,b,c){"use strict";a.util={},a.util.getDocumentBaseUrl=function(a){return"about:blank"!==a.baseURI?a.baseURI:null},a.util.clone=function(a){var b,c={};for(b in a)a.hasOwnProperty(b)&&(c[b]=a[b]);return c},a.util.cloneArray=function(a){return Array.prototype.slice.apply(a,[0])},a.util.joinUrl=function(a,b){var d=new c(b);return a&&d.is("relative")&&(d=d.absoluteTo(a)),d.toString()},a.util.isDataUri=function(a){return/^data:/.test(a)},a.util.map=function(b,c,d){var e,f=0,g=a.util.cloneArray(b),h=[];0===g.length&&d(h);var i=function(a){function b(b){f+=1,h[a]=b,f===g.length&&d(h)}c(g[a],b)};for(e=0;ewindow.onerror = "+j(h)+";",k=function(){var a=f.contentDocument;c.document.getElementsByTagName("body")[0].removeChild(f),e(a,l(h))};f.onload=b>0?function(){setTimeout(k,b)}:k,f.contentDocument.open(),f.contentDocument.write(""+i+g+""),f.contentDocument.close()};var m=function(){return c.navigator.userAgent.indexOf("WebKit")>=0},n=function(a){var e;return a.documentElement.setAttribute("xmlns",a.documentElement.namespaceURI),e=(new c.XMLSerializer).serializeToString(a.documentElement),m()?b?b(e):(d.util.log("Looks like your browser needs html2xhtml.js as workaround for writing XML. Please include it."),e):e},o=function(){if(c.navigator.userAgent.indexOf("WebKit")>=0&&c.navigator.userAgent.indexOf("Chrome")<0)return!1;if(c.BlobBuilder||c.MozBlobBuilder||c.WebKitBlobBuilder)return!0;if(c.Blob)try{return new c.Blob([""],{type:"text/xml"}),!0}catch(a){return!1}return!1},p=function(a){var b,d="image/svg+xml;charset=utf-8",e=c.BlobBuilder||c.MozBlobBuilder||c.WebKitBlobBuilder;return e?(b=new e,b.append(a),b.getBlob(d)):new c.Blob([a],{type:d})},q=function(a){var b=c.URL||c.webkitURL||window;return o()?b.createObjectURL(p(a)):"data:image/svg+xml;charset=utf-8,"+encodeURIComponent(a)},r=function(a){var b=c.URL||c.webkitURL||window;o()&&b.revokeObjectURL(a)},s=function(a,b){var c=a.createElement(b);return c.style.visibility="hidden",c.style.width="0px",c.style.height="0px",c.style.position="absolute",c.style.top="-10000px",c.style.left="-10000px",a.getElementsByTagName("body")[0].appendChild(c),c},t=function(a,b){var c=a.getElementById(b);return c||(c=s(a,"div"),c.id=b),c},u="rasterizeHTML_js_FirefoxWorkaround",v=function(){var a=c.navigator.userAgent.match(/Firefox\/(\d+).0/);return!a||!a[1]||parseInt(a[1],10)<17},w=function(a,b){var e,f=d.util.getConstantUniqueIdFor(a),g=b?b.ownerDocument:c.document;v()&&(e=t(g,u+f),e.innerHTML=a,e.className=u)},x=function(a){window.navigator.userAgent.indexOf("WebKit")>=0&&Array.prototype.forEach.call(a.getElementsByTagName("style"),function(a){a.textContent="span {}\n"+a.textContent})},y=function(a,b){var e=d.util.getConstantUniqueIdFor(a),f=b?b.ownerDocument:c.document,g=f.getElementById(u+e);g&&g.parentNode.removeChild(g)};d.getSvgForDocument=function(a,b,c){var d;return x(a),d=n(a),''+''+d+""+""},d.renderSvg=function(a,b,d,e){var f,g,h=function(){g.onload=null,g.onerror=null},i=function(){f&&r(f),y(a,b)};w(a,b),f=q(a),g=new c.Image,g.onload=function(){h(),i(),d(g)},g.onerror=function(){i(),e()},g.src=f},d.drawImageOnCanvas=function(a,b){try{b.getContext("2d").drawImage(a,0,0)}catch(c){return!1}return!0};var z=function(a,b,c,e,f,g){var h,i=d.getSvgForDocument(a,b,c),j=function(a){a.push({resourceType:"document",msg:"Error rendering page"})};d.renderSvg(i,e,function(a){e&&(h=d.drawImageOnCanvas(a,e),h||(j(g),a=null)),f&&f(a,g)},function(){j(g),f&&f(null,g)})};return d.drawDocument=function(b,c,e,f){var g,h=d.util.parseOptionalParameters(c,e,f),i=h.canvas?h.canvas.width:300,j=h.canvas?h.canvas.height:200,k=void 0!==h.options.width?h.options.width:i,l=void 0!==h.options.height?h.options.height:j,m=h.options.executeJsTimeout||0;g=a.util.clone(h.options),g.inlineScripts=h.options.executeJs===!0,a.inlineReferences(b,g,function(a){h.options.executeJs?d.util.executeJavascript(b,m,function(b,c){z(b,k,l,h.canvas,h.callback,a.concat(c))}):z(b,k,l,h.canvas,h.callback,a)})},d.drawHTML=function(a,b,e,f){var g=d.util.parseOptionalParameters(b,e,f),h=c.document.implementation.createHTMLDocument("");h.documentElement.innerHTML=a,d.drawDocument(h,g.canvas,g.options,g.callback)},d.drawURL=function(b,c,e,f){var g,h=d.util.parseOptionalParameters(c,e,f);g=a.util.clone(h.options),g.baseUrl=b,a.util.ajax(b,h.options,function(a){d.drawHTML(a,h.canvas,g,h.callback)},function(){h.callback&&h.callback(null,[{resourceType:"page",url:b,msg:"Unable to load page "+b}])})},d}(window.rasterizeHTMLInline,window.html2xhtml||window.HTMLtoXML,window); \ No newline at end of file diff --git a/package.json b/package.json index 79548e18..1746daab 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "rasterizeHTML.js", "title": "rasterizeHTML.js", - "version": "0.4.1", + "version": "0.5.0", "description": "Renders HTML into the browser's canvas.", "keywords": [ "canvas",