From 079ce6bdf0771ec6b55f7852e899bb644bf27e52 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Thu, 31 Dec 2020 16:06:44 +0100 Subject: [PATCH 1/7] Add bazel recipe and update protobufjs to 6.10.2 --- ts/package.json | 2 +- ts/protobufjs.bzl | 29 +++++++++++++++++++++++++++++ ts/yarn.lock | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 ts/protobufjs.bzl diff --git a/ts/package.json b/ts/package.json index 7f1ee8a7d..3f7bdd6d8 100644 --- a/ts/package.json +++ b/ts/package.json @@ -67,7 +67,7 @@ "lodash.debounce": "^4.0.8", "lodash.throttle": "^4.1.1", "mathjax": "^3.1.2", - "protobufjs": "^6.10.1" + "protobufjs": "^6.10.2" }, "files": [ "dist/*" diff --git a/ts/protobufjs.bzl b/ts/protobufjs.bzl new file mode 100644 index 000000000..218d2ac65 --- /dev/null +++ b/ts/protobufjs.bzl @@ -0,0 +1,29 @@ +load("//ts:copy.bzl", "copy_files") + +"Rule to copy protobufjs subset from node_modules to vendor folder." + +_include = [ + "dist/protobuf.min.js", +] + +_unwanted_prefix = "external/npm/node_modules/protobufjs/dist/" + +def _copy_protobufjs_impl(ctx): + wanted = [] + for f in ctx.attr.protobufjs.files.to_list(): + path = f.path + want = True + + for substr in _include: + if substr in path: + output = path.replace(_unwanted_prefix, "") + wanted.append((f, output)) + + return copy_files(ctx, wanted) + +copy_protobufjs = rule( + implementation = _copy_protobufjs_impl, + attrs = { + "protobufjs": attr.label(default = "@npm//protobufjs:protobufjs__files"), + }, +) diff --git a/ts/yarn.lock b/ts/yarn.lock index 0bb62a605..db681fd30 100644 --- a/ts/yarn.lock +++ b/ts/yarn.lock @@ -2200,7 +2200,7 @@ protobufjs@6.8.8: "@types/node" "^10.1.0" long "^4.0.0" -protobufjs@^6.10.1: +protobufjs@^6.10.2: version "6.10.2" resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.10.2.tgz#b9cb6bd8ec8f87514592ba3fdfd28e93f33a469b" integrity sha512-27yj+04uF6ya9l+qfpH187aqEzfCF4+Uit0I9ZBQVqK09hk/SQzKa2MUqUpXaVa7LOFRg1TSSr3lVxGOk6c0SQ== From 2ba944640dc7cec1e7d56730de7337b19ed30af0 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Thu, 31 Dec 2020 16:15:25 +0100 Subject: [PATCH 2/7] Add build recipe to aqt/data/web/js --- qt/aqt/data/web/js/vendor/BUILD.bazel | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qt/aqt/data/web/js/vendor/BUILD.bazel b/qt/aqt/data/web/js/vendor/BUILD.bazel index 51e901ab9..99e7ff45f 100644 --- a/qt/aqt/data/web/js/vendor/BUILD.bazel +++ b/qt/aqt/data/web/js/vendor/BUILD.bazel @@ -1,5 +1,6 @@ load("//ts:jquery.bzl", "copy_jquery") load("//ts:jquery-ui.bzl", "copy_jquery_ui") +load("//ts:protobufjs.bzl", "copy_protobufjs") copy_jquery( name = "jquery", @@ -11,10 +12,16 @@ copy_jquery_ui( visibility = ["//visibility:public"], ) +copy_protobufjs( + name = "protobufjs", + visibility = ["//visibility:public"], +) + files = [ "jquery", "jquery-ui", + "protobufjs", ] directories = [ From 4da27afba83a9799811c66ebfbcc423a76cd7b81 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Thu, 31 Dec 2020 16:17:46 +0100 Subject: [PATCH 3/7] Remove hardcoded protobufjs --- qt/aqt/data/web/js/vendor/protobuf.min.js | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 qt/aqt/data/web/js/vendor/protobuf.min.js diff --git a/qt/aqt/data/web/js/vendor/protobuf.min.js b/qt/aqt/data/web/js/vendor/protobuf.min.js deleted file mode 100644 index cefb63dce..000000000 --- a/qt/aqt/data/web/js/vendor/protobuf.min.js +++ /dev/null @@ -1,8 +0,0 @@ -/*! - * protobuf.js v6.10.0 (c) 2016, daniel wirtz - * compiled wed, 15 jul 2020 23:34:14 utc - * licensed under the bsd-3-clause license - * see: https://github.com/dcodeio/protobuf.js for details - */ -!function(g){"use strict";var r,e,t,i;r={1:[function(t,i){i.exports=function(t,i){var n=Array(arguments.length-1),s=0,r=2,u=!0;for(;r>2],r=(3&f)<<4,o=1;break;case 1:s[u++]=h[r|f>>4],r=(15&f)<<2,o=2;break;case 2:s[u++]=h[r|f>>6],s[u++]=h[63&f],o=0}8191>4,r=o,s=2;break;case 2:i[n++]=(15&r)<<4|(60&o)>>2,r=o,s=3;break;case 3:i[n++]=(3&r)<<6|o,s=0}}if(1===s)throw Error(c);return n-e},r.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}},{}],3:[function(t,i){function a(i,n){"string"==typeof i&&(n=i,i=g);var f=[];function h(t){if("string"!=typeof t){var i=c();if(a.verbose&&console.log("codegen: "+i),i="return "+i,t){for(var n=Object.keys(t),r=Array(n.length+1),e=Array(n.length),s=0;s>>0,n,r);else if(i<11754943508222875e-54)t((e<<31|Math.round(i/1401298464324817e-60))>>>0,n,r);else{var s=Math.floor(Math.log(i)/Math.LN2);t((e<<31|127+s<<23|8388607&Math.round(i*Math.pow(2,-s)*8388608))>>>0,n,r)}}function n(t,i,n){var r=t(i,n),e=2*(r>>31)+1,s=r>>>23&255,u=8388607&r;return 255==s?u?NaN:1/0*e:0==s?1401298464324817e-60*e*u:e*Math.pow(2,s-150)*(8388608+u)}function r(t,i,n){o[0]=t,i[n]=f[0],i[n+1]=f[1],i[n+2]=f[2],i[n+3]=f[3]}function e(t,i,n){o[0]=t,i[n]=f[3],i[n+1]=f[2],i[n+2]=f[1],i[n+3]=f[0]}function s(t,i){return f[0]=t[i],f[1]=t[i+1],f[2]=t[i+2],f[3]=t[i+3],o[0]}function u(t,i){return f[3]=t[i],f[2]=t[i+1],f[1]=t[i+2],f[0]=t[i+3],o[0]}var o,f,h,c,a,l;function v(t,i,n,r,e,s){var u=r<0?1:0;if(u&&(r=-r),0===r)t(0,e,s+i),t(0<1/r?0:2147483648,e,s+n);else if(isNaN(r))t(0,e,s+i),t(2146959360,e,s+n);else if(17976931348623157e292>>0,e,s+n);else{var o;if(r<22250738585072014e-324)t((o=r/5e-324)>>>0,e,s+i),t((u<<31|o/4294967296)>>>0,e,s+n);else{var f=Math.floor(Math.log(r)/Math.LN2);1024===f&&(f=1023),t(4503599627370496*(o=r*Math.pow(2,-f))>>>0,e,s+i),t((u<<31|f+1023<<20|1048576*o&1048575)>>>0,e,s+n)}}}function d(t,i,n,r,e){var s=t(r,e+i),u=t(r,e+n),o=2*(u>>31)+1,f=u>>>20&2047,h=4294967296*(1048575&u)+s;return 2047==f?h?NaN:1/0*o:0==f?5e-324*o*h:o*Math.pow(2,f-1075)*(h+4503599627370496)}function b(t,i,n){c[0]=t,i[n]=a[0],i[n+1]=a[1],i[n+2]=a[2],i[n+3]=a[3],i[n+4]=a[4],i[n+5]=a[5],i[n+6]=a[6],i[n+7]=a[7]}function y(t,i,n){c[0]=t,i[n]=a[7],i[n+1]=a[6],i[n+2]=a[5],i[n+3]=a[4],i[n+4]=a[3],i[n+5]=a[2],i[n+6]=a[1],i[n+7]=a[0]}function p(t,i){return a[0]=t[i],a[1]=t[i+1],a[2]=t[i+2],a[3]=t[i+3],a[4]=t[i+4],a[5]=t[i+5],a[6]=t[i+6],a[7]=t[i+7],c[0]}function m(t,i){return a[7]=t[i],a[6]=t[i+1],a[5]=t[i+2],a[4]=t[i+3],a[3]=t[i+4],a[2]=t[i+5],a[1]=t[i+6],a[0]=t[i+7],c[0]}return"undefined"!=typeof Float32Array?(o=new Float32Array([-0]),f=new Uint8Array(o.buffer),h=128===f[3],t.writeFloatLE=h?r:e,t.writeFloatBE=h?e:r,t.readFloatLE=h?s:u,t.readFloatBE=h?u:s):(t.writeFloatLE=i.bind(null,w),t.writeFloatBE=i.bind(null,g),t.readFloatLE=n.bind(null,j),t.readFloatBE=n.bind(null,k)),"undefined"!=typeof Float64Array?(c=new Float64Array([-0]),a=new Uint8Array(c.buffer),l=128===a[7],t.writeDoubleLE=l?b:y,t.writeDoubleBE=l?y:b,t.readDoubleLE=l?p:m,t.readDoubleBE=l?m:p):(t.writeDoubleLE=v.bind(null,w,0,4),t.writeDoubleBE=v.bind(null,g,4,0),t.readDoubleLE=d.bind(null,j,0,4),t.readDoubleBE=d.bind(null,k,4,0)),t}function w(t,i,n){i[n]=255&t,i[n+1]=t>>>8&255,i[n+2]=t>>>16&255,i[n+3]=t>>>24}function g(t,i,n){i[n]=t>>>24,i[n+1]=t>>>16&255,i[n+2]=t>>>8&255,i[n+3]=255&t}function j(t,i){return(t[i]|t[i+1]<<8|t[i+2]<<16|t[i+3]<<24)>>>0}function k(t,i){return(t[i]<<24|t[i+1]<<16|t[i+2]<<8|t[i+3])>>>0}i.exports=n(n)},{}],7:[function(t,i,n){function r(t){try{var i=eval("require")(t);if(i&&(i.length||Object.keys(i).length))return i}catch(t){}return null}i.exports=r},{}],8:[function(t,i,n){var r=n,s=r.isAbsolute=function(t){return/^(?:\/|\w+:)/.test(t)},e=r.normalize=function(t){var i=(t=t.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),n=s(t),r="";n&&(r=i.shift()+"/");for(var e=0;e>>1,u=null,o=e;return function(t){if(t<1||s>10),s[u++]=56320+(1023&r)):s[u++]=(15&r)<<12|(63&t[i++])<<6|63&t[i++],8191>6|192:(55296==(64512&r)&&56320==(64512&(e=t.charCodeAt(u+1)))?(r=65536+((1023&r)<<10)+(1023&e),++u,i[n++]=r>>18|240,i[n++]=r>>12&63|128):i[n++]=r>>12|224,i[n++]=r>>6&63|128),i[n++]=63&r|128);return n-s}},{}],11:[function(t,i,n){var r=n,l=t(14),v=t(33);function u(t,i,n,r){if(i.resolvedType)if(i.resolvedType instanceof l){t("switch(d%s){",r);for(var e=i.resolvedType.values,s=Object.keys(e),u=0;u>>0",r,r);break;case"int32":case"sint32":case"sfixed32":t("m%s=d%s|0",r,r);break;case"uint64":o=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":t("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",r,r,o)('else if(typeof d%s==="string")',r)("m%s=parseInt(d%s,10)",r,r)('else if(typeof d%s==="number")',r)("m%s=d%s",r,r)('else if(typeof d%s==="object")',r)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",r,r,r,o?"true":"");break;case"bytes":t('if(typeof d%s==="string")',r)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",r,r,r)("else if(d%s.length)",r)("m%s=d%s",r,r);break;case"string":t("m%s=String(d%s)",r,r);break;case"bool":t("m%s=Boolean(d%s)",r,r)}}return t}function d(t,i,n,r){if(i.resolvedType)i.resolvedType instanceof l?t("d%s=o.enums===String?types[%i].values[m%s]:m%s",r,n,r,r):t("d%s=types[%i].toObject(m%s,o)",r,n,r);else{var e=!1;switch(i.type){case"double":case"float":t("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",r,r,r,r);break;case"uint64":e=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":t('if(typeof m%s==="number")',r)("d%s=o.longs===String?String(m%s):m%s",r,r,r)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",r,r,r,r,e?"true":"",r);break;case"bytes":t("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",r,r,r,r,r);break;default:t("d%s=m%s",r,r)}}return t}r.fromObject=function(t){var i=t.fieldsArray,n=v.codegen(["d"],t.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!i.length)return n("return new this.ctor");n("var m=new this.ctor");for(var r=0;r>>3){");for(var n=0;n>>3){")("case 1: k=r.%s(); break",r.keyType)("case 2:"),f.basic[e]===g?i("value=types[%i].decode(r,r.uint32())",n):i("value=r.%s()",e),i("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),f.long[r.keyType]!==g?i('%s[typeof k==="object"?util.longToHash(k):k]=value',s):i("%s[k]=value",s)):r.repeated?(i("if(!(%s&&%s.length))",s,s)("%s=[]",s),f.packed[e]!==g&&i("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos>>0,8|c.mapKey[s.keyType],s.keyType),f===g?n("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",u,i):n(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|f,o,i),n("}")("}")):s.repeated?(n("if(%s!=null&&%s.length){",i,i),s.packed&&c.packed[o]!==g?n("w.uint32(%i).fork()",(s.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",i)("w.%s(%s[i])",o,i)("w.ldelim()"):(n("for(var i=0;i<%s.length;++i)",i),f===g?l(n,s,u,i+"[i]"):n("w.uint32(%i).%s(%s[i])",(s.id<<3|f)>>>0,o,i)),n("}")):(s.optional&&n("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",i,s.name),f===g?l(n,s,u,i):n("w.uint32(%i).%s(%s)",(s.id<<3|f)>>>0,o,i))}return n("return w")};var h=t(14),c=t(32),a=t(33);function l(t,i,n,r){return i.resolvedType.group?t("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",n,r,(i.id<<3|3)>>>0,(i.id<<3|4)>>>0):t("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",n,r,(i.id<<3|2)>>>0)}},{14:14,32:32,33:33}],14:[function(t,i){i.exports=e;var o=t(22);((e.prototype=Object.create(o.prototype)).constructor=e).className="Enum";var n=t(21),r=t(33);function e(t,i,n,r,e){if(o.call(this,t,n),i&&"object"!=typeof i)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=r,this.comments=e||{},this.reserved=g,i)for(var s=Object.keys(i),u=0;ui)return!0;return!1},h.isReservedName=function(t,i){if(t)for(var n=0;n "+t.len)}function o(t){this.buf=t,this.pos=0,this.len=t.length}function f(){return r.Buffer?function(t){return(o.create=function(t){return r.Buffer.isBuffer(t)?new n(t):c(t)})(t)}:c}var h,c="undefined"!=typeof Uint8Array?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new o(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new o(t);throw Error("illegal buffer")};function a(){var t=new e(0,0),i=0;if(!(4=this.len)throw u(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*i)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(127&this.buf[this.pos++])<<7*i)>>>0,t}for(;i<4;++i)if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*i)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(127&this.buf[this.pos])<<28)>>>0,t.hi=(t.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return t;if(i=0,4>>0,this.buf[this.pos++]<128)return t}else for(;i<5;++i){if(this.pos>=this.len)throw u(this);if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*i+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}function l(t,i){return(t[i-4]|t[i-3]<<8|t[i-2]<<16|t[i-1]<<24)>>>0}function v(){if(this.pos+8>this.len)throw u(this,8);return new e(l(this.buf,this.pos+=4),l(this.buf,this.pos+=4))}o.create=f(),o.prototype.f=r.Array.prototype.subarray||r.Array.prototype.slice,o.prototype.uint32=(h=4294967295,function(){if(h=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return h;if(h=(h|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return h;if(h=(h|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return h;if(h=(h|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return h;if(h=(h|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return h;if((this.pos+=5)>this.len)throw this.pos=this.len,u(this,10);return h}),o.prototype.int32=function(){return 0|this.uint32()},o.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)|0},o.prototype.bool=function(){return 0!==this.uint32()},o.prototype.fixed32=function(){if(this.pos+4>this.len)throw u(this,4);return l(this.buf,this.pos+=4)},o.prototype.sfixed32=function(){if(this.pos+4>this.len)throw u(this,4);return 0|l(this.buf,this.pos+=4)},o.prototype.float=function(){if(this.pos+4>this.len)throw u(this,4);var t=r.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t},o.prototype.double=function(){if(this.pos+8>this.len)throw u(this,4);var t=r.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t},o.prototype.bytes=function(){var t=this.uint32(),i=this.pos,n=this.pos+t;if(n>this.len)throw u(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(i,n):i===n?new this.buf.constructor(0):this.f.call(this.buf,i,n)},o.prototype.string=function(){var t=this.bytes();return s.read(t,0,t.length)},o.prototype.skip=function(t){if("number"==typeof t){if(this.pos+t>this.len)throw u(this,t);this.pos+=t}else do{if(this.pos>=this.len)throw u(this)}while(128&this.buf[this.pos++]);return this},o.prototype.skipType=function(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(t=7&this.uint32());)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this},o.r=function(t){n=t,o.create=f(),n.r();var i=r.Long?"toLong":"toNumber";r.merge(o.prototype,{int64:function(){return a.call(this)[i](!1)},uint64:function(){return a.call(this)[i](!0)},sint64:function(){return a.call(this).zzDecode()[i](!1)},fixed64:function(){return v.call(this)[i](!0)},sfixed64:function(){return v.call(this)[i](!1)}})}},{35:35}],25:[function(t,i){i.exports=e;var n=t(24);(e.prototype=Object.create(n.prototype)).constructor=e;var r=t(35);function e(t){n.call(this,t)}e.r=function(){r.Buffer&&(e.prototype.f=r.Buffer.prototype.slice)},e.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))},e.r()},{24:24,35:35}],26:[function(t,i){i.exports=n;var r=t(21);((n.prototype=Object.create(r.prototype)).constructor=n).className="Root";var e,v,d,s=t(15),u=t(14),o=t(23),b=t(33);function n(t){r.call(this,"",t),this.deferred=[],this.files=[]}function y(){}n.fromJSON=function(t,i){return i=i||new n,t.options&&i.setOptions(t.options),i.addJSON(t.nested)},n.prototype.resolvePath=b.path.resolve,n.prototype.fetch=b.fetch,n.prototype.load=function t(i,s,e){"function"==typeof s&&(e=s,s=g);var u=this;if(!e)return b.asPromise(t,u,i,s);var o=e===y;function f(t,i){if(e){var n=e;if(e=null,o)throw t;n(t,i)}}function h(t){var i=t.lastIndexOf("google/protobuf/");if(-1>>0,this.hi=i>>>0}var s=e.zero=new e(0,0);s.toNumber=function(){return 0},s.zzEncode=s.zzDecode=function(){return this},s.length=function(){return 1};var r=e.zeroHash="\0\0\0\0\0\0\0\0";e.fromNumber=function(t){if(0===t)return s;var i=t<0;i&&(t=-t);var n=t>>>0,r=(t-n)/4294967296>>>0;return i&&(r=~r>>>0,n=~n>>>0,4294967295<++n&&(n=0,4294967295<++r&&(r=0))),new e(n,r)},e.from=function(t){if("number"==typeof t)return e.fromNumber(t);if(n.isString(t)){if(!n.Long)return e.fromNumber(parseInt(t,10));t=n.Long.fromString(t)}return t.low||t.high?new e(t.low>>>0,t.high>>>0):s},e.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var i=1+~this.lo>>>0,n=~this.hi>>>0;return i||(n=n+1>>>0),-(i+4294967296*n)}return this.lo+4294967296*this.hi},e.prototype.toLong=function(t){return n.Long?new n.Long(0|this.lo,0|this.hi,!!t):{low:0|this.lo,high:0|this.hi,unsigned:!!t}};var u=String.prototype.charCodeAt;e.fromHash=function(t){return t===r?s:new e((u.call(t,0)|u.call(t,1)<<8|u.call(t,2)<<16|u.call(t,3)<<24)>>>0,(u.call(t,4)|u.call(t,5)<<8|u.call(t,6)<<16|u.call(t,7)<<24)>>>0)},e.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},e.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this},e.prototype.zzDecode=function(){var t=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this},e.prototype.length=function(){var t=this.lo,i=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return 0==n?0==i?t<16384?t<128?1:2:t<2097152?3:4:i<16384?i<128?5:6:i<2097152?7:8:n<128?9:10}},{35:35}],35:[function(t,i,n){var r=n;function e(t,i,n){for(var r=Object.keys(i),e=0;e>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;127>>7;i[n++]=t.lo}function b(t,i,n){i[n]=255&t,i[n+1]=t>>>8&255,i[n+2]=t>>>16&255,i[n+3]=t>>>24}c.create=a(),c.alloc=function(t){return new r.Array(t)},r.Array!==Array&&(c.alloc=r.pool(c.alloc,r.Array.prototype.subarray)),c.prototype.y=function(t,i,n){return this.tail=this.tail.next=new o(t,i,n),this.len+=i,this},(v.prototype=Object.create(o.prototype)).fn=function(t,i,n){for(;127>>=7;i[n]=t},c.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new v((t>>>=0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this},c.prototype.int32=function(t){return t<0?this.y(d,10,e.fromNumber(t)):this.uint32(t)},c.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)},c.prototype.int64=c.prototype.uint64=function(t){var i=e.from(t);return this.y(d,i.length(),i)},c.prototype.sint64=function(t){var i=e.from(t).zzEncode();return this.y(d,i.length(),i)},c.prototype.bool=function(t){return this.y(l,1,t?1:0)},c.prototype.sfixed32=c.prototype.fixed32=function(t){return this.y(b,4,t>>>0)},c.prototype.sfixed64=c.prototype.fixed64=function(t){var i=e.from(t);return this.y(b,4,i.lo).y(b,4,i.hi)},c.prototype.float=function(t){return this.y(r.float.writeFloatLE,4,t)},c.prototype.double=function(t){return this.y(r.float.writeDoubleLE,8,t)};var y=r.Array.prototype.set?function(t,i,n){i.set(t,n)}:function(t,i,n){for(var r=0;r>>0;if(!i)return this.y(l,1,0);if(r.isString(t)){var n=c.alloc(i=s.length(t));s.decode(t,n,0),t=n}return this.uint32(i).y(y,i,t)},c.prototype.string=function(t){var i=u.length(t);return i?this.uint32(i).y(u.write,i,t):this.y(l,1,0)},c.prototype.fork=function(){return this.states=new h(this),this.head=this.tail=new o(f,0,0),this.len=0,this},c.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new o(f,0,0),this.len=0),this},c.prototype.ldelim=function(){var t=this.head,i=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=t.next,this.tail=i,this.len+=n),this},c.prototype.finish=function(){for(var t=this.head.next,i=this.constructor.alloc(this.len),n=0;t;)t.fn(t.val,i,n),n+=t.len,t=t.next;return i},c.r=function(t){n=t,c.create=a(),n.r()}},{35:35}],39:[function(t,i){i.exports=e;var n=t(38);(e.prototype=Object.create(n.prototype)).constructor=e;var r=t(35);function e(){n.call(this)}function s(t,i,n){t.length<40?r.utf8.write(t,i,n):i.utf8Write?i.utf8Write(t,n):i.write(t,n)}e.r=function(){e.alloc=r.b,e.writeBytesBuffer=r.Buffer&&r.Buffer.prototype instanceof Uint8Array&&"set"===r.Buffer.prototype.set.name?function(t,i,n){i.set(t,n)}:function(t,i,n){if(t.copy)t.copy(i,n,0,t.length);else for(var r=0;r>>0;return this.uint32(i),i&&this.y(e.writeBytesBuffer,i,t),this},e.prototype.string=function(t){var i=r.Buffer.byteLength(t);return this.uint32(i),i&&this.y(s,i,t),this},e.r()},{35:35,38:38}]},e={},t=[16],i=function t(i){var n=e[i];return n||r[i][0].call(n=e[i]={exports:{}},t,n,n.exports),n.exports}(t[0]),i.util.global.protobuf=i,"function"==typeof define&&define.amd&&define(["long"],function(t){return t&&t.isLong&&(i.util.Long=t,i.configure()),i}),"object"==typeof module&&module&&module.exports&&(module.exports=i)}(); -//# sourceMappingURL=protobuf.min.js.map From bfd9c93e617886d6c1b2f3fb12c1d81564fcead4 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Thu, 31 Dec 2020 16:27:52 +0100 Subject: [PATCH 4/7] Add css-browser-selector as bazel rule, and update from 0.4.0 to 0.6.5 --- ts/css-browser-selector.bzl | 29 +++++++++++++++++++++++++++++ ts/licenses.json | 7 +++++++ ts/package.json | 1 + ts/yarn.lock | 5 +++++ 4 files changed, 42 insertions(+) create mode 100644 ts/css-browser-selector.bzl diff --git a/ts/css-browser-selector.bzl b/ts/css-browser-selector.bzl new file mode 100644 index 000000000..7db733d56 --- /dev/null +++ b/ts/css-browser-selector.bzl @@ -0,0 +1,29 @@ +load("//ts:copy.bzl", "copy_files") + +"Rule to copy css-browser-selector subset from node_modules to vendor folder." + +_include = [ + "css-browser-selector.min.js", +] + +_unwanted_prefix = "external/npm/node_modules/css-browser-selector/" + +def _copy_browsersel(ctx): + wanted = [] + for f in ctx.attr.browsersel.files.to_list(): + path = f.path + want = True + + for substr in _include: + if substr in path: + output = path.replace(_unwanted_prefix, "") + wanted.append((f, output)) + + return copy_files(ctx, wanted) + +copy_browsersel = rule( + implementation = _copy_browsersel_impl, + attrs = { + "browsersel": attr.label(default = "@npm//css-browser-selector:css_browser-selector__files"), + }, +) diff --git a/ts/licenses.json b/ts/licenses.json index 5a37fd249..a78ecf1a0 100644 --- a/ts/licenses.json +++ b/ts/licenses.json @@ -99,6 +99,13 @@ "path": "node_modules/protobufjs/node_modules/@types/node", "licenseFile": "node_modules/protobufjs/node_modules/@types/node/LICENSE" }, + "css-browser-selector@0.6.5": { + "licenses": "CC-BY-SA-2.5", + "repository": "https://github.com/verbatim/css_browser_selector", + "publisher": "Rafael Lima", + "path": "node_modules/css-browser-selector", + "licenseFile": "node_modules/css-browser-selector/README.mkdn" + }, "d3-array@2.9.1": { "licenses": "BSD-3-Clause", "repository": "https://github.com/d3/d3-array", diff --git a/ts/package.json b/ts/package.json index 3f7bdd6d8..d04226ca7 100644 --- a/ts/package.json +++ b/ts/package.json @@ -52,6 +52,7 @@ }, "dependencies": { "@fluent/bundle": "^0.15.1", + "css-browser-selector": "^0.6.5", "d3-array": "^2.8.0", "d3-axis": "^1.0.12", "d3-interpolate": "^1.4.0", diff --git a/ts/yarn.lock b/ts/yarn.lock index db681fd30..89b22551e 100644 --- a/ts/yarn.lock +++ b/ts/yarn.lock @@ -756,6 +756,11 @@ cross-spawn@^7.0.1: shebang-command "^2.0.0" which "^2.0.1" +css-browser-selector@^0.6.5: + version "0.6.5" + resolved "https://registry.yarnpkg.com/css-browser-selector/-/css-browser-selector-0.6.5.tgz#d2b06c01ff7d7cb455e2006b6b6558d39372ca60" + integrity sha1-0rBsAf99fLRV4gBra2VY05NyymA= + csstype@^3.0.2: version "3.0.5" resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.0.5.tgz#7fdec6a28a67ae18647c51668a9ff95bb2fa7bb8" From ebb8171021419bf6ce3e807ffb9861ede285f298 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Thu, 31 Dec 2020 16:41:01 +0100 Subject: [PATCH 5/7] Add css-browser-selector to BAZEL build file in data/web/js/vendor --- qt/aqt/data/web/js/vendor/BUILD.bazel | 7 +++++++ ts/css-browser-selector.bzl | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/qt/aqt/data/web/js/vendor/BUILD.bazel b/qt/aqt/data/web/js/vendor/BUILD.bazel index 99e7ff45f..7f45af741 100644 --- a/qt/aqt/data/web/js/vendor/BUILD.bazel +++ b/qt/aqt/data/web/js/vendor/BUILD.bazel @@ -1,6 +1,7 @@ load("//ts:jquery.bzl", "copy_jquery") load("//ts:jquery-ui.bzl", "copy_jquery_ui") load("//ts:protobufjs.bzl", "copy_protobufjs") +load("//ts:css-browser-selector.bzl", "copy_css_browser_selector") copy_jquery( name = "jquery", @@ -17,11 +18,17 @@ copy_protobufjs( visibility = ["//visibility:public"], ) +copy_css_browser_selector( + name = "css-browser-selector", + visibility = ["//visibility:public"], +) + files = [ "jquery", "jquery-ui", "protobufjs", + "css-browser-selector", ] directories = [ diff --git a/ts/css-browser-selector.bzl b/ts/css-browser-selector.bzl index 7db733d56..ad2c4578b 100644 --- a/ts/css-browser-selector.bzl +++ b/ts/css-browser-selector.bzl @@ -3,14 +3,14 @@ load("//ts:copy.bzl", "copy_files") "Rule to copy css-browser-selector subset from node_modules to vendor folder." _include = [ - "css-browser-selector.min.js", + "css_browser_selector.min.js", ] _unwanted_prefix = "external/npm/node_modules/css-browser-selector/" -def _copy_browsersel(ctx): +def _copy_css_browser_selector_impl(ctx): wanted = [] - for f in ctx.attr.browsersel.files.to_list(): + for f in ctx.attr.css_browser_selector.files.to_list(): path = f.path want = True @@ -21,9 +21,9 @@ def _copy_browsersel(ctx): return copy_files(ctx, wanted) -copy_browsersel = rule( - implementation = _copy_browsersel_impl, +copy_css_browser_selector = rule( + implementation = _copy_css_browser_selector_impl, attrs = { - "browsersel": attr.label(default = "@npm//css-browser-selector:css_browser-selector__files"), + "css_browser_selector": attr.label(default = "@npm//css-browser-selector:css-browser-selector__files"), }, ) From ffc40d89592752c554d3c80526d5eba487029046 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Thu, 31 Dec 2020 16:47:20 +0100 Subject: [PATCH 6/7] Replace browsersel with css-browser-selector in aqt files and add redirect --- qt/aqt/clayout.py | 2 +- qt/aqt/mediasrv.py | 4 ++++ qt/aqt/previewer.py | 2 +- qt/aqt/reviewer.py | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/qt/aqt/clayout.py b/qt/aqt/clayout.py index 9dd79a81e..14a95a39e 100644 --- a/qt/aqt/clayout.py +++ b/qt/aqt/clayout.py @@ -309,7 +309,7 @@ class CardLayout(QDialog): jsinc = [ "js/vendor/jquery.min.js", - "js/vendor/browsersel.js", + "js/vendor/css_browser_selector.min.js", "js/mathjax.js", "js/vendor/mathjax/tex-chtml.js", "js/reviewer.js", diff --git a/qt/aqt/mediasrv.py b/qt/aqt/mediasrv.py index 9749a582c..aecfc79d8 100644 --- a/qt/aqt/mediasrv.py +++ b/qt/aqt/mediasrv.py @@ -201,6 +201,10 @@ def _redirectWebExports(path): base = "jquery-ui.min" addprefix = "js/vendor/" + elif base == "browsersel": + base = "css_browser_selector.min" + addprefix = "js/vendor/" + if addprefix: oldpath = path path = f"{targetPath}{addprefix}{base}{ext}" diff --git a/qt/aqt/previewer.py b/qt/aqt/previewer.py index e5cc3fe3d..7eb60870c 100644 --- a/qt/aqt/previewer.py +++ b/qt/aqt/previewer.py @@ -111,7 +111,7 @@ class Previewer(QDialog): def _setup_web_view(self): jsinc = [ "js/vendor/jquery.min.js", - "js/vendor/browsersel.js", + "js/vendor/css_browser_selector.min.js", "js/mathjax.js", "js/vendor/mathjax/tex-chtml.js", "js/reviewer.js", diff --git a/qt/aqt/reviewer.py b/qt/aqt/reviewer.py index aa0be2508..a5f12e381 100644 --- a/qt/aqt/reviewer.py +++ b/qt/aqt/reviewer.py @@ -159,7 +159,7 @@ class Reviewer: css=["css/reviewer.css"], js=[ "js/vendor/jquery.min.js", - "js/vendor/browsersel.js", + "js/vendor/css_browser_selector.min.js", "js/mathjax.js", "js/vendor/mathjax/tex-chtml.js", "js/reviewer.js", From f31b2312df63563be9d89c993e0bbf24fb2c5e11 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Thu, 31 Dec 2020 16:48:04 +0100 Subject: [PATCH 7/7] Remove browsersel --- qt/aqt/data/web/js/vendor/browsersel.js | 1 - 1 file changed, 1 deletion(-) delete mode 100644 qt/aqt/data/web/js/vendor/browsersel.js diff --git a/qt/aqt/data/web/js/vendor/browsersel.js b/qt/aqt/data/web/js/vendor/browsersel.js deleted file mode 100644 index 9c50762ca..000000000 --- a/qt/aqt/data/web/js/vendor/browsersel.js +++ /dev/null @@ -1 +0,0 @@ -/* CSS Browser Selector v0.4.0 (Nov 02, 2010) Rafael Lima (http://rafael.adm.br). CC BY 2.5. */function css_browser_selector(u){var ua=u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1},g='gecko',w='webkit',s='safari',o='opera',m='mobile',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3.6')?g+' ff3 ff3_6':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('blackberry')?m+' blackberry':is('android')?m+' android':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?m+' j2me':is('iphone')?m+' iphone':is('ipod')?m+' ipod':is('ipad')?m+' ipad':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win'+(is('windows nt 6.0')?' vista':''):is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);