@aiquants/html-to-markdown 0.5.1 → 0.6.0
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/{core-DhxxOcPm.js → core-txi0EJ9v.js} +19 -12
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/main.js +1 -1
- package/dist/{mcp-server-DOe8W9IZ.js → mcp-server-B8T7ljWL.js} +2 -2
- package/dist/{mcp-server-Dn3EHzcf.cjs → mcp-server-jjdOcY1v.cjs} +1 -1
- package/dist/{mcp-server-streamable-pcpU_lDl.js → mcp-server-streamable-Bv5fFO_D.js} +498 -330
- package/dist/mcp-server-streamable-DU6yq8ZG.cjs +1 -0
- package/dist/mcp-streamable.cjs +1 -1
- package/dist/mcp-streamable.js +1 -1
- package/dist/mcp.cjs +1 -1
- package/dist/mcp.js +1 -1
- package/dist/src/mcp-server.d.ts +18 -0
- package/dist/{version-BNwQMbri.js → version-DrEUqsN7.js} +99 -70
- package/dist/version-Jbxn3hLf.cjs +1 -0
- package/package.json +18 -13
- package/dist/mcp-server-streamable-DUB_ixZe.cjs +0 -1
- package/dist/version-BsWiDlbg.cjs +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { J as JSONRPCMessageSchema, i as isInitializeRequest, e as isJSONRPCRequest, D as DEFAULT_NEGOTIATED_PROTOCOL_VERSION, f as SUPPORTED_PROTOCOL_VERSIONS, h as isJSONRPCResponse, j as isJSONRPCError, g as getPackageVersion, S as Server, I as InitializeRequestSchema, L as ListToolsRequestSchema, C as CallToolRequestSchema, p as parseHtmlToMarkdownArgs, b as parseSaveContentArgs, s as saveContentToFile, d as parseUrlToMarkdownFileArgs } from "./version-
|
|
2
|
-
import { a as getAugmentedNamespace, c as commonjsGlobal, b as getDefaultExportFromCjs, h as htmlToMarkdown } from "./core-
|
|
1
|
+
import { J as JSONRPCMessageSchema, i as isInitializeRequest, e as isJSONRPCRequest, D as DEFAULT_NEGOTIATED_PROTOCOL_VERSION, f as SUPPORTED_PROTOCOL_VERSIONS, h as isJSONRPCResponse, j as isJSONRPCError, g as getPackageVersion, S as Server, I as InitializeRequestSchema, L as ListToolsRequestSchema, C as CallToolRequestSchema, p as parseHtmlToMarkdownArgs, b as parseSaveContentArgs, s as saveContentToFile, d as parseUrlToMarkdownFileArgs } from "./version-DrEUqsN7.js";
|
|
2
|
+
import { a as getAugmentedNamespace, c as commonjsGlobal, b as getDefaultExportFromCjs, h as htmlToMarkdown } from "./core-txi0EJ9v.js";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import cors from "cors";
|
|
5
5
|
import express from "express";
|
|
@@ -2293,7 +2293,7 @@ function requireBuffer() {
|
|
|
2293
2293
|
function numberIsNaN(obj) {
|
|
2294
2294
|
return obj !== obj;
|
|
2295
2295
|
}
|
|
2296
|
-
const hexSliceLookupTable = function() {
|
|
2296
|
+
const hexSliceLookupTable = (function() {
|
|
2297
2297
|
const alphabet = "0123456789abcdef";
|
|
2298
2298
|
const table = new Array(256);
|
|
2299
2299
|
for (let i = 0; i < 16; ++i) {
|
|
@@ -2303,7 +2303,7 @@ function requireBuffer() {
|
|
|
2303
2303
|
}
|
|
2304
2304
|
}
|
|
2305
2305
|
return table;
|
|
2306
|
-
}();
|
|
2306
|
+
})();
|
|
2307
2307
|
function defineBigIntMethod(fn) {
|
|
2308
2308
|
return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
|
|
2309
2309
|
}
|
|
@@ -2410,12 +2410,14 @@ function requireBomHandling() {
|
|
|
2410
2410
|
}
|
|
2411
2411
|
StripBOMWrapper.prototype.write = function(buf) {
|
|
2412
2412
|
var res = this.decoder.write(buf);
|
|
2413
|
-
if (this.pass || !res)
|
|
2413
|
+
if (this.pass || !res) {
|
|
2414
2414
|
return res;
|
|
2415
|
+
}
|
|
2415
2416
|
if (res[0] === BOMChar) {
|
|
2416
2417
|
res = res.slice(1);
|
|
2417
|
-
if (typeof this.options.stripBOM === "function")
|
|
2418
|
+
if (typeof this.options.stripBOM === "function") {
|
|
2418
2419
|
this.options.stripBOM();
|
|
2420
|
+
}
|
|
2419
2421
|
}
|
|
2420
2422
|
this.pass = true;
|
|
2421
2423
|
return res;
|
|
@@ -2425,6 +2427,22 @@ function requireBomHandling() {
|
|
|
2425
2427
|
};
|
|
2426
2428
|
return bomHandling;
|
|
2427
2429
|
}
|
|
2430
|
+
var mergeExports;
|
|
2431
|
+
var hasRequiredMergeExports;
|
|
2432
|
+
function requireMergeExports() {
|
|
2433
|
+
if (hasRequiredMergeExports) return mergeExports;
|
|
2434
|
+
hasRequiredMergeExports = 1;
|
|
2435
|
+
var hasOwn = typeof Object.hasOwn === "undefined" ? Function.call.bind(Object.prototype.hasOwnProperty) : Object.hasOwn;
|
|
2436
|
+
function mergeModules(target, module) {
|
|
2437
|
+
for (var key in module) {
|
|
2438
|
+
if (hasOwn(module, key)) {
|
|
2439
|
+
target[key] = module[key];
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
mergeExports = mergeModules;
|
|
2444
|
+
return mergeExports;
|
|
2445
|
+
}
|
|
2428
2446
|
var encodings = {};
|
|
2429
2447
|
var string_decoder = {};
|
|
2430
2448
|
var safeBuffer = { exports: {} };
|
|
@@ -2748,9 +2766,11 @@ function requireInternal() {
|
|
|
2748
2766
|
function InternalCodec(codecOptions, iconv) {
|
|
2749
2767
|
this.enc = codecOptions.encodingName;
|
|
2750
2768
|
this.bomAware = codecOptions.bomAware;
|
|
2751
|
-
if (this.enc === "base64")
|
|
2769
|
+
if (this.enc === "base64") {
|
|
2752
2770
|
this.encoder = InternalEncoderBase64;
|
|
2753
|
-
else if (this.enc === "
|
|
2771
|
+
} else if (this.enc === "utf8") {
|
|
2772
|
+
this.encoder = InternalEncoderUtf8;
|
|
2773
|
+
} else if (this.enc === "cesu8") {
|
|
2754
2774
|
this.enc = "utf8";
|
|
2755
2775
|
this.encoder = InternalEncoderCesu8;
|
|
2756
2776
|
if (Buffer2.from("eda0bdedb2a9", "hex").toString() !== "💩") {
|
|
@@ -2762,9 +2782,6 @@ function requireInternal() {
|
|
|
2762
2782
|
InternalCodec.prototype.encoder = InternalEncoder;
|
|
2763
2783
|
InternalCodec.prototype.decoder = InternalDecoder;
|
|
2764
2784
|
var StringDecoder = requireString_decoder().StringDecoder;
|
|
2765
|
-
if (!StringDecoder.prototype.end)
|
|
2766
|
-
StringDecoder.prototype.end = function() {
|
|
2767
|
-
};
|
|
2768
2785
|
function InternalDecoder(options, codec) {
|
|
2769
2786
|
this.decoder = new StringDecoder(codec.enc);
|
|
2770
2787
|
}
|
|
@@ -2801,12 +2818,13 @@ function requireInternal() {
|
|
|
2801
2818
|
function InternalEncoderCesu8(options, codec) {
|
|
2802
2819
|
}
|
|
2803
2820
|
InternalEncoderCesu8.prototype.write = function(str) {
|
|
2804
|
-
var buf = Buffer2.alloc(str.length * 3)
|
|
2821
|
+
var buf = Buffer2.alloc(str.length * 3);
|
|
2822
|
+
var bufIdx = 0;
|
|
2805
2823
|
for (var i = 0; i < str.length; i++) {
|
|
2806
2824
|
var charCode = str.charCodeAt(i);
|
|
2807
|
-
if (charCode < 128)
|
|
2825
|
+
if (charCode < 128) {
|
|
2808
2826
|
buf[bufIdx++] = charCode;
|
|
2809
|
-
else if (charCode < 2048) {
|
|
2827
|
+
} else if (charCode < 2048) {
|
|
2810
2828
|
buf[bufIdx++] = 192 + (charCode >>> 6);
|
|
2811
2829
|
buf[bufIdx++] = 128 + (charCode & 63);
|
|
2812
2830
|
} else {
|
|
@@ -2826,7 +2844,10 @@ function requireInternal() {
|
|
|
2826
2844
|
this.defaultCharUnicode = codec.defaultCharUnicode;
|
|
2827
2845
|
}
|
|
2828
2846
|
InternalDecoderCesu8.prototype.write = function(buf) {
|
|
2829
|
-
var acc = this.acc
|
|
2847
|
+
var acc = this.acc;
|
|
2848
|
+
var contBytes = this.contBytes;
|
|
2849
|
+
var accBytes = this.accBytes;
|
|
2850
|
+
var res = "";
|
|
2830
2851
|
for (var i = 0; i < buf.length; i++) {
|
|
2831
2852
|
var curByte = buf[i];
|
|
2832
2853
|
if ((curByte & 192) !== 128) {
|
|
@@ -2853,12 +2874,13 @@ function requireInternal() {
|
|
|
2853
2874
|
contBytes--;
|
|
2854
2875
|
accBytes++;
|
|
2855
2876
|
if (contBytes === 0) {
|
|
2856
|
-
if (accBytes === 2 && acc < 128 && acc > 0)
|
|
2877
|
+
if (accBytes === 2 && acc < 128 && acc > 0) {
|
|
2857
2878
|
res += this.defaultCharUnicode;
|
|
2858
|
-
else if (accBytes === 3 && acc < 2048)
|
|
2879
|
+
} else if (accBytes === 3 && acc < 2048) {
|
|
2859
2880
|
res += this.defaultCharUnicode;
|
|
2860
|
-
else
|
|
2881
|
+
} else {
|
|
2861
2882
|
res += String.fromCharCode(acc);
|
|
2883
|
+
}
|
|
2862
2884
|
}
|
|
2863
2885
|
} else {
|
|
2864
2886
|
res += this.defaultCharUnicode;
|
|
@@ -2872,10 +2894,35 @@ function requireInternal() {
|
|
|
2872
2894
|
};
|
|
2873
2895
|
InternalDecoderCesu8.prototype.end = function() {
|
|
2874
2896
|
var res = 0;
|
|
2875
|
-
if (this.contBytes > 0)
|
|
2897
|
+
if (this.contBytes > 0) {
|
|
2876
2898
|
res += this.defaultCharUnicode;
|
|
2899
|
+
}
|
|
2877
2900
|
return res;
|
|
2878
2901
|
};
|
|
2902
|
+
function InternalEncoderUtf8(options, codec) {
|
|
2903
|
+
this.highSurrogate = "";
|
|
2904
|
+
}
|
|
2905
|
+
InternalEncoderUtf8.prototype.write = function(str) {
|
|
2906
|
+
if (this.highSurrogate) {
|
|
2907
|
+
str = this.highSurrogate + str;
|
|
2908
|
+
this.highSurrogate = "";
|
|
2909
|
+
}
|
|
2910
|
+
if (str.length > 0) {
|
|
2911
|
+
var charCode = str.charCodeAt(str.length - 1);
|
|
2912
|
+
if (charCode >= 55296 && charCode < 56320) {
|
|
2913
|
+
this.highSurrogate = str[str.length - 1];
|
|
2914
|
+
str = str.slice(0, str.length - 1);
|
|
2915
|
+
}
|
|
2916
|
+
}
|
|
2917
|
+
return Buffer2.from(str, this.enc);
|
|
2918
|
+
};
|
|
2919
|
+
InternalEncoderUtf8.prototype.end = function() {
|
|
2920
|
+
if (this.highSurrogate) {
|
|
2921
|
+
var str = this.highSurrogate;
|
|
2922
|
+
this.highSurrogate = "";
|
|
2923
|
+
return Buffer2.from(str, this.enc);
|
|
2924
|
+
}
|
|
2925
|
+
};
|
|
2879
2926
|
return internal;
|
|
2880
2927
|
}
|
|
2881
2928
|
var utf32 = {};
|
|
@@ -2907,8 +2954,8 @@ function requireUtf32() {
|
|
|
2907
2954
|
var offset = 0;
|
|
2908
2955
|
for (var i = 0; i < src.length; i += 2) {
|
|
2909
2956
|
var code = src.readUInt16LE(i);
|
|
2910
|
-
var isHighSurrogate =
|
|
2911
|
-
var isLowSurrogate =
|
|
2957
|
+
var isHighSurrogate = code >= 55296 && code < 56320;
|
|
2958
|
+
var isLowSurrogate = code >= 56320 && code < 57344;
|
|
2912
2959
|
if (this.highSurrogate) {
|
|
2913
2960
|
if (isHighSurrogate || !isLowSurrogate) {
|
|
2914
2961
|
write32.call(dst, this.highSurrogate, offset);
|
|
@@ -2921,26 +2968,29 @@ function requireUtf32() {
|
|
|
2921
2968
|
continue;
|
|
2922
2969
|
}
|
|
2923
2970
|
}
|
|
2924
|
-
if (isHighSurrogate)
|
|
2971
|
+
if (isHighSurrogate) {
|
|
2925
2972
|
this.highSurrogate = code;
|
|
2926
|
-
else {
|
|
2973
|
+
} else {
|
|
2927
2974
|
write32.call(dst, code, offset);
|
|
2928
2975
|
offset += 4;
|
|
2929
2976
|
this.highSurrogate = 0;
|
|
2930
2977
|
}
|
|
2931
2978
|
}
|
|
2932
|
-
if (offset < dst.length)
|
|
2979
|
+
if (offset < dst.length) {
|
|
2933
2980
|
dst = dst.slice(0, offset);
|
|
2981
|
+
}
|
|
2934
2982
|
return dst;
|
|
2935
2983
|
};
|
|
2936
2984
|
Utf32Encoder.prototype.end = function() {
|
|
2937
|
-
if (!this.highSurrogate)
|
|
2985
|
+
if (!this.highSurrogate) {
|
|
2938
2986
|
return;
|
|
2987
|
+
}
|
|
2939
2988
|
var buf = Buffer2.alloc(4);
|
|
2940
|
-
if (this.isLE)
|
|
2989
|
+
if (this.isLE) {
|
|
2941
2990
|
buf.writeUInt32LE(this.highSurrogate, 0);
|
|
2942
|
-
else
|
|
2991
|
+
} else {
|
|
2943
2992
|
buf.writeUInt32BE(this.highSurrogate, 0);
|
|
2993
|
+
}
|
|
2944
2994
|
this.highSurrogate = 0;
|
|
2945
2995
|
return buf;
|
|
2946
2996
|
};
|
|
@@ -2950,8 +3000,9 @@ function requireUtf32() {
|
|
|
2950
3000
|
this.overflow = [];
|
|
2951
3001
|
}
|
|
2952
3002
|
Utf32Decoder.prototype.write = function(src) {
|
|
2953
|
-
if (src.length === 0)
|
|
3003
|
+
if (src.length === 0) {
|
|
2954
3004
|
return "";
|
|
3005
|
+
}
|
|
2955
3006
|
var i = 0;
|
|
2956
3007
|
var codepoint = 0;
|
|
2957
3008
|
var dst = Buffer2.alloc(src.length + 4);
|
|
@@ -2960,8 +3011,9 @@ function requireUtf32() {
|
|
|
2960
3011
|
var overflow = this.overflow;
|
|
2961
3012
|
var badChar = this.badChar;
|
|
2962
3013
|
if (overflow.length > 0) {
|
|
2963
|
-
for (; i < src.length && overflow.length < 4; i++)
|
|
3014
|
+
for (; i < src.length && overflow.length < 4; i++) {
|
|
2964
3015
|
overflow.push(src[i]);
|
|
3016
|
+
}
|
|
2965
3017
|
if (overflow.length === 4) {
|
|
2966
3018
|
if (isLE) {
|
|
2967
3019
|
codepoint = overflow[i] | overflow[i + 1] << 8 | overflow[i + 2] << 16 | overflow[i + 3] << 24;
|
|
@@ -3012,8 +3064,9 @@ function requireUtf32() {
|
|
|
3012
3064
|
Utf32AutoCodec.prototype.decoder = Utf32AutoDecoder;
|
|
3013
3065
|
function Utf32AutoEncoder(options, codec) {
|
|
3014
3066
|
options = options || {};
|
|
3015
|
-
if (options.addBOM === void 0)
|
|
3067
|
+
if (options.addBOM === void 0) {
|
|
3016
3068
|
options.addBOM = true;
|
|
3069
|
+
}
|
|
3017
3070
|
this.encoder = codec.iconv.getEncoder(options.defaultEncoding || "utf-32le", options);
|
|
3018
3071
|
}
|
|
3019
3072
|
Utf32AutoEncoder.prototype.write = function(str) {
|
|
@@ -3033,13 +3086,15 @@ function requireUtf32() {
|
|
|
3033
3086
|
if (!this.decoder) {
|
|
3034
3087
|
this.initialBufs.push(buf);
|
|
3035
3088
|
this.initialBufsLen += buf.length;
|
|
3036
|
-
if (this.initialBufsLen < 32)
|
|
3089
|
+
if (this.initialBufsLen < 32) {
|
|
3037
3090
|
return "";
|
|
3091
|
+
}
|
|
3038
3092
|
var encoding = detectEncoding(this.initialBufs, this.options.defaultEncoding);
|
|
3039
3093
|
this.decoder = this.iconv.getDecoder(encoding, this.options);
|
|
3040
3094
|
var resStr = "";
|
|
3041
|
-
for (var i = 0; i < this.initialBufs.length; i++)
|
|
3095
|
+
for (var i = 0; i < this.initialBufs.length; i++) {
|
|
3042
3096
|
resStr += this.decoder.write(this.initialBufs[i]);
|
|
3097
|
+
}
|
|
3043
3098
|
this.initialBufs.length = this.initialBufsLen = 0;
|
|
3044
3099
|
return resStr;
|
|
3045
3100
|
}
|
|
@@ -3050,11 +3105,13 @@ function requireUtf32() {
|
|
|
3050
3105
|
var encoding = detectEncoding(this.initialBufs, this.options.defaultEncoding);
|
|
3051
3106
|
this.decoder = this.iconv.getDecoder(encoding, this.options);
|
|
3052
3107
|
var resStr = "";
|
|
3053
|
-
for (var i = 0; i < this.initialBufs.length; i++)
|
|
3108
|
+
for (var i = 0; i < this.initialBufs.length; i++) {
|
|
3054
3109
|
resStr += this.decoder.write(this.initialBufs[i]);
|
|
3110
|
+
}
|
|
3055
3111
|
var trail = this.decoder.end();
|
|
3056
|
-
if (trail)
|
|
3112
|
+
if (trail) {
|
|
3057
3113
|
resStr += trail;
|
|
3114
|
+
}
|
|
3058
3115
|
this.initialBufs.length = this.initialBufsLen = 0;
|
|
3059
3116
|
return resStr;
|
|
3060
3117
|
}
|
|
@@ -3063,9 +3120,11 @@ function requireUtf32() {
|
|
|
3063
3120
|
function detectEncoding(bufs, defaultEncoding) {
|
|
3064
3121
|
var b = [];
|
|
3065
3122
|
var charsProcessed = 0;
|
|
3066
|
-
var invalidLE = 0
|
|
3067
|
-
var
|
|
3068
|
-
|
|
3123
|
+
var invalidLE = 0;
|
|
3124
|
+
var invalidBE = 0;
|
|
3125
|
+
var bmpCharsLE = 0;
|
|
3126
|
+
var bmpCharsBE = 0;
|
|
3127
|
+
outerLoop:
|
|
3069
3128
|
for (var i = 0; i < bufs.length; i++) {
|
|
3070
3129
|
var buf = bufs[i];
|
|
3071
3130
|
for (var j = 0; j < buf.length; j++) {
|
|
@@ -3086,7 +3145,7 @@ function requireUtf32() {
|
|
|
3086
3145
|
b.length = 0;
|
|
3087
3146
|
charsProcessed++;
|
|
3088
3147
|
if (charsProcessed >= 100) {
|
|
3089
|
-
break
|
|
3148
|
+
break outerLoop;
|
|
3090
3149
|
}
|
|
3091
3150
|
}
|
|
3092
3151
|
}
|
|
@@ -3126,9 +3185,12 @@ function requireUtf16() {
|
|
|
3126
3185
|
this.overflowByte = -1;
|
|
3127
3186
|
}
|
|
3128
3187
|
Utf16BEDecoder.prototype.write = function(buf) {
|
|
3129
|
-
if (buf.length == 0)
|
|
3188
|
+
if (buf.length == 0) {
|
|
3130
3189
|
return "";
|
|
3131
|
-
|
|
3190
|
+
}
|
|
3191
|
+
var buf2 = Buffer2.alloc(buf.length + 1);
|
|
3192
|
+
var i = 0;
|
|
3193
|
+
var j = 0;
|
|
3132
3194
|
if (this.overflowByte !== -1) {
|
|
3133
3195
|
buf2[0] = buf[0];
|
|
3134
3196
|
buf2[1] = this.overflowByte;
|
|
@@ -3153,8 +3215,9 @@ function requireUtf16() {
|
|
|
3153
3215
|
Utf16Codec.prototype.decoder = Utf16Decoder;
|
|
3154
3216
|
function Utf16Encoder(options, codec) {
|
|
3155
3217
|
options = options || {};
|
|
3156
|
-
if (options.addBOM === void 0)
|
|
3218
|
+
if (options.addBOM === void 0) {
|
|
3157
3219
|
options.addBOM = true;
|
|
3220
|
+
}
|
|
3158
3221
|
this.encoder = codec.iconv.getEncoder("utf-16le", options);
|
|
3159
3222
|
}
|
|
3160
3223
|
Utf16Encoder.prototype.write = function(str) {
|
|
@@ -3174,13 +3237,15 @@ function requireUtf16() {
|
|
|
3174
3237
|
if (!this.decoder) {
|
|
3175
3238
|
this.initialBufs.push(buf);
|
|
3176
3239
|
this.initialBufsLen += buf.length;
|
|
3177
|
-
if (this.initialBufsLen < 16)
|
|
3240
|
+
if (this.initialBufsLen < 16) {
|
|
3178
3241
|
return "";
|
|
3242
|
+
}
|
|
3179
3243
|
var encoding = detectEncoding(this.initialBufs, this.options.defaultEncoding);
|
|
3180
3244
|
this.decoder = this.iconv.getDecoder(encoding, this.options);
|
|
3181
3245
|
var resStr = "";
|
|
3182
|
-
for (var i = 0; i < this.initialBufs.length; i++)
|
|
3246
|
+
for (var i = 0; i < this.initialBufs.length; i++) {
|
|
3183
3247
|
resStr += this.decoder.write(this.initialBufs[i]);
|
|
3248
|
+
}
|
|
3184
3249
|
this.initialBufs.length = this.initialBufsLen = 0;
|
|
3185
3250
|
return resStr;
|
|
3186
3251
|
}
|
|
@@ -3191,11 +3256,13 @@ function requireUtf16() {
|
|
|
3191
3256
|
var encoding = detectEncoding(this.initialBufs, this.options.defaultEncoding);
|
|
3192
3257
|
this.decoder = this.iconv.getDecoder(encoding, this.options);
|
|
3193
3258
|
var resStr = "";
|
|
3194
|
-
for (var i = 0; i < this.initialBufs.length; i++)
|
|
3259
|
+
for (var i = 0; i < this.initialBufs.length; i++) {
|
|
3195
3260
|
resStr += this.decoder.write(this.initialBufs[i]);
|
|
3261
|
+
}
|
|
3196
3262
|
var trail = this.decoder.end();
|
|
3197
|
-
if (trail)
|
|
3263
|
+
if (trail) {
|
|
3198
3264
|
resStr += trail;
|
|
3265
|
+
}
|
|
3199
3266
|
this.initialBufs.length = this.initialBufsLen = 0;
|
|
3200
3267
|
return resStr;
|
|
3201
3268
|
}
|
|
@@ -3204,8 +3271,9 @@ function requireUtf16() {
|
|
|
3204
3271
|
function detectEncoding(bufs, defaultEncoding) {
|
|
3205
3272
|
var b = [];
|
|
3206
3273
|
var charsProcessed = 0;
|
|
3207
|
-
var asciiCharsLE = 0
|
|
3208
|
-
|
|
3274
|
+
var asciiCharsLE = 0;
|
|
3275
|
+
var asciiCharsBE = 0;
|
|
3276
|
+
outerLoop:
|
|
3209
3277
|
for (var i = 0; i < bufs.length; i++) {
|
|
3210
3278
|
var buf = bufs[i];
|
|
3211
3279
|
for (var j = 0; j < buf.length; j++) {
|
|
@@ -3220,7 +3288,7 @@ function requireUtf16() {
|
|
|
3220
3288
|
b.length = 0;
|
|
3221
3289
|
charsProcessed++;
|
|
3222
3290
|
if (charsProcessed >= 100) {
|
|
3223
|
-
break
|
|
3291
|
+
break outerLoop;
|
|
3224
3292
|
}
|
|
3225
3293
|
}
|
|
3226
3294
|
}
|
|
@@ -3263,11 +3331,17 @@ function requireUtf7() {
|
|
|
3263
3331
|
}
|
|
3264
3332
|
var base64Regex = /[A-Za-z0-9\/+]/;
|
|
3265
3333
|
var base64Chars = [];
|
|
3266
|
-
for (var i = 0; i < 256; i++)
|
|
3334
|
+
for (var i = 0; i < 256; i++) {
|
|
3267
3335
|
base64Chars[i] = base64Regex.test(String.fromCharCode(i));
|
|
3268
|
-
|
|
3336
|
+
}
|
|
3337
|
+
var plusChar = "+".charCodeAt(0);
|
|
3338
|
+
var minusChar = "-".charCodeAt(0);
|
|
3339
|
+
var andChar = "&".charCodeAt(0);
|
|
3269
3340
|
Utf7Decoder.prototype.write = function(buf) {
|
|
3270
|
-
var res = ""
|
|
3341
|
+
var res = "";
|
|
3342
|
+
var lastI = 0;
|
|
3343
|
+
var inBase64 = this.inBase64;
|
|
3344
|
+
var base64Accum = this.base64Accum;
|
|
3271
3345
|
for (var i2 = 0; i2 < buf.length; i2++) {
|
|
3272
3346
|
if (!inBase64) {
|
|
3273
3347
|
if (buf[i2] == plusChar) {
|
|
@@ -3283,8 +3357,9 @@ function requireUtf7() {
|
|
|
3283
3357
|
var b64str = base64Accum + this.iconv.decode(buf.slice(lastI, i2), "ascii");
|
|
3284
3358
|
res += this.iconv.decode(Buffer2.from(b64str, "base64"), "utf16-be");
|
|
3285
3359
|
}
|
|
3286
|
-
if (buf[i2] != minusChar)
|
|
3360
|
+
if (buf[i2] != minusChar) {
|
|
3287
3361
|
i2--;
|
|
3362
|
+
}
|
|
3288
3363
|
lastI = i2 + 1;
|
|
3289
3364
|
inBase64 = false;
|
|
3290
3365
|
base64Accum = "";
|
|
@@ -3306,8 +3381,9 @@ function requireUtf7() {
|
|
|
3306
3381
|
};
|
|
3307
3382
|
Utf7Decoder.prototype.end = function() {
|
|
3308
3383
|
var res = "";
|
|
3309
|
-
if (this.inBase64 && this.base64Accum.length > 0)
|
|
3384
|
+
if (this.inBase64 && this.base64Accum.length > 0) {
|
|
3310
3385
|
res = this.iconv.decode(Buffer2.from(this.base64Accum, "base64"), "utf16-be");
|
|
3386
|
+
}
|
|
3311
3387
|
this.inBase64 = false;
|
|
3312
3388
|
this.base64Accum = "";
|
|
3313
3389
|
return res;
|
|
@@ -3326,10 +3402,14 @@ function requireUtf7() {
|
|
|
3326
3402
|
this.base64AccumIdx = 0;
|
|
3327
3403
|
}
|
|
3328
3404
|
Utf7IMAPEncoder.prototype.write = function(str) {
|
|
3329
|
-
var inBase64 = this.inBase64
|
|
3405
|
+
var inBase64 = this.inBase64;
|
|
3406
|
+
var base64Accum = this.base64Accum;
|
|
3407
|
+
var base64AccumIdx = this.base64AccumIdx;
|
|
3408
|
+
var buf = Buffer2.alloc(str.length * 5 + 10);
|
|
3409
|
+
var bufIdx = 0;
|
|
3330
3410
|
for (var i2 = 0; i2 < str.length; i2++) {
|
|
3331
3411
|
var uChar = str.charCodeAt(i2);
|
|
3332
|
-
if (
|
|
3412
|
+
if (uChar >= 32 && uChar <= 126) {
|
|
3333
3413
|
if (inBase64) {
|
|
3334
3414
|
if (base64AccumIdx > 0) {
|
|
3335
3415
|
bufIdx += buf.write(base64Accum.slice(0, base64AccumIdx).toString("base64").replace(/\//g, ",").replace(/=+$/, ""), bufIdx);
|
|
@@ -3340,8 +3420,9 @@ function requireUtf7() {
|
|
|
3340
3420
|
}
|
|
3341
3421
|
if (!inBase64) {
|
|
3342
3422
|
buf[bufIdx++] = uChar;
|
|
3343
|
-
if (uChar === andChar)
|
|
3423
|
+
if (uChar === andChar) {
|
|
3344
3424
|
buf[bufIdx++] = minusChar;
|
|
3425
|
+
}
|
|
3345
3426
|
}
|
|
3346
3427
|
} else {
|
|
3347
3428
|
if (!inBase64) {
|
|
@@ -3363,7 +3444,8 @@ function requireUtf7() {
|
|
|
3363
3444
|
return buf.slice(0, bufIdx);
|
|
3364
3445
|
};
|
|
3365
3446
|
Utf7IMAPEncoder.prototype.end = function() {
|
|
3366
|
-
var buf = Buffer2.alloc(10)
|
|
3447
|
+
var buf = Buffer2.alloc(10);
|
|
3448
|
+
var bufIdx = 0;
|
|
3367
3449
|
if (this.inBase64) {
|
|
3368
3450
|
if (this.base64AccumIdx > 0) {
|
|
3369
3451
|
bufIdx += buf.write(this.base64Accum.slice(0, this.base64AccumIdx).toString("base64").replace(/\//g, ",").replace(/=+$/, ""), bufIdx);
|
|
@@ -3382,7 +3464,10 @@ function requireUtf7() {
|
|
|
3382
3464
|
var base64IMAPChars = base64Chars.slice();
|
|
3383
3465
|
base64IMAPChars[",".charCodeAt(0)] = true;
|
|
3384
3466
|
Utf7IMAPDecoder.prototype.write = function(buf) {
|
|
3385
|
-
var res = ""
|
|
3467
|
+
var res = "";
|
|
3468
|
+
var lastI = 0;
|
|
3469
|
+
var inBase64 = this.inBase64;
|
|
3470
|
+
var base64Accum = this.base64Accum;
|
|
3386
3471
|
for (var i2 = 0; i2 < buf.length; i2++) {
|
|
3387
3472
|
if (!inBase64) {
|
|
3388
3473
|
if (buf[i2] == andChar) {
|
|
@@ -3398,8 +3483,9 @@ function requireUtf7() {
|
|
|
3398
3483
|
var b64str = base64Accum + this.iconv.decode(buf.slice(lastI, i2), "ascii").replace(/,/g, "/");
|
|
3399
3484
|
res += this.iconv.decode(Buffer2.from(b64str, "base64"), "utf16-be");
|
|
3400
3485
|
}
|
|
3401
|
-
if (buf[i2] != minusChar)
|
|
3486
|
+
if (buf[i2] != minusChar) {
|
|
3402
3487
|
i2--;
|
|
3488
|
+
}
|
|
3403
3489
|
lastI = i2 + 1;
|
|
3404
3490
|
inBase64 = false;
|
|
3405
3491
|
base64Accum = "";
|
|
@@ -3421,8 +3507,9 @@ function requireUtf7() {
|
|
|
3421
3507
|
};
|
|
3422
3508
|
Utf7IMAPDecoder.prototype.end = function() {
|
|
3423
3509
|
var res = "";
|
|
3424
|
-
if (this.inBase64 && this.base64Accum.length > 0)
|
|
3510
|
+
if (this.inBase64 && this.base64Accum.length > 0) {
|
|
3425
3511
|
res = this.iconv.decode(Buffer2.from(this.base64Accum, "base64"), "utf16-be");
|
|
3512
|
+
}
|
|
3426
3513
|
this.inBase64 = false;
|
|
3427
3514
|
this.base64Accum = "";
|
|
3428
3515
|
return res;
|
|
@@ -3437,20 +3524,24 @@ function requireSbcsCodec() {
|
|
|
3437
3524
|
var Buffer2 = requireSafer().Buffer;
|
|
3438
3525
|
sbcsCodec._sbcs = SBCSCodec;
|
|
3439
3526
|
function SBCSCodec(codecOptions, iconv) {
|
|
3440
|
-
if (!codecOptions)
|
|
3527
|
+
if (!codecOptions) {
|
|
3441
3528
|
throw new Error("SBCS codec is called without the data.");
|
|
3442
|
-
|
|
3529
|
+
}
|
|
3530
|
+
if (!codecOptions.chars || codecOptions.chars.length !== 128 && codecOptions.chars.length !== 256) {
|
|
3443
3531
|
throw new Error("Encoding '" + codecOptions.type + "' has incorrect 'chars' (must be of len 128 or 256)");
|
|
3532
|
+
}
|
|
3444
3533
|
if (codecOptions.chars.length === 128) {
|
|
3445
3534
|
var asciiString = "";
|
|
3446
|
-
for (var i = 0; i < 128; i++)
|
|
3535
|
+
for (var i = 0; i < 128; i++) {
|
|
3447
3536
|
asciiString += String.fromCharCode(i);
|
|
3537
|
+
}
|
|
3448
3538
|
codecOptions.chars = asciiString + codecOptions.chars;
|
|
3449
3539
|
}
|
|
3450
3540
|
this.decodeBuf = Buffer2.from(codecOptions.chars, "ucs2");
|
|
3451
3541
|
var encodeBuf = Buffer2.alloc(65536, iconv.defaultCharSingleByte.charCodeAt(0));
|
|
3452
|
-
for (var i = 0; i < codecOptions.chars.length; i++)
|
|
3542
|
+
for (var i = 0; i < codecOptions.chars.length; i++) {
|
|
3453
3543
|
encodeBuf[codecOptions.chars.charCodeAt(i)] = i;
|
|
3544
|
+
}
|
|
3454
3545
|
this.encodeBuf = encodeBuf;
|
|
3455
3546
|
}
|
|
3456
3547
|
SBCSCodec.prototype.encoder = SBCSEncoder;
|
|
@@ -3460,8 +3551,9 @@ function requireSbcsCodec() {
|
|
|
3460
3551
|
}
|
|
3461
3552
|
SBCSEncoder.prototype.write = function(str) {
|
|
3462
3553
|
var buf = Buffer2.alloc(str.length);
|
|
3463
|
-
for (var i = 0; i < str.length; i++)
|
|
3554
|
+
for (var i = 0; i < str.length; i++) {
|
|
3464
3555
|
buf[i] = this.encodeBuf[str.charCodeAt(i)];
|
|
3556
|
+
}
|
|
3465
3557
|
return buf;
|
|
3466
3558
|
};
|
|
3467
3559
|
SBCSEncoder.prototype.end = function() {
|
|
@@ -3472,7 +3564,8 @@ function requireSbcsCodec() {
|
|
|
3472
3564
|
SBCSDecoder.prototype.write = function(buf) {
|
|
3473
3565
|
var decodeBuf = this.decodeBuf;
|
|
3474
3566
|
var newBuf = Buffer2.alloc(buf.length * 2);
|
|
3475
|
-
var idx1 = 0
|
|
3567
|
+
var idx1 = 0;
|
|
3568
|
+
var idx2 = 0;
|
|
3476
3569
|
for (var i = 0; i < buf.length; i++) {
|
|
3477
3570
|
idx1 = buf[i] * 2;
|
|
3478
3571
|
idx2 = i * 2;
|
|
@@ -3492,149 +3585,149 @@ function requireSbcsData() {
|
|
|
3492
3585
|
hasRequiredSbcsData = 1;
|
|
3493
3586
|
sbcsData = {
|
|
3494
3587
|
// Not supported by iconv, not sure why.
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3588
|
+
10029: "maccenteuro",
|
|
3589
|
+
maccenteuro: {
|
|
3590
|
+
type: "_sbcs",
|
|
3591
|
+
chars: "ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ"
|
|
3499
3592
|
},
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3593
|
+
808: "cp808",
|
|
3594
|
+
ibm808: "cp808",
|
|
3595
|
+
cp808: {
|
|
3596
|
+
type: "_sbcs",
|
|
3597
|
+
chars: "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмноп░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀рстуфхцчшщъыьэюяЁёЄєЇїЎў°∙·√№€■ "
|
|
3505
3598
|
},
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3599
|
+
mik: {
|
|
3600
|
+
type: "_sbcs",
|
|
3601
|
+
chars: "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя└┴┬├─┼╣║╚╔╩╦╠═╬┐░▒▓│┤№§╗╝┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ "
|
|
3509
3602
|
},
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3603
|
+
cp720: {
|
|
3604
|
+
type: "_sbcs",
|
|
3605
|
+
chars: "éâàçêëèïîّْô¤ـûùءآأؤ£إئابةتثجحخدذرزسشص«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ضطظعغفµقكلمنهوىي≡ًٌٍَُِ≈°∙·√ⁿ²■ "
|
|
3513
3606
|
},
|
|
3514
3607
|
// Aliases of generated encodings.
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
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
|
-
|
|
3608
|
+
ascii8bit: "ascii",
|
|
3609
|
+
usascii: "ascii",
|
|
3610
|
+
ansix34: "ascii",
|
|
3611
|
+
ansix341968: "ascii",
|
|
3612
|
+
ansix341986: "ascii",
|
|
3613
|
+
csascii: "ascii",
|
|
3614
|
+
cp367: "ascii",
|
|
3615
|
+
ibm367: "ascii",
|
|
3616
|
+
isoir6: "ascii",
|
|
3617
|
+
iso646us: "ascii",
|
|
3618
|
+
iso646irv: "ascii",
|
|
3619
|
+
us: "ascii",
|
|
3620
|
+
latin1: "iso88591",
|
|
3621
|
+
latin2: "iso88592",
|
|
3622
|
+
latin3: "iso88593",
|
|
3623
|
+
latin4: "iso88594",
|
|
3624
|
+
latin5: "iso88599",
|
|
3625
|
+
latin6: "iso885910",
|
|
3626
|
+
latin7: "iso885913",
|
|
3627
|
+
latin8: "iso885914",
|
|
3628
|
+
latin9: "iso885915",
|
|
3629
|
+
latin10: "iso885916",
|
|
3630
|
+
csisolatin1: "iso88591",
|
|
3631
|
+
csisolatin2: "iso88592",
|
|
3632
|
+
csisolatin3: "iso88593",
|
|
3633
|
+
csisolatin4: "iso88594",
|
|
3634
|
+
csisolatincyrillic: "iso88595",
|
|
3635
|
+
csisolatinarabic: "iso88596",
|
|
3636
|
+
csisolatingreek: "iso88597",
|
|
3637
|
+
csisolatinhebrew: "iso88598",
|
|
3638
|
+
csisolatin5: "iso88599",
|
|
3639
|
+
csisolatin6: "iso885910",
|
|
3640
|
+
l1: "iso88591",
|
|
3641
|
+
l2: "iso88592",
|
|
3642
|
+
l3: "iso88593",
|
|
3643
|
+
l4: "iso88594",
|
|
3644
|
+
l5: "iso88599",
|
|
3645
|
+
l6: "iso885910",
|
|
3646
|
+
l7: "iso885913",
|
|
3647
|
+
l8: "iso885914",
|
|
3648
|
+
l9: "iso885915",
|
|
3649
|
+
l10: "iso885916",
|
|
3650
|
+
isoir14: "iso646jp",
|
|
3651
|
+
isoir57: "iso646cn",
|
|
3652
|
+
isoir100: "iso88591",
|
|
3653
|
+
isoir101: "iso88592",
|
|
3654
|
+
isoir109: "iso88593",
|
|
3655
|
+
isoir110: "iso88594",
|
|
3656
|
+
isoir144: "iso88595",
|
|
3657
|
+
isoir127: "iso88596",
|
|
3658
|
+
isoir126: "iso88597",
|
|
3659
|
+
isoir138: "iso88598",
|
|
3660
|
+
isoir148: "iso88599",
|
|
3661
|
+
isoir157: "iso885910",
|
|
3662
|
+
isoir166: "tis620",
|
|
3663
|
+
isoir179: "iso885913",
|
|
3664
|
+
isoir199: "iso885914",
|
|
3665
|
+
isoir203: "iso885915",
|
|
3666
|
+
isoir226: "iso885916",
|
|
3667
|
+
cp819: "iso88591",
|
|
3668
|
+
ibm819: "iso88591",
|
|
3669
|
+
cyrillic: "iso88595",
|
|
3670
|
+
arabic: "iso88596",
|
|
3671
|
+
arabic8: "iso88596",
|
|
3672
|
+
ecma114: "iso88596",
|
|
3673
|
+
asmo708: "iso88596",
|
|
3674
|
+
greek: "iso88597",
|
|
3675
|
+
greek8: "iso88597",
|
|
3676
|
+
ecma118: "iso88597",
|
|
3677
|
+
elot928: "iso88597",
|
|
3678
|
+
hebrew: "iso88598",
|
|
3679
|
+
hebrew8: "iso88598",
|
|
3680
|
+
turkish: "iso88599",
|
|
3681
|
+
turkish8: "iso88599",
|
|
3682
|
+
thai: "iso885911",
|
|
3683
|
+
thai8: "iso885911",
|
|
3684
|
+
celtic: "iso885914",
|
|
3685
|
+
celtic8: "iso885914",
|
|
3686
|
+
isoceltic: "iso885914",
|
|
3687
|
+
tis6200: "tis620",
|
|
3688
|
+
tis62025291: "tis620",
|
|
3689
|
+
tis62025330: "tis620",
|
|
3690
|
+
1e4: "macroman",
|
|
3691
|
+
10006: "macgreek",
|
|
3692
|
+
10007: "maccyrillic",
|
|
3693
|
+
10079: "maciceland",
|
|
3694
|
+
10081: "macturkish",
|
|
3695
|
+
cspc8codepage437: "cp437",
|
|
3696
|
+
cspc775baltic: "cp775",
|
|
3697
|
+
cspc850multilingual: "cp850",
|
|
3698
|
+
cspcp852: "cp852",
|
|
3699
|
+
cspc862latinhebrew: "cp862",
|
|
3700
|
+
cpgr: "cp869",
|
|
3701
|
+
msee: "cp1250",
|
|
3702
|
+
mscyrl: "cp1251",
|
|
3703
|
+
msansi: "cp1252",
|
|
3704
|
+
msgreek: "cp1253",
|
|
3705
|
+
msturk: "cp1254",
|
|
3706
|
+
mshebr: "cp1255",
|
|
3707
|
+
msarab: "cp1256",
|
|
3708
|
+
winbaltrim: "cp1257",
|
|
3709
|
+
cp20866: "koi8r",
|
|
3710
|
+
20866: "koi8r",
|
|
3711
|
+
ibm878: "koi8r",
|
|
3712
|
+
cskoi8r: "koi8r",
|
|
3713
|
+
cp21866: "koi8u",
|
|
3714
|
+
21866: "koi8u",
|
|
3715
|
+
ibm1168: "koi8u",
|
|
3716
|
+
strk10482002: "rk1048",
|
|
3717
|
+
tcvn5712: "tcvn",
|
|
3718
|
+
tcvn57121: "tcvn",
|
|
3719
|
+
gb198880: "iso646cn",
|
|
3720
|
+
cn: "iso646cn",
|
|
3721
|
+
csiso14jisc6220ro: "iso646jp",
|
|
3722
|
+
jisc62201969ro: "iso646jp",
|
|
3723
|
+
jp: "iso646jp",
|
|
3724
|
+
cshproman8: "hproman8",
|
|
3725
|
+
r8: "hproman8",
|
|
3726
|
+
roman8: "hproman8",
|
|
3727
|
+
xroman8: "hproman8",
|
|
3728
|
+
ibm1051: "hproman8",
|
|
3729
|
+
mac: "macintosh",
|
|
3730
|
+
csmacintosh: "macintosh"
|
|
3638
3731
|
};
|
|
3639
3732
|
return sbcsData;
|
|
3640
3733
|
}
|
|
@@ -4100,21 +4193,30 @@ function requireDbcsCodec() {
|
|
|
4100
4193
|
hasRequiredDbcsCodec = 1;
|
|
4101
4194
|
var Buffer2 = requireSafer().Buffer;
|
|
4102
4195
|
dbcsCodec._dbcs = DBCSCodec;
|
|
4103
|
-
var UNASSIGNED = -1
|
|
4104
|
-
|
|
4196
|
+
var UNASSIGNED = -1;
|
|
4197
|
+
var GB18030_CODE = -2;
|
|
4198
|
+
var SEQ_START = -10;
|
|
4199
|
+
var NODE_START = -1e3;
|
|
4200
|
+
var UNASSIGNED_NODE = new Array(256);
|
|
4201
|
+
var DEF_CHAR = -1;
|
|
4202
|
+
for (var i = 0; i < 256; i++) {
|
|
4105
4203
|
UNASSIGNED_NODE[i] = UNASSIGNED;
|
|
4204
|
+
}
|
|
4106
4205
|
function DBCSCodec(codecOptions, iconv) {
|
|
4107
4206
|
this.encodingName = codecOptions.encodingName;
|
|
4108
|
-
if (!codecOptions)
|
|
4207
|
+
if (!codecOptions) {
|
|
4109
4208
|
throw new Error("DBCS codec is called without the data.");
|
|
4110
|
-
|
|
4209
|
+
}
|
|
4210
|
+
if (!codecOptions.table) {
|
|
4111
4211
|
throw new Error("Encoding '" + this.encodingName + "' has no data.");
|
|
4212
|
+
}
|
|
4112
4213
|
var mappingTable = codecOptions.table();
|
|
4113
4214
|
this.decodeTables = [];
|
|
4114
4215
|
this.decodeTables[0] = UNASSIGNED_NODE.slice(0);
|
|
4115
4216
|
this.decodeTableSeq = [];
|
|
4116
|
-
for (var i2 = 0; i2 < mappingTable.length; i2++)
|
|
4217
|
+
for (var i2 = 0; i2 < mappingTable.length; i2++) {
|
|
4117
4218
|
this._addDecodeChunk(mappingTable[i2]);
|
|
4219
|
+
}
|
|
4118
4220
|
if (typeof codecOptions.gb18030 === "function") {
|
|
4119
4221
|
this.gb18030 = codecOptions.gb18030();
|
|
4120
4222
|
var commonThirdByteNodeIdx = this.decodeTables.length;
|
|
@@ -4141,8 +4243,9 @@ function requireDbcsCodec() {
|
|
|
4141
4243
|
}
|
|
4142
4244
|
var fourthByteNode = this.decodeTables[NODE_START - thirdByteNode[k]];
|
|
4143
4245
|
for (var l = 48; l <= 57; l++) {
|
|
4144
|
-
if (fourthByteNode[l] === UNASSIGNED)
|
|
4246
|
+
if (fourthByteNode[l] === UNASSIGNED) {
|
|
4145
4247
|
fourthByteNode[l] = GB18030_CODE;
|
|
4248
|
+
}
|
|
4146
4249
|
}
|
|
4147
4250
|
}
|
|
4148
4251
|
}
|
|
@@ -4152,20 +4255,25 @@ function requireDbcsCodec() {
|
|
|
4152
4255
|
this.encodeTable = [];
|
|
4153
4256
|
this.encodeTableSeq = [];
|
|
4154
4257
|
var skipEncodeChars = {};
|
|
4155
|
-
if (codecOptions.encodeSkipVals)
|
|
4258
|
+
if (codecOptions.encodeSkipVals) {
|
|
4156
4259
|
for (var i2 = 0; i2 < codecOptions.encodeSkipVals.length; i2++) {
|
|
4157
4260
|
var val = codecOptions.encodeSkipVals[i2];
|
|
4158
|
-
if (typeof val === "number")
|
|
4261
|
+
if (typeof val === "number") {
|
|
4159
4262
|
skipEncodeChars[val] = true;
|
|
4160
|
-
else
|
|
4161
|
-
for (var j = val.from; j <= val.to; j++)
|
|
4263
|
+
} else {
|
|
4264
|
+
for (var j = val.from; j <= val.to; j++) {
|
|
4162
4265
|
skipEncodeChars[j] = true;
|
|
4266
|
+
}
|
|
4267
|
+
}
|
|
4163
4268
|
}
|
|
4269
|
+
}
|
|
4164
4270
|
this._fillEncodeTable(0, 0, skipEncodeChars);
|
|
4165
4271
|
if (codecOptions.encodeAdd) {
|
|
4166
|
-
for (var uChar in codecOptions.encodeAdd)
|
|
4167
|
-
if (Object.prototype.hasOwnProperty.call(codecOptions.encodeAdd, uChar))
|
|
4272
|
+
for (var uChar in codecOptions.encodeAdd) {
|
|
4273
|
+
if (Object.prototype.hasOwnProperty.call(codecOptions.encodeAdd, uChar)) {
|
|
4168
4274
|
this._setEncodeChar(uChar.charCodeAt(0), codecOptions.encodeAdd[uChar]);
|
|
4275
|
+
}
|
|
4276
|
+
}
|
|
4169
4277
|
}
|
|
4170
4278
|
this.defCharSB = this.encodeTable[0][iconv.defaultCharSingleByte.charCodeAt(0)];
|
|
4171
4279
|
if (this.defCharSB === UNASSIGNED) this.defCharSB = this.encodeTable[0]["?"];
|
|
@@ -4175,10 +4283,12 @@ function requireDbcsCodec() {
|
|
|
4175
4283
|
DBCSCodec.prototype.decoder = DBCSDecoder;
|
|
4176
4284
|
DBCSCodec.prototype._getDecodeTrieNode = function(addr) {
|
|
4177
4285
|
var bytes2 = [];
|
|
4178
|
-
for (; addr > 0; addr >>>= 8)
|
|
4286
|
+
for (; addr > 0; addr >>>= 8) {
|
|
4179
4287
|
bytes2.push(addr & 255);
|
|
4180
|
-
|
|
4288
|
+
}
|
|
4289
|
+
if (bytes2.length == 0) {
|
|
4181
4290
|
bytes2.push(0);
|
|
4291
|
+
}
|
|
4182
4292
|
var node = this.decodeTables[0];
|
|
4183
4293
|
for (var i2 = bytes2.length - 1; i2 > 0; i2--) {
|
|
4184
4294
|
var val = node[bytes2[i2]];
|
|
@@ -4187,8 +4297,9 @@ function requireDbcsCodec() {
|
|
|
4187
4297
|
this.decodeTables.push(node = UNASSIGNED_NODE.slice(0));
|
|
4188
4298
|
} else if (val <= NODE_START) {
|
|
4189
4299
|
node = this.decodeTables[NODE_START - val];
|
|
4190
|
-
} else
|
|
4300
|
+
} else {
|
|
4191
4301
|
throw new Error("Overwrite byte in " + this.encodingName + ", addr: " + addr.toString(16));
|
|
4302
|
+
}
|
|
4192
4303
|
}
|
|
4193
4304
|
return node;
|
|
4194
4305
|
};
|
|
@@ -4201,45 +4312,53 @@ function requireDbcsCodec() {
|
|
|
4201
4312
|
if (typeof part === "string") {
|
|
4202
4313
|
for (var l = 0; l < part.length; ) {
|
|
4203
4314
|
var code = part.charCodeAt(l++);
|
|
4204
|
-
if (
|
|
4315
|
+
if (code >= 55296 && code < 56320) {
|
|
4205
4316
|
var codeTrail = part.charCodeAt(l++);
|
|
4206
|
-
if (
|
|
4317
|
+
if (codeTrail >= 56320 && codeTrail < 57344) {
|
|
4207
4318
|
writeTable[curAddr++] = 65536 + (code - 55296) * 1024 + (codeTrail - 56320);
|
|
4208
|
-
else
|
|
4319
|
+
} else {
|
|
4209
4320
|
throw new Error("Incorrect surrogate pair in " + this.encodingName + " at chunk " + chunk[0]);
|
|
4210
|
-
|
|
4321
|
+
}
|
|
4322
|
+
} else if (code > 4080 && code <= 4095) {
|
|
4211
4323
|
var len = 4095 - code + 2;
|
|
4212
4324
|
var seq = [];
|
|
4213
|
-
for (var m = 0; m < len; m++)
|
|
4325
|
+
for (var m = 0; m < len; m++) {
|
|
4214
4326
|
seq.push(part.charCodeAt(l++));
|
|
4327
|
+
}
|
|
4215
4328
|
writeTable[curAddr++] = SEQ_START - this.decodeTableSeq.length;
|
|
4216
4329
|
this.decodeTableSeq.push(seq);
|
|
4217
|
-
} else
|
|
4330
|
+
} else {
|
|
4218
4331
|
writeTable[curAddr++] = code;
|
|
4332
|
+
}
|
|
4219
4333
|
}
|
|
4220
4334
|
} else if (typeof part === "number") {
|
|
4221
4335
|
var charCode = writeTable[curAddr - 1] + 1;
|
|
4222
|
-
for (var l = 0; l < part; l++)
|
|
4336
|
+
for (var l = 0; l < part; l++) {
|
|
4223
4337
|
writeTable[curAddr++] = charCode++;
|
|
4224
|
-
|
|
4338
|
+
}
|
|
4339
|
+
} else {
|
|
4225
4340
|
throw new Error("Incorrect type '" + typeof part + "' given in " + this.encodingName + " at chunk " + chunk[0]);
|
|
4341
|
+
}
|
|
4226
4342
|
}
|
|
4227
|
-
if (curAddr > 255)
|
|
4343
|
+
if (curAddr > 255) {
|
|
4228
4344
|
throw new Error("Incorrect chunk in " + this.encodingName + " at addr " + chunk[0] + ": too long" + curAddr);
|
|
4345
|
+
}
|
|
4229
4346
|
};
|
|
4230
4347
|
DBCSCodec.prototype._getEncodeBucket = function(uCode) {
|
|
4231
4348
|
var high = uCode >> 8;
|
|
4232
|
-
if (this.encodeTable[high] === void 0)
|
|
4349
|
+
if (this.encodeTable[high] === void 0) {
|
|
4233
4350
|
this.encodeTable[high] = UNASSIGNED_NODE.slice(0);
|
|
4351
|
+
}
|
|
4234
4352
|
return this.encodeTable[high];
|
|
4235
4353
|
};
|
|
4236
4354
|
DBCSCodec.prototype._setEncodeChar = function(uCode, dbcsCode) {
|
|
4237
4355
|
var bucket = this._getEncodeBucket(uCode);
|
|
4238
4356
|
var low = uCode & 255;
|
|
4239
|
-
if (bucket[low] <= SEQ_START)
|
|
4357
|
+
if (bucket[low] <= SEQ_START) {
|
|
4240
4358
|
this.encodeTableSeq[SEQ_START - bucket[low]][DEF_CHAR] = dbcsCode;
|
|
4241
|
-
else if (bucket[low] == UNASSIGNED)
|
|
4359
|
+
} else if (bucket[low] == UNASSIGNED) {
|
|
4242
4360
|
bucket[low] = dbcsCode;
|
|
4361
|
+
}
|
|
4243
4362
|
};
|
|
4244
4363
|
DBCSCodec.prototype._setEncodeSequence = function(seq, dbcsCode) {
|
|
4245
4364
|
var uCode = seq[0];
|
|
@@ -4256,12 +4375,13 @@ function requireDbcsCodec() {
|
|
|
4256
4375
|
}
|
|
4257
4376
|
for (var j = 1; j < seq.length - 1; j++) {
|
|
4258
4377
|
var oldVal = node[uCode];
|
|
4259
|
-
if (typeof oldVal === "object")
|
|
4378
|
+
if (typeof oldVal === "object") {
|
|
4260
4379
|
node = oldVal;
|
|
4261
|
-
else {
|
|
4380
|
+
} else {
|
|
4262
4381
|
node = node[uCode] = {};
|
|
4263
|
-
if (oldVal !== void 0)
|
|
4382
|
+
if (oldVal !== void 0) {
|
|
4264
4383
|
node[DEF_CHAR] = oldVal;
|
|
4384
|
+
}
|
|
4265
4385
|
}
|
|
4266
4386
|
}
|
|
4267
4387
|
uCode = seq[seq.length - 1];
|
|
@@ -4274,8 +4394,9 @@ function requireDbcsCodec() {
|
|
|
4274
4394
|
for (var i2 = 0; i2 < 256; i2++) {
|
|
4275
4395
|
var uCode = node[i2];
|
|
4276
4396
|
var mbCode = prefix + i2;
|
|
4277
|
-
if (skipEncodeChars[mbCode])
|
|
4397
|
+
if (skipEncodeChars[mbCode]) {
|
|
4278
4398
|
continue;
|
|
4399
|
+
}
|
|
4279
4400
|
if (uCode >= 0) {
|
|
4280
4401
|
this._setEncodeChar(uCode, mbCode);
|
|
4281
4402
|
hasValues = true;
|
|
@@ -4283,10 +4404,11 @@ function requireDbcsCodec() {
|
|
|
4283
4404
|
var subNodeIdx = NODE_START - uCode;
|
|
4284
4405
|
if (!subNodeEmpty[subNodeIdx]) {
|
|
4285
4406
|
var newPrefix = mbCode << 8 >>> 0;
|
|
4286
|
-
if (this._fillEncodeTable(subNodeIdx, newPrefix, skipEncodeChars))
|
|
4407
|
+
if (this._fillEncodeTable(subNodeIdx, newPrefix, skipEncodeChars)) {
|
|
4287
4408
|
hasValues = true;
|
|
4288
|
-
else
|
|
4409
|
+
} else {
|
|
4289
4410
|
subNodeEmpty[subNodeIdx] = true;
|
|
4411
|
+
}
|
|
4290
4412
|
}
|
|
4291
4413
|
} else if (uCode <= SEQ_START) {
|
|
4292
4414
|
this._setEncodeSequence(this.decodeTableSeq[SEQ_START - uCode], mbCode);
|
|
@@ -4304,7 +4426,12 @@ function requireDbcsCodec() {
|
|
|
4304
4426
|
this.gb18030 = codec.gb18030;
|
|
4305
4427
|
}
|
|
4306
4428
|
DBCSEncoder.prototype.write = function(str) {
|
|
4307
|
-
var newBuf = Buffer2.alloc(str.length * (this.gb18030 ? 4 : 3))
|
|
4429
|
+
var newBuf = Buffer2.alloc(str.length * (this.gb18030 ? 4 : 3));
|
|
4430
|
+
var leadSurrogate = this.leadSurrogate;
|
|
4431
|
+
var seqObj = this.seqObj;
|
|
4432
|
+
var nextChar = -1;
|
|
4433
|
+
var i2 = 0;
|
|
4434
|
+
var j = 0;
|
|
4308
4435
|
while (true) {
|
|
4309
4436
|
if (nextChar === -1) {
|
|
4310
4437
|
if (i2 == str.length) break;
|
|
@@ -4313,7 +4440,7 @@ function requireDbcsCodec() {
|
|
|
4313
4440
|
var uCode = nextChar;
|
|
4314
4441
|
nextChar = -1;
|
|
4315
4442
|
}
|
|
4316
|
-
if (
|
|
4443
|
+
if (uCode >= 55296 && uCode < 57344) {
|
|
4317
4444
|
if (uCode < 56320) {
|
|
4318
4445
|
if (leadSurrogate === -1) {
|
|
4319
4446
|
leadSurrogate = uCode;
|
|
@@ -4341,7 +4468,7 @@ function requireDbcsCodec() {
|
|
|
4341
4468
|
if (typeof resCode === "object") {
|
|
4342
4469
|
seqObj = resCode;
|
|
4343
4470
|
continue;
|
|
4344
|
-
} else if (typeof resCode
|
|
4471
|
+
} else if (typeof resCode === "number") {
|
|
4345
4472
|
dbcsCode = resCode;
|
|
4346
4473
|
} else if (resCode == void 0) {
|
|
4347
4474
|
resCode = seqObj[DEF_CHAR];
|
|
@@ -4353,8 +4480,9 @@ function requireDbcsCodec() {
|
|
|
4353
4480
|
seqObj = void 0;
|
|
4354
4481
|
} else if (uCode >= 0) {
|
|
4355
4482
|
var subtable = this.encodeTable[uCode >> 8];
|
|
4356
|
-
if (subtable !== void 0)
|
|
4483
|
+
if (subtable !== void 0) {
|
|
4357
4484
|
dbcsCode = subtable[uCode & 255];
|
|
4485
|
+
}
|
|
4358
4486
|
if (dbcsCode <= SEQ_START) {
|
|
4359
4487
|
seqObj = this.encodeTableSeq[SEQ_START - dbcsCode];
|
|
4360
4488
|
continue;
|
|
@@ -4374,8 +4502,9 @@ function requireDbcsCodec() {
|
|
|
4374
4502
|
}
|
|
4375
4503
|
}
|
|
4376
4504
|
}
|
|
4377
|
-
if (dbcsCode === UNASSIGNED)
|
|
4505
|
+
if (dbcsCode === UNASSIGNED) {
|
|
4378
4506
|
dbcsCode = this.defaultCharSingleByte;
|
|
4507
|
+
}
|
|
4379
4508
|
if (dbcsCode < 256) {
|
|
4380
4509
|
newBuf[j++] = dbcsCode;
|
|
4381
4510
|
} else if (dbcsCode < 65536) {
|
|
@@ -4397,9 +4526,11 @@ function requireDbcsCodec() {
|
|
|
4397
4526
|
return newBuf.slice(0, j);
|
|
4398
4527
|
};
|
|
4399
4528
|
DBCSEncoder.prototype.end = function() {
|
|
4400
|
-
if (this.leadSurrogate === -1 && this.seqObj === void 0)
|
|
4529
|
+
if (this.leadSurrogate === -1 && this.seqObj === void 0) {
|
|
4401
4530
|
return;
|
|
4402
|
-
|
|
4531
|
+
}
|
|
4532
|
+
var newBuf = Buffer2.alloc(10);
|
|
4533
|
+
var j = 0;
|
|
4403
4534
|
if (this.seqObj) {
|
|
4404
4535
|
var dbcsCode = this.seqObj[DEF_CHAR];
|
|
4405
4536
|
if (dbcsCode !== void 0) {
|
|
@@ -4428,7 +4559,12 @@ function requireDbcsCodec() {
|
|
|
4428
4559
|
this.gb18030 = codec.gb18030;
|
|
4429
4560
|
}
|
|
4430
4561
|
DBCSDecoder.prototype.write = function(buf) {
|
|
4431
|
-
var newBuf = Buffer2.alloc(buf.length * 2)
|
|
4562
|
+
var newBuf = Buffer2.alloc(buf.length * 2);
|
|
4563
|
+
var nodeIdx = this.nodeIdx;
|
|
4564
|
+
var prevBytes = this.prevBytes;
|
|
4565
|
+
var prevOffset = this.prevBytes.length;
|
|
4566
|
+
var seqStart = -this.prevBytes.length;
|
|
4567
|
+
var uCode;
|
|
4432
4568
|
for (var i2 = 0, j = 0; i2 < buf.length; i2++) {
|
|
4433
4569
|
var curByte = i2 >= 0 ? buf[i2] : prevBytes[i2 + prevOffset];
|
|
4434
4570
|
var uCode = this.decodeTables[nodeIdx][curByte];
|
|
@@ -4455,8 +4591,9 @@ function requireDbcsCodec() {
|
|
|
4455
4591
|
newBuf[j++] = uCode >> 8;
|
|
4456
4592
|
}
|
|
4457
4593
|
uCode = seq[seq.length - 1];
|
|
4458
|
-
} else
|
|
4594
|
+
} else {
|
|
4459
4595
|
throw new Error("iconv-lite internal error: invalid decoding table value " + uCode + " at " + nodeIdx + "/" + curByte);
|
|
4596
|
+
}
|
|
4460
4597
|
if (uCode >= 65536) {
|
|
4461
4598
|
uCode -= 65536;
|
|
4462
4599
|
var uCodeLead = 55296 | uCode >> 10;
|
|
@@ -4480,23 +4617,27 @@ function requireDbcsCodec() {
|
|
|
4480
4617
|
var bytesArr = this.prevBytes.slice(1);
|
|
4481
4618
|
this.prevBytes = [];
|
|
4482
4619
|
this.nodeIdx = 0;
|
|
4483
|
-
if (bytesArr.length > 0)
|
|
4620
|
+
if (bytesArr.length > 0) {
|
|
4484
4621
|
ret += this.write(bytesArr);
|
|
4622
|
+
}
|
|
4485
4623
|
}
|
|
4486
4624
|
this.prevBytes = [];
|
|
4487
4625
|
this.nodeIdx = 0;
|
|
4488
4626
|
return ret;
|
|
4489
4627
|
};
|
|
4490
4628
|
function findIdx(table, val) {
|
|
4491
|
-
if (table[0] > val)
|
|
4629
|
+
if (table[0] > val) {
|
|
4492
4630
|
return -1;
|
|
4493
|
-
|
|
4631
|
+
}
|
|
4632
|
+
var l = 0;
|
|
4633
|
+
var r = table.length;
|
|
4494
4634
|
while (l < r - 1) {
|
|
4495
4635
|
var mid = l + (r - l + 1 >> 1);
|
|
4496
|
-
if (table[mid] <= val)
|
|
4636
|
+
if (table[mid] <= val) {
|
|
4497
4637
|
l = mid;
|
|
4498
|
-
else
|
|
4638
|
+
} else {
|
|
4499
4639
|
r = mid;
|
|
4640
|
+
}
|
|
4500
4641
|
}
|
|
4501
4642
|
return l;
|
|
4502
4643
|
}
|
|
@@ -5833,7 +5974,7 @@ function requireDbcsData() {
|
|
|
5833
5974
|
// == Japanese/ShiftJIS ====================================================
|
|
5834
5975
|
// All japanese encodings are based on JIS X set of standards:
|
|
5835
5976
|
// JIS X 0201 - Single-byte encoding of ASCII + ¥ + Kana chars at 0xA1-0xDF.
|
|
5836
|
-
// JIS X 0208 - Main set of 6879 characters, placed in 94x94 plane, to be encoded by 2 bytes.
|
|
5977
|
+
// JIS X 0208 - Main set of 6879 characters, placed in 94x94 plane, to be encoded by 2 bytes.
|
|
5837
5978
|
// Has several variations in 1978, 1983, 1990 and 1997.
|
|
5838
5979
|
// JIS X 0212 - Supplementary plane of 6067 chars in 94x94 plane. 1990. Effectively dead.
|
|
5839
5980
|
// JIS X 0213 - Extension and modern replacement of 0208 and 0212. Total chars: 11233.
|
|
@@ -5850,7 +5991,7 @@ function requireDbcsData() {
|
|
|
5850
5991
|
// 0x8F, (0xA1-0xFE)x2 - 0212 plane (94x94).
|
|
5851
5992
|
// * JIS X 208: 7-bit, direct encoding of 0208. Byte ranges: 0x21-0x7E (94 values). Uncommon.
|
|
5852
5993
|
// Used as-is in ISO2022 family.
|
|
5853
|
-
// * ISO2022-JP: Stateful encoding, with escape sequences to switch between ASCII,
|
|
5994
|
+
// * ISO2022-JP: Stateful encoding, with escape sequences to switch between ASCII,
|
|
5854
5995
|
// 0201-1976 Roman, 0208-1978, 0208-1983.
|
|
5855
5996
|
// * ISO2022-JP-1: Adds esc seq for 0212-1990.
|
|
5856
5997
|
// * ISO2022-JP-2: Adds esc seq for GB2313-1980, KSX1001-1992, ISO8859-1, ISO8859-7.
|
|
@@ -5860,7 +6001,7 @@ function requireDbcsData() {
|
|
|
5860
6001
|
// After JIS X 0213 appeared, Shift_JIS-2004, EUC-JISX0213 and ISO2022-JP-2004 followed, with just changing the planes.
|
|
5861
6002
|
//
|
|
5862
6003
|
// Overall, it seems that it's a mess :( http://www8.plala.or.jp/tkubota1/unicode-symbols-map2.html
|
|
5863
|
-
|
|
6004
|
+
shiftjis: {
|
|
5864
6005
|
type: "_dbcs",
|
|
5865
6006
|
table: function() {
|
|
5866
6007
|
return require$$0;
|
|
@@ -5868,17 +6009,17 @@ function requireDbcsData() {
|
|
|
5868
6009
|
encodeAdd: { "¥": 92, "‾": 126 },
|
|
5869
6010
|
encodeSkipVals: [{ from: 60736, to: 63808 }]
|
|
5870
6011
|
},
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
6012
|
+
csshiftjis: "shiftjis",
|
|
6013
|
+
mskanji: "shiftjis",
|
|
6014
|
+
sjis: "shiftjis",
|
|
6015
|
+
windows31j: "shiftjis",
|
|
6016
|
+
ms31j: "shiftjis",
|
|
6017
|
+
xsjis: "shiftjis",
|
|
6018
|
+
windows932: "shiftjis",
|
|
6019
|
+
ms932: "shiftjis",
|
|
6020
|
+
932: "shiftjis",
|
|
6021
|
+
cp932: "shiftjis",
|
|
6022
|
+
eucjp: {
|
|
5882
6023
|
type: "_dbcs",
|
|
5883
6024
|
table: function() {
|
|
5884
6025
|
return require$$1;
|
|
@@ -5892,37 +6033,37 @@ function requireDbcsData() {
|
|
|
5892
6033
|
// http://en.wikipedia.org/wiki/GBK
|
|
5893
6034
|
// We mostly implement W3C recommendation: https://www.w3.org/TR/encoding/#gbk-encoder
|
|
5894
6035
|
// Oldest GB2312 (1981, ~7600 chars) is a subset of CP936
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
6036
|
+
gb2312: "cp936",
|
|
6037
|
+
gb231280: "cp936",
|
|
6038
|
+
gb23121980: "cp936",
|
|
6039
|
+
csgb2312: "cp936",
|
|
6040
|
+
csiso58gb231280: "cp936",
|
|
6041
|
+
euccn: "cp936",
|
|
5901
6042
|
// Microsoft's CP936 is a subset and approximation of GBK.
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
6043
|
+
windows936: "cp936",
|
|
6044
|
+
ms936: "cp936",
|
|
6045
|
+
936: "cp936",
|
|
6046
|
+
cp936: {
|
|
5906
6047
|
type: "_dbcs",
|
|
5907
6048
|
table: function() {
|
|
5908
6049
|
return require$$2;
|
|
5909
6050
|
}
|
|
5910
6051
|
},
|
|
5911
6052
|
// GBK (~22000 chars) is an extension of CP936 that added user-mapped chars and some other.
|
|
5912
|
-
|
|
6053
|
+
gbk: {
|
|
5913
6054
|
type: "_dbcs",
|
|
5914
6055
|
table: function() {
|
|
5915
6056
|
return require$$2.concat(require$$3);
|
|
5916
6057
|
}
|
|
5917
6058
|
},
|
|
5918
|
-
|
|
5919
|
-
|
|
6059
|
+
xgbk: "gbk",
|
|
6060
|
+
isoir58: "gbk",
|
|
5920
6061
|
// GB18030 is an algorithmic extension of GBK.
|
|
5921
6062
|
// Main source: https://www.w3.org/TR/encoding/#gbk-encoder
|
|
5922
6063
|
// http://icu-project.org/docs/papers/gb18030.html
|
|
5923
6064
|
// http://source.icu-project.org/repos/icu/data/trunk/charset/data/xml/gb-18030-2000.xml
|
|
5924
6065
|
// http://www.khngai.com/chinese/charmap/tblgbk.php?page=0
|
|
5925
|
-
|
|
6066
|
+
gb18030: {
|
|
5926
6067
|
type: "_dbcs",
|
|
5927
6068
|
table: function() {
|
|
5928
6069
|
return require$$2.concat(require$$3);
|
|
@@ -5933,26 +6074,26 @@ function requireDbcsData() {
|
|
|
5933
6074
|
encodeSkipVals: [128],
|
|
5934
6075
|
encodeAdd: { "€": 41699 }
|
|
5935
6076
|
},
|
|
5936
|
-
|
|
6077
|
+
chinese: "gb18030",
|
|
5937
6078
|
// == Korean ===============================================================
|
|
5938
6079
|
// EUC-KR, KS_C_5601 and KS X 1001 are exactly the same.
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
6080
|
+
windows949: "cp949",
|
|
6081
|
+
ms949: "cp949",
|
|
6082
|
+
949: "cp949",
|
|
6083
|
+
cp949: {
|
|
5943
6084
|
type: "_dbcs",
|
|
5944
6085
|
table: function() {
|
|
5945
6086
|
return require$$5;
|
|
5946
6087
|
}
|
|
5947
6088
|
},
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
6089
|
+
cseuckr: "cp949",
|
|
6090
|
+
csksc56011987: "cp949",
|
|
6091
|
+
euckr: "cp949",
|
|
6092
|
+
isoir149: "cp949",
|
|
6093
|
+
korean: "cp949",
|
|
6094
|
+
ksc56011987: "cp949",
|
|
6095
|
+
ksc56011989: "cp949",
|
|
6096
|
+
ksc5601: "cp949",
|
|
5956
6097
|
// == Big5/Taiwan/Hong Kong ================================================
|
|
5957
6098
|
// There are lots of tables for Big5 and cp950. Please see the following links for history:
|
|
5958
6099
|
// http://moztw.org/docs/big5/ http://www.haible.de/bruno/charsets/conversion-tables/Big5.html
|
|
@@ -5961,7 +6102,7 @@ function requireDbcsData() {
|
|
|
5961
6102
|
// * Windows CP 951: Microsoft variant of Big5-HKSCS-2001. Seems to be never public. http://me.abelcheung.org/articles/research/what-is-cp951/
|
|
5962
6103
|
// * Big5-2003 (Taiwan standard) almost superset of cp950.
|
|
5963
6104
|
// * Unicode-at-on (UAO) / Mozilla 1.8. Falling out of use on the Web. Not supported by other browsers.
|
|
5964
|
-
// * Big5-HKSCS (-2001, -2004, -2008). Hong Kong standard.
|
|
6105
|
+
// * Big5-HKSCS (-2001, -2004, -2008). Hong Kong standard.
|
|
5965
6106
|
// many unicode code points moved from PUA to Supplementary plane (U+2XXXX) over the years.
|
|
5966
6107
|
// Plus, it has 4 combining sequences.
|
|
5967
6108
|
// Seems that Mozilla refused to support it for 10 yrs. https://bugzilla.mozilla.org/show_bug.cgi?id=162431 https://bugzilla.mozilla.org/show_bug.cgi?id=310299
|
|
@@ -5972,21 +6113,21 @@ function requireDbcsData() {
|
|
|
5972
6113
|
// In the encoder, it might make sense to support encoding old PUA mappings to Big5 bytes seq-s.
|
|
5973
6114
|
// Official spec: http://www.ogcio.gov.hk/en/business/tech_promotion/ccli/terms/doc/2003cmp_2008.txt
|
|
5974
6115
|
// http://www.ogcio.gov.hk/tc/business/tech_promotion/ccli/terms/doc/hkscs-2008-big5-iso.txt
|
|
5975
|
-
//
|
|
6116
|
+
//
|
|
5976
6117
|
// Current understanding of how to deal with Big5(-HKSCS) is in the Encoding Standard, http://encoding.spec.whatwg.org/#big5-encoder
|
|
5977
6118
|
// Unicode mapping (http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/OTHER/BIG5.TXT) is said to be wrong.
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
6119
|
+
windows950: "cp950",
|
|
6120
|
+
ms950: "cp950",
|
|
6121
|
+
950: "cp950",
|
|
6122
|
+
cp950: {
|
|
5982
6123
|
type: "_dbcs",
|
|
5983
6124
|
table: function() {
|
|
5984
6125
|
return require$$6;
|
|
5985
6126
|
}
|
|
5986
6127
|
},
|
|
5987
6128
|
// Big5 has many variations and is an extension of cp950. We use Encoding Standard's as a consensus.
|
|
5988
|
-
|
|
5989
|
-
|
|
6129
|
+
big5: "big5hkscs",
|
|
6130
|
+
big5hkscs: {
|
|
5990
6131
|
type: "_dbcs",
|
|
5991
6132
|
table: function() {
|
|
5992
6133
|
return require$$6.concat(require$$7);
|
|
@@ -6065,9 +6206,9 @@ function requireDbcsData() {
|
|
|
6065
6206
|
41678
|
|
6066
6207
|
]
|
|
6067
6208
|
},
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6209
|
+
cnbig5: "big5hkscs",
|
|
6210
|
+
csbig5: "big5hkscs",
|
|
6211
|
+
xxbig5: "big5hkscs"
|
|
6071
6212
|
};
|
|
6072
6213
|
return dbcsData;
|
|
6073
6214
|
}
|
|
@@ -6076,6 +6217,7 @@ function requireEncodings() {
|
|
|
6076
6217
|
if (hasRequiredEncodings) return encodings;
|
|
6077
6218
|
hasRequiredEncodings = 1;
|
|
6078
6219
|
(function(exports) {
|
|
6220
|
+
var mergeModules = requireMergeExports();
|
|
6079
6221
|
var modules = [
|
|
6080
6222
|
requireInternal(),
|
|
6081
6223
|
requireUtf32(),
|
|
@@ -6089,9 +6231,7 @@ function requireEncodings() {
|
|
|
6089
6231
|
];
|
|
6090
6232
|
for (var i = 0; i < modules.length; i++) {
|
|
6091
6233
|
var module = modules[i];
|
|
6092
|
-
|
|
6093
|
-
if (Object.prototype.hasOwnProperty.call(module, enc))
|
|
6094
|
-
exports[enc] = module[enc];
|
|
6234
|
+
mergeModules(exports, module);
|
|
6095
6235
|
}
|
|
6096
6236
|
})(encodings);
|
|
6097
6237
|
return encodings;
|
|
@@ -6102,8 +6242,8 @@ function requireStreams() {
|
|
|
6102
6242
|
if (hasRequiredStreams) return streams;
|
|
6103
6243
|
hasRequiredStreams = 1;
|
|
6104
6244
|
var Buffer2 = requireSafer().Buffer;
|
|
6105
|
-
streams = function(
|
|
6106
|
-
var Transform =
|
|
6245
|
+
streams = function(streamModule) {
|
|
6246
|
+
var Transform = streamModule.Transform;
|
|
6107
6247
|
function IconvLiteEncoderStream(conv, options) {
|
|
6108
6248
|
this.conv = conv;
|
|
6109
6249
|
options = options || {};
|
|
@@ -6114,8 +6254,9 @@ function requireStreams() {
|
|
|
6114
6254
|
constructor: { value: IconvLiteEncoderStream }
|
|
6115
6255
|
});
|
|
6116
6256
|
IconvLiteEncoderStream.prototype._transform = function(chunk, encoding, done) {
|
|
6117
|
-
if (typeof chunk
|
|
6257
|
+
if (typeof chunk !== "string") {
|
|
6118
6258
|
return done(new Error("Iconv encoding stream needs strings as its input."));
|
|
6259
|
+
}
|
|
6119
6260
|
try {
|
|
6120
6261
|
var res = this.conv.write(chunk);
|
|
6121
6262
|
if (res && res.length) this.push(res);
|
|
@@ -6154,8 +6295,9 @@ function requireStreams() {
|
|
|
6154
6295
|
constructor: { value: IconvLiteDecoderStream }
|
|
6155
6296
|
});
|
|
6156
6297
|
IconvLiteDecoderStream.prototype._transform = function(chunk, encoding, done) {
|
|
6157
|
-
if (!Buffer2.isBuffer(chunk) && !(chunk instanceof Uint8Array))
|
|
6298
|
+
if (!Buffer2.isBuffer(chunk) && !(chunk instanceof Uint8Array)) {
|
|
6158
6299
|
return done(new Error("Iconv decoding stream needs buffers as its input."));
|
|
6300
|
+
}
|
|
6159
6301
|
try {
|
|
6160
6302
|
var res = this.conv.write(chunk);
|
|
6161
6303
|
if (res && res.length) this.push(res, this.encoding);
|
|
@@ -6197,7 +6339,9 @@ function requireLib() {
|
|
|
6197
6339
|
hasRequiredLib = 1;
|
|
6198
6340
|
(function(module) {
|
|
6199
6341
|
var Buffer2 = requireSafer().Buffer;
|
|
6200
|
-
var bomHandling2 = requireBomHandling()
|
|
6342
|
+
var bomHandling2 = requireBomHandling();
|
|
6343
|
+
var mergeModules = requireMergeExports();
|
|
6344
|
+
var iconv = module.exports;
|
|
6201
6345
|
iconv.encodings = null;
|
|
6202
6346
|
iconv.defaultCharUnicode = "�";
|
|
6203
6347
|
iconv.defaultCharSingleByte = "?";
|
|
@@ -6231,31 +6375,38 @@ function requireLib() {
|
|
|
6231
6375
|
};
|
|
6232
6376
|
iconv.toEncoding = iconv.encode;
|
|
6233
6377
|
iconv.fromEncoding = iconv.decode;
|
|
6234
|
-
iconv._codecDataCache = {};
|
|
6378
|
+
iconv._codecDataCache = { __proto__: null };
|
|
6235
6379
|
iconv.getCodec = function getCodec(encoding) {
|
|
6236
|
-
if (!iconv.encodings)
|
|
6237
|
-
|
|
6380
|
+
if (!iconv.encodings) {
|
|
6381
|
+
var raw = requireEncodings();
|
|
6382
|
+
iconv.encodings = { __proto__: null };
|
|
6383
|
+
mergeModules(iconv.encodings, raw);
|
|
6384
|
+
}
|
|
6238
6385
|
var enc = iconv._canonicalizeEncoding(encoding);
|
|
6239
6386
|
var codecOptions = {};
|
|
6240
6387
|
while (true) {
|
|
6241
6388
|
var codec = iconv._codecDataCache[enc];
|
|
6242
|
-
if (codec)
|
|
6389
|
+
if (codec) {
|
|
6243
6390
|
return codec;
|
|
6391
|
+
}
|
|
6244
6392
|
var codecDef = iconv.encodings[enc];
|
|
6245
6393
|
switch (typeof codecDef) {
|
|
6246
6394
|
case "string":
|
|
6247
6395
|
enc = codecDef;
|
|
6248
6396
|
break;
|
|
6249
6397
|
case "object":
|
|
6250
|
-
for (var key in codecDef)
|
|
6398
|
+
for (var key in codecDef) {
|
|
6251
6399
|
codecOptions[key] = codecDef[key];
|
|
6252
|
-
|
|
6400
|
+
}
|
|
6401
|
+
if (!codecOptions.encodingName) {
|
|
6253
6402
|
codecOptions.encodingName = enc;
|
|
6403
|
+
}
|
|
6254
6404
|
enc = codecDef.type;
|
|
6255
6405
|
break;
|
|
6256
6406
|
case "function":
|
|
6257
|
-
if (!codecOptions.encodingName)
|
|
6407
|
+
if (!codecOptions.encodingName) {
|
|
6258
6408
|
codecOptions.encodingName = enc;
|
|
6409
|
+
}
|
|
6259
6410
|
codec = new codecDef(codecOptions, iconv);
|
|
6260
6411
|
iconv._codecDataCache[codecOptions.encodingName] = codec;
|
|
6261
6412
|
return codec;
|
|
@@ -6268,21 +6419,26 @@ function requireLib() {
|
|
|
6268
6419
|
return ("" + encoding).toLowerCase().replace(/:\d{4}$|[^0-9a-z]/g, "");
|
|
6269
6420
|
};
|
|
6270
6421
|
iconv.getEncoder = function getEncoder(encoding, options) {
|
|
6271
|
-
var codec = iconv.getCodec(encoding)
|
|
6272
|
-
|
|
6422
|
+
var codec = iconv.getCodec(encoding);
|
|
6423
|
+
var encoder = new codec.encoder(options, codec);
|
|
6424
|
+
if (codec.bomAware && options && options.addBOM) {
|
|
6273
6425
|
encoder = new bomHandling2.PrependBOM(encoder, options);
|
|
6426
|
+
}
|
|
6274
6427
|
return encoder;
|
|
6275
6428
|
};
|
|
6276
6429
|
iconv.getDecoder = function getDecoder(encoding, options) {
|
|
6277
|
-
var codec = iconv.getCodec(encoding)
|
|
6278
|
-
|
|
6430
|
+
var codec = iconv.getCodec(encoding);
|
|
6431
|
+
var decoder = new codec.decoder(options, codec);
|
|
6432
|
+
if (codec.bomAware && !(options && options.stripBOM === false)) {
|
|
6279
6433
|
decoder = new bomHandling2.StripBOM(decoder, options);
|
|
6434
|
+
}
|
|
6280
6435
|
return decoder;
|
|
6281
6436
|
};
|
|
6282
|
-
iconv.enableStreamingAPI = function enableStreamingAPI(
|
|
6283
|
-
if (iconv.supportsStreams)
|
|
6437
|
+
iconv.enableStreamingAPI = function enableStreamingAPI(streamModule2) {
|
|
6438
|
+
if (iconv.supportsStreams) {
|
|
6284
6439
|
return;
|
|
6285
|
-
|
|
6440
|
+
}
|
|
6441
|
+
var streams2 = requireStreams()(streamModule2);
|
|
6286
6442
|
iconv.IconvLiteEncoderStream = streams2.IconvLiteEncoderStream;
|
|
6287
6443
|
iconv.IconvLiteDecoderStream = streams2.IconvLiteDecoderStream;
|
|
6288
6444
|
iconv.encodeStream = function encodeStream(encoding, options) {
|
|
@@ -6293,13 +6449,13 @@ function requireLib() {
|
|
|
6293
6449
|
};
|
|
6294
6450
|
iconv.supportsStreams = true;
|
|
6295
6451
|
};
|
|
6296
|
-
var
|
|
6452
|
+
var streamModule;
|
|
6297
6453
|
try {
|
|
6298
|
-
|
|
6454
|
+
streamModule = require("stream");
|
|
6299
6455
|
} catch (e) {
|
|
6300
6456
|
}
|
|
6301
|
-
if (
|
|
6302
|
-
iconv.enableStreamingAPI(
|
|
6457
|
+
if (streamModule && streamModule.Transform) {
|
|
6458
|
+
iconv.enableStreamingAPI(streamModule);
|
|
6303
6459
|
} else {
|
|
6304
6460
|
iconv.encodeStream = iconv.decodeStream = function() {
|
|
6305
6461
|
throw new Error("iconv-lite Streaming API is not enabled. Use iconv.enableStreamingAPI(require('stream')); to enable it.");
|
|
@@ -6798,6 +6954,10 @@ class StreamableHTTPServerTransport {
|
|
|
6798
6954
|
res.on("close", () => {
|
|
6799
6955
|
this._streamMapping.delete(this._standaloneSseStreamId);
|
|
6800
6956
|
});
|
|
6957
|
+
res.on("error", (error) => {
|
|
6958
|
+
var _a;
|
|
6959
|
+
(_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
|
|
6960
|
+
});
|
|
6801
6961
|
}
|
|
6802
6962
|
/**
|
|
6803
6963
|
* Replays events that would have been sent after the specified event ID
|
|
@@ -6828,6 +6988,10 @@ class StreamableHTTPServerTransport {
|
|
|
6828
6988
|
}
|
|
6829
6989
|
}));
|
|
6830
6990
|
this._streamMapping.set(streamId, res);
|
|
6991
|
+
res.on("error", (error) => {
|
|
6992
|
+
var _a2;
|
|
6993
|
+
(_a2 = this.onerror) === null || _a2 === void 0 ? void 0 : _a2.call(this, error);
|
|
6994
|
+
});
|
|
6831
6995
|
} catch (error) {
|
|
6832
6996
|
(_b = this.onerror) === null || _b === void 0 ? void 0 : _b.call(this, error);
|
|
6833
6997
|
}
|
|
@@ -6852,7 +7016,7 @@ class StreamableHTTPServerTransport {
|
|
|
6852
7016
|
*/
|
|
6853
7017
|
async handleUnsupportedRequest(res) {
|
|
6854
7018
|
res.writeHead(405, {
|
|
6855
|
-
|
|
7019
|
+
Allow: "GET, POST, DELETE"
|
|
6856
7020
|
}).end(JSON.stringify({
|
|
6857
7021
|
jsonrpc: "2.0",
|
|
6858
7022
|
error: {
|
|
@@ -6977,6 +7141,10 @@ class StreamableHTTPServerTransport {
|
|
|
6977
7141
|
res.on("close", () => {
|
|
6978
7142
|
this._streamMapping.delete(streamId);
|
|
6979
7143
|
});
|
|
7144
|
+
res.on("error", (error) => {
|
|
7145
|
+
var _a2;
|
|
7146
|
+
(_a2 = this.onerror) === null || _a2 === void 0 ? void 0 : _a2.call(this, error);
|
|
7147
|
+
});
|
|
6980
7148
|
for (const message of messages) {
|
|
6981
7149
|
(_d = this.onmessage) === null || _d === void 0 ? void 0 : _d.call(this, message, { authInfo, requestInfo });
|
|
6982
7150
|
}
|