From: Vincent Vanwaelscappel Date: Thu, 30 Sep 2021 13:54:57 +0000 (+0200) Subject: wip #4627 @4 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=d57c61fd60ed4a86a55e9706a2a7bb88d5fb5210;p=fluidbook-html5.git wip #4627 @4 --- diff --git a/js/libs/canvg/canvg.min.js b/js/libs/canvg/canvg.min.js new file mode 100644 index 00000000..b4113008 --- /dev/null +++ b/js/libs/canvg/canvg.min.js @@ -0,0 +1 @@ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).canvg={})}(this,function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(t){var e={exports:{}};return t(e,e.exports),e.exports}function c(t){try{return!!t()}catch(t){return!0}}function n(t){return a?o.createElement(t):{}}function g(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}function l(e,r){try{x(d,e,r)}catch(t){d[e]=r}return r}function u(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++T+E).toString(36)}function h(t){return A(C,t)||(P&&A(M,t)?C[t]=M[t]:C[t]=N("Symbol."+t)),C[t]}var i=function(t){return t&&t.Math==Math&&t},d=i("object"==typeof globalThis&&globalThis)||i("object"==typeof window&&window)||i("object"==typeof self&&self)||i("object"==typeof e&&e)||function(){return this}()||Function("return this")(),f=!c(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),p=function(t){return"object"==typeof t?null!==t:"function"==typeof t},o=d.document,a=p(o)&&p(o.createElement),s=!f&&!c(function(){return 7!=Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a}),R=function(t){if(!p(t))throw TypeError(String(t)+" is not an object");return t},y=function(t,e){if(!p(t))return t;var r,n;if(e&&"function"==typeof(r=t.toString)&&!p(n=r.call(t)))return n;if("function"==typeof(r=t.valueOf)&&!p(n=r.call(t)))return n;if(!e&&"function"==typeof(r=t.toString)&&!p(n=r.call(t)))return n;throw TypeError("Can't convert object to primitive value")},v=Object.defineProperty,m={f:f?v:function(t,e,r){if(R(t),e=y(e,!0),R(r),s)try{return v(t,e,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported");return"value"in r&&(t[e]=r.value),t}},x=f?function(t,e,r){return m.f(t,e,g(1,r))}:function(t,e,r){return t[e]=r,t},b="__core-js_shared__",S=d[b]||l(b,{}),w=r(function(t){(t.exports=function(t,e){return S[t]||(S[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.8.3",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})}),k={}.hasOwnProperty,A=function(t,e){return k.call(t,e)},T=0,E=Math.random(),P=!!Object.getOwnPropertySymbols&&!c(function(){return!String(Symbol())}),O=P&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,C=w("wks"),M=d.Symbol,N=O?M:M&&M.withoutSetter||u,_={};_[h("toStringTag")]="z";var D="[object z]"===String(_),V=Function.toString;"function"!=typeof S.inspectSource&&(S.inspectSource=function(t){return V.call(t)});var I,L,j,F,z,B,U,H,X=S.inspectSource,Y=d.WeakMap,W="function"==typeof Y&&/native code/.test(X(Y)),G=w("keys"),q=function(t){return G[t]||(G[t]=u(t))},Q={},$=d.WeakMap;U=W?(I=S.state||(S.state=new $),L=I.get,j=I.has,F=I.set,z=function(t,e){return e.facade=t,F.call(I,t,e),e},B=function(t){return L.call(I,t)||{}},function(t){return j.call(I,t)}):(H=q("state"),Q[H]=!0,z=function(t,e){return e.facade=t,x(t,H,e),e},B=function(t){return A(t,H)?t[H]:{}},function(t){return A(t,H)});var Z={set:z,get:B,has:U,enforce:function(t){return U(t)?B(t):z(t,{})},getterFor:function(r){return function(t){var e;if(!p(t)||(e=B(t)).type!==r)throw TypeError("Incompatible receiver, "+r+" required");return e}}},K=r(function(t){var e=Z.get,u=Z.enforce,s=String(String).split("String");(t.exports=function(t,e,r,n){var i=!!n&&!!n.unsafe,o=!!n&&!!n.enumerable,a=!!n&&!!n.noTargetGet;"function"==typeof r&&("string"!=typeof e||A(r,"name")||x(r,"name",e),(n=u(r)).source||(n.source=s.join("string"==typeof e?e:""))),t!==d?(i?!a&&t[e]&&(o=!0):delete t[e],o?t[e]=r:x(t,e,r)):o?t[e]=r:l(e,r)})(Function.prototype,"toString",function(){return"function"==typeof this&&e(this).source||X(this)})}),J={}.toString,tt=function(t){return J.call(t).slice(8,-1)},et=h("toStringTag"),rt="Arguments"==tt(function(){return arguments}()),nt=D?tt:function(t){var e;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(t=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),et))?t:rt?tt(e):"Object"==(t=tt(e))&&"function"==typeof e.callee?"Arguments":t};D||K(Object.prototype,"toString",D?{}.toString:function(){return"[object "+nt(this)+"]"},{unsafe:!0});function it(t){return Tt(Et(t))}function ot(t){return"function"==typeof t?t:void 0}function at(t,e){return arguments.length<2?ot(Ct[t])||ot(d[t]):Ct[t]&&Ct[t][e]||d[t]&&d[t][e]}function ut(t){return 0i;)A(n,r=e[i++])&&(~Ft(o,r)||o.push(r));return o}function lt(t,e){var r,n,i,o,a=t.target,u=t.global,s=t.stat;if(r=u?d:s?d[a]||l(a,{}):(d[a]||{}).prototype)for(n in e){if(i=e[n],o=t.noTargetGet?(o=Kt(r,n))&&o.value:r[n],!Zt(u?n:a+(s?".":"#")+n,t.forced)&&void 0!==o){if(typeof i==typeof o)continue;!function(t,e){for(var r=Xt(e),n=m.f,i=Ot.f,o=0;or;){var i,o,a,u=y[r++],s=e?u.ok:u.fail,c=u.resolve,l=u.reject,h=u.domain;try{s?(e||(2===f.rejection&&function(e){Je.call(d,function(){var t=e.facade;xe?sr.emit("rejectionHandled",t):vr("rejectionhandled",t,e.value)})}(f),f.rejection=1),!0===s?i=t:(h&&h.enter(),i=s(t),h&&(h.exit(),a=!0)),i===u.promise?l(ar("Promise-chain cycle")):(o=gr(i))?o.call(i,c,l):c(i)):l(t)}catch(t){h&&!a&&h.exit(),l(t)}}f.reactions=[],f.notified=!1,p&&!f.rejection&&(n=f,Je.call(d,function(){var t,e=n.facade,r=n.value;if(mr(n)&&(t=Ge(function(){xe?sr.emit("unhandledRejection",r,e):vr(yr,e,r)}),n.rejection=xe||mr(n)?2:1,t.error))throw t.value}))}))},vr=function(t,e,r){var n,i;fr?((n=ur.createEvent("Event")).promise=e,n.reason=r,n.initEvent(t,!1,!0),d.dispatchEvent(n)):n={promise:e,reason:r},!pr&&(i=d["on"+t])?i(n):t===yr&&function(t,e){var r=d.console;r&&r.error&&(1===arguments.length?r.error(t):r.error(t,e))}("Unhandled promise rejection",r)},mr=function(t){return 1!==t.rejection&&!t.parent},xr=function(e,r,n){return function(t){e(r,t,n)}},br=function(t,e,r){t.done||(t.done=!0,(t=r?r:t).value=e,t.state=2,dr(t,!0))},Sr=function(r,t,e){if(!r.done){r.done=!0,e&&(r=e);try{if(r.facade===t)throw ar("Promise can't be resolved itself");var n=gr(t);n?Ye(function(){var e={done:!1};try{n.call(t,xr(Sr,e,r),xr(br,e,r))}catch(t){br(e,t,r)}}):(r.value=t,r.state=1,dr(r,!1))}catch(t){br({done:!1},t,r)}}};wt&&(or=function(t){gt(this,or,er),yt(t),qe.call(this);var e=rr(this);try{t(xr(Sr,e),xr(br,e))}catch(t){br(e,t)}},(qe=function(t){nr(this,{type:er,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=ht(or.prototype,{then:function(t,e){var r=ir(this),n=lr(he(this,or));return n.ok="function"!=typeof t||t,n.fail="function"==typeof e&&e,n.domain=xe?sr.domain:void 0,r.parent=!0,r.reactions.push(n),0!=r.state&&dr(r,!1),n.promise},catch:function(t){return this.then(void 0,t)}}),Qe=function(){var t=new qe,e=rr(t);this.promise=t,this.resolve=xr(Sr,e),this.reject=xr(br,e)},We.f=lr=function(t){return t===or||t===$e?new Qe:hr(t)},"function"==typeof Jt&&(Ze=Jt.prototype.then,K(Jt.prototype,"then",function(t,e){var r=this;return new or(function(t,e){Ze.call(r,t,e)}).then(t,e)},{unsafe:!0}),"function"==typeof cr&<({global:!0,enumerable:!0,forced:!0},{fetch:function(t){return Xe(or,cr.apply(d,arguments))}}))),lt({global:!0,wrap:!0,forced:wt},{Promise:or}),ft(or,er,!1),pt(er),$e=at(er),lt({target:er,stat:!0,forced:wt},{reject:function(t){var e=lr(this);return e.reject.call(void 0,t),e.promise}}),lt({target:er,stat:!0,forced:wt},{resolve:function(t){return Xe(this,t)}}),lt({target:er,stat:!0,forced:Lt},{all:function(t){var u=this,e=lr(u),s=e.resolve,c=e.reject,r=Ge(function(){var n=yt(u.resolve),i=[],o=0,a=1;St(t,function(t){var e=o++,r=!1;i.push(void 0),a++,n.call(u,t).then(function(t){r||(r=!0,i[e]=t,--a||s(i))},c)}),--a||s(i)});return r.error&&c(r.value),e.promise},race:function(t){var r=this,n=lr(r),i=n.reject,e=Ge(function(){var e=yt(r.resolve);St(t,function(t){e.call(r,t).then(n.resolve,i)})});return e.error&&i(e.value),n.promise}});var wr=Ot.f;lt({target:"Reflect",stat:!0},{deleteProperty:function(t,e){var r=wr(R(t),e);return!(r&&!r.configurable)&&delete t[e]}});var kr=r(function(t){var e=function(a){var s,t=Object.prototype,c=t.hasOwnProperty,e="function"==typeof Symbol?Symbol:{},n=e.iterator||"@@iterator",r=e.asyncIterator||"@@asyncIterator",i=e.toStringTag||"@@toStringTag";function o(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{o({},"")}catch(a){o=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var i,o,a,u,e=e&&e.prototype instanceof d?e:d,e=Object.create(e.prototype),n=new R(n||[]);return e._invoke=(i=t,o=r,a=n,u=h,function(t,e){if(u===p)throw new Error("Generator is already running");if(u===y){if("throw"===t)throw e;return E()}for(a.method=t,a.arg=e;;){var r=a.delegate;if(r){var n=function t(e,r){var n=e.iterator[r.method];if(n===s){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=s,t(e,r),"throw"===r.method))return g;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return g}var n=l(n,e.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,g;n=n.arg;return n?n.done?(r[e.resultName]=n.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=s),r.delegate=null,g):n:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}(r,a);if(n){if(n===g)continue;return n}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(u===h)throw u=y,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);u=p;n=l(i,o,a);if("normal"===n.type){if(u=a.done?y:f,n.arg===g)continue;return{value:n.arg,done:a.done}}"throw"===n.type&&(u=y,a.method="throw",a.arg=n.arg)}}),e}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}a.wrap=u;var h="suspendedStart",f="suspendedYield",p="executing",y="completed",g={};function d(){}function v(){}function m(){}var x={};x[n]=function(){return this};e=Object.getPrototypeOf,e=e&&e(e(T([])));e&&e!==t&&c.call(e,n)&&(x=e);var b=m.prototype=d.prototype=Object.create(x);function S(t){["next","throw","return"].forEach(function(e){o(t,e,function(t){return this._invoke(e,t)})})}function w(a,u){var e;this._invoke=function(r,n){function t(){return new u(function(t,e){!function e(t,r,n,i){t=l(a[t],a,r);if("throw"!==t.type){var o=t.arg;return(r=o.value)&&"object"==typeof r&&c.call(r,"__await")?u.resolve(r.__await).then(function(t){e("next",t,n,i)},function(t){e("throw",t,n,i)}):u.resolve(r).then(function(t){o.value=t,n(o)},function(t){return e("throw",t,n,i)})}i(t.arg)}(r,n,t,e)})}return e=e?e.then(t,t):t()}}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function T(e){if(e){var t=e[n];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,t=function t(){for(;++r")}),en="$0"==="a".replace(/./,"$0"),b=h("replace"),rn=!!/./[b]&&""===/./[b]("a","$0"),nn=!c(function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};t="ab".split(t);return 2!==t.length||"a"!==t[0]||"b"!==t[1]}),w=function(r,t,e,n){var o,i,a=h(r),u=!c(function(){var t={};return t[a]=function(){return 7},7!=""[r](t)}),s=u&&!c(function(){var t=!1,e=/a/;return"split"===r&&((e={}).constructor={},e.constructor[Jr]=function(){return e},e.flags="",e[a]=/./[a]),e.exec=function(){return t=!0,null},e[a](""),!t});u&&s&&("replace"!==r||tn&&en&&!rn)&&("split"!==r||nn)||(o=/./[a],e=(s=e(a,""[r],function(t,e,r,n,i){return e.exec===$r?u&&!i?{done:!0,value:o.call(e,r,n)}:{done:!0,value:t.call(r,e,n)}:{done:!1}},{REPLACE_KEEPS_$0:en,REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE:rn}))[0],i=s[1],K(String.prototype,r,e),K(RegExp.prototype,a,2==t?function(t,e){return i.call(t,this,e)}:function(t){return i.call(t,this)})),n&&x(RegExp.prototype[a],"sham",!0)},W=function(o){return function(t,e){var r,n=String(Et(t)),i=_t(e),t=n.length;return i<0||t<=i?o?"":void 0:(e=n.charCodeAt(i))<55296||56319]*>)/g,cn=/\$([$&'`]|\d\d?)/g,ln=Math.max,hn=Math.min;w("replace",2,function(i,b,S,t){var w=t.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE,k=t.REPLACE_KEEPS_$0,A=w?"$":"$0";return[function(t,e){var r=Et(this),n=null==t?void 0:t[i];return void 0!==n?n.call(t,r,e):b.call(String(r),t,e)},function(t,e){if(!w&&k||"string"==typeof e&&-1===e.indexOf(A)){var r=S(b,t,this,e);if(r.done)return r.value}var n=R(t),i=String(this),o="function"==typeof e;o||(e=String(e));var a,u=n.global;u&&(a=n.unicode,n.lastIndex=0);for(var s=[];;){var c=Kr(n,i);if(null===c)break;if(s.push(c),!u)break;""===String(c[0])&&(n.lastIndex=Zr(i,ut(n.lastIndex),a))}for(var l,h="",f=0,p=0;pt.length)&&(e=t.length);for(var r=0,n=new Array(e);r~.[:]+)/g,Dn=/(\.[^\s+>~.[:]+)/g,Vn=/(::[^\s+>~.[:]+|:first-line|:first-letter|:before|:after)/gi,In=/(:[\w-]+\([^)]*\))/gi,Ln=/(:[^\s+>~.[:]+)/g,jn=/([^\s+>~.[:]+)/g;function Fn(t,e){var r=e.exec(t);return r?[t.replace(e," "),r.length]:[t,0]}function zn(t){var e=[0,0,0],t=Fn(r=t.replace(/:not\(([^)]*)\)/g," $1 ").replace(/{[\s\S]*/gm," "),Nn),t=Mn(t,2),r=t[0],n=t[1];e[1]+=n;t=Fn(r,_n),t=Mn(t,2);r=t[0],n=t[1],e[0]+=n;t=Fn(r,Dn),t=Mn(t,2);r=t[0],n=t[1],e[1]+=n;t=Fn(r,Vn),t=Mn(t,2);r=t[0],n=t[1],e[2]+=n;t=Fn(r,In),t=Mn(t,2);r=t[0],n=t[1],e[1]+=n;t=Fn(r,Ln),t=Mn(t,2);r=t[0],n=t[1],e[1]+=n;t=Fn(r=r.replace(/[*\s+>~]/g," ").replace(/[#.]/g," "),jn),t=Mn(t,2);return r=t[0],n=t[1],e[2]+=n,e.join("")}var Bn=1e-8;function Un(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2))}function Hn(t,e){return(t[0]*e[0]+t[1]*e[1])/(Un(t)*Un(e))}function Xn(t,e){return(t[0]*e[1]ii)throw TypeError(oi);for(e=0;e>>0;if(0==n)return[];if(void 0===t)return[r];if(!fn(t))return y.call(r,t,n);for(var i,o,a,u=[],e=(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.unicode?"u":"")+(t.sticky?"y":""),s=0,c=new RegExp(t.source,e+"g");(i=$r.call(c,r))&&!((o=c.lastIndex)>s&&(u.push(r.slice(s,i.index)),1=n));)c.lastIndex===i.index&&c.lastIndex++;return s===r.length?!a&&c.test("")||u.push(""):u.push(r.slice(s)),u.length>n?u.slice(0,n):u}:"0".split(void 0,0).length?function(t,e){return void 0===t&&0===e?[]:y.call(this,t,e)}:y;return[function(t,e){var r=Et(this),n=null==t?void 0:t[i];return void 0!==n?n.call(t,r,e):d.call(String(r),t,e)},function(t,e){var r=g(d,t,this,e,d!==y);if(r.done)return r.value;var n=R(t),i=String(this),r=he(n,RegExp),o=n.unicode,t=(n.ignoreCase?"i":"")+(n.multiline?"m":"")+(n.unicode?"u":"")+(pi?"y":"g"),a=new r(pi?n:"^(?:"+n.source+")",t),u=void 0===e?fi:e>>>0;if(0==u)return[];if(0===i.length)return null===Kr(a,i)?[i]:[];for(var s=0,c=0,l=[];c "+u.toRGB()+" -> "+u.toHex());a.appendChild(s),a.appendChild(c),o.appendChild(a)}catch(e){}return o}}var qi=(ei(Qi,[{key:"split",value:function(){var t=0=m&&(n=r-i%m,o.shouldUpdate(c,f)&&(o.render(e,l,h,p,y,g,d),v.runEvents())),o.intervalId=Ui(t)},a||v.start(),this.intervalId=Ui(u))}},{key:"stop",value:function(){this.intervalId&&(Ui.cancel(this.intervalId),this.intervalId=null),this.mouse.stop()}},{key:"shouldUpdate",value:function(t,e){if(!t){var r=this.frameDuration;if(this.animations.reduce(function(t,e){return e.update(r)||t},!1))return!0}return!("function"!=typeof e||!e())||!(this.isReadyLock||!this.isReady())||!!this.mouse.hasEvents()}},{key:"render",value:function(t,e,r,n,i,o,a){var u=this.CLIENT_WIDTH,s=this.CLIENT_HEIGHT,c=this.viewPort,l=this.ctx,h=this.isFirstRender,f=l.canvas;c.clear(),f.width&&f.height?c.setCurrent(f.width,f.height):c.setCurrent(u,s);var p=t.getStyle("width"),u=t.getStyle("height");!e&&(h||"number"!=typeof n&&"number"!=typeof i)&&(p.hasValue()&&(f.width=p.getPixels("x"),f.style&&(f.style.width="".concat(f.width,"px"))),u.hasValue()&&(f.height=u.getPixels("y"),f.style&&(f.style.height="".concat(f.height,"px"))));var y,s=f.clientWidth||f.width,f=f.clientHeight||f.height;e&&p.hasValue()&&u.hasValue()&&(s=p.getPixels("x"),f=u.getPixels("y")),c.setCurrent(s,f),"number"==typeof o&&t.getAttribute("x",!0).setValue(o),"number"==typeof a&&t.getAttribute("y",!0).setValue(a),"number"!=typeof n&&"number"!=typeof i||(c=kn(t.getAttribute("viewBox").getString()),a=o=0,"number"==typeof n&&((y=t.getStyle("width")).hasValue()?o=y.getPixels("x")/n:isNaN(c[2])||(o=c[2]/n)),"number"==typeof i&&((y=t.getStyle("height")).hasValue()?a=y.getPixels("y")/i:isNaN(c[3])||(a=c[3]/i)),o=o||a,a=a||o,t.getAttribute("width",!0).setValue(n),t.getAttribute("height",!0).setValue(i),(i=t.getStyle("transform",!0,!0)).setValue("".concat(i.getString()," scale(").concat(1/o,", ").concat(1/a,")"))),r||l.clearRect(0,0,s,f),t.render(l),h&&(this.isFirstRender=!1)}}]),so);function so(t){var e=1"+t+"<\/script>"}var To,Eo=Object.keys||function(t){return ct(t,zt)},Po=f?Object.defineProperties:function(t,e){R(t);for(var r,n=Eo(e),i=n.length,o=0;o=e.length?{value:void 0,done:!0}:(r=Ko(e,r),t.index+=r.length,{value:r,done:!1})});function ra(t){return function(t){if(Array.isArray(t))return Cn(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||On(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var _=(ei(ua,[{key:"apply",value:function(t){var e=this.point,r=e.x,e=e.y;t.translate(r||0,e||0)}},{key:"unapply",value:function(t){var e=this.point,r=e.x,e=e.y;t.translate(-1*r||0,-1*e||0)}},{key:"applyToPoint",value:function(t){var e=this.point,r=e.x,e=e.y;t.applyTransform([1,0,0,1,r||0,e||0])}}]),ua),w=(ei(aa,[{key:"apply",value:function(t){var e=this.cx,r=this.cy,n=this.originX,i=this.originY,o=this.angle,n=e+n.getPixels("x"),i=r+i.getPixels("y");t.translate(n,i),t.rotate(o.getRadians()),t.translate(-n,-i)}},{key:"unapply",value:function(t){var e=this.cx,r=this.cy,n=this.originX,i=this.originY,o=this.angle,n=e+n.getPixels("x"),i=r+i.getPixels("y");t.translate(n,i),t.rotate(-1*o.getRadians()),t.translate(-n,-i)}},{key:"applyToPoint",value:function(t){var e=this.cx,r=this.cy,n=this.angle.getRadians();t.applyTransform([1,0,0,1,e||0,r||0]),t.applyTransform([Math.cos(n),Math.sin(n),-Math.sin(n),Math.cos(n),0,0]),t.applyTransform([1,0,0,1,-e||0,-r||0])}}]),aa),ze=(ei(oa,[{key:"apply",value:function(t){var e=this.scale,r=e.x,n=e.y,i=this.originX,e=this.originY,i=i.getPixels("x"),e=e.getPixels("y");t.translate(i,e),t.scale(r,n||r),t.translate(-i,-e)}},{key:"unapply",value:function(t){var e=this.scale,r=e.x,n=e.y,i=this.originX,e=this.originY,i=i.getPixels("x"),e=e.getPixels("y");t.translate(i,e),t.scale(1/r,1/n||r),t.translate(-i,-e)}},{key:"applyToPoint",value:function(t){var e=this.scale,r=e.x,e=e.y;t.applyTransform([r||0,0,0,e||0,0,0])}}]),oa),na=(ei(ia,[{key:"apply",value:function(t){var e=this.originX,r=this.originY,n=this.matrix,e=e.getPixels("x"),r=r.getPixels("y");t.translate(e,r),t.transform(n[0],n[1],n[2],n[3],n[4],n[5]),t.translate(-e,-r)}},{key:"unapply",value:function(t){var e=this.originX,r=this.originY,n=this.matrix,i=n[0],o=n[2],a=n[4],u=n[1],s=n[3],c=n[5],n=1/(i*(+s-0*c)-o*(+u-0*c)+a*(0*u-0*s)),e=e.getPixels("x"),r=r.getPixels("y");t.translate(e,r),t.transform(n*(+s-0*c),n*(0*c-+u),n*(0*a-+o),n*(+i-0*a),n*(o*c-a*s),n*(a*u-i*c)),t.translate(-e,-r)}},{key:"applyToPoint",value:function(t){t.applyTransform(this.matrix)}}]),ia);function ia(t,e,r){Jn(this,ia),this.type="matrix",this.matrix=[],this.originX=null,this.originY=null,this.matrix=kn(e),this.originX=r[0],this.originY=r[1]}function oa(t,e,r){Jn(this,oa),this.type="scale",this.scale=null,this.originX=null,this.originY=null;e=no.parseScale(e);0!==e.x&&0!==e.y||(e.x=Bn,e.y=Bn),this.scale=e,this.originX=r[0],this.originY=r[1]}function aa(t,e,r){Jn(this,aa),this.type="rotate",this.angle=null,this.originX=null,this.originY=null,this.cx=0,this.cy=0;e=kn(e);this.angle=new qi(t,"angle",e[0]),this.originX=r[0],this.originY=r[1],this.cx=e[1]||0,this.cy=e[2]||0}function ua(t,e){Jn(this,ua),this.type="translate",this.point=null,this.point=no.parse(e)}var sa=function(){xo(o,na);var r,n,i=(r=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,e=ko(r);return e=n?(t=ko(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),bo(this,e)});function o(t,e,r){return Jn(this,o),(r=i.call(this,t,e,r)).type="skew",r.angle=null,r.angle=new qi(t,"angle",e),r}return o}();b=function(){xo(o,sa);var r,n,i=(r=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,e=ko(r);return e=n?(t=ko(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),bo(this,e)});function o(t,e,r){return Jn(this,o),(r=i.call(this,t,e,r)).type="skewX",r.matrix=[1,0,Math.tan(r.angle.getRadians()),1,0,0],r}return o}();var W=function(){xo(o,sa);var r,n,i=(r=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,e=ko(r);return e=n?(t=ko(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),bo(this,e)});function o(t,e,r){return Jn(this,o),(r=i.call(this,t,e,r)).type="skewY",r.matrix=[1,Math.tan(r.angle.getRadians()),0,1,0,0],r}return o}(),ca=(ei(la,[{key:"apply",value:function(t){for(var e=this.transforms,r=e.length,n=0;nDa;Da++)A(Pa,Ma=_a[Da])&&!A(Na,Ma)&&Ra(Na,Ma,Aa(Pa,Ma));(Na.prototype=Oa).constructor=Na,K(d,Ea,Na)}var Va=(ei(Ia,[{key:"addPoint",value:function(t,e){void 0!==t&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=t,this.x2=t),tthis.x2&&(this.x2=t)),void 0!==e&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),ethis.y2&&(this.y2=e))}},{key:"addX",value:function(t){this.addPoint(t,null)}},{key:"addY",value:function(t){this.addPoint(null,t)}},{key:"addBoundingBox",value:function(t){var e,r,n;t&&(e=t.x1,r=t.y1,n=t.x2,t=t.y2,this.addPoint(e,r),this.addPoint(n,t))}},{key:"sumCubic",value:function(t,e,r,n,i){return Math.pow(1-t,3)*e+3*Math.pow(1-t,2)*t*r+3*(1-t)*Math.pow(t,2)*n+Math.pow(t,3)*i}},{key:"bezierCurveAdd",value:function(t,e,r,n,i){var o,a,u=6*e-12*r+6*n,s=-3*e+9*r-9*n+3*i,c=3*r-3*e;0!=s?(o=Math.pow(u,2)-4*c*s)<0||(0<(a=(-u+Math.sqrt(o))/(2*s))&&a<1&&(t?this.addX(this.sumCubic(a,e,r,n,i)):this.addY(this.sumCubic(a,e,r,n,i))),0<(s=(-u-Math.sqrt(o))/(2*s))&&s<1&&(t?this.addX(this.sumCubic(s,e,r,n,i)):this.addY(this.sumCubic(s,e,r,n,i)))):0==u||0<(u=-c/u)&&u<1&&(t?this.addX(this.sumCubic(u,e,r,n,i)):this.addY(this.sumCubic(u,e,r,n,i)))}},{key:"addBezierCurve",value:function(t,e,r,n,i,o,a,u){this.addPoint(t,e),this.addPoint(a,u),this.bezierCurveAdd(!0,t,r,i,a),this.bezierCurveAdd(!1,e,n,o,u)}},{key:"addQuadraticCurve",value:function(t,e,r,n,i,o){r=t+2/3*(r-t),n=e+2/3*(n-e);this.addBezierCurve(t,e,r,r+1/3*(i-t),n,n+1/3*(o-e),i,o)}},{key:"isPointInBox",value:function(t,e){var r=this.x1,n=this.y1,i=this.x2,o=this.y2;return r<=t&&t<=i&&n<=e&&e<=o}},{key:"x",get:function(){return this.x1}},{key:"y",get:function(){return this.y1}},{key:"width",get:function(){return this.x2-this.x1}},{key:"height",get:function(){return this.y2-this.y1}}]),Ia);function Ia(){var t=0t.phi1&&(t.phi2-=2*Ba),1===t.sweepFlag&&t.phi2R.maxX&&(R.maxX=t),tR.maxY&&(R.maxY=t),tg&&xg&&x=this.commands.length-1}},{key:"next",value:function(){var t=this.commands[++this.i];return this.previousCommand=this.command,this.command=t}},{key:"getPoint",value:function(){var t=new no(this.command[0=e.length?{value:t.target=void 0,done:!0}:"keys"==r?{value:n,done:!1}:"values"==r?{value:e[n],done:!1}:{value:[n,e[n]],done:!1}},"values");ne.Arguments=ne.Array,Oe("keys"),Oe("values"),Oe("entries");var Cu,Mu=h("iterator"),Nu=h("toStringTag"),_u=Ou.values;for(Cu in eo){var Du=d[Cu],Vu=Du&&Du.prototype;if(Vu){if(Vu[Mu]!==_u)try{x(Vu,Mu,_u)}catch(t){Vu[Mu]=_u}if(Vu[Nu]||x(Vu,Nu,Cu),eo[Cu])for(var Iu in Ou)if(Vu[Iu]!==Ou[Iu])try{x(Vu,Iu,Ou[Iu])}catch(t){Vu[Iu]=Ou[Iu]}}}var Lu=function(){xo(o,ha);var r,n,i=(r=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,e=ko(r);return e=n?(t=ko(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),bo(this,e)});function o(t,e,r){Jn(this,o),(r=i.call(this,t,e,r)).type="animate",r.duration=0,r.initialValue=null,r.initialUnits="",r.removed=!1,r.frozen=!1,t.screen.animations.push(wo(r)),r.begin=r.getAttribute("begin").getMilliseconds(),r.maxDuration=r.begin+r.getAttribute("dur").getMilliseconds(),r.from=r.getAttribute("from"),r.to=r.getAttribute("to"),r.values=new qi(t,"values",null);t=r.getAttribute("values");return t.hasValue()&&r.values.setValue(t.getString().split(";")),r}return ei(o,[{key:"getProperty",value:function(){var t=this.getAttribute("attributeType").getString(),e=this.getAttribute("attributeName").getString();return"CSS"===t?this.parent.getStyle(e,!0):this.parent.getAttribute(e,!0)}},{key:"calcValue",value:function(){var t=this.initialUnits,e=this.getProgress(),r=e.progress,n=e.from,e=e.to,r=n.getNumber()+(e.getNumber()-n.getNumber())*r;return"%"===t&&(r*=100),"".concat(r).concat(t)}},{key:"update",value:function(t){var e=this.parent,r=this.getProperty();if(this.initialValue||(this.initialValue=r.getString(),this.initialUnits=r.getUnits()),this.duration>this.maxDuration){var n=this.getAttribute("fill").getString("remove");if("indefinite"===this.getAttribute("repeatCount").getString()||"indefinite"===this.getAttribute("repeatDur").getString())this.duration=0;else if("freeze"!==n||this.frozen){if("remove"===n&&!this.removed)return this.removed=!0,r.setValue(e.animationFrozen?e.animationFrozenValue:this.initialValue),!0}else this.frozen=!0,e.animationFrozen=!0,e.animationFrozenValue=r.getString();return!1}this.duration+=t;n=!1;return this.begint.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}(wo(n).children);try{for(a.s();!(i=a.n()).done;){var u=i.value;switch(u.type){case"font-face":var s=(n.fontFace=u).getStyle("font-family");s.hasValue()&&(o[s.getString()]=wo(n));break;case"missing-glyph":n.missingGlyph=u;break;case"glyph":var c=u;c.arabicForm?(n.isRTL=!0,n.isArabic=!0,void 0===n.glyphs[c.unicode]&&(n.glyphs[c.unicode]={}),n.glyphs[c.unicode][c.arabicForm]=c):n.glyphs[c.unicode]=c}}}catch(t){a.e(t)}finally{a.f()}return n}return ei(h,[{key:"render",value:function(){}}]),h}();Ir=function(){xo(o,ha);var r,n,i=(r=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,e=ko(r);return e=n?(t=ko(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),bo(this,e)});function o(t,e,r){return Jn(this,o),(r=i.call(this,t,e,r)).type="font-face",r.ascent=r.getAttribute("ascent").getNumber(),r.descent=r.getAttribute("descent").getNumber(),r.unitsPerEm=r.getAttribute("units-per-em").getNumber(),r}return o}();dn=function(){xo(i,yu);var r,n,e=(r=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,e=ko(r);return e=n?(t=ko(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),bo(this,e)});function i(){var t;return Jn(this,i),(t=e.apply(this,arguments)).type="missing-glyph",t.horizAdvX=0,t}return i}();Ci=function(){xo(i,du);var r,n,e=(r=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,e=ko(r);return e=n?(t=ko(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),bo(this,e)});function i(){var t;return Jn(this,i),(t=e.apply(this,arguments)).type="tref",t}return ei(i,[{key:"getText",value:function(){var t=this.getHrefAttribute().getDefinition();if(t){t=t.children[0];if(t)return t.getText()}return""}}]),i}();var Fu,zu,Bu,Uu,Hu,Xu,Yu,Wu,xn=function(){xo(o,du);var r,n,i=(r=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,e=ko(r);return e=n?(t=ko(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),bo(this,e)});function o(t,e,r){Jn(this,o),(t=i.call(this,t,e,r)).type="a";r=e.childNodes,e=r[0],r=0t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}(this.dataArray);try{for(o.s();!(i=o.n()).done;){var a=i.value;if(!a||!(a.pathLength<5e-5||r+a.pathLength+5e-5=i&&(this.equidistantCache.points.push({x:u.x,y:u.y,distance:a}),o-=i)}}}},{key:"getEquidistantPointOnPath",value:function(t,e,r){if(this.buildEquidistantCache(e,r),t<0||5e-5>x;0!=(o[v+3]=Y)?(o[v]=(D*m>>x)*(q=255/Y),o[v+1]=(V*m>>x)*q,o[v+2]=(I*m>>x)*q):o[v]=o[v+1]=o[v+2]=0,D-=C,V-=M,I-=N,L-=_,C-=y.r,M-=y.g,N-=y.b,_-=y.a;var W=d+((W=X+n+1)>x,0>x)*(J=255/J),o[vt+1]=(ot*m>>x)*J,o[vt+2]=(at*m>>x)*J):o[vt]=o[vt+1]=o[vt+2]=0,it-=tt,ot-=et,at-=rt,ut-=nt,tt-=y.r,et-=y.g,rt-=y.b,nt-=y.a,vt=Q+((vt=dt+c) 0) { + if (this.texts[pageNr] !== undefined && (!this.fluidbook.support.svgtocanvg && $(this.texts[pageNr]).get(0).width > 0)) { this.addTextContents(pageNr, callback) } else { this._loadTexts(pageNr, function () { @@ -683,6 +685,7 @@ FluidbookLoader.prototype = { html += ''; } $(t).html(html); + this.renderTextsCanvas(); } else { $(t).append(this.texts[pageNr]); @@ -707,6 +710,8 @@ FluidbookLoader.prototype = { } var page = $(this).data('page'); + + var c = $(this).closest('.texts'); var tw = $(c).width(); var th = $(c).height(); @@ -737,13 +742,33 @@ FluidbookLoader.prototype = { } var ctx = canvas.getContext("2d"); - var img = $this.texts[page].get(0); - if (img.width === 0) { - $this.deletePage(page); - $this._preloadPage(page, callback); - return; + if ($this.fluidbook.support.svgtocanvg) { + try { + var dim = $this.getPageDimensions(page); + var c = canvg.Canvg.fromString(ctx, $this.texts[page], { + enableRedraw: false, + ignoreAnimation: true, + ignoreMouse: true, + ignoreDimensions: true, + scaleWidth: cw, + scaleHeight: ch, + offsetX: cw - (dim.width / 2), + offsetY: ch - (dim.height / 2), + }); + c.render(); + } catch (e) { + console.warn(e); + console.info($this.texts[page]); + } + } else { + var img = $this.texts[page].get(0); + if (img.width === 0) { + $this.deletePage(page); + $this._preloadPage(page, callback); + return; + } + ctx.drawImage(img, 0, 0, img.width * 0.998, img.height * 0.998, 0, 0, cw, ch); } - ctx.drawImage(img, 0, 0, img.width * 0.998, img.height * 0.998, 0, 0, cw, ch); $(this).data('w', cw).data('h', ch); }); }, @@ -753,7 +778,19 @@ FluidbookLoader.prototype = { callback(); return; } - this.texts[pageNr] = this.loadImage(this.getTextsURL(pageNr), null, null, 'image/svg+xml', pageNr, callback); + var $this = this; + var url = this.getTextsURL(pageNr); + if (this.fluidbook.support.svgtocanvg) { + $.ajax({ + url: url, + dataType: 'text', + }).done(function (data) { + $this.texts[pageNr] = data; + callback(); + }); + } else { + this.texts[pageNr] = this.loadImage(url, null, null, 'image/svg+xml', pageNr, callback); + } }, loadDatas: function (pageNr, callback) { var $this = this; diff --git a/js/libs/fluidbook/fluidbook.support.js b/js/libs/fluidbook/fluidbook.support.js index 639a1d2d..a7ac6c07 100644 --- a/js/libs/fluidbook/fluidbook.support.js +++ b/js/libs/fluidbook/fluidbook.support.js @@ -15,6 +15,7 @@ function FluidbookSupport(fluidbook) { this.edge = Modernizr.edge; this.chromeBased = Modernizr.chrome || this.edge; this.svgtocanvas = this.IE === 0; + this.svgtocanvg = false && this.svgtocanvas; // If in node-webkit or if the index.html fluidbook is locally open in a browser this.offline = (typeof process !== "undefined" && process.versions['node-webkit']) || window.location.toString().indexOf("file://") == 0;