@loaders.gl/polyfills 4.0.0-beta.1 → 4.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/dist.min.js CHANGED
@@ -13,1588 +13,6 @@
13
13
  __defProp(target, name, { get: all[name], enumerable: true });
14
14
  };
15
15
 
16
- // src/utils/globals.ts
17
- var isBrowser, globals, global_;
18
- var init_globals = __esm({
19
- "src/utils/globals.ts"() {
20
- isBrowser = typeof process !== "object" || String(process) !== "[object process]" || process.browser;
21
- globals = {
22
- self: typeof self !== "undefined" && self,
23
- window: typeof window !== "undefined" && window,
24
- global: typeof global !== "undefined" && global
25
- };
26
- global_ = globals.global || globals.self || globals.window;
27
- }
28
- });
29
-
30
- // src/lib/encoding-indexes.ts
31
- var encoding_indexes_default;
32
- var init_encoding_indexes = __esm({
33
- "src/lib/encoding-indexes.ts"() {
34
- encoding_indexes_default = {
35
- "ibm866": [1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 9617, 9618, 9619, 9474, 9508, 9569, 9570, 9558, 9557, 9571, 9553, 9559, 9565, 9564, 9563, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 9566, 9567, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 9575, 9576, 9572, 9573, 9561, 9560, 9554, 9555, 9579, 9578, 9496, 9484, 9608, 9604, 9612, 9616, 9600, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1025, 1105, 1028, 1108, 1031, 1111, 1038, 1118, 176, 8729, 183, 8730, 8470, 164, 9632, 160],
36
- "iso-8859-2": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 728, 321, 164, 317, 346, 167, 168, 352, 350, 356, 377, 173, 381, 379, 176, 261, 731, 322, 180, 318, 347, 711, 184, 353, 351, 357, 378, 733, 382, 380, 340, 193, 194, 258, 196, 313, 262, 199, 268, 201, 280, 203, 282, 205, 206, 270, 272, 323, 327, 211, 212, 336, 214, 215, 344, 366, 218, 368, 220, 221, 354, 223, 341, 225, 226, 259, 228, 314, 263, 231, 269, 233, 281, 235, 283, 237, 238, 271, 273, 324, 328, 243, 244, 337, 246, 247, 345, 367, 250, 369, 252, 253, 355, 729],
37
- "iso-8859-3": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 294, 728, 163, 164, null, 292, 167, 168, 304, 350, 286, 308, 173, null, 379, 176, 295, 178, 179, 180, 181, 293, 183, 184, 305, 351, 287, 309, 189, null, 380, 192, 193, 194, null, 196, 266, 264, 199, 200, 201, 202, 203, 204, 205, 206, 207, null, 209, 210, 211, 212, 288, 214, 215, 284, 217, 218, 219, 220, 364, 348, 223, 224, 225, 226, null, 228, 267, 265, 231, 232, 233, 234, 235, 236, 237, 238, 239, null, 241, 242, 243, 244, 289, 246, 247, 285, 249, 250, 251, 252, 365, 349, 729],
38
- "iso-8859-4": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 312, 342, 164, 296, 315, 167, 168, 352, 274, 290, 358, 173, 381, 175, 176, 261, 731, 343, 180, 297, 316, 711, 184, 353, 275, 291, 359, 330, 382, 331, 256, 193, 194, 195, 196, 197, 198, 302, 268, 201, 280, 203, 278, 205, 206, 298, 272, 325, 332, 310, 212, 213, 214, 215, 216, 370, 218, 219, 220, 360, 362, 223, 257, 225, 226, 227, 228, 229, 230, 303, 269, 233, 281, 235, 279, 237, 238, 299, 273, 326, 333, 311, 244, 245, 246, 247, 248, 371, 250, 251, 252, 361, 363, 729],
39
- "iso-8859-5": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 173, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 8470, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 167, 1118, 1119],
40
- "iso-8859-6": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, null, null, null, 164, null, null, null, null, null, null, null, 1548, 173, null, null, null, null, null, null, null, null, null, null, null, null, null, 1563, null, null, null, 1567, null, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1594, null, null, null, null, null, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, null, null, null, null, null, null, null, null, null, null, null, null, null],
41
- "iso-8859-7": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 8216, 8217, 163, 8364, 8367, 166, 167, 168, 169, 890, 171, 172, 173, null, 8213, 176, 177, 178, 179, 900, 901, 902, 183, 904, 905, 906, 187, 908, 189, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, null, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, null],
42
- "iso-8859-8": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, null, 162, 163, 164, 165, 166, 167, 168, 169, 215, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 247, 187, 188, 189, 190, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 8215, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, null, null, 8206, 8207, null],
43
- "iso-8859-10": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 274, 290, 298, 296, 310, 167, 315, 272, 352, 358, 381, 173, 362, 330, 176, 261, 275, 291, 299, 297, 311, 183, 316, 273, 353, 359, 382, 8213, 363, 331, 256, 193, 194, 195, 196, 197, 198, 302, 268, 201, 280, 203, 278, 205, 206, 207, 208, 325, 332, 211, 212, 213, 214, 360, 216, 370, 218, 219, 220, 221, 222, 223, 257, 225, 226, 227, 228, 229, 230, 303, 269, 233, 281, 235, 279, 237, 238, 239, 240, 326, 333, 243, 244, 245, 246, 361, 248, 371, 250, 251, 252, 253, 254, 312],
44
- "iso-8859-13": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 8221, 162, 163, 164, 8222, 166, 167, 216, 169, 342, 171, 172, 173, 174, 198, 176, 177, 178, 179, 8220, 181, 182, 183, 248, 185, 343, 187, 188, 189, 190, 230, 260, 302, 256, 262, 196, 197, 280, 274, 268, 201, 377, 278, 290, 310, 298, 315, 352, 323, 325, 211, 332, 213, 214, 215, 370, 321, 346, 362, 220, 379, 381, 223, 261, 303, 257, 263, 228, 229, 281, 275, 269, 233, 378, 279, 291, 311, 299, 316, 353, 324, 326, 243, 333, 245, 246, 247, 371, 322, 347, 363, 252, 380, 382, 8217],
45
- "iso-8859-14": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 7682, 7683, 163, 266, 267, 7690, 167, 7808, 169, 7810, 7691, 7922, 173, 174, 376, 7710, 7711, 288, 289, 7744, 7745, 182, 7766, 7809, 7767, 7811, 7776, 7923, 7812, 7813, 7777, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 372, 209, 210, 211, 212, 213, 214, 7786, 216, 217, 218, 219, 220, 221, 374, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 373, 241, 242, 243, 244, 245, 246, 7787, 248, 249, 250, 251, 252, 253, 375, 255],
46
- "iso-8859-15": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 8364, 165, 352, 167, 353, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 381, 181, 182, 183, 382, 185, 186, 187, 338, 339, 376, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255],
47
- "iso-8859-16": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 261, 321, 8364, 8222, 352, 167, 353, 169, 536, 171, 377, 173, 378, 379, 176, 177, 268, 322, 381, 8221, 182, 183, 382, 269, 537, 187, 338, 339, 376, 380, 192, 193, 194, 258, 196, 262, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 272, 323, 210, 211, 212, 336, 214, 346, 368, 217, 218, 219, 220, 280, 538, 223, 224, 225, 226, 259, 228, 263, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 273, 324, 242, 243, 244, 337, 246, 347, 369, 249, 250, 251, 252, 281, 539, 255],
48
- "koi8-r": [9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 8992, 9632, 8729, 8730, 8776, 8804, 8805, 160, 8993, 176, 178, 183, 247, 9552, 9553, 9554, 1105, 9555, 9556, 9557, 9558, 9559, 9560, 9561, 9562, 9563, 9564, 9565, 9566, 9567, 9568, 9569, 1025, 9570, 9571, 9572, 9573, 9574, 9575, 9576, 9577, 9578, 9579, 9580, 169, 1102, 1072, 1073, 1094, 1076, 1077, 1092, 1075, 1093, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1103, 1088, 1089, 1090, 1091, 1078, 1074, 1100, 1099, 1079, 1096, 1101, 1097, 1095, 1098, 1070, 1040, 1041, 1062, 1044, 1045, 1060, 1043, 1061, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1071, 1056, 1057, 1058, 1059, 1046, 1042, 1068, 1067, 1047, 1064, 1069, 1065, 1063, 1066],
49
- "koi8-u": [9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 8992, 9632, 8729, 8730, 8776, 8804, 8805, 160, 8993, 176, 178, 183, 247, 9552, 9553, 9554, 1105, 1108, 9556, 1110, 1111, 9559, 9560, 9561, 9562, 9563, 1169, 1118, 9566, 9567, 9568, 9569, 1025, 1028, 9571, 1030, 1031, 9574, 9575, 9576, 9577, 9578, 1168, 1038, 169, 1102, 1072, 1073, 1094, 1076, 1077, 1092, 1075, 1093, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1103, 1088, 1089, 1090, 1091, 1078, 1074, 1100, 1099, 1079, 1096, 1101, 1097, 1095, 1098, 1070, 1040, 1041, 1062, 1044, 1045, 1060, 1043, 1061, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1071, 1056, 1057, 1058, 1059, 1046, 1042, 1068, 1067, 1047, 1064, 1069, 1065, 1063, 1066],
50
- "macintosh": [196, 197, 199, 201, 209, 214, 220, 225, 224, 226, 228, 227, 229, 231, 233, 232, 234, 235, 237, 236, 238, 239, 241, 243, 242, 244, 246, 245, 250, 249, 251, 252, 8224, 176, 162, 163, 167, 8226, 182, 223, 174, 169, 8482, 180, 168, 8800, 198, 216, 8734, 177, 8804, 8805, 165, 181, 8706, 8721, 8719, 960, 8747, 170, 186, 937, 230, 248, 191, 161, 172, 8730, 402, 8776, 8710, 171, 187, 8230, 160, 192, 195, 213, 338, 339, 8211, 8212, 8220, 8221, 8216, 8217, 247, 9674, 255, 376, 8260, 8364, 8249, 8250, 64257, 64258, 8225, 183, 8218, 8222, 8240, 194, 202, 193, 203, 200, 205, 206, 207, 204, 211, 212, 63743, 210, 218, 219, 217, 305, 710, 732, 175, 728, 729, 730, 184, 733, 731, 711],
51
- "windows-874": [8364, 129, 130, 131, 132, 8230, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 153, 154, 155, 156, 157, 158, 159, 160, 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3592, 3593, 3594, 3595, 3596, 3597, 3598, 3599, 3600, 3601, 3602, 3603, 3604, 3605, 3606, 3607, 3608, 3609, 3610, 3611, 3612, 3613, 3614, 3615, 3616, 3617, 3618, 3619, 3620, 3621, 3622, 3623, 3624, 3625, 3626, 3627, 3628, 3629, 3630, 3631, 3632, 3633, 3634, 3635, 3636, 3637, 3638, 3639, 3640, 3641, 3642, null, null, null, null, 3647, 3648, 3649, 3650, 3651, 3652, 3653, 3654, 3655, 3656, 3657, 3658, 3659, 3660, 3661, 3662, 3663, 3664, 3665, 3666, 3667, 3668, 3669, 3670, 3671, 3672, 3673, 3674, 3675, null, null, null, null],
52
- "windows-1250": [8364, 129, 8218, 131, 8222, 8230, 8224, 8225, 136, 8240, 352, 8249, 346, 356, 381, 377, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 8482, 353, 8250, 347, 357, 382, 378, 160, 711, 728, 321, 164, 260, 166, 167, 168, 169, 350, 171, 172, 173, 174, 379, 176, 177, 731, 322, 180, 181, 182, 183, 184, 261, 351, 187, 317, 733, 318, 380, 340, 193, 194, 258, 196, 313, 262, 199, 268, 201, 280, 203, 282, 205, 206, 270, 272, 323, 327, 211, 212, 336, 214, 215, 344, 366, 218, 368, 220, 221, 354, 223, 341, 225, 226, 259, 228, 314, 263, 231, 269, 233, 281, 235, 283, 237, 238, 271, 273, 324, 328, 243, 244, 337, 246, 247, 345, 367, 250, 369, 252, 253, 355, 729],
53
- "windows-1251": [1026, 1027, 8218, 1107, 8222, 8230, 8224, 8225, 8364, 8240, 1033, 8249, 1034, 1036, 1035, 1039, 1106, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 8482, 1113, 8250, 1114, 1116, 1115, 1119, 160, 1038, 1118, 1032, 164, 1168, 166, 167, 1025, 169, 1028, 171, 172, 173, 174, 1031, 176, 177, 1030, 1110, 1169, 181, 182, 183, 1105, 8470, 1108, 187, 1112, 1029, 1109, 1111, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103],
54
- "windows-1252": [8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 352, 8249, 338, 141, 381, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 353, 8250, 339, 157, 382, 376, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255],
55
- "windows-1253": [8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 136, 8240, 138, 8249, 140, 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 8482, 154, 8250, 156, 157, 158, 159, 160, 901, 902, 163, 164, 165, 166, 167, 168, 169, null, 171, 172, 173, 174, 8213, 176, 177, 178, 179, 900, 181, 182, 183, 904, 905, 906, 187, 908, 189, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, null, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, null],
56
- "windows-1254": [8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 352, 8249, 338, 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 353, 8250, 339, 157, 158, 376, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 286, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 304, 350, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 287, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 305, 351, 255],
57
- "windows-1255": [8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 138, 8249, 140, 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 154, 8250, 156, 157, 158, 159, 160, 161, 162, 163, 8362, 165, 166, 167, 168, 169, 215, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 247, 187, 188, 189, 190, 191, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1471, 1472, 1473, 1474, 1475, 1520, 1521, 1522, 1523, 1524, null, null, null, null, null, null, null, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, null, null, 8206, 8207, null],
58
- "windows-1256": [8364, 1662, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 1657, 8249, 338, 1670, 1688, 1672, 1711, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 1705, 8482, 1681, 8250, 339, 8204, 8205, 1722, 160, 1548, 162, 163, 164, 165, 166, 167, 168, 169, 1726, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 1563, 187, 188, 189, 190, 1567, 1729, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 215, 1591, 1592, 1593, 1594, 1600, 1601, 1602, 1603, 224, 1604, 226, 1605, 1606, 1607, 1608, 231, 232, 233, 234, 235, 1609, 1610, 238, 239, 1611, 1612, 1613, 1614, 244, 1615, 1616, 247, 1617, 249, 1618, 251, 252, 8206, 8207, 1746],
59
- "windows-1257": [8364, 129, 8218, 131, 8222, 8230, 8224, 8225, 136, 8240, 138, 8249, 140, 168, 711, 184, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 8482, 154, 8250, 156, 175, 731, 159, 160, null, 162, 163, 164, null, 166, 167, 216, 169, 342, 171, 172, 173, 174, 198, 176, 177, 178, 179, 180, 181, 182, 183, 248, 185, 343, 187, 188, 189, 190, 230, 260, 302, 256, 262, 196, 197, 280, 274, 268, 201, 377, 278, 290, 310, 298, 315, 352, 323, 325, 211, 332, 213, 214, 215, 370, 321, 346, 362, 220, 379, 381, 223, 261, 303, 257, 263, 228, 229, 281, 275, 269, 233, 378, 279, 291, 311, 299, 316, 353, 324, 326, 243, 333, 245, 246, 247, 371, 322, 347, 363, 252, 380, 382, 729],
60
- "windows-1258": [8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 138, 8249, 338, 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 154, 8250, 339, 157, 158, 376, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 258, 196, 197, 198, 199, 200, 201, 202, 203, 768, 205, 206, 207, 272, 209, 777, 211, 212, 416, 214, 215, 216, 217, 218, 219, 220, 431, 771, 223, 224, 225, 226, 259, 228, 229, 230, 231, 232, 233, 234, 235, 769, 237, 238, 239, 273, 241, 803, 243, 244, 417, 246, 247, 248, 249, 250, 251, 252, 432, 8363, 255],
61
- "x-mac-cyrillic": [1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 8224, 176, 1168, 163, 167, 8226, 182, 1030, 174, 169, 8482, 1026, 1106, 8800, 1027, 1107, 8734, 177, 8804, 8805, 1110, 181, 1169, 1032, 1028, 1108, 1031, 1111, 1033, 1113, 1034, 1114, 1112, 1029, 172, 8730, 402, 8776, 8710, 171, 187, 8230, 160, 1035, 1115, 1036, 1116, 1109, 8211, 8212, 8220, 8221, 8216, 8217, 247, 8222, 1038, 1118, 1039, 1119, 8470, 1025, 1105, 1103, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 8364]
62
- };
63
- }
64
- });
65
-
66
- // src/lib/encoding.ts
67
- function inRange(a, min, max) {
68
- return min <= a && a <= max;
69
- }
70
- function includes(array, item) {
71
- return array.indexOf(item) !== -1;
72
- }
73
- function ToDictionary(o) {
74
- if (o === void 0)
75
- return {};
76
- if (o === Object(o))
77
- return o;
78
- throw TypeError("Could not convert argument to dictionary");
79
- }
80
- function stringToCodePoints(string) {
81
- var s = String(string);
82
- var n = s.length;
83
- var i = 0;
84
- var u = [];
85
- while (i < n) {
86
- var c = s.charCodeAt(i);
87
- if (c < 55296 || c > 57343) {
88
- u.push(c);
89
- } else if (56320 <= c && c <= 57343) {
90
- u.push(65533);
91
- } else if (55296 <= c && c <= 56319) {
92
- if (i === n - 1) {
93
- u.push(65533);
94
- } else {
95
- var d = s.charCodeAt(i + 1);
96
- if (56320 <= d && d <= 57343) {
97
- var a = c & 1023;
98
- var b = d & 1023;
99
- u.push(65536 + (a << 10) + b);
100
- i += 1;
101
- } else {
102
- u.push(65533);
103
- }
104
- }
105
- }
106
- i += 1;
107
- }
108
- return u;
109
- }
110
- function codePointsToString(code_points) {
111
- var s = "";
112
- for (var i = 0; i < code_points.length; ++i) {
113
- var cp = code_points[i];
114
- if (cp <= 65535) {
115
- s += String.fromCharCode(cp);
116
- } else {
117
- cp -= 65536;
118
- s += String.fromCharCode((cp >> 10) + 55296, (cp & 1023) + 56320);
119
- }
120
- }
121
- return s;
122
- }
123
- function isASCIIByte(a) {
124
- return 0 <= a && a <= 127;
125
- }
126
- function Stream(tokens) {
127
- this.tokens = [].slice.call(tokens);
128
- this.tokens.reverse();
129
- }
130
- function decoderError(fatal, opt_code_point) {
131
- if (fatal)
132
- throw TypeError("Decoder error");
133
- return opt_code_point || 65533;
134
- }
135
- function encoderError(code_point) {
136
- throw TypeError("The code point " + code_point + " could not be encoded.");
137
- }
138
- function Decoder() {
139
- }
140
- function Encoder() {
141
- }
142
- function getEncoding(label) {
143
- label = String(label).trim().toLowerCase();
144
- if (Object.prototype.hasOwnProperty.call(label_to_encoding, label)) {
145
- return label_to_encoding[label];
146
- }
147
- return null;
148
- }
149
- function indexCodePointFor(pointer, index2) {
150
- if (!index2)
151
- return null;
152
- return index2[pointer] || null;
153
- }
154
- function indexPointerFor(code_point, index2) {
155
- var pointer = index2.indexOf(code_point);
156
- return pointer === -1 ? null : pointer;
157
- }
158
- function index(name) {
159
- if (!("encoding-indexes" in global)) {
160
- throw Error("Indexes missing. Did you forget to include encoding-indexes.js first?");
161
- }
162
- return global["encoding-indexes"][name];
163
- }
164
- function indexGB18030RangesCodePointFor(pointer) {
165
- if (pointer > 39419 && pointer < 189e3 || pointer > 1237575)
166
- return null;
167
- if (pointer === 7457)
168
- return 59335;
169
- var offset = 0;
170
- var code_point_offset = 0;
171
- var idx = index("gb18030-ranges");
172
- var i;
173
- for (i = 0; i < idx.length; ++i) {
174
- var entry = idx[i];
175
- if (entry[0] <= pointer) {
176
- offset = entry[0];
177
- code_point_offset = entry[1];
178
- } else {
179
- break;
180
- }
181
- }
182
- return code_point_offset + pointer - offset;
183
- }
184
- function indexGB18030RangesPointerFor(code_point) {
185
- if (code_point === 59335)
186
- return 7457;
187
- var offset = 0;
188
- var pointer_offset = 0;
189
- var idx = index("gb18030-ranges");
190
- var i;
191
- for (i = 0; i < idx.length; ++i) {
192
- var entry = idx[i];
193
- if (entry[1] <= code_point) {
194
- offset = entry[1];
195
- pointer_offset = entry[0];
196
- } else {
197
- break;
198
- }
199
- }
200
- return pointer_offset + code_point - offset;
201
- }
202
- function indexShiftJISPointerFor(code_point) {
203
- shift_jis_index = shift_jis_index || index("jis0208").map(function(code_point2, pointer) {
204
- return inRange(pointer, 8272, 8835) ? null : code_point2;
205
- });
206
- var index_ = shift_jis_index;
207
- return index_.indexOf(code_point);
208
- }
209
- function indexBig5PointerFor(code_point) {
210
- big5_index_no_hkscs = big5_index_no_hkscs || index("big5").map(function(code_point2, pointer) {
211
- return pointer < (161 - 129) * 157 ? null : code_point2;
212
- });
213
- var index_ = big5_index_no_hkscs;
214
- if (code_point === 9552 || code_point === 9566 || code_point === 9569 || code_point === 9578 || code_point === 21313 || code_point === 21317) {
215
- return index_.lastIndexOf(code_point);
216
- }
217
- return indexPointerFor(code_point, index_);
218
- }
219
- function TextDecoder(label, options) {
220
- if (!(this instanceof TextDecoder))
221
- throw TypeError("Called as a function. Did you forget 'new'?");
222
- label = label !== void 0 ? String(label) : DEFAULT_ENCODING;
223
- options = ToDictionary(options);
224
- this._encoding = null;
225
- this._decoder = null;
226
- this._ignoreBOM = false;
227
- this._BOMseen = false;
228
- this._error_mode = "replacement";
229
- this._do_not_flush = false;
230
- var encoding = getEncoding(label);
231
- if (encoding === null || encoding.name === "replacement")
232
- throw RangeError("Unknown encoding: " + label);
233
- if (!decoders[encoding.name]) {
234
- throw Error("Decoder not present. Did you forget to include encoding-indexes.js first?");
235
- }
236
- var dec = this;
237
- dec._encoding = encoding;
238
- if (Boolean(options["fatal"]))
239
- dec._error_mode = "fatal";
240
- if (Boolean(options["ignoreBOM"]))
241
- dec._ignoreBOM = true;
242
- if (!Object.defineProperty) {
243
- this.encoding = dec._encoding.name.toLowerCase();
244
- this.fatal = dec._error_mode === "fatal";
245
- this.ignoreBOM = dec._ignoreBOM;
246
- }
247
- return dec;
248
- }
249
- function TextEncoder(label, options) {
250
- if (!(this instanceof TextEncoder))
251
- throw TypeError("Called as a function. Did you forget 'new'?");
252
- options = ToDictionary(options);
253
- this._encoding = null;
254
- this._encoder = null;
255
- this._do_not_flush = false;
256
- this._fatal = Boolean(options["fatal"]) ? "fatal" : "replacement";
257
- var enc = this;
258
- if (Boolean(options["NONSTANDARD_allowLegacyEncoding"])) {
259
- label = label !== void 0 ? String(label) : DEFAULT_ENCODING;
260
- var encoding = getEncoding(label);
261
- if (encoding === null || encoding.name === "replacement")
262
- throw RangeError("Unknown encoding: " + label);
263
- if (!encoders[encoding.name]) {
264
- throw Error("Encoder not present. Did you forget to include encoding-indexes.js first?");
265
- }
266
- enc._encoding = encoding;
267
- } else {
268
- enc._encoding = getEncoding("utf-8");
269
- if (label !== void 0 && "console" in global) {
270
- console.warn("TextEncoder constructor called with encoding label, which is ignored.");
271
- }
272
- }
273
- if (!Object.defineProperty)
274
- this.encoding = enc._encoding.name.toLowerCase();
275
- return enc;
276
- }
277
- function UTF8Decoder(options) {
278
- var fatal = options.fatal;
279
- var utf8_code_point = 0, utf8_bytes_seen = 0, utf8_bytes_needed = 0, utf8_lower_boundary = 128, utf8_upper_boundary = 191;
280
- this.handler = function(stream, bite) {
281
- if (bite === end_of_stream && utf8_bytes_needed !== 0) {
282
- utf8_bytes_needed = 0;
283
- return decoderError(fatal);
284
- }
285
- if (bite === end_of_stream)
286
- return finished;
287
- if (utf8_bytes_needed === 0) {
288
- if (inRange(bite, 0, 127)) {
289
- return bite;
290
- } else if (inRange(bite, 194, 223)) {
291
- utf8_bytes_needed = 1;
292
- utf8_code_point = bite & 31;
293
- } else if (inRange(bite, 224, 239)) {
294
- if (bite === 224)
295
- utf8_lower_boundary = 160;
296
- if (bite === 237)
297
- utf8_upper_boundary = 159;
298
- utf8_bytes_needed = 2;
299
- utf8_code_point = bite & 15;
300
- } else if (inRange(bite, 240, 244)) {
301
- if (bite === 240)
302
- utf8_lower_boundary = 144;
303
- if (bite === 244)
304
- utf8_upper_boundary = 143;
305
- utf8_bytes_needed = 3;
306
- utf8_code_point = bite & 7;
307
- } else {
308
- return decoderError(fatal);
309
- }
310
- return null;
311
- }
312
- if (!inRange(bite, utf8_lower_boundary, utf8_upper_boundary)) {
313
- utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;
314
- utf8_lower_boundary = 128;
315
- utf8_upper_boundary = 191;
316
- stream.prepend(bite);
317
- return decoderError(fatal);
318
- }
319
- utf8_lower_boundary = 128;
320
- utf8_upper_boundary = 191;
321
- utf8_code_point = utf8_code_point << 6 | bite & 63;
322
- utf8_bytes_seen += 1;
323
- if (utf8_bytes_seen !== utf8_bytes_needed)
324
- return null;
325
- var code_point = utf8_code_point;
326
- utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;
327
- return code_point;
328
- };
329
- }
330
- function UTF8Encoder(options) {
331
- var fatal = options.fatal;
332
- this.handler = function(stream, code_point) {
333
- if (code_point === end_of_stream)
334
- return finished;
335
- if (isASCIICodePoint(code_point))
336
- return code_point;
337
- var count, offset;
338
- if (inRange(code_point, 128, 2047)) {
339
- count = 1;
340
- offset = 192;
341
- } else if (inRange(code_point, 2048, 65535)) {
342
- count = 2;
343
- offset = 224;
344
- } else if (inRange(code_point, 65536, 1114111)) {
345
- count = 3;
346
- offset = 240;
347
- }
348
- var bytes = [(code_point >> 6 * count) + offset];
349
- while (count > 0) {
350
- var temp = code_point >> 6 * (count - 1);
351
- bytes.push(128 | temp & 63);
352
- count -= 1;
353
- }
354
- return bytes;
355
- };
356
- }
357
- function SingleByteDecoder(index2, options) {
358
- var fatal = options.fatal;
359
- this.handler = function(stream, bite) {
360
- if (bite === end_of_stream)
361
- return finished;
362
- if (isASCIIByte(bite))
363
- return bite;
364
- var code_point = index2[bite - 128];
365
- if (code_point === null)
366
- return decoderError(fatal);
367
- return code_point;
368
- };
369
- }
370
- function SingleByteEncoder(index2, options) {
371
- var fatal = options.fatal;
372
- this.handler = function(stream, code_point) {
373
- if (code_point === end_of_stream)
374
- return finished;
375
- if (isASCIICodePoint(code_point))
376
- return code_point;
377
- var pointer = indexPointerFor(code_point, index2);
378
- if (pointer === null)
379
- encoderError(code_point);
380
- return pointer + 128;
381
- };
382
- }
383
- function GB18030Decoder(options) {
384
- var fatal = options.fatal;
385
- var gb18030_first = 0, gb18030_second = 0, gb18030_third = 0;
386
- this.handler = function(stream, bite) {
387
- if (bite === end_of_stream && gb18030_first === 0 && gb18030_second === 0 && gb18030_third === 0) {
388
- return finished;
389
- }
390
- if (bite === end_of_stream && (gb18030_first !== 0 || gb18030_second !== 0 || gb18030_third !== 0)) {
391
- gb18030_first = 0;
392
- gb18030_second = 0;
393
- gb18030_third = 0;
394
- decoderError(fatal);
395
- }
396
- var code_point;
397
- if (gb18030_third !== 0) {
398
- code_point = null;
399
- if (inRange(bite, 48, 57)) {
400
- code_point = indexGB18030RangesCodePointFor((((gb18030_first - 129) * 10 + gb18030_second - 48) * 126 + gb18030_third - 129) * 10 + bite - 48);
401
- }
402
- var buffer = [gb18030_second, gb18030_third, bite];
403
- gb18030_first = 0;
404
- gb18030_second = 0;
405
- gb18030_third = 0;
406
- if (code_point === null) {
407
- stream.prepend(buffer);
408
- return decoderError(fatal);
409
- }
410
- return code_point;
411
- }
412
- if (gb18030_second !== 0) {
413
- if (inRange(bite, 129, 254)) {
414
- gb18030_third = bite;
415
- return null;
416
- }
417
- stream.prepend([gb18030_second, bite]);
418
- gb18030_first = 0;
419
- gb18030_second = 0;
420
- return decoderError(fatal);
421
- }
422
- if (gb18030_first !== 0) {
423
- if (inRange(bite, 48, 57)) {
424
- gb18030_second = bite;
425
- return null;
426
- }
427
- var lead = gb18030_first;
428
- var pointer = null;
429
- gb18030_first = 0;
430
- var offset = bite < 127 ? 64 : 65;
431
- if (inRange(bite, 64, 126) || inRange(bite, 128, 254))
432
- pointer = (lead - 129) * 190 + (bite - offset);
433
- code_point = pointer === null ? null : indexCodePointFor(pointer, index("gb18030"));
434
- if (code_point === null && isASCIIByte(bite))
435
- stream.prepend(bite);
436
- if (code_point === null)
437
- return decoderError(fatal);
438
- return code_point;
439
- }
440
- if (isASCIIByte(bite))
441
- return bite;
442
- if (bite === 128)
443
- return 8364;
444
- if (inRange(bite, 129, 254)) {
445
- gb18030_first = bite;
446
- return null;
447
- }
448
- return decoderError(fatal);
449
- };
450
- }
451
- function GB18030Encoder(options, gbk_flag) {
452
- var fatal = options.fatal;
453
- this.handler = function(stream, code_point) {
454
- if (code_point === end_of_stream)
455
- return finished;
456
- if (isASCIICodePoint(code_point))
457
- return code_point;
458
- if (code_point === 58853)
459
- return encoderError(code_point);
460
- if (gbk_flag && code_point === 8364)
461
- return 128;
462
- var pointer = indexPointerFor(code_point, index("gb18030"));
463
- if (pointer !== null) {
464
- var lead = floor(pointer / 190) + 129;
465
- var trail = pointer % 190;
466
- var offset = trail < 63 ? 64 : 65;
467
- return [lead, trail + offset];
468
- }
469
- if (gbk_flag)
470
- return encoderError(code_point);
471
- pointer = indexGB18030RangesPointerFor(code_point);
472
- var byte1 = floor(pointer / 10 / 126 / 10);
473
- pointer = pointer - byte1 * 10 * 126 * 10;
474
- var byte2 = floor(pointer / 10 / 126);
475
- pointer = pointer - byte2 * 10 * 126;
476
- var byte3 = floor(pointer / 10);
477
- var byte4 = pointer - byte3 * 10;
478
- return [byte1 + 129, byte2 + 48, byte3 + 129, byte4 + 48];
479
- };
480
- }
481
- function Big5Decoder(options) {
482
- var fatal = options.fatal;
483
- var Big5_lead = 0;
484
- this.handler = function(stream, bite) {
485
- if (bite === end_of_stream && Big5_lead !== 0) {
486
- Big5_lead = 0;
487
- return decoderError(fatal);
488
- }
489
- if (bite === end_of_stream && Big5_lead === 0)
490
- return finished;
491
- if (Big5_lead !== 0) {
492
- var lead = Big5_lead;
493
- var pointer = null;
494
- Big5_lead = 0;
495
- var offset = bite < 127 ? 64 : 98;
496
- if (inRange(bite, 64, 126) || inRange(bite, 161, 254))
497
- pointer = (lead - 129) * 157 + (bite - offset);
498
- switch (pointer) {
499
- case 1133:
500
- return [202, 772];
501
- case 1135:
502
- return [202, 780];
503
- case 1164:
504
- return [234, 772];
505
- case 1166:
506
- return [234, 780];
507
- }
508
- var code_point = pointer === null ? null : indexCodePointFor(pointer, index("big5"));
509
- if (code_point === null && isASCIIByte(bite))
510
- stream.prepend(bite);
511
- if (code_point === null)
512
- return decoderError(fatal);
513
- return code_point;
514
- }
515
- if (isASCIIByte(bite))
516
- return bite;
517
- if (inRange(bite, 129, 254)) {
518
- Big5_lead = bite;
519
- return null;
520
- }
521
- return decoderError(fatal);
522
- };
523
- }
524
- function Big5Encoder(options) {
525
- var fatal = options.fatal;
526
- this.handler = function(stream, code_point) {
527
- if (code_point === end_of_stream)
528
- return finished;
529
- if (isASCIICodePoint(code_point))
530
- return code_point;
531
- var pointer = indexBig5PointerFor(code_point);
532
- if (pointer === null)
533
- return encoderError(code_point);
534
- var lead = floor(pointer / 157) + 129;
535
- if (lead < 161)
536
- return encoderError(code_point);
537
- var trail = pointer % 157;
538
- var offset = trail < 63 ? 64 : 98;
539
- return [lead, trail + offset];
540
- };
541
- }
542
- function EUCJPDecoder(options) {
543
- var fatal = options.fatal;
544
- var eucjp_jis0212_flag = false, eucjp_lead = 0;
545
- this.handler = function(stream, bite) {
546
- if (bite === end_of_stream && eucjp_lead !== 0) {
547
- eucjp_lead = 0;
548
- return decoderError(fatal);
549
- }
550
- if (bite === end_of_stream && eucjp_lead === 0)
551
- return finished;
552
- if (eucjp_lead === 142 && inRange(bite, 161, 223)) {
553
- eucjp_lead = 0;
554
- return 65377 - 161 + bite;
555
- }
556
- if (eucjp_lead === 143 && inRange(bite, 161, 254)) {
557
- eucjp_jis0212_flag = true;
558
- eucjp_lead = bite;
559
- return null;
560
- }
561
- if (eucjp_lead !== 0) {
562
- var lead = eucjp_lead;
563
- eucjp_lead = 0;
564
- var code_point = null;
565
- if (inRange(lead, 161, 254) && inRange(bite, 161, 254)) {
566
- code_point = indexCodePointFor((lead - 161) * 94 + (bite - 161), index(!eucjp_jis0212_flag ? "jis0208" : "jis0212"));
567
- }
568
- eucjp_jis0212_flag = false;
569
- if (!inRange(bite, 161, 254))
570
- stream.prepend(bite);
571
- if (code_point === null)
572
- return decoderError(fatal);
573
- return code_point;
574
- }
575
- if (isASCIIByte(bite))
576
- return bite;
577
- if (bite === 142 || bite === 143 || inRange(bite, 161, 254)) {
578
- eucjp_lead = bite;
579
- return null;
580
- }
581
- return decoderError(fatal);
582
- };
583
- }
584
- function EUCJPEncoder(options) {
585
- var fatal = options.fatal;
586
- this.handler = function(stream, code_point) {
587
- if (code_point === end_of_stream)
588
- return finished;
589
- if (isASCIICodePoint(code_point))
590
- return code_point;
591
- if (code_point === 165)
592
- return 92;
593
- if (code_point === 8254)
594
- return 126;
595
- if (inRange(code_point, 65377, 65439))
596
- return [142, code_point - 65377 + 161];
597
- if (code_point === 8722)
598
- code_point = 65293;
599
- var pointer = indexPointerFor(code_point, index("jis0208"));
600
- if (pointer === null)
601
- return encoderError(code_point);
602
- var lead = floor(pointer / 94) + 161;
603
- var trail = pointer % 94 + 161;
604
- return [lead, trail];
605
- };
606
- }
607
- function ISO2022JPDecoder(options) {
608
- var fatal = options.fatal;
609
- var states = {
610
- ASCII: 0,
611
- Roman: 1,
612
- Katakana: 2,
613
- LeadByte: 3,
614
- TrailByte: 4,
615
- EscapeStart: 5,
616
- Escape: 6
617
- };
618
- var iso2022jp_decoder_state = states.ASCII, iso2022jp_decoder_output_state = states.ASCII, iso2022jp_lead = 0, iso2022jp_output_flag = false;
619
- this.handler = function(stream, bite) {
620
- switch (iso2022jp_decoder_state) {
621
- default:
622
- case states.ASCII:
623
- if (bite === 27) {
624
- iso2022jp_decoder_state = states.EscapeStart;
625
- return null;
626
- }
627
- if (inRange(bite, 0, 127) && bite !== 14 && bite !== 15 && bite !== 27) {
628
- iso2022jp_output_flag = false;
629
- return bite;
630
- }
631
- if (bite === end_of_stream) {
632
- return finished;
633
- }
634
- iso2022jp_output_flag = false;
635
- return decoderError(fatal);
636
- case states.Roman:
637
- if (bite === 27) {
638
- iso2022jp_decoder_state = states.EscapeStart;
639
- return null;
640
- }
641
- if (bite === 92) {
642
- iso2022jp_output_flag = false;
643
- return 165;
644
- }
645
- if (bite === 126) {
646
- iso2022jp_output_flag = false;
647
- return 8254;
648
- }
649
- if (inRange(bite, 0, 127) && bite !== 14 && bite !== 15 && bite !== 27 && bite !== 92 && bite !== 126) {
650
- iso2022jp_output_flag = false;
651
- return bite;
652
- }
653
- if (bite === end_of_stream) {
654
- return finished;
655
- }
656
- iso2022jp_output_flag = false;
657
- return decoderError(fatal);
658
- case states.Katakana:
659
- if (bite === 27) {
660
- iso2022jp_decoder_state = states.EscapeStart;
661
- return null;
662
- }
663
- if (inRange(bite, 33, 95)) {
664
- iso2022jp_output_flag = false;
665
- return 65377 - 33 + bite;
666
- }
667
- if (bite === end_of_stream) {
668
- return finished;
669
- }
670
- iso2022jp_output_flag = false;
671
- return decoderError(fatal);
672
- case states.LeadByte:
673
- if (bite === 27) {
674
- iso2022jp_decoder_state = states.EscapeStart;
675
- return null;
676
- }
677
- if (inRange(bite, 33, 126)) {
678
- iso2022jp_output_flag = false;
679
- iso2022jp_lead = bite;
680
- iso2022jp_decoder_state = states.TrailByte;
681
- return null;
682
- }
683
- if (bite === end_of_stream) {
684
- return finished;
685
- }
686
- iso2022jp_output_flag = false;
687
- return decoderError(fatal);
688
- case states.TrailByte:
689
- if (bite === 27) {
690
- iso2022jp_decoder_state = states.EscapeStart;
691
- return decoderError(fatal);
692
- }
693
- if (inRange(bite, 33, 126)) {
694
- iso2022jp_decoder_state = states.LeadByte;
695
- var pointer = (iso2022jp_lead - 33) * 94 + bite - 33;
696
- var code_point = indexCodePointFor(pointer, index("jis0208"));
697
- if (code_point === null)
698
- return decoderError(fatal);
699
- return code_point;
700
- }
701
- if (bite === end_of_stream) {
702
- iso2022jp_decoder_state = states.LeadByte;
703
- stream.prepend(bite);
704
- return decoderError(fatal);
705
- }
706
- iso2022jp_decoder_state = states.LeadByte;
707
- return decoderError(fatal);
708
- case states.EscapeStart:
709
- if (bite === 36 || bite === 40) {
710
- iso2022jp_lead = bite;
711
- iso2022jp_decoder_state = states.Escape;
712
- return null;
713
- }
714
- stream.prepend(bite);
715
- iso2022jp_output_flag = false;
716
- iso2022jp_decoder_state = iso2022jp_decoder_output_state;
717
- return decoderError(fatal);
718
- case states.Escape:
719
- var lead = iso2022jp_lead;
720
- iso2022jp_lead = 0;
721
- var state = null;
722
- if (lead === 40 && bite === 66)
723
- state = states.ASCII;
724
- if (lead === 40 && bite === 74)
725
- state = states.Roman;
726
- if (lead === 40 && bite === 73)
727
- state = states.Katakana;
728
- if (lead === 36 && (bite === 64 || bite === 66))
729
- state = states.LeadByte;
730
- if (state !== null) {
731
- iso2022jp_decoder_state = iso2022jp_decoder_state = state;
732
- var output_flag = iso2022jp_output_flag;
733
- iso2022jp_output_flag = true;
734
- return !output_flag ? null : decoderError(fatal);
735
- }
736
- stream.prepend([lead, bite]);
737
- iso2022jp_output_flag = false;
738
- iso2022jp_decoder_state = iso2022jp_decoder_output_state;
739
- return decoderError(fatal);
740
- }
741
- };
742
- }
743
- function ISO2022JPEncoder(options) {
744
- var fatal = options.fatal;
745
- var states = {
746
- ASCII: 0,
747
- Roman: 1,
748
- jis0208: 2
749
- };
750
- var iso2022jp_state = states.ASCII;
751
- this.handler = function(stream, code_point) {
752
- if (code_point === end_of_stream && iso2022jp_state !== states.ASCII) {
753
- stream.prepend(code_point);
754
- iso2022jp_state = states.ASCII;
755
- return [27, 40, 66];
756
- }
757
- if (code_point === end_of_stream && iso2022jp_state === states.ASCII)
758
- return finished;
759
- if ((iso2022jp_state === states.ASCII || iso2022jp_state === states.Roman) && (code_point === 14 || code_point === 15 || code_point === 27)) {
760
- return encoderError(65533);
761
- }
762
- if (iso2022jp_state === states.ASCII && isASCIICodePoint(code_point))
763
- return code_point;
764
- if (iso2022jp_state === states.Roman && (isASCIICodePoint(code_point) && code_point !== 92 && code_point !== 126 || code_point == 165 || code_point == 8254)) {
765
- if (isASCIICodePoint(code_point))
766
- return code_point;
767
- if (code_point === 165)
768
- return 92;
769
- if (code_point === 8254)
770
- return 126;
771
- }
772
- if (isASCIICodePoint(code_point) && iso2022jp_state !== states.ASCII) {
773
- stream.prepend(code_point);
774
- iso2022jp_state = states.ASCII;
775
- return [27, 40, 66];
776
- }
777
- if ((code_point === 165 || code_point === 8254) && iso2022jp_state !== states.Roman) {
778
- stream.prepend(code_point);
779
- iso2022jp_state = states.Roman;
780
- return [27, 40, 74];
781
- }
782
- if (code_point === 8722)
783
- code_point = 65293;
784
- var pointer = indexPointerFor(code_point, index("jis0208"));
785
- if (pointer === null)
786
- return encoderError(code_point);
787
- if (iso2022jp_state !== states.jis0208) {
788
- stream.prepend(code_point);
789
- iso2022jp_state = states.jis0208;
790
- return [27, 36, 66];
791
- }
792
- var lead = floor(pointer / 94) + 33;
793
- var trail = pointer % 94 + 33;
794
- return [lead, trail];
795
- };
796
- }
797
- function ShiftJISDecoder(options) {
798
- var fatal = options.fatal;
799
- var Shift_JIS_lead = 0;
800
- this.handler = function(stream, bite) {
801
- if (bite === end_of_stream && Shift_JIS_lead !== 0) {
802
- Shift_JIS_lead = 0;
803
- return decoderError(fatal);
804
- }
805
- if (bite === end_of_stream && Shift_JIS_lead === 0)
806
- return finished;
807
- if (Shift_JIS_lead !== 0) {
808
- var lead = Shift_JIS_lead;
809
- var pointer = null;
810
- Shift_JIS_lead = 0;
811
- var offset = bite < 127 ? 64 : 65;
812
- var lead_offset = lead < 160 ? 129 : 193;
813
- if (inRange(bite, 64, 126) || inRange(bite, 128, 252))
814
- pointer = (lead - lead_offset) * 188 + bite - offset;
815
- if (inRange(pointer, 8836, 10715))
816
- return 57344 - 8836 + pointer;
817
- var code_point = pointer === null ? null : indexCodePointFor(pointer, index("jis0208"));
818
- if (code_point === null && isASCIIByte(bite))
819
- stream.prepend(bite);
820
- if (code_point === null)
821
- return decoderError(fatal);
822
- return code_point;
823
- }
824
- if (isASCIIByte(bite) || bite === 128)
825
- return bite;
826
- if (inRange(bite, 161, 223))
827
- return 65377 - 161 + bite;
828
- if (inRange(bite, 129, 159) || inRange(bite, 224, 252)) {
829
- Shift_JIS_lead = bite;
830
- return null;
831
- }
832
- return decoderError(fatal);
833
- };
834
- }
835
- function ShiftJISEncoder(options) {
836
- var fatal = options.fatal;
837
- this.handler = function(stream, code_point) {
838
- if (code_point === end_of_stream)
839
- return finished;
840
- if (isASCIICodePoint(code_point) || code_point === 128)
841
- return code_point;
842
- if (code_point === 165)
843
- return 92;
844
- if (code_point === 8254)
845
- return 126;
846
- if (inRange(code_point, 65377, 65439))
847
- return code_point - 65377 + 161;
848
- if (code_point === 8722)
849
- code_point = 65293;
850
- var pointer = indexShiftJISPointerFor(code_point);
851
- if (pointer === null)
852
- return encoderError(code_point);
853
- var lead = floor(pointer / 188);
854
- var lead_offset = lead < 31 ? 129 : 193;
855
- var trail = pointer % 188;
856
- var offset = trail < 63 ? 64 : 65;
857
- return [lead + lead_offset, trail + offset];
858
- };
859
- }
860
- function EUCKRDecoder(options) {
861
- var fatal = options.fatal;
862
- var euckr_lead = 0;
863
- this.handler = function(stream, bite) {
864
- if (bite === end_of_stream && euckr_lead !== 0) {
865
- euckr_lead = 0;
866
- return decoderError(fatal);
867
- }
868
- if (bite === end_of_stream && euckr_lead === 0)
869
- return finished;
870
- if (euckr_lead !== 0) {
871
- var lead = euckr_lead;
872
- var pointer = null;
873
- euckr_lead = 0;
874
- if (inRange(bite, 65, 254))
875
- pointer = (lead - 129) * 190 + (bite - 65);
876
- var code_point = pointer === null ? null : indexCodePointFor(pointer, index("euc-kr"));
877
- if (pointer === null && isASCIIByte(bite))
878
- stream.prepend(bite);
879
- if (code_point === null)
880
- return decoderError(fatal);
881
- return code_point;
882
- }
883
- if (isASCIIByte(bite))
884
- return bite;
885
- if (inRange(bite, 129, 254)) {
886
- euckr_lead = bite;
887
- return null;
888
- }
889
- return decoderError(fatal);
890
- };
891
- }
892
- function EUCKREncoder(options) {
893
- var fatal = options.fatal;
894
- this.handler = function(stream, code_point) {
895
- if (code_point === end_of_stream)
896
- return finished;
897
- if (isASCIICodePoint(code_point))
898
- return code_point;
899
- var pointer = indexPointerFor(code_point, index("euc-kr"));
900
- if (pointer === null)
901
- return encoderError(code_point);
902
- var lead = floor(pointer / 190) + 129;
903
- var trail = pointer % 190 + 65;
904
- return [lead, trail];
905
- };
906
- }
907
- function convertCodeUnitToBytes(code_unit, utf16be) {
908
- var byte1 = code_unit >> 8;
909
- var byte2 = code_unit & 255;
910
- if (utf16be)
911
- return [byte1, byte2];
912
- return [byte2, byte1];
913
- }
914
- function UTF16Decoder(utf16_be, options) {
915
- var fatal = options.fatal;
916
- var utf16_lead_byte = null, utf16_lead_surrogate = null;
917
- this.handler = function(stream, bite) {
918
- if (bite === end_of_stream && (utf16_lead_byte !== null || utf16_lead_surrogate !== null)) {
919
- return decoderError(fatal);
920
- }
921
- if (bite === end_of_stream && utf16_lead_byte === null && utf16_lead_surrogate === null) {
922
- return finished;
923
- }
924
- if (utf16_lead_byte === null) {
925
- utf16_lead_byte = bite;
926
- return null;
927
- }
928
- var code_unit;
929
- if (utf16_be) {
930
- code_unit = (utf16_lead_byte << 8) + bite;
931
- } else {
932
- code_unit = (bite << 8) + utf16_lead_byte;
933
- }
934
- utf16_lead_byte = null;
935
- if (utf16_lead_surrogate !== null) {
936
- var lead_surrogate = utf16_lead_surrogate;
937
- utf16_lead_surrogate = null;
938
- if (inRange(code_unit, 56320, 57343)) {
939
- return 65536 + (lead_surrogate - 55296) * 1024 + (code_unit - 56320);
940
- }
941
- stream.prepend(convertCodeUnitToBytes(code_unit, utf16_be));
942
- return decoderError(fatal);
943
- }
944
- if (inRange(code_unit, 55296, 56319)) {
945
- utf16_lead_surrogate = code_unit;
946
- return null;
947
- }
948
- if (inRange(code_unit, 56320, 57343))
949
- return decoderError(fatal);
950
- return code_unit;
951
- };
952
- }
953
- function UTF16Encoder(utf16_be, options) {
954
- var fatal = options.fatal;
955
- this.handler = function(stream, code_point) {
956
- if (code_point === end_of_stream)
957
- return finished;
958
- if (inRange(code_point, 0, 65535))
959
- return convertCodeUnitToBytes(code_point, utf16_be);
960
- var lead = convertCodeUnitToBytes((code_point - 65536 >> 10) + 55296, utf16_be);
961
- var trail = convertCodeUnitToBytes((code_point - 65536 & 1023) + 56320, utf16_be);
962
- return lead.concat(trail);
963
- };
964
- }
965
- function XUserDefinedDecoder(options) {
966
- var fatal = options.fatal;
967
- this.handler = function(stream, bite) {
968
- if (bite === end_of_stream)
969
- return finished;
970
- if (isASCIIByte(bite))
971
- return bite;
972
- return 63360 + bite - 128;
973
- };
974
- }
975
- function XUserDefinedEncoder(options) {
976
- var fatal = options.fatal;
977
- this.handler = function(stream, code_point) {
978
- if (code_point === end_of_stream)
979
- return finished;
980
- if (isASCIICodePoint(code_point))
981
- return code_point;
982
- if (inRange(code_point, 63360, 63487))
983
- return code_point - 63360 + 128;
984
- return encoderError(code_point);
985
- };
986
- }
987
- var floor, isASCIICodePoint, end_of_stream, finished, encodings, label_to_encoding, encoders, decoders, shift_jis_index, big5_index_no_hkscs, DEFAULT_ENCODING;
988
- var init_encoding = __esm({
989
- "src/lib/encoding.ts"() {
990
- init_encoding_indexes();
991
- global["encoding-indexes"] = encoding_indexes_default || {};
992
- floor = Math.floor;
993
- isASCIICodePoint = isASCIIByte;
994
- end_of_stream = -1;
995
- Stream.prototype = {
996
- endOfStream: function() {
997
- return !this.tokens.length;
998
- },
999
- read: function() {
1000
- if (!this.tokens.length)
1001
- return end_of_stream;
1002
- return this.tokens.pop();
1003
- },
1004
- prepend: function(token) {
1005
- if (Array.isArray(token)) {
1006
- var tokens = token;
1007
- while (tokens.length)
1008
- this.tokens.push(tokens.pop());
1009
- } else {
1010
- this.tokens.push(token);
1011
- }
1012
- },
1013
- push: function(token) {
1014
- if (Array.isArray(token)) {
1015
- var tokens = token;
1016
- while (tokens.length)
1017
- this.tokens.unshift(tokens.shift());
1018
- } else {
1019
- this.tokens.unshift(token);
1020
- }
1021
- }
1022
- };
1023
- finished = -1;
1024
- Decoder.prototype = {
1025
- handler: function(stream, bite) {
1026
- }
1027
- };
1028
- Encoder.prototype = {
1029
- handler: function(stream, code_point) {
1030
- }
1031
- };
1032
- encodings = [
1033
- {
1034
- encodings: [
1035
- {
1036
- labels: ["unicode-1-1-utf-8", "utf-8", "utf8"],
1037
- name: "UTF-8"
1038
- }
1039
- ],
1040
- heading: "The Encoding"
1041
- },
1042
- {
1043
- encodings: [
1044
- {
1045
- labels: ["866", "cp866", "csibm866", "ibm866"],
1046
- name: "IBM866"
1047
- },
1048
- {
1049
- labels: [
1050
- "csisolatin2",
1051
- "iso-8859-2",
1052
- "iso-ir-101",
1053
- "iso8859-2",
1054
- "iso88592",
1055
- "iso_8859-2",
1056
- "iso_8859-2:1987",
1057
- "l2",
1058
- "latin2"
1059
- ],
1060
- name: "ISO-8859-2"
1061
- },
1062
- {
1063
- labels: [
1064
- "csisolatin3",
1065
- "iso-8859-3",
1066
- "iso-ir-109",
1067
- "iso8859-3",
1068
- "iso88593",
1069
- "iso_8859-3",
1070
- "iso_8859-3:1988",
1071
- "l3",
1072
- "latin3"
1073
- ],
1074
- name: "ISO-8859-3"
1075
- },
1076
- {
1077
- labels: [
1078
- "csisolatin4",
1079
- "iso-8859-4",
1080
- "iso-ir-110",
1081
- "iso8859-4",
1082
- "iso88594",
1083
- "iso_8859-4",
1084
- "iso_8859-4:1988",
1085
- "l4",
1086
- "latin4"
1087
- ],
1088
- name: "ISO-8859-4"
1089
- },
1090
- {
1091
- labels: [
1092
- "csisolatincyrillic",
1093
- "cyrillic",
1094
- "iso-8859-5",
1095
- "iso-ir-144",
1096
- "iso8859-5",
1097
- "iso88595",
1098
- "iso_8859-5",
1099
- "iso_8859-5:1988"
1100
- ],
1101
- name: "ISO-8859-5"
1102
- },
1103
- {
1104
- labels: [
1105
- "arabic",
1106
- "asmo-708",
1107
- "csiso88596e",
1108
- "csiso88596i",
1109
- "csisolatinarabic",
1110
- "ecma-114",
1111
- "iso-8859-6",
1112
- "iso-8859-6-e",
1113
- "iso-8859-6-i",
1114
- "iso-ir-127",
1115
- "iso8859-6",
1116
- "iso88596",
1117
- "iso_8859-6",
1118
- "iso_8859-6:1987"
1119
- ],
1120
- name: "ISO-8859-6"
1121
- },
1122
- {
1123
- labels: [
1124
- "csisolatingreek",
1125
- "ecma-118",
1126
- "elot_928",
1127
- "greek",
1128
- "greek8",
1129
- "iso-8859-7",
1130
- "iso-ir-126",
1131
- "iso8859-7",
1132
- "iso88597",
1133
- "iso_8859-7",
1134
- "iso_8859-7:1987",
1135
- "sun_eu_greek"
1136
- ],
1137
- name: "ISO-8859-7"
1138
- },
1139
- {
1140
- labels: [
1141
- "csiso88598e",
1142
- "csisolatinhebrew",
1143
- "hebrew",
1144
- "iso-8859-8",
1145
- "iso-8859-8-e",
1146
- "iso-ir-138",
1147
- "iso8859-8",
1148
- "iso88598",
1149
- "iso_8859-8",
1150
- "iso_8859-8:1988",
1151
- "visual"
1152
- ],
1153
- name: "ISO-8859-8"
1154
- },
1155
- {
1156
- labels: ["csiso88598i", "iso-8859-8-i", "logical"],
1157
- name: "ISO-8859-8-I"
1158
- },
1159
- {
1160
- labels: [
1161
- "csisolatin6",
1162
- "iso-8859-10",
1163
- "iso-ir-157",
1164
- "iso8859-10",
1165
- "iso885910",
1166
- "l6",
1167
- "latin6"
1168
- ],
1169
- name: "ISO-8859-10"
1170
- },
1171
- {
1172
- labels: ["iso-8859-13", "iso8859-13", "iso885913"],
1173
- name: "ISO-8859-13"
1174
- },
1175
- {
1176
- labels: ["iso-8859-14", "iso8859-14", "iso885914"],
1177
- name: "ISO-8859-14"
1178
- },
1179
- {
1180
- labels: ["csisolatin9", "iso-8859-15", "iso8859-15", "iso885915", "iso_8859-15", "l9"],
1181
- name: "ISO-8859-15"
1182
- },
1183
- {
1184
- labels: ["iso-8859-16"],
1185
- name: "ISO-8859-16"
1186
- },
1187
- {
1188
- labels: ["cskoi8r", "koi", "koi8", "koi8-r", "koi8_r"],
1189
- name: "KOI8-R"
1190
- },
1191
- {
1192
- labels: ["koi8-ru", "koi8-u"],
1193
- name: "KOI8-U"
1194
- },
1195
- {
1196
- labels: ["csmacintosh", "mac", "macintosh", "x-mac-roman"],
1197
- name: "macintosh"
1198
- },
1199
- {
1200
- labels: ["dos-874", "iso-8859-11", "iso8859-11", "iso885911", "tis-620", "windows-874"],
1201
- name: "windows-874"
1202
- },
1203
- {
1204
- labels: ["cp1250", "windows-1250", "x-cp1250"],
1205
- name: "windows-1250"
1206
- },
1207
- {
1208
- labels: ["cp1251", "windows-1251", "x-cp1251"],
1209
- name: "windows-1251"
1210
- },
1211
- {
1212
- labels: [
1213
- "ansi_x3.4-1968",
1214
- "ascii",
1215
- "cp1252",
1216
- "cp819",
1217
- "csisolatin1",
1218
- "ibm819",
1219
- "iso-8859-1",
1220
- "iso-ir-100",
1221
- "iso8859-1",
1222
- "iso88591",
1223
- "iso_8859-1",
1224
- "iso_8859-1:1987",
1225
- "l1",
1226
- "latin1",
1227
- "us-ascii",
1228
- "windows-1252",
1229
- "x-cp1252"
1230
- ],
1231
- name: "windows-1252"
1232
- },
1233
- {
1234
- labels: ["cp1253", "windows-1253", "x-cp1253"],
1235
- name: "windows-1253"
1236
- },
1237
- {
1238
- labels: [
1239
- "cp1254",
1240
- "csisolatin5",
1241
- "iso-8859-9",
1242
- "iso-ir-148",
1243
- "iso8859-9",
1244
- "iso88599",
1245
- "iso_8859-9",
1246
- "iso_8859-9:1989",
1247
- "l5",
1248
- "latin5",
1249
- "windows-1254",
1250
- "x-cp1254"
1251
- ],
1252
- name: "windows-1254"
1253
- },
1254
- {
1255
- labels: ["cp1255", "windows-1255", "x-cp1255"],
1256
- name: "windows-1255"
1257
- },
1258
- {
1259
- labels: ["cp1256", "windows-1256", "x-cp1256"],
1260
- name: "windows-1256"
1261
- },
1262
- {
1263
- labels: ["cp1257", "windows-1257", "x-cp1257"],
1264
- name: "windows-1257"
1265
- },
1266
- {
1267
- labels: ["cp1258", "windows-1258", "x-cp1258"],
1268
- name: "windows-1258"
1269
- },
1270
- {
1271
- labels: ["x-mac-cyrillic", "x-mac-ukrainian"],
1272
- name: "x-mac-cyrillic"
1273
- }
1274
- ],
1275
- heading: "Legacy single-byte encodings"
1276
- },
1277
- {
1278
- encodings: [
1279
- {
1280
- labels: [
1281
- "chinese",
1282
- "csgb2312",
1283
- "csiso58gb231280",
1284
- "gb2312",
1285
- "gb_2312",
1286
- "gb_2312-80",
1287
- "gbk",
1288
- "iso-ir-58",
1289
- "x-gbk"
1290
- ],
1291
- name: "GBK"
1292
- },
1293
- {
1294
- labels: ["gb18030"],
1295
- name: "gb18030"
1296
- }
1297
- ],
1298
- heading: "Legacy multi-byte Chinese (simplified) encodings"
1299
- },
1300
- {
1301
- encodings: [
1302
- {
1303
- labels: ["big5", "big5-hkscs", "cn-big5", "csbig5", "x-x-big5"],
1304
- name: "Big5"
1305
- }
1306
- ],
1307
- heading: "Legacy multi-byte Chinese (traditional) encodings"
1308
- },
1309
- {
1310
- encodings: [
1311
- {
1312
- labels: ["cseucpkdfmtjapanese", "euc-jp", "x-euc-jp"],
1313
- name: "EUC-JP"
1314
- },
1315
- {
1316
- labels: ["csiso2022jp", "iso-2022-jp"],
1317
- name: "ISO-2022-JP"
1318
- },
1319
- {
1320
- labels: [
1321
- "csshiftjis",
1322
- "ms932",
1323
- "ms_kanji",
1324
- "shift-jis",
1325
- "shift_jis",
1326
- "sjis",
1327
- "windows-31j",
1328
- "x-sjis"
1329
- ],
1330
- name: "Shift_JIS"
1331
- }
1332
- ],
1333
- heading: "Legacy multi-byte Japanese encodings"
1334
- },
1335
- {
1336
- encodings: [
1337
- {
1338
- labels: [
1339
- "cseuckr",
1340
- "csksc56011987",
1341
- "euc-kr",
1342
- "iso-ir-149",
1343
- "korean",
1344
- "ks_c_5601-1987",
1345
- "ks_c_5601-1989",
1346
- "ksc5601",
1347
- "ksc_5601",
1348
- "windows-949"
1349
- ],
1350
- name: "EUC-KR"
1351
- }
1352
- ],
1353
- heading: "Legacy multi-byte Korean encodings"
1354
- },
1355
- {
1356
- encodings: [
1357
- {
1358
- labels: ["csiso2022kr", "hz-gb-2312", "iso-2022-cn", "iso-2022-cn-ext", "iso-2022-kr"],
1359
- name: "replacement"
1360
- },
1361
- {
1362
- labels: ["utf-16be"],
1363
- name: "UTF-16BE"
1364
- },
1365
- {
1366
- labels: ["utf-16", "utf-16le"],
1367
- name: "UTF-16LE"
1368
- },
1369
- {
1370
- labels: ["x-user-defined"],
1371
- name: "x-user-defined"
1372
- }
1373
- ],
1374
- heading: "Legacy miscellaneous encodings"
1375
- }
1376
- ];
1377
- label_to_encoding = {};
1378
- encodings.forEach(function(category) {
1379
- category.encodings.forEach(function(encoding) {
1380
- encoding.labels.forEach(function(label) {
1381
- label_to_encoding[label] = encoding;
1382
- });
1383
- });
1384
- });
1385
- encoders = {};
1386
- decoders = {};
1387
- DEFAULT_ENCODING = "utf-8";
1388
- if (Object.defineProperty) {
1389
- Object.defineProperty(TextDecoder.prototype, "encoding", {
1390
- get: function() {
1391
- return this._encoding.name.toLowerCase();
1392
- }
1393
- });
1394
- Object.defineProperty(TextDecoder.prototype, "fatal", {
1395
- get: function() {
1396
- return this._error_mode === "fatal";
1397
- }
1398
- });
1399
- Object.defineProperty(TextDecoder.prototype, "ignoreBOM", {
1400
- get: function() {
1401
- return this._ignoreBOM;
1402
- }
1403
- });
1404
- }
1405
- TextDecoder.prototype.decode = function decode(input, options) {
1406
- var bytes;
1407
- if (typeof input === "object" && input instanceof ArrayBuffer) {
1408
- bytes = new Uint8Array(input);
1409
- } else if (typeof input === "object" && "buffer" in input && input.buffer instanceof ArrayBuffer) {
1410
- bytes = new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
1411
- } else {
1412
- bytes = new Uint8Array(0);
1413
- }
1414
- options = ToDictionary(options);
1415
- if (!this._do_not_flush) {
1416
- this._decoder = decoders[this._encoding.name]({
1417
- fatal: this._error_mode === "fatal"
1418
- });
1419
- this._BOMseen = false;
1420
- }
1421
- this._do_not_flush = Boolean(options["stream"]);
1422
- var input_stream = new Stream(bytes);
1423
- var output = [];
1424
- var result;
1425
- while (true) {
1426
- var token = input_stream.read();
1427
- if (token === end_of_stream)
1428
- break;
1429
- result = this._decoder.handler(input_stream, token);
1430
- if (result === finished)
1431
- break;
1432
- if (result !== null) {
1433
- if (Array.isArray(result))
1434
- output.push.apply(output, result);
1435
- else
1436
- output.push(result);
1437
- }
1438
- }
1439
- if (!this._do_not_flush) {
1440
- do {
1441
- result = this._decoder.handler(input_stream, input_stream.read());
1442
- if (result === finished)
1443
- break;
1444
- if (result === null)
1445
- continue;
1446
- if (Array.isArray(result))
1447
- output.push.apply(output, result);
1448
- else
1449
- output.push(result);
1450
- } while (!input_stream.endOfStream());
1451
- this._decoder = null;
1452
- }
1453
- function serializeStream(stream) {
1454
- if (includes(["UTF-8", "UTF-16LE", "UTF-16BE"], this._encoding.name) && !this._ignoreBOM && !this._BOMseen) {
1455
- if (stream.length > 0 && stream[0] === 65279) {
1456
- this._BOMseen = true;
1457
- stream.shift();
1458
- } else if (stream.length > 0) {
1459
- this._BOMseen = true;
1460
- } else {
1461
- }
1462
- }
1463
- return codePointsToString(stream);
1464
- }
1465
- return serializeStream.call(this, output);
1466
- };
1467
- if (Object.defineProperty) {
1468
- Object.defineProperty(TextEncoder.prototype, "encoding", {
1469
- get: function() {
1470
- return this._encoding.name.toLowerCase();
1471
- }
1472
- });
1473
- }
1474
- TextEncoder.prototype.encode = function encode(opt_string, options) {
1475
- opt_string = opt_string === void 0 ? "" : String(opt_string);
1476
- options = ToDictionary(options);
1477
- if (!this._do_not_flush)
1478
- this._encoder = encoders[this._encoding.name]({
1479
- fatal: this._fatal === "fatal"
1480
- });
1481
- this._do_not_flush = Boolean(options["stream"]);
1482
- var input = new Stream(stringToCodePoints(opt_string));
1483
- var output = [];
1484
- var result;
1485
- while (true) {
1486
- var token = input.read();
1487
- if (token === end_of_stream)
1488
- break;
1489
- result = this._encoder.handler(input, token);
1490
- if (result === finished)
1491
- break;
1492
- if (Array.isArray(result))
1493
- output.push.apply(output, result);
1494
- else
1495
- output.push(result);
1496
- }
1497
- if (!this._do_not_flush) {
1498
- while (true) {
1499
- result = this._encoder.handler(input, input.read());
1500
- if (result === finished)
1501
- break;
1502
- if (Array.isArray(result))
1503
- output.push.apply(output, result);
1504
- else
1505
- output.push(result);
1506
- }
1507
- this._encoder = null;
1508
- }
1509
- return new Uint8Array(output);
1510
- };
1511
- encoders["UTF-8"] = function(options) {
1512
- return new UTF8Encoder(options);
1513
- };
1514
- decoders["UTF-8"] = function(options) {
1515
- return new UTF8Decoder(options);
1516
- };
1517
- (function() {
1518
- if (!("encoding-indexes" in global))
1519
- return;
1520
- encodings.forEach(function(category) {
1521
- if (category.heading !== "Legacy single-byte encodings")
1522
- return;
1523
- category.encodings.forEach(function(encoding) {
1524
- var name = encoding.name;
1525
- var idx = index(name.toLowerCase());
1526
- decoders[name] = function(options) {
1527
- return new SingleByteDecoder(idx, options);
1528
- };
1529
- encoders[name] = function(options) {
1530
- return new SingleByteEncoder(idx, options);
1531
- };
1532
- });
1533
- });
1534
- })();
1535
- decoders["GBK"] = function(options) {
1536
- return new GB18030Decoder(options);
1537
- };
1538
- encoders["GBK"] = function(options) {
1539
- return new GB18030Encoder(options, true);
1540
- };
1541
- encoders["gb18030"] = function(options) {
1542
- return new GB18030Encoder(options);
1543
- };
1544
- decoders["gb18030"] = function(options) {
1545
- return new GB18030Decoder(options);
1546
- };
1547
- encoders["Big5"] = function(options) {
1548
- return new Big5Encoder(options);
1549
- };
1550
- decoders["Big5"] = function(options) {
1551
- return new Big5Decoder(options);
1552
- };
1553
- encoders["EUC-JP"] = function(options) {
1554
- return new EUCJPEncoder(options);
1555
- };
1556
- decoders["EUC-JP"] = function(options) {
1557
- return new EUCJPDecoder(options);
1558
- };
1559
- encoders["ISO-2022-JP"] = function(options) {
1560
- return new ISO2022JPEncoder(options);
1561
- };
1562
- decoders["ISO-2022-JP"] = function(options) {
1563
- return new ISO2022JPDecoder(options);
1564
- };
1565
- encoders["Shift_JIS"] = function(options) {
1566
- return new ShiftJISEncoder(options);
1567
- };
1568
- decoders["Shift_JIS"] = function(options) {
1569
- return new ShiftJISDecoder(options);
1570
- };
1571
- encoders["EUC-KR"] = function(options) {
1572
- return new EUCKREncoder(options);
1573
- };
1574
- decoders["EUC-KR"] = function(options) {
1575
- return new EUCKRDecoder(options);
1576
- };
1577
- encoders["UTF-16BE"] = function(options) {
1578
- return new UTF16Encoder(true, options);
1579
- };
1580
- decoders["UTF-16BE"] = function(options) {
1581
- return new UTF16Decoder(true, options);
1582
- };
1583
- encoders["UTF-16LE"] = function(options) {
1584
- return new UTF16Encoder(false, options);
1585
- };
1586
- decoders["UTF-16LE"] = function(options) {
1587
- return new UTF16Decoder(false, options);
1588
- };
1589
- encoders["x-user-defined"] = function(options) {
1590
- return new XUserDefinedEncoder(options);
1591
- };
1592
- decoders["x-user-defined"] = function(options) {
1593
- return new XUserDefinedDecoder(options);
1594
- };
1595
- }
1596
- });
1597
-
1598
16
  // src/promise/all-settled.ts
1599
17
  function allSettled(promises) {
1600
18
  const mappedPromises = promises.map((promise) => {
@@ -1614,176 +32,29 @@
1614
32
  }
1615
33
  });
1616
34
 
1617
- // (disabled):src/node/buffer/btoa.node
1618
- var init_btoa = __esm({
1619
- "(disabled):src/node/buffer/btoa.node"() {
1620
- }
1621
- });
1622
-
1623
- // (disabled):src/node/fetch/headers.node
1624
- var init_headers = __esm({
1625
- "(disabled):src/node/fetch/headers.node"() {
1626
- }
1627
- });
1628
-
1629
- // (disabled):src/node/fetch/response.node
1630
- var init_response = __esm({
1631
- "(disabled):src/node/fetch/response.node"() {
1632
- }
1633
- });
1634
-
1635
- // (disabled):src/node/fetch/fetch.node
1636
- var init_fetch = __esm({
1637
- "(disabled):src/node/fetch/fetch.node"() {
1638
- }
1639
- });
1640
-
1641
- // (disabled):src/node/images/encode-image.node
1642
- var init_encode_image = __esm({
1643
- "(disabled):src/node/images/encode-image.node"() {
1644
- }
1645
- });
1646
-
1647
- // (disabled):src/node/images/parse-image.node
1648
- var init_parse_image = __esm({
1649
- "(disabled):src/node/images/parse-image.node"() {
1650
- }
1651
- });
1652
-
1653
- // src/node/file/file-reader.ts
1654
- var FileReaderPolyfill;
1655
- var init_file_reader = __esm({
1656
- "src/node/file/file-reader.ts"() {
1657
- init_btoa();
1658
- FileReaderPolyfill = class {
1659
- constructor() {
1660
- this.onload = null;
1661
- }
1662
- abort() {
1663
- return;
1664
- }
1665
- async readAsArrayBuffer(blob) {
1666
- const arrayBuffer = await blob.arrayBuffer();
1667
- if (this.onload) {
1668
- this.onload({ target: { result: arrayBuffer } });
1669
- }
1670
- }
1671
- async readAsBinaryString(blob) {
1672
- throw Error("Not implemented");
1673
- }
1674
- async readAsDataURL(blob) {
1675
- const text = await blob.text();
1676
- const dataUrl = `data://;base64,${(0, import_btoa.atob)(text)}`;
1677
- if (this.onload) {
1678
- this.onload({ target: { result: dataUrl } });
1679
- }
1680
- }
1681
- async readAsText(blob) {
1682
- const text = await blob.text();
1683
- if (this.onload) {
1684
- this.onload({ target: { result: text } });
1685
- }
1686
- }
1687
- };
1688
- }
1689
- });
1690
-
1691
- // (disabled):src/node/file/file
1692
- var init_file = __esm({
1693
- "(disabled):src/node/file/file"() {
1694
- }
1695
- });
1696
-
1697
- // (disabled):src/node/file/blob
1698
- var init_blob = __esm({
1699
- "(disabled):src/node/file/blob"() {
1700
- }
35
+ // src/index.browser.ts
36
+ var index_browser_exports = {};
37
+ __export(index_browser_exports, {
38
+ NodeFileSystem: () => NodeFileSystem,
39
+ installFilePolyfills: () => installFilePolyfills
1701
40
  });
1702
-
1703
- // src/node/file/install-file-polyfills.ts
1704
41
  function installFilePolyfills() {
1705
- if (typeof ReadableStream === "undefined" && global) {
1706
- }
1707
- if (typeof Blob === "undefined" && global) {
1708
- global.Blob = import_blob.BlobPolyfill;
1709
- }
1710
- if (typeof FileReader === "undefined" && global) {
1711
- global.FileReader = FileReaderPolyfill;
1712
- }
1713
- if (typeof File === "undefined" && global) {
1714
- global.File = import_file.FilePolyfill;
1715
- }
1716
42
  }
1717
- var init_install_file_polyfills = __esm({
1718
- "src/node/file/install-file-polyfills.ts"() {
1719
- init_blob();
1720
- init_file_reader();
1721
- init_file();
1722
- }
1723
- });
1724
-
1725
- // src/index.ts
1726
- var src_exports = {};
1727
- __export(src_exports, {
1728
- FilePolyfill: () => import_file2.FilePolyfill,
1729
- FileReaderPolyfill: () => FileReaderPolyfill,
1730
- installFilePolyfills: () => installFilePolyfills
1731
- });
1732
- var installTextEncoder, installTextDecoder;
1733
- var init_src = __esm({
1734
- "src/index.ts"() {
1735
- init_globals();
1736
- init_encoding();
43
+ var NodeFileSystem;
44
+ var init_index_browser = __esm({
45
+ "src/index.browser.ts"() {
1737
46
  init_all_settled();
1738
- init_btoa();
1739
- init_headers();
1740
- init_response();
1741
- init_fetch();
1742
- init_encode_image();
1743
- init_parse_image();
1744
- init_file_reader();
1745
- init_file();
1746
- init_install_file_polyfills();
1747
- installTextEncoder = !isBrowser || !("TextEncoder" in global_);
1748
- if (installTextEncoder) {
1749
- global_["TextEncoder"] = TextEncoder;
1750
- }
1751
- installTextDecoder = !isBrowser || !("TextDecoder" in global_);
1752
- if (installTextDecoder) {
1753
- global_["TextDecoder"] = TextDecoder;
1754
- }
1755
- if (!isBrowser && !("atob" in global_) && base64.atob) {
1756
- global_["atob"] = base64.atob;
1757
- }
1758
- if (!isBrowser && !("btoa" in global_) && base64.btoa) {
1759
- global_["btoa"] = base64.btoa;
1760
- }
1761
- if (!isBrowser && !("Headers" in global_) && import_headers.Headers) {
1762
- global_["Headers"] = import_headers.Headers;
1763
- }
1764
- if (!isBrowser && !("Response" in global_) && import_response.Response) {
1765
- global_["Response"] = import_response.Response;
1766
- }
1767
- if (!isBrowser && !("fetch" in global_) && import_fetch.fetchNode) {
1768
- global_["fetch"] = import_fetch.fetchNode;
1769
- }
1770
- if (!isBrowser && !("_encodeImageNode" in global_) && import_encode_image.encodeImageNode) {
1771
- global_["_encodeImageNode"] = import_encode_image.encodeImageNode;
1772
- }
1773
- if (!isBrowser && !("_parseImageNode" in global_) && import_parse_image.parseImageNode) {
1774
- global_["_parseImageNode"] = import_parse_image.parseImageNode;
1775
- global_["_imageFormatsNode"] = import_parse_image.NODE_FORMAT_SUPPORT;
1776
- }
1777
47
  if (!("allSettled" in Promise)) {
1778
48
  Promise.allSettled = allSettled;
1779
49
  }
50
+ NodeFileSystem = null;
1780
51
  }
1781
52
  });
1782
53
 
1783
54
  // src/bundle.ts
1784
55
  var require_bundle = __commonJS({
1785
56
  "src/bundle.ts"(exports, module) {
1786
- var moduleExports = (init_src(), src_exports);
57
+ var moduleExports = (init_index_browser(), index_browser_exports);
1787
58
  globalThis.loaders = globalThis.loaders || {};
1788
59
  module.exports = Object.assign(globalThis.loaders, moduleExports);
1789
60
  }