1
0
This repository has been archived on 2023-11-30. You can view files and clone it, but cannot push or open issues or pull requests.
dtux__avion-poeme/dist/rasterizeHTML/rasterizeHTML.allinone.js

13 lines
64 KiB
JavaScript
Raw Permalink Normal View History

/*! rasterizeHTML.js - v1.0.0 - 2015-03-01
* http://www.github.com/cburgmer/rasterizeHTML.js
* Copyright (c) 2015 Christoph Burgmer; Licensed MIT */
/* Integrated dependencies:
* url (MIT License),
* CSSOM.js (MIT License),
* ayepromise (BSD License & WTFPL),
* xmlserializer (MIT License),
* css-font-face-src (BSD License),
* inlineresources (MIT License) */
!function(a){if("object"==typeof exports)module.exports=a();else if("function"==typeof define&&define.amd)define(a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.rasterizeHTML=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};a[g][0].call(j.exports,function(b){var c=a[g][1][b];return e(c?c:b)},j,j.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(b,c,d){!function(e,f){"function"==typeof a&&a.amd?a(["url","xmlserializer","ayepromise","inlineresources"],function(a,b,c,d){return e.rasterizeHTML=f(a,b,c,d)}):"object"==typeof d?c.exports=f(b("url"),b("xmlserializer"),b("ayepromise"),b("inlineresources")):e.rasterizeHTML=f(url,xmlserializer,ayepromise,inlineresources)}(this,function(a,b,c,d){var e=function(a){"use strict";var b={},c=[];b.joinUrl=function(b,c){return b?a.resolve(b,c):c},b.getConstantUniqueIdFor=function(a){return c.indexOf(a)<0&&c.push(a),c.indexOf(a)},b.clone=function(a){var b,c={};for(b in a)a.hasOwnProperty(b)&&(c[b]=a[b]);return c};var d=function(a){return"object"==typeof a&&null!==a},e=function(a){return d(a)&&Object.prototype.toString.apply(a).match(/\[object (Canvas|HTMLCanvasElement)\]/i)};return b.parseOptionalParameters=function(a){var c={canvas:null,options:{}};return null==a[0]||e(a[0])?(c.canvas=a[0]||null,c.options=b.clone(a[1])):c.options=b.clone(a[0]),c},b}(a),f=function(a,b){"use strict";var c={},d=function(a,b,c){var d=a[b];return a[b]=function(){var a=Array.prototype.slice.call(arguments);return c.apply(this,[a,d])},d};return c.baseUrlRespectingXhr=function(b,c){var e=function(){var e=new b;return d(e,"open",function(b,d){var e=b.shift(),f=b.shift(),g=a.joinUrl(c,f);return d.apply(this,[e,g].concat(b))}),e};return e},c.finishNotifyingXhr=function(a){var c=0,e=0,f=!1,g=b.defer(),h=function(){var a=c-e;0>=a&&f&&g.resolve({totalCount:c})},i=function(){var b=new a;return d(b,"send",function(a,b){return c+=1,b.apply(this,arguments)}),b.addEventListener("load",function(){e+=1,h()}),b};return i.waitForRequestsToFinish=function(){return f=!0,h(),g.promise},i},c}(e,c),g=function(){"use strict";var a={},b=function(a){return Array.prototype.slice.call(a)};a.addClassNameRecursively=function(b,c){b.className+=" "+c,b.parentNode!==b.ownerDocument&&a.addClassNameRecursively(b.parentNode,c)};var c=function(a,c){var d=a.parentStyleSheet,e=b(d.cssRules).indexOf(a);d.insertRule(c,e+1),d.deleteRule(e)},d=function(a,b){var d=a.cssText.replace(/^[^\{]+/,""),e=b+" "+d;c(a,e)},e=function(a){return b(a).reduce(function(a,b){return a+b.cssText},"")},f=function(a){a.textContent=e(a.sheet.cssRules)},g=function(a){return"((?:^|[^.#:\\w])|(?=\\W))("+a.join("|")+")(?=\\W|$)"},h=function(a,c,e){var h=g(c);b(a.querySelectorAll("style")).forEach(function(a){var c=b(a.sheet.cssRules).filter(function(a){return a.selectorText&&new RegExp(h,"i").test(a.selectorText)});c.length&&(c.forEach(function(a){var b=a.selectorText.replace(new RegExp(h,"gi"),function(a,b,c){return b+e(c)});b!==a.selectorText&&d(a,b)}),f(a))})};return a.rewriteCssSelectorWith=function(a,b,c){h(a,[b],function(){return c})},a.lowercaseCssTypeSelectors=function(a,b){h(a,b,function(a){return a.toLowerCase()})},a.findHtmlOnlyNodeNames=function(a){for(var b,c=a.createTreeWalker(a,NodeFilter.SHOW_ELEMENT),d={},e={};c.nextNode();)b=c.currentNode.tagName.toLowerCase(),"http://www.w3.org/1999/xhtml"===c.currentNode.namespaceURI?d[b]=!0:e[b]=!0;return Object.keys(d).filter(function(a){return!e[a]})},a}(),h=function(a){"use strict";var b={},c=function(a){return Array.prototype.slice.call(a)};return b.fakeHover=function(b,c){var d=b.querySelector(c),e="rasterizehtmlhover";d&&(a.addClassNameRecursively(d,e),a.rewriteCssSelectorWith(b,":hover","."+e))},b.fakeActive=function(b,c){var d=b.querySelector(c),e="rasterizehtmlactive";d&&(
d.CSSStyleSheet=function(){d.StyleSheet.call(this),this.cssRules=[]},d.CSSStyleSheet.prototype=new d.StyleSheet,d.CSSStyleSheet.prototype.constructor=d.CSSStyleSheet,d.CSSStyleSheet.prototype.insertRule=function(a,b){if(0>b||b>this.cssRules.length)throw new RangeError("INDEX_SIZE_ERR");var c=d.parse(a).cssRules[0];return c.parentStyleSheet=this,this.cssRules.splice(b,0,c),b},d.CSSStyleSheet.prototype.deleteRule=function(a){if(0>a||a>=this.cssRules.length)throw new RangeError("INDEX_SIZE_ERR");this.cssRules.splice(a,1)},d.CSSStyleSheet.prototype.toString=function(){for(var a="",b=this.cssRules,c=0;c<b.length;c++)a+=b[c].cssText+"\n";return a},c.CSSStyleSheet=d.CSSStyleSheet,d.parse=a("./parse").parse},{"./CSSStyleRule":18,"./StyleSheet":24,"./parse":27}],20:[function(a,b,c){var d={};d.CSSValue=function(){},d.CSSValue.prototype={constructor:d.CSSValue,set cssText(a){var b=this._getConstructorName();throw new Exception('DOMException: property "cssText" of "'+b+'" is readonly!')},get cssText(){var a=this._getConstructorName();throw new Exception('getter "cssText" of "'+a+'" is not implemented!')},_getConstructorName:function(){var a=this.constructor.toString(),b=a.match(/function\s([^\(]+)/),c=b[1];return c}},c.CSSValue=d.CSSValue},{}],21:[function(a,b,c){var d={CSSValue:a("./CSSValue").CSSValue};d.CSSValueExpression=function(a,b){this._token=a,this._idx=b},d.CSSValueExpression.prototype=new d.CSSValue,d.CSSValueExpression.prototype.constructor=d.CSSValueExpression,d.CSSValueExpression.prototype.parse=function(){for(var a,b=this._token,c=this._idx,d="",e="",f="",g=[];;++c){if(d=b.charAt(c),""==d){f="css expression error: unfinished expression!";break}switch(d){case"(":g.push(d),e+=d;break;case")":g.pop(d),e+=d;break;case"/":(a=this._parseJSComment(b,c))?a.error?f="css expression error: unfinished comment in expression!":c=a.idx:(a=this._parseJSRexExp(b,c))?(c=a.idx,e+=a.text):e+=d;break;case"'":case'"':a=this._parseJSString(b,c,d),a?(c=a.idx,e+=a.text):e+=d;break;default:e+=d}if(f)break;if(0==g.length)break}var h;return h=f?{error:f}:{idx:c,expression:e}},d.CSSValueExpression.prototype._parseJSComment=function(a,b){var c,d=a.charAt(b+1);if("/"==d||"*"==d){var e,f,g=b;return"/"==d?f="\n":"*"==d&&(f="*/"),e=a.indexOf(f,g+1+1),-1!==e?(e=e+f.length-1,c=a.substring(b,e+1),{idx:e,text:c}):(error="css expression error: unfinished comment in expression!",{error:error})}return!1},d.CSSValueExpression.prototype._parseJSString=function(a,b,c){var d,e=this._findMatchedIdx(a,b,c);return-1===e?!1:(d=a.substring(b,e+c.length),{idx:e,text:d})},d.CSSValueExpression.prototype._parseJSRexExp=function(a,b){var c=a.substring(0,b).replace(/\s+$/,""),d=[/^$/,/\($/,/\[$/,/\!$/,/\+$/,/\-$/,/\*$/,/\/\s+/,/\%$/,/\=$/,/\>$/,/\<$/,/\&$/,/\|$/,/\^$/,/\~$/,/\?$/,/\,$/,/delete$/,/in$/,/instanceof$/,/new$/,/typeof$/,/void$/],e=d.some(function(a){return a.test(c)});if(e){var f="/";return this._parseJSString(a,b,f)}return!1},d.CSSValueExpression.prototype._findMatchedIdx=function(a,b,c){for(var d,e=b,f=-1;;){if(d=a.indexOf(c,e+1),-1===d){d=f;break}var g=a.substring(b+1,d),h=g.match(/\\+$/);if(!h||h[0]%2==0)break;e=d}var i=a.indexOf("\n",b+1);return d>i&&(d=f),d},c.CSSValueExpression=d.CSSValueExpression},{"./CSSValue":20}],22:[function(a,b,c){var d={};d.MatcherList=function(){this.length=0},d.MatcherList.prototype={constructor:d.MatcherList,get matcherText(){return Array.prototype.join.call(this,", ")},set matcherText(a){for(var b=a.split(","),c=this.length=b.length,d=0;c>d;d++)this[d]=b[d].trim()},appendMatcher:function(a){-1===Array.prototype.indexOf.call(this,a)&&(this[this.length]=a,this.length++)},deleteMatcher:function(a){var b=Array.prototype.indexOf.call(this,a);-1!==b&&Array.prototype.splice.call(this,b,1)}},c.MatcherList=d.MatcherList},{}],23:[function(a,b,c){var d={};d.MediaList=function(){this.length=0},d.MediaList.prototype={constructor:d.MediaList,get mediaText(){return Array.prototype.join.call(this,", ")},set mediaText(a){for(var b=a.split(","),c=this.length=b.length,d=0;c>d;d++)this[d]=b[d].trim()},appendMedium:function(a){-1===Array.prototy
},e=function(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")},f=function(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},g=function(a){var b=a.value;return" "+a.name+'="'+e(b)+'"'},h=function(a){var b=a.tagName;return"http://www.w3.org/1999/xhtml"===a.namespaceURI&&(b=b.toLowerCase()),b},i=function(a){var b=Array.prototype.map.call(a.attributes||a.attrs,function(a){return a.name}).indexOf("xmlns")>=0;return b||a.parentNode&&a.namespaceURI===a.parentNode.namespaceURI&&"html"!==h(a)?"":' xmlns="'+a.namespaceURI+'"'},j=function(a){return Array.prototype.map.call(a.childNodes,function(a){return o(a)}).join("")},k=function(a){var b="<"+h(a);return b+=i(a),Array.prototype.forEach.call(a.attributes||a.attrs,function(a){b+=g(a)}),a.childNodes.length>0?(b+=">",b+=j(a),b+="</"+h(a)+">"):b+="/>",b},l=function(a){var b=a.nodeValue||a.value||"";return f(b)},m=function(a){return"<!--"+a.data.replace(/-/g,"&#45;")+"-->"},n=function(a){return"<![CDATA["+a.nodeValue+"]]>"},o=function(a){return"#document"===a.nodeName||"#document-fragment"===a.nodeName?j(a):a.tagName?k(a):"#text"===a.nodeName?l(a):"#comment"===a.nodeName?m(a):"#cdata-section"===a.nodeName?n(a):void 0};c.serializeToString=function(a){return d(o(a))}},{}]},{},[1])(1)});