From d0cffa56d3d729158de036a722ff47d187a5861f Mon Sep 17 00:00:00 2001 From: nobody Date: Mon, 3 Aug 2020 13:32:36 +0200 Subject: [PATCH] Improved webFontLoader --- core/mappings.js | 42 ++++++++++++++-------------- core/resources.js | 4 --- modules/internal/helpers.js | 2 +- resources/webfont/1.6.28/webfont.jsm | 17 ----------- 4 files changed, 22 insertions(+), 43 deletions(-) delete mode 100644 resources/webfont/1.6.28/webfont.jsm diff --git a/core/mappings.js b/core/mappings.js index 24f4c382..934db9f0 100644 --- a/core/mappings.js +++ b/core/mappings.js @@ -60,9 +60,9 @@ var mappings = { 'prototype/{version}/prototype.': resources.prototypeJS, 'scriptaculous/{version}/scriptaculous.': resources.scriptaculous, 'swfobject/{version}/swfobject.': resources.swfobject, - 'webfont/{version}/webfont.': resources.webfont, + 'webfont/{version}/webfont.': resources.webfontloader, 'webfont/{version}/webfontloader.js': resources.webfontloader, - 'webfont/1/webfont.js': resources.webfont + 'webfont/1/webfont.js': resources.webfontloader } }, // Microsoft Ajax CDN @@ -311,8 +311,8 @@ var mappings = { 'urlive/{version}/jquery.urlive.': resources.jqueryURLive, 'vue/{version}/vue.min.js': resources.vueJs, 'waypoints/{version}/jquery.waypoints.': resources.jQueryWaypoints, - 'webfont/{version}/webfont.js': resources.webfont, - 'webfont/{version}/webfontloader.js': resources.webfont, + 'webfont/{version}/webfont.js': resources.webfontloader, + 'webfont/{version}/webfontloader.js': resources.webfontloader, 'webrtc-adapter/{version}/adapter.min.js': resources.webRTCadapter, 'wow/{version}/wow.min.': resources.wow } @@ -378,7 +378,7 @@ var mappings = { 'urlize.js/urlize.js': resources.urlize, 'vanilla-lazyload@{version}/dist/lazyload.': resources.vanillaLazyload, '@webcomponents/webcomponentsjs/webcomponents-loader.js': resources.webcomponentsJS, - 'webfontloader@{version}/webfontloader.': resources.webfont + 'webfontloader@{version}/webfontloader.': resources.webfontloader }, '/': { 'algoliasearch/3/algoliasearch.': resources.algoliaSearch, @@ -407,7 +407,7 @@ var mappings = { 'swfobject/{version}/swfobject.': resources.swfobject, 'underscorejs/{version}/underscore.': resources.underscore, 'underscorejs/{version}/underscore-min.': resources.underscore, - 'webfontloader/{version}/webfont': resources.webfont + 'webfontloader/{version}/webfont': resources.webfontloader }, // TEMPORARY SOLUTION '/g/': { @@ -505,8 +505,8 @@ var mappings = { 'swfobject/{version}/swfobject_src.': resources.swfobject, 'underscore.js/{version}/underscore.': resources.underscore, 'underscore.js/{version}/underscore-min.': resources.underscore, - 'webfont/{version}/webfont.': resources.webfont, - 'webfont/{version}/webfont_debug.': resources.webfont + 'webfont/{version}/webfont.': resources.webfontloader, + 'webfont/{version}/webfont_debug.': resources.webfontloader } }, // Baidu CDN @@ -540,8 +540,8 @@ var mappings = { 'swfobject/{version}/swfobject.': resources.swfobject, 'underscore.js/{version}/underscore.': resources.underscore, 'underscore.js/{version}/underscore-min.': resources.underscore, - 'webfont/{version}/webfont.': resources.webfont, - 'webfont/{version}/webfont_debug.': resources.webfont + 'webfont/{version}/webfont.': resources.webfontloader, + 'webfont/{version}/webfont_debug.': resources.webfontloader }, '/libs/': { 'angular.js/{version}/angular-animate.': resources.angularAnimate, @@ -570,8 +570,8 @@ var mappings = { 'swfobject/{version}/swfobject.': resources.swfobject, 'underscore.js/{version}/underscore.': resources.underscore, 'underscore.js/{version}/underscore-min.': resources.underscore, - 'webfont/{version}/webfont.': resources.webfont, - 'webfont/{version}/webfont_debug.': resources.webfont + 'webfont/{version}/webfont.': resources.webfontloader, + 'webfont/{version}/webfont_debug.': resources.webfontloader } }, // Staticfile CDN @@ -602,8 +602,8 @@ var mappings = { 'prototype/{version}/prototype.': resources.prototypeJS, 'scriptaculous/{version}/scriptaculous.': resources.scriptaculous, 'swfobject/{version}/swfobject.': resources.swfobject, - 'webfont/{version}/webfont.': resources.webfont, - 'webfont/{version}/webfont_debug.': resources.webfont + 'webfont/{version}/webfont.': resources.webfontloader, + 'webfont/{version}/webfont_debug.': resources.webfontloader } }, // BootCDN @@ -636,12 +636,12 @@ var mappings = { 'swfobject/{version}/swfobject.': resources.swfobject, 'underscore.js/{version}/underscore.': resources.underscore, 'underscore.js/{version}/underscore-min.': resources.underscore, - 'webfont/{version}/webfont.': resources.webfont, - 'webfont/{version}/webfont_debug.': resources.webfont, + 'webfont/{version}/webfont.': resources.webfontloader, + 'webfont/{version}/webfont_debug.': resources.webfontloader, 'ember.js/{version}/ember.': resources.ember, 'moment.js/{version}/moment.': resources.moment, 'moment.js/{version}/moment.min.': resources.moment, - 'webfont/{version}/webfontloader.': resources.webfont + 'webfont/{version}/webfontloader.': resources.webfontloader } }, // Tencent Public Libraries @@ -692,8 +692,8 @@ var mappings = { 'swfobject/{version}/swfobject.': resources.swfobject, 'underscore.js/{version}/underscore.': resources.underscore, 'underscore.js/{version}/underscore-min.': resources.underscore, - 'webfont/{version}/webfont.': resources.webfont, - 'webfont/{version}/webfont_debug.': resources.webfont + 'webfont/{version}/webfont.': resources.webfontloader, + 'webfont/{version}/webfont_debug.': resources.webfontloader } }, // Sina Public Resources @@ -714,8 +714,8 @@ var mappings = { 'swfobject/{version}/swfobject.': resources.swfobject, 'underscore/{version}/underscore.': resources.underscore, 'underscore/{version}/underscore-min.': resources.underscore, - 'webfont/{version}/webfont.': resources.webfont, - 'webfont/{version}/webfont_debug.': resources.webfont + 'webfont/{version}/webfont.': resources.webfontloader, + 'webfont/{version}/webfont_debug.': resources.webfontloader } }, // UpYun Library diff --git a/core/resources.js b/core/resources.js index f9106f55..4b250408 100644 --- a/core/resources.js +++ b/core/resources.js @@ -666,10 +666,6 @@ var resources = { 'type': 'application/javascript' }, // Web Font Loader - 'webfont': { - 'path': 'resources/webfont/{version}/webfont.jsm', - 'type': 'application/javascript' - }, 'webfontloader': { 'path': 'resources/webfont/{version}/webfontloader.jsm', 'type': 'application/javascript' diff --git a/modules/internal/helpers.js b/modules/internal/helpers.js index 2aeb81c2..8975243e 100644 --- a/modules/internal/helpers.js +++ b/modules/internal/helpers.js @@ -676,6 +676,6 @@ const ListOfFiles = { 'urlize.jsm': 'urlize', 'vue.jsm': 'Vue.js', 'webcomponents-loader.jsm': 'WebComponents Loader (JS)', - 'webfont.jsm': 'Web Font Loader', + 'webfontloader.jsm': 'Web Font Loader', 'wow.min.jsm': 'WOW' }; diff --git a/resources/webfont/1.6.28/webfont.jsm b/resources/webfont/1.6.28/webfont.jsm deleted file mode 100644 index d1e856a2..00000000 --- a/resources/webfont/1.6.28/webfont.jsm +++ /dev/null @@ -1,17 +0,0 @@ -/* Web Font Loader v1.6.28 - (c) Adobe Systems, Google. License: Apache 2.0 */(function(){function aa(a,b,c){return a.call.apply(a.bind,arguments)}function ba(a,b,c){if(!a)throw Error();if(2=b.f?e():a.fonts.load(fa(b.a),b.h).then(function(a){1<=a.length?d():setTimeout(f,25)},function(){e()})}f()}),e=null,f=new Promise(function(a,d){e=setTimeout(d,b.f)});Promise.race([f,d]).then(function(){e&&(clearTimeout(e),e=null);b.g(b.a)},function(){b.j(b.a)})};function Q(a,b,c,d,e,f,g){this.v=a;this.B=b;this.c=c;this.a=d;this.s=g||"BESbswy";this.f={};this.w=e||3E3;this.u=f||null;this.m=this.j=this.h=this.g=null;this.g=new M(this.c,this.s);this.h=new M(this.c,this.s);this.j=new M(this.c,this.s);this.m=new M(this.c,this.s);a=new G(this.a.c+",serif",J(this.a));a=O(a);this.g.a.style.cssText=a;a=new G(this.a.c+",sans-serif",J(this.a));a=O(a);this.h.a.style.cssText=a;a=new G("serif",J(this.a));a=O(a);this.j.a.style.cssText=a;a=new G("sans-serif",J(this.a));a= -O(a);this.m.a.style.cssText=a;N(this.g);N(this.h);N(this.j);N(this.m)}var R={D:"serif",C:"sans-serif"},S=null;function T(){if(null===S){var a=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);S=!!a&&(536>parseInt(a[1],10)||536===parseInt(a[1],10)&&11>=parseInt(a[2],10))}return S}Q.prototype.start=function(){this.f.serif=this.j.a.offsetWidth;this.f["sans-serif"]=this.m.a.offsetWidth;this.A=q();U(this)}; -function la(a,b,c){for(var d in R)if(R.hasOwnProperty(d)&&b===a.f[R[d]]&&c===a.f[R[d]])return!0;return!1}function U(a){var b=a.g.a.offsetWidth,c=a.h.a.offsetWidth,d;(d=b===a.f.serif&&c===a.f["sans-serif"])||(d=T()&&la(a,b,c));d?q()-a.A>=a.w?T()&&la(a,b,c)&&(null===a.u||a.u.hasOwnProperty(a.a.c))?V(a,a.v):V(a,a.B):ma(a):V(a,a.v)}function ma(a){setTimeout(p(function(){U(this)},a),50)}function V(a,b){setTimeout(p(function(){v(this.g.a);v(this.h.a);v(this.j.a);v(this.m.a);b(this.a)},a),0)};function W(a,b,c){this.c=a;this.a=b;this.f=0;this.m=this.j=!1;this.s=c}var X=null;W.prototype.g=function(a){var b=this.a;b.g&&w(b.f,[b.a.c("wf",a.c,J(a).toString(),"active")],[b.a.c("wf",a.c,J(a).toString(),"loading"),b.a.c("wf",a.c,J(a).toString(),"inactive")]);K(b,"fontactive",a);this.m=!0;na(this)}; -W.prototype.h=function(a){var b=this.a;if(b.g){var c=y(b.f,b.a.c("wf",a.c,J(a).toString(),"active")),d=[],e=[b.a.c("wf",a.c,J(a).toString(),"loading")];c||d.push(b.a.c("wf",a.c,J(a).toString(),"inactive"));w(b.f,d,e)}K(b,"fontinactive",a);na(this)};function na(a){0==--a.f&&a.j&&(a.m?(a=a.a,a.g&&w(a.f,[a.a.c("wf","active")],[a.a.c("wf","loading"),a.a.c("wf","inactive")]),K(a,"active")):L(a.a))};function oa(a){this.j=a;this.a=new ja;this.h=0;this.f=this.g=!0}oa.prototype.load=function(a){this.c=new ca(this.j,a.context||this.j);this.g=!1!==a.events;this.f=!1!==a.classes;pa(this,new ha(this.c,a),a)}; -function qa(a,b,c,d,e){var f=0==--a.h;(a.f||a.g)&&setTimeout(function(){var a=e||null,m=d||null||{};if(0===c.length&&f)L(b.a);else{b.f+=c.length;f&&(b.j=f);var h,l=[];for(h=0;h