@vitessce/dev 2.0.0-beta.0 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{deflate.498f1fff.mjs → deflate.fd6a2bf5.mjs} +1 -1
- package/dist/{index.3e7f200a.mjs → index.879a4eb2.mjs} +2160 -500
- package/dist/index.js +1 -0
- package/dist/index.mjs +3 -1
- package/dist/index.umd.js +2153 -493
- package/dist/{jpeg.76899aba.mjs → jpeg.da6a1ce7.mjs} +1 -1
- package/dist/{lerc.b63a936e.mjs → lerc.f650c15f.mjs} +1 -1
- package/dist/{lzw.7a63ed8b.mjs → lzw.a7b59c9a.mjs} +1 -1
- package/dist/{packbits.f5da2e5e.mjs → packbits.948b00a6.mjs} +1 -1
- package/dist/{raw.b6ef11f5.mjs → raw.f81790cb.mjs} +1 -1
- package/dist/{webimage.7e22bbfd.mjs → webimage.a23de56d.mjs} +1 -1
- package/package.json +5 -4
|
@@ -833,6 +833,25 @@ const canLoadResolution = (loader2, resolution) => {
|
|
|
833
833
|
const maxSize = maxHeapSize || 2 ** 31 - 1;
|
|
834
834
|
return totalBytes < maxSize && height2 <= 2048 && depthDownsampled <= 2048 && width2 <= 2048 && depthDownsampled > 1;
|
|
835
835
|
};
|
|
836
|
+
const VALUE_TRANSFORM_OPTIONS = [
|
|
837
|
+
{ name: "None", value: null },
|
|
838
|
+
{ name: "Log", value: "log1p" },
|
|
839
|
+
{ name: "ArcSinh", value: "arcsinh" }
|
|
840
|
+
];
|
|
841
|
+
function getValueTransformFunction(featureValueTransform, coefficient) {
|
|
842
|
+
let transformFunction;
|
|
843
|
+
switch (featureValueTransform) {
|
|
844
|
+
case "log1p":
|
|
845
|
+
transformFunction = (v) => Math.log(1 + v * coefficient);
|
|
846
|
+
break;
|
|
847
|
+
case "arcsinh":
|
|
848
|
+
transformFunction = (v) => Math.asinh(v * coefficient);
|
|
849
|
+
break;
|
|
850
|
+
default:
|
|
851
|
+
transformFunction = (v) => v;
|
|
852
|
+
}
|
|
853
|
+
return transformFunction;
|
|
854
|
+
}
|
|
836
855
|
var commonjsGlobal$1 = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
837
856
|
function getDefaultExportFromCjs$1(x2) {
|
|
838
857
|
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
|
|
@@ -858,477 +877,6 @@ function getAugmentedNamespace(n3) {
|
|
|
858
877
|
});
|
|
859
878
|
return a2;
|
|
860
879
|
}
|
|
861
|
-
var lzString = { exports: {} };
|
|
862
|
-
(function(module2) {
|
|
863
|
-
var LZString = function() {
|
|
864
|
-
var f2 = String.fromCharCode;
|
|
865
|
-
var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
866
|
-
var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
|
|
867
|
-
var baseReverseDic = {};
|
|
868
|
-
function getBaseValue(alphabet, character) {
|
|
869
|
-
if (!baseReverseDic[alphabet]) {
|
|
870
|
-
baseReverseDic[alphabet] = {};
|
|
871
|
-
for (var i2 = 0; i2 < alphabet.length; i2++) {
|
|
872
|
-
baseReverseDic[alphabet][alphabet.charAt(i2)] = i2;
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
return baseReverseDic[alphabet][character];
|
|
876
|
-
}
|
|
877
|
-
var LZString2 = {
|
|
878
|
-
compressToBase64: function(input) {
|
|
879
|
-
if (input == null)
|
|
880
|
-
return "";
|
|
881
|
-
var res = LZString2._compress(input, 6, function(a2) {
|
|
882
|
-
return keyStrBase64.charAt(a2);
|
|
883
|
-
});
|
|
884
|
-
switch (res.length % 4) {
|
|
885
|
-
default:
|
|
886
|
-
case 0:
|
|
887
|
-
return res;
|
|
888
|
-
case 1:
|
|
889
|
-
return res + "===";
|
|
890
|
-
case 2:
|
|
891
|
-
return res + "==";
|
|
892
|
-
case 3:
|
|
893
|
-
return res + "=";
|
|
894
|
-
}
|
|
895
|
-
},
|
|
896
|
-
decompressFromBase64: function(input) {
|
|
897
|
-
if (input == null)
|
|
898
|
-
return "";
|
|
899
|
-
if (input == "")
|
|
900
|
-
return null;
|
|
901
|
-
return LZString2._decompress(input.length, 32, function(index2) {
|
|
902
|
-
return getBaseValue(keyStrBase64, input.charAt(index2));
|
|
903
|
-
});
|
|
904
|
-
},
|
|
905
|
-
compressToUTF16: function(input) {
|
|
906
|
-
if (input == null)
|
|
907
|
-
return "";
|
|
908
|
-
return LZString2._compress(input, 15, function(a2) {
|
|
909
|
-
return f2(a2 + 32);
|
|
910
|
-
}) + " ";
|
|
911
|
-
},
|
|
912
|
-
decompressFromUTF16: function(compressed) {
|
|
913
|
-
if (compressed == null)
|
|
914
|
-
return "";
|
|
915
|
-
if (compressed == "")
|
|
916
|
-
return null;
|
|
917
|
-
return LZString2._decompress(compressed.length, 16384, function(index2) {
|
|
918
|
-
return compressed.charCodeAt(index2) - 32;
|
|
919
|
-
});
|
|
920
|
-
},
|
|
921
|
-
compressToUint8Array: function(uncompressed) {
|
|
922
|
-
var compressed = LZString2.compress(uncompressed);
|
|
923
|
-
var buf = new Uint8Array(compressed.length * 2);
|
|
924
|
-
for (var i2 = 0, TotalLen = compressed.length; i2 < TotalLen; i2++) {
|
|
925
|
-
var current_value = compressed.charCodeAt(i2);
|
|
926
|
-
buf[i2 * 2] = current_value >>> 8;
|
|
927
|
-
buf[i2 * 2 + 1] = current_value % 256;
|
|
928
|
-
}
|
|
929
|
-
return buf;
|
|
930
|
-
},
|
|
931
|
-
decompressFromUint8Array: function(compressed) {
|
|
932
|
-
if (compressed === null || compressed === void 0) {
|
|
933
|
-
return LZString2.decompress(compressed);
|
|
934
|
-
} else {
|
|
935
|
-
var buf = new Array(compressed.length / 2);
|
|
936
|
-
for (var i2 = 0, TotalLen = buf.length; i2 < TotalLen; i2++) {
|
|
937
|
-
buf[i2] = compressed[i2 * 2] * 256 + compressed[i2 * 2 + 1];
|
|
938
|
-
}
|
|
939
|
-
var result = [];
|
|
940
|
-
buf.forEach(function(c2) {
|
|
941
|
-
result.push(f2(c2));
|
|
942
|
-
});
|
|
943
|
-
return LZString2.decompress(result.join(""));
|
|
944
|
-
}
|
|
945
|
-
},
|
|
946
|
-
compressToEncodedURIComponent: function(input) {
|
|
947
|
-
if (input == null)
|
|
948
|
-
return "";
|
|
949
|
-
return LZString2._compress(input, 6, function(a2) {
|
|
950
|
-
return keyStrUriSafe.charAt(a2);
|
|
951
|
-
});
|
|
952
|
-
},
|
|
953
|
-
decompressFromEncodedURIComponent: function(input) {
|
|
954
|
-
if (input == null)
|
|
955
|
-
return "";
|
|
956
|
-
if (input == "")
|
|
957
|
-
return null;
|
|
958
|
-
input = input.replace(/ /g, "+");
|
|
959
|
-
return LZString2._decompress(input.length, 32, function(index2) {
|
|
960
|
-
return getBaseValue(keyStrUriSafe, input.charAt(index2));
|
|
961
|
-
});
|
|
962
|
-
},
|
|
963
|
-
compress: function(uncompressed) {
|
|
964
|
-
return LZString2._compress(uncompressed, 16, function(a2) {
|
|
965
|
-
return f2(a2);
|
|
966
|
-
});
|
|
967
|
-
},
|
|
968
|
-
_compress: function(uncompressed, bitsPerChar, getCharFromInt) {
|
|
969
|
-
if (uncompressed == null)
|
|
970
|
-
return "";
|
|
971
|
-
var i2, value2, context_dictionary = {}, context_dictionaryToCreate = {}, context_c = "", context_wc = "", context_w = "", context_enlargeIn = 2, context_dictSize = 3, context_numBits = 2, context_data = [], context_data_val = 0, context_data_position = 0, ii;
|
|
972
|
-
for (ii = 0; ii < uncompressed.length; ii += 1) {
|
|
973
|
-
context_c = uncompressed.charAt(ii);
|
|
974
|
-
if (!Object.prototype.hasOwnProperty.call(context_dictionary, context_c)) {
|
|
975
|
-
context_dictionary[context_c] = context_dictSize++;
|
|
976
|
-
context_dictionaryToCreate[context_c] = true;
|
|
977
|
-
}
|
|
978
|
-
context_wc = context_w + context_c;
|
|
979
|
-
if (Object.prototype.hasOwnProperty.call(context_dictionary, context_wc)) {
|
|
980
|
-
context_w = context_wc;
|
|
981
|
-
} else {
|
|
982
|
-
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
|
|
983
|
-
if (context_w.charCodeAt(0) < 256) {
|
|
984
|
-
for (i2 = 0; i2 < context_numBits; i2++) {
|
|
985
|
-
context_data_val = context_data_val << 1;
|
|
986
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
987
|
-
context_data_position = 0;
|
|
988
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
989
|
-
context_data_val = 0;
|
|
990
|
-
} else {
|
|
991
|
-
context_data_position++;
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
value2 = context_w.charCodeAt(0);
|
|
995
|
-
for (i2 = 0; i2 < 8; i2++) {
|
|
996
|
-
context_data_val = context_data_val << 1 | value2 & 1;
|
|
997
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
998
|
-
context_data_position = 0;
|
|
999
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
1000
|
-
context_data_val = 0;
|
|
1001
|
-
} else {
|
|
1002
|
-
context_data_position++;
|
|
1003
|
-
}
|
|
1004
|
-
value2 = value2 >> 1;
|
|
1005
|
-
}
|
|
1006
|
-
} else {
|
|
1007
|
-
value2 = 1;
|
|
1008
|
-
for (i2 = 0; i2 < context_numBits; i2++) {
|
|
1009
|
-
context_data_val = context_data_val << 1 | value2;
|
|
1010
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
1011
|
-
context_data_position = 0;
|
|
1012
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
1013
|
-
context_data_val = 0;
|
|
1014
|
-
} else {
|
|
1015
|
-
context_data_position++;
|
|
1016
|
-
}
|
|
1017
|
-
value2 = 0;
|
|
1018
|
-
}
|
|
1019
|
-
value2 = context_w.charCodeAt(0);
|
|
1020
|
-
for (i2 = 0; i2 < 16; i2++) {
|
|
1021
|
-
context_data_val = context_data_val << 1 | value2 & 1;
|
|
1022
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
1023
|
-
context_data_position = 0;
|
|
1024
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
1025
|
-
context_data_val = 0;
|
|
1026
|
-
} else {
|
|
1027
|
-
context_data_position++;
|
|
1028
|
-
}
|
|
1029
|
-
value2 = value2 >> 1;
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
context_enlargeIn--;
|
|
1033
|
-
if (context_enlargeIn == 0) {
|
|
1034
|
-
context_enlargeIn = Math.pow(2, context_numBits);
|
|
1035
|
-
context_numBits++;
|
|
1036
|
-
}
|
|
1037
|
-
delete context_dictionaryToCreate[context_w];
|
|
1038
|
-
} else {
|
|
1039
|
-
value2 = context_dictionary[context_w];
|
|
1040
|
-
for (i2 = 0; i2 < context_numBits; i2++) {
|
|
1041
|
-
context_data_val = context_data_val << 1 | value2 & 1;
|
|
1042
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
1043
|
-
context_data_position = 0;
|
|
1044
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
1045
|
-
context_data_val = 0;
|
|
1046
|
-
} else {
|
|
1047
|
-
context_data_position++;
|
|
1048
|
-
}
|
|
1049
|
-
value2 = value2 >> 1;
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
context_enlargeIn--;
|
|
1053
|
-
if (context_enlargeIn == 0) {
|
|
1054
|
-
context_enlargeIn = Math.pow(2, context_numBits);
|
|
1055
|
-
context_numBits++;
|
|
1056
|
-
}
|
|
1057
|
-
context_dictionary[context_wc] = context_dictSize++;
|
|
1058
|
-
context_w = String(context_c);
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
if (context_w !== "") {
|
|
1062
|
-
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
|
|
1063
|
-
if (context_w.charCodeAt(0) < 256) {
|
|
1064
|
-
for (i2 = 0; i2 < context_numBits; i2++) {
|
|
1065
|
-
context_data_val = context_data_val << 1;
|
|
1066
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
1067
|
-
context_data_position = 0;
|
|
1068
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
1069
|
-
context_data_val = 0;
|
|
1070
|
-
} else {
|
|
1071
|
-
context_data_position++;
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
value2 = context_w.charCodeAt(0);
|
|
1075
|
-
for (i2 = 0; i2 < 8; i2++) {
|
|
1076
|
-
context_data_val = context_data_val << 1 | value2 & 1;
|
|
1077
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
1078
|
-
context_data_position = 0;
|
|
1079
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
1080
|
-
context_data_val = 0;
|
|
1081
|
-
} else {
|
|
1082
|
-
context_data_position++;
|
|
1083
|
-
}
|
|
1084
|
-
value2 = value2 >> 1;
|
|
1085
|
-
}
|
|
1086
|
-
} else {
|
|
1087
|
-
value2 = 1;
|
|
1088
|
-
for (i2 = 0; i2 < context_numBits; i2++) {
|
|
1089
|
-
context_data_val = context_data_val << 1 | value2;
|
|
1090
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
1091
|
-
context_data_position = 0;
|
|
1092
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
1093
|
-
context_data_val = 0;
|
|
1094
|
-
} else {
|
|
1095
|
-
context_data_position++;
|
|
1096
|
-
}
|
|
1097
|
-
value2 = 0;
|
|
1098
|
-
}
|
|
1099
|
-
value2 = context_w.charCodeAt(0);
|
|
1100
|
-
for (i2 = 0; i2 < 16; i2++) {
|
|
1101
|
-
context_data_val = context_data_val << 1 | value2 & 1;
|
|
1102
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
1103
|
-
context_data_position = 0;
|
|
1104
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
1105
|
-
context_data_val = 0;
|
|
1106
|
-
} else {
|
|
1107
|
-
context_data_position++;
|
|
1108
|
-
}
|
|
1109
|
-
value2 = value2 >> 1;
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
context_enlargeIn--;
|
|
1113
|
-
if (context_enlargeIn == 0) {
|
|
1114
|
-
context_enlargeIn = Math.pow(2, context_numBits);
|
|
1115
|
-
context_numBits++;
|
|
1116
|
-
}
|
|
1117
|
-
delete context_dictionaryToCreate[context_w];
|
|
1118
|
-
} else {
|
|
1119
|
-
value2 = context_dictionary[context_w];
|
|
1120
|
-
for (i2 = 0; i2 < context_numBits; i2++) {
|
|
1121
|
-
context_data_val = context_data_val << 1 | value2 & 1;
|
|
1122
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
1123
|
-
context_data_position = 0;
|
|
1124
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
1125
|
-
context_data_val = 0;
|
|
1126
|
-
} else {
|
|
1127
|
-
context_data_position++;
|
|
1128
|
-
}
|
|
1129
|
-
value2 = value2 >> 1;
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
context_enlargeIn--;
|
|
1133
|
-
if (context_enlargeIn == 0) {
|
|
1134
|
-
context_enlargeIn = Math.pow(2, context_numBits);
|
|
1135
|
-
context_numBits++;
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
value2 = 2;
|
|
1139
|
-
for (i2 = 0; i2 < context_numBits; i2++) {
|
|
1140
|
-
context_data_val = context_data_val << 1 | value2 & 1;
|
|
1141
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
1142
|
-
context_data_position = 0;
|
|
1143
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
1144
|
-
context_data_val = 0;
|
|
1145
|
-
} else {
|
|
1146
|
-
context_data_position++;
|
|
1147
|
-
}
|
|
1148
|
-
value2 = value2 >> 1;
|
|
1149
|
-
}
|
|
1150
|
-
while (true) {
|
|
1151
|
-
context_data_val = context_data_val << 1;
|
|
1152
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
1153
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
1154
|
-
break;
|
|
1155
|
-
} else
|
|
1156
|
-
context_data_position++;
|
|
1157
|
-
}
|
|
1158
|
-
return context_data.join("");
|
|
1159
|
-
},
|
|
1160
|
-
decompress: function(compressed) {
|
|
1161
|
-
if (compressed == null)
|
|
1162
|
-
return "";
|
|
1163
|
-
if (compressed == "")
|
|
1164
|
-
return null;
|
|
1165
|
-
return LZString2._decompress(compressed.length, 32768, function(index2) {
|
|
1166
|
-
return compressed.charCodeAt(index2);
|
|
1167
|
-
});
|
|
1168
|
-
},
|
|
1169
|
-
_decompress: function(length2, resetValue, getNextValue) {
|
|
1170
|
-
var dictionary = [], enlargeIn = 4, dictSize = 4, numBits = 3, entry2 = "", result = [], i2, w2, bits, resb, maxpower, power, c2, data2 = { val: getNextValue(0), position: resetValue, index: 1 };
|
|
1171
|
-
for (i2 = 0; i2 < 3; i2 += 1) {
|
|
1172
|
-
dictionary[i2] = i2;
|
|
1173
|
-
}
|
|
1174
|
-
bits = 0;
|
|
1175
|
-
maxpower = Math.pow(2, 2);
|
|
1176
|
-
power = 1;
|
|
1177
|
-
while (power != maxpower) {
|
|
1178
|
-
resb = data2.val & data2.position;
|
|
1179
|
-
data2.position >>= 1;
|
|
1180
|
-
if (data2.position == 0) {
|
|
1181
|
-
data2.position = resetValue;
|
|
1182
|
-
data2.val = getNextValue(data2.index++);
|
|
1183
|
-
}
|
|
1184
|
-
bits |= (resb > 0 ? 1 : 0) * power;
|
|
1185
|
-
power <<= 1;
|
|
1186
|
-
}
|
|
1187
|
-
switch (bits) {
|
|
1188
|
-
case 0:
|
|
1189
|
-
bits = 0;
|
|
1190
|
-
maxpower = Math.pow(2, 8);
|
|
1191
|
-
power = 1;
|
|
1192
|
-
while (power != maxpower) {
|
|
1193
|
-
resb = data2.val & data2.position;
|
|
1194
|
-
data2.position >>= 1;
|
|
1195
|
-
if (data2.position == 0) {
|
|
1196
|
-
data2.position = resetValue;
|
|
1197
|
-
data2.val = getNextValue(data2.index++);
|
|
1198
|
-
}
|
|
1199
|
-
bits |= (resb > 0 ? 1 : 0) * power;
|
|
1200
|
-
power <<= 1;
|
|
1201
|
-
}
|
|
1202
|
-
c2 = f2(bits);
|
|
1203
|
-
break;
|
|
1204
|
-
case 1:
|
|
1205
|
-
bits = 0;
|
|
1206
|
-
maxpower = Math.pow(2, 16);
|
|
1207
|
-
power = 1;
|
|
1208
|
-
while (power != maxpower) {
|
|
1209
|
-
resb = data2.val & data2.position;
|
|
1210
|
-
data2.position >>= 1;
|
|
1211
|
-
if (data2.position == 0) {
|
|
1212
|
-
data2.position = resetValue;
|
|
1213
|
-
data2.val = getNextValue(data2.index++);
|
|
1214
|
-
}
|
|
1215
|
-
bits |= (resb > 0 ? 1 : 0) * power;
|
|
1216
|
-
power <<= 1;
|
|
1217
|
-
}
|
|
1218
|
-
c2 = f2(bits);
|
|
1219
|
-
break;
|
|
1220
|
-
case 2:
|
|
1221
|
-
return "";
|
|
1222
|
-
}
|
|
1223
|
-
dictionary[3] = c2;
|
|
1224
|
-
w2 = c2;
|
|
1225
|
-
result.push(c2);
|
|
1226
|
-
while (true) {
|
|
1227
|
-
if (data2.index > length2) {
|
|
1228
|
-
return "";
|
|
1229
|
-
}
|
|
1230
|
-
bits = 0;
|
|
1231
|
-
maxpower = Math.pow(2, numBits);
|
|
1232
|
-
power = 1;
|
|
1233
|
-
while (power != maxpower) {
|
|
1234
|
-
resb = data2.val & data2.position;
|
|
1235
|
-
data2.position >>= 1;
|
|
1236
|
-
if (data2.position == 0) {
|
|
1237
|
-
data2.position = resetValue;
|
|
1238
|
-
data2.val = getNextValue(data2.index++);
|
|
1239
|
-
}
|
|
1240
|
-
bits |= (resb > 0 ? 1 : 0) * power;
|
|
1241
|
-
power <<= 1;
|
|
1242
|
-
}
|
|
1243
|
-
switch (c2 = bits) {
|
|
1244
|
-
case 0:
|
|
1245
|
-
bits = 0;
|
|
1246
|
-
maxpower = Math.pow(2, 8);
|
|
1247
|
-
power = 1;
|
|
1248
|
-
while (power != maxpower) {
|
|
1249
|
-
resb = data2.val & data2.position;
|
|
1250
|
-
data2.position >>= 1;
|
|
1251
|
-
if (data2.position == 0) {
|
|
1252
|
-
data2.position = resetValue;
|
|
1253
|
-
data2.val = getNextValue(data2.index++);
|
|
1254
|
-
}
|
|
1255
|
-
bits |= (resb > 0 ? 1 : 0) * power;
|
|
1256
|
-
power <<= 1;
|
|
1257
|
-
}
|
|
1258
|
-
dictionary[dictSize++] = f2(bits);
|
|
1259
|
-
c2 = dictSize - 1;
|
|
1260
|
-
enlargeIn--;
|
|
1261
|
-
break;
|
|
1262
|
-
case 1:
|
|
1263
|
-
bits = 0;
|
|
1264
|
-
maxpower = Math.pow(2, 16);
|
|
1265
|
-
power = 1;
|
|
1266
|
-
while (power != maxpower) {
|
|
1267
|
-
resb = data2.val & data2.position;
|
|
1268
|
-
data2.position >>= 1;
|
|
1269
|
-
if (data2.position == 0) {
|
|
1270
|
-
data2.position = resetValue;
|
|
1271
|
-
data2.val = getNextValue(data2.index++);
|
|
1272
|
-
}
|
|
1273
|
-
bits |= (resb > 0 ? 1 : 0) * power;
|
|
1274
|
-
power <<= 1;
|
|
1275
|
-
}
|
|
1276
|
-
dictionary[dictSize++] = f2(bits);
|
|
1277
|
-
c2 = dictSize - 1;
|
|
1278
|
-
enlargeIn--;
|
|
1279
|
-
break;
|
|
1280
|
-
case 2:
|
|
1281
|
-
return result.join("");
|
|
1282
|
-
}
|
|
1283
|
-
if (enlargeIn == 0) {
|
|
1284
|
-
enlargeIn = Math.pow(2, numBits);
|
|
1285
|
-
numBits++;
|
|
1286
|
-
}
|
|
1287
|
-
if (dictionary[c2]) {
|
|
1288
|
-
entry2 = dictionary[c2];
|
|
1289
|
-
} else {
|
|
1290
|
-
if (c2 === dictSize) {
|
|
1291
|
-
entry2 = w2 + w2.charAt(0);
|
|
1292
|
-
} else {
|
|
1293
|
-
return null;
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
result.push(entry2);
|
|
1297
|
-
dictionary[dictSize++] = w2 + entry2.charAt(0);
|
|
1298
|
-
enlargeIn--;
|
|
1299
|
-
w2 = entry2;
|
|
1300
|
-
if (enlargeIn == 0) {
|
|
1301
|
-
enlargeIn = Math.pow(2, numBits);
|
|
1302
|
-
numBits++;
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
};
|
|
1307
|
-
return LZString2;
|
|
1308
|
-
}();
|
|
1309
|
-
if (module2 != null) {
|
|
1310
|
-
module2.exports = LZString;
|
|
1311
|
-
}
|
|
1312
|
-
})(lzString);
|
|
1313
|
-
const VALUE_TRANSFORM_OPTIONS = [
|
|
1314
|
-
{ name: "None", value: null },
|
|
1315
|
-
{ name: "Log", value: "log1p" },
|
|
1316
|
-
{ name: "ArcSinh", value: "arcsinh" }
|
|
1317
|
-
];
|
|
1318
|
-
function getValueTransformFunction(featureValueTransform, coefficient) {
|
|
1319
|
-
let transformFunction;
|
|
1320
|
-
switch (featureValueTransform) {
|
|
1321
|
-
case "log1p":
|
|
1322
|
-
transformFunction = (v) => Math.log(1 + v * coefficient);
|
|
1323
|
-
break;
|
|
1324
|
-
case "arcsinh":
|
|
1325
|
-
transformFunction = (v) => Math.asinh(v * coefficient);
|
|
1326
|
-
break;
|
|
1327
|
-
default:
|
|
1328
|
-
transformFunction = (v) => v;
|
|
1329
|
-
}
|
|
1330
|
-
return transformFunction;
|
|
1331
|
-
}
|
|
1332
880
|
var rngBrowser = { exports: {} };
|
|
1333
881
|
var getRandomValues$1 = typeof crypto != "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto != "undefined" && typeof window.msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto);
|
|
1334
882
|
if (getRandomValues$1) {
|
|
@@ -60017,7 +59565,7 @@ var json2csv_umd = { exports: {} };
|
|
|
60017
59565
|
var CARRIAGE_RETURN = "\r".charCodeAt(0);
|
|
60018
59566
|
var TAB = " ".charCodeAt(0);
|
|
60019
59567
|
var STRING_BUFFER_SIZE = 64 * 1024;
|
|
60020
|
-
function
|
|
59568
|
+
function Parser2() {
|
|
60021
59569
|
this.tState = START;
|
|
60022
59570
|
this.value = void 0;
|
|
60023
59571
|
this.string = void 0;
|
|
@@ -60034,7 +59582,7 @@ var json2csv_umd = { exports: {} };
|
|
|
60034
59582
|
this.temp_buffs = { "2": new Buffer2(2), "3": new Buffer2(3), "4": new Buffer2(4) };
|
|
60035
59583
|
this.offset = -1;
|
|
60036
59584
|
}
|
|
60037
|
-
|
|
59585
|
+
Parser2.toknam = function(code) {
|
|
60038
59586
|
var keys5 = Object.keys(C3);
|
|
60039
59587
|
for (var i2 = 0, l2 = keys5.length; i2 < l2; i2++) {
|
|
60040
59588
|
var key2 = keys5[i2];
|
|
@@ -60044,13 +59592,13 @@ var json2csv_umd = { exports: {} };
|
|
|
60044
59592
|
}
|
|
60045
59593
|
return code && "0x" + code.toString(16);
|
|
60046
59594
|
};
|
|
60047
|
-
var proto =
|
|
59595
|
+
var proto = Parser2.prototype;
|
|
60048
59596
|
proto.onError = function(err2) {
|
|
60049
59597
|
throw err2;
|
|
60050
59598
|
};
|
|
60051
59599
|
proto.charError = function(buffer2, i2) {
|
|
60052
59600
|
this.tState = STOP;
|
|
60053
|
-
this.onError(new Error("Unexpected " + JSON.stringify(String.fromCharCode(buffer2[i2])) + " at position " + i2 + " in state " +
|
|
59601
|
+
this.onError(new Error("Unexpected " + JSON.stringify(String.fromCharCode(buffer2[i2])) + " at position " + i2 + " in state " + Parser2.toknam(this.tState)));
|
|
60054
59602
|
};
|
|
60055
59603
|
proto.appendStringChar = function(char) {
|
|
60056
59604
|
if (this.stringBufferOffset >= STRING_BUFFER_SIZE) {
|
|
@@ -60136,7 +59684,7 @@ var json2csv_umd = { exports: {} };
|
|
|
60136
59684
|
i2 = i2 + j - 1;
|
|
60137
59685
|
} else if (this.bytes_remaining === 0 && n3 >= 128) {
|
|
60138
59686
|
if (n3 <= 193 || n3 > 244) {
|
|
60139
|
-
return this.onError(new Error("Invalid UTF-8 character at position " + i2 + " in state " +
|
|
59687
|
+
return this.onError(new Error("Invalid UTF-8 character at position " + i2 + " in state " + Parser2.toknam(this.tState)));
|
|
60140
59688
|
}
|
|
60141
59689
|
if (n3 >= 194 && n3 <= 223)
|
|
60142
59690
|
this.bytes_in_sequence = 2;
|
|
@@ -60334,7 +59882,7 @@ var json2csv_umd = { exports: {} };
|
|
|
60334
59882
|
};
|
|
60335
59883
|
proto.parseError = function(token, value2) {
|
|
60336
59884
|
this.tState = STOP;
|
|
60337
|
-
this.onError(new Error("Unexpected " +
|
|
59885
|
+
this.onError(new Error("Unexpected " + Parser2.toknam(token) + (value2 ? "(" + JSON.stringify(value2) + ")" : "") + " in state " + Parser2.toknam(this.state)));
|
|
60338
59886
|
};
|
|
60339
59887
|
proto.push = function() {
|
|
60340
59888
|
this.stack.push({ value: this.value, key: this.key, mode: this.mode });
|
|
@@ -60432,8 +59980,8 @@ var json2csv_umd = { exports: {} };
|
|
|
60432
59980
|
return this.parseError(token, value2);
|
|
60433
59981
|
}
|
|
60434
59982
|
};
|
|
60435
|
-
|
|
60436
|
-
var jsonparse =
|
|
59983
|
+
Parser2.C = C3;
|
|
59984
|
+
var jsonparse = Parser2;
|
|
60437
59985
|
var Transform$12 = Stream.Transform;
|
|
60438
59986
|
var JSON2CSVTransform = /* @__PURE__ */ function(_Transform) {
|
|
60439
59987
|
_inherits2(JSON2CSVTransform2, _Transform);
|
|
@@ -181080,16 +180628,16 @@ async function getDecoder(fileDirectory) {
|
|
|
181080
180628
|
const Decoder = await importFn();
|
|
181081
180629
|
return new Decoder(fileDirectory);
|
|
181082
180630
|
}
|
|
181083
|
-
addDecoder([void 0, 1], () => import("./raw.
|
|
181084
|
-
addDecoder(5, () => import("./lzw.
|
|
180631
|
+
addDecoder([void 0, 1], () => import("./raw.f81790cb.mjs").then((m2) => m2.default));
|
|
180632
|
+
addDecoder(5, () => import("./lzw.a7b59c9a.mjs").then((m2) => m2.default));
|
|
181085
180633
|
addDecoder(6, () => {
|
|
181086
180634
|
throw new Error("old style JPEG compression is not supported.");
|
|
181087
180635
|
});
|
|
181088
|
-
addDecoder(7, () => import("./jpeg.
|
|
181089
|
-
addDecoder([8, 32946], () => import("./deflate.
|
|
181090
|
-
addDecoder(32773, () => import("./packbits.
|
|
181091
|
-
addDecoder(34887, () => import("./lerc.
|
|
181092
|
-
addDecoder(50001, () => import("./webimage.
|
|
180636
|
+
addDecoder(7, () => import("./jpeg.da6a1ce7.mjs").then((m2) => m2.default));
|
|
180637
|
+
addDecoder([8, 32946], () => import("./deflate.fd6a2bf5.mjs").then((m2) => m2.default));
|
|
180638
|
+
addDecoder(32773, () => import("./packbits.948b00a6.mjs").then((m2) => m2.default));
|
|
180639
|
+
addDecoder(34887, () => import("./lerc.f650c15f.mjs").then((m2) => m2.default));
|
|
180640
|
+
addDecoder(50001, () => import("./webimage.a23de56d.mjs").then((m2) => m2.default));
|
|
181093
180641
|
function copyNewSize(array2, width2, height2, samplesPerPixel = 1) {
|
|
181094
180642
|
return new (Object.getPrototypeOf(array2)).constructor(width2 * height2 * samplesPerPixel);
|
|
181095
180643
|
}
|
|
@@ -184559,7 +184107,7 @@ function requireJson2xml() {
|
|
|
184559
184107
|
"attrValueProcessor",
|
|
184560
184108
|
"rootNodeName"
|
|
184561
184109
|
];
|
|
184562
|
-
function
|
|
184110
|
+
function Parser2(options) {
|
|
184563
184111
|
this.options = buildOptions2(options, defaultOptions2, props2);
|
|
184564
184112
|
if (this.options.ignoreAttributes || this.options.attrNodeName) {
|
|
184565
184113
|
this.isAttribute = function() {
|
|
@@ -184600,7 +184148,7 @@ function requireJson2xml() {
|
|
|
184600
184148
|
this.buildTextValNode = buildTextValNode;
|
|
184601
184149
|
this.buildObjectNode = buildObjectNode;
|
|
184602
184150
|
}
|
|
184603
|
-
|
|
184151
|
+
Parser2.prototype.parse = function(jObj) {
|
|
184604
184152
|
if (Array.isArray(jObj) && this.options.rootNodeName && this.options.rootNodeName.length > 1) {
|
|
184605
184153
|
jObj = {
|
|
184606
184154
|
[this.options.rootNodeName]: jObj
|
|
@@ -184608,7 +184156,7 @@ function requireJson2xml() {
|
|
|
184608
184156
|
}
|
|
184609
184157
|
return this.j2x(jObj, 0).val;
|
|
184610
184158
|
};
|
|
184611
|
-
|
|
184159
|
+
Parser2.prototype.j2x = function(jObj, level) {
|
|
184612
184160
|
let attrStr = "";
|
|
184613
184161
|
let val = "";
|
|
184614
184162
|
for (let key2 in jObj) {
|
|
@@ -184740,7 +184288,7 @@ function requireJson2xml() {
|
|
|
184740
184288
|
function isCDATA(name2) {
|
|
184741
184289
|
return name2 === this.options.cdataTagName;
|
|
184742
184290
|
}
|
|
184743
|
-
json2xml =
|
|
184291
|
+
json2xml = Parser2;
|
|
184744
184292
|
return json2xml;
|
|
184745
184293
|
}
|
|
184746
184294
|
(function(exports) {
|
|
@@ -210742,7 +210290,8 @@ function SpatialSubscriber(props2) {
|
|
|
210742
210290
|
const [width2, height2, deckRef] = useDeckCanvasSize();
|
|
210743
210291
|
const [obsLabelsTypes, obsLabelsData] = useMultiObsLabels(coordinationScopes, obsType, loaders, dataset, addUrl2);
|
|
210744
210292
|
const hasExpressionData = useHasLoader(loaders, dataset, DataType$3.OBS_FEATURE_MATRIX, { obsType, featureType, featureValueType });
|
|
210745
|
-
const
|
|
210293
|
+
const hasSegmentationsData = useHasLoader(loaders, dataset, DataType$3.OBS_SEGMENTATIONS, { obsType });
|
|
210294
|
+
const hasLocationsData = useHasLoader(loaders, dataset, DataType$3.OBS_LOCATIONS, { obsType });
|
|
210746
210295
|
const hasImageData = useHasLoader(loaders, dataset, DataType$3.IMAGE, {});
|
|
210747
210296
|
const [{ obsIndex: obsLocationsIndex, obsLocations }, obsLocationsStatus] = useObsLocationsData(loaders, dataset, addUrl2, false, { setSpatialPointLayer: setMoleculesLayer }, { spatialPointLayer: moleculesLayer }, { obsType: "molecule" });
|
|
210748
210297
|
const [{ obsLabels: obsLocationsLabels }, obsLabelsStatus] = useObsLabelsData(loaders, dataset, addUrl2, false, {}, {}, { obsType: "molecule" });
|
|
@@ -210864,7 +210413,7 @@ function SpatialSubscriber(props2) {
|
|
|
210864
210413
|
locationsCount
|
|
210865
210414
|
});
|
|
210866
210415
|
const getExpressionValue = useExpressionValueGetter({
|
|
210867
|
-
instanceObsIndex: obsSegmentationsIndex,
|
|
210416
|
+
instanceObsIndex: obsSegmentationsIndex ? obsSegmentationsIndex : obsCentroidsIndex,
|
|
210868
210417
|
matrixObsIndex,
|
|
210869
210418
|
expressionData
|
|
210870
210419
|
});
|
|
@@ -210874,7 +210423,7 @@ function SpatialSubscriber(props2) {
|
|
|
210874
210423
|
const canShow3DOptions = canLoad3DLayers && !((disable3d == null ? void 0 : disable3d.length) === imageLayerLoaders.length) && !globalDisable3d;
|
|
210875
210424
|
const options = useMemo(() => {
|
|
210876
210425
|
if (canShow3DOptions || hasExpressionData) {
|
|
210877
|
-
return jsx(SpatialOptions, { observationsLabel, cellColorEncoding, setCellColorEncoding, setSpatialAxisFixed, spatialAxisFixed, use3d, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange, canShowExpressionOptions: hasExpressionData, canShowColorEncodingOption:
|
|
210426
|
+
return jsx(SpatialOptions, { observationsLabel, cellColorEncoding, setCellColorEncoding, setSpatialAxisFixed, spatialAxisFixed, use3d, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange, canShowExpressionOptions: hasExpressionData, canShowColorEncodingOption: (hasLocationsData || hasSegmentationsData) && hasExpressionData, canShow3DOptions });
|
|
210878
210427
|
}
|
|
210879
210428
|
return null;
|
|
210880
210429
|
}, [
|
|
@@ -210883,7 +210432,8 @@ function SpatialSubscriber(props2) {
|
|
|
210883
210432
|
geneExpressionColormap,
|
|
210884
210433
|
geneExpressionColormapRange,
|
|
210885
210434
|
setGeneExpressionColormap,
|
|
210886
|
-
|
|
210435
|
+
hasLocationsData,
|
|
210436
|
+
hasSegmentationsData,
|
|
210887
210437
|
hasExpressionData,
|
|
210888
210438
|
observationsLabel,
|
|
210889
210439
|
setCellColorEncoding,
|
|
@@ -210893,11 +210443,11 @@ function SpatialSubscriber(props2) {
|
|
|
210893
210443
|
use3d
|
|
210894
210444
|
]);
|
|
210895
210445
|
useEffect(() => {
|
|
210896
|
-
if (!
|
|
210446
|
+
if (!hasSegmentationsData && cellsLayer && !obsSegmentations && !obsSegmentationsIndex && obsCentroids && obsCentroidsIndex) {
|
|
210897
210447
|
console.warn("Rendering cell segmentation diamonds for backwards compatibility.");
|
|
210898
210448
|
}
|
|
210899
210449
|
}, [
|
|
210900
|
-
|
|
210450
|
+
hasSegmentationsData,
|
|
210901
210451
|
cellsLayer,
|
|
210902
210452
|
obsSegmentations,
|
|
210903
210453
|
obsSegmentationsIndex,
|
|
@@ -210912,7 +210462,7 @@ function SpatialSubscriber(props2) {
|
|
|
210912
210462
|
rotationZ,
|
|
210913
210463
|
rotationOrbit,
|
|
210914
210464
|
orbitAxis
|
|
210915
|
-
}, setViewState, imageLayerDefs: imageLayers, obsSegmentationsLayerDefs: cellsLayer, obsLocationsLayerDefs: moleculesLayer, neighborhoodLayerDefs: neighborhoodsLayer, obsLocationsIndex, obsSegmentationsIndex, obsLocations, obsLocationsLabels, obsLocationsFeatureIndex, hasSegmentations:
|
|
210465
|
+
}, setViewState, imageLayerDefs: imageLayers, obsSegmentationsLayerDefs: cellsLayer, obsLocationsLayerDefs: moleculesLayer, neighborhoodLayerDefs: neighborhoodsLayer, obsLocationsIndex, obsSegmentationsIndex, obsLocations, obsLocationsLabels, obsLocationsFeatureIndex, hasSegmentations: hasSegmentationsData, obsSegmentations, obsSegmentationsType, obsCentroids, obsCentroidsIndex, cellFilter, cellSelection, cellHighlight, cellColors, neighborhoods, imageLayerLoaders, setCellFilter, setCellSelection: setCellSelectionProp, setCellHighlight, setMoleculeHighlight, setComponentHover: () => {
|
|
210916
210466
|
setComponentHover(uuid);
|
|
210917
210467
|
}, updateViewInfo: setComponentViewInfo, imageLayerCallbacks, segmentationLayerCallbacks, spatialAxisFixed, geneExpressionColormap, geneExpressionColormapRange, expressionData: shiftedExpressionDataForBitmask, cellColorEncoding, getExpressionValue, theme }), !disableTooltip && jsx(SpatialTooltipSubscriber, { parentUuid: uuid, obsHighlight: cellHighlight, width: width2, height: height2, getObsInfo })] });
|
|
210918
210468
|
}
|
|
@@ -272226,7 +271776,7 @@ function CellSetExpressionPlot(props2) {
|
|
|
272226
271776
|
orient: "left",
|
|
272227
271777
|
scale: "yscale",
|
|
272228
271778
|
zindex: 1,
|
|
272229
|
-
title: featureValueTransformName ? [`${featureValueTransformName}-Transformed`, `Normalized ${capitalize$2(featureValueType)} Values`] : `Normalized ${capitalize$2(featureValueType)} Values`
|
|
271779
|
+
title: featureValueTransformName && featureValueTransformName !== "None" ? [`${featureValueTransformName}-Transformed`, `Normalized ${capitalize$2(featureValueType)} Values`] : `Normalized ${capitalize$2(featureValueType)} Values`
|
|
272230
271780
|
},
|
|
272231
271781
|
{
|
|
272232
271782
|
orient: "bottom",
|
|
@@ -272390,15 +271940,17 @@ function CellSetExpressionPlotSubscriber(props2) {
|
|
|
272390
271940
|
const [urls2, addUrl2] = useUrls(loaders, dataset);
|
|
272391
271941
|
const transformOptions = VALUE_TRANSFORM_OPTIONS;
|
|
272392
271942
|
const [expressionData, loadedFeatureSelection, featureSelectionStatus] = useFeatureSelection(loaders, dataset, false, geneSelection, { obsType, featureType, featureValueType });
|
|
271943
|
+
const [{ featureLabelsMap }, featureLabelsStatus] = useFeatureLabelsData(loaders, dataset, addUrl2, false, {}, {}, { featureType });
|
|
272393
271944
|
const [{ obsIndex }, matrixIndicesStatus] = useObsFeatureMatrixIndices(loaders, dataset, addUrl2, false, { obsType, featureType, featureValueType });
|
|
272394
271945
|
const [{ obsSets: cellSets }, obsSetsStatus] = useObsSetsData(loaders, dataset, addUrl2, true, {}, {}, { obsType });
|
|
272395
271946
|
const isReady = useReady([
|
|
272396
271947
|
featureSelectionStatus,
|
|
272397
271948
|
matrixIndicesStatus,
|
|
272398
|
-
obsSetsStatus
|
|
271949
|
+
obsSetsStatus,
|
|
271950
|
+
featureLabelsStatus
|
|
272399
271951
|
]);
|
|
272400
271952
|
const [expressionArr, setArr, expressionMax] = useExpressionByCellSet(expressionData, obsIndex, cellSets, additionalCellSets, geneSelection, cellSetSelection, cellSetColor, featureValueTransform, featureValueTransformCoefficient, theme);
|
|
272401
|
-
const firstGeneSelected = geneSelection && geneSelection.length >= 1 ? geneSelection[0] : null;
|
|
271953
|
+
const firstGeneSelected = geneSelection && geneSelection.length >= 1 ? (featureLabelsMap == null ? void 0 : featureLabelsMap.get(geneSelection[0])) || geneSelection[0] : null;
|
|
272402
271954
|
const selectedTransformName = (_a3 = transformOptions.find((o2) => o2.value === featureValueTransform)) == null ? void 0 : _a3.name;
|
|
272403
271955
|
return jsx(TitleInfo, { title: `Expression by ${capitalize$2(obsType)} Set${firstGeneSelected ? ` (${firstGeneSelected})` : ""}`, removeGridComponent, urls: urls2, theme, isReady, options: jsx(CellSetExpressionPlotOptions, { featureValueTransform, setFeatureValueTransform, featureValueTransformCoefficient, setFeatureValueTransformCoefficient, transformOptions }), children: jsx("div", { ref: containerRef, className: classes.vegaContainer, children: expressionArr ? jsx(CellSetExpressionPlot, { domainMax: expressionMax, colors: setArr, data: expressionArr, theme, width: width2, height: height2, obsType, featureValueType, featureValueTransformName: selectedTransformName }) : jsxs("span", { children: ["Select a ", featureType, "."] }) }) });
|
|
272404
271956
|
}
|
|
@@ -275146,6 +274698,2112 @@ function Vitessce(props2) {
|
|
|
275146
274698
|
}, []);
|
|
275147
274699
|
return ready ? jsx(VitS, { ...props2 }) : null;
|
|
275148
274700
|
}
|
|
274701
|
+
const BROWSER_ALIASES_MAP = {
|
|
274702
|
+
"Amazon Silk": "amazon_silk",
|
|
274703
|
+
"Android Browser": "android",
|
|
274704
|
+
Bada: "bada",
|
|
274705
|
+
BlackBerry: "blackberry",
|
|
274706
|
+
Chrome: "chrome",
|
|
274707
|
+
Chromium: "chromium",
|
|
274708
|
+
Electron: "electron",
|
|
274709
|
+
Epiphany: "epiphany",
|
|
274710
|
+
Firefox: "firefox",
|
|
274711
|
+
Focus: "focus",
|
|
274712
|
+
Generic: "generic",
|
|
274713
|
+
"Google Search": "google_search",
|
|
274714
|
+
Googlebot: "googlebot",
|
|
274715
|
+
"Internet Explorer": "ie",
|
|
274716
|
+
"K-Meleon": "k_meleon",
|
|
274717
|
+
Maxthon: "maxthon",
|
|
274718
|
+
"Microsoft Edge": "edge",
|
|
274719
|
+
"MZ Browser": "mz",
|
|
274720
|
+
"NAVER Whale Browser": "naver",
|
|
274721
|
+
Opera: "opera",
|
|
274722
|
+
"Opera Coast": "opera_coast",
|
|
274723
|
+
PhantomJS: "phantomjs",
|
|
274724
|
+
Puffin: "puffin",
|
|
274725
|
+
QupZilla: "qupzilla",
|
|
274726
|
+
QQ: "qq",
|
|
274727
|
+
QQLite: "qqlite",
|
|
274728
|
+
Safari: "safari",
|
|
274729
|
+
Sailfish: "sailfish",
|
|
274730
|
+
"Samsung Internet for Android": "samsung_internet",
|
|
274731
|
+
SeaMonkey: "seamonkey",
|
|
274732
|
+
Sleipnir: "sleipnir",
|
|
274733
|
+
Swing: "swing",
|
|
274734
|
+
Tizen: "tizen",
|
|
274735
|
+
"UC Browser": "uc",
|
|
274736
|
+
Vivaldi: "vivaldi",
|
|
274737
|
+
"WebOS Browser": "webos",
|
|
274738
|
+
WeChat: "wechat",
|
|
274739
|
+
"Yandex Browser": "yandex",
|
|
274740
|
+
Roku: "roku"
|
|
274741
|
+
};
|
|
274742
|
+
const BROWSER_MAP = {
|
|
274743
|
+
amazon_silk: "Amazon Silk",
|
|
274744
|
+
android: "Android Browser",
|
|
274745
|
+
bada: "Bada",
|
|
274746
|
+
blackberry: "BlackBerry",
|
|
274747
|
+
chrome: "Chrome",
|
|
274748
|
+
chromium: "Chromium",
|
|
274749
|
+
electron: "Electron",
|
|
274750
|
+
epiphany: "Epiphany",
|
|
274751
|
+
firefox: "Firefox",
|
|
274752
|
+
focus: "Focus",
|
|
274753
|
+
generic: "Generic",
|
|
274754
|
+
googlebot: "Googlebot",
|
|
274755
|
+
google_search: "Google Search",
|
|
274756
|
+
ie: "Internet Explorer",
|
|
274757
|
+
k_meleon: "K-Meleon",
|
|
274758
|
+
maxthon: "Maxthon",
|
|
274759
|
+
edge: "Microsoft Edge",
|
|
274760
|
+
mz: "MZ Browser",
|
|
274761
|
+
naver: "NAVER Whale Browser",
|
|
274762
|
+
opera: "Opera",
|
|
274763
|
+
opera_coast: "Opera Coast",
|
|
274764
|
+
phantomjs: "PhantomJS",
|
|
274765
|
+
puffin: "Puffin",
|
|
274766
|
+
qupzilla: "QupZilla",
|
|
274767
|
+
qq: "QQ Browser",
|
|
274768
|
+
qqlite: "QQ Browser Lite",
|
|
274769
|
+
safari: "Safari",
|
|
274770
|
+
sailfish: "Sailfish",
|
|
274771
|
+
samsung_internet: "Samsung Internet for Android",
|
|
274772
|
+
seamonkey: "SeaMonkey",
|
|
274773
|
+
sleipnir: "Sleipnir",
|
|
274774
|
+
swing: "Swing",
|
|
274775
|
+
tizen: "Tizen",
|
|
274776
|
+
uc: "UC Browser",
|
|
274777
|
+
vivaldi: "Vivaldi",
|
|
274778
|
+
webos: "WebOS Browser",
|
|
274779
|
+
wechat: "WeChat",
|
|
274780
|
+
yandex: "Yandex Browser"
|
|
274781
|
+
};
|
|
274782
|
+
const PLATFORMS_MAP = {
|
|
274783
|
+
tablet: "tablet",
|
|
274784
|
+
mobile: "mobile",
|
|
274785
|
+
desktop: "desktop",
|
|
274786
|
+
tv: "tv"
|
|
274787
|
+
};
|
|
274788
|
+
const OS_MAP = {
|
|
274789
|
+
WindowsPhone: "Windows Phone",
|
|
274790
|
+
Windows: "Windows",
|
|
274791
|
+
MacOS: "macOS",
|
|
274792
|
+
iOS: "iOS",
|
|
274793
|
+
Android: "Android",
|
|
274794
|
+
WebOS: "WebOS",
|
|
274795
|
+
BlackBerry: "BlackBerry",
|
|
274796
|
+
Bada: "Bada",
|
|
274797
|
+
Tizen: "Tizen",
|
|
274798
|
+
Linux: "Linux",
|
|
274799
|
+
ChromeOS: "Chrome OS",
|
|
274800
|
+
PlayStation4: "PlayStation 4",
|
|
274801
|
+
Roku: "Roku"
|
|
274802
|
+
};
|
|
274803
|
+
const ENGINE_MAP = {
|
|
274804
|
+
EdgeHTML: "EdgeHTML",
|
|
274805
|
+
Blink: "Blink",
|
|
274806
|
+
Trident: "Trident",
|
|
274807
|
+
Presto: "Presto",
|
|
274808
|
+
Gecko: "Gecko",
|
|
274809
|
+
WebKit: "WebKit"
|
|
274810
|
+
};
|
|
274811
|
+
class Utils {
|
|
274812
|
+
static getFirstMatch(regexp, ua) {
|
|
274813
|
+
const match2 = ua.match(regexp);
|
|
274814
|
+
return match2 && match2.length > 0 && match2[1] || "";
|
|
274815
|
+
}
|
|
274816
|
+
static getSecondMatch(regexp, ua) {
|
|
274817
|
+
const match2 = ua.match(regexp);
|
|
274818
|
+
return match2 && match2.length > 1 && match2[2] || "";
|
|
274819
|
+
}
|
|
274820
|
+
static matchAndReturnConst(regexp, ua, _const2) {
|
|
274821
|
+
if (regexp.test(ua)) {
|
|
274822
|
+
return _const2;
|
|
274823
|
+
}
|
|
274824
|
+
return void 0;
|
|
274825
|
+
}
|
|
274826
|
+
static getWindowsVersionName(version2) {
|
|
274827
|
+
switch (version2) {
|
|
274828
|
+
case "NT":
|
|
274829
|
+
return "NT";
|
|
274830
|
+
case "XP":
|
|
274831
|
+
return "XP";
|
|
274832
|
+
case "NT 5.0":
|
|
274833
|
+
return "2000";
|
|
274834
|
+
case "NT 5.1":
|
|
274835
|
+
return "XP";
|
|
274836
|
+
case "NT 5.2":
|
|
274837
|
+
return "2003";
|
|
274838
|
+
case "NT 6.0":
|
|
274839
|
+
return "Vista";
|
|
274840
|
+
case "NT 6.1":
|
|
274841
|
+
return "7";
|
|
274842
|
+
case "NT 6.2":
|
|
274843
|
+
return "8";
|
|
274844
|
+
case "NT 6.3":
|
|
274845
|
+
return "8.1";
|
|
274846
|
+
case "NT 10.0":
|
|
274847
|
+
return "10";
|
|
274848
|
+
default:
|
|
274849
|
+
return void 0;
|
|
274850
|
+
}
|
|
274851
|
+
}
|
|
274852
|
+
static getMacOSVersionName(version2) {
|
|
274853
|
+
const v = version2.split(".").splice(0, 2).map((s2) => parseInt(s2, 10) || 0);
|
|
274854
|
+
v.push(0);
|
|
274855
|
+
if (v[0] !== 10)
|
|
274856
|
+
return void 0;
|
|
274857
|
+
switch (v[1]) {
|
|
274858
|
+
case 5:
|
|
274859
|
+
return "Leopard";
|
|
274860
|
+
case 6:
|
|
274861
|
+
return "Snow Leopard";
|
|
274862
|
+
case 7:
|
|
274863
|
+
return "Lion";
|
|
274864
|
+
case 8:
|
|
274865
|
+
return "Mountain Lion";
|
|
274866
|
+
case 9:
|
|
274867
|
+
return "Mavericks";
|
|
274868
|
+
case 10:
|
|
274869
|
+
return "Yosemite";
|
|
274870
|
+
case 11:
|
|
274871
|
+
return "El Capitan";
|
|
274872
|
+
case 12:
|
|
274873
|
+
return "Sierra";
|
|
274874
|
+
case 13:
|
|
274875
|
+
return "High Sierra";
|
|
274876
|
+
case 14:
|
|
274877
|
+
return "Mojave";
|
|
274878
|
+
case 15:
|
|
274879
|
+
return "Catalina";
|
|
274880
|
+
default:
|
|
274881
|
+
return void 0;
|
|
274882
|
+
}
|
|
274883
|
+
}
|
|
274884
|
+
static getAndroidVersionName(version2) {
|
|
274885
|
+
const v = version2.split(".").splice(0, 2).map((s2) => parseInt(s2, 10) || 0);
|
|
274886
|
+
v.push(0);
|
|
274887
|
+
if (v[0] === 1 && v[1] < 5)
|
|
274888
|
+
return void 0;
|
|
274889
|
+
if (v[0] === 1 && v[1] < 6)
|
|
274890
|
+
return "Cupcake";
|
|
274891
|
+
if (v[0] === 1 && v[1] >= 6)
|
|
274892
|
+
return "Donut";
|
|
274893
|
+
if (v[0] === 2 && v[1] < 2)
|
|
274894
|
+
return "Eclair";
|
|
274895
|
+
if (v[0] === 2 && v[1] === 2)
|
|
274896
|
+
return "Froyo";
|
|
274897
|
+
if (v[0] === 2 && v[1] > 2)
|
|
274898
|
+
return "Gingerbread";
|
|
274899
|
+
if (v[0] === 3)
|
|
274900
|
+
return "Honeycomb";
|
|
274901
|
+
if (v[0] === 4 && v[1] < 1)
|
|
274902
|
+
return "Ice Cream Sandwich";
|
|
274903
|
+
if (v[0] === 4 && v[1] < 4)
|
|
274904
|
+
return "Jelly Bean";
|
|
274905
|
+
if (v[0] === 4 && v[1] >= 4)
|
|
274906
|
+
return "KitKat";
|
|
274907
|
+
if (v[0] === 5)
|
|
274908
|
+
return "Lollipop";
|
|
274909
|
+
if (v[0] === 6)
|
|
274910
|
+
return "Marshmallow";
|
|
274911
|
+
if (v[0] === 7)
|
|
274912
|
+
return "Nougat";
|
|
274913
|
+
if (v[0] === 8)
|
|
274914
|
+
return "Oreo";
|
|
274915
|
+
if (v[0] === 9)
|
|
274916
|
+
return "Pie";
|
|
274917
|
+
return void 0;
|
|
274918
|
+
}
|
|
274919
|
+
static getVersionPrecision(version2) {
|
|
274920
|
+
return version2.split(".").length;
|
|
274921
|
+
}
|
|
274922
|
+
static compareVersions(versionA, versionB, isLoose = false) {
|
|
274923
|
+
const versionAPrecision = Utils.getVersionPrecision(versionA);
|
|
274924
|
+
const versionBPrecision = Utils.getVersionPrecision(versionB);
|
|
274925
|
+
let precision = Math.max(versionAPrecision, versionBPrecision);
|
|
274926
|
+
let lastPrecision = 0;
|
|
274927
|
+
const chunks = Utils.map([versionA, versionB], (version2) => {
|
|
274928
|
+
const delta = precision - Utils.getVersionPrecision(version2);
|
|
274929
|
+
const _version = version2 + new Array(delta + 1).join(".0");
|
|
274930
|
+
return Utils.map(_version.split("."), (chunk) => new Array(20 - chunk.length).join("0") + chunk).reverse();
|
|
274931
|
+
});
|
|
274932
|
+
if (isLoose) {
|
|
274933
|
+
lastPrecision = precision - Math.min(versionAPrecision, versionBPrecision);
|
|
274934
|
+
}
|
|
274935
|
+
precision -= 1;
|
|
274936
|
+
while (precision >= lastPrecision) {
|
|
274937
|
+
if (chunks[0][precision] > chunks[1][precision]) {
|
|
274938
|
+
return 1;
|
|
274939
|
+
}
|
|
274940
|
+
if (chunks[0][precision] === chunks[1][precision]) {
|
|
274941
|
+
if (precision === lastPrecision) {
|
|
274942
|
+
return 0;
|
|
274943
|
+
}
|
|
274944
|
+
precision -= 1;
|
|
274945
|
+
} else if (chunks[0][precision] < chunks[1][precision]) {
|
|
274946
|
+
return -1;
|
|
274947
|
+
}
|
|
274948
|
+
}
|
|
274949
|
+
return void 0;
|
|
274950
|
+
}
|
|
274951
|
+
static map(arr, iterator2) {
|
|
274952
|
+
const result = [];
|
|
274953
|
+
let i2;
|
|
274954
|
+
if (Array.prototype.map) {
|
|
274955
|
+
return Array.prototype.map.call(arr, iterator2);
|
|
274956
|
+
}
|
|
274957
|
+
for (i2 = 0; i2 < arr.length; i2 += 1) {
|
|
274958
|
+
result.push(iterator2(arr[i2]));
|
|
274959
|
+
}
|
|
274960
|
+
return result;
|
|
274961
|
+
}
|
|
274962
|
+
static find(arr, predicate) {
|
|
274963
|
+
let i2;
|
|
274964
|
+
let l2;
|
|
274965
|
+
if (Array.prototype.find) {
|
|
274966
|
+
return Array.prototype.find.call(arr, predicate);
|
|
274967
|
+
}
|
|
274968
|
+
for (i2 = 0, l2 = arr.length; i2 < l2; i2 += 1) {
|
|
274969
|
+
const value2 = arr[i2];
|
|
274970
|
+
if (predicate(value2, i2)) {
|
|
274971
|
+
return value2;
|
|
274972
|
+
}
|
|
274973
|
+
}
|
|
274974
|
+
return void 0;
|
|
274975
|
+
}
|
|
274976
|
+
static assign(obj, ...assigners) {
|
|
274977
|
+
const result = obj;
|
|
274978
|
+
let i2;
|
|
274979
|
+
let l2;
|
|
274980
|
+
if (Object.assign) {
|
|
274981
|
+
return Object.assign(obj, ...assigners);
|
|
274982
|
+
}
|
|
274983
|
+
for (i2 = 0, l2 = assigners.length; i2 < l2; i2 += 1) {
|
|
274984
|
+
const assigner = assigners[i2];
|
|
274985
|
+
if (typeof assigner === "object" && assigner !== null) {
|
|
274986
|
+
const keys4 = Object.keys(assigner);
|
|
274987
|
+
keys4.forEach((key2) => {
|
|
274988
|
+
result[key2] = assigner[key2];
|
|
274989
|
+
});
|
|
274990
|
+
}
|
|
274991
|
+
}
|
|
274992
|
+
return obj;
|
|
274993
|
+
}
|
|
274994
|
+
static getBrowserAlias(browserName) {
|
|
274995
|
+
return BROWSER_ALIASES_MAP[browserName];
|
|
274996
|
+
}
|
|
274997
|
+
static getBrowserTypeByAlias(browserAlias) {
|
|
274998
|
+
return BROWSER_MAP[browserAlias] || "";
|
|
274999
|
+
}
|
|
275000
|
+
}
|
|
275001
|
+
const commonVersionIdentifier = /version\/(\d+(\.?_?\d+)+)/i;
|
|
275002
|
+
const browsersList = [
|
|
275003
|
+
{
|
|
275004
|
+
test: [/googlebot/i],
|
|
275005
|
+
describe(ua) {
|
|
275006
|
+
const browser2 = {
|
|
275007
|
+
name: "Googlebot"
|
|
275008
|
+
};
|
|
275009
|
+
const version2 = Utils.getFirstMatch(/googlebot\/(\d+(\.\d+))/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
|
275010
|
+
if (version2) {
|
|
275011
|
+
browser2.version = version2;
|
|
275012
|
+
}
|
|
275013
|
+
return browser2;
|
|
275014
|
+
}
|
|
275015
|
+
},
|
|
275016
|
+
{
|
|
275017
|
+
test: [/opera/i],
|
|
275018
|
+
describe(ua) {
|
|
275019
|
+
const browser2 = {
|
|
275020
|
+
name: "Opera"
|
|
275021
|
+
};
|
|
275022
|
+
const version2 = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
|
275023
|
+
if (version2) {
|
|
275024
|
+
browser2.version = version2;
|
|
275025
|
+
}
|
|
275026
|
+
return browser2;
|
|
275027
|
+
}
|
|
275028
|
+
},
|
|
275029
|
+
{
|
|
275030
|
+
test: [/opr\/|opios/i],
|
|
275031
|
+
describe(ua) {
|
|
275032
|
+
const browser2 = {
|
|
275033
|
+
name: "Opera"
|
|
275034
|
+
};
|
|
275035
|
+
const version2 = Utils.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
|
275036
|
+
if (version2) {
|
|
275037
|
+
browser2.version = version2;
|
|
275038
|
+
}
|
|
275039
|
+
return browser2;
|
|
275040
|
+
}
|
|
275041
|
+
},
|
|
275042
|
+
{
|
|
275043
|
+
test: [/SamsungBrowser/i],
|
|
275044
|
+
describe(ua) {
|
|
275045
|
+
const browser2 = {
|
|
275046
|
+
name: "Samsung Internet for Android"
|
|
275047
|
+
};
|
|
275048
|
+
const version2 = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
|
275049
|
+
if (version2) {
|
|
275050
|
+
browser2.version = version2;
|
|
275051
|
+
}
|
|
275052
|
+
return browser2;
|
|
275053
|
+
}
|
|
275054
|
+
},
|
|
275055
|
+
{
|
|
275056
|
+
test: [/Whale/i],
|
|
275057
|
+
describe(ua) {
|
|
275058
|
+
const browser2 = {
|
|
275059
|
+
name: "NAVER Whale Browser"
|
|
275060
|
+
};
|
|
275061
|
+
const version2 = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i, ua);
|
|
275062
|
+
if (version2) {
|
|
275063
|
+
browser2.version = version2;
|
|
275064
|
+
}
|
|
275065
|
+
return browser2;
|
|
275066
|
+
}
|
|
275067
|
+
},
|
|
275068
|
+
{
|
|
275069
|
+
test: [/MZBrowser/i],
|
|
275070
|
+
describe(ua) {
|
|
275071
|
+
const browser2 = {
|
|
275072
|
+
name: "MZ Browser"
|
|
275073
|
+
};
|
|
275074
|
+
const version2 = Utils.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
|
275075
|
+
if (version2) {
|
|
275076
|
+
browser2.version = version2;
|
|
275077
|
+
}
|
|
275078
|
+
return browser2;
|
|
275079
|
+
}
|
|
275080
|
+
},
|
|
275081
|
+
{
|
|
275082
|
+
test: [/focus/i],
|
|
275083
|
+
describe(ua) {
|
|
275084
|
+
const browser2 = {
|
|
275085
|
+
name: "Focus"
|
|
275086
|
+
};
|
|
275087
|
+
const version2 = Utils.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
|
275088
|
+
if (version2) {
|
|
275089
|
+
browser2.version = version2;
|
|
275090
|
+
}
|
|
275091
|
+
return browser2;
|
|
275092
|
+
}
|
|
275093
|
+
},
|
|
275094
|
+
{
|
|
275095
|
+
test: [/swing/i],
|
|
275096
|
+
describe(ua) {
|
|
275097
|
+
const browser2 = {
|
|
275098
|
+
name: "Swing"
|
|
275099
|
+
};
|
|
275100
|
+
const version2 = Utils.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
|
275101
|
+
if (version2) {
|
|
275102
|
+
browser2.version = version2;
|
|
275103
|
+
}
|
|
275104
|
+
return browser2;
|
|
275105
|
+
}
|
|
275106
|
+
},
|
|
275107
|
+
{
|
|
275108
|
+
test: [/coast/i],
|
|
275109
|
+
describe(ua) {
|
|
275110
|
+
const browser2 = {
|
|
275111
|
+
name: "Opera Coast"
|
|
275112
|
+
};
|
|
275113
|
+
const version2 = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
|
275114
|
+
if (version2) {
|
|
275115
|
+
browser2.version = version2;
|
|
275116
|
+
}
|
|
275117
|
+
return browser2;
|
|
275118
|
+
}
|
|
275119
|
+
},
|
|
275120
|
+
{
|
|
275121
|
+
test: [/opt\/\d+(?:.?_?\d+)+/i],
|
|
275122
|
+
describe(ua) {
|
|
275123
|
+
const browser2 = {
|
|
275124
|
+
name: "Opera Touch"
|
|
275125
|
+
};
|
|
275126
|
+
const version2 = Utils.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
|
275127
|
+
if (version2) {
|
|
275128
|
+
browser2.version = version2;
|
|
275129
|
+
}
|
|
275130
|
+
return browser2;
|
|
275131
|
+
}
|
|
275132
|
+
},
|
|
275133
|
+
{
|
|
275134
|
+
test: [/yabrowser/i],
|
|
275135
|
+
describe(ua) {
|
|
275136
|
+
const browser2 = {
|
|
275137
|
+
name: "Yandex Browser"
|
|
275138
|
+
};
|
|
275139
|
+
const version2 = Utils.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
|
275140
|
+
if (version2) {
|
|
275141
|
+
browser2.version = version2;
|
|
275142
|
+
}
|
|
275143
|
+
return browser2;
|
|
275144
|
+
}
|
|
275145
|
+
},
|
|
275146
|
+
{
|
|
275147
|
+
test: [/ucbrowser/i],
|
|
275148
|
+
describe(ua) {
|
|
275149
|
+
const browser2 = {
|
|
275150
|
+
name: "UC Browser"
|
|
275151
|
+
};
|
|
275152
|
+
const version2 = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
|
275153
|
+
if (version2) {
|
|
275154
|
+
browser2.version = version2;
|
|
275155
|
+
}
|
|
275156
|
+
return browser2;
|
|
275157
|
+
}
|
|
275158
|
+
},
|
|
275159
|
+
{
|
|
275160
|
+
test: [/Maxthon|mxios/i],
|
|
275161
|
+
describe(ua) {
|
|
275162
|
+
const browser2 = {
|
|
275163
|
+
name: "Maxthon"
|
|
275164
|
+
};
|
|
275165
|
+
const version2 = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
|
275166
|
+
if (version2) {
|
|
275167
|
+
browser2.version = version2;
|
|
275168
|
+
}
|
|
275169
|
+
return browser2;
|
|
275170
|
+
}
|
|
275171
|
+
},
|
|
275172
|
+
{
|
|
275173
|
+
test: [/epiphany/i],
|
|
275174
|
+
describe(ua) {
|
|
275175
|
+
const browser2 = {
|
|
275176
|
+
name: "Epiphany"
|
|
275177
|
+
};
|
|
275178
|
+
const version2 = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
|
275179
|
+
if (version2) {
|
|
275180
|
+
browser2.version = version2;
|
|
275181
|
+
}
|
|
275182
|
+
return browser2;
|
|
275183
|
+
}
|
|
275184
|
+
},
|
|
275185
|
+
{
|
|
275186
|
+
test: [/puffin/i],
|
|
275187
|
+
describe(ua) {
|
|
275188
|
+
const browser2 = {
|
|
275189
|
+
name: "Puffin"
|
|
275190
|
+
};
|
|
275191
|
+
const version2 = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
|
275192
|
+
if (version2) {
|
|
275193
|
+
browser2.version = version2;
|
|
275194
|
+
}
|
|
275195
|
+
return browser2;
|
|
275196
|
+
}
|
|
275197
|
+
},
|
|
275198
|
+
{
|
|
275199
|
+
test: [/sleipnir/i],
|
|
275200
|
+
describe(ua) {
|
|
275201
|
+
const browser2 = {
|
|
275202
|
+
name: "Sleipnir"
|
|
275203
|
+
};
|
|
275204
|
+
const version2 = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
|
275205
|
+
if (version2) {
|
|
275206
|
+
browser2.version = version2;
|
|
275207
|
+
}
|
|
275208
|
+
return browser2;
|
|
275209
|
+
}
|
|
275210
|
+
},
|
|
275211
|
+
{
|
|
275212
|
+
test: [/k-meleon/i],
|
|
275213
|
+
describe(ua) {
|
|
275214
|
+
const browser2 = {
|
|
275215
|
+
name: "K-Meleon"
|
|
275216
|
+
};
|
|
275217
|
+
const version2 = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
|
275218
|
+
if (version2) {
|
|
275219
|
+
browser2.version = version2;
|
|
275220
|
+
}
|
|
275221
|
+
return browser2;
|
|
275222
|
+
}
|
|
275223
|
+
},
|
|
275224
|
+
{
|
|
275225
|
+
test: [/micromessenger/i],
|
|
275226
|
+
describe(ua) {
|
|
275227
|
+
const browser2 = {
|
|
275228
|
+
name: "WeChat"
|
|
275229
|
+
};
|
|
275230
|
+
const version2 = Utils.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
|
275231
|
+
if (version2) {
|
|
275232
|
+
browser2.version = version2;
|
|
275233
|
+
}
|
|
275234
|
+
return browser2;
|
|
275235
|
+
}
|
|
275236
|
+
},
|
|
275237
|
+
{
|
|
275238
|
+
test: [/qqbrowser/i],
|
|
275239
|
+
describe(ua) {
|
|
275240
|
+
const browser2 = {
|
|
275241
|
+
name: /qqbrowserlite/i.test(ua) ? "QQ Browser Lite" : "QQ Browser"
|
|
275242
|
+
};
|
|
275243
|
+
const version2 = Utils.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
|
275244
|
+
if (version2) {
|
|
275245
|
+
browser2.version = version2;
|
|
275246
|
+
}
|
|
275247
|
+
return browser2;
|
|
275248
|
+
}
|
|
275249
|
+
},
|
|
275250
|
+
{
|
|
275251
|
+
test: [/msie|trident/i],
|
|
275252
|
+
describe(ua) {
|
|
275253
|
+
const browser2 = {
|
|
275254
|
+
name: "Internet Explorer"
|
|
275255
|
+
};
|
|
275256
|
+
const version2 = Utils.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i, ua);
|
|
275257
|
+
if (version2) {
|
|
275258
|
+
browser2.version = version2;
|
|
275259
|
+
}
|
|
275260
|
+
return browser2;
|
|
275261
|
+
}
|
|
275262
|
+
},
|
|
275263
|
+
{
|
|
275264
|
+
test: [/\sedg\//i],
|
|
275265
|
+
describe(ua) {
|
|
275266
|
+
const browser2 = {
|
|
275267
|
+
name: "Microsoft Edge"
|
|
275268
|
+
};
|
|
275269
|
+
const version2 = Utils.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i, ua);
|
|
275270
|
+
if (version2) {
|
|
275271
|
+
browser2.version = version2;
|
|
275272
|
+
}
|
|
275273
|
+
return browser2;
|
|
275274
|
+
}
|
|
275275
|
+
},
|
|
275276
|
+
{
|
|
275277
|
+
test: [/edg([ea]|ios)/i],
|
|
275278
|
+
describe(ua) {
|
|
275279
|
+
const browser2 = {
|
|
275280
|
+
name: "Microsoft Edge"
|
|
275281
|
+
};
|
|
275282
|
+
const version2 = Utils.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i, ua);
|
|
275283
|
+
if (version2) {
|
|
275284
|
+
browser2.version = version2;
|
|
275285
|
+
}
|
|
275286
|
+
return browser2;
|
|
275287
|
+
}
|
|
275288
|
+
},
|
|
275289
|
+
{
|
|
275290
|
+
test: [/vivaldi/i],
|
|
275291
|
+
describe(ua) {
|
|
275292
|
+
const browser2 = {
|
|
275293
|
+
name: "Vivaldi"
|
|
275294
|
+
};
|
|
275295
|
+
const version2 = Utils.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i, ua);
|
|
275296
|
+
if (version2) {
|
|
275297
|
+
browser2.version = version2;
|
|
275298
|
+
}
|
|
275299
|
+
return browser2;
|
|
275300
|
+
}
|
|
275301
|
+
},
|
|
275302
|
+
{
|
|
275303
|
+
test: [/seamonkey/i],
|
|
275304
|
+
describe(ua) {
|
|
275305
|
+
const browser2 = {
|
|
275306
|
+
name: "SeaMonkey"
|
|
275307
|
+
};
|
|
275308
|
+
const version2 = Utils.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i, ua);
|
|
275309
|
+
if (version2) {
|
|
275310
|
+
browser2.version = version2;
|
|
275311
|
+
}
|
|
275312
|
+
return browser2;
|
|
275313
|
+
}
|
|
275314
|
+
},
|
|
275315
|
+
{
|
|
275316
|
+
test: [/sailfish/i],
|
|
275317
|
+
describe(ua) {
|
|
275318
|
+
const browser2 = {
|
|
275319
|
+
name: "Sailfish"
|
|
275320
|
+
};
|
|
275321
|
+
const version2 = Utils.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i, ua);
|
|
275322
|
+
if (version2) {
|
|
275323
|
+
browser2.version = version2;
|
|
275324
|
+
}
|
|
275325
|
+
return browser2;
|
|
275326
|
+
}
|
|
275327
|
+
},
|
|
275328
|
+
{
|
|
275329
|
+
test: [/silk/i],
|
|
275330
|
+
describe(ua) {
|
|
275331
|
+
const browser2 = {
|
|
275332
|
+
name: "Amazon Silk"
|
|
275333
|
+
};
|
|
275334
|
+
const version2 = Utils.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i, ua);
|
|
275335
|
+
if (version2) {
|
|
275336
|
+
browser2.version = version2;
|
|
275337
|
+
}
|
|
275338
|
+
return browser2;
|
|
275339
|
+
}
|
|
275340
|
+
},
|
|
275341
|
+
{
|
|
275342
|
+
test: [/phantom/i],
|
|
275343
|
+
describe(ua) {
|
|
275344
|
+
const browser2 = {
|
|
275345
|
+
name: "PhantomJS"
|
|
275346
|
+
};
|
|
275347
|
+
const version2 = Utils.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i, ua);
|
|
275348
|
+
if (version2) {
|
|
275349
|
+
browser2.version = version2;
|
|
275350
|
+
}
|
|
275351
|
+
return browser2;
|
|
275352
|
+
}
|
|
275353
|
+
},
|
|
275354
|
+
{
|
|
275355
|
+
test: [/slimerjs/i],
|
|
275356
|
+
describe(ua) {
|
|
275357
|
+
const browser2 = {
|
|
275358
|
+
name: "SlimerJS"
|
|
275359
|
+
};
|
|
275360
|
+
const version2 = Utils.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i, ua);
|
|
275361
|
+
if (version2) {
|
|
275362
|
+
browser2.version = version2;
|
|
275363
|
+
}
|
|
275364
|
+
return browser2;
|
|
275365
|
+
}
|
|
275366
|
+
},
|
|
275367
|
+
{
|
|
275368
|
+
test: [/blackberry|\bbb\d+/i, /rim\stablet/i],
|
|
275369
|
+
describe(ua) {
|
|
275370
|
+
const browser2 = {
|
|
275371
|
+
name: "BlackBerry"
|
|
275372
|
+
};
|
|
275373
|
+
const version2 = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i, ua);
|
|
275374
|
+
if (version2) {
|
|
275375
|
+
browser2.version = version2;
|
|
275376
|
+
}
|
|
275377
|
+
return browser2;
|
|
275378
|
+
}
|
|
275379
|
+
},
|
|
275380
|
+
{
|
|
275381
|
+
test: [/(web|hpw)[o0]s/i],
|
|
275382
|
+
describe(ua) {
|
|
275383
|
+
const browser2 = {
|
|
275384
|
+
name: "WebOS Browser"
|
|
275385
|
+
};
|
|
275386
|
+
const version2 = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i, ua);
|
|
275387
|
+
if (version2) {
|
|
275388
|
+
browser2.version = version2;
|
|
275389
|
+
}
|
|
275390
|
+
return browser2;
|
|
275391
|
+
}
|
|
275392
|
+
},
|
|
275393
|
+
{
|
|
275394
|
+
test: [/bada/i],
|
|
275395
|
+
describe(ua) {
|
|
275396
|
+
const browser2 = {
|
|
275397
|
+
name: "Bada"
|
|
275398
|
+
};
|
|
275399
|
+
const version2 = Utils.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i, ua);
|
|
275400
|
+
if (version2) {
|
|
275401
|
+
browser2.version = version2;
|
|
275402
|
+
}
|
|
275403
|
+
return browser2;
|
|
275404
|
+
}
|
|
275405
|
+
},
|
|
275406
|
+
{
|
|
275407
|
+
test: [/tizen/i],
|
|
275408
|
+
describe(ua) {
|
|
275409
|
+
const browser2 = {
|
|
275410
|
+
name: "Tizen"
|
|
275411
|
+
};
|
|
275412
|
+
const version2 = Utils.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
|
275413
|
+
if (version2) {
|
|
275414
|
+
browser2.version = version2;
|
|
275415
|
+
}
|
|
275416
|
+
return browser2;
|
|
275417
|
+
}
|
|
275418
|
+
},
|
|
275419
|
+
{
|
|
275420
|
+
test: [/qupzilla/i],
|
|
275421
|
+
describe(ua) {
|
|
275422
|
+
const browser2 = {
|
|
275423
|
+
name: "QupZilla"
|
|
275424
|
+
};
|
|
275425
|
+
const version2 = Utils.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
|
275426
|
+
if (version2) {
|
|
275427
|
+
browser2.version = version2;
|
|
275428
|
+
}
|
|
275429
|
+
return browser2;
|
|
275430
|
+
}
|
|
275431
|
+
},
|
|
275432
|
+
{
|
|
275433
|
+
test: [/firefox|iceweasel|fxios/i],
|
|
275434
|
+
describe(ua) {
|
|
275435
|
+
const browser2 = {
|
|
275436
|
+
name: "Firefox"
|
|
275437
|
+
};
|
|
275438
|
+
const version2 = Utils.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
|
275439
|
+
if (version2) {
|
|
275440
|
+
browser2.version = version2;
|
|
275441
|
+
}
|
|
275442
|
+
return browser2;
|
|
275443
|
+
}
|
|
275444
|
+
},
|
|
275445
|
+
{
|
|
275446
|
+
test: [/electron/i],
|
|
275447
|
+
describe(ua) {
|
|
275448
|
+
const browser2 = {
|
|
275449
|
+
name: "Electron"
|
|
275450
|
+
};
|
|
275451
|
+
const version2 = Utils.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i, ua);
|
|
275452
|
+
if (version2) {
|
|
275453
|
+
browser2.version = version2;
|
|
275454
|
+
}
|
|
275455
|
+
return browser2;
|
|
275456
|
+
}
|
|
275457
|
+
},
|
|
275458
|
+
{
|
|
275459
|
+
test: [/MiuiBrowser/i],
|
|
275460
|
+
describe(ua) {
|
|
275461
|
+
const browser2 = {
|
|
275462
|
+
name: "Miui"
|
|
275463
|
+
};
|
|
275464
|
+
const version2 = Utils.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
|
275465
|
+
if (version2) {
|
|
275466
|
+
browser2.version = version2;
|
|
275467
|
+
}
|
|
275468
|
+
return browser2;
|
|
275469
|
+
}
|
|
275470
|
+
},
|
|
275471
|
+
{
|
|
275472
|
+
test: [/chromium/i],
|
|
275473
|
+
describe(ua) {
|
|
275474
|
+
const browser2 = {
|
|
275475
|
+
name: "Chromium"
|
|
275476
|
+
};
|
|
275477
|
+
const version2 = Utils.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
|
275478
|
+
if (version2) {
|
|
275479
|
+
browser2.version = version2;
|
|
275480
|
+
}
|
|
275481
|
+
return browser2;
|
|
275482
|
+
}
|
|
275483
|
+
},
|
|
275484
|
+
{
|
|
275485
|
+
test: [/chrome|crios|crmo/i],
|
|
275486
|
+
describe(ua) {
|
|
275487
|
+
const browser2 = {
|
|
275488
|
+
name: "Chrome"
|
|
275489
|
+
};
|
|
275490
|
+
const version2 = Utils.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i, ua);
|
|
275491
|
+
if (version2) {
|
|
275492
|
+
browser2.version = version2;
|
|
275493
|
+
}
|
|
275494
|
+
return browser2;
|
|
275495
|
+
}
|
|
275496
|
+
},
|
|
275497
|
+
{
|
|
275498
|
+
test: [/GSA/i],
|
|
275499
|
+
describe(ua) {
|
|
275500
|
+
const browser2 = {
|
|
275501
|
+
name: "Google Search"
|
|
275502
|
+
};
|
|
275503
|
+
const version2 = Utils.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i, ua);
|
|
275504
|
+
if (version2) {
|
|
275505
|
+
browser2.version = version2;
|
|
275506
|
+
}
|
|
275507
|
+
return browser2;
|
|
275508
|
+
}
|
|
275509
|
+
},
|
|
275510
|
+
{
|
|
275511
|
+
test(parser2) {
|
|
275512
|
+
const notLikeAndroid = !parser2.test(/like android/i);
|
|
275513
|
+
const butAndroid = parser2.test(/android/i);
|
|
275514
|
+
return notLikeAndroid && butAndroid;
|
|
275515
|
+
},
|
|
275516
|
+
describe(ua) {
|
|
275517
|
+
const browser2 = {
|
|
275518
|
+
name: "Android Browser"
|
|
275519
|
+
};
|
|
275520
|
+
const version2 = Utils.getFirstMatch(commonVersionIdentifier, ua);
|
|
275521
|
+
if (version2) {
|
|
275522
|
+
browser2.version = version2;
|
|
275523
|
+
}
|
|
275524
|
+
return browser2;
|
|
275525
|
+
}
|
|
275526
|
+
},
|
|
275527
|
+
{
|
|
275528
|
+
test: [/playstation 4/i],
|
|
275529
|
+
describe(ua) {
|
|
275530
|
+
const browser2 = {
|
|
275531
|
+
name: "PlayStation 4"
|
|
275532
|
+
};
|
|
275533
|
+
const version2 = Utils.getFirstMatch(commonVersionIdentifier, ua);
|
|
275534
|
+
if (version2) {
|
|
275535
|
+
browser2.version = version2;
|
|
275536
|
+
}
|
|
275537
|
+
return browser2;
|
|
275538
|
+
}
|
|
275539
|
+
},
|
|
275540
|
+
{
|
|
275541
|
+
test: [/safari|applewebkit/i],
|
|
275542
|
+
describe(ua) {
|
|
275543
|
+
const browser2 = {
|
|
275544
|
+
name: "Safari"
|
|
275545
|
+
};
|
|
275546
|
+
const version2 = Utils.getFirstMatch(commonVersionIdentifier, ua);
|
|
275547
|
+
if (version2) {
|
|
275548
|
+
browser2.version = version2;
|
|
275549
|
+
}
|
|
275550
|
+
return browser2;
|
|
275551
|
+
}
|
|
275552
|
+
},
|
|
275553
|
+
{
|
|
275554
|
+
test: [/.*/i],
|
|
275555
|
+
describe(ua) {
|
|
275556
|
+
const regexpWithoutDeviceSpec = /^(.*)\/(.*) /;
|
|
275557
|
+
const regexpWithDeviceSpec = /^(.*)\/(.*)[ \t]\((.*)/;
|
|
275558
|
+
const hasDeviceSpec = ua.search("\\(") !== -1;
|
|
275559
|
+
const regexp = hasDeviceSpec ? regexpWithDeviceSpec : regexpWithoutDeviceSpec;
|
|
275560
|
+
return {
|
|
275561
|
+
name: Utils.getFirstMatch(regexp, ua),
|
|
275562
|
+
version: Utils.getSecondMatch(regexp, ua)
|
|
275563
|
+
};
|
|
275564
|
+
}
|
|
275565
|
+
}
|
|
275566
|
+
];
|
|
275567
|
+
const osParsersList = [
|
|
275568
|
+
{
|
|
275569
|
+
test: [/Roku\/DVP/],
|
|
275570
|
+
describe(ua) {
|
|
275571
|
+
const version2 = Utils.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i, ua);
|
|
275572
|
+
return {
|
|
275573
|
+
name: OS_MAP.Roku,
|
|
275574
|
+
version: version2
|
|
275575
|
+
};
|
|
275576
|
+
}
|
|
275577
|
+
},
|
|
275578
|
+
{
|
|
275579
|
+
test: [/windows phone/i],
|
|
275580
|
+
describe(ua) {
|
|
275581
|
+
const version2 = Utils.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i, ua);
|
|
275582
|
+
return {
|
|
275583
|
+
name: OS_MAP.WindowsPhone,
|
|
275584
|
+
version: version2
|
|
275585
|
+
};
|
|
275586
|
+
}
|
|
275587
|
+
},
|
|
275588
|
+
{
|
|
275589
|
+
test: [/windows /i],
|
|
275590
|
+
describe(ua) {
|
|
275591
|
+
const version2 = Utils.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i, ua);
|
|
275592
|
+
const versionName = Utils.getWindowsVersionName(version2);
|
|
275593
|
+
return {
|
|
275594
|
+
name: OS_MAP.Windows,
|
|
275595
|
+
version: version2,
|
|
275596
|
+
versionName
|
|
275597
|
+
};
|
|
275598
|
+
}
|
|
275599
|
+
},
|
|
275600
|
+
{
|
|
275601
|
+
test: [/Macintosh(.*?) FxiOS(.*?)\//],
|
|
275602
|
+
describe(ua) {
|
|
275603
|
+
const result = {
|
|
275604
|
+
name: OS_MAP.iOS
|
|
275605
|
+
};
|
|
275606
|
+
const version2 = Utils.getSecondMatch(/(Version\/)(\d[\d.]+)/, ua);
|
|
275607
|
+
if (version2) {
|
|
275608
|
+
result.version = version2;
|
|
275609
|
+
}
|
|
275610
|
+
return result;
|
|
275611
|
+
}
|
|
275612
|
+
},
|
|
275613
|
+
{
|
|
275614
|
+
test: [/macintosh/i],
|
|
275615
|
+
describe(ua) {
|
|
275616
|
+
const version2 = Utils.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i, ua).replace(/[_\s]/g, ".");
|
|
275617
|
+
const versionName = Utils.getMacOSVersionName(version2);
|
|
275618
|
+
const os = {
|
|
275619
|
+
name: OS_MAP.MacOS,
|
|
275620
|
+
version: version2
|
|
275621
|
+
};
|
|
275622
|
+
if (versionName) {
|
|
275623
|
+
os.versionName = versionName;
|
|
275624
|
+
}
|
|
275625
|
+
return os;
|
|
275626
|
+
}
|
|
275627
|
+
},
|
|
275628
|
+
{
|
|
275629
|
+
test: [/(ipod|iphone|ipad)/i],
|
|
275630
|
+
describe(ua) {
|
|
275631
|
+
const version2 = Utils.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i, ua).replace(/[_\s]/g, ".");
|
|
275632
|
+
return {
|
|
275633
|
+
name: OS_MAP.iOS,
|
|
275634
|
+
version: version2
|
|
275635
|
+
};
|
|
275636
|
+
}
|
|
275637
|
+
},
|
|
275638
|
+
{
|
|
275639
|
+
test(parser2) {
|
|
275640
|
+
const notLikeAndroid = !parser2.test(/like android/i);
|
|
275641
|
+
const butAndroid = parser2.test(/android/i);
|
|
275642
|
+
return notLikeAndroid && butAndroid;
|
|
275643
|
+
},
|
|
275644
|
+
describe(ua) {
|
|
275645
|
+
const version2 = Utils.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i, ua);
|
|
275646
|
+
const versionName = Utils.getAndroidVersionName(version2);
|
|
275647
|
+
const os = {
|
|
275648
|
+
name: OS_MAP.Android,
|
|
275649
|
+
version: version2
|
|
275650
|
+
};
|
|
275651
|
+
if (versionName) {
|
|
275652
|
+
os.versionName = versionName;
|
|
275653
|
+
}
|
|
275654
|
+
return os;
|
|
275655
|
+
}
|
|
275656
|
+
},
|
|
275657
|
+
{
|
|
275658
|
+
test: [/(web|hpw)[o0]s/i],
|
|
275659
|
+
describe(ua) {
|
|
275660
|
+
const version2 = Utils.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i, ua);
|
|
275661
|
+
const os = {
|
|
275662
|
+
name: OS_MAP.WebOS
|
|
275663
|
+
};
|
|
275664
|
+
if (version2 && version2.length) {
|
|
275665
|
+
os.version = version2;
|
|
275666
|
+
}
|
|
275667
|
+
return os;
|
|
275668
|
+
}
|
|
275669
|
+
},
|
|
275670
|
+
{
|
|
275671
|
+
test: [/blackberry|\bbb\d+/i, /rim\stablet/i],
|
|
275672
|
+
describe(ua) {
|
|
275673
|
+
const version2 = Utils.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i, ua) || Utils.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i, ua) || Utils.getFirstMatch(/\bbb(\d+)/i, ua);
|
|
275674
|
+
return {
|
|
275675
|
+
name: OS_MAP.BlackBerry,
|
|
275676
|
+
version: version2
|
|
275677
|
+
};
|
|
275678
|
+
}
|
|
275679
|
+
},
|
|
275680
|
+
{
|
|
275681
|
+
test: [/bada/i],
|
|
275682
|
+
describe(ua) {
|
|
275683
|
+
const version2 = Utils.getFirstMatch(/bada\/(\d+(\.\d+)*)/i, ua);
|
|
275684
|
+
return {
|
|
275685
|
+
name: OS_MAP.Bada,
|
|
275686
|
+
version: version2
|
|
275687
|
+
};
|
|
275688
|
+
}
|
|
275689
|
+
},
|
|
275690
|
+
{
|
|
275691
|
+
test: [/tizen/i],
|
|
275692
|
+
describe(ua) {
|
|
275693
|
+
const version2 = Utils.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i, ua);
|
|
275694
|
+
return {
|
|
275695
|
+
name: OS_MAP.Tizen,
|
|
275696
|
+
version: version2
|
|
275697
|
+
};
|
|
275698
|
+
}
|
|
275699
|
+
},
|
|
275700
|
+
{
|
|
275701
|
+
test: [/linux/i],
|
|
275702
|
+
describe() {
|
|
275703
|
+
return {
|
|
275704
|
+
name: OS_MAP.Linux
|
|
275705
|
+
};
|
|
275706
|
+
}
|
|
275707
|
+
},
|
|
275708
|
+
{
|
|
275709
|
+
test: [/CrOS/],
|
|
275710
|
+
describe() {
|
|
275711
|
+
return {
|
|
275712
|
+
name: OS_MAP.ChromeOS
|
|
275713
|
+
};
|
|
275714
|
+
}
|
|
275715
|
+
},
|
|
275716
|
+
{
|
|
275717
|
+
test: [/PlayStation 4/],
|
|
275718
|
+
describe(ua) {
|
|
275719
|
+
const version2 = Utils.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i, ua);
|
|
275720
|
+
return {
|
|
275721
|
+
name: OS_MAP.PlayStation4,
|
|
275722
|
+
version: version2
|
|
275723
|
+
};
|
|
275724
|
+
}
|
|
275725
|
+
}
|
|
275726
|
+
];
|
|
275727
|
+
const platformParsersList = [
|
|
275728
|
+
{
|
|
275729
|
+
test: [/googlebot/i],
|
|
275730
|
+
describe() {
|
|
275731
|
+
return {
|
|
275732
|
+
type: "bot",
|
|
275733
|
+
vendor: "Google"
|
|
275734
|
+
};
|
|
275735
|
+
}
|
|
275736
|
+
},
|
|
275737
|
+
{
|
|
275738
|
+
test: [/huawei/i],
|
|
275739
|
+
describe(ua) {
|
|
275740
|
+
const model = Utils.getFirstMatch(/(can-l01)/i, ua) && "Nova";
|
|
275741
|
+
const platform = {
|
|
275742
|
+
type: PLATFORMS_MAP.mobile,
|
|
275743
|
+
vendor: "Huawei"
|
|
275744
|
+
};
|
|
275745
|
+
if (model) {
|
|
275746
|
+
platform.model = model;
|
|
275747
|
+
}
|
|
275748
|
+
return platform;
|
|
275749
|
+
}
|
|
275750
|
+
},
|
|
275751
|
+
{
|
|
275752
|
+
test: [/nexus\s*(?:7|8|9|10).*/i],
|
|
275753
|
+
describe() {
|
|
275754
|
+
return {
|
|
275755
|
+
type: PLATFORMS_MAP.tablet,
|
|
275756
|
+
vendor: "Nexus"
|
|
275757
|
+
};
|
|
275758
|
+
}
|
|
275759
|
+
},
|
|
275760
|
+
{
|
|
275761
|
+
test: [/ipad/i],
|
|
275762
|
+
describe() {
|
|
275763
|
+
return {
|
|
275764
|
+
type: PLATFORMS_MAP.tablet,
|
|
275765
|
+
vendor: "Apple",
|
|
275766
|
+
model: "iPad"
|
|
275767
|
+
};
|
|
275768
|
+
}
|
|
275769
|
+
},
|
|
275770
|
+
{
|
|
275771
|
+
test: [/Macintosh(.*?) FxiOS(.*?)\//],
|
|
275772
|
+
describe() {
|
|
275773
|
+
return {
|
|
275774
|
+
type: PLATFORMS_MAP.tablet,
|
|
275775
|
+
vendor: "Apple",
|
|
275776
|
+
model: "iPad"
|
|
275777
|
+
};
|
|
275778
|
+
}
|
|
275779
|
+
},
|
|
275780
|
+
{
|
|
275781
|
+
test: [/kftt build/i],
|
|
275782
|
+
describe() {
|
|
275783
|
+
return {
|
|
275784
|
+
type: PLATFORMS_MAP.tablet,
|
|
275785
|
+
vendor: "Amazon",
|
|
275786
|
+
model: "Kindle Fire HD 7"
|
|
275787
|
+
};
|
|
275788
|
+
}
|
|
275789
|
+
},
|
|
275790
|
+
{
|
|
275791
|
+
test: [/silk/i],
|
|
275792
|
+
describe() {
|
|
275793
|
+
return {
|
|
275794
|
+
type: PLATFORMS_MAP.tablet,
|
|
275795
|
+
vendor: "Amazon"
|
|
275796
|
+
};
|
|
275797
|
+
}
|
|
275798
|
+
},
|
|
275799
|
+
{
|
|
275800
|
+
test: [/tablet(?! pc)/i],
|
|
275801
|
+
describe() {
|
|
275802
|
+
return {
|
|
275803
|
+
type: PLATFORMS_MAP.tablet
|
|
275804
|
+
};
|
|
275805
|
+
}
|
|
275806
|
+
},
|
|
275807
|
+
{
|
|
275808
|
+
test(parser2) {
|
|
275809
|
+
const iDevice = parser2.test(/ipod|iphone/i);
|
|
275810
|
+
const likeIDevice = parser2.test(/like (ipod|iphone)/i);
|
|
275811
|
+
return iDevice && !likeIDevice;
|
|
275812
|
+
},
|
|
275813
|
+
describe(ua) {
|
|
275814
|
+
const model = Utils.getFirstMatch(/(ipod|iphone)/i, ua);
|
|
275815
|
+
return {
|
|
275816
|
+
type: PLATFORMS_MAP.mobile,
|
|
275817
|
+
vendor: "Apple",
|
|
275818
|
+
model
|
|
275819
|
+
};
|
|
275820
|
+
}
|
|
275821
|
+
},
|
|
275822
|
+
{
|
|
275823
|
+
test: [/nexus\s*[0-6].*/i, /galaxy nexus/i],
|
|
275824
|
+
describe() {
|
|
275825
|
+
return {
|
|
275826
|
+
type: PLATFORMS_MAP.mobile,
|
|
275827
|
+
vendor: "Nexus"
|
|
275828
|
+
};
|
|
275829
|
+
}
|
|
275830
|
+
},
|
|
275831
|
+
{
|
|
275832
|
+
test: [/[^-]mobi/i],
|
|
275833
|
+
describe() {
|
|
275834
|
+
return {
|
|
275835
|
+
type: PLATFORMS_MAP.mobile
|
|
275836
|
+
};
|
|
275837
|
+
}
|
|
275838
|
+
},
|
|
275839
|
+
{
|
|
275840
|
+
test(parser2) {
|
|
275841
|
+
return parser2.getBrowserName(true) === "blackberry";
|
|
275842
|
+
},
|
|
275843
|
+
describe() {
|
|
275844
|
+
return {
|
|
275845
|
+
type: PLATFORMS_MAP.mobile,
|
|
275846
|
+
vendor: "BlackBerry"
|
|
275847
|
+
};
|
|
275848
|
+
}
|
|
275849
|
+
},
|
|
275850
|
+
{
|
|
275851
|
+
test(parser2) {
|
|
275852
|
+
return parser2.getBrowserName(true) === "bada";
|
|
275853
|
+
},
|
|
275854
|
+
describe() {
|
|
275855
|
+
return {
|
|
275856
|
+
type: PLATFORMS_MAP.mobile
|
|
275857
|
+
};
|
|
275858
|
+
}
|
|
275859
|
+
},
|
|
275860
|
+
{
|
|
275861
|
+
test(parser2) {
|
|
275862
|
+
return parser2.getBrowserName() === "windows phone";
|
|
275863
|
+
},
|
|
275864
|
+
describe() {
|
|
275865
|
+
return {
|
|
275866
|
+
type: PLATFORMS_MAP.mobile,
|
|
275867
|
+
vendor: "Microsoft"
|
|
275868
|
+
};
|
|
275869
|
+
}
|
|
275870
|
+
},
|
|
275871
|
+
{
|
|
275872
|
+
test(parser2) {
|
|
275873
|
+
const osMajorVersion = Number(String(parser2.getOSVersion()).split(".")[0]);
|
|
275874
|
+
return parser2.getOSName(true) === "android" && osMajorVersion >= 3;
|
|
275875
|
+
},
|
|
275876
|
+
describe() {
|
|
275877
|
+
return {
|
|
275878
|
+
type: PLATFORMS_MAP.tablet
|
|
275879
|
+
};
|
|
275880
|
+
}
|
|
275881
|
+
},
|
|
275882
|
+
{
|
|
275883
|
+
test(parser2) {
|
|
275884
|
+
return parser2.getOSName(true) === "android";
|
|
275885
|
+
},
|
|
275886
|
+
describe() {
|
|
275887
|
+
return {
|
|
275888
|
+
type: PLATFORMS_MAP.mobile
|
|
275889
|
+
};
|
|
275890
|
+
}
|
|
275891
|
+
},
|
|
275892
|
+
{
|
|
275893
|
+
test(parser2) {
|
|
275894
|
+
return parser2.getOSName(true) === "macos";
|
|
275895
|
+
},
|
|
275896
|
+
describe() {
|
|
275897
|
+
return {
|
|
275898
|
+
type: PLATFORMS_MAP.desktop,
|
|
275899
|
+
vendor: "Apple"
|
|
275900
|
+
};
|
|
275901
|
+
}
|
|
275902
|
+
},
|
|
275903
|
+
{
|
|
275904
|
+
test(parser2) {
|
|
275905
|
+
return parser2.getOSName(true) === "windows";
|
|
275906
|
+
},
|
|
275907
|
+
describe() {
|
|
275908
|
+
return {
|
|
275909
|
+
type: PLATFORMS_MAP.desktop
|
|
275910
|
+
};
|
|
275911
|
+
}
|
|
275912
|
+
},
|
|
275913
|
+
{
|
|
275914
|
+
test(parser2) {
|
|
275915
|
+
return parser2.getOSName(true) === "linux";
|
|
275916
|
+
},
|
|
275917
|
+
describe() {
|
|
275918
|
+
return {
|
|
275919
|
+
type: PLATFORMS_MAP.desktop
|
|
275920
|
+
};
|
|
275921
|
+
}
|
|
275922
|
+
},
|
|
275923
|
+
{
|
|
275924
|
+
test(parser2) {
|
|
275925
|
+
return parser2.getOSName(true) === "playstation 4";
|
|
275926
|
+
},
|
|
275927
|
+
describe() {
|
|
275928
|
+
return {
|
|
275929
|
+
type: PLATFORMS_MAP.tv
|
|
275930
|
+
};
|
|
275931
|
+
}
|
|
275932
|
+
},
|
|
275933
|
+
{
|
|
275934
|
+
test(parser2) {
|
|
275935
|
+
return parser2.getOSName(true) === "roku";
|
|
275936
|
+
},
|
|
275937
|
+
describe() {
|
|
275938
|
+
return {
|
|
275939
|
+
type: PLATFORMS_MAP.tv
|
|
275940
|
+
};
|
|
275941
|
+
}
|
|
275942
|
+
}
|
|
275943
|
+
];
|
|
275944
|
+
const enginesParsersList = [
|
|
275945
|
+
{
|
|
275946
|
+
test(parser2) {
|
|
275947
|
+
return parser2.getBrowserName(true) === "microsoft edge";
|
|
275948
|
+
},
|
|
275949
|
+
describe(ua) {
|
|
275950
|
+
const isBlinkBased = /\sedg\//i.test(ua);
|
|
275951
|
+
if (isBlinkBased) {
|
|
275952
|
+
return {
|
|
275953
|
+
name: ENGINE_MAP.Blink
|
|
275954
|
+
};
|
|
275955
|
+
}
|
|
275956
|
+
const version2 = Utils.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i, ua);
|
|
275957
|
+
return {
|
|
275958
|
+
name: ENGINE_MAP.EdgeHTML,
|
|
275959
|
+
version: version2
|
|
275960
|
+
};
|
|
275961
|
+
}
|
|
275962
|
+
},
|
|
275963
|
+
{
|
|
275964
|
+
test: [/trident/i],
|
|
275965
|
+
describe(ua) {
|
|
275966
|
+
const engine = {
|
|
275967
|
+
name: ENGINE_MAP.Trident
|
|
275968
|
+
};
|
|
275969
|
+
const version2 = Utils.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i, ua);
|
|
275970
|
+
if (version2) {
|
|
275971
|
+
engine.version = version2;
|
|
275972
|
+
}
|
|
275973
|
+
return engine;
|
|
275974
|
+
}
|
|
275975
|
+
},
|
|
275976
|
+
{
|
|
275977
|
+
test(parser2) {
|
|
275978
|
+
return parser2.test(/presto/i);
|
|
275979
|
+
},
|
|
275980
|
+
describe(ua) {
|
|
275981
|
+
const engine = {
|
|
275982
|
+
name: ENGINE_MAP.Presto
|
|
275983
|
+
};
|
|
275984
|
+
const version2 = Utils.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i, ua);
|
|
275985
|
+
if (version2) {
|
|
275986
|
+
engine.version = version2;
|
|
275987
|
+
}
|
|
275988
|
+
return engine;
|
|
275989
|
+
}
|
|
275990
|
+
},
|
|
275991
|
+
{
|
|
275992
|
+
test(parser2) {
|
|
275993
|
+
const isGecko = parser2.test(/gecko/i);
|
|
275994
|
+
const likeGecko = parser2.test(/like gecko/i);
|
|
275995
|
+
return isGecko && !likeGecko;
|
|
275996
|
+
},
|
|
275997
|
+
describe(ua) {
|
|
275998
|
+
const engine = {
|
|
275999
|
+
name: ENGINE_MAP.Gecko
|
|
276000
|
+
};
|
|
276001
|
+
const version2 = Utils.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i, ua);
|
|
276002
|
+
if (version2) {
|
|
276003
|
+
engine.version = version2;
|
|
276004
|
+
}
|
|
276005
|
+
return engine;
|
|
276006
|
+
}
|
|
276007
|
+
},
|
|
276008
|
+
{
|
|
276009
|
+
test: [/(apple)?webkit\/537\.36/i],
|
|
276010
|
+
describe() {
|
|
276011
|
+
return {
|
|
276012
|
+
name: ENGINE_MAP.Blink
|
|
276013
|
+
};
|
|
276014
|
+
}
|
|
276015
|
+
},
|
|
276016
|
+
{
|
|
276017
|
+
test: [/(apple)?webkit/i],
|
|
276018
|
+
describe(ua) {
|
|
276019
|
+
const engine = {
|
|
276020
|
+
name: ENGINE_MAP.WebKit
|
|
276021
|
+
};
|
|
276022
|
+
const version2 = Utils.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i, ua);
|
|
276023
|
+
if (version2) {
|
|
276024
|
+
engine.version = version2;
|
|
276025
|
+
}
|
|
276026
|
+
return engine;
|
|
276027
|
+
}
|
|
276028
|
+
}
|
|
276029
|
+
];
|
|
276030
|
+
class Parser {
|
|
276031
|
+
constructor(UA, skipParsing = false) {
|
|
276032
|
+
if (UA === void 0 || UA === null || UA === "") {
|
|
276033
|
+
throw new Error("UserAgent parameter can't be empty");
|
|
276034
|
+
}
|
|
276035
|
+
this._ua = UA;
|
|
276036
|
+
this.parsedResult = {};
|
|
276037
|
+
if (skipParsing !== true) {
|
|
276038
|
+
this.parse();
|
|
276039
|
+
}
|
|
276040
|
+
}
|
|
276041
|
+
getUA() {
|
|
276042
|
+
return this._ua;
|
|
276043
|
+
}
|
|
276044
|
+
test(regex2) {
|
|
276045
|
+
return regex2.test(this._ua);
|
|
276046
|
+
}
|
|
276047
|
+
parseBrowser() {
|
|
276048
|
+
this.parsedResult.browser = {};
|
|
276049
|
+
const browserDescriptor = Utils.find(browsersList, (_browser) => {
|
|
276050
|
+
if (typeof _browser.test === "function") {
|
|
276051
|
+
return _browser.test(this);
|
|
276052
|
+
}
|
|
276053
|
+
if (_browser.test instanceof Array) {
|
|
276054
|
+
return _browser.test.some((condition) => this.test(condition));
|
|
276055
|
+
}
|
|
276056
|
+
throw new Error("Browser's test function is not valid");
|
|
276057
|
+
});
|
|
276058
|
+
if (browserDescriptor) {
|
|
276059
|
+
this.parsedResult.browser = browserDescriptor.describe(this.getUA());
|
|
276060
|
+
}
|
|
276061
|
+
return this.parsedResult.browser;
|
|
276062
|
+
}
|
|
276063
|
+
getBrowser() {
|
|
276064
|
+
if (this.parsedResult.browser) {
|
|
276065
|
+
return this.parsedResult.browser;
|
|
276066
|
+
}
|
|
276067
|
+
return this.parseBrowser();
|
|
276068
|
+
}
|
|
276069
|
+
getBrowserName(toLowerCase) {
|
|
276070
|
+
if (toLowerCase) {
|
|
276071
|
+
return String(this.getBrowser().name).toLowerCase() || "";
|
|
276072
|
+
}
|
|
276073
|
+
return this.getBrowser().name || "";
|
|
276074
|
+
}
|
|
276075
|
+
getBrowserVersion() {
|
|
276076
|
+
return this.getBrowser().version;
|
|
276077
|
+
}
|
|
276078
|
+
getOS() {
|
|
276079
|
+
if (this.parsedResult.os) {
|
|
276080
|
+
return this.parsedResult.os;
|
|
276081
|
+
}
|
|
276082
|
+
return this.parseOS();
|
|
276083
|
+
}
|
|
276084
|
+
parseOS() {
|
|
276085
|
+
this.parsedResult.os = {};
|
|
276086
|
+
const os = Utils.find(osParsersList, (_os) => {
|
|
276087
|
+
if (typeof _os.test === "function") {
|
|
276088
|
+
return _os.test(this);
|
|
276089
|
+
}
|
|
276090
|
+
if (_os.test instanceof Array) {
|
|
276091
|
+
return _os.test.some((condition) => this.test(condition));
|
|
276092
|
+
}
|
|
276093
|
+
throw new Error("Browser's test function is not valid");
|
|
276094
|
+
});
|
|
276095
|
+
if (os) {
|
|
276096
|
+
this.parsedResult.os = os.describe(this.getUA());
|
|
276097
|
+
}
|
|
276098
|
+
return this.parsedResult.os;
|
|
276099
|
+
}
|
|
276100
|
+
getOSName(toLowerCase) {
|
|
276101
|
+
const { name: name2 } = this.getOS();
|
|
276102
|
+
if (toLowerCase) {
|
|
276103
|
+
return String(name2).toLowerCase() || "";
|
|
276104
|
+
}
|
|
276105
|
+
return name2 || "";
|
|
276106
|
+
}
|
|
276107
|
+
getOSVersion() {
|
|
276108
|
+
return this.getOS().version;
|
|
276109
|
+
}
|
|
276110
|
+
getPlatform() {
|
|
276111
|
+
if (this.parsedResult.platform) {
|
|
276112
|
+
return this.parsedResult.platform;
|
|
276113
|
+
}
|
|
276114
|
+
return this.parsePlatform();
|
|
276115
|
+
}
|
|
276116
|
+
getPlatformType(toLowerCase = false) {
|
|
276117
|
+
const { type: type3 } = this.getPlatform();
|
|
276118
|
+
if (toLowerCase) {
|
|
276119
|
+
return String(type3).toLowerCase() || "";
|
|
276120
|
+
}
|
|
276121
|
+
return type3 || "";
|
|
276122
|
+
}
|
|
276123
|
+
parsePlatform() {
|
|
276124
|
+
this.parsedResult.platform = {};
|
|
276125
|
+
const platform = Utils.find(platformParsersList, (_platform) => {
|
|
276126
|
+
if (typeof _platform.test === "function") {
|
|
276127
|
+
return _platform.test(this);
|
|
276128
|
+
}
|
|
276129
|
+
if (_platform.test instanceof Array) {
|
|
276130
|
+
return _platform.test.some((condition) => this.test(condition));
|
|
276131
|
+
}
|
|
276132
|
+
throw new Error("Browser's test function is not valid");
|
|
276133
|
+
});
|
|
276134
|
+
if (platform) {
|
|
276135
|
+
this.parsedResult.platform = platform.describe(this.getUA());
|
|
276136
|
+
}
|
|
276137
|
+
return this.parsedResult.platform;
|
|
276138
|
+
}
|
|
276139
|
+
getEngine() {
|
|
276140
|
+
if (this.parsedResult.engine) {
|
|
276141
|
+
return this.parsedResult.engine;
|
|
276142
|
+
}
|
|
276143
|
+
return this.parseEngine();
|
|
276144
|
+
}
|
|
276145
|
+
getEngineName(toLowerCase) {
|
|
276146
|
+
if (toLowerCase) {
|
|
276147
|
+
return String(this.getEngine().name).toLowerCase() || "";
|
|
276148
|
+
}
|
|
276149
|
+
return this.getEngine().name || "";
|
|
276150
|
+
}
|
|
276151
|
+
parseEngine() {
|
|
276152
|
+
this.parsedResult.engine = {};
|
|
276153
|
+
const engine = Utils.find(enginesParsersList, (_engine) => {
|
|
276154
|
+
if (typeof _engine.test === "function") {
|
|
276155
|
+
return _engine.test(this);
|
|
276156
|
+
}
|
|
276157
|
+
if (_engine.test instanceof Array) {
|
|
276158
|
+
return _engine.test.some((condition) => this.test(condition));
|
|
276159
|
+
}
|
|
276160
|
+
throw new Error("Browser's test function is not valid");
|
|
276161
|
+
});
|
|
276162
|
+
if (engine) {
|
|
276163
|
+
this.parsedResult.engine = engine.describe(this.getUA());
|
|
276164
|
+
}
|
|
276165
|
+
return this.parsedResult.engine;
|
|
276166
|
+
}
|
|
276167
|
+
parse() {
|
|
276168
|
+
this.parseBrowser();
|
|
276169
|
+
this.parseOS();
|
|
276170
|
+
this.parsePlatform();
|
|
276171
|
+
this.parseEngine();
|
|
276172
|
+
return this;
|
|
276173
|
+
}
|
|
276174
|
+
getResult() {
|
|
276175
|
+
return Utils.assign({}, this.parsedResult);
|
|
276176
|
+
}
|
|
276177
|
+
satisfies(checkTree) {
|
|
276178
|
+
const platformsAndOSes = {};
|
|
276179
|
+
let platformsAndOSCounter = 0;
|
|
276180
|
+
const browsers = {};
|
|
276181
|
+
let browsersCounter = 0;
|
|
276182
|
+
const allDefinitions = Object.keys(checkTree);
|
|
276183
|
+
allDefinitions.forEach((key2) => {
|
|
276184
|
+
const currentDefinition = checkTree[key2];
|
|
276185
|
+
if (typeof currentDefinition === "string") {
|
|
276186
|
+
browsers[key2] = currentDefinition;
|
|
276187
|
+
browsersCounter += 1;
|
|
276188
|
+
} else if (typeof currentDefinition === "object") {
|
|
276189
|
+
platformsAndOSes[key2] = currentDefinition;
|
|
276190
|
+
platformsAndOSCounter += 1;
|
|
276191
|
+
}
|
|
276192
|
+
});
|
|
276193
|
+
if (platformsAndOSCounter > 0) {
|
|
276194
|
+
const platformsAndOSNames = Object.keys(platformsAndOSes);
|
|
276195
|
+
const OSMatchingDefinition = Utils.find(platformsAndOSNames, (name2) => this.isOS(name2));
|
|
276196
|
+
if (OSMatchingDefinition) {
|
|
276197
|
+
const osResult = this.satisfies(platformsAndOSes[OSMatchingDefinition]);
|
|
276198
|
+
if (osResult !== void 0) {
|
|
276199
|
+
return osResult;
|
|
276200
|
+
}
|
|
276201
|
+
}
|
|
276202
|
+
const platformMatchingDefinition = Utils.find(
|
|
276203
|
+
platformsAndOSNames,
|
|
276204
|
+
(name2) => this.isPlatform(name2)
|
|
276205
|
+
);
|
|
276206
|
+
if (platformMatchingDefinition) {
|
|
276207
|
+
const platformResult = this.satisfies(platformsAndOSes[platformMatchingDefinition]);
|
|
276208
|
+
if (platformResult !== void 0) {
|
|
276209
|
+
return platformResult;
|
|
276210
|
+
}
|
|
276211
|
+
}
|
|
276212
|
+
}
|
|
276213
|
+
if (browsersCounter > 0) {
|
|
276214
|
+
const browserNames = Object.keys(browsers);
|
|
276215
|
+
const matchingDefinition = Utils.find(browserNames, (name2) => this.isBrowser(name2, true));
|
|
276216
|
+
if (matchingDefinition !== void 0) {
|
|
276217
|
+
return this.compareVersion(browsers[matchingDefinition]);
|
|
276218
|
+
}
|
|
276219
|
+
}
|
|
276220
|
+
return void 0;
|
|
276221
|
+
}
|
|
276222
|
+
isBrowser(browserName, includingAlias = false) {
|
|
276223
|
+
const defaultBrowserName = this.getBrowserName().toLowerCase();
|
|
276224
|
+
let browserNameLower = browserName.toLowerCase();
|
|
276225
|
+
const alias = Utils.getBrowserTypeByAlias(browserNameLower);
|
|
276226
|
+
if (includingAlias && alias) {
|
|
276227
|
+
browserNameLower = alias.toLowerCase();
|
|
276228
|
+
}
|
|
276229
|
+
return browserNameLower === defaultBrowserName;
|
|
276230
|
+
}
|
|
276231
|
+
compareVersion(version2) {
|
|
276232
|
+
let expectedResults = [0];
|
|
276233
|
+
let comparableVersion = version2;
|
|
276234
|
+
let isLoose = false;
|
|
276235
|
+
const currentBrowserVersion = this.getBrowserVersion();
|
|
276236
|
+
if (typeof currentBrowserVersion !== "string") {
|
|
276237
|
+
return void 0;
|
|
276238
|
+
}
|
|
276239
|
+
if (version2[0] === ">" || version2[0] === "<") {
|
|
276240
|
+
comparableVersion = version2.substr(1);
|
|
276241
|
+
if (version2[1] === "=") {
|
|
276242
|
+
isLoose = true;
|
|
276243
|
+
comparableVersion = version2.substr(2);
|
|
276244
|
+
} else {
|
|
276245
|
+
expectedResults = [];
|
|
276246
|
+
}
|
|
276247
|
+
if (version2[0] === ">") {
|
|
276248
|
+
expectedResults.push(1);
|
|
276249
|
+
} else {
|
|
276250
|
+
expectedResults.push(-1);
|
|
276251
|
+
}
|
|
276252
|
+
} else if (version2[0] === "=") {
|
|
276253
|
+
comparableVersion = version2.substr(1);
|
|
276254
|
+
} else if (version2[0] === "~") {
|
|
276255
|
+
isLoose = true;
|
|
276256
|
+
comparableVersion = version2.substr(1);
|
|
276257
|
+
}
|
|
276258
|
+
return expectedResults.indexOf(
|
|
276259
|
+
Utils.compareVersions(currentBrowserVersion, comparableVersion, isLoose)
|
|
276260
|
+
) > -1;
|
|
276261
|
+
}
|
|
276262
|
+
isOS(osName) {
|
|
276263
|
+
return this.getOSName(true) === String(osName).toLowerCase();
|
|
276264
|
+
}
|
|
276265
|
+
isPlatform(platformType) {
|
|
276266
|
+
return this.getPlatformType(true) === String(platformType).toLowerCase();
|
|
276267
|
+
}
|
|
276268
|
+
isEngine(engineName) {
|
|
276269
|
+
return this.getEngineName(true) === String(engineName).toLowerCase();
|
|
276270
|
+
}
|
|
276271
|
+
is(anything, includingAlias = false) {
|
|
276272
|
+
return this.isBrowser(anything, includingAlias) || this.isOS(anything) || this.isPlatform(anything);
|
|
276273
|
+
}
|
|
276274
|
+
some(anythings = []) {
|
|
276275
|
+
return anythings.some((anything) => this.is(anything));
|
|
276276
|
+
}
|
|
276277
|
+
}
|
|
276278
|
+
/*!
|
|
276279
|
+
* Bowser - a browser detector
|
|
276280
|
+
* https://github.com/lancedikson/bowser
|
|
276281
|
+
* MIT License | (c) Dustin Diaz 2012-2015
|
|
276282
|
+
* MIT License | (c) Denis Demchenko 2015-2019
|
|
276283
|
+
*/
|
|
276284
|
+
class Bowser {
|
|
276285
|
+
static getParser(UA, skipParsing = false) {
|
|
276286
|
+
if (typeof UA !== "string") {
|
|
276287
|
+
throw new Error("UserAgent should be a string");
|
|
276288
|
+
}
|
|
276289
|
+
return new Parser(UA, skipParsing);
|
|
276290
|
+
}
|
|
276291
|
+
static parse(UA) {
|
|
276292
|
+
return new Parser(UA).getResult();
|
|
276293
|
+
}
|
|
276294
|
+
static get BROWSER_MAP() {
|
|
276295
|
+
return BROWSER_MAP;
|
|
276296
|
+
}
|
|
276297
|
+
static get ENGINE_MAP() {
|
|
276298
|
+
return ENGINE_MAP;
|
|
276299
|
+
}
|
|
276300
|
+
static get OS_MAP() {
|
|
276301
|
+
return OS_MAP;
|
|
276302
|
+
}
|
|
276303
|
+
static get PLATFORMS_MAP() {
|
|
276304
|
+
return PLATFORMS_MAP;
|
|
276305
|
+
}
|
|
276306
|
+
}
|
|
276307
|
+
var lzString = { exports: {} };
|
|
276308
|
+
(function(module2) {
|
|
276309
|
+
var LZString = function() {
|
|
276310
|
+
var f2 = String.fromCharCode;
|
|
276311
|
+
var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
276312
|
+
var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
|
|
276313
|
+
var baseReverseDic = {};
|
|
276314
|
+
function getBaseValue(alphabet, character) {
|
|
276315
|
+
if (!baseReverseDic[alphabet]) {
|
|
276316
|
+
baseReverseDic[alphabet] = {};
|
|
276317
|
+
for (var i2 = 0; i2 < alphabet.length; i2++) {
|
|
276318
|
+
baseReverseDic[alphabet][alphabet.charAt(i2)] = i2;
|
|
276319
|
+
}
|
|
276320
|
+
}
|
|
276321
|
+
return baseReverseDic[alphabet][character];
|
|
276322
|
+
}
|
|
276323
|
+
var LZString2 = {
|
|
276324
|
+
compressToBase64: function(input) {
|
|
276325
|
+
if (input == null)
|
|
276326
|
+
return "";
|
|
276327
|
+
var res = LZString2._compress(input, 6, function(a2) {
|
|
276328
|
+
return keyStrBase64.charAt(a2);
|
|
276329
|
+
});
|
|
276330
|
+
switch (res.length % 4) {
|
|
276331
|
+
default:
|
|
276332
|
+
case 0:
|
|
276333
|
+
return res;
|
|
276334
|
+
case 1:
|
|
276335
|
+
return res + "===";
|
|
276336
|
+
case 2:
|
|
276337
|
+
return res + "==";
|
|
276338
|
+
case 3:
|
|
276339
|
+
return res + "=";
|
|
276340
|
+
}
|
|
276341
|
+
},
|
|
276342
|
+
decompressFromBase64: function(input) {
|
|
276343
|
+
if (input == null)
|
|
276344
|
+
return "";
|
|
276345
|
+
if (input == "")
|
|
276346
|
+
return null;
|
|
276347
|
+
return LZString2._decompress(input.length, 32, function(index2) {
|
|
276348
|
+
return getBaseValue(keyStrBase64, input.charAt(index2));
|
|
276349
|
+
});
|
|
276350
|
+
},
|
|
276351
|
+
compressToUTF16: function(input) {
|
|
276352
|
+
if (input == null)
|
|
276353
|
+
return "";
|
|
276354
|
+
return LZString2._compress(input, 15, function(a2) {
|
|
276355
|
+
return f2(a2 + 32);
|
|
276356
|
+
}) + " ";
|
|
276357
|
+
},
|
|
276358
|
+
decompressFromUTF16: function(compressed) {
|
|
276359
|
+
if (compressed == null)
|
|
276360
|
+
return "";
|
|
276361
|
+
if (compressed == "")
|
|
276362
|
+
return null;
|
|
276363
|
+
return LZString2._decompress(compressed.length, 16384, function(index2) {
|
|
276364
|
+
return compressed.charCodeAt(index2) - 32;
|
|
276365
|
+
});
|
|
276366
|
+
},
|
|
276367
|
+
compressToUint8Array: function(uncompressed) {
|
|
276368
|
+
var compressed = LZString2.compress(uncompressed);
|
|
276369
|
+
var buf = new Uint8Array(compressed.length * 2);
|
|
276370
|
+
for (var i2 = 0, TotalLen = compressed.length; i2 < TotalLen; i2++) {
|
|
276371
|
+
var current_value = compressed.charCodeAt(i2);
|
|
276372
|
+
buf[i2 * 2] = current_value >>> 8;
|
|
276373
|
+
buf[i2 * 2 + 1] = current_value % 256;
|
|
276374
|
+
}
|
|
276375
|
+
return buf;
|
|
276376
|
+
},
|
|
276377
|
+
decompressFromUint8Array: function(compressed) {
|
|
276378
|
+
if (compressed === null || compressed === void 0) {
|
|
276379
|
+
return LZString2.decompress(compressed);
|
|
276380
|
+
} else {
|
|
276381
|
+
var buf = new Array(compressed.length / 2);
|
|
276382
|
+
for (var i2 = 0, TotalLen = buf.length; i2 < TotalLen; i2++) {
|
|
276383
|
+
buf[i2] = compressed[i2 * 2] * 256 + compressed[i2 * 2 + 1];
|
|
276384
|
+
}
|
|
276385
|
+
var result = [];
|
|
276386
|
+
buf.forEach(function(c2) {
|
|
276387
|
+
result.push(f2(c2));
|
|
276388
|
+
});
|
|
276389
|
+
return LZString2.decompress(result.join(""));
|
|
276390
|
+
}
|
|
276391
|
+
},
|
|
276392
|
+
compressToEncodedURIComponent: function(input) {
|
|
276393
|
+
if (input == null)
|
|
276394
|
+
return "";
|
|
276395
|
+
return LZString2._compress(input, 6, function(a2) {
|
|
276396
|
+
return keyStrUriSafe.charAt(a2);
|
|
276397
|
+
});
|
|
276398
|
+
},
|
|
276399
|
+
decompressFromEncodedURIComponent: function(input) {
|
|
276400
|
+
if (input == null)
|
|
276401
|
+
return "";
|
|
276402
|
+
if (input == "")
|
|
276403
|
+
return null;
|
|
276404
|
+
input = input.replace(/ /g, "+");
|
|
276405
|
+
return LZString2._decompress(input.length, 32, function(index2) {
|
|
276406
|
+
return getBaseValue(keyStrUriSafe, input.charAt(index2));
|
|
276407
|
+
});
|
|
276408
|
+
},
|
|
276409
|
+
compress: function(uncompressed) {
|
|
276410
|
+
return LZString2._compress(uncompressed, 16, function(a2) {
|
|
276411
|
+
return f2(a2);
|
|
276412
|
+
});
|
|
276413
|
+
},
|
|
276414
|
+
_compress: function(uncompressed, bitsPerChar, getCharFromInt) {
|
|
276415
|
+
if (uncompressed == null)
|
|
276416
|
+
return "";
|
|
276417
|
+
var i2, value2, context_dictionary = {}, context_dictionaryToCreate = {}, context_c = "", context_wc = "", context_w = "", context_enlargeIn = 2, context_dictSize = 3, context_numBits = 2, context_data = [], context_data_val = 0, context_data_position = 0, ii;
|
|
276418
|
+
for (ii = 0; ii < uncompressed.length; ii += 1) {
|
|
276419
|
+
context_c = uncompressed.charAt(ii);
|
|
276420
|
+
if (!Object.prototype.hasOwnProperty.call(context_dictionary, context_c)) {
|
|
276421
|
+
context_dictionary[context_c] = context_dictSize++;
|
|
276422
|
+
context_dictionaryToCreate[context_c] = true;
|
|
276423
|
+
}
|
|
276424
|
+
context_wc = context_w + context_c;
|
|
276425
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionary, context_wc)) {
|
|
276426
|
+
context_w = context_wc;
|
|
276427
|
+
} else {
|
|
276428
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
|
|
276429
|
+
if (context_w.charCodeAt(0) < 256) {
|
|
276430
|
+
for (i2 = 0; i2 < context_numBits; i2++) {
|
|
276431
|
+
context_data_val = context_data_val << 1;
|
|
276432
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
276433
|
+
context_data_position = 0;
|
|
276434
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
276435
|
+
context_data_val = 0;
|
|
276436
|
+
} else {
|
|
276437
|
+
context_data_position++;
|
|
276438
|
+
}
|
|
276439
|
+
}
|
|
276440
|
+
value2 = context_w.charCodeAt(0);
|
|
276441
|
+
for (i2 = 0; i2 < 8; i2++) {
|
|
276442
|
+
context_data_val = context_data_val << 1 | value2 & 1;
|
|
276443
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
276444
|
+
context_data_position = 0;
|
|
276445
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
276446
|
+
context_data_val = 0;
|
|
276447
|
+
} else {
|
|
276448
|
+
context_data_position++;
|
|
276449
|
+
}
|
|
276450
|
+
value2 = value2 >> 1;
|
|
276451
|
+
}
|
|
276452
|
+
} else {
|
|
276453
|
+
value2 = 1;
|
|
276454
|
+
for (i2 = 0; i2 < context_numBits; i2++) {
|
|
276455
|
+
context_data_val = context_data_val << 1 | value2;
|
|
276456
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
276457
|
+
context_data_position = 0;
|
|
276458
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
276459
|
+
context_data_val = 0;
|
|
276460
|
+
} else {
|
|
276461
|
+
context_data_position++;
|
|
276462
|
+
}
|
|
276463
|
+
value2 = 0;
|
|
276464
|
+
}
|
|
276465
|
+
value2 = context_w.charCodeAt(0);
|
|
276466
|
+
for (i2 = 0; i2 < 16; i2++) {
|
|
276467
|
+
context_data_val = context_data_val << 1 | value2 & 1;
|
|
276468
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
276469
|
+
context_data_position = 0;
|
|
276470
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
276471
|
+
context_data_val = 0;
|
|
276472
|
+
} else {
|
|
276473
|
+
context_data_position++;
|
|
276474
|
+
}
|
|
276475
|
+
value2 = value2 >> 1;
|
|
276476
|
+
}
|
|
276477
|
+
}
|
|
276478
|
+
context_enlargeIn--;
|
|
276479
|
+
if (context_enlargeIn == 0) {
|
|
276480
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
276481
|
+
context_numBits++;
|
|
276482
|
+
}
|
|
276483
|
+
delete context_dictionaryToCreate[context_w];
|
|
276484
|
+
} else {
|
|
276485
|
+
value2 = context_dictionary[context_w];
|
|
276486
|
+
for (i2 = 0; i2 < context_numBits; i2++) {
|
|
276487
|
+
context_data_val = context_data_val << 1 | value2 & 1;
|
|
276488
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
276489
|
+
context_data_position = 0;
|
|
276490
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
276491
|
+
context_data_val = 0;
|
|
276492
|
+
} else {
|
|
276493
|
+
context_data_position++;
|
|
276494
|
+
}
|
|
276495
|
+
value2 = value2 >> 1;
|
|
276496
|
+
}
|
|
276497
|
+
}
|
|
276498
|
+
context_enlargeIn--;
|
|
276499
|
+
if (context_enlargeIn == 0) {
|
|
276500
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
276501
|
+
context_numBits++;
|
|
276502
|
+
}
|
|
276503
|
+
context_dictionary[context_wc] = context_dictSize++;
|
|
276504
|
+
context_w = String(context_c);
|
|
276505
|
+
}
|
|
276506
|
+
}
|
|
276507
|
+
if (context_w !== "") {
|
|
276508
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
|
|
276509
|
+
if (context_w.charCodeAt(0) < 256) {
|
|
276510
|
+
for (i2 = 0; i2 < context_numBits; i2++) {
|
|
276511
|
+
context_data_val = context_data_val << 1;
|
|
276512
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
276513
|
+
context_data_position = 0;
|
|
276514
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
276515
|
+
context_data_val = 0;
|
|
276516
|
+
} else {
|
|
276517
|
+
context_data_position++;
|
|
276518
|
+
}
|
|
276519
|
+
}
|
|
276520
|
+
value2 = context_w.charCodeAt(0);
|
|
276521
|
+
for (i2 = 0; i2 < 8; i2++) {
|
|
276522
|
+
context_data_val = context_data_val << 1 | value2 & 1;
|
|
276523
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
276524
|
+
context_data_position = 0;
|
|
276525
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
276526
|
+
context_data_val = 0;
|
|
276527
|
+
} else {
|
|
276528
|
+
context_data_position++;
|
|
276529
|
+
}
|
|
276530
|
+
value2 = value2 >> 1;
|
|
276531
|
+
}
|
|
276532
|
+
} else {
|
|
276533
|
+
value2 = 1;
|
|
276534
|
+
for (i2 = 0; i2 < context_numBits; i2++) {
|
|
276535
|
+
context_data_val = context_data_val << 1 | value2;
|
|
276536
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
276537
|
+
context_data_position = 0;
|
|
276538
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
276539
|
+
context_data_val = 0;
|
|
276540
|
+
} else {
|
|
276541
|
+
context_data_position++;
|
|
276542
|
+
}
|
|
276543
|
+
value2 = 0;
|
|
276544
|
+
}
|
|
276545
|
+
value2 = context_w.charCodeAt(0);
|
|
276546
|
+
for (i2 = 0; i2 < 16; i2++) {
|
|
276547
|
+
context_data_val = context_data_val << 1 | value2 & 1;
|
|
276548
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
276549
|
+
context_data_position = 0;
|
|
276550
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
276551
|
+
context_data_val = 0;
|
|
276552
|
+
} else {
|
|
276553
|
+
context_data_position++;
|
|
276554
|
+
}
|
|
276555
|
+
value2 = value2 >> 1;
|
|
276556
|
+
}
|
|
276557
|
+
}
|
|
276558
|
+
context_enlargeIn--;
|
|
276559
|
+
if (context_enlargeIn == 0) {
|
|
276560
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
276561
|
+
context_numBits++;
|
|
276562
|
+
}
|
|
276563
|
+
delete context_dictionaryToCreate[context_w];
|
|
276564
|
+
} else {
|
|
276565
|
+
value2 = context_dictionary[context_w];
|
|
276566
|
+
for (i2 = 0; i2 < context_numBits; i2++) {
|
|
276567
|
+
context_data_val = context_data_val << 1 | value2 & 1;
|
|
276568
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
276569
|
+
context_data_position = 0;
|
|
276570
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
276571
|
+
context_data_val = 0;
|
|
276572
|
+
} else {
|
|
276573
|
+
context_data_position++;
|
|
276574
|
+
}
|
|
276575
|
+
value2 = value2 >> 1;
|
|
276576
|
+
}
|
|
276577
|
+
}
|
|
276578
|
+
context_enlargeIn--;
|
|
276579
|
+
if (context_enlargeIn == 0) {
|
|
276580
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
276581
|
+
context_numBits++;
|
|
276582
|
+
}
|
|
276583
|
+
}
|
|
276584
|
+
value2 = 2;
|
|
276585
|
+
for (i2 = 0; i2 < context_numBits; i2++) {
|
|
276586
|
+
context_data_val = context_data_val << 1 | value2 & 1;
|
|
276587
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
276588
|
+
context_data_position = 0;
|
|
276589
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
276590
|
+
context_data_val = 0;
|
|
276591
|
+
} else {
|
|
276592
|
+
context_data_position++;
|
|
276593
|
+
}
|
|
276594
|
+
value2 = value2 >> 1;
|
|
276595
|
+
}
|
|
276596
|
+
while (true) {
|
|
276597
|
+
context_data_val = context_data_val << 1;
|
|
276598
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
276599
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
276600
|
+
break;
|
|
276601
|
+
} else
|
|
276602
|
+
context_data_position++;
|
|
276603
|
+
}
|
|
276604
|
+
return context_data.join("");
|
|
276605
|
+
},
|
|
276606
|
+
decompress: function(compressed) {
|
|
276607
|
+
if (compressed == null)
|
|
276608
|
+
return "";
|
|
276609
|
+
if (compressed == "")
|
|
276610
|
+
return null;
|
|
276611
|
+
return LZString2._decompress(compressed.length, 32768, function(index2) {
|
|
276612
|
+
return compressed.charCodeAt(index2);
|
|
276613
|
+
});
|
|
276614
|
+
},
|
|
276615
|
+
_decompress: function(length2, resetValue, getNextValue) {
|
|
276616
|
+
var dictionary = [], enlargeIn = 4, dictSize = 4, numBits = 3, entry2 = "", result = [], i2, w2, bits, resb, maxpower, power, c2, data2 = { val: getNextValue(0), position: resetValue, index: 1 };
|
|
276617
|
+
for (i2 = 0; i2 < 3; i2 += 1) {
|
|
276618
|
+
dictionary[i2] = i2;
|
|
276619
|
+
}
|
|
276620
|
+
bits = 0;
|
|
276621
|
+
maxpower = Math.pow(2, 2);
|
|
276622
|
+
power = 1;
|
|
276623
|
+
while (power != maxpower) {
|
|
276624
|
+
resb = data2.val & data2.position;
|
|
276625
|
+
data2.position >>= 1;
|
|
276626
|
+
if (data2.position == 0) {
|
|
276627
|
+
data2.position = resetValue;
|
|
276628
|
+
data2.val = getNextValue(data2.index++);
|
|
276629
|
+
}
|
|
276630
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
276631
|
+
power <<= 1;
|
|
276632
|
+
}
|
|
276633
|
+
switch (bits) {
|
|
276634
|
+
case 0:
|
|
276635
|
+
bits = 0;
|
|
276636
|
+
maxpower = Math.pow(2, 8);
|
|
276637
|
+
power = 1;
|
|
276638
|
+
while (power != maxpower) {
|
|
276639
|
+
resb = data2.val & data2.position;
|
|
276640
|
+
data2.position >>= 1;
|
|
276641
|
+
if (data2.position == 0) {
|
|
276642
|
+
data2.position = resetValue;
|
|
276643
|
+
data2.val = getNextValue(data2.index++);
|
|
276644
|
+
}
|
|
276645
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
276646
|
+
power <<= 1;
|
|
276647
|
+
}
|
|
276648
|
+
c2 = f2(bits);
|
|
276649
|
+
break;
|
|
276650
|
+
case 1:
|
|
276651
|
+
bits = 0;
|
|
276652
|
+
maxpower = Math.pow(2, 16);
|
|
276653
|
+
power = 1;
|
|
276654
|
+
while (power != maxpower) {
|
|
276655
|
+
resb = data2.val & data2.position;
|
|
276656
|
+
data2.position >>= 1;
|
|
276657
|
+
if (data2.position == 0) {
|
|
276658
|
+
data2.position = resetValue;
|
|
276659
|
+
data2.val = getNextValue(data2.index++);
|
|
276660
|
+
}
|
|
276661
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
276662
|
+
power <<= 1;
|
|
276663
|
+
}
|
|
276664
|
+
c2 = f2(bits);
|
|
276665
|
+
break;
|
|
276666
|
+
case 2:
|
|
276667
|
+
return "";
|
|
276668
|
+
}
|
|
276669
|
+
dictionary[3] = c2;
|
|
276670
|
+
w2 = c2;
|
|
276671
|
+
result.push(c2);
|
|
276672
|
+
while (true) {
|
|
276673
|
+
if (data2.index > length2) {
|
|
276674
|
+
return "";
|
|
276675
|
+
}
|
|
276676
|
+
bits = 0;
|
|
276677
|
+
maxpower = Math.pow(2, numBits);
|
|
276678
|
+
power = 1;
|
|
276679
|
+
while (power != maxpower) {
|
|
276680
|
+
resb = data2.val & data2.position;
|
|
276681
|
+
data2.position >>= 1;
|
|
276682
|
+
if (data2.position == 0) {
|
|
276683
|
+
data2.position = resetValue;
|
|
276684
|
+
data2.val = getNextValue(data2.index++);
|
|
276685
|
+
}
|
|
276686
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
276687
|
+
power <<= 1;
|
|
276688
|
+
}
|
|
276689
|
+
switch (c2 = bits) {
|
|
276690
|
+
case 0:
|
|
276691
|
+
bits = 0;
|
|
276692
|
+
maxpower = Math.pow(2, 8);
|
|
276693
|
+
power = 1;
|
|
276694
|
+
while (power != maxpower) {
|
|
276695
|
+
resb = data2.val & data2.position;
|
|
276696
|
+
data2.position >>= 1;
|
|
276697
|
+
if (data2.position == 0) {
|
|
276698
|
+
data2.position = resetValue;
|
|
276699
|
+
data2.val = getNextValue(data2.index++);
|
|
276700
|
+
}
|
|
276701
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
276702
|
+
power <<= 1;
|
|
276703
|
+
}
|
|
276704
|
+
dictionary[dictSize++] = f2(bits);
|
|
276705
|
+
c2 = dictSize - 1;
|
|
276706
|
+
enlargeIn--;
|
|
276707
|
+
break;
|
|
276708
|
+
case 1:
|
|
276709
|
+
bits = 0;
|
|
276710
|
+
maxpower = Math.pow(2, 16);
|
|
276711
|
+
power = 1;
|
|
276712
|
+
while (power != maxpower) {
|
|
276713
|
+
resb = data2.val & data2.position;
|
|
276714
|
+
data2.position >>= 1;
|
|
276715
|
+
if (data2.position == 0) {
|
|
276716
|
+
data2.position = resetValue;
|
|
276717
|
+
data2.val = getNextValue(data2.index++);
|
|
276718
|
+
}
|
|
276719
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
276720
|
+
power <<= 1;
|
|
276721
|
+
}
|
|
276722
|
+
dictionary[dictSize++] = f2(bits);
|
|
276723
|
+
c2 = dictSize - 1;
|
|
276724
|
+
enlargeIn--;
|
|
276725
|
+
break;
|
|
276726
|
+
case 2:
|
|
276727
|
+
return result.join("");
|
|
276728
|
+
}
|
|
276729
|
+
if (enlargeIn == 0) {
|
|
276730
|
+
enlargeIn = Math.pow(2, numBits);
|
|
276731
|
+
numBits++;
|
|
276732
|
+
}
|
|
276733
|
+
if (dictionary[c2]) {
|
|
276734
|
+
entry2 = dictionary[c2];
|
|
276735
|
+
} else {
|
|
276736
|
+
if (c2 === dictSize) {
|
|
276737
|
+
entry2 = w2 + w2.charAt(0);
|
|
276738
|
+
} else {
|
|
276739
|
+
return null;
|
|
276740
|
+
}
|
|
276741
|
+
}
|
|
276742
|
+
result.push(entry2);
|
|
276743
|
+
dictionary[dictSize++] = w2 + entry2.charAt(0);
|
|
276744
|
+
enlargeIn--;
|
|
276745
|
+
w2 = entry2;
|
|
276746
|
+
if (enlargeIn == 0) {
|
|
276747
|
+
enlargeIn = Math.pow(2, numBits);
|
|
276748
|
+
numBits++;
|
|
276749
|
+
}
|
|
276750
|
+
}
|
|
276751
|
+
}
|
|
276752
|
+
};
|
|
276753
|
+
return LZString2;
|
|
276754
|
+
}();
|
|
276755
|
+
if (module2 != null) {
|
|
276756
|
+
module2.exports = LZString;
|
|
276757
|
+
}
|
|
276758
|
+
})(lzString);
|
|
276759
|
+
const CURRENT_VERSION = "0.0.1";
|
|
276760
|
+
const VITESSCE_CONF_QUERY_STRING = "vitessce_conf";
|
|
276761
|
+
const VERSION_QUERY_STRING = "vitessce_conf_version";
|
|
276762
|
+
const LENGTH_QUERY_STRING = "vitessce_conf_length";
|
|
276763
|
+
function sniffBrowser() {
|
|
276764
|
+
const { browser: browser2 } = Bowser.parse(window.navigator.userAgent);
|
|
276765
|
+
return browser2.name;
|
|
276766
|
+
}
|
|
276767
|
+
const MAX_BROWSER_URL_LENGTHS = {
|
|
276768
|
+
Chrome: 32779,
|
|
276769
|
+
"Internet Explorer": 2047,
|
|
276770
|
+
Edge: 2047,
|
|
276771
|
+
Safari: 65e3,
|
|
276772
|
+
Firefox: 65e3
|
|
276773
|
+
};
|
|
276774
|
+
class CompressedConfLengthError {
|
|
276775
|
+
constructor(message) {
|
|
276776
|
+
this.message = message;
|
|
276777
|
+
}
|
|
276778
|
+
}
|
|
276779
|
+
function encodeConfInUrl({ conf, onOverMaximumUrlLength = () => {
|
|
276780
|
+
} }) {
|
|
276781
|
+
const compressedConf = lzString.exports.compressToEncodedURIComponent(JSON.stringify(conf));
|
|
276782
|
+
const newParams = `${LENGTH_QUERY_STRING}=${compressedConf.length}&${VERSION_QUERY_STRING}=${CURRENT_VERSION}&${VITESSCE_CONF_QUERY_STRING}=${compressedConf}`;
|
|
276783
|
+
const browser2 = sniffBrowser();
|
|
276784
|
+
const maxLength = MAX_BROWSER_URL_LENGTHS[browser2];
|
|
276785
|
+
if (newParams.length > maxLength) {
|
|
276786
|
+
const willWorkOn = Object.entries(MAX_BROWSER_URL_LENGTHS).filter((entry2) => entry2[1] > newParams.length).map((entry2) => entry2[0]);
|
|
276787
|
+
const message = `Configuration is ${compressedConf.length} characters; max URL for ${browser2} is ${maxLength}: it will work on ${willWorkOn.join(", ") || "no browser"}.`;
|
|
276788
|
+
console.error(message);
|
|
276789
|
+
onOverMaximumUrlLength({ message, willWorkOn });
|
|
276790
|
+
}
|
|
276791
|
+
return newParams;
|
|
276792
|
+
}
|
|
276793
|
+
function decodeURLParamsToConf(queryString) {
|
|
276794
|
+
const params2 = new URLSearchParams(queryString.replace("#", "&"));
|
|
276795
|
+
const compressedConfString = params2.get(VITESSCE_CONF_QUERY_STRING);
|
|
276796
|
+
const expectedConfLength = Number(params2.get(LENGTH_QUERY_STRING));
|
|
276797
|
+
if (expectedConfLength !== compressedConfString.length) {
|
|
276798
|
+
throw new CompressedConfLengthError(`Compressed conf length (${compressedConfString.length}) != expected (${expectedConfLength}). URL truncated?`);
|
|
276799
|
+
}
|
|
276800
|
+
const version2 = params2.get(VERSION_QUERY_STRING);
|
|
276801
|
+
if (version2 === CURRENT_VERSION) {
|
|
276802
|
+
const conf = JSON.parse(lzString.exports.decompressFromEncodedURIComponent(compressedConfString));
|
|
276803
|
+
return conf;
|
|
276804
|
+
}
|
|
276805
|
+
throw new Error("Unrecognized URL Param Version");
|
|
276806
|
+
}
|
|
275149
276807
|
export {
|
|
275150
276808
|
BaseDecoder as B,
|
|
275151
276809
|
CoordinationType as C,
|
|
@@ -275156,6 +276814,8 @@ export {
|
|
|
275156
276814
|
LercAddCompression as a,
|
|
275157
276815
|
VitessceConfig as b,
|
|
275158
276816
|
Vitessce as c,
|
|
276817
|
+
decodeURLParamsToConf as d,
|
|
276818
|
+
encodeConfInUrl as e,
|
|
275159
276819
|
hconcat as h,
|
|
275160
276820
|
vconcat as v
|
|
275161
276821
|
};
|